Compare commits

...
1128 Commits
Author SHA1 Message Date
Denys Vlasenko 8cbc300d08 ash: fix compile breakage
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-08 03:18:51 +02:00
Denys Vlasenko 6f01ccffc2 bump version to 1.15.2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-08 03:06:39 +02:00
Denys Vlasenko 4ac9819263 apply post-1.15.1 fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-10-08 03:06:04 +02:00
Denys Vlasenko 5b807cd5ac test: use index_in_strings
function                                             old     new   delta
ops_texts                                              -     124    +124
ops_table                                              -      80     +80
display_process_list                                1447    1448      +1
binop                                                525     523      -2
static.no_op                                           6       2      -4
check_operator                                        71      63      -8
ops                                                  240       -    -240
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/3 up/down: 205/-254)          Total: -49 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-12 22:38:26 +02:00
Denys Vlasenko d7686c8c2c Apply post-1.15.0 fixes; bump version to 1.15.1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-09-12 17:57:19 +02:00
Denys Vlasenko e7aa0d9eca Releasing 1.15.0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-23 02:33:20 +02:00
Matthijs van de Water 0d5866624d wget: strip trailing whitespace from e.g. "Content-length: 120 "
function                                             old     new   delta
wget_main                                           2395    2427     +32

Signed-off-by: Matthijs van de Water <matthijs.van.de.water@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-22 20:19:48 +02:00
Denys Vlasenko 0da1c0a732 beep: optimize
function                                             old     new   delta
beep_main                                            394     276    -118

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-22 18:00:39 +02:00
Denys Vlasenko dc3d8939d4 preliminary work for gcc 4.4.0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-22 02:34:10 +02:00
Denys Vlasenko f2a8d5db9a fix duplicate FAST_FUNC FAST_FUNC
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-21 17:40:36 +02:00
Bernhard Reutner-Fischer 00ea82e846 add config knob for default freq and length
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2009-08-21 14:40:29 +02:00
Bernhard Reutner-Fischer 45de0746b3 add simple beep applet
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2009-08-21 13:18:31 +02:00
Denys Vlasenko e10db56aa3 update defconfig
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-21 00:16:01 +02:00
Denys Vlasenko 1cc4b13917 msh: aliased to hush
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-21 00:05:51 +02:00
Denys Vlasenko 263cff9a2f do not store 1st two bytes of compressed help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-20 23:34:01 +02:00
Denys Vlasenko d7874ed1d4 patch: support -N. By Olivier Duclos (olivier.duclos AT gmail.com)
function                                             old     new   delta
packed_usage                                       26646   26656     +10
patch_main                                          1101    1110      +9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-20 23:33:19 +02:00
Denys Vlasenko 0793491ff8 hush: enable "lash is deprecated, please use hush instead" message
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-20 03:40:04 +02:00
Denys Vlasenko a67a9627d0 hush: do not process options after non-option args
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-20 03:38:58 +02:00
Denys Vlasenko ffc39202aa ash: fix bug 571 (jobs %string misbehaving)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-17 02:12:20 +02:00
Denys Vlasenko f210cff601 sed: fix " echo /usr/lib | sed 's,\(^/\|\)[^/][^/]*,..,g' " bug
function                                             old     new   delta
process_files                                       2102    2091     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-17 01:35:04 +02:00
Denys Vlasenko 16d1e3c26f pgrep: match argv[0] too, not only comm; fix a bug in argv sanitization
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-14 22:33:10 +02:00
Denys Vlasenko 5da42fce51 modprobe: treat tabs in modules.dep as delimiters too. closes bug 567
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-14 02:10:54 +02:00
Denys Vlasenko 007c6fc677 typo fix in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-14 01:36:28 +02:00
Justin Maggard aa369e0f0d udhcpc: if got IP successfully, disable -n for future renewals
Signed-off-by: Justin Maggard <jmaggard10@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-13 01:26:17 +02:00
Matthew Stoltenberg 4803db53b8 volname: new applet
function                                             old     new   delta
volname_main                                           -      90     +90
packed_usage                                       26373   26387     +14
applet_names                                        2078    2086      +8
applet_main                                         1232    1236      +4
applet_nameofs                                       616     618      +2
applet_install_loc                                   154     155      +1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/0 up/down: 119/0)             Total: 119 bytes

Signed-off-by: Matthew Stoltenberg <d3matt@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-13 00:59:32 +02:00
Denys Vlasenko dbfa45b3b2 hust test: complain if busybox binary can't be found
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-12 21:24:29 +02:00
Denys Vlasenko cbfe6ad4c6 hush: fix \<newline> handling on NOMMU
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-12 19:47:44 +02:00
Denys Vlasenko 19679784c0 hush tests: remove the requirement that .config is in ../..
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-12 14:53:44 +02:00
Denys Vlasenko 09516066d4 hush: do not use ps -o in leak_argv1; do not hardcode path in negate
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-12 14:21:30 +02:00
Denys Vlasenko 79b021d738 tail: read only a portion of a file if it's huge. closes bug 551
function                                             old     new   delta
tail_main                                           1494    1526     +32
tail_read                                            125     129      +4

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-10 03:16:18 +02:00
Denys Vlasenko e531759ef1 fdisk: add handling of avr32. closes bug 555
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-10 00:08:35 +02:00
Denys Vlasenko a43df64eec tail: fix "tail +N file_shorter_than_N"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-09 22:06:56 +02:00
Denys Vlasenko 0568b6e45a randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-08 03:20:12 +02:00
Denys Vlasenko 334fcc8fd4 dd: conv=noerror should skip read errors using lseek (bug 539)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-05 23:16:27 +02:00
Denys Vlasenko eecbb547d2 correct mode of testsuite/rx.tests
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-03 10:36:58 +02:00
Tomoya Adachi 63416cc57d nc: fix nc -ll; report vfork errors; make select loop faster
function                                             old     new   delta
nc_main                                              933     946     +13

Signed-off-by: Tomoya Adachi <adachi@il.is.s.u-tokyo.ac.jp>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-03 02:59:22 +02:00
Denys Vlasenko dc9495df03 rx: strip padding from last block. closes bug 501.
function                                             old     new   delta
rx_main                                              876     974     +98

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-02 19:45:31 +02:00
Earl Chew 80a3418b8c runsv: run ./finish with parameters (runit compat)
function                                             old     new   delta
startservice                                         288     377     +89
runsv_main                                          1763    1783     +20

Signed-off-by: Earl Chew <earl_chew@agilent.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-02 02:23:27 +02:00
Denys Vlasenko aebb742939 svlogd: fix bug 521: use line buffering if any filtering is done
function                                             old     new   delta
logdirs_reopen                                      1296    1310     +14
svlogd_main                                         1439    1444      +5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-02 00:55:49 +02:00
Denys Vlasenko e2944af43e libbb: prevent resursion on malloc failure
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-08-01 06:53:03 +02:00
Denys Vlasenko 6d48d3ee2a rename _BB_SUID_ALWAYS and NEVER into REQUIRE and DROP. No code changes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-30 12:57:19 +02:00
Denys Vlasenko be116490d6 ping6: make it setuid just like ping
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-30 12:42:16 +02:00
Alexander Shishkin e766f62132 make find_pid_by_name look at /proc/PID/exe too
function                                             old     new   delta
procps_scan                                         1642    1709     +67
find_pid_by_name                                     193     223     +30
free_procps_scan                                      29      37      +8

Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-29 01:35:13 +02:00
Denys Vlasenko 09449630fb grep: fix -E + {range}; fix -o not printing all matches (bug 489)
two different bugs, one with EXTRA_COMPAT, other without.

function                                             old     new   delta
grep_file                                           1132    1129      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-29 01:20:09 +02:00
Alexander Shishkin 97af2ff8ca halt/reboot/poweroff: add a CONFIG_xxx to act SysV compatibly
Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-27 02:55:02 +02:00
Denys Vlasenko d1090c91cc dpkg: delete postrm script after it's run, not before. closes bug 449
function                                             old     new   delta
purge_package                                        220     252     +32

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-25 11:52:32 +02:00
Stefani Seibold f3b56b428f unzip: try lseek before resorting to reading
function                                             old     new   delta
unzip_skip                                            16      43     +27

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-25 02:02:22 +02:00
Denys Vlasenko bac9f03ed8 tftp: add comment, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-25 01:56:23 +02:00
Atsushi Nemoto 330d898e99 tftp[d]: fix block# handling on upload with non-default blocksize
function                                             old     new   delta
tftp_protocol                                       1590    1618     +28

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-24 22:34:47 +02:00
Denys Vlasenko 0e1b626b9a man: use man.config, not only man.conf (man version 1.6f compat)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-24 02:28:12 +02:00
Denys Vlasenko 7cee00e8ae ash: further fixes to debug machinery (closes bug 485)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-24 01:08:03 +02:00
Denys Vlasenko e56f22ac60 ash: make "jobs" work even in subshells
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-24 00:16:59 +02:00
Denys Vlasenko 86e83ec487 ash: fix debug machinery a bit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-23 22:07:07 +02:00
Denys Vlasenko 7cc5a50465 chmod 755 some files in examples/*
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-23 21:30:30 +02:00
Eric Lammerts 3b5a664440 tail: implement -F
function                                             old     new   delta
tail_main                                           1190    1494    +304

Signed-off-by: Eric Lammerts <busybox@lists.lammerts.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-22 00:31:27 +02:00
Denys Vlasenko 997538ab58 scriptreplay: show help text if run with no arguments
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-19 23:11:45 +02:00
Denys Vlasenko d6513cff17 tcpsvd,udpsvd: fix uid/gid printing when run with -u
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-19 23:07:13 +02:00
Denys Vlasenko 3ed181b7ac init: make comment more understandable. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-19 14:29:18 +02:00
Denys Vlasenko 4abfc2642d udhcpc: small simplification
function                                             old     new   delta
udhcpc_main                                         2401    2398      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-19 04:35:16 +02:00
Denys Vlasenko 753a3ce73e typo
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-19 04:27:10 +02:00
Denys Vlasenko 7d6a791ef6 udhcpc: add/edit comments, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-19 04:24:23 +02:00
Denys Vlasenko 13ca4b12e2 udhcpc: simplify manual renew (make it more similar to automatic one)
function                                             old     new   delta
udhcp_run_script                                     669     673      +4
udhcpc_main                                         2414    2401     -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-13)              Total: -9 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-19 04:07:21 +02:00
Denys Vlasenko 252ccba948 remove msh_function.patch. msh is deprecated
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-19 01:09:42 +02:00
Denys Vlasenko e414896f38 silly whitespace fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18 17:26:25 +02:00
Denys Vlasenko c1fc3d3000 fix mount test false positive
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18 17:22:03 +02:00
Denys Vlasenko 875f782b12 minor tweaks in testsuite
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18 16:34:01 +02:00
Denys Vlasenko 6ae6426a74 fix mountpoint test to not prevemt mkfs_xxx from making image in any file
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18 16:22:26 +02:00
Denys Vlasenko b71ce023e9 add SKIP_KNOWN_BUGS and SKIP_INTERNET_TESTS to testsuite
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18 15:19:41 +02:00
Denys Vlasenko f8e6b6eccb fix taskset testsuite
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18 13:08:49 +02:00
Denys Vlasenko 941990f0c5 correct date testsuite to use compatible format
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18 04:54:21 +02:00
Denys Vlasenko 38dd8aa657 touch: implement -t TIME (needed for testsuite)
This changes date -d TIME format a bit, makes it more compatible

function                                             old     new   delta
parse_datestr                                        391     618    +227
touch_main                                           360     361      +1
packed_usage                                       26624   26615      -9

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18 04:49:20 +02:00
Denys Vlasenko 7aca89a7a3 touch: implement -d --date (our own testsuite needs that)
function                                             old     new   delta
static.uname_longopts                                  -     137    +137
touch_main                                           231     360    +129
static.touch_longopts                                  -      32     +32
validate_tm_time                                       -      28     +28
packed_usage                                       26616   26624      +8
date_main                                            687     686      -1
static.longopts                                      162       -    -162
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 2/1 up/down: 334/-163)          Total: 171 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18 03:41:29 +02:00
Denys Vlasenko 73b71f381d date: factor out date parsing (in preparation for touch -d)
function                                             old     new   delta
parse_datestr                                          -     391    +391
sha512_process_block128                             1283    1310     +27
buffer_fill_and_print                                179     196     +17
nexpr                                                826     840     +14
unzip_main                                          1931    1939      +8
popstring                                            134     140      +6
qrealloc                                              33      36      +3
builtin_umask                                        121     123      +2
evalvar                                             1365    1363      -2
changepath                                           194     192      -2
do_compress                                         1698    1688     -10
hwclock_main                                         340     329     -11
cmdputs                                              414     402     -12
identify                                            4343    4329     -14
date_main                                           1186     687    -499
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 7/7 up/down: 468/-550)          Total: -82 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-18 03:40:35 +02:00
Denys Vlasenko d23f64eba7 test: fix "test !" and "test abc -a !". closes bug 465
function                                             old     new   delta
nexpr                                                826     840     +14

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-17 00:59:26 +02:00
Denys Vlasenko fff73641e4 widen "Unicode in environment" check
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-16 16:09:25 +02:00
Denys Vlasenko 9531f7dad7 another small lineedit fix
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-16 14:33:16 +02:00
Denys Vlasenko 5c2e81bb67 fix a thinko in lineedit completion code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-16 14:14:34 +02:00
Denys Vlasenko 01ba1676af lineedit+unicode: code shrink
function                                             old     new   delta
wcrtomb_internal                                     161      83     -78

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-16 03:06:22 +02:00
Denys Vlasenko f6106e6041 comment fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-16 02:27:04 +02:00
Denys Vlasenko 53fd1bf223 lineedit: code shrink
function                                             old     new   delta
collapse_pos                                           -      77     +77
read_line_input                                     4755    4757      +2
add_quote_for_spec_chars                              75      71      -4
find_match                                          1283     892    -391

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-16 02:19:39 +02:00
Denys Vlasenko 9038d6f8f5 remove trailing whitespace
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-15 20:02:19 +02:00
Denys Vlasenko 7dd0ce4953 randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-15 18:27:47 +02:00
Denys Vlasenko 0ad438b12a comment fix, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-15 02:14:15 +02:00
Denys Vlasenko 3b405437b8 busybox --install [-s] [DIR]: allow a parameter - destination DIR
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-15 00:35:34 +02:00
Denys Vlasenko b3ba9e28e8 sv: fix "sv o SRV; ...; sv d SRV" (bug 461) + code shrink
function                                             old     new   delta
status                                               120     118      -2
control                                              159     126     -33
sv_main                                             1222    1183     -39

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-15 00:24:08 +02:00
Denys Vlasenko e46601d8a3 runsv: rename field in a struct to not collide with other name
no code changes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-15 00:21:49 +02:00
Denys Vlasenko 8e96b5b531 sed: simpler fix for recent GNU compat stuff (by Rob Landley)
function                                             old     new   delta
process_files                                       2120    2102     -18

Signed-off-by: Rob Landley <rob@landley.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-14 01:02:57 +02:00
Denys Vlasenko 2907e79749 add comment about /etc/gshadow, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-13 01:27:47 +02:00
Denys Vlasenko 189f74d0f2 passwd + /etc/shadow: chage "change time" field too
function                                             old     new   delta
update_passwd                                       1171    1270     +99

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-13 01:15:30 +02:00
Denys Vlasenko 044b18083b lineedit+unicode: make TAB completion work again
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-12 02:50:35 +02:00
Denys Vlasenko 1302892a14 vi: small code shrink
function                                             old     new   delta
vi_word_motion                                       185     165     -20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-12 00:51:15 +02:00
Denys Vlasenko fda8f57360 tweaking Unicode support
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-11 22:26:48 +02:00
Denys Vlasenko 42a8fd0db0 added simplified Unicode support for non-locale-enabled builds
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-11 21:36:13 +02:00
Denys Vlasenko 883cea4751 ash: fixes in debug printouts
Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-11 15:31:59 +02:00
Denys Vlasenko 2e6d4ef695 lineedit: implement Unicode-aware line editing (optional)
When off:

function                                             old     new   delta
input_delete                                         133     140      +7
vi_word_motion                                       236     240      +4
vi_Back_motion                                        89      92      +3
vi_end_motion                                        223     225      +2
cmdedit_set_out_char                                  74      76      +2
vi_back_motion                                       198     199      +1
vi_Word_motion                                        87      88      +1
vi_End_motion                                         92      86      -6
read_line_input                                     6293    6270     -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/2 up/down: 20/-29)             Total: -9 bytes

When on:

lineedit_read_key                                    146     272    +126
BB_PUTCHAR                                             -      94     +94
read_line_input                                     6293    6351     +58
save_string                                            -      43     +43
wcstombs                                               -      38     +38
mbstowcs                                               -      38     +38
save_command_ps_at_cur_history                        65      93     +28
input_delete                                         133     148     +15
vi_Back_motion                                        89      90      +1
vi_Word_motion                                        87      86      -1
cmdedit_set_out_char                                  74      73      -1
vi_End_motion                                         92      84      -8
vi_back_motion                                       198     187     -11
vi_word_motion                                       236     206     -30
vi_end_motion                                        223     184     -39
------------------------------------------------------------------------------
(add/remove: 4/0 grow/shrink: 5/6 up/down: 441/-90)           Total: 351 bytes

There is one TODO and maybe some bugs :)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-10 18:40:49 +02:00
Denys Vlasenko 860d2bbdda fix fallout from BSD patches
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-10 18:37:06 +02:00
Denys Vlasenko 874201fee5 dmesg: try to detect buffer size
function                                             old     new   delta
dmesg_main                                           214     246     +32

Signed-off-by: Randy Robertson <rmrobert@vmware.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-10 14:14:14 +02:00
Denys Vlasenko ae68f1133f sed: deal with peculiar behavior of '2d;2,1p' in GNU sed
function                                             old     new   delta
process_files                                       2173    2120     -53

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-10 11:55:20 +02:00
Mike Frysinger 52a426744e restore shadow.h independence
Commit ee5dce3365 made busybox require shadow.h from the toolchain even
if the config opted for the internal busybox implementation.  This makes
building with toolchains that lack shadow support impossible.  Since the
merge only saved us from duplicating a simple structure (whose ABI isn't
going to ever change), restore the logic for complete busybox shadow
independence by reverting that previous commit slightly.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-07-09 01:35:29 -04:00
Mike Frysinger 4c8a721b45 depmod.pl: recurse through module dependencies
The previous fix up loaded dependencies two deep, but really that was an
incomplete fix as we need to load dependencies all the way down.  So change
the code to run recursively through all dependencies.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-07-09 00:28:48 -04:00
Denys Vlasenko b773f715d6 tar: handle 256-base encoding in mtime
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-08 18:58:09 +02:00
Denys Vlasenko da49f58524 move libc related stuff out of platform.h
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-08 02:58:38 +02:00
Denys Vlasenko 95cc814dbd udhcpd: fix a bug in add_lease where it was reading at [-1]
It is not correct when we read lease file!

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-07 14:59:30 +02:00
Denys Vlasenko a51543a3a4 reformime: small code and style fixes. no material changes in behavior.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-07 07:52:34 +02:00
Denys Vlasenko 7e7e08fb09 tweak MD5 config text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-06 23:24:20 +02:00
Denys Vlasenko 57dc5345e2 pgrep/pkill: support -s and -P options
function                                             old     new   delta
pgrep_main                                           510     580     +70
packed_usage                                       26575   26616     +41
act                                                  234     236      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 113/0)             Total: 113 bytes

Signed-off-by: Rob Landley <rob@landley.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-06 00:00:12 +02:00
Denys Vlasenko 666e1d3978 tweak sendmail and makemime help texts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-05 21:46:37 +02:00
Denys Vlasenko fe4ef36bcd libbb/sha: #undef macro names before #defining them.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-05 20:34:38 +02:00
Denys Vlasenko 6f58be0748 cp: make "non-POSIX" cp a bit more consistent
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-05 13:24:17 +02:00
Denys Vlasenko 2d7b5bfa9b cp: by popular demand, make it POSIX compliant (but less safe)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-05 12:49:29 +02:00
Denys Vlasenko 09e63bb81f df: fix "df /"
also, clean up mount checks in mkfs/fsck.

function                                             old     new   delta
find_mount_point                                     243     261     +18
sha1_process_block64                                 497     510     +13
find_main                                            436     444      +8
display_speed                                         85      90      +5
df_main                                              795     793      -2
parse_command                                       1463    1460      -3
static.ignored_mounts                                  8       -      -8
mkfs_minix_main                                     2962    2937     -25
fsck_minix_main                                     3065    2970     -95
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 4/4 up/down: 44/-133)           Total: -89 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-05 04:50:36 +02:00
Denys Vlasenko 9b1b62adc4 Patches to enable FreeBSD build
platform.h: fix wrong check for endianness, fix lchown
aliasing to chown on uclibc.

Code seems to not be affected in my testing.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-05 03:34:12 +02:00
Denys Vlasenko b22bbfffec fix dependencies of FEATURE_GETOPT_LONG
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-04 16:50:43 +02:00
Denys Vlasenko fca70a8cce ps: conditionally support additional -o FIELDs
function                                             old     new   delta
procps_scan                                         1409    1642    +233
out_spec                                             220     300     +80
func_ruser                                             -      36     +36
func_rgroup                                            -      36     +36
func_group                                            13      49     +36
func_nice                                              -      29     +29
buffer_fill_and_print                                179     196     +17
send_tree                                            355     360      +5
mkfs_vfat_main                                      1604    1609      +5
display_speed                                         85      90      +5
scriptreplay_main                                    194     197      +3
find_out_spec                                         55      58      +3
changepath                                           192     195      +3
sha1_process_block64                                 497     484     -13
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 10/1 up/down: 491/-13)          Total: 478 bytes

Signed-off-by: David Krakov <krakov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-03 22:16:17 +02:00
Denys Vlasenko c5d07fba29 svlogd: do not overrun read buffer (fixes bug 439)
function                                             old     new   delta
rotate                                               513     534     +21
logdirs_reopen                                      1291    1296      +5
processorstart                                       409     385     -24

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-03 18:31:23 +02:00
Denys Vlasenko 97ef65483a udhcpc: support option 0x79 (static routes) (part of bug 341)
function                                             old     new   delta
xmalloc_optname_optval                                 -     583    +583
dhcp_option_strings                                  258     266      +8
dhcp_options                                          70      72      +2
len_of_option_as_string                               11      12      +1
dhcp_option_lengths                                   11      12      +1
udhcp_run_script                                    1187     669    -518
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/1 up/down: 595/-518)           Total: 77 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-03 18:14:03 +02:00
Denys Vlasenko 7895b91743 udhcp: dname_dec may return NULL, account for that case
Other random cleanips included...

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-03 16:59:59 +02:00
Denys Vlasenko c3b6f2c7e1 Merge branch 'master' of git+ssh://vda@busybox.net/var/lib/git/busybox 2009-07-03 16:59:37 +02:00
Denys Vlasenko ae05dd42ca ls: make --color more compatible with coreutils
function                                             old     new   delta
static.color_str                                       -      34     +34
static.ls_longopts                                     -       9      +9
ls_color_opt                                           9       -      -9
ls_main                                              865     843     -22
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/1 up/down: 43/-31)             Total: 12 bytes
   text    data     bss     dec     hex filename
 820145     450    7692  828287   ca37f busybox_old
 820144     450    7692  828286   ca37e busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-03 12:22:19 +02:00
Bernhard Reutner-Fischer 86e992da84 test commit
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2009-07-03 01:19:49 +02:00
Bernhard Reutner-Fischer ec97062b20 test commit
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2009-07-03 01:15:54 +02:00
Bernhard Reutner-Fischer ca4f8d54e5 test commit
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2009-07-03 01:06:15 +02:00
Denys Vlasenko 5508363fd0 ls: fix --color handling. Closes bug 435.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-02 14:25:51 +02:00
Denys Vlasenko 5478aaf5b8 mdev: be more permissive on errors (dont die): mdev -s users want that
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-02 13:17:10 +02:00
Denys Vlasenko 90db359972 mdev: set $MDEV correctly for renamed nodes
function                                             old     new   delta
make_device                                         1467    1502     +35
build_alias                                           78       -     -78

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-02 13:07:11 +02:00
Denys Vlasenko cf4e503875 Added kernel patch for /proc/self/exe to examples
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-07-02 12:04:50 +02:00
Denys Vlasenko 7d5ddf14a3 wget: remove IPv6 scope id in Host: field (apache compat)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-30 20:36:27 +02:00
Denys Vlasenko 8bca3e20b9 sed: fix handling of 1d;1,3p and 1d;1,REGEXp
function                                             old     new   delta
process_files                                       2084    2173     +89

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-30 19:19:37 +02:00
Denys Vlasenko f1fab09242 wget: fix redirection from HTTP to FTP server
while at it, sanitize redirection in general; add printout
of every redirection hop; make sure we won't print any non-ASCII
garbage from remote server in error meesages.

function                                             old     new   delta
sanitize_string                                        -      14     +14
parse_url                                            294     301      +7
gethdr                                               190     197      +7
wget_main                                           2326    2331      +5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 33/0)               Total: 33 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-28 03:33:57 +02:00
Denys Vlasenko ab0c8d7b35 wget: remove strange *&var construct.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-28 01:23:35 +02:00
Denys Vlasenko 7f43280420 wget: code shrink by splitting main() into easier-to-optimize functions
function                                             old     new   delta
retrieve_file_data                                     -     356    +356
wget_main                                           2793    2326    -467
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 356/-467)         Total: -111 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-28 01:02:24 +02:00
Denys Vlasenko 1881ba48b1 Update a comment, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-27 22:09:28 +02:00
Denys Vlasenko 4fc5ec56f9 device matching against UUIDs: do not try floppies
function                                             old     new   delta
uuidcache_check_device                               255     292     +37

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-27 21:58:25 +02:00
Denys Vlasenko eb1cda2f2d trylink: don't use ld --gc-sections if ld doesn't support it
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-27 00:24:35 +02:00
Denys Vlasenko 7e6034309e printf: (allegedly) fix testsuite failure
Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-27 00:07:23 +02:00
Denys Vlasenko 4248c33a85 udhcpc: fix a read error loop (e.g.: device is down) blocking TERM
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-26 23:23:16 +02:00
Denys Vlasenko d30b89c7ee updates for supporting Linux kernel build and initrd utilities
cpio: --verbose, --quiet, --to-stdout
test: make 64-bit math enable-able for hush too
dnsdomainname: alias to hostname -d
hostname: support --fqdn, --domain, --file

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-26 01:55:45 +02:00
Denys Vlasenko 2f86ca1350 mdev: fix the case when move rule deletes node with name == device_name
Signed-off-by: Jean Wolter <jw5@os.inf.tu-dresden.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-22 01:31:12 +02:00
Denys Vlasenko b0bee2b0da trim/regularize usage texts. -92 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-20 03:59:02 +02:00
Denys Vlasenko 7a76eba1f6 udhcp: fix trivial compile error
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-19 13:51:29 +02:00
Denys Vlasenko 8e5d83b6c1 mkswap: remove configuration for v0 support
mkswap hasn't had v0 support since commit
d893b120bae5a9bdef4cfda2df5e62867d6b1cd0; it doesn't seem to make sense
to offer it for configuration.

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-19 13:45:01 +02:00
Denys Vlasenko beca96ffa7 mkswap: separate UUID feature
Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-19 13:14:48 +02:00
Denys Vlasenko f3b92d3856 getopt: FEATURE_GETOPT_LONG for -l; rename GETOPT_LONG to LONG_OPTS
Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-19 12:10:38 +02:00
Denys Vlasenko e2e4cc249d mount: support -i; pass through -f and -n to helpers as necessary
function                                             old     new   delta
mount_it_now                                         298     345     +47
singlemount                                          776     772      -4

Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-19 11:48:29 +02:00
Denys Vlasenko b96159d663 mkswap: accidentally committed wrong patch. fix it up
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-19 11:00:52 +02:00
Denys Vlasenko e1e2273076 mkswap: improve randomness of UUID generation set version/variant bits
function                                             old     new   delta
mkswap_main                                          317     410     +93

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-19 09:49:01 +02:00
Denys Vlasenko bf4aeed129 printf: fix exit code on conversion error
Signed-off-by: Colin Watson <cjwatson@ubuntu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-18 22:22:04 +02:00
Denys Vlasenko c9f280cc46 mkswap: generate UUID if CONFIG_DESKTOP=y. +110 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-18 21:55:47 +02:00
Denys Vlasenko 2207cd6e14 tweak to config wording, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-18 19:59:51 +02:00
Denys Vlasenko bcbd37df24 tweak Config texts and some broken English elsewhere
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-18 13:23:58 +02:00
Denys Vlasenko 14f6f0ad4a fsync: new applet by Pekka Pessi (Pekka.Pessi AT nokia.com)
function                                             old     new   delta
fsync_main                                             -     128    +128
fdatasync                                              -      39     +39
packed_usage                                       26596   26622     +26
applet_names                                        2098    2104      +6
applet_main                                         1240    1244      +4
applet_nameofs                                       620     622      +2
applet_install_loc                                   155     156      +1
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 5/0 up/down: 206/0)             Total: 206 bytes

Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-18 08:20:02 +02:00
Denys Vlasenko 7eaf58d958 modprobe: do not use ->probed_name blidly
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-17 20:33:50 +02:00
Denys Vlasenko ee47f6e44f modprobe: correct exitcode handling and error messages with respect to -q
function                                             old     new   delta
do_modprobe                                          319     339     +20
bb_delete_module                                      10      26     +16
moderror                                              62      71      +9
bb_init_module                                       112     119      +7
modprobe_main                                        488     494      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/0 up/down: 58/0)               Total: 58 bytes

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-17 18:46:06 +02:00
Denys Vlasenko a5bdbe1087 switch_root: allow /init to be a symlink; add doc (thanks Rob!)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-17 14:03:24 +02:00
Denys Vlasenko dc36a72ac0 udhcp: cosmetics in arpping.c, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-17 13:56:50 +02:00
Denys Vlasenko 799d00e84c udhcp: convert old-style logging in print_static_leases
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-17 13:44:04 +02:00
Denys Vlasenko 6947d2c7e1 udhcp: logging improvements, field and variable renames
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-17 13:24:03 +02:00
Denys Vlasenko 2b0e957808 examples/udhcp/udhcpd.conf: update
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-17 13:22:26 +02:00
Denys Vlasenko 4945ed32d7 udhcpc: fix format of one log message
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-17 11:58:11 +02:00
Denys Vlasenko 31af3d5a1d udhcp: shorten mac len from 16 to 6 in lease file
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-17 11:57:09 +02:00
Denys Vlasenko ac906fa85e udhcp: change UDHCP_DEBUG into int, make verbosity selectable with -v
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-17 11:54:52 +02:00
Denys Vlasenko ed8982bfc0 udhcp: add a few TODOs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-16 12:05:21 +02:00
Denys Vlasenko 26918dd28e udhcp: rename server/client_config.arp to server_mac and client_mac
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-16 12:04:23 +02:00
Denys Vlasenko cab3a0127c udhcp: cleanup of static lease handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-16 12:03:12 +02:00
Denys Vlasenko 56f2d06c64 udhcp: rename sprintip to sprint_nip, siaddr to siaddr_nip
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-16 10:25:35 +02:00
Denys Vlasenko 990a617edf udhcp: rename giaddr to gateway_nip and server to server_nip
"nip" stands for "IP in network order"

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-16 10:23:55 +02:00
Denys Vlasenko 1d924f59b1 udhcp: rename fields in struct dhcpOfferedAddr
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-16 10:23:01 +02:00
Denys Vlasenko 47f2d7ef7d udhcpd: don't fail ARP check if returned MAC matches client's one
Also, do not unicast replies to yiaddr.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-16 10:20:27 +02:00
Denys Vlasenko 1f363a0867 install: compat fix for mode of created files.
By Mat Hostetter (mhostetter AT tilera.com)

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-15 18:13:51 +02:00
Denys Vlasenko 9517d8ad72 seq: fix input handling in non-C locales
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-15 15:47:58 +02:00
Denys Vlasenko 6548edd430 vi: do not accept uppercase comments (compat). Closes bug 397.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-15 12:44:11 +02:00
Denys Vlasenko 4813a5100d libbb: stop using bb_strtod for now
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-15 09:50:54 +02:00
Denys Vlasenko cd3dd42c28 seq: fix testsuite failures
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-15 09:16:27 +02:00
Denys Vlasenko 82a6fb3ea6 ash: fix . builtin
Also, move [[ ]] comment to test.c and expand it

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-14 19:42:12 +02:00
Denys Vlasenko 2441060beb fix or document testsuite failures
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-13 23:41:57 +02:00
Denys Vlasenko 16635cc2e0 test, tcpsvd, tcpsvd: shrink
function                                             old     new   delta
nexpr                                                825     826      +1
tcpudpsvd_main                                      1830    1822      -8
test_main                                            257     247     -10
binop                                                584     525     -59
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 1/-77)             Total: -76 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-13 22:49:08 +02:00
Denys Vlasenko a3dcee3e8a fix permissions in testsuite
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-13 16:35:20 +02:00
Denys Vlasenko 145512c634 Update POSIX compliance table
Signed-off-by: Max Panasenkov <panmax@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-12 15:32:51 +02:00
Denys Vlasenko a99aa6e9c4 readlink: support -n, -v, -s and -q too if support for -f is requested
function                                             old     new   delta
readlink_main                                        104     135     +31
packed_usage                                       26322   26321      -1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 31/-1)              Total: 30 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-12 13:16:21 +02:00
Denys Vlasenko 641dd7b080 ash: revert over-zealous usage of FAST_FUNC
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-11 19:30:19 +02:00
Denys Vlasenko 77539190ab added comments about [[ ]] to ash and hush. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-10 14:09:48 +02:00
Denys Vlasenko 9ca656b149 hush: add HUSH_BASH_COMPAT, make [[ special handling depend on it
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-10 13:39:35 +02:00
Denys Vlasenko 1d77db8459 telnetd: more compact version of the fix for stray open fds
function                                             old     new   delta
telnetd_main                                        1520    1527      +7
make_new_session                                     510     416     -94
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-94)             Total: -87 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-10 13:38:08 +02:00
Denys Vlasenko a4bcbd0e04 telnetd: properly close fds in child
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-09 23:01:24 +02:00
Denys Vlasenko 9d617c44d2 hush: specially handle [[ - suppress globbing & multiword expansion
It's a bashism, but is surprisingly easy to do and costs very little code.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-09 18:40:52 +02:00
Denys Vlasenko 2634bf366b randomconfig fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-09 18:40:07 +02:00
Denys Vlasenko 38d9072b2c diff: tiny compat tweak
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-09 12:55:13 +02:00
Denys Vlasenko 764b2f0ec0 hush: drop REDIRECT_INVALID; other minor tweaks
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-07 16:05:04 +02:00
Denys Vlasenko df5131cf3d hush: fix a segfault in export builtin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-07 16:04:17 +02:00
Denys Vlasenko 8f24f9812d stop using non-standard macro, use WEXITSTATUS instead
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-07 16:02:00 +02:00
Denys Vlasenko d6b05eb9c2 hush: make builtins work in pipes (eval ... | ...) on NOMMU
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-06 20:59:55 +02:00
Denys Vlasenko 62152da892 ifupdown: if $PATH is not set, do not set it to "" in children
Also random code shrink:

function                                             old     new   delta
set_environ                                          328     330      +2
static.label_buf                                       4       -      -4
startup_PATH                                           4       -      -4
my_environ                                             4       -      -4
ifupdown_main                                       2148    2134     -14
setlocalenv                                          117      90     -27
get_var                                              139     112     -27
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 1/3 up/down: 2/-80)             Total: -78 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-05 21:53:11 +02:00
Denys Vlasenko 035b4d77dc ftpd: allow multiple -S options to increase verbosity too, like -v
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-05 20:42:40 +02:00
Denys Vlasenko 71016baf55 printf: accept negative numbers for %x; sh: overflowed numbers are 0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-05 16:24:29 +02:00
Denys Vlasenko 0f952c249e inetd: comment why we redirect stderr to network
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-05 15:35:36 +02:00
Denys Vlasenko 53f1791212 *: reduce #ifdef forest
Remove unnecessary #if statements from the "more", "script", and
"scriptreplay" commands.  Bloatcheck says 0 bytes changed.

Signed-off-by: Rob Landley <rob@landley.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-05 14:55:26 +02:00
Denys Vlasenko d5f1b1bbe0 *: add FAST_FUNC to function ptrs where it makes sense
function                                             old     new   delta
evalcommand                                         1195    1209     +14
testcmd                                                -      10     +10
printfcmd                                              -      10     +10
echocmd                                                -      10     +10
func_exec                                            270     276      +6
echo_dg                                              104     109      +5
store_nlmsg                                           85      89      +4
pseudo_exec_argv                                     195     198      +3
dotcmd                                               287     290      +3
machtime_stream                                       29      31      +2
discard_stream                                        24      26      +2
argstr                                              1299    1301      +2
killcmd                                              108     109      +1
evalfor                                              226     227      +1
daytime_stream                                        43      44      +1
run_list                                            2544    2543      -1
lookupvar                                             62      61      -1
ipaddr_modify                                       1310    1309      -1
...
parse_stream                                        2254    2245      -9
evalpipe                                             356     347      -9
collect_if                                           210     197     -13
read_opt                                             869     851     -18
handle_dollar                                        681     658     -23
print_addrinfo                                      1342    1303     -39
iterate_on_dir                                       156      59     -97
print_route                                         1709    1609    -100
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 12/130 up/down: 74/-767)       Total: -693 bytes
   text    data     bss     dec     hex filename
 841748     467    7872  850087   cf8a7 busybox_old
 841061     467    7872  849400   cf5f8 busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-05 12:06:05 +02:00
Denys Vlasenko 8507e1f109 ftpd: fix a case when with -w unknown commands are ignored with no error code
Signed-off-by: Stefan Seyfried <seife@suse.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-04 19:03:20 +02:00
Bernhard Reutner-Fischer a43972cb0f rename CONFIG_FEATURE_TAR_GZIP
CONFIG_FEATURE_TAR_GZIP was renamed to CONFIG_FEATURE_SEAMLESS_GZ.
  Adjust testsuite accordingly.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2009-06-03 20:35:26 +02:00
Denys Vlasenko dc2bbb9669 tweak docs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-03 15:19:03 +02:00
Denys Vlasenko 0821801349 hush: document a TODO in export builtin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-03 14:43:56 +02:00
Denys Vlasenko 6f22624a91 hush: fix a case when backgrounded cmd makes shell hang
Signed-off-by: Bayram Kurumahmut <kbayram@ubicom.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-03 14:37:30 +02:00
Denys Vlasenko 295fef80bc hush: add support for local builtin
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-03 12:47:26 +02:00
Mike Frysinger 98f74034cd bloat-o-meter: touchup argv handling
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reported-by: Matt Mackall <mpm@selenic.com>
2009-06-01 16:37:27 -04:00
Mike Frysinger 5177e28e9c bloat-o-meter: fix tab/space mixing
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 16:34:11 -04:00
Mike Frysinger eab40e5885 hush_test: stop mixing tabs/spaces for indentation
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 16:33:05 -04:00
Mike Frysinger a1e5ebe9bd gitignore: add debugging related files
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 14:16:43 -04:00
Mike Frysinger 6a46ab8b8f hush: unify syntax_error_unterm_{ch,str} a bit
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 14:16:43 -04:00
Mike Frysinger ef3e7fdd3b hush: push down expansion var in handle_dollar()
Declare the variable in the scope it is used rather than the entire
function scope so it's obvious it is only used there.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 14:16:43 -04:00
Mike Frysinger dc3bc40578 hush: add support for special vars in braces
Some people like to use ${?} rather than $?, so make sure we support all
the special single char vars that use this form.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 14:16:43 -04:00
Mike Frysinger ff64fb9e31 hush_test: filter test output to avoid C lib differences
The getopt function in some C libraries wraps the option in single quotes
while others do not.  Avoid the issue by running sed on the output and
strip all quotes.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 14:16:43 -04:00
Mike Frysinger f524b6c87f lineedit: fix warning about unused label when VI editing is disabled
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-06-01 14:16:43 -04:00
Denys Vlasenko 28a105d867 nc, hush: cosmetic cleanups, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-06-01 11:26:30 +02:00
Denys Vlasenko 4b7db4f2ca read_key: drop optimization where we read 3 bytes at once
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-29 10:39:06 +02:00
Denys Vlasenko 171932d7ca hust: trivial simplification in builtin_type
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-28 17:07:22 +02:00
Denys Vlasenko e640cb4ad1 hush: fix bug 353 (wrong handling of \x in assignments)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-28 16:49:11 +02:00
Denys Vlasenko 5d7cca2090 hush: optimize type builtin a bit more
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-28 09:58:43 +02:00
Denys Vlasenko dd6b211921 hush: optimize type builtin a bit
function                                             old     new   delta
builtin_type                                         130     125      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-28 09:45:50 +02:00
Mike Frysinger b9f2bb36ea only build common libarchive objs when needed
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-28 00:47:14 -04:00
Denys Vlasenko f3cbfc0e2c modprobe: fix more bugs in modprobe -r
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-28 03:54:29 +02:00
Denys Vlasenko 398c659970 cpio.tests: fix false positive
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-28 02:03:29 +02:00
Mike Frysinger 93cadc2fdd hush: implement type
Implement support for the POSIX `type` command.  Only POSIX stuff is
supported here, no bash extensions like -p or -P.

In the process, split the $PATH searching code out of builtin_source() and
into its own find_in_path() function so we don't duplicate it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-27 17:06:25 -04:00
Denys Vlasenko 673e945052 hush: remove outdated TODO and superfluous macro; fix compile breakage
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-27 14:39:35 +02:00
David Krakov 29ec116037 POSIX conformance documentation for busybox
Attached a start for POSIX conformance documentation for busybox (see
TODO file and discussion last week).
A table of all options as defined by POSIX and as implemented by
busybox (see for a FreeBSD example
http://people.freebsd.org/~schweikh/posix-utilities.html).

Only the tools that are stand-alone applets are documented (not ash
built-ins as 'read'), as there are multiple shells.
When there are two versions (echo) the stand-alone version was
checked. I think this may be the wrong way to go, as most users will
probably use the built-in version - but which shell?

The table was auto-generated by running, for each POSIX utility,
latest git allyesconfig* "busybox <tool> --help" and parsing the
output, and comparing that to tool options extracted from its man page
at http://www.opengroup.org/onlinepubs/9699919799/.
This means that it the usage string is not correct, the table is also
wrong. I noticed that for 'kill', for example, the usage string does
not mention the -s, -q, -o options.
For each option is set whether it exists in busybox and if it is, is
it compliant to the standard. Of course, checking compliance can only
be done manually - a process which will probably take some time (see
'cat' for example).

I didn't post the auto-generation script (python, ugly) because the
table will now change manually; I can post it if there is anyone
interested.

As for the tools not implemented by busybox at all, I think most of
them are indeed fairly esotetic. Some I was suprised to see missing
are link, file, newgrp, unlink.

* Well, almost allyesconfig - but nothing very POSIX-y was disabled.

Signed-off-by: David Krakov <krakov@gmail.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-26 19:42:34 -04:00
Denys Vlasenko 68759edb6e hush: tweak comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-26 14:39:41 +02:00
Denys Vlasenko e2df5f46d0 hush: rename last_waitpid_was_0 to we_have_children
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-26 14:34:10 +02:00
Denys Vlasenko 140def848c modprobe: fix modprobe -r. closes bug 315
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-26 12:48:34 +02:00
Denys Vlasenko 8d7be232a3 hush: fix SIGCHLD counting code, but keep it disabled for now.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-25 16:38:32 +02:00
Denys Vlasenko bf2af9acb2 flash_lock, flash_unlock: new applets
By Thierry Reding (thierry.reding AT avionic-design.de)

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-25 04:15:37 +02:00
Denys Vlasenko 4f26c97b9a make compound.tests executable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-23 17:00:13 +02:00
Denys Vlasenko e9bda90e54 hush: fix problems with case in subshells and with "case esac"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-23 16:50:07 +02:00
Mike Frysinger 342a63d659 hush_test: add some pathological compound list tests
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 18:35:37 -04:00
Mike Frysinger 12bcc76e9b hush_test: test for subshell function syntax
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 18:35:08 -04:00
Mike Frysinger 7b424fe738 hush_test: add subshelled case tests
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 18:09:24 -04:00
Mike Frysinger cc9205bda7 hush_test: update test output to match new getopt() output
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 17:58:15 -04:00
Mike Frysinger 33f85eeac5 hush_test: ignore generated files
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-21 17:45:26 -04:00
Denys Vlasenko 2b132e5139 hdparm: fix a thinko in a previous commit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-20 23:21:42 +02:00
Denys Vlasenko d8aeba4eed Merge branch 'master' of git+ssh://vda@busybox.net/var/lib/git/busybox 2009-05-20 21:50:29 +02:00
Denys Vlasenko c706845539 hdparm: code shrink
function                                             old     new   delta
parse_opts_0_INTMAX                                    -      12     +12
parse_opts_0_1                                         -      12     +12
parse_opts_0_max                                       -       9      +9
parse_opts                                            44      36      -8
process_dev                                         4679    4578    -101
hdparm_main                                         1061     854    -207
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 0/3 up/down: 33/-316)          Total: -283 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-20 16:11:41 +02:00
Denys Vlasenko 6d335be211 hdparm: correct (t & 1) ? '0' : '5' thinko; wrap 80+ col lines
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-20 14:48:03 +02:00
Denys Vlasenko 73f3799236 Merge branch 'master' of git+ssh://vda@busybox.net/var/lib/git/busybox 2009-05-20 14:10:50 +02:00
Denys Vlasenko e18255d1da Merge branch 'master' of git+ssh://vda@busybox.net/var/lib/git/busybox 2009-05-20 12:20:48 +02:00
Mike Frysinger 38478a600f hush: fix build failure when jobs are disabled
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reported-by: Thomas Chou <thomas@wytron.com.tw>
2009-05-20 04:48:06 -04:00
Denys Vlasenko 0149f02a72 appletlib.c: prevent applet list overflowing screen
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-19 18:01:42 +02:00
Denys Vlasenko 5e61115ea4 scriptreplay: new applet. +423 bytes
Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-19 17:36:16 +02:00
Denys Vlasenko 5a49d284a6 add platform tweaks
login: consider platforms having no domainname field in the utsname struct
include/platform.h: define IUCLC to 0 on platforms where it is not defined

Signed-off-by: Luca Favatella <slackydeb@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-19 13:18:45 +02:00
Denys Vlasenko e424423a7b awk: put at least one NUL between $n. Hopefully closes 337.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-18 23:50:03 +02:00
Denys Vlasenko 167cd709df gzip: fix gzip with many files corrupting some files after first
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-18 13:08:57 +02:00
Denys Vlasenko 16bda3bd1f depmod: fix handling of .gz modules
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-18 13:08:04 +02:00
Denys Vlasenko c396fe6306 lineedit: small fixes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-17 19:28:14 +02:00
Denys Vlasenko 020f40693a line editing: add an option to emit ESC [ 6 n and use results
This makes line editing able to recognize case when
cursor was not at the beginning of the line. It may also
be adapted later to find out display size (serial line users
would love it).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-17 16:44:54 +02:00
Denys Vlasenko 071ede1e5d xmalloc_[open_]read[_close]: do not ignore xrealloc return value
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-15 23:23:23 +02:00
Denys Vlasenko c15f40c3e7 lineedit: use read_key to recognize ESC sequence.
This fixes several vi mode bugs and prepares for further fixes.

function                                             old     new   delta
read_line_input                                     3287    5511   +2224
remember_in_history                                    -     499    +499
lineedit_read_key                                      -      70     +70
read_key                                             321     332     +11
input_tab                                           2823       -   -2823
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 2/0 up/down: 2804/-2823)        Total: -19 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-15 03:27:53 +02:00
Denys Vlasenko 1b0a93edb9 adduser/addgroup: make system id range configurable.
By Tito (farmatito AT tiscali.it).

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-14 00:23:34 +02:00
Denys Vlasenko 810b7161dc mount: save 80 bytes by forced de-inlining
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-13 23:48:59 +02:00
Denys Vlasenko e71dd7c1db mount: document when kernel started accepting string as NFS options
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-13 16:32:32 +02:00
Mike Frysinger 7a5814c74c split website off into dedicated git repo
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-13 01:48:00 -04:00
Denys Vlasenko 318a8e5ed5 TODO: add some
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-13 02:18:43 +02:00
Bernhard Reutner-Fischer 845142e106 Adjust names, link contributing info in main index
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2009-05-11 22:51:49 +02:00
Denys Vlasenko f427c80d02 sysctl: stop abusing parser->line
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-10 23:41:29 +02:00
Denys Vlasenko c8ab67cad8 tftp: do not risk invoking Sorcerer's Apprentice syndrome
examples/udhcp/simple.script: fix incorrect test for $1

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-10 23:27:43 +02:00
Bernhard Reutner-Fischer 8082ea1000 test commit
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2009-05-08 18:22:52 +02:00
Bernhard Reutner-Fischer b5d5245f46 Revert "test commit"
This reverts commit 8606aba04b.

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
2009-05-08 18:19:58 +02:00
Bernhard Reutner-Fischer 8606aba04b test commit 2009-05-08 18:18:42 +02:00
Mike Frysinger af61b2a5ad LICENSE: update address of the FSF
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-06 05:28:53 -04:00
Mike Frysinger 1e12ae9059 modprobe: add comment about expected modules.dep format
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-06 05:24:41 -04:00
Mike Frysinger 2b6497ba84 depmod.pl: updates and fixes galore
The helper script needs updating to match latest busybox modprobe behavior
in that all dependencies need to be listed, not just the immediate ones.
Along the way, fix symbol prefixed ports, optimize the output, and add
some more depmod compatible options.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-05 20:14:12 -04:00
Mike Frysinger 00ffaeab80 modprobe: add more useful debug points
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-05 20:13:45 -04:00
Mike Frysinger 3322351724 add .gitignore files
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-05 09:05:30 -04:00
Mike Frysinger 4f239b1bb4 libunarchive: fix build failure with !FEATURE_TAR_UNAME_GNAME
We can't use C if(...) with ENABLE_FEATURE_TAR_UNAME_GNAME because it
relies on conditional members in the file_header_t structure:

archival/libunarchive/data_extract_all.c: In function ‘data_extract_all’:
archival/libunarchive/data_extract_all.c:123: error: ‘file_header_t’ has no member named ‘uname’
archival/libunarchive/data_extract_all.c:124: error: ‘file_header_t’ has no member named ‘uname’
archival/libunarchive/data_extract_all.c:127: error: ‘file_header_t’ has no member named ‘gname’
archival/libunarchive/data_extract_all.c:128: error: ‘file_header_t’ has no member named ‘gname’
make[1]: *** [archival/libunarchive/data_extract_all.o] Error 1

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-05-05 07:00:27 -04:00
Denys Vlasenko 76f5e38c82 mdev: revert last wrong commit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-04 21:59:05 +02:00
root 6245202e7f hush: small fix for unset -f on NOMMU.
Signed-off-by: root <root@localhost.localdomain>
2009-05-04 12:00:19 +02:00
Bernhard Reutner-Fischer 62851171db fix debug message
Print the mime-type only after it has been set.
  Add possible TODOs: use TCP_CORK, parse_config()
2009-05-04 09:57:25 +02:00
Denys Vlasenko acdc49c073 hush: add more complex case to leak testcase, fix found breakage
function                                             old     new   delta
unset_local_var_len                                    -     167    +167
run_list                                            2350    2457    +107
set_vars_and_save_old                                  -      87     +87
free_pipe                                            207     227     +20
builtin_unset                                        220     229      +9
builtin_exit                                          49      47      -2
free_strings_and_unset                                53       -     -53
set_vars_all_and_save_old                             87       -     -87
unset_local_var                                      168       -    -168
------------------------------------------------------------------------------
(add/remove: 2/3 grow/shrink: 3/1 up/down: 390/-310)           Total: 80 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-04 01:58:10 +02:00
Denys Vlasenko cb6ff25afe hush: fix bug where in "var=val func" var's value is not visible in func
function                                             old     new   delta
unset_local_var                                        -     168    +168
set_vars_all_and_save_old                              -      87     +87
get_ptr_to_local_var                                   -      77     +77
free_strings_and_unset                                 -      53     +53
builtin_export                                       266     274      +8
get_local_var_value                                   31      33      +2
putenv_all                                            27       -     -27
free_strings_and_unsetenv                             53       -     -53
get_local_var                                         68       -     -68
run_list                                            2475    2350    -125
builtin_unset                                        380     220    -160
------------------------------------------------------------------------------
(add/remove: 4/3 grow/shrink: 2/2 up/down: 395/-433)          Total: -38 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-04 00:14:30 +02:00
Denys Vlasenko e19e1935a3 hush: fix \<newline> handling
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-03 02:15:18 +02:00
Denys Vlasenko b1cfc45376 hush: fix handling of unterminated subshell: (<eof>. Fixes bug 229.
function                                             old     new   delta
syntax_error_unexpected_ch                            31      41     +10
parse_stream                                        2184    2191      +7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-02 17:18:34 +02:00
Denys Vlasenko aa0a12d549 mdev: do not exit if user:group parse failed. closes bug 309.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-02 16:33:10 +02:00
Denys Vlasenko 1dd6cf8677 hush: fix multiple redirections of the same fd (bug 227)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-02 14:17:31 +02:00
Denys Vlasenko 54e0843e7d hush: make . cmd search $PATH
function         old     new   delta
builtin_source   128     249    +121

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-02 02:34:19 +02:00
Denys Vlasenko 48a29defca httpd: speed up httpd.conf at the cost of 49 bytes of code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-05-02 00:50:38 +02:00
Denys Vlasenko 9c35a1cfb6 ifplugd: fix warnings 2009-05-01 09:04:25 +02:00
Denys Vlasenko 44d1989997 des encrypt: fix goof with NUL byte added at the end as '.' 2009-05-01 03:41:25 +02:00
Denys Vlasenko 05ae400830 mdev: fix a case where we mangle device_path string and then use it. 2009-05-01 03:09:54 +02:00
Denys Vlasenko 47aaa2bee6 Make it clearer that usually people should _NOT_
select FEATURE_UNIX_LOCAL.
2009-05-01 03:00:04 +02:00
Denys Vlasenko 690ad2426e git commit test
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2009-04-30 21:24:24 +02:00
Denis Vlasenko 1fd3b38fd1 *: bb_error_msg's messages should not be capitalized 2009-04-29 12:02:57 +00:00
Denis Vlasenko 052ad9a568 lzop: new applet. Busyboxed by Alain Knaff. +7700 bytes. 2009-04-29 12:01:51 +00:00
Denis Vlasenko c8653f62f2 hush: make it possible to have interactive shell on non-ctty.
init=/bin/hush: shows prompt, history works, etc.

function                                             old     new   delta
hush_main                                            888     925     +37
block_signals                                        139     152     +13
builtin_fg_bg                                        284     293      +9
checkjobs_and_fg_shell                                35      41      +6
sigexit                                               65      66      +1
reset_traps_to_defaults                              165     164      -1
parse_stream                                        2200    2184     -16
run_list                                            2502    2475     -27
getpgid                                               35       -     -35
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 5/3 up/down: 66/-79)            Total: -13 bytes
2009-04-27 23:29:14 +00:00
Denis Vlasenko 42e4af3119 make leak test more robust by unsetting all vars 2009-04-26 23:25:36 +00:00
Denis Vlasenko 28e67966f3 hush: make getopt32 usable in builtins. use it in unset.
more uses are expected in the future.

function                                             old     new   delta
getopt32                                            1356    1393     +37
builtin_export                                       256     266     +10
builtin_unset                                        418     380     -38
2009-04-26 23:22:40 +00:00
Denis Vlasenko 572930027d hush: nommu fix for function passing 2009-04-26 20:06:14 +00:00
Denis Vlasenko 5b7589eb27 hush: fix SEGV in % expansion
function                                             old     new   delta
expand_variables                                    2203    2217     +14
2009-04-26 11:25:19 +00:00
Denis Vlasenko 80e57eb7d5 ifplugd: tiny shrink 2009-04-26 01:43:36 +00:00
Denis Vlasenko f4e4563fe7 ifplugd: add copyright 2009-04-26 01:17:44 +00:00
Denis Vlasenko 71c165780a ifplugd: new applet by Maksym Kryzhanovskyy (xmaks AT email.cz)
+3k code and 0.5k in messages. Most of the bloat due to compat :(
2009-04-26 01:08:51 +00:00
Denis Vlasenko 5bf59c104a shrink if FEATURE_SHADOWPASSWDS is off 2009-04-25 13:26:10 +00:00
Denis Vlasenko f6b4685691 add FEATURE_UNIX_LOCAL. By Ingo van Lil (inguin AT gmx.de) 2009-04-25 13:16:53 +00:00
Denis Vlasenko 9ac3dc764a unlzma: speedup, by Pascal Bellard (pascal.bellard AT ads-lu.com)
LZMA_FAST off: 10% faster and:
function                                             old     new   delta
rc_is_bit_1                                            -      92     +92
rc_do_normalize                                       45      81     +36
rc_update_bit_1                                       25       -     -25
rc_update_bit_0                                       30       -     -30
rc_is_bit_0_helper                                    38       -     -38
rc_get_bit                                            60      17     -43
rc_read                                               48       -     -48
unpack_lzma_stream                                  1768    1517    -251
------------------------------------------------------------------------------
(add/remove: 1/4 grow/shrink: 1/2 up/down: 128/-435)         Total: -307 bytes

LZMA_FAST on: 14% faster and:
unpack_lzma_stream                                  2301    2737    +436
rc_get_bit                                           106       -    -106
2009-04-25 12:19:35 +00:00
Mike Frysinger 6fb5f01c0b we need to daemonize *before* opening the watchdog device 2009-04-25 06:16:37 +00:00
Mike Frysinger 26cf2831d7 do not tell people they can enter "help" if help has actually been disabled 2009-04-24 06:40:30 +00:00
Mike Frysinger 67c1c7b456 use get_local_var_value() rather than getenv() when working with PS1/PS2/HOME, respect the PS2 env var, and make sure that the prompt changes whenever PS1/PS2 changes so we dont have to re-exec the shell to get a changed prompt 2009-04-24 06:26:18 +00:00
Denis Vlasenko eb4e5ecc32 inetd: constify data 2009-04-22 23:25:48 +00:00
Denis Vlasenko c2931aa2df adduser/addgroup: support specifying uid/gid, add system
account creation mode. By Tito.

function                                             old     new   delta
adduser_main                                         650     726     +76
addgroup_main                                        341     402     +61
addgroup_longopts                                      -      16     +16
adduser_longopts                                      97     103      +6
packed_usage                                       26161   26163      +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 161/0)             Total: 161 bytes
2009-04-22 21:35:52 +00:00
Denis Vlasenko c8d7109f60 httpd: fix small bug in parser. it crept in during cleanup 2009-04-22 14:16:59 +00:00
Denis Vlasenko 00643ca520 httpd: allow empty lines in conf file 2009-04-22 13:52:22 +00:00
Denis Vlasenko 1cf4a0eb81 httpd: simplify insane conf file parser
function                                             old     new   delta
bb_simplify_abs_path_inplace                           -      98     +98
parse_expr                                           824     832      +8
passwd_main                                         1025    1027      +2
evalvar                                             1374    1376      +2
parse_command                                       1463    1460      -3
bb_simplify_path                                     137      55     -82
parse_conf                                          1572    1422    -150
------------------------------------------------------------------------------
(add/remove: 3/2 grow/shrink: 3/3 up/down: 126/-251)         Total: -125 bytes
2009-04-22 13:49:16 +00:00
Denis Vlasenko 574c316e5a syslogd: added comment, no code changes 2009-04-22 02:53:02 +00:00
Denis Vlasenko b029154a2a httpd: improve help text 2009-04-22 00:26:39 +00:00
Denis Vlasenko 8ed1945a91 nc: free lsa in server mode, we might be up for a long time 2009-04-21 23:51:43 +00:00
Denis Vlasenko a771e7c005 *: remove check for errors on getsockaddr in cases we know they can't happen
libbb: make get_sock_lsa use only one getsockaddr syscall, not two

function                                             old     new   delta
get_sock_lsa                                          72     101     +29
do_iplink                                           1151    1137     -14
arping_main                                         1585    1569     -16
dolisten                                             789     755     -34
xrtnl_open                                           161      94     -67
2009-04-21 23:48:38 +00:00
Denis Vlasenko e6b10ef0a7 switch_root: move misplaced comment 2009-04-21 20:52:58 +00:00
Denis Vlasenko f9d4fc3cf8 switch_root: improve behavior on error; improve help text
*: make "can't execute '%s'" message uniform
2009-04-21 20:40:51 +00:00
Denis Vlasenko 950bd72966 hush: speed up set_local_var
function                                             old     new   delta
set_local_var                                        265     290     +25
2009-04-21 11:23:56 +00:00
Denis Vlasenko 5e34ff29bc *: mass renaming of USE_XXXX to IF_XXXX
and SKIP_XXXX to IF_NOT_XXXX - the second one was especially
badly named. It was not skipping anything!
2009-04-21 11:09:40 +00:00
Denis Vlasenko 8b814b4a34 tar: support for tar --numeric-owner. By Natanael Copa.
function                                             old     new   delta
tar_longopts                                         221     237     +16
data_extract_all                                     692     705     +13
tar_main                                             690     702     +12
2009-04-21 00:52:21 +00:00
Denis Vlasenko 76478b8091 udhcpc: fix truncation of last char in client hostnames 2009-04-21 00:41:57 +00:00
Denis Vlasenko 0ad8234474 switch_root: print errno on failure 2009-04-21 00:29:17 +00:00
Denis Vlasenko 1b47bbdfa4 tweak example udhcp script 2009-04-21 00:17:00 +00:00
Denis Vlasenko ad4bd0548a hush: export -n support
function                                             old     new   delta
builtin_export                                       206     256     +50
set_local_var                                        248     265     +17
expand_variables                                    2204    2203      -1
2009-04-20 22:04:21 +00:00
Denis Vlasenko d40fa397e4 hush: add two testcases 2009-04-20 10:52:31 +00:00
Denis Vlasenko e41fdbc279 watchdog: enable it before setting timeout
function                                             old     new   delta
watchdog_main                                        239     259     +20
static.enable                                          -       4      +4
2009-04-20 09:26:17 +00:00
Denis Vlasenko 8c64e033c0 hush: fix stdin of backgrounded pipe
function                                             old     new   delta
run_list                                            2450    2502     +52
2009-04-20 00:34:01 +00:00
Denis Vlasenko 11c17f75a7 mdev: enlarge inline documentation 2009-04-19 23:38:08 +00:00
Denis Vlasenko dcd78c4d0f hush: fix "export not_yet_defined_var", fix parsing of "cmd | }"
corner case; improve hush_leaktool.sh;
 fix some false positives in testsuite

function                                             old     new   delta
builtin_export                                       191     206     +15
parse_stream                                        2196    2200      +4
2009-04-19 23:07:51 +00:00
Denis Vlasenko 3798db58cf mdev: support $ENVVAR=regex 2009-04-19 21:37:07 +00:00
Denis Vlasenko f66fe9af89 another stab at fixing out-of-tree build 2009-04-19 14:12:50 +00:00
Denis Vlasenko 9f8d938172 same as previous, but -100 bytes 2009-04-19 14:03:11 +00:00
Denis Vlasenko bf25fbccb9 hush: fix handling of } which is not a closing one in { cmd; }
function                                             old     new   delta
parse_stream                                        2176    2302    +126
builtin_unset                                        381     387      +6
2009-04-19 13:57:51 +00:00
Denis Vlasenko a29c935442 hopefully fix out-of-tree build broken by 26139 2009-04-19 12:15:51 +00:00
Denis Vlasenko c7cc5a9432 mdev: Rob's #if forest removal
*: remove superfluous conts in "f(type *const param)"
2009-04-19 01:27:20 +00:00
Mike Frysinger 885b6f29ae fix build errors when function support is turned off 2009-04-18 21:04:25 +00:00
Denis Vlasenko 6008d8a3cc hush: fix thinko in error msg 2009-04-18 13:05:10 +00:00
Denis Vlasenko 38e626df4d hush: fix "trap -- handler SIGs..."; escape handlers in "trap" output 2009-04-18 12:58:19 +00:00
Denis Vlasenko 6a07d1fb5c acpid: prevent creation of zombies 2009-04-18 11:35:16 +00:00
Denis Vlasenko 730106767e hush: fix thinko in unset_func 2009-04-18 11:25:18 +00:00
Denis Vlasenko 40e84374ec hush: implement unset -f; beautify the handling of signal-killed pipe
four TODOs are gone

function                                             old     new   delta
builtin_unset                                        271     364     +93
checkjobs                                            394     428     +34
builtin_exit                                          49      47      -2
2009-04-18 11:23:38 +00:00
Denis Vlasenko eb85849b50 hush: deal with umask TODO (symbolic modes)
function                                             old     new   delta
builtin_umask                                         79     125     +46
2009-04-18 02:06:54 +00:00
Denis Vlasenko 6b9e05392b hush: implement proper SIGHUP handling
function                                             old     new   delta
check_and_run_traps                                  164     229     +65
insert_bg_job                                        376     366     -10
hush_main                                            937     927     -10
2009-04-18 01:23:21 +00:00
Denis Vlasenko 7b9e5c57ae builtin_return's parameter is not unused 2009-04-17 23:53:15 +00:00
Denis Vlasenko 3d40d8e655 hush: return builtin by Bayram Kurumahmut (kbayram AT ubicom.com)
~+200 bytes
2009-04-17 23:44:18 +00:00
Denis Vlasenko 3be2308676 fix move_to_unaligned32 2009-04-17 22:20:44 +00:00
Denis Vlasenko 66cb86e489 build system: remove some unnecessary rebuilds 2009-04-17 21:56:02 +00:00
Denis Vlasenko 270b1c3f68 hush: set $n properly for "source" builtin
function                                             old     new   delta
restore_G_args                                         -      78     +78
save_and_replace_G_args                                -      64     +64
builtin_source                                        72     107     +35
run_list                                            2549    2367    -182
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/1 up/down: 177/-182)           Total: -5 bytes
2009-04-17 18:54:50 +00:00
Denis Vlasenko 4ea187fd62 hush: fix non-interactive response to pipe being stopped.
function                                             old     new   delta
checkjobs                                            380     394     +14
2009-04-17 14:35:43 +00:00
Denis Vlasenko e4bd4f2cc8 hush: unblock TERM, INT, HUP in child shells too. 2009-04-17 13:52:51 +00:00
Denis Vlasenko f8c1f02d2f hush: disallow "{echo hi; }" (require whitespace)
and "{ echo hi }" (require semicolon or &)

function                                             old     new   delta
parse_stream                                        2098    2176     +78
done_command                                          98      84     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 78/-14)             Total: 64 bytes
2009-04-17 11:55:42 +00:00
Denis Vlasenko 5ff9629b8f mdev: add large comment, fix a buglet with subsystem and /sys/block 2009-04-17 00:01:04 +00:00
Denis Vlasenko 184f4ff432 disable FLASH_ERASEALL in defconfig 2009-04-16 23:05:59 +00:00
Denis Vlasenko 3161b61199 mdev: set mode, needed when device node already exists. 2009-04-16 22:42:01 +00:00
Denis Vlasenko 6dda5dec23 mdev: change subsystem syntax from /subsystem to subsystem/devname 2009-04-16 21:42:12 +00:00
Denis Vlasenko ea4f0847c3 update example udhcpc script 2009-04-16 20:04:09 +00:00
Denis Vlasenko fa4ca7889e hush: add a TODO 2009-04-16 12:00:15 +00:00
Denis Vlasenko bb929517a8 hush: fix "if { echo foo; } then { echo bar; } fi" parsing
function                                             old     new   delta
done_word                                            728     793     +65
parse_stream                                        2084    2098     +14
2009-04-16 10:59:40 +00:00
Denis Vlasenko 74a931ac9e hush: stop ignoring ^Z in child shells 2009-04-15 23:29:44 +00:00
Denis Vlasenko c4ada79343 hush: remove old disabled ^Z handling 2009-04-15 23:29:00 +00:00
Denis Vlasenko 41ddecd9ed hush: fix heredoc_huge.tests broken in last commits 2009-04-15 21:58:14 +00:00
Denis Vlasenko c376db332c hush: remove TODO comment itself :) 2009-04-15 21:49:48 +00:00
Denis Vlasenko 27014ed5cb hush: deal with a TODO: move argv_from_re_execing out of globals
function                                             old     new   delta
generate_stream_from_string                          156     165      +9
setup_heredoc                                        312     320      +8
re_execute_shell                                     387     391      +4
pseudo_exec_argv                                     129     133      +4
run_pipe                                            1790    1783      -7
clean_up_after_re_execute                             30       -     -30
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 4/1 up/down: 25/-37)            Total: -12 bytes
2009-04-15 21:48:23 +00:00
Denis Vlasenko c3587223c7 Start 1.15.x development 2009-04-15 13:04:52 +00:00
Denis Vlasenko bae3abf2c7 website: another tweak 2009-04-15 11:55:27 +00:00
Denis Vlasenko 9367734bd6 website: yet another small tweak 2009-04-15 11:51:18 +00:00
Denis Vlasenko 6c76a96f23 website: another tiny tweak 2009-04-15 11:48:25 +00:00
Denis Vlasenko 4e4c5db66a website: textual fixes in 1.14.0 announcement text 2009-04-15 11:11:19 +00:00
Denis Vlasenko 5dcb43a5d1 website: announce 1.14.0 and 1.13.4
Makefile: bump version to 1.14.0
2009-04-15 02:13:14 +00:00
Denis Vlasenko 32a3d084d3 mdev: safer handling of $SUBSYSTEM in mdev -s 2009-04-14 21:23:33 +00:00
Denis Vlasenko 7223424815 pointless whitespace/comment fixes, no code changes 2009-04-14 09:58:11 +00:00
Denis Vlasenko 7f9593753a randomconfig fixes 2009-04-14 08:06:59 +00:00
Denis Vlasenko b024f8da8f website: update ActionTec URL to http://opensource.actiontec.com/ 2009-04-14 01:31:41 +00:00
Denis Vlasenko 33c6b2a91a website: fix obsolete
"svn co svn://busybox.net/branches/busybox_1_12_stable"
 example
2009-04-14 00:59:37 +00:00
Denis Vlasenko 829bbd3b57 *: unify concurrent-safe update of /etc/{passwd,group,[g]shadow}
by Tito (farmatito AT tiscali.it)

function                                             old     new   delta
update_passwd                                        743    1171    +428
bb_perror_nomsg                                        -       9      +9
find_main                                            436     444      +8
passwd_main                                         1023    1027      +4
nameval                                              202     206      +4
chpasswd_main                                        315     319      +4
bb__parsespent                                       119     117      -2
adduser_main                                         654     650      -4
addgroup_main                                        345     341      -4
sv_main                                             1228    1222      -6
deluser_main                                         173     160     -13
bb_internal_putpwent                                  69       -     -69
add_user_to_group                                    231       -    -231
del_line_matching                                    460      31    -429
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 5/6 up/down: 457/-758)         Total: -301 bytes
2009-04-14 00:51:05 +00:00
Denis Vlasenko f2b39e088d mdev: add support for - "dont stop here" char
function                                             old     new   delta
make_device                                         1340    1362     +22
packed_usage                                       26291   26299      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 30/0)               Total: 30 bytes
2009-04-13 23:18:52 +00:00
Denis Vlasenko 065c714791 mdev: provide $SUBSYSTEM (by Vladimir)
function                                             old     new   delta
make_device                                         1265    1340     +75
dirAction                                             14      60     +46
mdev_main                                            676     695     +19
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 140/0)             Total: 140 bytes
2009-04-13 22:23:02 +00:00
Denis Vlasenko 0b791d9a97 move llist_find_str from modutils to libbb 2009-04-13 20:52:00 +00:00
Denis Vlasenko 4144504912 modutils: remove redundant sanitization 2009-04-13 20:32:31 +00:00
Denis Vlasenko 2b2183a77d hush: make function support configurable 2009-04-13 14:23:12 +00:00
Denis Vlasenko 323cbbfaa2 mdev: fix a bug where \t is not treated as delimiter after [>|=PATH] 2009-04-13 13:59:26 +00:00
Denis Vlasenko aafbae6181 mdev: make usage text more useful
function                                             old     new   delta
packed_usage                                       26235   26291     +56
2009-04-13 13:33:02 +00:00
Denis Vlasenko e8a796828e dhcprelay: fix usage text. Simplify and make code more readable.
Add TODOs.
2009-04-13 03:33:46 +00:00
Denis Vlasenko 1f63229a8e rmmod: fix bug 263
"modutils/rmmod can't remove modules with dash in name on 2.4 kernels"

function                                             old     new   delta
rmmod_main                                           187     220     +33
2009-04-13 02:25:40 +00:00
Denis Vlasenko 1fb26da071 mdev: ignore events with "$SUBSYSTEM" == "firmware" && "$ACTION" == "remove"
function                                             old     new   delta
mdev_main                                            665     676     +11
2009-04-13 02:15:57 +00:00
Denis Vlasenko 1d925affa9 website: add http://www.dream-multimedia-tv.de/ to list of products
using bbox
2009-04-13 00:55:42 +00:00
Denis Vlasenko bc56974062 hush: pass functions to child shells on NOMMU
function                                             old     new   delta
new_function                                           -     123    +123
hush_main                                           1198    1262     +64
re_execute_shell                                     341     387     +46
run_pipe                                            1872    1790     -82
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/1 up/down: 233/-82)           Total: 151 bytes
2009-04-12 20:35:19 +00:00
Denis Vlasenko ef1b439669 dnsd: stop using oversized buffer. trim comment. 2009-04-12 19:03:01 +00:00
Denis Vlasenko e12c90217b halt/reboot/powerdown: accept and ignore -i 2009-04-12 15:59:35 +00:00
Denis Vlasenko 51056b382a modutils: small optimization
function                                             old     new   delta
bb_init_module_24                                   4570    4565      -5
2009-04-12 14:21:29 +00:00
Denis Vlasenko f1df35c40b mdev: do not complain if /sys/block doesn't exist 2009-04-12 14:00:12 +00:00
Denis Vlasenko 67b5eeb933 awk: fix long field separators case. By Ian Wienand (ianw AT vmware.com) 2009-04-12 13:54:13 +00:00
Denis Vlasenko 32a385f5b0 getty: fix handling of speed 0;
stop using non-portable way of setting speeds.

function                                             old     new   delta
cfsetispeed                                            -      76     +76
cfsetospeed                                            -      57     +57
cfgetispeed                                            -      20     +20
2009-04-12 13:05:40 +00:00
Denis Vlasenko 5c32993009 mount: users report that CIFS support is breaking things,
mostly remove it.
2009-04-12 12:16:21 +00:00
Denis Vlasenko f8de411e24 dnsd: removed highly questionable setting of signals to SIG_IGN 2009-04-12 04:20:22 +00:00
Denis Vlasenko ddbf3bf35f dnsd: fix a number of bugs. Ideas by Ming-Ching Tiew (mctiew AT yahoo.com)
function                                             old     new   delta
undot                                                  -      42     +42
dnsd_main                                           1394    1213    -181
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 42/-181)          Total: -139 bytes
2009-04-12 04:09:09 +00:00
Denis Vlasenko 135cecbbce ash: fix warning in debug build 2009-04-12 00:00:57 +00:00
Denis Vlasenko c43430f1b9 hush: remove functions from TODOs 2009-04-11 11:07:22 +00:00
Denis Vlasenko 0701dca88c hush: improve debugging output 2009-04-11 10:38:47 +00:00
Denis Vlasenko ed055214bb hush: fix "while...do f1() {a;}; f1; f1 {b;}; f1; done" bug 2009-04-11 10:37:10 +00:00
Denis Vlasenko 75bccfa375 hush: tweak tests 2009-04-10 23:48:03 +00:00
Denis Vlasenko ce4acbbab6 hush: add function tests 2009-04-10 23:23:41 +00:00
Denis Vlasenko 6ba6f546ac hush: pass $n to functions
function                                             old     new   delta
run_pipe                                            1183    1325    +142
run_list                                            1219    1220      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 143/0)             Total: 143 bytes
2009-04-10 21:57:50 +00:00
Denis Vlasenko c0ea329297 hush: fix a few thinkos in function support; make it work on NOMMU;
functions in child shells now even have $n passed to them! :)
 (in main shell it still doesn't work)
2009-04-10 21:22:02 +00:00
Denis Vlasenko b7d8c0dbbd hush: first stab at function support. argv passing is not coded yet.
Only very rudimentary testing was done.
 With function support off, code growth is zero, with it on:

function                                             old     new   delta
run_list                                            2158    2339    +181
parse_stream                                        1929    2044    +115
find_builtin                                          24      67     +43
find_function                                          -      36     +36
file_get                                             244     264     +20
pseudo_exec_argv                                     145     160     +15
free_strings                                           -       7      +7
free_pipe                                            183     181      -2
done_word                                            735     728      -7
expand_variables                                    2227    2204     -23
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 5/3 up/down: 417/-32)           Total: 385 bytes
2009-04-10 19:05:43 +00:00
Denis Vlasenko 835fcfd33d hush: reinstate accidentally reverted comment fix 2009-04-10 13:51:56 +00:00
Denis Vlasenko 0b677d8337 hush: fix some TODOs. TODO in export builting: +250 bytes.
simplify unexpected EOF handling.

function                                             old     new   delta
builtin_export                                       117     374    +257
o_reset_to_empty_unquoted                              -      21     +21
parse_stream                                        1926    1929      +3
syntax_error_unterm_ch                                31      32      +1
handle_dollar                                        644     641      -3
parse_stream_dquoted                                 307     298      -9
add_till_backquote                                   106      97      -9
add_till_closing_paren                               303     286     -17
o_reset                                               21       -     -21
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 3/4 up/down: 282/-59)           Total: 223 bytes
2009-04-10 13:49:10 +00:00
Denis Vlasenko 1fd1ea4395 hush: tighten up "for" variable name check.
Add TODOs.
 Disable redir4.right part where we differ from bash.
 It is not a bug per standards.
 Add a few tests, one is in hush-bugs section:
 and_or_and_backgrounding.right. It will likely bite users
 in real world usage.
2009-04-10 12:03:20 +00:00
Denis Vlasenko 551bdfecb7 hush: fix typo in comment 2009-04-10 11:13:26 +00:00
Denis Vlasenko ed7823738c fix segfault on syntax error code path 2009-04-10 00:45:02 +00:00
Denis Vlasenko c96865f445 hush: readability improvements.
fix some more obscure bugs.
 a new redir4.tests is known to fail.
2009-04-10 00:20:58 +00:00
Mike Frysinger e05f9286a9 add test cases for parameter substitution with unset/null strings 2009-04-09 23:01:47 +00:00
Mike Frysinger 57e746781c dont crash if the variable we do substitution on is not set 2009-04-09 23:00:33 +00:00
Denis Vlasenko d68ae08cde hush: shrink and make more versatile error-reporting machinery
function                                             old     new   delta
syntax_error_unterm_ch                                 -      31     +31
syntax_error_unterm_str                                -      14     +14
parse_stream                                        2356    2361      +5
syntax_error_at                                       12      14      +2
syntax_error                                          25      27      +2
syntax_error_unterminated                             28       -     -28
expand_variables                                    2063    2031     -32
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 3/1 up/down: 54/-60)             Total: -6 bytes
   text    data     bss     dec     hex filename
  67278     197    3184   70659   11403 busybox_old
  67228     197    3184   70609   113d1 busybox_unstripped
2009-04-09 20:41:34 +00:00
Denis Vlasenko 05d3b7cc0d hush: deal with some easier TODOs
function                                             old     new   delta
is_well_formed_var_name                                -      87     +87
builtin_read                                          49      86     +37
die_if_script                                          -      31     +31
syntax_error_unterminated                              -      28     +28
syntax_error                                          26      51     +25
done_word                                            768     788     +20
syntax_error_at                                        -      12     +12
parse_stream_dquoted                                 320     328      +8
expand_variables                                    2064    2063      -1
run_list                                            1225    1220      -5
add_till_closing_paren                               308     303      -5
add_till_backquote                                   111     106      -5
handle_dollar                                        812     803      -9
parse_stream                                        2378    2356     -22
parse_redirect                                       408     372     -36
maybe_die                                             44       -     -44
is_assignment                                        215     134     -81
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 4/8 up/down: 248/-208)           Total: 40 bytes
2009-04-09 19:16:15 +00:00
Denis Vlasenko 1943aec2ec hush: plug the leak of expanded heredoc 2009-04-09 14:15:57 +00:00
Denis Vlasenko efea9d2819 hush: fix EXIT trap recursion case; check redirection failures
function                                             old     new   delta                          
run_pipe                                            1299    1328     +29                          
hush_exit                                             90     102     +12                          
hush_main                                           1172    1179      +7                          
run_list                                            1226    1225      -1                          
------------------------------------------------------------------------------                    
(add/remove: 0/0 grow/shrink: 3/1 up/down: 48/-1)              Total: 47 bytes
2009-04-09 13:43:11 +00:00
Denis Vlasenko f81e8dbc74 *: make "pragma GCC visibility push(hidden)" less ugly 2009-04-09 12:35:13 +00:00
Mike Frysinger 327fd47f36 skip some tests when fancy echo support is turned off 2009-04-09 07:50:18 +00:00
Mike Frysinger c3d91952d6 we arent testing echo -n here so use printf instead 2009-04-09 07:50:02 +00:00
Mike Frysinger 20300d0129 source the .config so tests can signal they need to be skipped due to feature disable 2009-04-09 07:49:43 +00:00
Mike Frysinger fe013a74ff patch by Stuart Hughes <seh@zee2.com> and Guenter <lists@gknw.net> to make "0" a special baud rate for getty where it uses this as "leave baud rate unchanged" 2009-04-09 07:08:04 +00:00
Denis Vlasenko f50caac53c hush: typo in comment 2009-04-09 01:40:15 +00:00
Denis Vlasenko a2218dd862 hush: fix thinko in re_execute_shell; pass even less junk to heredoc helper
function                                             old     new   delta
re_execute_shell                                     284     314     +30
setup_heredoc                                        290     303     +13
execv                                                 23       -     -23
2009-04-09 01:39:02 +00:00
Denis Vlasenko 5c090a96f9 hush: more rodust detection of unterminated strings etc;
fix a case where we forget to copy `cmd` text;
 optimize nommu heredoc helper by not passing environment to it;
 add several tests

function                                             old     new   delta
add_till_closing_paren                               256     308     +52
parse_stream                                        2337    2378     +41
add_till_backquote                                    82     111     +29
re_execute_shell                                     269     284     +15
handle_dollar                                        802     812     +10
parse_stream_dquoted                                 316     320      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/0 up/down: 151/0)             Total: 151 bytes
2009-04-08 21:51:33 +00:00
Denis Vlasenko ffe6f80851 expand leak_all1.tests 2009-04-08 16:59:24 +00:00
Denis Vlasenko 14725f82b6 slight tweak to the leak detector 2009-04-08 16:46:45 +00:00
Denis Vlasenko cc90f44402 hush: plug leak in run_pipe(). NOMMU only. 2009-04-08 16:40:34 +00:00
Denis Vlasenko 08daf564ae hush: add a leak test which currently fails 2009-04-08 12:11:23 +00:00
Denis Vlasenko c73b70c701 hush: add leak detector helper; fix/add tests for it
function                                             old     new   delta
builtin_memleak                                        -      92     +92
bltins                                               288     300     +12
2009-04-08 11:48:57 +00:00
Denis Vlasenko 3dfb035d8d hush: echo \2>file fix 2009-04-08 09:29:14 +00:00
Denis Vlasenko df6f95cedf FEATURE_FANCY_ECHO needs to be accessible for hush 2009-04-07 20:07:23 +00:00
Denis Vlasenko 02d6f1ad72 hush: fix heredoc expansion of $var and cmd
function                                             old     new   delta
expand_pseudo_dquoted                                  -     104    +104
setup_heredoc                                        215     275     +60
done_word                                            669     691     +22
parse_stream                                        1899    1902      +3
setup_redirects                                      196     191      -5
free_pipe                                            189     183      -6
expand_variables                                    2349    2229    -120
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/3 up/down: 189/-131)           Total: 58 bytes
2009-04-07 19:56:55 +00:00
Denis Vlasenko 25af86f73d hush: fix wrong comment 2009-04-07 13:29:27 +00:00
Denis Vlasenko af07b7c5b6 hush: fix heredoc <<- handling.
hush-misc/heredoc2.tests testcase needs only one fix now -
 $var and `cmd` expancsion in heredocs

function                                             old     new   delta
parse_redirect                                       265     306     +41
parse_stream                                        1866    1899     +33
2009-04-07 13:26:18 +00:00
Denis Vlasenko 50f3aa4547 hush: NOMMU-safe support of big heredocs
function                                             old     new   delta
setup_heredoc                                        116     215     +99
2009-04-07 10:52:40 +00:00
Mike Frysinger d4a24f2aae here documents have been added, so drop from TODO 2009-04-07 07:28:25 +00:00
Mike Frysinger 932e111418 use sleep rather than usleep 2009-04-07 06:08:14 +00:00
Mike Frysinger b509c9c670 add a pathological test case for here doc related to eof marker and other ugly corner cases 2009-04-07 06:06:05 +00:00
Mike Frysinger a4f331d3c3 implement support for parameter substitution via #/% operators 2009-04-07 06:03:22 +00:00
Denis Vlasenko 6c9be7f451 hush: heredoc support, based on patch by Mike Frysinger (vapier AT gentoo.org)
some TODOs are to be attacked later

function                                             old     new   delta
parse_stream                                        1461    1866    +405
parse_redirect                                         -     265    +265
setup_heredoc                                          -     116    +116
setup_redirects                                      151     196     +45
builtin_exit                                          49      47      -2
redirect_opt_num                                      61      55      -6
setup_redirect                                       212       -    -212
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 2/2 up/down: 831/-220)          Total: 611 bytes
2009-04-07 02:29:51 +00:00
Denis Vlasenko ab2b064342 hush: s/last_return_code/last_exitcode/g 2009-04-06 18:42:11 +00:00
Denis Vlasenko 0e15138c03 hush: fix "if false; then...fi" exitcode;
trim "keyword"-less hush by 10 bytes
2009-04-06 18:40:31 +00:00
Denis Vlasenko 4ed67dd3d5 make hush-misc/*.tests executable 2009-04-06 18:10:20 +00:00
Denis Vlasenko cd418a2670 hush: fix a bunch of obscure while/until/continue bugs
function                                             old     new   delta
run_list                                            1159    1214     +55
done_pipe                                            106     123     +17
done_command                                          86      98     +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 84/0)               Total: 84 bytes
2009-04-06 18:08:35 +00:00
Denis Vlasenko 8f8d013afc *.tests should be executable 2009-04-06 16:27:51 +00:00
Denis Vlasenko 715f712d15 move hush-parsing/and-or.tests to hush-misc/*
(which probably needs to be renamed to hush-execution...)
2009-04-06 16:17:51 +00:00
Mike Frysinger 3a64833eb9 add some brute force logic tests 2009-04-06 14:22:54 +00:00
Denis Vlasenko a2b11e3395 hush: fix "false && echo yes || echo no" bug 265
function                                             old     new   delta
run_list                                            1159    1189     +30
2009-04-06 14:11:13 +00:00
Denis Vlasenko 0969a49c08 hush: beautify re_execute_shell more 2009-04-06 13:05:57 +00:00
Denis Vlasenko 34e573d2ce hush: drop allocations in re_execute_shell
function                                             old     new   delta
hush_main                                           1127    1138     +11
re_execute_shell                                     286     256     -30
clean_up_after_re_execute                             66      30     -36
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 11/-66)            Total: -55 bytes
2009-04-06 12:56:28 +00:00
Mike Frysinger 3c7167b508 add tests for basic fd open/close/dupe 2009-04-06 12:36:10 +00:00
Mike Frysinger dc4178050a fix #>&- syntax for closing fds 2009-04-06 12:35:41 +00:00
Mike Frysinger 9052600feb fix redir1 tests -- usleep isnt standard in $PATH 2009-04-06 12:34:27 +00:00
Denis Vlasenko 5e883fb00d hush: micro-optimization. -37 bytes 2009-04-06 12:28:34 +00:00
Denis Vlasenko b1d11bf45e hush: more efficient filtering of "safe" arithmetic
function                                             old     new   delta
expand_variables                                    2170    2147     -23
2009-04-06 12:24:58 +00:00
Denis Vlasenko d0b4a8c285 hush: add <> and () as "safe" arith chars 2009-04-06 12:09:55 +00:00
Denis Vlasenko bfbc971f9f hush: print cd error to stderr; use fopen_or_warn in builtin_source;
prepare builtin_unset for function support
libbb: do not clear errno in fopen_or_warn

function                                             old     new   delta
builtin_unset                                        242     271     +29
fopen_or_warn                                         42      31     -11
builtin_cd                                            90      74     -16
builtin_source                                        89      72     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 29/-44)            Total: -15 bytes
2009-04-06 12:04:42 +00:00
Denis Vlasenko b0a6478eef hush: fix "export a=a b=b" (was not setting and exporting b)
function                                             old     new   delta
builtin_export                                       103     117     +14
2009-04-06 11:33:07 +00:00
Denis Vlasenko c8d27334a0 hush: update TODO list; + my usual pointless tweaks :( 2009-04-06 10:47:21 +00:00
Denis Vlasenko d3f973eab2 hush: mark SIGHUP TODOs better; don't disable SIGHUP for now,
small tweaks to comments
2009-04-06 10:21:42 +00:00
Denis Vlasenko a0e65120b5 hush: cosmetics, no code changes 2009-04-05 23:39:14 +00:00
Denis Vlasenko f4393046ef modprobe/insmod for 2.4: support compressed modules.
by Guenter (lists AT gknw.net)

function                                             old     new   delta
bb_init_module_24                                   4551    4570     +19
obj_load                                             786     794      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 27/0)               Total: 27 bytes
2009-04-05 23:25:09 +00:00
Denis Vlasenko 913a201bf0 hush: strip NULs from file input, they are PITA/impossible to handle correctly
function                                             old     new   delta
file_peek                                             89      93      +4
file_get                                             260     264      +4
2009-04-05 22:17:04 +00:00
Mike Frysinger 258275d85f drop HUSH_VER_STR since it has no relevance anymore -- just use BB_VER 2009-04-05 21:19:43 +00:00
Denis Vlasenko c4a7af55e9 hush: fix trap clearing in subshells on MMU; simplify NOMMU a bit:
function                                             old     new   delta
parse_stream_dquoted                                 335     324     -11
handle_dollar                                        849     800     -49
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-60)             Total: -60 bytes
2009-04-05 20:33:27 +00:00
Denis Vlasenko f937528571 hush: audit and fix "interactive shell" setup code.
function                                             old     new   delta
block_signals                                          -     139    +139
maybe_set_to_sigexit                                   -      47     +47
run_list                                            2018    2030     +12
expand_variables                                    2155    2165     +10
maybe_set_sighandler                                  47       -     -47
hush_main                                            992     918     -74
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 2/1 up/down: 208/-121)           Total: 87 bytes
2009-04-05 19:13:39 +00:00
Denis Vlasenko 46f9b6db80 hush: pass $! thru re-execution; try harder on re-exec; give error
msg if re-exec didn't work; other tweaks in main()

function                                             old     new   delta
hush_main                                           1144    1199     +55
re_execute_shell                                     237     286     +49
file_get                                             240     260     +20
clean_up_after_re_execute                             58      66      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 132/0)             Total: 132 bytes
2009-04-05 10:39:03 +00:00
Denis Vlasenko 232be3e79b hush: suppress bogus warning from 4.2.1 2009-04-05 09:16:00 +00:00
Denis Vlasenko 18f2a79f9b build system tweaks to account for latest hush changes 2009-04-05 09:02:11 +00:00
Denis Vlasenko d85a5df159 hush: randomconfig fixes 2009-04-05 08:43:57 +00:00
Denis Vlasenko cc4c693ec5 hush: plug the leak on NOMMU re-execute path
function                                             old     new   delta
clean_up_after_re_execute                              -      58     +58
re_execute_shell                                     226     244     +18
run_pipe                                            1271    1276      +5
generate_stream_from_string                          133     138      +5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 86/0)               Total: 86 bytes
2009-04-05 07:38:48 +00:00
Denis Vlasenko c3ff48b921 fixing mode on hush-leak/leak_argv1.tests 2009-04-05 02:14:59 +00:00
Denis Vlasenko 8a496d5db0 fixing mode on hush-leak/leak_argv1.tests 2009-04-05 02:14:37 +00:00
Denis Vlasenko 30db43b5c5 hush: fix passing of $n on NOMMU 2009-04-05 02:10:39 +00:00
Denis Vlasenko 16a0c74f63 hush: fix hush-misc/break5.tests NOMMU failure
function                                             old     new   delta
hush_main                                           1118    1144     +26
re_execute_shell                                     188     204     +16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 42/0)               Total: 42 bytes
2009-04-05 01:46:59 +00:00
Denis Vlasenko 0bb4a23506 hush: fix all testsuite failures on NOMMU except memory leak.
known TODOs: we do not pass traps and positional args yet.
2009-04-05 01:42:59 +00:00
Denis Vlasenko 609f2ab434 hush: enable NOMMU re-execution logic. Some testsuite entries
fail on NOMMU. Before it was much worse.
 No regressions on MMU, size:

function                                             old     new   delta
handle_dollar                                        626     632      +6
run_list                                            2018    2022      +4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 10/0)               Total: 10 bytes
2009-04-04 23:15:14 +00:00
Denis Vlasenko 9aa7d6fdc5 hush: preparatory patch for NOMMU-safe { list } handling.
function                                             old     new   delta
o_addblock                                             -      58     +58
o_addstr_with_NUL                                      -      27     +27
builtin_exit                                          47      49      +2
run_list                                            2020    2018      -2
o_addstrauto                                          27       -     -27
parse_stream                                        1508    1461     -47
o_addstr                                              58       -     -58
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 1/2 up/down: 87/-134)           Total: -47 bytes
2009-04-04 22:47:50 +00:00
Denis Vlasenko 42e78b978f ftpd: s/CONFIG_BUSYBOX_EXEC_PATH/bb_busybox_exec_path/ 2009-04-04 20:34:22 +00:00
Denis Vlasenko 34d4d89b2d hush: fix NOMMU hangs in pseudo_exec_argv. Add forgotted setting
of signal mask. Reuse same help string in all shells.

function                                             old     new   delta
builtin_exit                                          49      47      -2
pseudo_exec_argv                                     149     145      -4
builtin_help                                          74      63     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-17)             Total: -17 bytes
   text    data     bss     dec     hex filename
 825379     476    7616  833471   cb7bf busybox_old
 825341     476    7616  833433   cb799 busybox_unstripped
2009-04-04 20:24:37 +00:00
Denis Vlasenko 552433bc5a hush: fix "var=val >file" not creating file
function                                             old     new   delta
static.null_ptr                                        -       4      +4
run_list                                            2018    2020      +2
handle_dollar                                        667     626     -41
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 6/-41)             Total: -35 bytes
2009-04-04 19:29:21 +00:00
Denis Vlasenko a24c8caeb2 hush: remove code which errors out on $- and $_, it's useless;
wrap some longish lines

function                                             old     new   delta
handle_dollar                                        667     626     -41
2009-04-04 15:24:40 +00:00
Denis Vlasenko 7c9861214b hush: remove CHAR_xxx constants 2009-04-04 12:15:42 +00:00
Denis Vlasenko 6da69cddc0 hush: get rid of charmap[]
function                                             old     new   delta
parse_stream                                        1447    1508     +61
get_local_var_value                                    -      31     +31
run_list                                            2018    2020      +2
pseudo_exec_argv                                     151     149      -2
maybe_set_sighandler                                  50      47      -3
hush_exit                                             93      90      -3
builtin_wait                                         275     272      -3
check_and_run_traps                                  169     164      -5
hush_main                                            985     977      -8
file_get                                             260     240     -20
builtin_trap                                         438     414     -24
set_in_charmap                                        30       -     -30
lookup_param                                          31       -     -31
parse_and_run_stream                                 153      54     -99
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/9 up/down: 94/-228)          Total: -134 bytes
2009-04-04 12:12:58 +00:00
Mike Frysinger dfa9de7176 simplify maybe_die() slightly 2009-04-03 22:48:10 +00:00
Denis Vlasenko db2a9b683a hush: finally make cmd safe on NOMMU
function                                             old     new   delta
generate_stream_from_string                            -     157    +157
expand_variables                                    2050    2003     -47
generate_stream_from_list                            139       -    -139
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 157/-186)          Total: -29 bytes
2009-04-03 22:31:18 +00:00
Denis Vlasenko e0755e58ca hush: yet another randomconfig fix 2009-04-03 21:16:45 +00:00
Denis Vlasenko cc8289dc04 shell/math: randomconfig fix 2009-04-03 21:13:31 +00:00
Denis Vlasenko 60b392fd5b hush: randomconfig fixes 2009-04-03 19:14:32 +00:00
Denis Vlasenko b6e6556b31 hush: improve parse_stream: does not require parsing context struct;
cleans up on syntax errors (we used to leak memory in this case);
 much simplified interface to the rest of hush.

function                                             old     new   delta
parse_stream                                        1204    1447    +243
done_word                                            658     669     +11
static_get                                            22      28      +6
builtin_source                                        84      89      +5
parse_and_run_file                                    27      30      +3
parse_and_run_string                                  31      27      -4
builtin_eval                                          55      50      -5
hush_main                                            991     985      -6
free_pipe_list                                        39      31      -8
free_pipe                                            210     189     -21
expand_variables                                    2242    2199     -43
parse_and_run_stream                                 289     153    -136
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/7 up/down: 268/-223)           Total: 45 bytes
2009-04-03 16:49:04 +00:00
Denis Vlasenko 240c255d8b hush: simplify parse_stream
function                                             old     new   delta
parse_and_run_stream                                 292     289      -3
parse_stream                                        1218    1204     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-17)             Total: -17 bytes
2009-04-03 03:45:05 +00:00
Denis Vlasenko 3718168b87 hush: fix bug with local environment vars in pipes; simplify parse_stream()
function                                             old     new   delta
parse_stream                                        1238    1218     -20
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-20)             Total: -20 bytes
2009-04-03 03:19:15 +00:00
Denis Vlasenko f9f7429346 hush: explain parsing context structure
plug leak in setup_redirect on error path

function                                             old     new   delta
done_command                                          84      86      +2
done_word                                            657     658      +1
done_pipe                                            105     106      +1
initialize_context                                    39      38      -1
setup_redirect                                       219     212      -7
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 4/-8)               Total: -4 bytes
2009-04-03 00:07:05 +00:00
Denis Vlasenko 027e3fddb5 hush: straighten parse_stream() API a bit
function                                             old     new   delta
parse_stream                                        1240    1238      -2
expand_variables                                    2272    2242     -30
parse_and_run_stream                                 338     292     -46
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-78)             Total: -78 bytes
2009-04-02 22:50:40 +00:00
Mike Frysinger a36258f288 trim trailing slashes from specified subdir so we output to the right place 2009-04-02 22:46:52 +00:00
Denis Vlasenko b7aaae9052 hush: rename ->o_quote to ->o_escape
hush_test/hush-arith/*: new tests for arithmetic evaluation
2009-04-02 20:17:49 +00:00
Mike Frysinger 7a79afa3ca Arithmetic Expansion is supported now in hush, so drop from TODO 2009-04-02 17:06:35 +00:00
Denis Vlasenko f328e00b10 hush: do not inadvertently parse $((1 + "22")) as ok.
-20 bytes code size
2009-04-02 16:55:38 +00:00
Denis Vlasenko 2f1d394214 hush: make
a=55; echo $(($a + 1)) $((1 + $((2)) + `echo $a`))
 work as expected

function                                             old     new   delta
handle_dollar                                          -     667    +667
parse_stream_dquoted                                   -     316    +316
expand_variables                                    2124    2272    +148
is_assignment                                        134     215     +81
parse_stream                                        2038    1240    -798
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/1 up/down: 1212/-798)         Total: 414 bytes
2009-04-02 16:31:29 +00:00
Denis Vlasenko b29eb6ed25 shells: do not need to have math state global
function                                             old     new   delta                           
ash_arith                                              -     143    +143                           
expand_variables                                    2102    2124     +22                           
popstring                                            134     140      +6                           
parse_command                                       1460    1463      +3                           
trapcmd                                              236     238      +2                           
changepath                                           197     196      -1                           
raise_interrupt                                       86      83      -3                           
hush_main                                           1012     991     -21                           
ash_main                                            1388    1364     -24                           
arith_set_local_var                                   73      34     -39                           
dash_arith                                           117       -    -117                           
------------------------------------------------------------------------------                     
(add/remove: 1/1 grow/shrink: 4/5 up/down: 176/-205)          Total: -29 bytes
2009-04-02 13:46:27 +00:00
Denis Vlasenko 0dfe1d26a9 fix ash-alias/alias.tests failure 2009-04-02 12:57:38 +00:00
Mike Frysinger 98c52645c0 split math code out of ash and into a standalone library so we can use it in any shell (like hush!) 2009-04-02 10:02:37 +00:00
Denis Vlasenko 551ffdccea more of pointless whitespace fixes 2009-04-01 19:48:05 +00:00
Denis Vlasenko bd79c3d337 dhcpd: remember and record hostnames; optimize get_option
dumpleases: show hostnames

function                                             old     new   delta
add_lease                                            230     292     +62
send_offer                                           403     421     +18
send_ACK                                             232     249     +17
read_leases                                          249     258      +9
dumpleases_main                                      604     609      +5
nobody_responds_to_arp                                84      86      +2
udhcp_end_option                                      32      30      -2
udhcp_get_option                                     222     171     -51
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/2 up/down: 113/-53)            Total: 60 bytes
2009-04-01 12:36:09 +00:00
Denis Vlasenko 3266aa9ec2 trailing whitespace removal 2009-04-01 11:24:04 +00:00
Denis Vlasenko 88b8f0a347 sendmail: update by Vladimir
build system: tweak for rare case where include/autoconf.h
  does not get updated

function                                             old     new   delta
packed_usage                                       26238   26242      +4
sendmail_main                                       1353     897    -456
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 4/-456)           Total: -452 bytes
2009-03-31 23:41:53 +00:00
Denis Vlasenko d308106245 hust_test/*: use "$THIS_SH" instead of hush 2009-03-31 22:14:32 +00:00
Denis Vlasenko 9983d806d9 volumeid: fix bug 249 "findfs finds the wrong partition" 2009-03-31 19:47:34 +00:00
Denis Vlasenko f6fbd62760 ash: add/improve comments, no code changes 2009-03-31 19:36:58 +00:00
Denis Vlasenko 46aeab9a34 ash: fix $IFS handling in read. closes bug 235 2009-03-31 19:18:17 +00:00
Denis Vlasenko 7566bae197 hush: fix wait builtin
function                                             old     new   delta
builtin_wait                                         174     275    +101
sigwaitinfo                                            -      48     +48
__GI_sigwaitinfo                                       -      48     +48
check_and_run_traps                                  133     169     +36
checkjobs                                            349     380     +31
hush_main                                            971     991     +20
static.zero_timespec                                   -       8      +8
run_list                                            2010    2016      +6
file_get                                             254     260      +6
static.zero_ts                                         8       -      -8
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 6/0 up/down: 304/-8)            Total: 296 bytes
2009-03-31 17:24:49 +00:00
Denis Vlasenko 70c6e40e47 libbb: fix typo in comment 2009-03-31 13:14:18 +00:00
Denis Vlasenko 1b62ead313 hush: don't lie in comment 2009-03-31 13:13:17 +00:00
Denis Vlasenko 7b830e78f2 hush: fix comments, no code changes 2009-03-31 13:05:32 +00:00
Denis Vlasenko 422cd7c81c hush: make ^C work again, ^Z probably isn't working
function                                             old     new   delta
file_get                                             219     254     +35
check_and_run_traps                                  122     133     +11
run_list                                            2001    2010      +9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 55/0)               Total: 55 bytes
2009-03-31 12:41:52 +00:00
Denis Vlasenko abedaac842 hush: do not reset sighaldlers after fork - instead, prevent them from doing any harm
if they will be called. saves many sigaction calls on every fork.

function                                             old     new   delta
hush_main                                            887     971     +84
sigexit                                               54      65     +11
run_list                                            2006    2001      -5
maybe_set_sighandler                                  76      50     -26
set_fatal_sighandler                                 186       -    -186
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/2 up/down: 95/-217)          Total: -122 bytes
2009-03-31 12:03:40 +00:00
Denis Vlasenko d5762932fb hush: rework signal and trap handling. Some smaller bits are TODO,
expect minor breakage

function                                             old     new   delta
set_fatal_sighandler                                  12     186    +174
check_and_run_traps                                    -     122    +122
maybe_set_sighandler                                   -      76     +76
hush_main                                            831     887     +56
sigtimedwait                                           -      50     +50
__GI_sigtimedwait                                      -      50     +50
hush_exit                                             49      93     +44
set_mode                                             749     777     +28
pseudo_exec_argv                                     131     151     +20
static.zero_ts                                         -       8      +8
expand_variables                                    1962    1970      +8
builtin_wait                                         172     174      +2
set_misc_sighandler                                   12       -     -12
set_jobctrl_sighandler                                12       -     -12
handler_ctrl_c                                        16       -     -16
builtin_set_mode                                      28       -     -28
handle_trap                                           97       -     -97
handler_ctrl_z                                       107       -    -107
builtin_trap                                         545     438    -107
run_list                                            2149    2006    -143
------------------------------------------------------------------------------
(add/remove: 5/6 grow/shrink: 7/2 up/down: 638/-522)          Total: 116 bytes
2009-03-31 11:22:57 +00:00
Mike Frysinger d690f68554 implement unset semantics as required by POSIX 2009-03-30 06:50:54 +00:00
Mike Frysinger 5f9f1506ad fix DOC build output to be like kbuild standard 2009-03-30 05:26:34 +00:00
Mike Frysinger 0080ea7992 update trap poisx link 2009-03-30 03:50:07 +00:00
Mike Frysinger 87824e0e50 do not automatically display job information when the shell is not interactive 2009-03-30 00:19:30 +00:00
Mike Frysinger 681a4b7f06 enable trap tests 2009-03-29 23:49:46 +00:00
Mike Frysinger 9f8128f480 first pass at trap support in hush 2009-03-29 23:49:37 +00:00
Denis Vlasenko 0d907eab6c modutils: dont pass NULL options to init_module() 2009-03-29 17:25:14 +00:00
Denis Vlasenko a83dbd4146 build system: hdparm -d is not that dangerous, remove warning 2009-03-29 17:13:20 +00:00
Denis Vlasenko a6eb7f4ddf sendmail: add more example in usage text 2009-03-29 16:53:25 +00:00
Denis Vlasenko e1de3af989 module loading for 2.4: use fd-based io instead of FILE based;
use xlseek and xread; simpler check for ELF signature.

   text    data     bss     dec     hex filename
 824460     476    7616  832552   cb428 busybox_old
 824333     476    7616  832425   cb3a9 busybox_unstripped
2009-03-29 16:38:59 +00:00
Mike Frysinger fd303b11ef add test cases for trap ... but disabled for now until trap support is committed 2009-03-29 09:54:40 +00:00
Denis Vlasenko 038fe44713 sysctl: move code around to get rid of forward references.
(incidentally it helps gcc to make code smaller)
2009-03-29 02:23:16 +00:00
Denis Vlasenko 5a6617acb8 sysctl: fix broken -p [file] - close bug 231 2009-03-29 02:22:19 +00:00
Mike Frysinger b975febeea mark msh as deprecated 2009-03-29 00:52:41 +00:00
Mike Frysinger 40b8dc410e use bb_strtou() in umask/wait and check errno to see if there was a problem rather than using endp 2009-03-29 00:50:30 +00:00
Mike Frysinger 8ec1c9dc6e make sure we check job status whenever updating the prompt 2009-03-29 00:45:26 +00:00
Mike Frysinger 0b87e4ad15 test for invalid named variables 2009-03-28 21:06:38 +00:00
Mike Frysinger 7c3e52c1bd do not let handle_dollar() accept vars that start with a digit 2009-03-28 21:06:22 +00:00
Mike Frysinger 56bdea1b43 implement wait builtin 2009-03-28 20:01:58 +00:00
Denis Vlasenko e61f07f036 remove ((expr)) bash'ism 2009-03-28 19:31:34 +00:00
Denis Vlasenko 701ac1864b randomconfig fix 2009-03-28 19:22:08 +00:00
Mike Frysinger 5a82845f60 update the normally disabled debug code around the syntax() func to use new maybe_die() 2009-03-28 19:09:04 +00:00
Denis Vlasenko a2333c8938 randomtest fixes 2009-03-28 19:08:23 +00:00
Mike Frysinger 78f9d8eb7a add hush tests for parameter expansion 2009-03-28 18:55:34 +00:00
Mike Frysinger 6379bb4fde implement most POSIX parameter expansions (~+500bytes) 2009-03-28 18:55:03 +00:00
Mike Frysinger 42ab86520e make sure we exit based on test failure rather than always exiting with 0 2009-03-28 15:43:47 +00:00
Mike Frysinger 25a6ca0dd4 split up feature todo by posix/bash 2009-03-28 13:59:26 +00:00
Mike Frysinger ad88d5a4cf unify set handling with command line processing, fixup set argv processing so it doesnt clobber argv when setting options, and barf on unhandled set options 2009-03-28 13:44:51 +00:00
Mike Frysinger 19a7ea126a handle the "-s" command line option that POSIX requires 2009-03-28 13:02:11 +00:00
Mike Frysinger a71cfa8aa1 rename "-f" (fake) option to "-n" to match POSIX 2009-03-28 12:57:54 +00:00
Mike Frysinger d006edb2ca tweak format modifier in debug code to fixup gcc warning 2009-03-28 12:43:53 +00:00
Mike Frysinger ec2c655702 convert some of the ENABLE_FEATURE_EDITING from CPP if to C if 2009-03-28 12:24:44 +00:00
Mike Frysinger 39456a18a1 stop lying about [[ test support 2009-03-28 12:21:57 +00:00
Denis Vlasenko 781b672b37 mkfs.vfat: fix a problem with over-estimating FAT size 2009-03-28 12:17:20 +00:00
Mike Frysinger 70a2c8d531 make lash deprecation more prominent 2009-03-28 12:12:58 +00:00
Denis Vlasenko f54dd09171 mkfs.vfat: mkdosfs compat with choosing clyster size 2009-03-28 03:22:08 +00:00
Denis Vlasenko 14ee4e65f1 mkfs.vfat: more of pointless tweaking 2009-03-28 02:28:58 +00:00
Denis Vlasenko 020f465cbd mkfs.vfat: small tweak to comments 2009-03-28 02:18:49 +00:00
Denis Vlasenko 9d04b6b630 mkdosfs (aka mkfs.vfat): new applet by Vladimir
text    data     bss     dec     hex filename
 821202     476    7616  829294   ca76e busybox_old
 823577     476    7616  831669   cb0b5 busybox_unstripped
2009-03-28 02:13:01 +00:00
Denis Vlasenko 4d3a812b71 ls: warning fix
rm: accept and ignore -v (verbose)
2009-03-27 17:22:00 +00:00
Denis Vlasenko 3603cd2808 tail: fix tail +N syntax not working. Closes bug 221. 2009-03-27 02:36:02 +00:00
Mike Frysinger bfc0fae952 enable most job functions on no-mmu systems 2009-03-26 18:14:16 +00:00
Denis Vlasenko f9beb61a81 tftp: when we infer local name from remote (-r [/]path/path/file),
strip path. This mimics wget and is generally more intuitive.
2009-03-25 03:55:53 +00:00
Mike Frysinger b2705e1652 do not make startup banner depend on job support 2009-03-23 08:44:02 +00:00
Denis Vlasenko c0ea82a457 libbb: revent previous version of "concurrent history updating"
and replace it with one which does not "snoop" history written
by others. (1) it is what bug 185 needs, and (2) it is less bloaty:

function                                             old     new   delta
load_history                                           -     252    +252
read_line_input                                     3155    3287    +132
next_token                                           914     918      +4
qrealloc                                              36      33      -3
getoptscmd                                           713     708      -5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 388/-8)            Total: 380 bytes
2009-03-23 06:33:37 +00:00
Mike Frysinger ddbee974b4 move parse_stream out of ENABLE_HUSH_TICK to avoid implicit decl/build error 2009-03-22 22:48:41 +00:00
Denis Vlasenko 57abf9e947 libbb: make history saving/loading concurrent-safe
* all history writers always append (not overwrite) history files
* they reload history if they detect that file length has changed since last
write
* they trim history file only when it grows 4 times longer than MAXLINES
* they do this atomically by creating new file and renaming it to old

Unfortunately, this comes at a price:

function                                             old     new   delta
load_history                                           -     346    +346
read_line_input                                     3155    3358    +203
new_line_input_t                                      17      31     +14
...irrelevant small jitter...
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/5 up/down: 573/-13)           Total: 560 bytes
2009-03-22 19:00:05 +00:00
Denis Vlasenko 3fd1046300 timeout: fix parsing of -t NUM on MMU 2009-03-22 14:49:00 +00:00
Denis Vlasenko 424f79b48f hush: rearrange functions to reduce amount of forward references.
Minimal code changes.
2009-03-22 14:23:34 +00:00
Denis Vlasenko e1300f6fc7 hush: fix segv at repeated "set -- a b c" + "shift" 2009-03-22 11:41:18 +00:00
Denis Vlasenko 786ce17d6d hush: fix strcpy of potentially overlapping strings 2009-03-21 21:51:11 +00:00
Denis Vlasenko ccff0b962c msh testsuite: fix false positive, tweak run stript 2009-03-21 19:58:58 +00:00
Denis Vlasenko 3a014b85dc ls: make readlink error to not disrupt output (try ls -l /proc/self/fd).
libbb: make xmalloc_readlink_or_warn warning more specific.

function                                             old     new   delta
xmalloc_readlink_or_warn                              33      61     +28
showfiles                                           1495    1460     -35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 28/-35)             Total: -7 bytes
2009-03-21 19:11:23 +00:00
Denis Vlasenko 05af832097 cpio: more compat: -0 and -L options
function                                             old     new   delta
cpio_main                                           1417    1473     +56
2009-03-20 23:01:48 +00:00
Denis Vlasenko 83518d18a3 Compatibility fixes:
grep: support -z
find: support --mindepth
  together +45 bytes
cpio: support -p (configurable, +230 bytes)
libbb: tweaks for cpio
2009-03-20 22:17:13 +00:00
Denis Vlasenko 0b28103cc7 cd: "support" -v by ignoring it 2009-03-20 14:04:00 +00:00
Denis Vlasenko feecc7b74e hush: tweak testsuite 2009-03-20 12:12:33 +00:00
Denis Vlasenko a8b6dff97f hush: fix bug 207 and "hush -c" parameter passing.
Now hush -c 'printf "%s\n" "$@"' (prints "\n")
 and hush -c 'printf "%s\n" "$@"' qwe asd (prints "asd\n")
 both work correctly
2009-03-20 12:05:14 +00:00
Denis Vlasenko 5368ad53e9 ash: expand comment 2009-03-20 10:20:08 +00:00
Denis Vlasenko 11fb7cf5af hush: fix set [--] params. Closes bug 199.
function                                             old     new   delta
builtin_set                                           55     194    +139
add_strings_to_strings                                 -     130    +130
add_string_to_strings                                110      26     -84
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 269/-84)           Total: 185 bytes
2009-03-20 10:13:08 +00:00
Denis Vlasenko 1bb3d7e450 ash: add missing comma in debug scaffolding 2009-03-20 07:45:36 +00:00
Denis Vlasenko b9e70ddf2d ash: fix a case where we close wrong descriptor; add debug hack for that 2009-03-20 01:24:08 +00:00
Denis Vlasenko f173395c4a ash: DEBUG should be 0 :) 2009-03-19 23:21:55 +00:00
Denis Vlasenko b21f379639 ash: fix TRACE commands 2009-03-19 23:09:58 +00:00
Denis Vlasenko 653d8e79b2 ash: make evaltree save/restore int suppression depth.
Hopefully this fixes bug 189. Not confirmed by users yet.

function                                             old     new   delta
evaltree                                             809     842     +33
evalvar                                             1374    1376      +2
2009-03-19 21:59:35 +00:00
Denis Vlasenko 731de5ce76 doc update 2009-03-19 13:42:05 +00:00
Denis Vlasenko 4b875708c1 ash: in dotrap(), do not clear gotsig[] for SIGINT if there is no handler
for it, otherwise raise interrupt gets confused later.
 The rest are readability fixes.

function                                             old     new   delta                                                                                                       
evaltreenr                                           817     818      +1                                                                                                       
evaltree                                             817     818      +1                                                                                                       
evalstring                                            88      89      +1                                                                                                       
cmdloop                                              420     419      -1                                                                                                       
evalskip                                               4       1      -3                                                                                                       
breakcmd                                              84      81      -3                                                                                                       
ash_main                                            1382    1379      -3                                                                                                       
evalloop                                             183     177      -6                                                                                                       
evalfor                                              231     225      -6                                                                                                       
------------------------------------------------------------------------------                                                                                                 
(add/remove: 0/0 grow/shrink: 3/6 up/down: 3/-22)             Total: -19 bytes
2009-03-19 13:30:04 +00:00
Denis Vlasenko 0354aba9a1 df: fix FEATURE_DF_FANCY=off, FEATURE_HUMAN_READABLE=on case. 2009-03-19 03:56:20 +00:00
Denis Vlasenko 7f88e34e1a ash: tentatively fix bug 189. 2009-03-19 03:36:18 +00:00
Denis Vlasenko 5981ba5843 init: test for vt terminal with VT_OPENQRY,
assume that anything else is TERM=vt102, not TERM=linux.
 (Serial console test is less correct)
 Tentatively closes bug 195.

function                                             old     new   delta
init_main                                            946     919     -27
2009-03-19 02:35:44 +00:00
Denis Vlasenko 5c2b81470d ash: fix "ash -c 'exec 1>&0'" complaining that fd 0 is busy 2009-03-19 01:59:59 +00:00
Denis Vlasenko c1969f69b1 ls: make color-related code more readable. Fix a case when
it was working non-deterministically.

function                                             old     new   delta
bold                                                   -      34     +34
showfiles                                           1508    1495     -13
fgcolor                                               50      34     -16
bgcolor                                               34       -     -34
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/2 up/down: 34/-63)            Total: -29 bytes
2009-03-18 22:39:34 +00:00
Denis Vlasenko cbb4e61dd5 httpd: add comment explaining why SERVER_NAME etc is not set. 2009-03-18 20:00:46 +00:00
Denis Vlasenko 9f57cf6604 ftpd: fix command fetching to not do it in 1-byte reads;
fix command de-escaping. Tested to download files with embeeded \xff and LF.
libbb: tweaks for the above

function                                             old     new   delta
ftpd_main                                           2231    2321     +90
xmalloc_fgets_internal                               190     222     +32
xmalloc_fgets_str_len                                  -      27     +27
xmalloc_fgets_str                                      7      23     +16
xmalloc_fgetline_str                                  10      26     +16
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 181/0)             Total: 181 bytes
2009-03-18 17:32:44 +00:00
Denis Vlasenko fce4a9454c ftpd: add some comments 2009-03-18 16:02:54 +00:00
Denis Vlasenko e3b840ce98 ftpd: trim messages (but make sure they still make sense)
text    data     bss     dec     hex filename                                                                                                                               
   4400       0       0    4400    1130 ftpd_old.o
   4346       0       0    4346    10fa ftpd.o
2009-03-18 14:25:28 +00:00
Denis Vlasenko 5b492ee876 ftpd: do not use nasty tricks for re-execing if we are on MMU machine.
On NOMMU, code is alomost the same, on MMU:

function                                             old     new   delta
handle_dir_common                                    223     390    +167
ftpd_main                                           2306    2231     -75
popen_ls                                             203       -    -203
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 167/-278)         Total: -111 bytes
2009-03-18 14:12:22 +00:00
Denis Vlasenko 1432cb4bd9 ftpd: add support for MDTM, I see clients often use it,
it may allow client-side caching.

function                                             old     new   delta
ftpd_main                                           2232    2306     +74
gmtime_r                                               -      19     +19
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 93/0)               Total: 93 bytes
2009-03-18 00:45:00 +00:00
Denis Vlasenko 3a7a1eba2e ftpd: document NLST format 2009-03-17 13:03:06 +00:00
Denis Vlasenko 1a82555108 ftpd: instead of wordy HELP, implement useful, and smaller, FEAT.
(HELP is still "supported" as an alias to FEAT)

   text    data     bss     dec     hex filename
 807331     468    7856  815655   c7227 busybox_old
 807246     468    7856  815570   c71d2 busybox_unstripped
2009-03-17 12:40:34 +00:00
Denis Vlasenko edb0de4283 ftpd: implement -vv verbosity
function                                             old     new   delta
ftpd_main                                           2097    2190     +93
verbose_log                                            -      33     +33
cmdio_write_raw                                       12      34     +22
cmdio_write_ok                                        25      45     +20
cmdio_write_error                                     25      45     +20
cmdio_write                                           62      78     +16
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/0 up/down: 204/0)             Total: 204 bytes
2009-03-17 12:23:24 +00:00
Denis Vlasenko e6c94a611a ftpd: tweak timeout code 2009-03-17 05:11:51 +00:00
Denis Vlasenko 99d71da1cf chat: update by Vladimir
1) to treat timeout more correctly (timeout affects whole send command
    duration, not a single char); 
 2) to recognize RECORD directive.

function                                             old     new   delta
chat_main                                           1246    1359    +113
exitcode                                               1       -      -1
2009-03-16 23:06:23 +00:00
Denis Vlasenko 074c9036b2 ftpd: fix thinko: set_nport takes port in network order 2009-03-16 21:01:41 +00:00
Denis Vlasenko fbf5846ce1 ftpd: dont use fdprintf for simple status messages
function                                             old     new   delta
ftpd_main                                           2025    2055     +30
cmdio_write_ok                                        17      25      +8
cmdio_write_error                                     17      25      +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 46/0)               Total: 46 bytes
2009-03-16 20:54:45 +00:00
Denis Vlasenko 43bb7bba3b ftpd: simplify PORT check by assuming IP = peer's IP.
Should be as safe as before this change.

function                                             old     new   delta
ftpd_main                                           2115    2025     -90
2009-03-16 19:54:06 +00:00
Denis Vlasenko 20c8216897 ftpd: add idle and absolute timeouts. This is a security issue,
otherwise ftpd may end up hanging indefinitely.

function                                             old     new   delta
timeout_handler                                        -     110    +110
ftpd_main                                           2019    2115     +96
packed_usage                                       25662   25685     +23
handle_upload_common                                 306     322     +16
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 245/0)             Total: 245 bytes
2009-03-16 16:19:53 +00:00
Denis Vlasenko f2160b6a09 ftpd: security tightened up:
PORT is not allowed on !IPv4
 PORT must have IP == peer's IP
 upload is allowed only into regular files

function                                             old     new   delta
ftpd_main                                           1815    2019    +204
handle_upload_common                                 260     306     +46
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 250/0)             Total: 250 bytes
2009-03-16 14:53:54 +00:00
Denis Vlasenko 7a6766428e awk: fix compat issue found by gpm build
function                                             old     new   delta
as_regex                                             105     131     +26
hash_find                                            247     233     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 26/-14)             Total: 12 bytes
2009-03-15 22:20:31 +00:00
Denis Vlasenko 9210a36495 tr: support -C as synonym to -c 2009-03-15 16:41:55 +00:00
Denis Vlasenko fc58ba1298 ftpd: fix the bug where >2GB file ops report errors;
make a few simplifications; add TODOs.

function                                             old     new   delta
port_or_pasv_was_seen                                  -      37     +37
get_remote_transfer_fd                               104     109      +5
handle_upload_common                                 265     260      -5
handle_dir_common                                    228     223      -5
popen_ls                                             211     203      -8
ftpd_main                                           1825    1815     -10
data_transfer_checks_ok                               37       -     -37
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/4 up/down: 42/-65)            Total: -23 bytes
2009-03-15 15:54:58 +00:00
Denis Vlasenko 823f10b8f0 sha: merge K[] for sha256 and 512
function                                             old     new   delta
sha_K                                                  -     640    +640
sha256_process_block64                               440     425     -15
sha512_process_block128                             1336    1283     -53
K512_lo                                              320       -    -320
K256                                                 320       -    -320
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 0/2 up/down: 640/-708)          Total: -68 bytes
2009-03-15 04:56:51 +00:00
Denis Vlasenko 8ec8d5e3db sha: fix thinko in sha512; add FAST_FUNC to sha1/sha256
function                                             old     new   delta
sha512_process_block128                             1334    1336      +2
sha1_hash                                            112     111      -1
sha256_process_block64                               446     440      -6
sha1_process_block64                                 494     484     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 2/-17)             Total: -15 bytes
2009-03-15 02:56:00 +00:00
Denis Vlasenko e9afc468fa sha: merge sha1/sha256 handling (they are similar enough for this),
shrink sha215 code

function                                             old     new   delta
sha1_end                                             129     142     +13
sha1_process_block64                                 486     494      +8
sha256_begin                                          37      44      +7
sha1_begin                                            49      56      +7
sha1_hash                                            108     112      +4
...
sha512_end                                           204     184     -20
sha512_process_block128                             1405    1334     -71
sha256_process_block64                               520     446     -74
sha256_end                                           147       -    -147
sha512_hash                                          297     130    -167
sha256_hash                                          260       -    -260
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 11/9 up/down: 59/-752)         Total: -693 bytes
2009-03-15 02:28:05 +00:00
Denis Vlasenko 7241e6d377 uname: correct cut/paste error
touch: add long options

function                                             old     new   delta
static.longopts                                      137     162     +25
touch_main                                           221     231     +10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 35/0)               Total: 35 bytes
2009-03-15 01:28:30 +00:00
Denis Vlasenko 7aaedcf21e mount: support "-O option"; stop trying to mount swap partitions
function                                             old     new   delta
mount_main                                           975    1152    +177
umount_main                                          640     636      -4
packed_usage                                       25666   25662      -4
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 177/-8)            Total: 169 bytes
2009-03-14 22:57:20 +00:00
Denis Vlasenko 447ab18cf6 uname: support long options 2009-03-14 18:41:19 +00:00
Denis Vlasenko 3b5c9b8885 insmod/modprobe: do not pass NULL to kernel as module parameter 2009-03-13 23:43:26 +00:00
Denis Vlasenko 1f0b95f147 tar: make FEATURE_TAR_AUTODETECT work with DESKTOP off too. 2009-03-13 14:26:44 +00:00
Denis Vlasenko c8329c9568 sha: reduce sha256/512 context size. Make sha1/sha256 code more similar
function                                             old     new   delta
sha512_end                                           182     204     +22
sha256_end                                           137     147     +10
sha1_hash                                            113     108      -5
sha1_end                                             143     129     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 32/-19)             Total: 13 bytes
2009-03-12 19:06:18 +00:00
Denis Vlasenko 4a43057268 sha: tiny shrink 2009-03-12 17:50:50 +00:00
Denis Vlasenko ddb1b85053 add comment about sha testing 2009-03-12 16:05:02 +00:00
Denis Vlasenko cd2cd312b7 shrink sha hashing a bit more (remove wbuflen field from ctx),
remove the requirement for aligned buffer

function                                             old     new   delta
sha512_hash                                          262     297     +35
sha1_end                                             136     143      +7
passwd_main                                         1019    1023      +4
sha256_end                                           135     137      +2
count_lines                                           72      74      +2
sha256_hash                                          259     260      +1
popstring                                            164     158      -6
sha512_begin                                          88      81      -7
sha256_begin                                          44      37      -7
parse_expr                                           832     824      -8
bbunpack                                             446     438      -8
sha256_process_block64                               529     520      -9
md5_end                                              166     151     -15
evaltreenr                                           817     802     -15
evaltree                                             817     802     -15
sha512_end                                           204     182     -22
sha512_process_block128                             1444    1405     -39
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/11 up/down: 51/-151)         Total: -100 bytes
2009-03-12 15:40:27 +00:00
Denis Vlasenko 6a5d9faa29 shrink sha hashing
function                                             old     new   delta
sha512_hash                                          262     281     +19
sha512_end                                           204     221     +17
sha1_hash                                            128     113     -15
static.mask                                           16       -     -16
static.bits                                           16       -     -16
sha1_end                                             160     136     -24
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 2/2 up/down: 36/-71)            Total: -35 bytes
2009-03-12 15:39:11 +00:00
Denis Vlasenko 4abaec50a2 popmaildir: fix several grave bugs with using memory past end of malloc block 2009-03-12 15:35:26 +00:00
Mike Frysinger dec37b3232 the -elf2flt flag can be used w/out -Wl, so drop the requirement so people can use either form 2009-03-12 07:56:49 +00:00
Denis Vlasenko 98c87f7575 sha256/512: code shrink. Run-tested.
function                                             old     new   delta
sha512_process_block128                                -    1444   +1444
sha1_process_block64                                   -     542    +542
sha256_process_block64                                 -     529    +529
K512_lo                                                -     320    +320
K256                                                   -     320    +320
init512_lo                                             -      32     +32
init256                                                -      32     +32
sha1_hash                                             99     128     +29
sha256_end                                           160     135     -25
sha1_end                                             189     160     -29
sha512_end                                           237     204     -33
sha256_begin                                          77      44     -33
sha512_begin                                         154      88     -66
sha256_hash                                          338     259     -79
sha512_hash                                          358     262     -96
sha1_compile                                         542       -    -542
sha256_process_block                                 594       -    -594
static.K                                             896       -    -896
sha512_process_block                                1861       -   -1861
------------------------------------------------------------------------------
(add/remove: 7/4 grow/shrink: 1/7 up/down: 3248/-4254)      Total: -1006 bytes
   text    data     bss     dec     hex filename
 808013     468    7856  816337   c74d1 busybox_old
 807007     468    7856  815331   c70e3 busybox_unstripped
2009-03-11 21:15:51 +00:00
Denis Vlasenko 54ac03a618 *: remove LOG_NOWAIT 2009-03-11 15:59:49 +00:00
Denis Vlasenko 4221e90ae4 ftpd: stop unconditional logging to syslog. This was the only applet
which was doing it. Added option -S to enable it when desired.

function                                             old     new   delta
packed_usage                                       25647   25666     +19
ftpd_main                                           1826    1825      -1
2009-03-11 15:07:44 +00:00
Denis Vlasenko a19e64933c docs/logging_and_backgrounding.txt: new mini-doc
dnsd: remove statics, remove nerly-useless SIGINT handler
crond: correct more of logfile to 0666 (as usual, umask allows
 user to remove unwanted bits).
nameif: print errors to stderr too, not just to syslog

function                                             old     new   delta
udhcp_read_interface                                 308     306      -2
ttl                                                    4       -      -4
fileconf                                               4       -      -4
dnsentry                                               4       -      -4
interrupt                                             19       -     -19
dnsd_main                                           1463    1394     -69
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 0/2 up/down: 0/-102)           Total: -102 bytes
   text    data     bss     dec     hex filename
 808161     476    7864  816501   c7575 busybox_old
 807994     468    7856  816318   c74be busybox_unstripped
2009-03-11 14:40:00 +00:00
Denis Vlasenko 4774179cb9 mail.c: more robust handling of SIGCHLD
init: more robust signal handling
2009-03-10 16:01:57 +00:00
Denis Vlasenko 245f91b649 ftpd + ls - timestamp = confused Mozilla. Prevent that. 2009-03-09 22:37:23 +00:00
Denis Vlasenko 5b28d314e7 ftpd: add LOG_NDELAY to openlog 2009-03-09 17:22:16 +00:00
Denis Vlasenko 1a6adbd71b uniq: strncmp(a,b, -1) might be problematic, use INT_MAX instead 2009-03-09 16:43:28 +00:00
Denis Vlasenko 9257671c76 fix typo in help text 2009-03-09 16:25:33 +00:00
Denis Vlasenko c41cba5a57 ftpd: reuse ls applet for LIST/NLST/STAT generation
function                                             old     new   delta
popen_ls                                               -     211    +211
ftpd_main                                           1760    1826     +66
handle_dir_common                                    199     228     +29
get_remote_transfer_fd                                89     104     +15
replace_char                                          30      34      +4
handle_upload_common                                 263     265      +2
bind_for_passive_mode                                129     121      -8
cmdio_write                                           84      62     -22
escape_text                                          166     136     -30
init_data_sock_params                                 81       -     -81
ftpdataio_dispose_transfer_fd                         87       -     -87
write_dirstats                                       149       -    -149
write_filestats                                      603       -    -603
------------------------------------------------------------------------------
(add/remove: 1/4 grow/shrink: 11/5 up/down: 384/-986)        Total: -602 bytes
   text    data     bss     dec     hex filename
 808804     476    7864  817144   c77f8 busybox_old
 808156     476    7864  816496   c7570 busybox_unstripped
2009-03-09 15:46:07 +00:00
Denis Vlasenko 9b2fbda538 ftpd: EPSV and SIZE support. Tested to work on IPv6 too.
libbb: str2sockaddr shuld accept [IPv6] addr without port -
 wget 'ftp://[::1]/file' needs that to work.

function                                             old     new   delta
bind_for_passive_mode                                  -     129    +129
get_nport                                              -      30     +30
ftpd_main                                           1731    1760     +29
str2sockaddr                                         412     431     +19
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 2/0 up/down: 207/0)             Total: 207 bytes
   text    data     bss     dec     hex filename
 808568     476    7864  816908   c770c busybox_old
 808804     476    7864  817144   c77f8 busybox_unstripped
2009-03-09 13:01:08 +00:00
Denis Vlasenko 57a3b17498 ftp: reduce amount of realloc's done in cmdio_write
text    data     bss     dec     hex filename
 808562     476    7864  816902   c7706 busybox_old
 808568     476    7864  816908   c770c busybox_unstripped
2009-03-09 04:38:37 +00:00
Denis Vlasenko d42eb81206 ftpd: code shrink 2009-03-09 04:22:52 +00:00
Denis Vlasenko 3455285339 ftpd: code shrink 2009-03-09 04:18:00 +00:00
Denis Vlasenko f1a11b5a4e ftp: code shrink
text    data     bss     dec     hex filename
 809078     476    7864  817418   c790a busybox_old
 808590     476    7864  816930   c7722 busybox_unstripped
2009-03-09 04:13:59 +00:00
Denis Vlasenko 9e95920efd ftpd: code shuffled a bit, added comments 2009-03-09 03:15:05 +00:00
Denis Vlasenko 51c9bb1fd1 ftpd: add comment 2009-03-09 02:51:46 +00:00
Denis Vlasenko ffb4bb3034 ftpd: further code shrink
function                                             old     new   delta      
port_pasv_cleanup                                      -      50     +50      
replace_char                                           -      30     +30      
ftp_write_str_common                                 102     104      +2
handle_dir_common                                    209     204      -5
ftpd_main                                           1990    1970     -20
port_cleanup                                          23       -     -23
pasv_cleanup                                          28       -     -28
handle_upload_common                                 320     273     -47
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 1/3 up/down: 82/-123)           Total: -41 bytes
2009-03-09 02:23:45 +00:00
Denis Vlasenko 73c571a5ff *: move get_sock_lsa and xwrite_str to libbb, use where appropriate
function                                             old     new   delta
get_sock_lsa                                           -      72     +72
buffer_fill_and_print                                179     196     +17
parse_expr                                           824     832      +8
read_base64                                          343     348      +5
nameval                                              202     206      +4
fbset_main                                          1694    1698      +4
expand                                              1849    1853      +4
udhcp_send_kernel_packet                             249     252      +3
udhcp_get_option                                     223     222      -1
chat_main                                           1246    1245      -1
pack_gzip                                           1661    1659      -2
doset                                                299     297      -2
bb__parsespent                                       119     117      -2
test_main                                            260     257      -3
qgravechar                                           109     106      -3
tcpudpsvd_main                                      1834    1830      -4
sysctl_display_all                                   589     580      -9
xopen_xwrite_close                                    44      33     -11
prs                                                   30      18     -12
find_main                                            418     406     -12
full_write2_str                                       25      12     -13
adduser_main                                         667     654     -13
evaltreenr                                           817     802     -15
evaltree                                             817     802     -15
tftpd_main                                           526     493     -33
ftpd_main                                           2050    1990     -60
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 7/18 up/down: 117/-211)         Total: -94 bytes
2009-03-09 00:12:37 +00:00
Denis Vlasenko 5e4fda0aff ftpd: code chrink, fixed some minor bugs
ls: update comment
*: openlog fixes (added LOG_PID, set LOG_DAEMON as appropriate)

function                                             old     new   delta
xwrite_str                                             -      26     +26
cmdio_write_ok                                         -      15     +15
handle_cwd                                            40      45      +5
packed_usage                                       25668   25670      +2
cmdio_write_raw                                        7       9      +2
handle_upload_common                                 322     320      -2
udhcpd_main                                         1375    1372      -3
udhcpc_main                                         2362    2359      -3
port_cleanup                                          27      23      -4
handle_dir_common                                    221     209     -12
str_netfd_write                                       26       -     -26
cmdio_get_cmd_and_arg                                122       -    -122
ftpd_main                                           2208    2050    -158
------------------------------------------------------------------------------
   text    data     bss     dec     hex filename
 809933     476    7864  818273   c7c61 busybox_old
 809199     476    7864  817539   c7983 busybox_unstripped
2009-03-08 23:46:48 +00:00
Denis Vlasenko bf9d17949e adding forgotten new file 2009-03-08 09:31:28 +00:00
Denis Vlasenko 16b4a2de97 ftpd: new applet by Adam Tkac
$ size ftpd.o
   text    data     bss     dec     hex filename
   5703       0       0    5703    1647 ftpd.o
2009-03-08 09:30:56 +00:00
Denis Vlasenko c8985bf353 website: mention fixes to syslogd 2009-03-08 01:06:18 +00:00
Denis Vlasenko 01034172f5 website: announce 1.13.3 2009-03-08 01:00:16 +00:00
Denis Vlasenko fb1a23d73b halt/reboot/poweroff: improve error reporting
function                                             old     new   delta
halt_main                                            207     185     -22
2009-03-07 01:54:24 +00:00
Denis Vlasenko a6b6f05379 further work on modprobe
function                                             old     new   delta
gather_options_str                                     -      75     +75
config_file_action                                   388     413     +25
load_modules_dep                                     175     192     +17
add_probe                                             67      72      +5
modprobe_main                                        494     488      -6
gather_options                                        89       -     -89
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 3/1 up/down: 122/-95)            Total: 27 bytes
2009-03-06 22:48:11 +00:00
Bernhard Reutner-Fischer 8517d6fc1f - test commit 2009-03-05 17:27:39 +00:00
Denis Vlasenko 0e2f362a61 modprobe: rework/speedup by Timo Teras (timo.teras AT iki.fi)
function                                             old     new   delta
load_modules_dep                                       -     175    +175
helper_get_module                                      -     106    +106
gather_options                                         -      89     +89
add_probe                                              -      67     +67
config_file_action                                   345     388     +43
get_or_add_modentry                                    -      10     +10
loaded                                                 4       -      -4
read_config                                          239     234      -5
llist_find                                            34       -     -34
add_option                                            60       -     -60
modprobe_main                                        567     494     -73
do_modprobe                                          601     273    -328
------------------------------------------------------------------------------
(add/remove: 5/3 grow/shrink: 1/3 up/down: 490/-504)          Total: -14 bytes
   text    data     bss     dec     hex filename
 816778     476    7888  825142   c9736 busybox_old
 816768     476    7880  825124   c9724 busybox_unstripped
2009-03-05 16:32:27 +00:00
Denis Vlasenko c5741003e9 modutils: delete unused global variable
function                                             old     new   delta
modprobe_main                                        570     567      -3
insmod_main                                          101      98      -3
insmod_outputname                                      4       -      -4
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/2 up/down: 0/-10)             Total: -10 bytes
   text    data     bss     dec     hex filename
 816784     476    7892  825152   c9740 busybox_old
 816778     476    7888  825142   c9736 busybox_unstripped
2009-03-05 09:26:17 +00:00
Denis Vlasenko 76140a77c9 networking/libiproute/*: code shrink by optimizing numeric conversions
and other misc stuff

function                                             old     new   delta
print_tunnel                                         660     656      -4
format_host                                            5       -      -5
get_unsigned                                          70      54     -16
get_u32                                               70      54     -16
do_iplink                                           1173    1151     -22
get_prefix                                           417     393     -24
print_rule                                           800     771     -29
print_addrinfo                                      1374    1342     -32
print_route                                         1745    1709     -36
iprule_modify                                        905     866     -39
iproute_modify                                      1105    1048     -57
get_integer                                           70       -     -70
parse_args                                          1684    1440    -244
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/11 up/down: 0/-594)          Total: -594 bytes
   text    data     bss     dec     hex filename
 817378     476    7892  825746   c9992 busybox_old
 816784     476    7892  825152   c9740 busybox_unstripped
2009-03-05 09:21:57 +00:00
Denis Vlasenko 021de3f029 sendmail: document and fix usage of fd #4, fix check for helper failure.
function                                             old     new   delta
packed_usage                                       25663   25694     +31
signal_handler                                       191     215     +24
kill_helper                                           22      31      +9
launch_helper                                        194     184     -10
get_cred_or_die                                      142     129     -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 64/-23)             Total: 41 bytes
2009-03-04 17:56:00 +00:00
Denis Vlasenko 5a2ad699fc wget: --post-data support by Harald Kuthe (harald-tuxbox AT arcor.de)
function                                             old     new   delta
wget_main                                           2467    2793    +326
static.wget_longopts                                 110     122     +12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 338/0)             Total: 338 bytes
2009-03-04 14:13:37 +00:00
Denis Vlasenko 9604e1b8fc modprobe: emit "can't open 'modules.dep': (errno)" instead of "module not found"
*: s/can't open %s/can't open '%s'/, it's better to use same string.

function                                             old     new   delta
do_modprobe                                          588     601     +13
config_file_action                                   339     345      +6
modprobe_main                                        565     570      +5
unable_to_open                                        14      16      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 26/0)               Total: 26 bytes
   text    data     bss     dec     hex filename
 816800     476    7892  825168   c9750 busybox_old
 816812     476    7892  825180   c975c busybox_unstripped
2009-03-03 18:47:56 +00:00
Denis Vlasenko 787a492f23 ip: in "ip rule add from all table 1", "all" is taken as 0.0.0.0/32,
whereas "any" and "default" would be 0.0.0.0/0. They must be all 0.0.0.0/0.
Closes bug 57.
2009-03-03 14:55:29 +00:00
Denis Vlasenko 230997bd61 expr: a bit more robust handling of regexps with groups (closes bug 87) 2009-03-03 14:27:36 +00:00
Denis Vlasenko 6852effbc2 printf: fix 1.12.0 breakage (from %*d fix). It was misinterpreting "*" 2009-03-03 14:14:44 +00:00
Denis Vlasenko 248ce91017 ls: implement -Q and -g (-g was accepted but ignored)
function                                             old     new   delta
print_name                                             -     198    +198
showfiles                                           1489    1508     +19
ls_options                                            30      31      +1
opt_flags                                            112     108      -4
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/1 up/down: 218/-4)            Total: 214 bytes
2009-03-03 14:09:04 +00:00
Denis Vlasenko 11a6f9b44f ls: do not follow links with -s (closes bug 33),
display unsigned data with %XXu, not %XXd.
2009-03-03 13:20:22 +00:00
Denis Vlasenko 7886275c98 top: make it work again on 2.4 kernels (closes bug 125) 2009-03-03 11:55:31 +00:00
Denis Vlasenko 7e0c243ad5 sendmail: improve help text 2009-03-02 16:12:00 +00:00
Denis Vlasenko 50af926ecf wget: fix --header handling 2009-03-02 15:08:06 +00:00
Denis Vlasenko d9415d6335 syslogd: create logfile with 0666, not 0600. 2009-03-02 14:26:28 +00:00
Denis Vlasenko 37ad6b323d tr: update testsuite 2009-03-02 12:07:15 +00:00
Denis Vlasenko 491d6e3b56 tr: fix overflow in expand and complement, fix stop after [:class:],
fix order of [:xdigit:], make tr require one param at least.

function                                             old     new   delta
expand                                              1743    1849    +106
tr_main                                              463     518     +55
complement                                            72      75      +3
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 164/0)             Total: 164 bytes
2009-03-02 12:05:57 +00:00
Denis Vlasenko 1bfcc8b08e tr: support [:xdigit:], fix handling of ranges and [x]'s.
add testsuite entry for each of 3 bugs fixed.

function                                             old     new   delta      
static.classes                                        73      82      +9      
expand                                              1738    1743      +5      
complement                                            74      72      -2      
tr_main                                              472     463      -9      
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 14/-11)              Total: 3 bytes
2009-03-01 04:50:18 +00:00
Denis Vlasenko 31773b71e8 runsv: another tiny optimization
function                                             old     new   delta
startservice                                         297     288      -9
ctrl                                                 435     426      -9
2009-02-26 12:38:01 +00:00
Denis Vlasenko f09f4e015b runsv: small optimization
*: more paranoia around passing NULL to execl[e]

function                                             old     new   delta
custom                                               240     221     -19
2009-02-26 12:29:59 +00:00
Denis Vlasenko 48637e0924 modutils: oveflow fix 2009-02-26 12:00:52 +00:00
Denis Vlasenko 9aa5c652e9 unzip: fix thinko with le/be conv and size (closes bug 129)
awk: make "struct global" hack more robust wrt alignment (closes bug 131)
2009-02-26 11:21:04 +00:00
Denis Vlasenko 8e5de2aab7 login: fix buglet introduced by "simplification" 2009-02-24 17:10:24 +00:00
Denis Vlasenko e261bba6a5 flash_eraseall.c: fix vda's breakage 2009-02-24 16:47:03 +00:00
Bernhard Reutner-Fischer 30e3df3817 - rephrase helptext for clarity 2009-02-24 10:05:15 +00:00
Bernhard Reutner-Fischer 12aca796ba - improve wording 2009-02-24 10:03:22 +00:00
Bernhard Reutner-Fischer 0adf7f2d46 - by not calling getpagesize() twice we can save 2 bytes (walter harms) 2009-02-23 16:51:25 +00:00
Bernhard Reutner-Fischer f3b39a27a6 - fix typo (thanks to Peter Kjellerstedt for noticing) 2009-02-23 16:21:53 +00:00
Bernhard Reutner-Fischer a31187dbea - Dual-license the config parser also under "LGLPv2.1 or later"
(Vladimir Dronnikov)
2009-02-22 10:57:23 +00:00
Ned Ludd 039ed437d3 make modutils compile again 2009-02-20 04:56:00 +00:00
Denis Vlasenko a430b695a2 depmod: accept and ignore -r (Linux kernle build needs this) 2009-02-19 01:25:42 +00:00
Denis Vlasenko 962e3656f6 flash_eraseall: shrink
function                                             old     new   delta
flash_eraseall_main                                 1044    1006     -38
2009-02-19 01:17:12 +00:00
Bernhard Reutner-Fischer 02468c2063 - add big busybox logo as transparent png 2009-02-18 21:09:07 +00:00
Bernhard Reutner-Fischer 7307e06122 - bail out if screen resolution does not match PPM dimensions.
Previously a 640x480 PPM on an e.g. 720x400 console would just segfault when
  reading the lines. While this bug should perhaps be fixed to handle such cases
  properly we just exit gracefully until somebody is willing to take care of it
  properly.
2009-02-18 15:28:43 +00:00
Bernhard Reutner-Fischer 8dcb33c3eb - document ppm header and skip whitespace 2009-02-18 15:13:05 +00:00
Bernhard Reutner-Fischer e455f6ec27 - update TODOs 2009-02-18 14:05:54 +00:00
Bernhard Reutner-Fischer 8af23f8fc3 - eliminate globals 2009-02-18 13:42:51 +00:00
Bernhard Reutner-Fischer 7d9d251543 - make it compile and shrink it a little bit (~-110 bytes)
text	   data	    bss	    dec	    hex	filename
   1533	      4	      0	   1537	    601	miscutils/flash_eraseall.o.old
   1415	      4	      0	   1419	    58b	miscutils/flash_eraseall.o
- add some FIXMEs
2009-02-18 13:26:29 +00:00
Bernhard Reutner-Fischer 0d22d1755c - add flash_eraseall
This is the result after converting mtd-utils' flash_eraseall to BB.
The functionality given by this patch almost the same except that this
one does not support long options.
I needed this tool a system which does not have a lot of flash for RFS
and merging this into BB as the only way out.

[bigeasy@]$ ./scripts/bloat-o-meter bb_wo_fl bb_w_fl
function                                             old     new   delta
flash_eraseall_main                                    -    1072   +1072
show_progress                                          -      62     +62
packed_usage                                       25156   25176     +20
applet_names                                        1958    1973     +15
applet_main                                         2352    2360      +8
target_endian                                          -       4      +4
applet_nameofs                                       588     590      +2
applet_install_loc                                   147     148      +1
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 5/0 up/down: 1184/0)           Total: 1184 bytes
[bigeasy@]$ size miscutils/flash_eraseall.o
   text    data     bss     dec     hex filename
   1586       4       0    1590     636 miscutils/flash_eraseall.o

Signed-off-by: Benedigt Spranger <b.spranger@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
2009-02-18 13:23:46 +00:00
Bernhard Reutner-Fischer 051fdb9e7a - PPMs can have comments in the header.
Thanks to Denys for pointing that out. (~+7b)
2009-02-16 12:36:50 +00:00
Denis Vlasenko 8ad78e1ec7 ash: make dot command search current directory first, as bash does. 2009-02-15 12:40:30 +00:00
Denis Vlasenko c6ab085002 Make "shadowed" numeric config entries (ones which depend on
other options which are off) to have the value of 0, not "".
2009-02-15 12:01:14 +00:00
Denis Vlasenko 28ea4298e3 volume_id: abort early on read failures.
should help with probing missing fdd's
2009-02-15 05:51:19 +00:00
Denis Vlasenko 93b38208d1 init: fix compile breakage with '# CONFIG_FEATURE_KILL_REMOVED is not set'
runsvdir.c: fix typo in comment
2009-02-14 20:58:13 +00:00
Bernhard Reutner-Fischer 97b954decb - improve wording 2009-02-14 13:17:48 +00:00
Bernhard Reutner-Fischer 51d943d761 - improve helptext 2009-02-14 12:58:48 +00:00
Bernhard Reutner-Fischer 4efcec9378 - misc untested shrinkage:
$ ./scripts/bloat-o-meter _bb_un.oorig busybox_unstripped
function                                             old     new   delta
fbsplash_main                                        595     985    +390
fb_drawimage                                         493       -    -493
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 390/-493)         Total: -103 bytes

$ size miscutils/fbsplash.o*
   text           data     bss     dec     hex filename
   2019              0       0    2019     7e3 miscutils/fbsplash.o.oorig
   1857              0       0    1857     741 miscutils/fbsplash.o.new
2009-02-14 12:36:16 +00:00
Bernhard Reutner-Fischer 52b56b7585 - improve helptext of obsolete devfs stuff.. 2009-02-14 12:19:37 +00:00
Bernhard Reutner-Fischer bb5f8eddc4 - cosmetic typo in helptext 2009-02-14 12:13:13 +00:00
Denis Vlasenko 9f00e05781 killall and sestatus also need ARGVN scanning 2009-02-14 01:36:11 +00:00
Denis Vlasenko d63cd1bf1c mdev: if /sys/class/block exists, don't scan /sys/block 2009-02-13 00:02:54 +00:00
Denis Vlasenko a0ab943492 function old new delta
kill_main                                            706     884    +178
2009-02-07 22:30:39 +00:00
Denis Vlasenko 2ca84f6064 httpd: tiny optimization 2009-02-05 12:38:21 +00:00
Denis Vlasenko 1cbfd98ded httpd:
Kill config options by making them always on:

FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES

This makes httpd.c remotely readable - it had ~125 #ifdefs, now it has ~100.
The growth on a .config with all FEATURE_HTTPDs off is:

function                                             old     new   delta
send_file_and_exit                                     -     269    +269
parse_conf                                           683     763     +80
free_llist                                             -      32     +32
httpd_main                                           427     454     +27
sighup_handler                                         -      15     +15
handle_incoming_and_exit                            1110     905    -205
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 2/1 up/down: 423/-205)          Total: 218 bytes
2009-02-04 23:43:44 +00:00
Denis Vlasenko 6d5590f9d0 sendmail: remove erroneous usage lines 2009-02-04 00:01:07 +00:00
Denis Vlasenko ded5dfef6e crond,crontab: make cron directory location configurable 2009-02-03 23:59:41 +00:00
Denis Vlasenko d814c98692 telnetd: do not advertise TELNET_LFLOW, we do not support
it properly.
2009-02-02 23:43:57 +00:00
Denis Vlasenko 04158e0459 udhcpd: add code which rejects lease files with suspicious or old timestamp.
*: s/time(0)/time(NULL)/g
2009-02-02 10:48:06 +00:00
Denis Vlasenko 512c8ae053 login: small simplification by Walter Harms. -10 bytes 2009-02-02 00:15:57 +00:00
Denis Vlasenko 4eff8efa59 login: cleanup work by Walter Harms. No logic changes. 2009-02-02 00:15:00 +00:00
Denis Vlasenko 73121c3c8c dhcpd,dumpleases: write and use 64-bit current time in lease file.
without it, determination of remaining lease time is unreliable.
 Yes, it's costly in code size, but without it, dumpleases output
 is misleading!

function                                             old     new   delta
read_leases                                          143     282    +139
dumpleases_main                                      447     572    +125
write_leases                                         193     233     +40
hton64                                                29      58     +29
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 333/0)             Total: 333 bytes
2009-02-01 00:40:45 +00:00
Denis Vlasenko 49325969e7 modutils-24: code shrink
function                                             old     new   delta
helper_create_alloced_section                          -     117    +117
print_load_map                                       474     450     -24
bb_init_module_24                                   4615    4545     -70
obj_create_alloced_section                           131      30    -101
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/3 up/down: 117/-195)          Total: -78 bytes
2009-01-31 23:33:54 +00:00
Denis Vlasenko 4acdb46ff1 ionice: new applet, adapted from Linux kernel' example by Walter Harms
text    data     bss     dec     hex filename
1050316     924   10952 1062192  103530 busybox_old
1050758     924   10952 1062634  1036ea busybox_unstripped
2009-01-31 21:45:57 +00:00
Denis Vlasenko 802cab15e5 brctl: fix compilation on 2.4.x kernels 2009-01-31 20:08:21 +00:00
Denis Vlasenko 9ec0ecbfdd init: remove wait() loop on restart, it may be dangerous 2009-01-31 19:26:12 +00:00
Denis Vlasenko 4ae8a05b13 init: fix a bug where on reload order of entries might be wrong
function                                             old     new   delta
run_shutdown_and_kill_processes                        -      97     +97
pause_and_low_level_reboot                             -      48     +48
run_actions                                           81     107     +26
restart_handler                                       56      81     +25
new_init_action                                      137     150     +13
run                                                  576     579      +3
open_stdio_to_tty                                    110      98     -12
check_delayed_sigs                                   195     170     -25
waitfor                                              354     318     -36
low_level_reboot                                      53       -     -53
kill_all_processes                                   115       -    -115
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 4/3 up/down: 212/-241)          Total: -29 bytes
2009-01-31 18:55:54 +00:00
Denis Vlasenko e35af56790 modutils-24: use xasprintf and xzalloc where appropriate,
remove unreachanble code
build system: correct some dependencies in config system
init: convert one #if into if() - for Rob.

function                                             old     new   delta
obj_string_patch                                     136     129      -7
bb_init_module_24                                   4759    4615    -144
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-151)           Total: -151 bytes
2009-01-31 14:22:24 +00:00
Denis Vlasenko fc2a4fc2ba init: small correction in a comment 2009-01-31 01:07:05 +00:00
Denis Vlasenko 72c99af0b4 init: major improvement in documentation and signal handling.
Lots of nasty, but hard to trip, races are fixed.

   text    data     bss     dec     hex filename
1038828     924   10932 1050684  10083c busybox_old
1038787     924   10932 1050643  100813 busybox_unstripped
2009-01-31 01:03:45 +00:00
Denis Vlasenko cab28aa7de init: preparatory patch, no code changes 2009-01-31 01:02:07 +00:00
Denis Vlasenko 6c62246a35 init: reinstate proper handling of !ENABLE_FEATURE_USE_INITTAB 2009-01-29 02:01:04 +00:00
Denis Vlasenko b2b2c404b5 init: reduce ifdef forest (specially for Rob's happiness) 2009-01-28 23:56:31 +00:00
Bernhard Reutner-Fischer a7542dd619 - be gentle to syntax highlighting 2009-01-27 18:54:41 +00:00
Bernhard Reutner-Fischer dd76b79962 - update Michele address 2009-01-27 12:56:33 +00:00
Denis Vlasenko 41d5ebee17 awk: in BEGIN section $0 should be "", not "0". 2009-01-25 01:00:15 +00:00
Denis Vlasenko bdea2c06dc traceroute: allow -w NUM as small as 1 2009-01-24 21:23:41 +00:00
Denis Vlasenko 766c10c386 traceroute: rewrite. Do not emit raw IP packets, instead send UDP or ICMP
packets and rely on the kernel to form IP headers, select source IP
 and interface. Doing it in traceroute wasn't working too good,
 and was bloating it.

function                                             old     new   delta
freehostinfo                                          29       -     -29
setsin                                                30       -     -30
in_cksum                                              57       -     -57
gethostinfo                                          165       -    -165
ifaddrlist                                           364       -    -364
traceroute_main                                     3713    2951    -762
------------------------------------------------------------------------------
(add/remove: 0/5 grow/shrink: 0/1 up/down: 0/-1407)         Total: -1407 bytes
2009-01-24 20:14:24 +00:00
Denis Vlasenko fa65a3d78f traceroute: preparatory trivial cleanups
function                                             old     new   delta
traceroute_main                                     3932    3713    -219
2009-01-24 20:11:36 +00:00
Denis Vlasenko 39b681343b tunctl: new applet by Vladimir
function                                             old     new   delta
tunctl_main                                            -     371    +371
packed_usage                                       25669   25799    +130
applet_names                                        1981    1988      +7
applet_main                                         1192    1196      +4
applet_nameofs                                       596     598      +2
applet_install_loc                                   149     150      +1
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 5/0 up/down: 515/0)             Total: 515 bytes
2009-01-23 02:07:14 +00:00
Bernhard Reutner-Fischer f6107c7e88 - add CONFIG_EXTRA_CFLAGS (thanks to keesj)
This helps with remembering additional flags like e.g. cpu settings for
  people who did not configured their compiler to produce code for their cpu
  per default.
2009-01-22 13:27:14 +00:00
Denis Vlasenko 498436586e tar: stop changing net tarfile's mode, GNU tar doesn't do it 2009-01-20 02:52:57 +00:00
Denis Vlasenko 038eec7c8b uname: use wider integer for option bits 2009-01-19 16:38:30 +00:00
Denis Vlasenko 059138fd08 uname: add support for -i and -o, fix printing of unknown -p
value with -a option

function                                             old     new   delta
uname_main                                           166     185     +19
utsname_offset                                        12      16      +4
options                                              621     623      +2
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 25/0)               Total: 25 bytes
2009-01-19 16:32:23 +00:00
Denis Vlasenko ec64a5775e dhcpc: suppress "warning: 'timestamp_before_wait' might be used uninitialized 2009-01-14 00:28:03 +00:00
Denis Vlasenko 1265df1f31 libbb: shrink linked list ops (by xmaks AT email.cz)
function                                             old     new   delta
llist_pop                                             33      29      -4
llist_unlink                                          47      28     -19
llist_add_to_end                                      50      31     -19
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-42)             Total: -42 bytes
2009-01-13 15:22:50 +00:00
Denis Vlasenko 35261159e6 depmod: fix -b option (by timo.teras AT iki.fi)
function                                             old     new   delta
xfreopen_write                                         -      35     +35
parse_module                                         346     353      +7
depmod_main                                          553     546      -7
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 42/-7)              Total: 35 bytes
2009-01-12 22:12:22 +00:00
Denis Vlasenko f478fde33c adduser: allow adding to group 0; don't _create_ /etc/shadow,
only append data if it exists.

function                                             old     new   delta
adduser_main                                         642     667     +25
2009-01-12 09:20:49 +00:00
Denis Vlasenko 319fe129a1 mdev: fix breakage caused by unified parser usage 2009-01-12 07:57:52 +00:00
Bernhard Reutner-Fischer f0dc2c1d5c - use https for bugzilla URLs 2009-01-10 11:36:38 +00:00
Bernhard Reutner-Fischer e44a4e316d - isascii() is obsolescent in SUSv4 and furthermore looks redundant in this spot 2009-01-09 14:49:11 +00:00
Mike Frysinger 870ccd7212 do not whine if /sys/block does not exist ... embedded systems dont need stinkin block devices 2009-01-08 17:19:01 +00:00
Denis Vlasenko 501b0e335f sysctl: fix another corner case with "dots and slashes" 2009-01-08 03:35:47 +00:00
Denis Vlasenko cb39a7ca6d printf: make integer format strings print long long-sized values.
function                                             old     new   delta
printf_main                                          668     834    +166
bb_strtoll                                             -      84     +84
print_direc                                          391     431     +40
conv_strtoull                                          -      19     +19
conv_strtoll                                           -      19     +19
conv_strtoul                                          16       -     -16
conv_strtol                                           16       -     -16
------------------------------------------------------------------------------
(add/remove: 4/2 grow/shrink: 2/0 up/down: 342/-32)           Total: 296 bytes
2009-01-04 02:58:58 +00:00
Denis Vlasenko 0416e3dde1 udhcpd: disable opton to have absolute lease times in lease file
(that does not work with dumpleases)
dumpleases: fix -a option.
networking/udhcp/*: code shrink, more compact static leases struture,
 better comments, etc

function                                             old     new   delta
find_free_or_expired_address                           -     147    +147
nobody_responds_to_arp                                 -      84     +84
read_opt                                             781     830     +49
dumpleases_main                                      435     447     +12
send_ACK                                             229     232      +3
read_staticlease                                      90      93      +3
addStaticLease                                        60      61      +1
getIpByMac                                            46      43      -3
reservedIp                                            31      20     -11
keywords                                             304     288     -16
send_offer                                           428     403     -25
write_leases                                         225     193     -32
read_leases                                          184     143     -41
read_yn                                               64       -     -64
find_address                                         191       -    -191
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 5/6 up/down: 299/-383)          Total: -84 bytes
2009-01-01 17:52:09 +00:00
Denis Vlasenko b2ec03813c website: announce 1.13.2 amd 1.12.4 2008-12-31 03:43:24 +00:00
Denis Vlasenko d8850f2d0d dc: fix the "base 2" patch omission of base not being set 2008-12-30 10:40:05 +00:00
Denis Vlasenko 76ddc2e3e4 libbb: add bb_unsetenv (taken from hush).
udhcpc: stop filtering environment passed to the script.
crond: fix uncovered potential bug (failing unsetenv)
mdev: fix uncovered potential bug (failing unsetenv)
tcp, udpsvd: fix uncovered potential bug (failing unsetenv)

function                                             old     new   delta
safe_setenv                                            -      58     +58
bb_unsetenv                                            -      55     +55
builtin_unset                                        139     138      -1
tcpudpsvd_main                                      1843    1830     -13
free_strings_and_unsetenv                             87      53     -34
udhcp_run_script                                    1186    1133     -53
safe_setenv4                                          62       -     -62
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/4 up/down: 113/-163)          Total: -50 bytes
2008-12-30 05:05:31 +00:00
Denis Vlasenko d6e8f9450c sysctl: fix gcc warning (false positive) 2008-12-29 01:03:17 +00:00
Denis Vlasenko e40e76f3cd unexpand: fix incorrect expansion, add test for it
function                                             old     new   delta
expand_main                                          676     656     -20
2008-12-26 14:56:03 +00:00
Denis Vlasenko 73ac056f50 s/an user/a user/ 2008-12-25 01:01:23 +00:00
Denis Vlasenko 54d10059c9 *: tweak error messages
sysctl: shrink; support recursing if name is a directory:
 "sysctl net.ipv4.conf". Patch by xmaks AT email.cz

   text    data     bss     dec     hex filename
 793659     504    7492  801655   c3b77 busybox_old
 793576     504    7492  801572   c3b24 busybox_unstripped
2008-12-24 03:11:43 +00:00
Denis Vlasenko 4e12b1a2a9 libbb: introduce and use xmalloc_ttyname (-32 in bss).
ash: small code shrink

   text    data     bss     dec     hex filename
 793669     504    7524  801697   c3ba1 busybox_old
 793659     504    7492  801655   c3b77 busybox_unstripped
2008-12-23 23:36:47 +00:00
Bernhard Reutner-Fischer b3523b9cd3 - we already have an impl for man 2008-12-22 17:09:12 +00:00
Bernhard Reutner-Fischer 54143af9ef Add fancy svn browser thingy (via Lance Albertson of OSL) 2008-12-18 00:44:58 +00:00
Bernhard Reutner-Fischer 9b143a9e39 Update links to new site locations (via Lance Albertson at OSL) 2008-12-18 00:43:31 +00:00
Denis Vlasenko 68819d1232 ash: fix CONFIG_ASH_OPTIMIZE_FOR_SIZE off + high-bit chars case
(do we even need CONFIG_ASH_OPTIMIZE_FOR_SIZE conditional?)
2008-12-15 11:26:36 +00:00
Denis Vlasenko 3139ea7f15 expand: fix incorrect expansion exactly on tab boundary; shrink the code
function                                             old     new   delta
expand_main                                          698     676     -22
xputchar                                              53       -     -53
2008-12-14 15:45:25 +00:00
Denis Vlasenko 005ff882ba watchdog: build fixes, no code changes 2008-12-14 14:49:06 +00:00
Denis Vlasenko ab6b446e95 header_verbose_list: show off_t size, not cast to (unsigned)
get_header_tar: support GNU tar's "base256" encoding

function                                             old     new   delta
get_header_tar                                      1536    1600     +64
header_verbose_list                                  242     257     +15
2008-12-12 02:14:35 +00:00
Denis Vlasenko 12abcb36c8 libiproute: fix buggy open check: s/if (fd)/if (fd >= 0)/
less: small optimization -15 bytes
2008-12-10 14:14:09 +00:00
Denis Vlasenko 311c19a661 ash: printf builtin with no arguments should not exit 2008-12-10 11:51:45 +00:00
Denis Vlasenko 6a2d0d9b8d mount: make it more readable 2008-12-10 11:39:18 +00:00
Denis Vlasenko 3f8f4b2a93 placate Rob's qualms about mount.c 2008-12-10 11:28:30 +00:00
Denis Vlasenko a3ca7cf069 add a note that SO_BINDTODEVICE needs padded iface name on 2.6.26 2008-12-10 11:24:33 +00:00
Denis Vlasenko 517413f9af bb_info_msg: make it do atomic, unbuffered writes
udhcpc: fix a problem where we don't open listening socket fast enough

function                                             old     new   delta
bb_info_msg                                           70     126     +56
change_listen_mode                                    37      78     +41
udhcp_listen_socket                                  151     124     -27
udhcpc_main                                         2344    2285     -59
2008-12-10 11:16:47 +00:00
Denis Vlasenko e53738558f *: fix SO_BINDTODEVICE. Kernel wants at least IFNAMSIZ bytes there. 2008-12-10 11:12:16 +00:00
Denis Vlasenko 0d94820adf syslogd: comment out file locking;
make signal handling syncronous (old was racy)

function                                             old     new   delta
syslogd_main                                         963    1090    +127
quit_signal                                           96       -     -96
log_locally                                          743     595    -148
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/1 up/down: 127/-244)         Total: -117 bytes
2008-12-09 22:53:31 +00:00
Denis Vlasenko 1bcdcd2ef0 init: do not eat last char in messages;
do not print duplicate "init:" prefix to syslog
2008-12-09 21:23:31 +00:00
Denis Vlasenko efb545b9bd optimize 16- and 32-bit moves
function                                             old     new   delta
udhcpd_main                                         1239    1257     +18
udhcp_add_simple_option                               93      92      -1
buffer_read_le_u32                                    19      18      -1
unpack_gz_stream_with_info                           526     520      -6
dnsd_main                                           1470    1463      -7
udhcp_run_script                                    1208    1186     -22
send_ACK                                             255     229     -26
arping_main                                         1661    1623     -38
send_offer                                           470     428     -42
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/8 up/down: 18/-143)          Total: -125 bytes
2008-12-08 22:56:18 +00:00
Denis Vlasenko d1a84a2880 libbb: move crypt_make_salt() to pw_encrypt.c, reuse
bin-to-ascii64 conversion which does not require an array.

function                                             old     new   delta
to64                                                  29      33      +4
to64_msb_first                                        63      62      -1
ascii64                                               65       -     -65
2008-12-07 01:16:34 +00:00
Denis Vlasenko db12d1d733 Fix forgotten license comments 2008-12-07 00:52:58 +00:00
Denis Vlasenko 30e5cf8875 mount: cosmetics, no code changes (verified with objdump -drsx) 2008-12-05 16:40:36 +00:00
Denis Vlasenko 15437e3e2a libbb: add xgetgrnam too. ~0 code size change 2008-12-05 16:23:06 +00:00
Denis Vlasenko d324e1b808 libbb/crypt: code shrink
function                                             old     new   delta
to64_msb_first                                         -      63     +63
des_crypt                                           1509    1338    -171
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 63/-171)          Total: -108 bytes
2008-12-04 15:29:35 +00:00
Bernhard Reutner-Fischer 9c6d12993f - -4b and use proper define; add license note 2008-12-04 14:19:21 +00:00
Denis Vlasenko 3f70b87c59 clarify which version of crond is known to put tasks in separate pgrps 2008-12-04 13:57:59 +00:00
Denis Vlasenko 3246c0de12 iproute: fix ipXXX utilities trying to parse their applet name
as their 1st parameter.
2008-12-04 12:15:19 +00:00
Denis Vlasenko e45930e890 Fold mkpasswd applet into cryptpw.
mkpasswd is in Debian, OTOH cryptpw was added to busybox earlier.
Trying to make both camps happy by making those two applets just aliases.
They are command-line compatible. We can decide whether we want to drop one
(and which one) later.

function                                             old     new   delta
cryptpw_main                                         183     314    +131
static.methods                                        21       -     -21
packed_usage                                       25707   25648     -59
mkpasswd_main                                        307       -    -307
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/1 up/down: 131/-387)         Total: -256 bytes
2008-12-04 12:05:26 +00:00
Denis Vlasenko 196a953f21 iptunnel: fix problems with including linux/ip_tunnel.h
on some systems
2008-12-03 20:16:11 +00:00
Denis Vlasenko d7a805efaf libbb: introduce and use xgetpwnam. ~ -150 bytes. 2008-12-03 19:05:55 +00:00
Bernhard Reutner-Fischer ac1c96f673 - remove superfluous comment from previous commit 2008-12-03 18:49:44 +00:00
Bernhard Reutner-Fischer 82b1429966 - add new applet mkpasswd(1)
function                                             old     new   delta
bb_ask                                                 -     355    +355
mkpasswd_main                                          -     296    +296
.rodata                                           121746  121847    +101
packed_usage                                       24632   24689     +57
static.methods                                         -      21     +21
gmatch                                               229     248     +19
bb_ask_stdin                                           -      11     +11
applet_names                                        1949    1958      +9
applet_main                                         1172    1176      +4
sulogin_main                                         503     505      +2
applet_nameofs                                       586     588      +2
sha256_hash                                          329     327      -2
correct_password                                     208     206      -2
parse_command                                       1442    1439      -3
get_cred_or_die                                      145     141      -4
passwd_main                                         1054    1044     -10
bb_askpass                                           348       -    -348
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 7/5 up/down: 877/-369)          Total: 508 bytes
2008-12-03 18:48:39 +00:00
Denis Vlasenko 81c3a1d0b2 ash: remove TODO which seems to actually work now.
no code changes
2008-12-03 11:59:12 +00:00
Denis Vlasenko 6ebb2f56d5 crond: use bb_setpgrp, not setpgrp
platform.h: make a bit more readable
2008-12-03 10:46:12 +00:00
Denis Vlasenko f8535ccd65 ash: finally installed it as /bin/sh on my machine.
some breakage noticed, the most dire is mishandled ^C.
 fixing it.

function                                             old     new   delta
blocking_wait_with_raise_on_sig                        -      40     +40
waitforjob                                            85     100     +15
setsignal                                            280     278      -2
evalvar                                             1376    1374      -2
waitcmd                                              186     182      -4
dowait                                               350     316     -34
redirect                                            1231    1185     -46
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/5 up/down: 55/-88)            Total: -33 bytes
2008-12-03 10:36:26 +00:00
Denis Vlasenko 0c68a874e7 libbb: password/group function helpers rewritten by Tito:
function                                             old     new   delta
xgetpwuid                                              -      27     +27
uid2uname_utoa                                         -      22     +22
gid2group_utoa                                         -      22     +22
uid2uname                                              -      18     +18
gid2group                                              -      18     +18
buffer_fill_and_print                                179     196     +17
print_user                                            12      24     +12
print_group                                           12      24     +12
get_cached                                            89      99     +10
...
print_common                                         134     120     -14
vlock_main                                           415     396     -19
logger_main                                          410     387     -23
crontab_main                                         642     609     -33
bb_getpwuid                                           42       -     -42
bb_getgrgid                                           42       -     -42
bb_getug                                              80       -     -80
------------------------------------------------------------------------------
(add/remove: 6/3 grow/shrink: 9/11 up/down: 187/-296)        Total: -109 bytes
2008-12-02 22:56:59 +00:00
Denis Vlasenko b6ddee2425 crond: put tasks in separate process groups 2008-12-02 21:52:24 +00:00
Denis Vlasenko c5045fdbf1 vconfig: style fix, no code changes 2008-12-02 20:38:36 +00:00
Denis Vlasenko 360d9661b6 libbb: add strncpy_IFNAMSIZ
function                                             old     new   delta
...
udhcp_read_interface                                 225     220      -5
brctl_main                                          1151    1146      -5
add_interface                                        109     104      -5
ipaddr_list_or_flush                                2174    2167      -7
do_add_ioctl                                          88      80      -8
vconfig_main                                         249     240      -9
do_del_ioctl                                          78      68     -10
do_iplink                                           1186    1173     -13
do_if_fetch                                          766     753     -13
buffer_fill_and_print                                196     179     -17
parse_args                                          1709    1684     -25
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/20 up/down: 11/-140)         Total: -129 bytes
2008-12-02 18:18:50 +00:00
Denis Vlasenko 928b2c0fee ...and exclude LC_ALL too 2008-12-01 12:38:36 +00:00
Denis Vlasenko dcc921e3ca build system: fix sorting + locale in make objsizes 2008-12-01 12:36:41 +00:00
Denis Vlasenko 1e10afcdfb volume_id/fat: careful with sector#, it may not fit in 32 bits. +91 bytes
volume_id/*: a bit of code shrink
2008-11-30 17:41:31 +00:00
Denis Vlasenko a34b8a4d30 init: O_NONBLOCK needs more thought. reverted for now 2008-11-29 23:14:37 +00:00
Denis Vlasenko 7a1ddf20f3 mountpoint: add -n option (by Vladimir)
text    data     bss     dec     hex filename
 799859     560    7748  808167   c54e7 busybox_old
 799845     560    7748  808153   c54d9 busybox_unstripped
2008-11-29 12:54:16 +00:00
Denis Vlasenko d723fb155d inotifyd: save resourses by closing unused inotify descriptors 2008-11-29 09:07:24 +00:00
Denis Vlasenko d16950ded9 acpid: new applet by Vladimir. +737 bytes 2008-11-29 09:05:50 +00:00
Denis Vlasenko f7d87f9b18 Announce 1.13.1 and 1.12.3 2008-11-29 06:57:53 +00:00
Denis Vlasenko e27dafd338 ash: add FIXME 2008-11-28 04:01:03 +00:00
Denis Vlasenko 7b2294edff ash: "ash: syntax error: XXX unexpected" -> "ash: syntax error: unexpected XXX" 2008-11-28 03:50:46 +00:00
Denis Vlasenko 41eb300ff6 ash: shrink on top of previous change
function                                             old     new   delta
readtoken1                                          3201    3221     +20
xxreadtoken                                          306     313      +7
pungetc                                               13      12      -1
ash_main                                            1380    1379      -1
setinputfile                                         196     192      -4
plinno                                                 4       -      -4
parsenleft                                             4       -      -4
parsenextc                                             4       -      -4
parselleft                                             4       -      -4
setinputstring                                        67      62      -5
pushstring                                           123     114      -9
pgetc                                                455     438     -17
pushfile                                              69      31     -38
popfile                                              114      76     -38
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 2/8 up/down: 27/-129)          Total: -102 bytes
   text    data     bss     dec     hex filename
 798750     564    7756  807070   c509e busybox_old
 798664     560    7748  806972   c503c busybox_unstripped
2008-11-28 03:42:31 +00:00
Denis Vlasenko 727752d2d2 ash: better fix for ash -c 'echo 5&' and ash -c 'sleep 5&'
with testcase
2008-11-28 03:41:47 +00:00
Denis Vlasenko 9e0a7c9c41 remove a few superfluous includes 2008-11-25 13:33:11 +00:00
Denis Vlasenko 61befda93b ash,hush: add TODO for rare build failure
*: remove some redundant includes
2008-11-25 01:36:03 +00:00
Denis Vlasenko 1689840672 ash: fix bad interaction between ash -c '....&' and bash compat 2008-11-25 01:34:52 +00:00
Denis Vlasenko 8a2f6bfc2f timeout: fix a few bugs. vda is stupid 2008-11-24 22:34:47 +00:00
Denis Vlasenko 4240408b70 trim help text a bit 2008-11-24 13:42:24 +00:00
Denis Vlasenko a9acbe6cad timeout: new applet. 370 bytes. by Roberto Foglietta. 2008-11-24 13:25:20 +00:00
Denis Vlasenko 00d8417631 vi: speedup and code shrink (Walter Harms)
networking/interface.c: silence warning (Vladimir)
wget: more robust EINTR detection
2008-11-24 07:34:42 +00:00
Denis Vlasenko 4b5709496b strings: code shrink -22 bytes by Tito 2008-11-23 14:58:14 +00:00
Denis Vlasenko 4c83025ea6 diff: emit /dev/null if diff -rN diffs a file against /dev/null
function                                             old     new   delta
diffreg                                             1782    1786      +4
2008-11-23 14:40:00 +00:00
Bernhard Reutner-Fischer 9a280fa7e6 - documentation fix 2008-11-22 20:30:53 +00:00
Denis Vlasenko 9d1d4c06d7 httpd: set $HOST to Host: header value. +83 bytes.
by Tobias Poschwatta (tp AT fonz.de)
2008-11-22 20:29:35 +00:00
Denis Vlasenko 3bc3f08370 modutils-24: small fixes by Harald Kuthe (harald-tuxbox AT arcor.de)
function                                             old     new   delta
obj_load                                             819     832     +13
obj_allocate_commons                                 488     462     -26
bb_init_module_24                                   4800    4759     -41
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 13/-67)            Total: -54 bytes
2008-11-22 20:18:37 +00:00
Denis Vlasenko 12ff9dc714 networking/interface.c: better readability (by Walter Harms)
mkfs_minix: whitespace fix
2008-11-22 18:58:11 +00:00
Denis Vlasenko ae6e135ae8 tftpd: can also have TFTP_DEBUG 2008-11-22 18:41:41 +00:00
Denis Vlasenko 36309cf3f4 insmod: clarify module_name / file_name distinction 2008-11-22 18:29:01 +00:00
Denis Vlasenko cc5feabeba ash: NTO2 needs #if ENABLE_ASH_BASH_COMPAT 2008-11-22 01:32:40 +00:00
Denis Vlasenko 340299a8bc ash: fix miscalculation of memory needed for eval tree
found by Timo Teras (timo.teras AT iki.fi)
2008-11-21 10:36:36 +00:00
Denis Vlasenko b8baf407aa dpkg: better and shorter code to compare versions
(taken from "official" dpkg).
 By Eugene T. Bordenkircher (eugebo AT gmail.com)

function                                             old     new   delta
order                                                  -      48     +48
test_version                                         273     276      +3
version_compare_part                                 396     187    -209
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 51/-209)          Total: -158 bytes
2008-11-20 23:41:56 +00:00
Denis Vlasenko 9a4c0d59a7 inotifyd: exit if x event happened for all files
fix FIONREAD parameter type
 fix default mask code
 shrink help text

function                                             old     new   delta
inotifyd_main                                        497     506      +9
packed_usage                                       25446   25431     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 9/-15)              Total: -6 bytes
2008-11-20 01:24:39 +00:00
Denis Vlasenko 4ae1e13d3f vi: fix several instances of major goof: when text grows, text[]
might get reallocated! We were keeping around pointers to old place...

function                                             old     new   delta
colon                                               3017    3037     +20
char_insert                                          336     354     +18
stupid_insert                                         18      24      +6
string_insert                                         89      94      +5
do_cmd                                              4461    4465      +4
file_insert                                          328     329      +1
text_hole_make                                       134     120     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/1 up/down: 54/-14)             Total: 40 bytes
2008-11-19 13:25:14 +00:00
Denis Vlasenko 58a88916b9 klogd: fix small buglet in previous commit 2008-11-19 09:35:00 +00:00
Denis Vlasenko 2e7dc5d37b klogctl: fix a problem where we don't terminate read data with '\0'
and then misinterpret it. Code shrink while at it.

function                                             old     new   delta
klogd_main                                           404     362     -42
2008-11-19 07:59:49 +00:00
Denis Vlasenko a09a42cd83 inotify: add x, o, and u events 2008-11-17 22:19:18 +00:00
Denis Vlasenko 249d948e39 nslookup: glibc + IPv6 address of DNS server don't mix (yet) 2008-11-17 15:36:36 +00:00
Denis Vlasenko de7a52fff2 id: do not abort build if we use internal password/group functions. 2008-11-17 00:12:17 +00:00
Denis Vlasenko 3eb4466bf8 libbb: replace some memmove's with memcpy's (Ron (ron AT debian.org))
bb_dump_dump                                        2674    2611     -63
2008-11-16 22:21:23 +00:00
Denis Vlasenko 3f5f246466 nslookup: allow usage of IPv6 addresses or hostnames
for DNS server name; allow for port specification.
 Tested to work: "nslookup google.com [::1]:5353"
2008-11-16 19:02:26 +00:00
Denis Vlasenko 5ff1265691 id: abort the build of uclibc is less than 0.9.30 2008-11-16 15:03:11 +00:00
Denis Vlasenko e88bd2d931 man: better check for duplicated MANPATH. Also -10 bytes. 2008-11-16 04:05:13 +00:00
Denis Vlasenko 2479cd4a5d inotifyd: fix "inotifyd with no params" case 2008-11-14 22:14:12 +00:00
Denis Vlasenko 289ff0e341 inotify: document waiting behavior 2008-11-14 21:52:16 +00:00
Denis Vlasenko b0e5d42d4f inotify: fix buffer overflow and "unreaped zombies" problem 2008-11-14 21:34:13 +00:00
Wade Berrier 142c5cb2a2 ifupdown.c: allow options to udhcpc to be configurable from .config
This allows more control over options that are passed to udhcpc
that are not configurable via /etc/network/interfaces.

Example: rather than quit when an initial lease isn't found,
you could use "--background" so that udhcpc keeps running and
continually attempts to get an ip.  That way, when you plug in
the ethernet after powering on the device, you'll still get an ip.
2008-11-14 21:18:45 +00:00
Denis Vlasenko 86c285d900 stat: fix compile breakage (get_f_fsid() is used even if !FEATURE_STAT_FORMAT) 2008-11-13 21:53:32 +00:00
Denis Vlasenko 3470f9297e libbb: sha_crypt -123 bytes 2008-11-13 13:25:18 +00:00
Denis Vlasenko 6bd54d48f4 libbb/pw_encrypt_sha: -28 bytes 2008-11-13 12:55:11 +00:00
Denis Vlasenko 6b1e3d7e73 libbb: remove glibc-style bloat from sha_crypt. -1130 bytes.
cryptpw: add more difficult test vectors.
2008-11-13 12:23:46 +00:00
Denis Vlasenko 4d47692fb8 arp: stop using globals
function                                             old     new   delta
hw_set                                                 1       -      -1
arp_main                                            1559    1558      -1
sockfd                                                 8       4      -4
hw                                                     4       -      -4
device                                                 4       -      -4
ap                                                     4       -      -4
packed_usage                                       25402   25393      -9
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 0/3 up/down: 0/-27)             Total: -27 bytes
2008-11-13 00:05:17 +00:00
Denis Vlasenko fd5a3d2812 gzip: fix gzip -dc case caused by using stale getopt state 2008-11-12 22:06:46 +00:00
Denis Vlasenko 7753ea49bd seq: shrink by 10 bytes 2008-11-12 21:37:19 +00:00
Denis Vlasenko cf3e05bbdb correct help texts 2008-11-12 21:18:58 +00:00
Denis Vlasenko 81c6a91251 telnetd: fix compile problem for non-standalone telnetd 2008-11-12 21:14:50 +00:00
Bernhard Reutner-Fischer c021cb08b5 - add support for seq -s <separator> 2008-11-12 13:22:24 +00:00
Bernhard Reutner-Fischer 2598f761bb - add seq -w support (Natanael Copa) 2008-11-12 12:59:56 +00:00
Denis Vlasenko 1ad4db1d8e modprobe-small: fix failure to load when no arguments are given
modutils-24: fix bad interaction of xzalloc with xrealloc_vector; style fixes
2008-11-12 00:09:58 +00:00
Denis Vlasenko f91f14d221 cksum, printenv: report errors via exitcode
function                                             old     new   delta
cksum_main                                           296     315     +19
printenv_main                                         74      86     +12
2008-11-11 22:59:41 +00:00
Denis Vlasenko 0d8736772d head: report file open errors with exitcode 1 (was happily returning 0)
head_main                                            409     417      +8
2008-11-11 22:43:10 +00:00
Denis Vlasenko 272710fe93 expr: on error, exit with exitcode 2
expr_main                                            101     110      +9
2008-11-11 22:36:58 +00:00
Denis Vlasenko 98f5cdfca7 stat: make stat -f show filesystem "ID:" as coreutils does
print_statfs                                         358     370     +12
2008-11-11 22:25:34 +00:00
Denis Vlasenko f3c2d13602 env: support -uVAR=VAL
function                                             old     new   delta
env_main                                             245     233     -12
2008-11-11 21:32:39 +00:00
Denis Vlasenko 618a3027ed du: fix "du /dir /dir" case
reset_ino_dev_hashtable                                -      84     +84
du                                                   388     376     -12
du_main                                              327     301     -26
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 84/-38)             Total: 46 bytes
2008-11-11 21:15:56 +00:00
Denis Vlasenko 3b35fbb632 runsvdir: straighten some convoluted code. logic is unchanged 2008-11-11 09:33:24 +00:00
Denis Vlasenko 9f2f808b0d telnetd: correctly output 0xff char. ~100 bytes.
telnet: fix some atrocious names and style. no code changes
2008-11-11 02:56:39 +00:00
Denis Vlasenko e9b9a19ad3 libbb: disable a second md5 implementation which managed to creep in :)
function                                             old     new   delta
sha512_end                                           239     237      -2
sha256_end                                           162     160      -2
sha1_end                                             191     189      -2
md5_end                                              168     166      -2
__md5__magic                                           4       -      -4
md5_crypt                                            627     621      -6
static.S                                              16       -     -16
__md5_Init                                            42       -     -42
static.P                                              64       -     -64
__md5_Final                                          131       -    -131
__md5_Update                                         153       -    -153
static.C                                             268      12    -256
__md5_Transform                                      293       -    -293
------------------------------------------------------------------------------
(add/remove: 0/7 grow/shrink: 0/6 up/down: 0/-973)           Total: -973 bytes
2008-11-11 01:38:04 +00:00
Denis Vlasenko 6f05874b9d webpage: announce 1.13.0 and 1.12.2 2008-11-10 22:23:20 +00:00
Denis Vlasenko 2211d5268c libbb: add optionl support for SHA256/512 encrypted passwords
function                                             old     new   delta
sha_crypt                                              -    2423   +2423
cryptpw_main                                         128     183     +55
to64                                                   -      29     +29
pw_encrypt                                           974    1000     +26
str_rounds                                             -      11     +11
login_main                                          1532    1541      +9
packed_usage                                       25215   25200     -15
__md5_to64                                            29       -     -29
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 3/1 up/down: 2553/-44)         Total: 2509 bytes
2008-11-10 18:52:35 +00:00
Denis Vlasenko 56dceb9b77 sha256,sha512: new applets. +4.9kb
we will require sha256/512 code for new $5$ and $6$ style
 password hashes anyway, they are showing up already
 in people's /etc/passwd...
2008-11-10 13:32:50 +00:00
Denis Vlasenko c028ec280a Typo fixes 2008-11-10 10:47:47 +00:00
Denis Vlasenko 0a009c3c6b libbb: constify some data in sha1. gcc is clever enough to do it itself,
thus no actual code changes. Also some pointless beautifuing crept in.
2008-11-10 09:51:15 +00:00
Denis Vlasenko 4cfa5a27aa build system: reorder less' options in config so that
they are properly indented
2008-11-10 09:33:42 +00:00
Denis Vlasenko f8a22575f7 Bump version to 1.14.0.svn 2008-11-09 17:32:46 +00:00
Denis Vlasenko 90dbff7267 Bump version to 1.13.0 2008-11-09 17:28:41 +00:00
Denis Vlasenko 095f5b1c1c update "maximum nommu" config 2008-11-09 16:12:38 +00:00
Denis Vlasenko 62e0dc2b51 update random config tester 2008-11-09 16:08:31 +00:00
Denis Vlasenko 44f96d39e1 randomconfig fixes 2008-11-09 02:23:42 +00:00
Denis Vlasenko 6d0443557c telnetd: set SO_KEEPALIVE, users report it's useful. +20 bytes. 2008-11-09 00:44:40 +00:00
Denis Vlasenko 3fa36e2350 *: a bit of code shrink
function                                             old     new   delta
stop_handler                                          41      38      -3
sulogin_main                                         508     504      -4
got_cont                                               4       -      -4
cont_handler                                          11       -     -11
startservice                                         309     297     -12
processorstart                                       423     409     -14
tcpudpsvd_main                                      1861    1843     -18
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/5 up/down: 0/-66)             Total: -66 bytes
2008-11-09 00:15:11 +00:00
Denis Vlasenko 73cc54388d move documentation to docs/ 2008-11-08 22:31:19 +00:00
Denis Vlasenko 4febd91326 kbd_mode: s/ioctl/xioctl. also saves 12 bytes 2008-11-08 21:42:14 +00:00
Denis Vlasenko dc70069a46 kbd_mode: support -C TTY option
function                                             old     new   delta
packed_usage                                       25334   25361     +27
kbd_mode_main                                        146     173     +27
2008-11-08 21:39:06 +00:00
Denis Vlasenko 2a8329e0e9 build system: remove '-Wl,' when we pass flags to ld. 2008-11-08 20:36:32 +00:00
Denis Vlasenko 30e1ab691c libbb: add a TODO to support new SHA-based encrypted passwords 2008-11-07 13:36:46 +00:00
Denis Vlasenko 2ec94a7ee8 login: fix /etc/nologin handling (should prohibit non-root LOGINS,
not running login by non-root). minor code shrink.

function                                             old     new   delta
login_main                                          1669    1602     -67
2008-11-07 12:59:31 +00:00
Denis Vlasenko b0150d299f telnetd: handle emacs M-DEL and IAC-NOP (putty keepalive)
by Jim Cathey (jcathey AT ciena.com)

function                                             old     new   delta
telnetd_main                                        1314    1364     +50
2008-11-07 01:58:21 +00:00
Denis Vlasenko 4f7d90f1c7 defconfig: explain what we aim it to be 2008-11-07 01:32:11 +00:00
Denis Vlasenko 694b514148 login: fix /etc/nologin support
build system: fix config warnings ("Overlong line")

function                                             old     new   delta
login_main                                          1735    1774     +39
__libc_tcdrain                                         -      23     +23
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 62/0)               Total: 62 bytes
2008-11-07 01:12:16 +00:00
Denis Vlasenko 239d06bd47 add mailutils/* 2008-11-06 23:42:42 +00:00
Denis Vlasenko b9d572a273 total overhaul of mail applets. again. Vladimir as usual. 2008-11-06 23:41:38 +00:00
Denis Vlasenko f10bc3964f correction in comment 2008-11-06 23:28:42 +00:00
Denis Vlasenko f068b3e9f4 sv: make default service dir configurable (Vladimir wants it) 2008-11-06 23:07:42 +00:00
Denis Vlasenko 3854c5ddf4 runsvdir: alternative methon of supporting runsvdir-as-init. +66 bytes.
*: s/int/pid_t where appropriate
2008-11-06 22:39:57 +00:00
Denis Vlasenko 70e8f49f71 basename: fix error code. again. deja vu feeling... 2008-11-06 15:13:33 +00:00
Denis Vlasenko fc66892abd *: remove superfluous casts. no code changes 2008-11-06 02:32:31 +00:00
Denis Vlasenko 35a064b67f build system: tidying up CONFIG_xxx names (suggested by Rob) 2008-11-06 00:49:59 +00:00
Denis Vlasenko 202ac504e1 *: code shrink by adding a wrapper around very common tcsetattr(0, TCSANOW, xx) op
function                                             old     new   delta
tcsetattr_stdin_TCSANOW                                -      14     +14
set_sane_term                                        116     113      -3
top_main                                            1277    1273      -4
make_new_session                                     421     415      -6
rawmode                                              133     126      -7
reset_term                                            18      10      -8
die                                                   43      35      -8
cookmode                                              62      54      -8
vlock_main                                           425     415     -10
read_line_input                                     3165    3155     -10
bb_askpass                                           357     347     -10
fsck_minix_main                                     3079    3065     -14
getty_main                                          2375    2332     -43
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/12 up/down: 14/-131)         Total: -117 bytes
2008-11-05 13:20:58 +00:00
Denis Vlasenko 905ed8730f add serial HOWTO doc 2008-11-05 12:19:39 +00:00
Denis Vlasenko 4cb576ea98 inetd: fix a case when we have zero services 2008-11-05 11:36:22 +00:00
Bernhard Reutner-Fischer a643816fe3 - commentary typo fix (tito) 2008-11-05 08:18:16 +00:00
Bernhard Reutner-Fischer 6559100021 - fix typo in print_user() (tito) 2008-11-05 08:15:13 +00:00
Denis Vlasenko 391ffa19d1 nslookup: tiny shrink (-5 bytes); add comment about res_init
inet_common: cosmetics, no code changes
2008-11-04 21:44:28 +00:00
Denis Vlasenko c51457ca5b less: fix pasting into search line ('/' cmd) -
it was mishandled because pasting "types" very fast
 and read_key eats many chars. +30 bytes.
2008-11-02 00:55:41 +00:00
Denis Vlasenko 3c385cd706 lineedit: fix bug 5824: Since version 23530 with lineedit.c,
"fdisk" & "ed" can't work any more
2008-11-02 00:41:05 +00:00
Denis Vlasenko 9b0f6e1142 add comment, no code changes 2008-11-01 13:40:32 +00:00
Denis Vlasenko 1a9e9bdd93 gunzip: restore mtime. approx +80 bytes of code
rpm: make code more robust
lsmod: small code shrink
2008-11-01 12:54:56 +00:00
Denis Vlasenko 5a89763fb7 tftpd: show help if stdin is not a socket 2008-11-01 00:22:24 +00:00
Denis Vlasenko 44d5dcebc6 iplink: accept shorthands for "address" keyword here:
"ip link set address 00:11:22:33:44:55"
ifupdown: use "addr" instead of "address"
2008-11-01 00:10:51 +00:00
Denis Vlasenko 64974793b9 less: fix newly-introduced case of less spinning forever
on pty's closed etc
2008-10-31 03:04:55 +00:00
Denis Vlasenko 028eab61bc runsvdir: if we have PID == 1, SIGHUP should make small pause,
not 1 minute one
2008-10-31 02:37:18 +00:00
Denis Vlasenko bb26db49b1 modprobe: fix a segfault when modprobe is called with no arguments at all
function                                             old     new   delta
modprobe_main                                        559     535     -24
2008-10-31 02:04:28 +00:00
Denis Vlasenko b9b344aa44 kill[all[5]]: accept -s SIG too. kill_main: +29 bytes
by Steve Bennett (steveb AT workware.net.au)
2008-10-31 00:30:48 +00:00
Denis Vlasenko f34cfff2f0 setup_environment: cd $HOME regardless of clear_env value. 2008-10-30 23:58:19 +00:00
Denis Vlasenko 91f8f82bfb tftpd: be less cryptic in help text 2008-10-30 23:42:37 +00:00
Denis Vlasenko 6b38e18247 dc: support for bases 2 and 8, by Nate Case (ncase AT xes-inc.com)
function                                             old     new   delta
print_base                                            87     176     +89
set_output_base                                       81      95     +14
static.bases                                           -       5      +5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 108/0)             Total: 108 bytes
2008-10-30 23:25:50 +00:00
Bernhard Reutner-Fischer 470dc1d7e2 - minor shrinkage (~-60) 2008-10-30 17:42:49 +00:00
Bernhard Reutner-Fischer e29186687b - support ip link set eth1 address 00:11:22:33:44:55
and not only the shorthand "addr". Thanks to ncopa for noticing
2008-10-30 16:45:55 +00:00
Denis Vlasenko 31d58e58d2 randomconfig fixes 2008-10-29 13:16:28 +00:00
Denis Vlasenko 1fe7887659 another small defconfig update 2008-10-29 12:25:39 +00:00
Denis Vlasenko b15a6f2489 update defconfig 2008-10-29 12:18:10 +00:00
Denis Vlasenko cf696850f3 runsvdir: kill another global 2008-10-29 12:07:34 +00:00
Denis Vlasenko 6a2c2cf6f3 runsvdir: fx a recent vda's buglet (was pausing even if not signaled).
stop spawning children immediately if signaled. Kill one global.
2008-10-29 12:04:45 +00:00
Denis Vlasenko e7368f16fa id: better wording in comments, no code changes 2008-10-29 10:30:54 +00:00
Denis Vlasenko 58f3c2e01e runsvdir: shrink (by Vladimir) 2008-10-29 03:45:33 +00:00
Denis Vlasenko 9657596dd6 runsvdir: do not exit if we are pid 1. 2008-10-29 03:42:44 +00:00
Denis Vlasenko 40fdcbb270 more whitespace fixes 2008-10-29 01:20:13 +00:00
Denis Vlasenko 9504e444b8 whitespace fixes, no code changes 2008-10-29 01:19:15 +00:00
Denis Vlasenko c3a9dc8ac5 vi: fix uninitialized last_search_pattern (bug 5794) 2008-10-29 00:58:04 +00:00
Denis Vlasenko 34e68c8b42 id: coreutils compat by Tito + test script 2008-10-29 00:27:31 +00:00
Bernhard Reutner-Fischer d498850e02 - typo in documentation 2008-10-27 21:30:39 +00:00
Denis Vlasenko 6214941a3a ash: add testcase for bug 5304 2008-10-27 14:33:03 +00:00
Denis Vlasenko be54d6bc60 ash: fix "while kill -0 $child; do true; done" looping forever. 2008-10-27 14:25:52 +00:00
Denis Vlasenko 7ff85c53f1 udhcp: simplify SO_BINDTODEVICE call 2008-10-27 12:56:58 +00:00
Denis Vlasenko de5f645dff ls: trim help text 2008-10-27 12:37:22 +00:00
Denis Vlasenko 59f502b36f ping: trivial code shrink
function                                             old     new   delta
ping6_main                                            31      30      -1
ping_main                                            405     370     -35
2008-10-27 11:54:45 +00:00
Denis Vlasenko c503dde01a cpio: emit TRAILER even when hard links were found.
by Pascal Bellard (pascal.bellard AT ads-lu.com)
2008-10-26 19:55:20 +00:00
Denis Vlasenko 6b9d6c7544 devmem: fixlet in cleanup code 2008-10-26 19:07:43 +00:00
Denis Vlasenko 043246560f devmem: make it more script-friendly; don't do any reads
and output nothing if writing was requested. -100 bytes
2008-10-26 17:26:55 +00:00
Denis Vlasenko e1ef89abad less: correctly wrap lines with tabs 2008-10-26 16:30:09 +00:00
Denis Vlasenko c94fa5651a devmem: new applet 2008-10-26 11:08:14 +00:00
Denis Vlasenko f3dcd3c30a less: FEATURE_LESS_LINENUMS depends on FEATURE_LESS_DASHCMD 2008-10-26 00:24:38 +00:00
Denis Vlasenko 7462b21dbe read_key is actually written by Rob, add him to copyright notice 2008-10-26 00:19:33 +00:00
Denis Vlasenko 7b32e8f0bf less: disable _ command, it's useless bloat 2008-10-26 00:15:36 +00:00
Denis Vlasenko bdd2d8f178 read_key: add comments how Shift and Meta keys looks like.
no code changes
2008-10-25 23:59:41 +00:00
Denis Vlasenko 5f6aaf39cf less: reuse former vi's key reading code. Improve SIGWINCH handling.
function                                             old     new   delta
less_main                                           2056    2097     +41
getch_nowait                                         248     273     +25
read_key                                             310     321     +11
static.esccmds                                        61      69      +8
count_lines                                           72      74      +2
less_gets                                            166     142     -24
less_getch                                           172      43    -129
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 6/5 up/down: 91/-170)           Total: -79 bytes
   text    data     bss     dec     hex filename
2008-10-25 23:27:29 +00:00
Denis Vlasenko 39b0135c59 libbb: add forgotten file from previous commit :( 2008-10-25 23:23:32 +00:00
Denis Vlasenko 0112ff5203 vi: move key reading routine out of vi into llbbb
function                                             old     new   delta
read_key                                               -     310    +310
....
static.esccmds                                       170      61    -109
readit                                               286      60    -226
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 9/10 up/down: 349/-367)         Total: -18 bytes
2008-10-25 23:23:00 +00:00
Denis Vlasenko 73d702ee07 tar: fix typo in comment 2008-10-25 09:27:35 +00:00
Denis Vlasenko ebad0294c9 tar: fix bug 3844: non-root tar does not preserve perms 2008-10-24 23:47:38 +00:00
Denis Vlasenko 53c80f0972 less: add optional line number toggle and resizing on SIGWINCH. 2008-10-24 22:43:27 +00:00
Bernhard Reutner-Fischer aa2a1c000c - improve wording and fix alphabetical order 2008-10-24 19:48:47 +00:00
Denis Vlasenko e8efe81abf less: add less v.418 help text doc. No code changes. 2008-10-24 11:07:20 +00:00
Denis Vlasenko 2d5bd807c0 build system cleanup: rename FEATURE_AWK_MATH to FEATURE_AWK_LIBM;
disable parsing test applet.
2008-10-24 10:49:49 +00:00
Denis Vlasenko d908395eae less: experimental code to enable wrap/no-wrap
and adapting to resized xterm windows. disabled for now.
2008-10-24 10:42:21 +00:00
Denis Vlasenko 8f39b72aba less: more sane way of line numbering. Prepares for
wrap/unwrap and line numbers to be toggleable.
2008-10-23 22:02:30 +00:00
Bernhard Reutner-Fischer 2dfd295726 - give glob a chance
CROSS_COMPILE=~/foo-bar-baz would fail otherwise
  See http://www.uclibc.org/lists/buildroot/2008-October/011191.html
2008-10-23 13:49:21 +00:00
Bernhard Reutner-Fischer 01ea971610 - use sys/inotify.h 2008-10-21 17:26:10 +00:00
Denis Vlasenko 5cb54b5adc init: downgrade ENABLE_DEBUG_INIT to just a #define to prevent people
from selecting it in error. It has to be used ONLY for debugging
 init, never in production, as resulting init has serious differences.
2008-10-21 17:14:26 +00:00
Denis Vlasenko 37890e2f37 awk: fix typo in atan2 code. closes bug 5594. 2008-10-21 12:59:34 +00:00
Bernhard Reutner-Fischer 8fbd8ac8dd - fix ip route rejecting dotted quads as prefix
- adjust error message for wrong prefix not to mention address
  Previously e.g. ip route add 127.0.0.0/255.0.0.0 dev dummy0
  was rejected, saying
ip: an inet address is expected rather than "127.0.0.0/255.0.0.0"
 
function                                             old     new   delta
get_prefix_1                                         201     309    +108
get_prefix                                            55      73     +18
get_addr                                              55      73     +18
get_addr32                                            48      58     +10
get_addr_1                                           249     204     -45
.rodata                                           114569  114524     -45
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/2 up/down: 154/-90)            Total: 64 bytes
2008-10-21 12:42:45 +00:00
Denis Vlasenko 7effd7ae99 getopt: reinstate erroneously removed getopt() reset code. 2008-10-21 12:36:43 +00:00
Denis Vlasenko 4c9e9c4314 vi: handle chars 0x80, 0x81... correctly 2008-10-20 08:59:03 +00:00
Denis Vlasenko 078323010b dc: conditionalize parts which require libm 2008-10-20 08:43:10 +00:00
Denis Vlasenko b730474bda ash: fix NOEXEC mode - we were forgetting to pass environment!
env: promote to NOEXEC
hd: promote to NOEXEC, as hexdump is NOEXEC already
2008-10-20 08:15:51 +00:00
Denis Vlasenko d1660cb9ad ash: fix a bug in standalone mode (corrupted getopt() state) 2008-10-20 07:52:33 +00:00
Denis Vlasenko 802a7be54f add comment explaining previous change 2008-10-19 19:54:49 +00:00
Denis Vlasenko 582dff0514 volume identification: abolish /proc/partitions and /proc/cdroms
scanning. It does not catch volume managers and such.
Adding even more cruft is bad, so I decided to simply
scan /dev/* for any block devices. See how much better
it finds devices now:

# ./busybox_old blkid
/dev/sda1: LABEL="/boot" UUID="7931e231-dcb4-4b6d-9301-f7354ae24061"
/dev/dm-0: LABEL="Fedora-9-Live-x8" UUID="bb491e1e-1145-4f5b-b0ab-cbd2baf4f15a"
/dev/dm-1: UUID="edc2a920-ef83-437e-ba64-d3b6dc851267"
/dev/sdb1: UUID="6F84-ED0F"

# ./busybox blkid
/dev/sdb1: UUID="6F84-ED0F"
/dev/root: LABEL="Fedora-9-Live-x8" UUID="bb491e1e-1145-4f5b-b0ab-cbd2baf4f15a"
/dev/dm-1: UUID="edc2a920-ef83-437e-ba64-d3b6dc851267"
/dev/dm-0: LABEL="Fedora-9-Live-x8" UUID="bb491e1e-1145-4f5b-b0ab-cbd2baf4f15a"
/dev/sda1: LABEL="/boot" UUID="7931e231-dcb4-4b6d-9301-f7354ae24061"
/dev/mapper/VolGroup00-LogVol01: UUID="edc2a920-ef83-437e-ba64-d3b6dc851267"
/dev/mapper/VolGroup00-LogVol00: LABEL="Fedora-9-Live-x8" UUID="bb491e1e-1145-4f5b-b0ab-cbd2baf4f15a"

function                                             old     new   delta
static.drive_name_string                              12       -     -12
append_mount_options                                 205     190     -15
volume_id_open_node                                   37      18     -19
uuidcache_check_device                               485     257    -228
uuidcache_init                                       637      36    -601
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/4 up/down: 0/-875)           Total: -875 bytes
   text    data     bss     dec     hex filename
 792218     592    6648  799458   c32e2 busybox_old
 791260     592    6648  798500   c2f24 busybox_unstripped
2008-10-19 19:36:30 +00:00
Denis Vlasenko bff06fe02a blkid: vda forgot to svn add it again. vda is stupid 2008-10-19 17:47:31 +00:00
Rob Landley 4bdeaaf556 Comment and whitespace tweaks. 2008-10-19 04:21:21 +00:00
Denis Vlasenko e3742f4217 vi: explain why reading 4 chars is unsafe 2008-10-18 19:37:41 +00:00
Denis Vlasenko 3ab3d8a5cf libbb: do not reject floating point strings like ".15" 2008-10-18 19:18:51 +00:00
Denis Vlasenko f9dde919d6 mount: -o parm1 -o parm2 should accumulate 2008-10-18 19:15:57 +00:00
Denis Vlasenko 1dfeeeb651 vi: whitespace fix 2008-10-18 19:04:37 +00:00
Denis Vlasenko cf4dd07b28 cpio: fix regression in prev commit (harmless) 2008-10-17 14:11:04 +00:00
Denis Vlasenko d83676ec47 data_extract_all: do not complain if directory exists on mkdir
rpm/cpio: move "20653 blocks" printout from get_header_cpio to cpio_main -
rpm doesn't want to have that
2008-10-17 14:03:56 +00:00
Denis Vlasenko aa9eb1fc67 rpm: fix incompatibilities which prevented rpm -i foo.src.rpm
function                                             old     new   delta
fileaction_setowngrp                                  57      89     +32
2008-10-16 13:29:13 +00:00
Denis Vlasenko 8ef801b40c vi: a few trivial optimizations to keyboard reading code; bump timeout to 50s.
function                                             old     new   delta
edit_file                                            901     912     +11
count_lines                                           74      72      -2
readit                                               306     289     -17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 11/-19)             Total: -8 bytes
2008-10-16 09:46:07 +00:00
Rob Landley 7960ea8918 Confirmed that on Linux the serial interrupt takes precedence over the timer
interrupt, so we don't need to worry about scheduler delays.  This means the
delay can be trimmed down to 25 miliseconds.  Add comment while at it.
2008-10-16 06:34:10 +00:00
Denis Vlasenko 8854b352f4 build system: dpkg needs .gz handling 2008-10-15 14:50:14 +00:00
Denis Vlasenko a9c3f7a19e sysctl: sysctl -a was still misbehaving, fix it 2008-10-15 13:50:24 +00:00
Denis Vlasenko 9299305756 return accidentally deleted "/* vi: set sw=4 ts=4: */" 2008-10-15 09:44:37 +00:00
Denis Vlasenko e915a1a410 sysctl: fix bug 3894 _for real_. 2008-10-15 09:43:35 +00:00
Denis Vlasenko 81944c9e92 sysctl: remove trivial comments. no code changes 2008-10-15 08:45:54 +00:00
Denis Vlasenko cfdb711a18 sysctl: remove special-cased reporting of EPERM,
common code path gives nearly the same message. -50 bytes
2008-10-15 08:29:17 +00:00
Denis Vlasenko 58cc52aa76 sysctl: fix bug 3894 (by Kryzhanovskyy Maksym)
function                                             old     new   delta
sysctl_dots_to_slashes                                 -      47     +47
sysctl_write_setting                                 310     298     -12
sysctl_read_setting                                  296     284     -12
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 47/-24)             Total: 23 bytes
2008-10-15 08:22:55 +00:00
Denis Vlasenko d44c1535ae vi: fix bizarre formatting. no code changes 2008-10-14 12:59:42 +00:00
Denis Vlasenko ddc8ae3003 hush: add TODO 2008-10-14 12:50:34 +00:00
Denis Vlasenko 371de4acf7 hush: next small step towards functions 2008-10-14 12:43:13 +00:00
Denis Vlasenko ded6ad34ed fix recurring "last_cmd overrun", fix [del] handling in insert mode 2008-10-14 12:26:30 +00:00
Denis Vlasenko 267e16c74a vi: trivial size optimization -65 bytes 2008-10-14 10:34:41 +00:00
Denis Vlasenko 25497c1d92 vi: reinstate timeout of 300 ms 2008-10-14 10:25:05 +00:00
Denis Vlasenko 5373fbcd11 vi: add comments to Rob's algorithm of reading and matching ESC sequences
(nice work btw!)
2008-10-14 10:09:56 +00:00
Rob Landley 5e38cd910a Escape sequences sent over serial links don't come in as a block, so poll
needs to pause a bit to make sure the next character has time to come in.
2008-10-14 08:44:09 +00:00
Rob Landley 988dd5549b Clean up editors/vi.c:readit() so it only does readahead when actually
parsing an escape sequence.  (This mitigates but doesn't fully fix the
the "cursoring around the file deletes data under qemu" bug, presumably due
to "\033[D" being treated as three separate characters.)
2008-10-14 01:42:33 +00:00
Denis Vlasenko f886fd2bc7 hush: fix NOMMU bug (analogous to preceding commit for MMU) 2008-10-13 12:36:05 +00:00
Denis Vlasenko d29084dd7d testcase for the last fix 2008-10-13 08:54:42 +00:00
Denis Vlasenko 22d10a0292 hush: fix trashing of environment by local env vars:
a=a; a=b cmd; - a was unset!
  +57 bytes

function                                             old     new   delta
add_string_to_strings                                  -     110    +110
putenv_all                                             -      27     +27
run_list                                            2086    2111     +25
free_strings                                           -       7      +7
free_pipe                                            210     208      -2
add_malloced_string_to_strings                       110       -    -110
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 1/1 up/down: 169/-112)           Total: 57 bytes
2008-10-13 08:53:43 +00:00
Denis Vlasenko 1e19afd38a blkid: new applet. We almost had everything needed for it already
function                                             old     new   delta
display_uuid_cache                                     -      89     +89
blkid_main                                             -       8      +8
applet_names                                        1871    1877      +6
applet_main                                         1140    1144      +4
applet_nameofs                                       570     572      +2
packed_usage                                       24737   24735      -2
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/1 up/down: 109/-2)            Total: 107 bytes
2008-10-12 11:20:08 +00:00
Denis Vlasenko d5e305944a findfs: fix LUKS and FAT detection routines; do not exit if corrupted
FAT fs makes us try to seek past volume

function                                             old     new   delta
volume_id_get_buffer                                 301     327     +26
volume_id_probe_luks                                  79      82      +3
get_attr_volume_id                                    73      65      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 29/-8)              Total: 21 bytes
2008-10-12 11:17:49 +00:00
Denis Vlasenko cdd1f732bc zcip: code size optimizations, improved help text and comments
function                                             old     new   delta
packed_usage                                       24750   24787     +37
run                                                  658     655      -3
pick                                                  40      34      -6
arp                                                  186     177      -9
zcip_main                                           1402    1356     -46
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 37/-64)            Total: -27 bytes
2008-10-10 11:28:39 +00:00
Denis Vlasenko afd7a8d744 hush: fix environment and memory leaks, add tests for them
function                                             old     new   delta
add_malloced_string_to_strings                         -     110    +110
run_list                                            1999    2086     +87
free_strings_and_unsetenv                              -      87     +87
hush_version_str                                       -      18     +18
pseudo_exec_argv                                     139     146      +7
static.version_str                                    17       -     -17
free_pipe                                            237     210     -27
done_word                                            790     642    -148
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 2/2 up/down: 309/-192)          Total: 117 bytes
2008-10-09 16:29:44 +00:00
Denis Vlasenko 07e05c100f unzip: remove example of a file we now can handle 2008-10-09 13:52:30 +00:00
Denis Vlasenko c373527e4f hush: preparatory work for implementing functions 2008-10-09 12:58:26 +00:00
Denis Vlasenko 9af22c7626 hush: massive renaming of ill-named structures and fields
hush: error out on constructs like:
 $ abc(def) - was working as if it was (abcdef)
 $ case b in abc(a|(b) echo YES; esac - was ignoring 'abc' and extra '('
2008-10-09 12:54:58 +00:00
Bernhard Reutner-Fischer 578de8644c - route metric support (Natanael Copa)
Adds about 75b
2008-10-07 17:00:58 +00:00
Bernhard Reutner-Fischer 2239f81941 - add some anchors 2008-10-07 16:05:03 +00:00
Denis Vlasenko 834dee785d ash: support &> redirection (bashism). ~90 bytes of code 2008-10-07 09:18:30 +00:00
Denis Vlasenko 176d49d4f7 ash: some beautification work, no code changes 2008-10-06 09:51:47 +00:00
Denis Vlasenko 559691a3bf ash: implement ">&file" bashism. ~100 bytes. 2008-10-05 18:39:31 +00:00
Denis Vlasenko 93d0776a96 watchdog: WDIOC_SETTIMEOUT accepts seconds, not milliseconds
klogd: handle many lines at once, by Steve Bennett (steveb AT workware.net.au)
2008-10-04 16:40:17 +00:00
Bernhard Reutner-Fischer c2d5a27b62 - wrap overlong line 2008-10-02 13:30:31 +00:00
Denis Vlasenko f60719cd49 grep: fix 'echo aaa | grep -o a' + ENABLE_EXTRA_COMPAT case
by Natanael Copa
2008-09-30 22:37:29 +00:00
Denis Vlasenko df6b3ad6ba inetd: use config parser. by Vladimir
function                                             old     new   delta
reread_config_file                                  1092    2154   +1062
next_line                                             98      33     -65
next_word                                            197      57    -140
parse_one_line                                      1202       -   -1202
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/2 up/down: 1062/-1407)       Total: -345 bytes
2008-09-30 01:22:25 +00:00
Denis Vlasenko 58680706d7 route: fix for 64-bit BE machines by Seonghun Lim (wariua AT gmail.com) 2008-09-28 23:39:18 +00:00
Denis Vlasenko 22eb410d66 website: announce 1.12.1 and 1.11.3 2008-09-28 18:33:02 +00:00
Denis Vlasenko 27e1501cb2 scripts/randomtest[.loop]: add scripts for randomconfig testing 2008-09-28 17:19:02 +00:00
Denis Vlasenko 651d49a2ce showkey: suppress gcc warning 2008-09-28 16:44:28 +00:00
Denis Vlasenko 2b2d977057 sendmail: update by Vladimir 2008-09-28 13:50:57 +00:00
Denis Vlasenko 6826441a02 remove redundant NULL check 2008-09-27 23:39:55 +00:00
Denis Vlasenko bb04506dc8 more style fixes, no code changes 2008-09-27 14:06:06 +00:00
Denis Vlasenko d6855d1b50 style fixes, no code changes 2008-09-27 14:03:25 +00:00
Denis Vlasenko bed22a01fb sendmail: compat update by Vladimir
function                                             old     new   delta
sendgetmail_main                                    1889    2091    +202
putchar_unlocked                                       -      43     +43
putchar                                                -      43     +43
packed_usage                                       24868   24910     +42
smtp_checkp                                          102     111      +9
uuencode                                             235     227      -8
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 3/1 up/down: 339/-8)            Total: 331 bytes
2008-09-27 14:01:22 +00:00
Denis Vlasenko 682ad3045c lineedit: fix problems with empty commands in history 2008-09-27 01:28:56 +00:00
Denis Vlasenko 75897ea6d5 start_stop_daemon: accept (and ignore) -R <param> 2008-09-27 01:05:13 +00:00
Denis Vlasenko 739e30fbc3 udhcp: add inline docs; small code shrink
function                                             old     new   delta
send_packet                                          103      87     -16
udhcpc_main                                         2359    2323     -36
2008-09-26 23:45:20 +00:00
Denis Vlasenko 7d9399e8dc udhcpc: fixlet for previous commit 2008-09-26 22:21:03 +00:00
Denis Vlasenko c321b51dc6 udhcp: added some FIXMEs; code shrink. -49 bytes 2008-09-26 16:29:12 +00:00
Bernhard Reutner-Fischer 1a89133caf Markus Heidelberg writes:
* document --nicelevel in Config.in
* usage: --verbose is the fancy option, not --quiet
2008-09-26 15:14:56 +00:00
Bernhard Reutner-Fischer 48a6773b3a - add less -I to be able to search case-insensitively
+17b, but the helptext is quite elaborate, thus:
function                                             old     new   delta
.rodata                                           118995  119032     +37
packed_usage                                       24731   24767     +36
regex_process                                        284     300     +16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 89/0)               Total: 89 bytes
2008-09-26 14:10:17 +00:00
Bernhard Reutner-Fischer fd3552dff9 - commentary typo fix 2008-09-26 11:23:22 +00:00
Denis Vlasenko bfc93a3caf nmeter: 4k buffers are too small for /proc files,
make them dynamically sized with 16k upper limit. +75 bytes
2008-09-26 11:12:09 +00:00
Denis Vlasenko ee5dce3365 libpwdgrp: make it coexist with <pwd.h>, <grp.h> and <shadow.h>.
allows to get rid of hacks in libbb.h (extra declaration of setgroups -
 now it comes from grp.h as intended).
2008-09-26 10:35:55 +00:00
Denis Vlasenko f1980f67d3 dhcp: add FAST_FUNC as appropriate. -160 bytes. 2008-09-26 09:34:59 +00:00
Denis Vlasenko cdb0b652dd dhcpc: treat "discover...select...discover..." loop the same way
as "discover...discover...discover..."
2008-09-26 09:34:15 +00:00
Denis Vlasenko b46d5f9a93 fix usage text - s/USE_GETOPT_LONG/USE_FEATURE_xxxLONG_OPTIONS/
by Markus Heidelberg (markus.heidelberg AT web.de)
2008-09-25 21:06:24 +00:00
Bernhard Reutner-Fischer 97516fc3a6 - add dpkg -l <packagepattern> (Peter Korsgaard) 2008-09-25 12:18:49 +00:00
Bernhard Reutner-Fischer 6c4dadefb6 - update my name. No obj-code changes ;) 2008-09-25 12:13:34 +00:00
Bernhard Reutner-Fischer a46d2b1d2d - improve helptext 2008-09-25 11:50:13 +00:00
Denis Vlasenko c8842213f5 top: fix "top -d 1" (bug 5144) 2008-09-25 11:42:10 +00:00
Denis Vlasenko 42cc6bab16 top: don't lie in help screen about "-d 1" being valid 2008-09-25 11:17:10 +00:00
Denis Vlasenko 35840ab204 top: fixes to prev commit: '1' should toggle SMP view too;
"cpu ..." line should be parsed unconditionally
top: do not truncate loadavg string. More info -> better
2008-09-25 11:11:37 +00:00
Bernhard Reutner-Fischer 864329d674 - fix compilation on OSF/1 2008-09-25 10:55:05 +00:00
Denis Vlasenko 17e7f04c8d top: optional SMP support by Vineet Gupta (vineetg76 AT gmail.com) 2008-09-25 10:48:06 +00:00
Denis Vlasenko e0bcba18eb df: unsigned long needs %lu 2008-09-25 10:41:15 +00:00
Denis Vlasenko ea7c9b3366 whitespace fixes 2008-09-25 10:39:10 +00:00
Denis Vlasenko cac0f5b7e5 return setgroups() decl to libbb, it is needed if we use libpwdgrp. 2008-09-25 10:20:46 +00:00
Mike Frysinger f6cad924b1 we dont provide setgroups() replacement, so dont provide the prototype either ... especially since it conflicts on some systems (like Darwin) 2008-09-25 00:41:49 +00:00
Denis Vlasenko 923a79a769 runsvdir: conditionalize "log in argiment" (mis)feature. By Vladimir.
with:
runsv                                                139     141      +2
runsvdir_main                                       1583    1513     -70

 without:
warn2_cannot                                          14      27     +13
runsv                                                139     141      +2
warnx                                                 28      16     -12
warn3x                                                23       -     -23
runsvdir_main                                       1583    1125    -458
2008-09-22 21:34:24 +00:00
Denis Vlasenko 30cfdf90ce crontab: do not destroy STDIN_FILENO, editor may need it (crontab -e)
vi: deal with EOF/error on stdin and with input NULs

function                                             old     new   delta
crontab_main                                         623     642     +19
edit_file                                            901     906      +5
readit                                               331     318     -13
2008-09-21 15:29:29 +00:00
Denis Vlasenko 006e8628fc unzip: handle "central directory"
needed for OpenOffice, gmail attachment .zips etc
 conditional on CONFIG_DESKTOP

function                                             old     new   delta
unzip_main                                          1643    1939    +296
find_cds_offset                                        -     173    +173
unzip_skip                                            11      16      +5
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 474/0)             Total: 474 bytes
2008-09-21 01:01:46 +00:00
Denis Vlasenko eef6077d7e setfont: use ioctl(KDFONTOP), it honours -C tty 2008-09-20 18:14:13 +00:00
Denis Vlasenko b8d1a4cd5f init: set stderr to NONBLOCK
*: s/setenv(a,b,1)/xsetenv(a,b)/

function                                             old     new   delta
init_main                                            856     895     +39
message                                              146     144      -2
crond_main                                          1418    1416      -2
run                                                  661     658      -3
zcip_main                                           1409    1403      -6
edit_file                                            910     901      -9
environment                                           20       -     -20
2008-09-20 16:28:59 +00:00
Denis Vlasenko b61dc1c1ce webpage: add "RD129 embedded board from ELPA" to product page
split it into "projects" (software) and "products" (hardware) parts
2008-09-20 15:16:50 +00:00
Denis Vlasenko 3728bc5a3d website: add a product using bbox - EMTEC MovieCube R700 2008-09-20 13:28:45 +00:00
Denis Vlasenko 248b4a77e7 libbb: document that we maybe will want to understand \e someday
(no code changes)
2008-09-19 23:43:59 +00:00
Denis Vlasenko 9ac706b7a6 grep: yet another fixlet for EXTRA_COMPAT 2008-09-19 21:32:51 +00:00
Denis Vlasenko c110b7d61f grep: fix EXTRA_COMPAT grep to honor -E and -i 2008-09-19 21:29:21 +00:00
Denis Vlasenko 72fa70af4c setfont: small fixes from Vladimir 2008-09-18 01:01:02 +00:00
Denis Vlasenko 2228426512 id: fix "id <user>" case. Requires getgrouplist().
function                                             old     new   delta
getgrouplist_internal                                  -     200    +200
id_main                                              462     539     +77
bb_internal_getgrouplist                               -      67     +67
bb__parsespent                                       119     117      -2
bb_internal_initgroups                               213      58    -155
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/2 up/down: 344/-157)          Total: 187 bytes
2008-09-18 00:56:24 +00:00
Denis Vlasenko 28f5619e84 slattach: preserve speed in non-raw mode. +39 bytes.
by Matthieu CASTET (matthieu.castet AT parrot.com)
2008-09-16 21:27:59 +00:00
Denis Vlasenko 53f219ebbe setfont: support -m and -C, support -m TEXTUAL_MAP (by Vladimir)
build system: fixlet for echo applet config

function                                             old     new   delta
setfont_main                                         157     387    +230
ctoi                                                   -      75     +75
packed_usage                                       24921   24950     +29
2008-09-16 19:35:42 +00:00
Denis Vlasenko a1e16c9298 man: do not use default if /etc/man.conf has different MANPATH
do not warn if /etc/man.conf does not exist
2008-09-14 21:30:35 +00:00
Denis Vlasenko e357d2ae68 man: use default MANPATH of "/usr/man"; do not search paths twice 2008-09-14 21:26:55 +00:00
Denis Vlasenko 7c9c1bb616 modprobe-small: trivial SEGV fix 2008-09-14 20:33:03 +00:00
Denis Vlasenko 0d602e9386 id: unsigned long is excessive for option bitmask 2008-09-14 19:31:36 +00:00
Denis Vlasenko 2bc5c033dc setfont: add comments/TODOs, no code changes 2008-09-13 18:27:32 +00:00
Denis Vlasenko ba1315d0fb modutils/*: rewrite by Timo Teras <timo.teras AT iki.fi>
- a lot faster (linear algorithmic complexity, smaller memory foot print)
- a lot smaller (the old code was overly complicated)
- loading of aliases is now module-init-tools compliant
- blacklisting is done correctly (-b option added)
- module argument quoting done right
- depmod now correctly generates modules.symbols and modules.alias

add/remove: 16/21 grow/shrink: 4/6 up/down: 6930/-9316 Total: -2386 bytes
   text    data     bss     dec     hex filename
 806039     592    6680  813311   c68ff busybox_old
 803498     592    6676  810766   c5f0e busybox_unstripped
2008-09-13 14:59:38 +00:00
Denis Vlasenko 4f3209b9d4 id: code shrink
function                                             old     new   delta
id_main                                              494     462     -32
2008-09-13 12:51:10 +00:00
Bernhard Reutner-Fischer 0ee1cb0084 - implement id -G (Tito Ragusa) 2008-09-12 09:58:11 +00:00
Paul Mundt 70de57f60a Kill off bogus #error's for big endian SH targets, these work fine. 2008-09-12 09:19:40 +00:00
Denis Vlasenko 08ea11ab07 runsvd: shrink by Vladimir
*: use unified trivial signal handler

function                                             old     new   delta
record_signo                                           -      10     +10
process_stdin                                        433     443     +10
bbunpack                                             383     391      +8
wc_main                                              598     605      +7
conescape                                            293     296      +3
nmeter_main                                          670     672      +2
fallbackSort                                        1717    1719      +2
bb_got_signal                                          -       1      +1
microcom_main                                        713     712      -1
signalled                                              2       -      -2
pack_gzip                                           1661    1659      -2
evalvar                                             1376    1374      -2
compare_keys                                         737     735      -2
parse_command                                       1460    1456      -4
expand                                              1748    1744      -4
s_term                                                37      29      -8
s_hangup                                               8       -      -8
fgotsig                                               10       -     -10
find_pair                                            187     169     -18
signal_handler                                       190     170     -20
runsvdir_main                                       1701    1583    -118
------------------------------------------------------------------------------
(add/remove: 2/3 grow/shrink: 6/10 up/down: 43/-199)         Total: -156 bytes
2008-09-11 19:51:11 +00:00
Denis Vlasenko 9725daa03a halt: reinstate -w even if !FEATURE_WTMP; beautify code in halt.c 2008-09-11 09:54:23 +00:00
Denis Vlasenko 8d89bed840 watchdog: add -T option
function                                             old     new   delta
 watchdog_main                                        159     219     +60
mdev: support match by major,minor. See bug 4714.
 +100 bytes.
2008-09-07 23:22:08 +00:00
Denis Vlasenko ee9deb863e ifenslave: on uclibc at least, net/if.h + linux/if_bonding.h dont coexist 2008-09-06 14:52:28 +00:00
Denis Vlasenko ee34ebe966 ifenslave: wants net/if.h 2008-09-06 14:42:27 +00:00
Denis Vlasenko 9f9c1935fa install: shrink -D code. By Bernhard.
function                                             old     new   delta
install_main                                         726     707     -19
2008-09-06 14:35:08 +00:00
Denis Vlasenko 1c781cc8ff modprobe-small: make insmod command line compatible
function                                             old     new   delta
modprobe_main                                        326     435    +109
moderror                                               -      52     +52
process_module                                       577     530     -47
2008-09-06 14:14:01 +00:00
Bernhard Reutner-Fischer 4acb1b0793 - commentary typo fix 2008-09-05 11:46:43 +00:00
Denis Vlasenko 665eaff3b1 awk: add a comment 2008-09-05 04:59:02 +00:00
Bernhard Reutner-Fischer fd6b5ad137 - uncomment tc for now 2008-09-04 16:16:47 +00:00
Bernhard Reutner-Fischer 0901c51518 - add WIP stub for tc.
Printing worked at some point. Modify/Delete needs some refacturing.
2008-09-04 13:22:58 +00:00
Bernhard Reutner-Fischer 161931efa5 - mention that we ignore -v, -b, -c 2008-09-04 09:33:23 +00:00
Denis Vlasenko d4b719878f kbd_mode: fix non-ASCII letters in comments
install: support -D
2008-09-03 21:54:46 +00:00
Denis Vlasenko a2e1eea189 awk: improve nadling of negative numbers in bitwise ops;
fix handling of octal costants. add test for it

function                                             old     new   delta
getvar_i_int                                           -      93     +93
my_strtod                                              -      84     +84
qrealloc                                              33      36      +3
getvar_i                                              99      95      -4
next_token                                           979     919     -60
evaluate                                            6359    5627    -732
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/3 up/down: 180/-796)         Total: -616 bytes
2008-09-02 09:00:23 +00:00
Bernhard Reutner-Fischer b424930e4e - pass "Accept:" and "Accept-Language:" header to CGI scripts (Alina Friedrichsen)
Alina writes:
With this patch the BusyBox httpd pass the "Accept:" and
"Accept-Language:" header by the environment variables to the
CGI-Script, so this can make Content Negotiation to deliver the page in
the language, which was selected by the user in the browser settings,
and/or serve the XHTML page with the right MIME-Type
application/xhtml+xml to user agents which support it und text/html
which don't.

(Needed e.g. for OpenWrt LuCI.)

Signed-off-by: Alina Friedrichsen <x-alina at gmx dot net>
2008-09-01 15:30:49 +00:00
Bernhard Reutner-Fischer 2bdc99f600 - remove excess whitespace (Vladimir Dronnikov) 2008-09-01 15:26:12 +00:00
Bernhard Reutner-Fischer d93179fd5b - halt's -w depends on FEATURE_WTMP (Vladimir Dronnikov) 2008-09-01 15:24:52 +00:00
Bernhard Reutner-Fischer d129d7c3cd - add ether-wake to the hardcoded(argh!) list of APPLET_ODDNAME 2008-09-01 15:23:04 +00:00
Denis Vlasenko 04e458d435 insmod: fix detection of open failure 2008-08-31 21:56:48 +00:00
Denis Vlasenko 1045d00462 build system: fix "Possible unintended interpolation of @host"
message
2008-08-31 21:29:35 +00:00
Denis Vlasenko 66496d75a7 build system: echo and test features may be enabled
even if these applets are enabled as ash builtins only
testsuite: add some awk tests
2008-08-29 08:37:07 +00:00
Denis Vlasenko 7cbcd1cbf4 awk: bitwise ops cast oprands and results to unsigned long,
not signed. closes 4774.
2008-08-28 23:16:58 +00:00
Denis Vlasenko 996a61475a awk: support hex constants 2008-08-28 22:59:23 +00:00
Denis Vlasenko d66aa3c701 df: add support for more options, add some coreutils 6.10 compat.
by Bernhard Reutner-Fischer

function                                             old     new   delta
df_main                                              664     795    +131
packed_usage                                       24812   24862     +50
make_human_readable_str                              213     262     +49
static.ignored_mounts                                  -       8      +8
static.unit_chars                                      -       7      +7
static.zero_and_units                                  6       -      -6
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 3/0 up/down: 245/-6)            Total: 239 bytes
2008-08-28 22:42:52 +00:00
Denis Vlasenko 3b80cac953 insmod: mix xmalloc with xrealloc_vector more carefully 2008-08-28 21:38:10 +00:00
Bernhard Reutner-Fischer 1ebdaccd6d - forgot to pass in the HOST_EXTRACFLAGS 2008-08-28 14:29:54 +00:00
Denis Vlasenko 18c93029fd insmod: shrink
function                                             old     new   delta
obj_allocate_commons                                 488     462     -26
insmod_main                                         3830    3714    -116
2008-08-27 22:29:43 +00:00
Denis Vlasenko 8f0e342803 cksum: respect CONFIG_LFS=y. Adds 36 bytes in this case. 2008-08-27 21:31:23 +00:00
Bernhard Reutner-Fischer f3d1e213fe - pull check-lxdialog from linux-2.6.26 2008-08-27 07:39:57 +00:00
Denis Vlasenko b522d6931d trylink: make messages less confusing 2008-08-26 20:09:08 +00:00
Denis Vlasenko 279ca69727 modprobe-small: support "blacklist" keyword in /etc/modules/<modulename> 2008-08-26 01:32:33 +00:00
Denis Vlasenko c4e4b6b936 reinstate sponsor's links 2008-08-25 22:03:41 +00:00
Denis Vlasenko b66d16a2e6 fbset: fix mode matching code: original code may trigger false positive.
E.g. fbset -n '16bit'
 succeeded at 'mode "640x480 16bit"' and that is wrong.
 Also parser is rewritten. By Vladimir.

function                                             old     new   delta
static.syncs                                           -      20     +20
g_options                                              4       -      -4
g_cmdoptions                                         432     385     -47
fbset_main                                          1842    1642    -200
2008-08-24 16:25:40 +00:00
Denis Vlasenko 5770715588 ping: SO_RCVBUF must be bigger than packet size,
otherwise large ping packets might fail to be received.
2008-08-24 00:02:18 +00:00
Denis Vlasenko 15f2fdb2b9 hexdump: fix SEGV in hexdump -e "" 2008-08-23 23:15:48 +00:00
Denis Vlasenko 7fe21c69cd setarch: do not try to use non-existent data in argv[] 2008-08-23 23:15:17 +00:00
Denis Vlasenko 6cd36bc2da tweak web page 2008-08-22 11:16:52 +00:00
Bernhard Reutner-Fischer 9ff245f6a0 - move some older news to the news archive (the main page was once again over 30kib big) 2008-08-22 08:45:01 +00:00
Bernhard Reutner-Fischer 7d0d3e265b - reformat help text 2008-08-22 08:25:26 +00:00
Denis Vlasenko 657341762a Announce 1.11.2 2008-08-21 22:10:47 +00:00
Bernhard Reutner-Fischer a28a05b96a - print the documentation per default 2008-08-21 21:15:28 +00:00
Bernhard Reutner-Fischer 99ecc46d93 - document rmdir args 2008-08-21 20:52:55 +00:00
Bernhard Reutner-Fischer 6375853cd8 - document rmmod -w and -f arguments 2008-08-21 20:18:55 +00:00
Denis Vlasenko e82da4dfee fix xargs -e help text 2008-08-21 19:59:30 +00:00
Bernhard Reutner-Fischer c397792ab3 - tweak markup. No relevant changes 2008-08-21 16:08:06 +00:00
Bernhard Reutner-Fischer bc8bc59e69 - cleanup urls 2008-08-21 14:37:14 +00:00
Bernhard Reutner-Fischer 3b0161d045 - fix typo 2008-08-21 14:14:36 +00:00
Bernhard Reutner-Fischer f2d4a65be8 - fix markup 2008-08-21 14:10:55 +00:00
Bernhard Reutner-Fischer eae3846e87 - do not advertise the standalone udhcpd. It is actively maintained in busybox only. 2008-08-21 14:08:44 +00:00
Bernhard Reutner-Fischer e0fe65b68f - fix markup 2008-08-21 14:00:25 +00:00
Bernhard Reutner-Fischer 8eeaa747c8 - add doc-clean target 2008-08-21 13:47:20 +00:00
Bernhard Reutner-Fischer 6887e77c32 - add note about CONFIG_CROSS_COMPILER_PREFIX while cleanup up markup. 2008-08-21 13:37:47 +00:00
Bernhard Reutner-Fischer 20a55b7bff - fix typo of mine 2008-08-21 13:32:14 +00:00
Bernhard Reutner-Fischer f0d0811c05 - improve documentation a bit 2008-08-21 13:22:44 +00:00
Bernhard Reutner-Fischer b5d701d737 - some more nitpicks 2008-08-21 12:52:45 +00:00
Bernhard Reutner-Fischer beea4b8021 - some more markup fixes 2008-08-21 12:42:39 +00:00
Bernhard Reutner-Fischer 0fa539457b - fix typo 2008-08-21 12:27:42 +00:00
Denis Vlasenko b91168a74c more of pointless beautifuing on the web page 2008-08-21 12:24:02 +00:00
Denis Vlasenko f9dba6e226 trim webpage text a bit 2008-08-21 12:07:38 +00:00
Bernhard Reutner-Fischer 557f9c4b31 - drop outdated paragraph (which additionally contained some mistyped html-like junk) 2008-08-21 11:54:23 +00:00
Bernhard Reutner-Fischer 5f52150536 - misc. minor tweaks 2008-08-21 11:52:12 +00:00
Bernhard Reutner-Fischer beb6ea47c3 - point people to the current stable branch 2008-08-21 11:43:36 +00:00
Bernhard Reutner-Fischer 78c41b2dc5 - tweak markup 2008-08-21 11:38:22 +00:00
Denis Vlasenko 14a79381d0 more cosmetic fixes on the website 2008-08-21 11:36:24 +00:00
Denis Vlasenko 68cef20f5d cosmetic fixes on the webpage 2008-08-21 11:34:57 +00:00
Bernhard Reutner-Fischer b22fbfefc8 - tweak markup 2008-08-21 11:34:46 +00:00
Bernhard Reutner-Fischer a0420aba1c - bump copyright year 2008-08-21 11:23:42 +00:00
Bernhard Reutner-Fischer 158f1d4ea6 - fix markup 2008-08-21 11:19:52 +00:00
Bernhard Reutner-Fischer 8c8601cfbc - fix some wrong markup.
sed -i -e 's, href=\([^"][^>]*\)>, href="\1">,g' *.html
  The proper way to specify an attribute is to quote the val: theattrib="val"
2008-08-21 10:54:55 +00:00
Bernhard Reutner-Fischer 040feada1e - correct release date for 1.12.0 and fix a few typos 2008-08-21 10:35:26 +00:00
Denis Vlasenko c1b39edee1 announce 1.12.0 2008-08-21 10:19:28 +00:00
Denis Vlasenko 2a7031bb12 Bump version to 1.13.0.svn 2008-08-20 23:30:42 +00:00
757 changed files with 47740 additions and 30883 deletions

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
#
# Kbuild ignores
#
.*
*.o
*.o.*
*.a
*.s
#
# Never ignore these
#
!.gitignore
#
# Normal output
#
/busybox
/busybox_unstripped*
#
# Backups / patches
#
*~
*.orig
*.rej
/*.patch
#
# debugging stuff
#
core
.gdb_history
.gdbinit
+1 -1
View File
@@ -166,7 +166,7 @@ Paul Fox <pgf@foxharp.boston.ma.us>
Roberto A. Foglietta <me@roberto.foglietta.name>
port: dnsd
Bernhard Fischer <rep.nop@aon.at>
Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
misc
Mike Frysinger <vapier@gentoo.org>
+55 -33
View File
@@ -30,18 +30,6 @@ config EXTRA_COMPAT
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
@@ -114,7 +102,29 @@ config LOCALE_SUPPORT
Enable this if your system has locale support and you would like
busybox to support locale settings.
config GETOPT_LONG
config FEATURE_ASSUME_UNICODE
bool "Support Unicode"
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.
config FEATURE_CHECK_UNICODE_IN_ENV
bool "Check $LANG environment variable"
default y
depends on FEATURE_ASSUME_UNICODE && !LOCALE_SUPPORT
help
With this option on, Unicode support is activated
only if LANG variable has the value of the form "xxxx.utf8"
Otherwise, Unicode support will be always enabled and active.
config LONG_OPTS
bool "Support for --long-options"
default y
help
@@ -155,15 +165,17 @@ config FEATURE_SUID
default n
help
With this option you can install the busybox binary belonging
to root with the suid bit set, and it'll and it'll automatically drop
to root with the suid bit set, and it will automatically drop
priviledges for applets that don't need root access.
If you're really paranoid and don't want to do this, build two
If you are 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
are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs,
and vlock.
are:
crontab, dnsd, findfs, ipcrm, ipcs, login, passwd, ping, su,
traceroute, vlock.
config FEATURE_SUID_CONFIG
bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
@@ -254,18 +266,18 @@ config BUSYBOX_EXEC_PATH
# These are auto-selected by other options
config FEATURE_SYSLOG
bool "Support for logging to syslog"
bool #No description makes it a hidden option
default n
help
This option is auto-selected when you select any applet which may
send its output to syslog. You do not need to select it manually.
#help
# This option is auto-selected when you select any applet which may
# send its output to syslog. You do not need to select it manually.
config FEATURE_HAVE_RPC
bool "RPC support"
bool #No description makes it a hidden option
default n
help
This is automatically selected if any of enabled applets need it.
You do not need to select it manually.
#help
# This is automatically selected if any of enabled applets need it.
# You do not need to select it manually.
endmenu
@@ -402,9 +414,18 @@ config CROSS_COMPILER_PREFIX
help
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.
"i386-uclibc-".
Note that CROSS_COMPILE environment variable or
"make CROSS_COMPILE=xxx ..." will override this selection.
Native builds leave this empty.
config EXTRA_CFLAGS
string "Additional CFLAGS"
default ""
help
Additional CFLAGS to pass to the compiler verbatim.
endmenu
@@ -491,8 +512,8 @@ config INCLUDE_SUSv2
will be supported in head, tail, and fold. (Note: should
affect renice too.)
config PARSE
bool "Uniform config file parser debugging applet: parse"
### config PARSE
### bool "Uniform config file parser debugging applet: parse"
endmenu
@@ -590,9 +611,10 @@ source modutils/Config.in
source util-linux/Config.in
source miscutils/Config.in
source networking/Config.in
source printutils/Config.in
source mailutils/Config.in
source procps/Config.in
source shell/Config.in
source sysklogd/Config.in
source runit/Config.in
source selinux/Config.in
source printutils/Config.in
source shell/Config.in
source sysklogd/Config.in
+2 -2
View File
@@ -10,7 +10,7 @@ distributed under.
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -313,7 +313,7 @@ the "copyright" line and a pointer to where the full notice is found.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
+11 -3
View File
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 12
SUBLEVEL = 0
PATCHLEVEL = 15
SUBLEVEL = 2
EXTRAVERSION =
NAME = Unnamed
@@ -168,6 +168,7 @@ 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
@@ -456,6 +457,7 @@ libs-y := \
libbb/ \
libpwdgrp/ \
loginutils/ \
mailutils/ \
miscutils/ \
modutils/ \
networking/ \
@@ -505,7 +507,7 @@ endif
# command line.
# This allow a user to issue only 'make' to build a kernel including modules
# Defaults busybox but it is usually overridden in the arch makefile
all: busybox
all: busybox doc
-include $(srctree)/arch/$(ARCH)/Makefile
@@ -966,6 +968,12 @@ clean: archclean $(clean-dirs)
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
-type f -print | xargs rm -f
PHONY += doc-clean
doc-clean: rm-files := docs/busybox.pod \
docs/BusyBox.html docs/BusyBox.1 docs/BusyBox.txt
doc-clean:
$(call cmd,rmfiles)
# mrproper - Delete all generated files, including .config
#
mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
+6
View File
@@ -105,6 +105,12 @@ bigdata: busybox_unstripped
.PHONY: doc
doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
# FIXME: Doesn't belong here
cmd_doc =
quiet_cmd_doc = $(Q)echo " DOC $(@F)"
silent_cmd_doc =
disp_doc = $($(quiet)cmd_doc)
docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
$(srctree)/include/usage.h \
$(srctree)/docs/busybox_footer.pod \
+18 -3
View File
@@ -23,6 +23,7 @@ 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,-Wunused-function -Wunused-value,)
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
# warn about C99 declaration after statement
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
@@ -31,6 +32,15 @@ CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
ifeq ($(CONFIG_WERROR),y)
CFLAGS += $(call cc-option,-Werror,)
## TODO:
## gcc version 4.4.0 20090506 (Red Hat 4.4.0-4) (GCC) is a PITA:
## const char *ptr; ... off_t v = *(off_t*)ptr; -> BOOM
## and no easy way to convince it to shut the hell up.
## We have a lot of such things all over the place.
## Classic *(off_t*)(void*)ptr does not work,
## and I am unwilling to do crazy gcc specific ({ void *ppp = ...; })
## stuff in macros. This would obfuscate the code too much.
#CFLAGS += $(call cc-ifversion, -eq, 0404, -fno-strict-aliasing)
endif
# gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
@@ -81,6 +91,11 @@ CFLAGS_busybox += $(ARCH_PIE)
CFLAGS += $(ARCH_FPIE)
endif
ifneq ($(CONFIG_EXTRA_CFLAGS),)
CFLAGS += $(strip $(subst ",,$(CONFIG_EXTRA_CFLAGS)))
#"))
endif
LDLIBS += m crypt
ifeq ($(CONFIG_PAM),y)
@@ -99,12 +114,12 @@ ifeq ($(CONFIG_DMALLOC),y)
LDLIBS += dmalloc
endif
# If a flat binary should be built, CFLAGS_busybox="-Wl,-elf2flt"
# If a flat binary should be built, CFLAGS_busybox="-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
# seem to be entirely correct variable to put "-elf2flt" into).
W_ELF2FLT = -elf2flt
ifneq (,$(findstring $(W_ELF2FLT),$(LDFLAGS) $(CFLAGS_busybox)))
SKIP_STRIP = y
endif
+1
View File
@@ -6,6 +6,7 @@ help:
@echo 'Cleaning:'
@echo ' clean - delete temporary files created by build'
@echo ' distclean - delete all non-source files (including .config)'
@echo ' doc-clean - delete all generated documentation'
@echo
@echo 'Build:'
@echo ' all - Executable and documentation'
+1 -1
View File
@@ -78,7 +78,7 @@ Downloading the current source code:
http://busybox.net/developer.html
The developers also have a bug and patch tracking system
(http://bugs.busybox.net) although posting a bug/patch to the mailing list
(https://bugs.busybox.net) although posting a bug/patch to the mailing list
is generally a faster way of getting it fixed, and the complete archive of
what happened is the subversion changelog.
+42 -24
View File
@@ -16,14 +16,10 @@ Rob Landley suggested these:
Figure out where we need utf8 support, and add it.
sh
The command shell situation is a big mess. We have three different
The command shell situation is a mess. We have two 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.
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).
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
@@ -99,15 +95,10 @@ Rob Landley suggested these:
This one's open to everybody, but I'll wind up doing it...
Bernhard Fischer <busybox@busybox.net> suggests to look at these:
Bernhard Reutner-Fischer <busybox@busybox.net> suggests to look at these:
New debug options:
-Wlarger-than-127
Cleanup any big users
-Wunused-parameter
Facilitate applet PROTOTYPES to provide means for having applets that
do a) not take any arguments b) need only one of argc or argv c) need
both argc and argv. All of these three options should go for the most
feature complete denominator.
Collate BUFSIZ IOBUF_SIZE MY_BUF_SIZE PIPE_PROGRESS_SIZE BUFSIZE PIPESIZE
make bb_common_bufsiz1 configurable, size wise.
make pipesize configurable, size wise.
@@ -132,14 +123,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
---
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
compressed. This could probably be a script in the extras directory that
calls cat/zcat/bzcat | less
(How doclifter might work into this is anybody's guess.)
---
ar
Write support!
---
@@ -183,8 +166,7 @@ Unify archivers
---
Text buffer support.
Several existing applets (sort, vi, less...) read
a whole file into memory and act on it. There might be an opportunity
for shared code in there that could be moved into libbb...
a whole file into memory and act on it. Use open_read_close().
---
Memory Allocation
We have a CONFIG_BUFFER mechanism that lets us select whether to do memory
@@ -236,7 +218,7 @@ Switch CONFIG_SYMBOLS to ENABLE_SYMBOLS
FEATURE_CLEAN_UP
This is more an unresolved issue than a to-do item. More thought is needed.
Normally we rely on exit() to free memory, close files, and unmap segments
Normally we rely on exit() to free memory, close files and unmap segments
for us. This makes most calls to free(), close(), and unmap() optional in
busybox applets that don't intend to run for very long, and optional stuff
can be omitted to save size.
@@ -265,7 +247,6 @@ FEATURE_CLEAN_UP
For right now, exit() handles it just fine.
Minor stuff:
watchdog.c could autodetect the timer duration via:
if(!ioctl (fd, WDIOC_GETTIMEOUT, &tmo)) timer_duration = 1 + (tmo / 2);
@@ -280,13 +261,14 @@ Minor stuff:
---
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
Move __get_hz() to a better place and (re)use it in route.c, ash.c
---
See grep -r strtod
Alot of duplication that wants cleanup.
---
in_ether duplicated in network/{interface,ifconfig}.c
---
unify progress_meter. wget, flash_eraseall, pipe_progress, fbsplash, setfiles.
Code cleanup:
@@ -296,3 +278,39 @@ Replace deprecated functions.
---
vdprintf() -> similar sized functionality
---
(TODO list after discussion 11.05.2009)
* shrink tc/brctl/ip
tc/brctl seem like fairly large things to try and tackle in your timeframe,
and i think people have posted attempts in the past. Adding additional
options to ip though seems reasonable.
* add tests for some applets
* implement POSIX utilities and audit them for POSIX conformance. then
audit them for GNU conformance. then document all your findings in a new
doc/conformance.txt file while perhaps implementing some of the missing
features.
you can find the latest POSIX documentation (1003.1-2008) here:
http://www.opengroup.org/onlinepubs/9699919799/
and the complete list of all utilities that POSIX covers:
http://www.opengroup.org/onlinepubs/9699919799/idx/utilities.html
The first step would to generate a file/matrix what is already archived
(also IPV6)
* ntpdate/ntpd (see ntpclient and openntp for examples)
* implement 'at'
* rpcbind (former portmap) or equivalent
so that we don't have to use -o nolock on nfs mounts
* check IPV6 compliance
* generate a mini example using kernel+busybox only (+libc) for example
* more support for advanced linux 2.6.x features, see: iotop
most likely there is more
* even more support for statistics: mpstat, iostat, powertop....
+149 -95
View File
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Busybox version: 1.12.0.svn
# Wed Aug 20 00:24:07 2008
# Busybox version: 1.15.0.svn
# Fri Aug 21 00:13:18 2009
#
CONFIG_HAVE_DOT_CONFIG=y
@@ -13,8 +13,7 @@ CONFIG_HAVE_DOT_CONFIG=y
# General Configuration
#
CONFIG_DESKTOP=y
# CONFIG_EXTRA_COMPAT is not set
CONFIG_FEATURE_ASSUME_UNICODE=y
CONFIG_EXTRA_COMPAT=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
@@ -23,7 +22,9 @@ CONFIG_FEATURE_VERBOSE_USAGE=y
CONFIG_FEATURE_COMPRESS_USAGE=y
CONFIG_FEATURE_INSTALLER=y
# CONFIG_LOCALE_SUPPORT is not set
CONFIG_GETOPT_LONG=y
# CONFIG_FEATURE_ASSUME_UNICODE is not set
# CONFIG_FEATURE_CHECK_UNICODE_IN_ENV is not set
CONFIG_LONG_OPTS=y
CONFIG_FEATURE_DEVPTS=y
# CONFIG_FEATURE_CLEAN_UP is not set
CONFIG_FEATURE_PIDFILE=y
@@ -47,6 +48,7 @@ CONFIG_NOMMU=y
# CONFIG_FEATURE_SHARED_BUSYBOX is not set
CONFIG_LFS=y
CONFIG_CROSS_COMPILER_PREFIX=""
CONFIG_EXTRA_CFLAGS=""
#
# Debugging Options
@@ -58,7 +60,6 @@ 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
@@ -88,6 +89,8 @@ CONFIG_FEATURE_EDITING_HISTORY=15
CONFIG_FEATURE_TAB_COMPLETION=y
CONFIG_FEATURE_USERNAME_COMPLETION=y
CONFIG_FEATURE_EDITING_FANCY_PROMPT=y
CONFIG_FEATURE_EDITING_ASK_TERMINAL=y
CONFIG_FEATURE_NON_POSIX_CP=y
CONFIG_FEATURE_VERBOSE_CP_MESSAGE=y
CONFIG_FEATURE_COPYBUF_KB=4
CONFIG_MONOTONIC_SYSCALL=y
@@ -111,11 +114,14 @@ CONFIG_BUNZIP2=y
CONFIG_BZIP2=y
CONFIG_CPIO=y
CONFIG_FEATURE_CPIO_O=y
CONFIG_FEATURE_CPIO_P=y
CONFIG_DPKG=y
CONFIG_DPKG_DEB=y
CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY=y
CONFIG_GUNZIP=y
CONFIG_GZIP=y
CONFIG_LZOP=y
CONFIG_LZOP_COMPR_HIGH=y
CONFIG_RPM2CPIO=y
CONFIG_RPM=y
CONFIG_TAR=y
@@ -153,7 +159,7 @@ CONFIG_DD=y
CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
CONFIG_FEATURE_DD_IBS_OBS=y
CONFIG_DF=y
CONFIG_FEATURE_DF_INODE=y
CONFIG_FEATURE_DF_FANCY=y
CONFIG_DIRNAME=y
CONFIG_DOS2UNIX=y
CONFIG_UNIX2DOS=y
@@ -169,6 +175,7 @@ CONFIG_EXPR=y
CONFIG_EXPR_MATH_SUPPORT_64=y
CONFIG_FALSE=y
CONFIG_FOLD=y
CONFIG_FSYNC=y
CONFIG_HEAD=y
CONFIG_FEATURE_FANCY_HEAD=y
CONFIG_HOSTID=y
@@ -208,6 +215,8 @@ CONFIG_RMDIR=y
CONFIG_FEATURE_RMDIR_LONG_OPTIONS=y
CONFIG_SEQ=y
CONFIG_SHA1SUM=y
CONFIG_SHA256SUM=y
CONFIG_SHA512SUM=y
CONFIG_SLEEP=y
CONFIG_FEATURE_FANCY_SLEEP=y
CONFIG_FEATURE_FLOAT_SLEEP=y
@@ -283,6 +292,8 @@ CONFIG_FEATURE_RESIZE_PRINT=y
CONFIG_SETCONSOLE=y
CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS=y
CONFIG_SETFONT=y
CONFIG_FEATURE_SETFONT_TEXTUAL_MAP=y
CONFIG_DEFAULT_SETFONT_DIR=""
CONFIG_SETKEYCODES=y
CONFIG_SETLOGCONS=y
CONFIG_SHOWKEY=y
@@ -304,7 +315,7 @@ CONFIG_WHICH=y
# Editors
#
CONFIG_AWK=y
CONFIG_FEATURE_AWK_MATH=y
CONFIG_FEATURE_AWK_LIBM=y
CONFIG_CMP=y
CONFIG_DIFF=y
CONFIG_FEATURE_DIFF_BINARY=y
@@ -367,7 +378,6 @@ CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
# Init Utilities
#
CONFIG_INIT=y
# CONFIG_DEBUG_INIT is not set
CONFIG_FEATURE_USE_INITTAB=y
CONFIG_FEATURE_KILL_REMOVED=y
CONFIG_FEATURE_KILL_DELAY=1
@@ -377,6 +387,8 @@ CONFIG_FEATURE_EXTRA_QUIET=y
CONFIG_FEATURE_INIT_COREDUMPS=y
CONFIG_FEATURE_INITRD=y
CONFIG_HALT=y
# CONFIG_FEATURE_CALL_TELINIT is not set
CONFIG_TELINIT_PATH=""
CONFIG_MESG=y
#
@@ -386,13 +398,17 @@ CONFIG_FEATURE_SHADOWPASSWDS=y
CONFIG_USE_BB_PWD_GRP=y
CONFIG_USE_BB_SHADOW=y
CONFIG_USE_BB_CRYPT=y
CONFIG_USE_BB_CRYPT_SHA=y
CONFIG_ADDGROUP=y
CONFIG_FEATURE_ADDGROUP_LONG_OPTIONS=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_FIRST_SYSTEM_ID=100
CONFIG_LAST_SYSTEM_ID=999
CONFIG_DELUSER=y
CONFIG_GETTY=y
CONFIG_FEATURE_UTMP=y
@@ -425,32 +441,35 @@ CONFIG_LSATTR=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_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_BLACKLIST is not set
# CONFIG_DEPMOD is not set
#
# Options common to multiple modutils
#
# CONFIG_FEATURE_2_4_MODULES 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_FEATURE_MODUTILS_ALIAS is not set
# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
# CONFIG_FEATURE_QUERY_MODULE_INTERFACE is not set
#
# Linux System Utilities
#
# CONFIG_ACPID is not set
# CONFIG_FEATURE_ACPID_COMPAT is not set
CONFIG_BLKID=y
CONFIG_DMESG=y
CONFIG_FEATURE_DMESG_PRETTY=y
CONFIG_FBSET=y
@@ -475,7 +494,9 @@ CONFIG_MKFS_MINIX=y
# Minix filesystem support
#
CONFIG_FEATURE_MINIX2=y
CONFIG_MKFS_VFAT=y
CONFIG_GETOPT=y
CONFIG_FEATURE_GETOPT_LONG=y
CONFIG_HEXDUMP=y
CONFIG_FEATURE_HEXDUMP_REVERSE=y
CONFIG_HD=y
@@ -492,7 +513,7 @@ 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_FEATURE_MKSWAP_UUID=y
CONFIG_MORE=y
CONFIG_FEATURE_USE_TERMIOS=y
CONFIG_VOLUMEID=y
@@ -527,6 +548,7 @@ CONFIG_RDEV=y
CONFIG_READPROFILE=y
CONFIG_RTCWAKE=y
CONFIG_SCRIPT=y
CONFIG_SCRIPTREPLAY=y
CONFIG_SETARCH=y
CONFIG_SWAPONOFF=y
CONFIG_FEATURE_SWAPON_PRI=y
@@ -545,6 +567,9 @@ CONFIG_FEATURE_MOUNT_LOOP=y
#
CONFIG_ADJTIMEX=y
CONFIG_BBCONFIG=y
CONFIG_BEEP=y
CONFIG_FEATURE_BEEP_FREQ=4000
CONFIG_FEATURE_BEEP_LENGTH_MS=30
CONFIG_CHAT=y
CONFIG_FEATURE_CHAT_NOFAIL=y
CONFIG_FEATURE_CHAT_TTY_HIFI=y
@@ -555,18 +580,25 @@ CONFIG_FEATURE_CHAT_VAR_ABORT_LEN=y
CONFIG_FEATURE_CHAT_CLR_ABORT=y
CONFIG_CHRT=y
CONFIG_CROND=y
CONFIG_DEBUG_CROND_OPTION=y
CONFIG_FEATURE_CROND_D=y
CONFIG_FEATURE_CROND_CALL_SENDMAIL=y
CONFIG_FEATURE_CROND_DIR="/var/spool/cron"
CONFIG_CRONTAB=y
CONFIG_DC=y
CONFIG_FEATURE_DC_LIBM=y
# CONFIG_DEVFSD is not set
# CONFIG_DEVFSD_MODLOAD is not set
# CONFIG_DEVFSD_FG_NP is not set
# CONFIG_DEVFSD_VERBOSE is not set
# CONFIG_FEATURE_DEVFS is not set
CONFIG_DEVMEM=y
CONFIG_EJECT=y
CONFIG_FEATURE_EJECT_SCSI=y
CONFIG_FBSPLASH=y
# CONFIG_FLASH_LOCK is not set
# CONFIG_FLASH_UNLOCK is not set
# CONFIG_FLASH_ERASEALL is not set
CONFIG_IONICE=y
CONFIG_INOTIFYD=y
CONFIG_LAST=y
CONFIG_FEATURE_LAST_SMALL=y
@@ -575,9 +607,11 @@ CONFIG_LESS=y
CONFIG_FEATURE_LESS_MAXLINES=9999999
CONFIG_FEATURE_LESS_BRACKETS=y
CONFIG_FEATURE_LESS_FLAGS=y
CONFIG_FEATURE_LESS_FLAGCS=y
CONFIG_FEATURE_LESS_MARKS=y
CONFIG_FEATURE_LESS_REGEXP=y
CONFIG_FEATURE_LESS_WINCH=y
CONFIG_FEATURE_LESS_DASHCMD=y
CONFIG_FEATURE_LESS_LINENUMS=y
CONFIG_HDPARM=y
CONFIG_FEATURE_HDPARM_GET_IDENTITY=y
CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF=y
@@ -601,13 +635,16 @@ CONFIG_STRINGS=y
CONFIG_TASKSET=y
CONFIG_FEATURE_TASKSET_FANCY=y
CONFIG_TIME=y
CONFIG_TIMEOUT=y
CONFIG_TTYSIZE=y
CONFIG_VOLNAME=y
CONFIG_WATCHDOG=y
#
# Networking Utilities
#
CONFIG_FEATURE_IPV6=y
CONFIG_FEATURE_UNIX_LOCAL=y
CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y
CONFIG_VERBOSE_RESOLUTION_ERRORS=y
CONFIG_ARP=y
@@ -618,6 +655,8 @@ CONFIG_FEATURE_BRCTL_SHOW=y
CONFIG_DNSD=y
CONFIG_ETHER_WAKE=y
CONFIG_FAKEIDENTD=y
CONFIG_FTPD=y
CONFIG_FEATURE_FTP_WRITE=y
CONFIG_FTPGET=y
CONFIG_FTPPUT=y
CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y
@@ -625,11 +664,9 @@ CONFIG_HOSTNAME=y
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
@@ -643,6 +680,7 @@ CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y
CONFIG_FEATURE_IFCONFIG_HW=y
CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
CONFIG_IFENSLAVE=y
CONFIG_IFPLUGD=y
CONFIG_IFUPDOWN=y
CONFIG_IFUPDOWN_IFSTATE_PATH="/var/run/ifstate"
CONFIG_FEATURE_IFUPDOWN_IP=y
@@ -689,8 +727,6 @@ 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
@@ -702,7 +738,7 @@ CONFIG_TFTPD=y
CONFIG_FEATURE_TFTP_GET=y
CONFIG_FEATURE_TFTP_PUT=y
CONFIG_FEATURE_TFTP_BLOCKSIZE=y
CONFIG_DEBUG_TFTP=y
CONFIG_TFTP_DEBUG=y
CONFIG_TRACEROUTE=y
CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE=y
@@ -715,10 +751,11 @@ 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_UDHCP_DEBUG=9
CONFIG_FEATURE_UDHCP_RFC3397=y
CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80
CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="-R -n"
CONFIG_VCONFIG=y
CONFIG_WGET=y
CONFIG_FEATURE_WGET_STATUSBAR=y
@@ -726,8 +763,28 @@ CONFIG_FEATURE_WGET_AUTHENTICATION=y
CONFIG_FEATURE_WGET_LONG_OPTIONS=y
CONFIG_ZCIP=y
CONFIG_TCPSVD=y
CONFIG_TUNCTL=y
CONFIG_FEATURE_TUNCTL_UG=y
CONFIG_UDPSVD=y
#
# Print Utilities
#
CONFIG_LPD=y
CONFIG_LPR=y
CONFIG_LPQ=y
#
# Mail Utilities
#
CONFIG_MAKEMIME=y
CONFIG_FEATURE_MIME_CHARSET="us-ascii"
CONFIG_POPMAILDIR=y
CONFIG_FEATURE_POPMAILDIR_DELIVERY=y
CONFIG_REFORMIME=y
CONFIG_FEATURE_REFORMIME_COMPAT=y
CONFIG_SENDMAIL=y
#
# Process Utilities
#
@@ -745,80 +802,28 @@ CONFIG_PKILL=y
CONFIG_PS=y
CONFIG_FEATURE_PS_WIDE=y
CONFIG_FEATURE_PS_TIME=y
CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS=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_SMP_CPU=y
CONFIG_FEATURE_TOP_DECIMALS=y
CONFIG_FEATURE_TOP_SMP_PROCESS=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_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
# CONFIG_ASH_ALIAS is not set
# CONFIG_ASH_MATH_SUPPORT is not set
# 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=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
#
# Bourne Shell Options
#
CONFIG_FEATURE_SH_EXTRA_QUIET=y
CONFIG_FEATURE_SH_STANDALONE=y
CONFIG_FEATURE_SH_NOFORK=y
CONFIG_CTTYHACK=y
#
# System Logging Utilities
#
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
CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING=y
CONFIG_KLOGD=y
CONFIG_LOGGER=y
#
# Runit Utilities
#
CONFIG_RUNSV=y
CONFIG_RUNSVDIR=y
CONFIG_FEATURE_RUNSVDIR_LOG=y
CONFIG_SV=y
CONFIG_SV_DEFAULT_SERVICE_DIR="/var/service"
CONFIG_SVLOGD=y
CONFIG_CHPST=y
CONFIG_SETUIDGID=y
@@ -827,7 +832,7 @@ CONFIG_ENVDIR=y
CONFIG_SOFTLIMIT=y
#
# Selinux Utilities
# SELinux Utilities
#
CONFIG_CHCON=y
CONFIG_FEATURE_CHCON_LONG_OPTIONS=y
@@ -846,8 +851,57 @@ CONFIG_SETSEBOOL=y
CONFIG_SESTATUS=y
#
# Print Utilities
# Shells
#
CONFIG_LPD=y
CONFIG_LPR=y
CONFIG_LPQ=y
# CONFIG_FEATURE_SH_IS_ASH is not set
CONFIG_FEATURE_SH_IS_HUSH=y
# CONFIG_FEATURE_SH_IS_NONE is not set
# 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
# CONFIG_ASH_ALIAS 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=y
CONFIG_HUSH_BASH_COMPAT=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_HUSH_FUNCTIONS=y
CONFIG_HUSH_LOCAL=y
CONFIG_HUSH_EXPORT_N=y
CONFIG_LASH=y
CONFIG_MSH=y
CONFIG_SH_MATH_SUPPORT=y
CONFIG_SH_MATH_SUPPORT_64=y
CONFIG_FEATURE_SH_EXTRA_QUIET=y
CONFIG_FEATURE_SH_STANDALONE=y
CONFIG_FEATURE_SH_NOFORK=y
CONFIG_CTTYHACK=y
#
# System Logging Utilities
#
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
CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING=y
CONFIG_KLOGD=y
CONFIG_LOGGER=y
+2
View File
@@ -0,0 +1,2 @@
/applet_tables
/usage
+13 -4
View File
@@ -14,17 +14,26 @@ always:= $(hostprogs-y)
# Generated files need additional love
HOSTCFLAGS_usage.o = -I$(srctree)/include
# This trick decreases amount of rebuilds
# if tree is merely renamed/copied
ifeq ($(srctree),$(objtree))
srctree_slash =
else
srctree_slash = $(srctree)/
endif
HOSTCFLAGS_usage.o = -I$(srctree_slash)include
applets/applets.o: include/usage_compressed.h include/applet_tables.h
applets/usage: .config $(srctree)/applets/usage_compressed
applets/usage: .config $(srctree_slash)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
cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets
include/usage_compressed.h: applets/usage $(srctree)/applets/usage_compressed
include/usage_compressed.h: applets/usage $(srctree_slash)applets/usage_compressed
$(call cmd,gen_usage_compressed)
quiet_cmd_gen_applet_tables = GEN include/applet_tables.h
+5
View File
@@ -1,4 +1,9 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2008 Denys Vlasenko.
*
* Licensed under GPLv2, see file LICENSE in this tarball for details.
*/
#include <unistd.h>
/* Just #include "autoconf.h" doesn't work for builds in separate
+2 -2
View File
@@ -17,14 +17,14 @@ 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 \
"$loc/usage" | bzip2 -1 | dd bs=2 skip=1 | od -v -t x1 \
| $SED -e 's/^[^ ]*//' \
| $SED -e 's/ //g' \
| grep -v '^$' \
+31 -8
View File
@@ -53,12 +53,12 @@ config AR
probably say N here.
config FEATURE_AR_LONG_FILENAMES
bool "Support for long filenames (not need for debs)"
bool "Support for long filenames (not needed 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.
@@ -110,9 +110,17 @@ config FEATURE_CPIO_O
This implementation of cpio can create cpio archives in the "newc"
format only.
config FEATURE_CPIO_P
bool "Support for passthrough mode"
default n
depends on FEATURE_CPIO_O
help
Passthrough mode. Rarely used.
config DPKG
bool "dpkg"
default n
select FEATURE_SEAMLESS_GZ
help
dpkg is a medium-level tool to install, build, remove and manage
Debian packages.
@@ -123,9 +131,9 @@ config DPKG
config DPKG_DEB
bool "dpkg_deb"
default n
select FEATURE_SEAMLESS_GZ
help
dpkg-deb packs, unpacks and provides information about Debian
archives.
dpkg-deb unpacks and provides information about Debian archives.
This implementation of dpkg-deb cannot pack archives.
@@ -157,6 +165,21 @@ config GZIP
gzip is used to compress files.
It's probably the most widely used UNIX compression program.
config LZOP
bool "lzop"
default n
help
Lzop compression/decompresion.
config LZOP_COMPR_HIGH
bool "lzop complession levels 7,8,9 (not very useful)"
default n
depends on LZOP
help
High levels (7,8,9) of lzop compression. These levels
are actually slower than gzip at equivalent compression ratios
and take up 3.2K of code.
config RPM2CPIO
bool "rpm2cpio"
default n
@@ -188,11 +211,11 @@ config FEATURE_TAR_CREATE
tar archives using the `-c' option.
config FEATURE_TAR_AUTODETECT
bool "Autodetect gz/bz2 compressed tarballs"
bool "Autodetect compressed tarballs"
default n
depends on FEATURE_SEAMLESS_Z || FEATURE_SEAMLESS_GZ || FEATURE_SEAMLESS_BZ2 || FEATURE_SEAMLESS_LZMA
help
With this option tar can automatically detect gzip/bzip2 compressed
With this option tar can automatically detect compressed
tarballs. Currently it works only on files (not pipes etc).
config FEATURE_TAR_FROM
@@ -233,7 +256,7 @@ config FEATURE_TAR_GNU_EXTENSIONS
config FEATURE_TAR_LONG_OPTIONS
bool "Enable long options"
default n
depends on TAR && GETOPT_LONG
depends on TAR && LONG_OPTS
help
Enable use of long options, increases size by about 400 Bytes
+2
View File
@@ -16,6 +16,8 @@ lib-$(CONFIG_DPKG) += dpkg.o
lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o
lib-$(CONFIG_GUNZIP) += bbunzip.o
lib-$(CONFIG_GZIP) += gzip.o bbunzip.o
lib-$(CONFIG_LZOP) += lzop.o lzo1x_1.o lzo1x_1o.o lzo1x_d.o bbunzip.o
lib-$(CONFIG_LZOP_COMPR_HIGH) += lzo1x_9x.o
lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o
lib-$(CONFIG_RPM) += rpm.o
lib-$(CONFIG_TAR) += tar.o
+27 -11
View File
@@ -30,13 +30,14 @@ int open_to_or_warn(int to_fd, const char *filename, int flags, int mode)
int FAST_FUNC bbunpack(char **argv,
char* (*make_new_name)(char *filename),
USE_DESKTOP(long long) int (*unpacker)(void)
IF_DESKTOP(long long) int (*unpacker)(unpack_info_t *info)
)
{
struct stat stat_buf;
USE_DESKTOP(long long) int status;
IF_DESKTOP(long long) int status;
char *filename, *new_name;
smallint exitcode = 0;
unpack_info_t info;
do {
/* NB: new_name is *maybe* malloc'ed! */
@@ -92,14 +93,29 @@ int FAST_FUNC bbunpack(char **argv,
"use -f to force it");
}
status = unpacker();
/* memset(&info, 0, sizeof(info)); */
info.mtime = 0; /* so far it has one member only */
status = unpacker(&info);
if (status < 0)
exitcode = 1;
if (filename) {
char *del = new_name;
if (status >= 0) {
/* TODO: restore user/group/times here? */
/* TODO: restore other things? */
if (info.mtime) {
struct utimbuf times;
times.actime = info.mtime;
times.modtime = info.mtime;
/* Close first.
* On some systems calling utime
* then closing resets the mtime. */
close(STDOUT_FILENO);
/* Ignoring errors */
utime(new_name, &times);
}
/* Delete _compressed_ file */
del = filename;
/* restore extension (unless tgz -> tar case) */
@@ -159,7 +175,7 @@ char* make_new_name_bunzip2(char *filename)
}
static
USE_DESKTOP(long long) int unpack_bunzip2(void)
IF_DESKTOP(long long) int unpack_bunzip2(unpack_info_t *info UNUSED_PARAM)
{
return unpack_bz2_stream_prime(STDIN_FILENO, STDOUT_FILENO);
}
@@ -235,9 +251,9 @@ char* make_new_name_gunzip(char *filename)
}
static
USE_DESKTOP(long long) int unpack_gunzip(void)
IF_DESKTOP(long long) int unpack_gunzip(unpack_info_t *info)
{
USE_DESKTOP(long long) int status = -1;
IF_DESKTOP(long long) int status = -1;
/* do the decompression, and cleanup */
if (xread_char(STDIN_FILENO) == 0x1f) {
@@ -247,7 +263,7 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
if (ENABLE_FEATURE_SEAMLESS_Z && magic2 == 0x9d) {
status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO);
} else if (magic2 == 0x8b) {
status = unpack_gz_stream(STDIN_FILENO, STDOUT_FILENO);
status = unpack_gz_stream_with_info(STDIN_FILENO, STDOUT_FILENO, info);
} else {
goto bad_magic;
}
@@ -309,7 +325,7 @@ char* make_new_name_unlzma(char *filename)
}
static
USE_DESKTOP(long long) int unpack_unlzma(void)
IF_DESKTOP(long long) int unpack_unlzma(unpack_info_t *info UNUSED_PARAM)
{
return unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO);
}
@@ -344,9 +360,9 @@ char* make_new_name_uncompress(char *filename)
}
static
USE_DESKTOP(long long) int unpack_uncompress(void)
IF_DESKTOP(long long) int unpack_uncompress(unpack_info_t *info UNUSED_PARAM)
{
USE_DESKTOP(long long) int status = -1;
IF_DESKTOP(long long) int status = -1;
if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) {
bb_error_msg("invalid magic");
+6 -5
View File
@@ -8,6 +8,7 @@
*/
#include "libbb.h"
#include "unarchive.h"
#define CONFIG_BZIP2_FEATURE_SPEED 1
@@ -63,7 +64,7 @@ static uint8_t level;
* total written bytes so far otherwise
*/
static
USE_DESKTOP(long long) int bz_write(bz_stream *strm, void* rbuf, ssize_t rlen, void *wbuf)
IF_DESKTOP(long long) int bz_write(bz_stream *strm, void* rbuf, ssize_t rlen, void *wbuf)
{
int n, n2, ret;
@@ -97,13 +98,13 @@ USE_DESKTOP(long long) int bz_write(bz_stream *strm, void* rbuf, ssize_t rlen, v
if (rlen && strm->avail_in == 0)
break;
}
return 0 USE_DESKTOP( + strm->total_out );
return 0 IF_DESKTOP( + strm->total_out );
}
static
USE_DESKTOP(long long) int compressStream(void)
IF_DESKTOP(long long) int compressStream(unpack_info_t *info UNUSED_PARAM)
{
USE_DESKTOP(long long) int total;
IF_DESKTOP(long long) int total;
ssize_t count;
bz_stream bzs; /* it's small */
#define strm (&bzs)
@@ -162,7 +163,7 @@ int bzip2_main(int argc UNUSED_PARAM, char **argv)
opt_complementary = "s2"; /* -s means -2 (compatibility) */
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
opt = getopt32(argv, "cfv" USE_BUNZIP2("dt") "123456789qzs");
opt = getopt32(argv, "cfv" IF_BUNZIP2("dt") "123456789qzs");
#if ENABLE_BUNZIP2 /* bunzip2_main may not be visible... */
if (opt & 0x18) // -d and/or -t
return bunzip2_main(argc, argv);
+271 -191
View File
@@ -14,177 +14,13 @@
#include "libbb.h"
#include "unarchive.h"
#if ENABLE_FEATURE_CPIO_O
static off_t cpio_pad4(off_t size)
{
int i;
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:
-t, --list List the archive
-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
@@ -242,48 +78,280 @@ static int cpio_o(void)
--sparse Write files with blocks of zeros as sparse files
-u, --unconditional Replace all files unconditionally
*/
enum {
CPIO_OPT_EXTRACT = (1 << 0),
CPIO_OPT_TEST = (1 << 1),
CPIO_OPT_NUL_TERMINATED = (1 << 2),
CPIO_OPT_UNCONDITIONAL = (1 << 3),
CPIO_OPT_VERBOSE = (1 << 4),
CPIO_OPT_CREATE_LEADING_DIR = (1 << 5),
CPIO_OPT_PRESERVE_MTIME = (1 << 6),
CPIO_OPT_DEREF = (1 << 7),
CPIO_OPT_FILE = (1 << 8),
OPTBIT_FILE = 8,
IF_FEATURE_CPIO_O(OPTBIT_CREATE ,)
IF_FEATURE_CPIO_O(OPTBIT_FORMAT ,)
IF_FEATURE_CPIO_P(OPTBIT_PASSTHROUGH,)
IF_LONG_OPTS( OPTBIT_QUIET ,)
IF_LONG_OPTS( OPTBIT_2STDOUT ,)
CPIO_OPT_CREATE = IF_FEATURE_CPIO_O((1 << OPTBIT_CREATE )) + 0,
CPIO_OPT_FORMAT = IF_FEATURE_CPIO_O((1 << OPTBIT_FORMAT )) + 0,
CPIO_OPT_PASSTHROUGH = IF_FEATURE_CPIO_P((1 << OPTBIT_PASSTHROUGH)) + 0,
CPIO_OPT_QUIET = IF_LONG_OPTS( (1 << OPTBIT_QUIET )) + 0,
CPIO_OPT_2STDOUT = IF_LONG_OPTS( (1 << OPTBIT_2STDOUT )) + 0,
};
#define OPTION_STR "it0uvdmLF:"
#if ENABLE_FEATURE_CPIO_O
static off_t cpio_pad4(off_t size)
{
int i;
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)
{
static const char trailer[] ALIGN1 = "TRAILER!!!";
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 = (option_mask32 & CPIO_OPT_NUL_TERMINATED)
? bb_get_chunk_from_file(stdin, NULL)
: 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 ((option_mask32 & CPIO_OPT_DEREF)
? stat(name, &st)
: 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 (name != trailer)
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
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;
USE_FEATURE_CPIO_O(const char *cpio_fmt = "";)
IF_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),
};
#if ENABLE_GETOPT_LONG
#if ENABLE_LONG_OPTS
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"
#if ENABLE_FEATURE_CPIO_P
"pass-through\0" No_argument "p"
#endif
#endif
"verbose\0" No_argument "v"
"quiet\0" No_argument "\xff"
"to-stdout\0" No_argument "\xfe"
;
#endif
/* Initialize */
archive_handle = init_handle();
archive_handle->src_fd = STDIN_FILENO;
archive_handle->seek = seek_by_read;
archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER;
/* As of now we do not enforce this: */
/* -i,-t,-o,-p are mutually exclusive */
/* -u,-d,-m make sense only with -i or -p */
/* -L makes sense only with -o or -p */
#if ENABLE_FEATURE_CPIO_O
opt = getopt32(argv, "ituvF:dmoH:", &cpio_filename, &cpio_fmt);
#if !ENABLE_FEATURE_CPIO_O
opt = getopt32(argv, OPTION_STR, &cpio_filename);
#else
opt = getopt32(argv, OPTION_STR "oH:" IF_FEATURE_CPIO_P("p"), &cpio_filename, &cpio_fmt);
if (opt & CPIO_OPT_PASSTHROUGH) {
pid_t pid;
struct fd_pair pp;
if (argv[optind] == NULL)
bb_show_usage();
if (opt & CPIO_OPT_CREATE_LEADING_DIR)
mkdir(argv[optind], 0777);
/* Crude existence check:
* close(xopen(argv[optind], O_RDONLY | O_DIRECTORY));
* We can also xopen, fstat, IS_DIR, later fchdir.
* This would check for existence earlier and cleaner.
* As it stands now, if we fail xchdir later,
* child dies on EPIPE, unless it caught
* a diffrerent problem earlier.
* This is good enough for now.
*/
#if !BB_MMU
pp.rd = 3;
pp.wr = 4;
if (!re_execed) {
close(3);
close(4);
xpiped_pair(pp);
}
#else
xpiped_pair(pp);
#endif
pid = fork_or_rexec(argv);
if (pid == 0) { /* child */
close(pp.rd);
xmove_fd(pp.wr, STDOUT_FILENO);
goto dump;
}
/* parent */
xchdir(argv[optind++]);
close(pp.wr);
xmove_fd(pp.rd, STDIN_FILENO);
opt &= ~CPIO_OPT_PASSTHROUGH;
opt |= CPIO_OPT_EXTRACT;
goto skip;
}
/* -o */
if (opt & CPIO_OPT_CREATE) {
if (*cpio_fmt != 'n')
if (*cpio_fmt != 'n') /* we _require_ "-H newc" */
bb_show_usage();
if (opt & CPIO_OPT_FILE) {
fclose(stdout);
@@ -291,13 +359,18 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
/* Paranoia: I don't trust libc that much */
xdup2(fileno(stdout), STDOUT_FILENO);
}
dump:
return cpio_o();
}
#else
opt = getopt32(argv, "ituvF:dm", &cpio_filename);
skip:
#endif
argv += optind;
archive_handle = init_handle();
archive_handle->src_fd = STDIN_FILENO;
archive_handle->seek = seek_by_read;
archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER;
/* One of either extract or test options must be given */
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
bb_show_usage();
@@ -305,13 +378,13 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
if (opt & CPIO_OPT_TEST) {
/* if both extract and test options are given, ignore extract option */
if (opt & CPIO_OPT_EXTRACT) {
opt &= ~CPIO_OPT_EXTRACT;
}
opt &= ~CPIO_OPT_EXTRACT;
archive_handle->action_header = header_list;
}
if (opt & CPIO_OPT_EXTRACT) {
archive_handle->action_data = data_extract_all;
if (opt & CPIO_OPT_2STDOUT)
archive_handle->action_data = data_extract_to_stdout;
}
if (opt & CPIO_OPT_UNCONDITIONAL) {
archive_handle->ah_flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
@@ -341,8 +414,15 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
argv++;
}
/* see get_header_cpio */
archive_handle->ah_priv[2] = (void*) ~(ptrdiff_t)0;
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
continue;
if (archive_handle->ah_priv[2] != (void*) ~(ptrdiff_t)0
&& !(opt & CPIO_OPT_QUIET)
)
printf("%lu blocks\n", (unsigned long)(ptrdiff_t)(archive_handle->ah_priv[2]));
return EXIT_SUCCESS;
}
+77 -77
View File
@@ -6,6 +6,10 @@
* written by glenn mcgrath with the help of others
* copyright (c) 2001 by glenn mcgrath
*
* parts of the version comparison code is plucked from the real dpkg
* application which is licensed GPLv2 and
* copyright (c) 1995 Ian Jackson <ian@chiark.greenend.org.uk>
*
* started life as a busybox implementation of udpkg
*
* licensed under gplv2 or later, see file license in this tarball for details.
@@ -25,6 +29,7 @@
*/
#include "libbb.h"
#include <fnmatch.h>
#include "unarchive.h"
/* note: if you vary hash_prime sizes be aware,
@@ -134,7 +139,7 @@ static void make_hash(const char *key, unsigned *start, unsigned *decrement, con
/* shifts the ascii based value and adds it to previous value
* 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*/
* no effect */
hash_num += (key[i] + key[i-1]) << ((key[i] * i) % 24);
}
*start = (unsigned) hash_num % hash_prime;
@@ -182,60 +187,52 @@ static unsigned search_status_hashtable(const char *key)
return probe_address;
}
/* Need to rethink version comparison, maybe the official dpkg has something i can use ? */
static int version_compare_part(const char *version1, const char *version2)
static int order(char x)
{
int upstream_len1 = 0;
int upstream_len2 = 0;
char *name1_char;
char *name2_char;
int len1 = 0;
int len2 = 0;
int tmp_int;
int ver_num1;
int ver_num2;
return (x == '~' ? -1
: x == '\0' ? 0
: isdigit(x) ? 0
: isalpha(x) ? x
: (unsigned char)x + 256
);
}
if (version1 == NULL) {
version1 = xstrdup("");
}
if (version2 == NULL) {
version2 = xstrdup("");
}
upstream_len1 = strlen(version1);
upstream_len2 = strlen(version2);
/* This code is taken from dpkg and modified slightly to work with busybox */
static int version_compare_part(const char *val, const char *ref)
{
if (!val) val = "";
if (!ref) ref = "";
while ((len1 < upstream_len1) || (len2 < upstream_len2)) {
/* Compare non-digit section */
tmp_int = strcspn(&version1[len1], "0123456789");
name1_char = xstrndup(&version1[len1], tmp_int);
len1 += tmp_int;
tmp_int = strcspn(&version2[len2], "0123456789");
name2_char = xstrndup(&version2[len2], tmp_int);
len2 += tmp_int;
tmp_int = strcmp(name1_char, name2_char);
free(name1_char);
free(name2_char);
if (tmp_int != 0) {
return tmp_int;
while (*val || *ref) {
int first_diff;
while ((*val && !isdigit(*val)) || (*ref && !isdigit(*ref))) {
int vc = order(*val);
int rc = order(*ref);
if (vc != rc)
return vc - rc;
val++;
ref++;
}
/* Compare digits */
tmp_int = strspn(&version1[len1], "0123456789");
name1_char = xstrndup(&version1[len1], tmp_int);
len1 += tmp_int;
tmp_int = strspn(&version2[len2], "0123456789");
name2_char = xstrndup(&version2[len2], tmp_int);
len2 += tmp_int;
ver_num1 = atoi(name1_char);
ver_num2 = atoi(name2_char);
free(name1_char);
free(name2_char);
if (ver_num1 < ver_num2) {
return -1;
while (*val == '0')
val++;
while (*ref == '0')
ref++;
first_diff = 0;
while (isdigit(*val) && isdigit(*ref)) {
if (first_diff == 0)
first_diff = *val - *ref;
val++;
ref++;
}
if (ver_num1 > ver_num2) {
if (isdigit(*val))
return 1;
}
if (isdigit(*ref))
return -1;
if (first_diff)
return first_diff;
}
return 0;
}
@@ -248,39 +245,34 @@ static int version_compare(const unsigned ver1, const unsigned ver2)
{
char *ch_ver1 = name_hashtable[ver1];
char *ch_ver2 = name_hashtable[ver2];
char epoch1, epoch2;
unsigned long epoch1 = 0, epoch2 = 0;
char *colon;
char *deb_ver1, *deb_ver2;
char *ver1_ptr, *ver2_ptr;
char *upstream_ver1;
char *upstream_ver2;
int result;
/* Compare epoch */
if (ch_ver1[1] == ':') {
epoch1 = ch_ver1[0];
ver1_ptr = strchr(ch_ver1, ':') + 1;
} else {
epoch1 = '0';
ver1_ptr = ch_ver1;
colon = strchr(ch_ver1, ':');
if (colon) {
epoch1 = atoi(ch_ver1);
ch_ver1 = colon + 1;
}
if (ch_ver2[1] == ':') {
epoch2 = ch_ver2[0];
ver2_ptr = strchr(ch_ver2, ':') + 1;
} else {
epoch2 = '0';
ver2_ptr = ch_ver2;
colon = strchr(ch_ver2, ':');
if (colon) {
epoch2 = atoi(ch_ver2);
ch_ver2 = colon + 1;
}
if (epoch1 < epoch2) {
return -1;
}
else if (epoch1 > epoch2) {
if (epoch1 > epoch2) {
return 1;
}
/* Compare upstream version */
upstream_ver1 = xstrdup(ver1_ptr);
upstream_ver2 = xstrdup(ver2_ptr);
upstream_ver1 = xstrdup(ch_ver1);
upstream_ver2 = xstrdup(ch_ver2);
/* Chop off debian version, and store for later use */
deb_ver1 = strrchr(upstream_ver1, '-');
@@ -1293,7 +1285,7 @@ static void free_array(char **array)
* the status_hashtable to retrieve the info. This results in smaller code than
* scanning the status file. The resulting list, however, is unsorted.
*/
static void list_packages(void)
static void list_packages(const char *pattern)
{
int i;
@@ -1314,6 +1306,9 @@ static void list_packages(void)
name_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->name];
vers_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->version];
if (pattern && fnmatch(pattern, name_str, 0))
continue;
/* get abbreviation for status field 1 */
s1 = stat_str[0] == 'i' ? 'i' : 'r';
@@ -1359,8 +1354,8 @@ static void remove_package(const unsigned package_num, int noisy)
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);
/* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
exclude_files = xzalloc(sizeof(exclude_files[0]) * 3);
exclude_files[0] = xstrdup(conffile_name);
exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
@@ -1398,20 +1393,25 @@ static void purge_package(const unsigned package_num)
sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
remove_files = create_list(list_name);
exclude_files = xzalloc(sizeof(char*));
/* Some directories cant be removed straight away, so do multiple passes */
while (remove_file_array(remove_files, exclude_files)) /* repeat */;
while (remove_file_array(remove_files, NULL))
continue;
free_array(remove_files);
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = all_control_list(package_name);
remove_file_array(remove_files, exclude_files);
free_array(remove_files);
free(exclude_files);
/* Run postrm script */
/* Delete all of them except the postrm script */
exclude_files = xzalloc(sizeof(exclude_files[0]) * 2);
exclude_files[0] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
remove_file_array(remove_files, exclude_files);
free_array(exclude_files);
/* Run and remove postrm script */
run_package_script_or_die(package_name, "postrm");
remove_file_array(remove_files, NULL);
free_array(remove_files);
/* Change package status */
set_status(status_num, "not-installed", 3);
@@ -1626,7 +1626,7 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv)
/* if the list action was given print the installed packages and exit */
if (opt & OPT_list_installed) {
list_packages();
list_packages(argv[0]);
return EXIT_SUCCESS;
}
+35 -40
View File
@@ -40,6 +40,7 @@ aa: 85.1% -- replaced with aa.gz
*/
#include "libbb.h"
#include "unarchive.h"
/* ===========================================================================
@@ -266,7 +267,7 @@ struct globals {
#define DECLARE(type, array, size) \
type * array
#define ALLOC(type, array, size) \
array = xzalloc((size_t)(((size)+1L)/2) * 2*sizeof(type));
array = xzalloc((size_t)(((size)+1L)/2) * 2*sizeof(type))
#define FREE(array) \
do { free(array); array = NULL; } while (0)
@@ -387,19 +388,6 @@ static void put_32bit(ulg n)
put_16bit(n >> 16);
}
/* ===========================================================================
* Clear input and output buffers
*/
static void clear_bufs(void)
{
G1.outcnt = 0;
#ifdef DEBUG
G1.insize = 0;
#endif
G1.isize = 0;
}
/* ===========================================================================
* Run a set of bytes through the crc shift register. If s is a NULL
* pointer, then initialize the crc shift register contents instead.
@@ -2014,11 +2002,41 @@ char* make_new_name_gzip(char *filename)
}
static
USE_DESKTOP(long long) int pack_gzip(void)
IF_DESKTOP(long long) int pack_gzip(unpack_info_t *info UNUSED_PARAM)
{
struct stat s;
clear_bufs();
/* Clear input and output buffers */
G1.outcnt = 0;
#ifdef DEBUG
G1.insize = 0;
#endif
G1.isize = 0;
/* Reinit G2.xxx */
memset(&G2, 0, sizeof(G2));
G2.l_desc.dyn_tree = G2.dyn_ltree;
G2.l_desc.static_tree = G2.static_ltree;
G2.l_desc.extra_bits = extra_lbits;
G2.l_desc.extra_base = LITERALS + 1;
G2.l_desc.elems = L_CODES;
G2.l_desc.max_length = MAX_BITS;
//G2.l_desc.max_code = 0;
G2.d_desc.dyn_tree = G2.dyn_dtree;
G2.d_desc.static_tree = G2.static_dtree;
G2.d_desc.extra_bits = extra_dbits;
//G2.d_desc.extra_base = 0;
G2.d_desc.elems = D_CODES;
G2.d_desc.max_length = MAX_BITS;
//G2.d_desc.max_code = 0;
G2.bl_desc.dyn_tree = G2.bl_tree;
//G2.bl_desc.static_tree = NULL;
G2.bl_desc.extra_bits = extra_blbits,
//G2.bl_desc.extra_base = 0;
G2.bl_desc.elems = BL_CODES;
G2.bl_desc.max_length = MAX_BL_BITS;
//G2.bl_desc.max_code = 0;
s.st_ctime = 0;
fstat(STDIN_FILENO, &s);
zip(s.st_ctime);
@@ -2049,7 +2067,7 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
unsigned opt;
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
opt = getopt32(argv, "cfv" USE_GUNZIP("dt") "q123456789n");
opt = getopt32(argv, "cfv" IF_GUNZIP("dt") "q123456789n");
#if ENABLE_GUNZIP /* gunzip_main may not be visible... */
if (opt & 0x18) // -d and/or -t
return gunzip_main(argc, argv);
@@ -2063,29 +2081,6 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
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;
G2.l_desc.extra_base = LITERALS + 1;
G2.l_desc.elems = L_CODES;
G2.l_desc.max_length = MAX_BITS;
//G2.l_desc.max_code = 0;
G2.d_desc.dyn_tree = G2.dyn_dtree;
G2.d_desc.static_tree = G2.static_dtree;
G2.d_desc.extra_bits = extra_dbits;
//G2.d_desc.extra_base = 0;
G2.d_desc.elems = D_CODES;
G2.d_desc.max_length = MAX_BITS;
//G2.d_desc.max_code = 0;
G2.bl_desc.dyn_tree = G2.bl_tree;
//G2.bl_desc.static_tree = NULL;
G2.bl_desc.extra_bits = extra_blbits,
//G2.bl_desc.extra_base = 0;
G2.bl_desc.elems = BL_CODES;
G2.bl_desc.max_length = MAX_BL_BITS;
//G2.bl_desc.max_code = 0;
/* Allocate all global buffers (for DYN_ALLOC option) */
ALLOC(uch, G1.l_buf, INBUFSIZ);
+93
View File
@@ -0,0 +1,93 @@
/*
This file is part of the LZO real-time data compression library.
Copyright (C) 1996..2008 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
Markus F.X.J. Oberhumer <markus@oberhumer.com>
http://www.oberhumer.com/opensource/lzo/
The LZO library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the LZO library; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "liblzo_interface.h"
/* lzo-2.03/src/config1x.h */
#define M2_MIN_LEN 3
#define M2_MAX_LEN 8
#define M3_MAX_LEN 33
#define M4_MAX_LEN 9
#define M1_MAX_OFFSET 0x0400
#define M2_MAX_OFFSET 0x0800
#define M3_MAX_OFFSET 0x4000
#define M4_MAX_OFFSET 0xbfff
#define M1_MARKER 0
#define M3_MARKER 32
#define M4_MARKER 16
#define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
#define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
#define LZO_EOF_CODE
/* lzo-2.03/src/lzo_dict.h */
#define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex]
#define DX2(p,s1,s2) \
(((((unsigned)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
//#define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
//#define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
#define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
#define D_SIZE (1U << D_BITS)
#define D_MASK ((1U << D_BITS) - 1)
#define D_HIGH ((D_MASK >> 1) + 1)
#define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
( \
m_pos = ip - (unsigned)(ip - m_pos), \
((uintptr_t)m_pos < (uintptr_t)in \
|| (m_off = (unsigned)(ip - m_pos)) <= 0 \
|| m_off > max_offset) \
)
#define DENTRY(p,in) (p)
#define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in)
#define DMS(v,s) ((unsigned) (((v) & (D_MASK >> (s))) << (s)))
#define DM(v) ((unsigned) ((v) & D_MASK))
#define DMUL(a,b) ((unsigned) ((a) * (b)))
/* lzo-2.03/src/lzo_ptr.h */
#define pd(a,b) ((unsigned)((a)-(b)))
# define TEST_IP (ip < ip_end)
# define NEED_IP(x) \
if ((unsigned)(ip_end - ip) < (unsigned)(x)) goto input_overrun
# undef TEST_OP /* don't need both of the tests here */
# define TEST_OP 1
# define NEED_OP(x) \
if ((unsigned)(op_end - op) < (unsigned)(x)) goto output_overrun
#define HAVE_ANY_OP 1
//#if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
# define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
//# define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
//#else
//# define TEST_LB(m_pos) ((void) 0)
//# define TEST_LBO(m_pos,o) ((void) 0)
//#endif
+71
View File
@@ -0,0 +1,71 @@
/*
This file is part of the LZO real-time data compression library.
Copyright (C) 1996..2008 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
Markus F.X.J. Oberhumer <markus@oberhumer.com>
http://www.oberhumer.com/opensource/lzo/
The LZO library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the LZO library; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#define LZO1X
#undef LZO1Y
#undef assert
/*
static void die_at(int line)
{
bb_error_msg_and_die("internal error at %d", line);
}
#define assert(v) if (!(v)) die_at(__LINE__)
*/
#define assert(v) ((void)0)
int lzo1x_1_compress(const uint8_t* src, unsigned src_len,
uint8_t* dst, unsigned* dst_len,
void* wrkmem);
int lzo1x_1_15_compress(const uint8_t* src, unsigned src_len,
uint8_t* dst, unsigned* dst_len,
void* wrkmem);
int lzo1x_999_compress_level(const uint8_t* in, unsigned in_len,
uint8_t* out, unsigned* out_len,
void* wrkmem,
int compression_level);
/* decompression */
//int lzo1x_decompress(const uint8_t* src, unsigned src_len,
// uint8_t* dst, unsigned* dst_len,
// void* wrkmem /* NOT USED */);
/* safe decompression with overrun testing */
int lzo1x_decompress_safe(const uint8_t* src, unsigned src_len,
uint8_t* dst, unsigned* dst_len,
void* wrkmem /* NOT USED */);
#define LZO_E_OK 0
#define LZO_E_ERROR (-1)
#define LZO_E_OUT_OF_MEMORY (-2) /* [not used right now] */
#define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */
#define LZO_E_INPUT_OVERRUN (-4)
#define LZO_E_OUTPUT_OVERRUN (-5)
#define LZO_E_LOOKBEHIND_OVERRUN (-6)
#define LZO_E_EOF_NOT_FOUND (-7)
#define LZO_E_INPUT_NOT_CONSUMED (-8)
#define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */
/* lzo-2.03/include/lzo/lzoconf.h */
#define LZO_VERSION 0x2030
+7 -1
View File
@@ -4,7 +4,9 @@
#
# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
lib-y:= \
lib-y:=
COMMON_FILES:= \
\
data_skip.o \
data_extract_all.o \
@@ -49,3 +51,7 @@ lib-$(CONFIG_FEATURE_SEAMLESS_GZ) += open_transformer.o decompress_unzip.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
ifneq ($(lib-y),)
lib-y += $(COMMON_FILES)
endif
+19 -16
View File
@@ -21,7 +21,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
/* Check if the file already exists */
if (archive_handle->ah_flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
/* Remove the entry if it exists */
if (((file_header->mode & S_IFMT) != S_IFDIR)
if ((!S_ISDIR(file_header->mode))
&& (unlink(file_header->name) == -1)
&& (errno != ENOENT)
) {
@@ -77,7 +77,9 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
}
case S_IFDIR:
res = mkdir(file_header->name, file_header->mode);
if ((res == -1) && (errno != EISDIR)
if ((res == -1)
&& (errno != EISDIR) /* btw, Linux doesn't return this */
&& (errno != EEXIST)
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("cannot make dir %s", file_header->name);
@@ -113,23 +115,24 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
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 (!(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)) {
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);
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
#endif
lchown(file_header->name, file_header->uid, file_header->gid);
}
if ((file_header->mode & S_IFMT) != S_IFLNK) {
if (!S_ISLNK(file_header->mode)) {
/* uclibc has no lchmod, glibc is even stranger -
* it has lchmod which seems to do nothing!
* so we use chmod... */
+5 -5
View File
@@ -648,10 +648,10 @@ void FAST_FUNC 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 FAST_FUNC
IF_DESKTOP(long long) int FAST_FUNC
unpack_bz2_stream(int src_fd, int dst_fd)
{
USE_DESKTOP(long long total_written = 0;)
IF_DESKTOP(long long total_written = 0;)
char *outbuf;
bunzip_data *bd;
int i;
@@ -666,7 +666,7 @@ unpack_bz2_stream(int src_fd, int dst_fd)
i = RETVAL_SHORT_WRITE;
break;
}
USE_DESKTOP(total_written += i;)
IF_DESKTOP(total_written += i;)
}
}
@@ -686,10 +686,10 @@ unpack_bz2_stream(int src_fd, int dst_fd)
dealloc_bunzip(bd);
free(outbuf);
return i ? i : USE_DESKTOP(total_written) + 0;
return i ? i : IF_DESKTOP(total_written) + 0;
}
USE_DESKTOP(long long) int FAST_FUNC
IF_DESKTOP(long long) int FAST_FUNC
unpack_bz2_stream_prime(int src_fd, int dst_fd)
{
unsigned char magic[2];
@@ -72,11 +72,11 @@
* be stored in the compressed file.
*/
USE_DESKTOP(long long) int FAST_FUNC
IF_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;
IF_DESKTOP(long long total_written = 0;)
IF_DESKTOP(long long) int retval = -1;
unsigned char *stackp;
long code;
int finchar;
@@ -265,7 +265,7 @@ unpack_Z_stream(int fd_in, int fd_out)
if (outpos >= OBUFSIZ) {
full_write(fd_out, outbuf, outpos);
//error check??
USE_DESKTOP(total_written += outpos;)
IF_DESKTOP(total_written += outpos;)
outpos = 0;
}
stackp += i;
@@ -294,10 +294,10 @@ unpack_Z_stream(int fd_in, int fd_out)
if (outpos > 0) {
full_write(fd_out, outbuf, outpos);
//error check??
USE_DESKTOP(total_written += outpos;)
IF_DESKTOP(total_written += outpos;)
}
retval = USE_DESKTOP(total_written) + 0;
retval = IF_DESKTOP(total_written) + 0;
err:
free(inbuf);
free(outbuf);
+8 -8
View File
@@ -228,10 +228,10 @@ enum {
};
USE_DESKTOP(long long) int FAST_FUNC
IF_DESKTOP(long long) int FAST_FUNC
unpack_lzma_stream(int src_fd, int dst_fd)
{
USE_DESKTOP(long long total_written = 0;)
IF_DESKTOP(long long total_written = 0;)
lzma_header_t header;
int lc, pb, lp;
uint32_t pos_state_mask;
@@ -330,7 +330,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
global_pos += 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_DESKTOP(total_written += header.dict_size;)
}
#else
len = 1;
@@ -468,20 +468,20 @@ unpack_lzma_stream(int src_fd, int dst_fd)
}
len += LZMA_MATCH_MIN_LEN;
SKIP_FEATURE_LZMA_FAST(string:)
IF_NOT_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:)
IF_NOT_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) != (ssize_t)header.dict_size)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
IF_DESKTOP(total_written += header.dict_size;)
}
len--;
} while (len != 0 && buffer_pos < header.dst_size);
@@ -489,8 +489,8 @@ unpack_lzma_stream(int src_fd, int dst_fd)
}
{
SKIP_DESKTOP(int total_written = 0; /* success */)
USE_DESKTOP(total_written += buffer_pos;)
IF_NOT_DESKTOP(int total_written = 0; /* success */)
IF_DESKTOP(total_written += buffer_pos;)
if (full_write(dst_fd, buffer, buffer_pos) != (ssize_t)buffer_pos) {
bad:
total_written = -1; /* failure */
+28 -17
View File
@@ -970,10 +970,10 @@ static int inflate_get_next_window(STATE_PARAM_ONLY)
/* Called from unpack_gz_stream() and inflate_unzip() */
static USE_DESKTOP(long long) int
static IF_DESKTOP(long long) int
inflate_unzip_internal(STATE_PARAM int in, int out)
{
USE_DESKTOP(long long) int n = 0;
IF_DESKTOP(long long) int n = 0;
ssize_t nwrote;
/* Allocate all global buffers (for DYN_ALLOC option) */
@@ -1008,7 +1008,7 @@ inflate_unzip_internal(STATE_PARAM int in, int out)
n = -1;
goto ret;
}
USE_DESKTOP(n += nwrote;)
IF_DESKTOP(n += nwrote;)
if (r == 0) break;
}
@@ -1033,10 +1033,10 @@ inflate_unzip_internal(STATE_PARAM int in, int out)
/* For unzip */
USE_DESKTOP(long long) int FAST_FUNC
IF_DESKTOP(long long) int FAST_FUNC
inflate_unzip(inflate_unzip_result *res, off_t compr_size, int in, int out)
{
USE_DESKTOP(long long) int n;
IF_DESKTOP(long long) int n;
DECLARE_STATE;
ALLOC_STATE;
@@ -1083,8 +1083,7 @@ static uint16_t buffer_read_le_u16(STATE_PARAM_ONLY)
{
uint16_t res;
#if BB_LITTLE_ENDIAN
/* gcc 4.2.1 is very clever */
memcpy(&res, &bytebuffer[bytebuffer_offset], 2);
move_from_unaligned16(res, &bytebuffer[bytebuffer_offset]);
#else
res = bytebuffer[bytebuffer_offset];
res |= bytebuffer[bytebuffer_offset + 1] << 8;
@@ -1097,7 +1096,7 @@ static uint32_t buffer_read_le_u32(STATE_PARAM_ONLY)
{
uint32_t res;
#if BB_LITTLE_ENDIAN
memcpy(&res, &bytebuffer[bytebuffer_offset], 4);
move_from_unaligned32(res, &bytebuffer[bytebuffer_offset]);
#else
res = bytebuffer[bytebuffer_offset];
res |= bytebuffer[bytebuffer_offset + 1] << 8;
@@ -1108,18 +1107,21 @@ static uint32_t buffer_read_le_u32(STATE_PARAM_ONLY)
return res;
}
static int check_header_gzip(STATE_PARAM_ONLY)
static int check_header_gzip(STATE_PARAM unpack_info_t *info)
{
union {
unsigned char raw[8];
struct {
uint8_t gz_method;
uint8_t flags;
//uint32_t mtime; - unused fields
//uint8_t xtra_flags;
//uint8_t os_flags;
} formatted; /* packed */
uint32_t mtime;
uint8_t xtra_flags_UNUSED;
uint8_t os_flags_UNUSED;
} __attribute__((packed)) formatted;
} header;
struct BUG_header {
char BUG_header[sizeof(header) == 8 ? 1 : -1];
};
/*
* Rewind bytebuffer. We use the beginning because the header has 8
@@ -1167,6 +1169,9 @@ static int check_header_gzip(STATE_PARAM_ONLY)
}
}
if (info)
info->mtime = SWAP_LE32(header.formatted.mtime);
/* Read the header checksum */
if (header.formatted.flags & 0x02) {
if (!top_up(PASS_STATE 2))
@@ -1176,11 +1181,11 @@ static int check_header_gzip(STATE_PARAM_ONLY)
return 1;
}
USE_DESKTOP(long long) int FAST_FUNC
unpack_gz_stream(int in, int out)
IF_DESKTOP(long long) int FAST_FUNC
unpack_gz_stream_with_info(int in, int out, unpack_info_t *info)
{
uint32_t v32;
USE_DESKTOP(long long) int n;
IF_DESKTOP(long long) int n;
DECLARE_STATE;
n = 0;
@@ -1192,7 +1197,7 @@ unpack_gz_stream(int in, int out)
gunzip_src_fd = in;
again:
if (!check_header_gzip(PASS_STATE_ONLY)) {
if (!check_header_gzip(PASS_STATE info)) {
bb_error_msg("corrupted data");
n = -1;
goto ret;
@@ -1239,3 +1244,9 @@ unpack_gz_stream(int in, int out)
DEALLOC_STATE;
return n;
}
IF_DESKTOP(long long) int FAST_FUNC
unpack_gz_stream(int in, int out)
{
return unpack_gz_stream_with_info(in, out, NULL);
}
+2 -1
View File
@@ -27,6 +27,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
#define hardlinks_to_create (*(hardlinks_t **)(&archive_handle->ah_priv[0]))
#define created_hardlinks (*(hardlinks_t **)(&archive_handle->ah_priv[1]))
#define block_count (archive_handle->ah_priv[2])
// if (!archive_handle->ah_priv_inited) {
// archive_handle->ah_priv_inited = 1;
// hardlinks_to_create = NULL;
@@ -76,7 +77,7 @@ char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
/* Always round up. ">> 9" divides by 512 */
printf("%"OFF_FMT"u blocks\n", (archive_handle->offset + 511) >> 9);
block_count = (void*)(ptrdiff_t) ((archive_handle->offset + 511) >> 9);
goto create_hardlinks;
}
+85 -10
View File
@@ -14,6 +14,74 @@
#include "libbb.h"
#include "unarchive.h"
/*
* GNU tar uses "base-256 encoding" for very large numbers (>8 billion).
* Encoding is binary, with highest bit always set as a marker
* and sign in next-highest bit:
* 80 00 .. 00 - zero
* bf ff .. ff - largest positive number
* ff ff .. ff - minus 1
* c0 00 .. 00 - smallest negative number
*
* We expect it only in size field, where negative numbers don't make sense.
*/
static off_t getBase256_len12(const char *str)
{
off_t value;
int len;
/* if (*str & 0x40) error; - caller prevents this */
if (sizeof(off_t) >= 12) {
/* Probably 128-bit (16 byte) off_t. Can be optimized. */
len = 12;
value = *str++ & 0x3f;
while (--len)
value = (value << 8) + (unsigned char) *str++;
return value;
}
#ifdef CHECK_FOR_OVERFLOW
/* Can be optimized to eat 32-bit chunks */
char c = *str++ & 0x3f;
len = 12;
while (1) {
if (c)
bb_error_msg_and_die("overflow in base-256 encoded file size");
if (--len == sizeof(off_t))
break;
c = *str++;
}
#else
str += (12 - sizeof(off_t));
#endif
/* Now str points to sizeof(off_t) least significant bytes.
*
* Example of tar file with 8914993153 (0x213600001) byte file.
* Field starts at offset 7c:
* 00070 30 30 30 00 30 30 30 30 30 30 30 00 80 00 00 00 |000.0000000.....|
* 00080 00 00 00 02 13 60 00 01 31 31 31 32 30 33 33 36 |.....`..11120336|
*
* str is at offset 80 or 84 now (64-bit or 32-bit off_t).
* We (ab)use the fact that value happens to be aligned,
* and fetch it in one go:
*/
if (sizeof(off_t) == 8) {
value = *(off_t*)str;
value = SWAP_BE64(value);
} else if (sizeof(off_t) == 4) {
value = *(off_t*)str;
value = SWAP_BE32(value);
} else {
value = 0;
len = sizeof(off_t);
while (--len)
value = (value << 8) + (unsigned char) *str++;
}
return value;
}
/* NB: _DESTROYS_ str[len] character! */
static unsigned long long getOctal(char *str, int len)
{
@@ -76,8 +144,8 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
// 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_FEATURE_TAR_GNU_EXTENSIONS(p_longname = NULL;)
// IF_FEATURE_TAR_GNU_EXTENSIONS(p_linkname = NULL;)
// }
if (sizeof(tar) != 512)
@@ -91,7 +159,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
again_after_align:
#if ENABLE_DESKTOP
#if ENABLE_DESKTOP || ENABLE_FEATURE_TAR_AUTODETECT
/* to prevent misdetection of bz2 sig */
*(uint32_t*)(&tar) = 0;
i = full_read(archive_handle->src_fd, &tar, 512);
@@ -108,7 +176,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
bb_error_msg_and_die("short read");
}
if (i != 512) {
USE_FEATURE_TAR_AUTODETECT(goto autodetect;)
IF_FEATURE_TAR_AUTODETECT(goto autodetect;)
goto short_read;
}
@@ -142,7 +210,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
#if ENABLE_FEATURE_TAR_AUTODETECT
char FAST_FUNC (*get_header_ptr)(archive_handle_t *);
USE_DESKTOP(autodetect:)
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().
@@ -197,14 +265,14 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
sum = strtoul(tar.chksum, &cp, 8);
if ((*cp && *cp != ' ')
|| (sum_u != sum USE_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum))
|| (sum_u != sum IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum))
) {
bb_error_msg_and_die("invalid tar header checksum");
}
#else
/* This field does not need special treatment (getOctal) */
sum = xstrtoul(tar.chksum, 8);
if (sum_u != sum USE_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum)) {
if (sum_u != sum IF_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum)) {
bb_error_msg_and_die("invalid tar header checksum");
}
#endif
@@ -233,8 +301,15 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
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);
/* mtime: rudimentally handle GNU tar's "base256 encoding"
* People report tarballs with NEGATIVE unix times encoded that way */
file_header->mtime = (tar.mtime[0] & 0x80) /* base256? */
? 0 /* bogus */
: GET_OCTAL(tar.mtime);
/* size: handle GNU tar's "base256 encoding" */
file_header->size = (tar.size[0] & 0xc0) == 0x80 /* positive base256? */
? getBase256_len12(tar.size)
: GET_OCTAL(tar.size);
file_header->gid = GET_OCTAL(tar.gid);
file_header->uid = GET_OCTAL(tar.uid);
/* Set bits 0-11 of the files mode */
@@ -285,7 +360,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
file_header->mode |= S_IFBLK;
goto size0;
case '5':
USE_FEATURE_TAR_OLDGNU_COMPATIBILITY(set_dir:)
IF_FEATURE_TAR_OLDGNU_COMPATIBILITY(set_dir:)
file_header->mode |= S_IFDIR;
goto size0;
case '6':
+2 -2
View File
@@ -24,11 +24,11 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
snprintf(gid, sizeof(gid), "%u", (unsigned)file_header->gid);
group = gid;
}
printf("%s %s/%s %9u %4u-%02u-%02u %02u:%02u:%02u %s",
printf("%s %s/%s %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
bb_mode_string(file_header->mode),
user,
group,
(unsigned int) file_header->size,
file_header->size,
1900 + mtime->tm_year,
1 + mtime->tm_mon,
mtime->tm_mday,
+2 -2
View File
@@ -12,7 +12,7 @@
* in include/unarchive.h. On NOMMU, transformer is removed.
*/
void FAST_FUNC open_transformer(int fd,
USE_DESKTOP(long long) int FAST_FUNC (*transformer)(int src_fd, int dst_fd),
IF_DESKTOP(long long) int FAST_FUNC (*transformer)(int src_fd, int dst_fd),
const char *transform_prog)
{
struct fd_pair fd_pipe;
@@ -52,7 +52,7 @@ void FAST_FUNC open_transformer(int fd,
argv[2] = (char*)"-";
argv[3] = NULL;
BB_EXECVP(transform_prog, argv);
bb_perror_msg_and_die("can't exec %s", transform_prog);
bb_perror_msg_and_die("can't execute '%s'", transform_prog);
}
#endif
/* notreached */
+35
View File
@@ -0,0 +1,35 @@
/* LZO1X-1 compression
This file is part of the LZO real-time data compression library.
Copyright (C) 1996..2008 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
Markus F.X.J. Oberhumer <markus@oberhumer.com>
http://www.oberhumer.com/opensource/lzo/
The LZO library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the LZO library; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "libbb.h"
#include "liblzo.h"
#define D_BITS 14
#define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
#define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
#define DO_COMPRESS lzo1x_1_compress
#include "lzo1x_c.c"
+35
View File
@@ -0,0 +1,35 @@
/* LZO1X-1(15) compression
This file is part of the LZO real-time data compression library.
Copyright (C) 1996..2008 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
Markus F.X.J. Oberhumer <markus@oberhumer.com>
http://www.oberhumer.com/opensource/lzo/
The LZO library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the LZO library; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "libbb.h"
#include "liblzo.h"
#define D_BITS 15
#define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
#define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
#define DO_COMPRESS lzo1x_1_15_compress
#include "lzo1x_c.c"
+920
View File
@@ -0,0 +1,920 @@
/* lzo1x_9x.c -- implementation of the LZO1X-999 compression algorithm
This file is part of the LZO real-time data compression library.
Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
The LZO library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the LZO library; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Markus F.X.J. Oberhumer
<markus@oberhumer.com>
http://www.oberhumer.com/opensource/lzo/
*/
#include "libbb.h"
/* The following is probably only safe on Intel-compatible processors ... */
#define LZO_UNALIGNED_OK_2
#define LZO_UNALIGNED_OK_4
#include "liblzo.h"
#define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
#define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
#define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
/***********************************************************************
//
************************************************************************/
#define SWD_N M4_MAX_OFFSET /* size of ring buffer */
#define SWD_F 2048 /* upper limit for match length */
#define SWD_BEST_OFF (LZO_MAX3(M2_MAX_LEN, M3_MAX_LEN, M4_MAX_LEN) + 1)
typedef struct {
int init;
unsigned look; /* bytes in lookahead buffer */
unsigned m_len;
unsigned m_off;
const uint8_t *bp;
const uint8_t *ip;
const uint8_t *in;
const uint8_t *in_end;
uint8_t *out;
unsigned r1_lit;
} lzo1x_999_t;
#define getbyte(c) ((c).ip < (c).in_end ? *((c).ip)++ : (-1))
/* lzo_swd.c -- sliding window dictionary */
/***********************************************************************
//
************************************************************************/
#define SWD_UINT_MAX USHRT_MAX
#ifndef SWD_HSIZE
# define SWD_HSIZE 16384
#endif
#ifndef SWD_MAX_CHAIN
# define SWD_MAX_CHAIN 2048
#endif
#define HEAD3(b, p) \
( ((0x9f5f * ((((b[p]<<5)^b[p+1])<<5) ^ b[p+2])) >> 5) & (SWD_HSIZE-1) )
#if defined(LZO_UNALIGNED_OK_2)
# define HEAD2(b,p) (* (uint16_t *) &(b[p]))
#else
# define HEAD2(b,p) (b[p] ^ ((unsigned)b[p+1]<<8))
#endif
#define NIL2 SWD_UINT_MAX
typedef struct lzo_swd {
/* public - "built-in" */
/* public - configuration */
unsigned max_chain;
int use_best_off;
/* public - output */
unsigned m_len;
unsigned m_off;
unsigned look;
int b_char;
#if defined(SWD_BEST_OFF)
unsigned best_off[SWD_BEST_OFF];
#endif
/* semi public */
lzo1x_999_t *c;
unsigned m_pos;
#if defined(SWD_BEST_OFF)
unsigned best_pos[SWD_BEST_OFF];
#endif
/* private */
unsigned ip; /* input pointer (lookahead) */
unsigned bp; /* buffer pointer */
unsigned rp; /* remove pointer */
unsigned node_count;
unsigned first_rp;
uint8_t b[SWD_N + SWD_F];
uint8_t b_wrap[SWD_F]; /* must follow b */
uint16_t head3[SWD_HSIZE];
uint16_t succ3[SWD_N + SWD_F];
uint16_t best3[SWD_N + SWD_F];
uint16_t llen3[SWD_HSIZE];
#ifdef HEAD2
uint16_t head2[65536L];
#endif
} lzo_swd_t, *lzo_swd_p;
#define SIZEOF_LZO_SWD_T (sizeof(lzo_swd_t))
/* Access macro for head3.
* head3[key] may be uninitialized, but then its value will never be used.
*/
#define s_get_head3(s,key) s->head3[key]
/***********************************************************************
//
************************************************************************/
#define B_SIZE (SWD_N + SWD_F)
static int swd_init(lzo_swd_p s)
{
/* defaults */
s->node_count = SWD_N;
memset(s->llen3, 0, sizeof(s->llen3[0]) * (unsigned)SWD_HSIZE);
#ifdef HEAD2
memset(s->head2, 0xff, sizeof(s->head2[0]) * 65536L);
assert(s->head2[0] == NIL2);
#endif
s->ip = 0;
s->bp = s->ip;
s->first_rp = s->ip;
assert(s->ip + SWD_F <= B_SIZE);
s->look = (unsigned) (s->c->in_end - s->c->ip);
if (s->look > 0) {
if (s->look > SWD_F)
s->look = SWD_F;
memcpy(&s->b[s->ip],s->c->ip,s->look);
s->c->ip += s->look;
s->ip += s->look;
}
if (s->ip == B_SIZE)
s->ip = 0;
s->rp = s->first_rp;
if (s->rp >= s->node_count)
s->rp -= s->node_count;
else
s->rp += B_SIZE - s->node_count;
return LZO_E_OK;
}
#define swd_pos2off(s,pos) \
(s->bp > (pos) ? s->bp - (pos) : B_SIZE - ((pos) - s->bp))
/***********************************************************************
//
************************************************************************/
static void swd_getbyte(lzo_swd_p s)
{
int c;
if ((c = getbyte(*(s->c))) < 0) {
if (s->look > 0)
--s->look;
} else {
s->b[s->ip] = c;
if (s->ip < SWD_F)
s->b_wrap[s->ip] = c;
}
if (++s->ip == B_SIZE)
s->ip = 0;
if (++s->bp == B_SIZE)
s->bp = 0;
if (++s->rp == B_SIZE)
s->rp = 0;
}
/***********************************************************************
// remove node from lists
************************************************************************/
static void swd_remove_node(lzo_swd_p s, unsigned node)
{
if (s->node_count == 0) {
unsigned key;
key = HEAD3(s->b,node);
assert(s->llen3[key] > 0);
--s->llen3[key];
#ifdef HEAD2
key = HEAD2(s->b,node);
assert(s->head2[key] != NIL2);
if ((unsigned) s->head2[key] == node)
s->head2[key] = NIL2;
#endif
} else
--s->node_count;
}
/***********************************************************************
//
************************************************************************/
static void swd_accept(lzo_swd_p s, unsigned n)
{
assert(n <= s->look);
while (n--) {
unsigned key;
swd_remove_node(s,s->rp);
/* add bp into HEAD3 */
key = HEAD3(s->b,s->bp);
s->succ3[s->bp] = s_get_head3(s,key);
s->head3[key] = s->bp;
s->best3[s->bp] = SWD_F + 1;
s->llen3[key]++;
assert(s->llen3[key] <= SWD_N);
#ifdef HEAD2
/* add bp into HEAD2 */
key = HEAD2(s->b,s->bp);
s->head2[key] = s->bp;
#endif
swd_getbyte(s);
}
}
/***********************************************************************
//
************************************************************************/
static void swd_search(lzo_swd_p s, unsigned node, unsigned cnt)
{
const uint8_t *p1;
const uint8_t *p2;
const uint8_t *px;
unsigned m_len = s->m_len;
const uint8_t *b = s->b;
const uint8_t *bp = s->b + s->bp;
const uint8_t *bx = s->b + s->bp + s->look;
unsigned char scan_end1;
assert(s->m_len > 0);
scan_end1 = bp[m_len - 1];
for ( ; cnt-- > 0; node = s->succ3[node]) {
p1 = bp;
p2 = b + node;
px = bx;
assert(m_len < s->look);
if (p2[m_len - 1] == scan_end1 &&
p2[m_len] == p1[m_len] &&
p2[0] == p1[0] &&
p2[1] == p1[1]) {
unsigned i;
assert(lzo_memcmp(bp,&b[node],3) == 0);
p1 += 2; p2 += 2;
do {} while (++p1 < px && *p1 == *++p2);
i = p1-bp;
assert(lzo_memcmp(bp,&b[node],i) == 0);
#if defined(SWD_BEST_OFF)
if (i < SWD_BEST_OFF) {
if (s->best_pos[i] == 0)
s->best_pos[i] = node + 1;
}
#endif
if (i > m_len) {
s->m_len = m_len = i;
s->m_pos = node;
if (m_len == s->look)
return;
if (m_len >= SWD_F)
return;
if (m_len > (unsigned) s->best3[node])
return;
scan_end1 = bp[m_len - 1];
}
}
}
}
/***********************************************************************
//
************************************************************************/
#ifdef HEAD2
static int swd_search2(lzo_swd_p s)
{
unsigned key;
assert(s->look >= 2);
assert(s->m_len > 0);
key = s->head2[ HEAD2(s->b,s->bp) ];
if (key == NIL2)
return 0;
assert(lzo_memcmp(&s->b[s->bp],&s->b[key],2) == 0);
#if defined(SWD_BEST_OFF)
if (s->best_pos[2] == 0)
s->best_pos[2] = key + 1;
#endif
if (s->m_len < 2) {
s->m_len = 2;
s->m_pos = key;
}
return 1;
}
#endif
/***********************************************************************
//
************************************************************************/
static void swd_findbest(lzo_swd_p s)
{
unsigned key;
unsigned cnt, node;
unsigned len;
assert(s->m_len > 0);
/* get current head, add bp into HEAD3 */
key = HEAD3(s->b,s->bp);
node = s->succ3[s->bp] = s_get_head3(s,key);
cnt = s->llen3[key]++;
assert(s->llen3[key] <= SWD_N + SWD_F);
if (cnt > s->max_chain)
cnt = s->max_chain;
s->head3[key] = s->bp;
s->b_char = s->b[s->bp];
len = s->m_len;
if (s->m_len >= s->look) {
if (s->look == 0)
s->b_char = -1;
s->m_off = 0;
s->best3[s->bp] = SWD_F + 1;
} else {
#ifdef HEAD2
if (swd_search2(s))
#endif
if (s->look >= 3)
swd_search(s,node,cnt);
if (s->m_len > len)
s->m_off = swd_pos2off(s,s->m_pos);
s->best3[s->bp] = s->m_len;
#if defined(SWD_BEST_OFF)
if (s->use_best_off) {
int i;
for (i = 2; i < SWD_BEST_OFF; i++)
if (s->best_pos[i] > 0)
s->best_off[i] = swd_pos2off(s,s->best_pos[i]-1);
else
s->best_off[i] = 0;
}
#endif
}
swd_remove_node(s,s->rp);
#ifdef HEAD2
/* add bp into HEAD2 */
key = HEAD2(s->b,s->bp);
s->head2[key] = s->bp;
#endif
}
#undef HEAD3
#undef HEAD2
#undef s_get_head3
/***********************************************************************
//
************************************************************************/
static int init_match(lzo1x_999_t *c, lzo_swd_p s, uint32_t use_best_off)
{
int r;
assert(!c->init);
c->init = 1;
s->c = c;
r = swd_init(s);
if (r != 0)
return r;
s->use_best_off = use_best_off;
return r;
}
/***********************************************************************
//
************************************************************************/
static int find_match(lzo1x_999_t *c, lzo_swd_p s,
unsigned this_len, unsigned skip)
{
assert(c->init);
if (skip > 0) {
assert(this_len >= skip);
swd_accept(s, this_len - skip);
} else {
assert(this_len <= 1);
}
s->m_len = 1;
s->m_len = 1;
#ifdef SWD_BEST_OFF
if (s->use_best_off)
memset(s->best_pos,0,sizeof(s->best_pos));
#endif
swd_findbest(s);
c->m_len = s->m_len;
c->m_off = s->m_off;
swd_getbyte(s);
if (s->b_char < 0) {
c->look = 0;
c->m_len = 0;
} else {
c->look = s->look + 1;
}
c->bp = c->ip - c->look;
return LZO_E_OK;
}
/* this is a public functions, but there is no prototype in a header file */
static int lzo1x_999_compress_internal(const uint8_t *in , unsigned in_len,
uint8_t *out, unsigned *out_len,
void *wrkmem,
unsigned good_length,
unsigned max_lazy,
unsigned max_chain,
uint32_t use_best_off);
/***********************************************************************
//
************************************************************************/
static uint8_t *code_match(lzo1x_999_t *c,
uint8_t *op, unsigned m_len, unsigned m_off)
{
assert(op > c->out);
if (m_len == 2) {
assert(m_off <= M1_MAX_OFFSET);
assert(c->r1_lit > 0); assert(c->r1_lit < 4);
m_off -= 1;
*op++ = M1_MARKER | ((m_off & 3) << 2);
*op++ = m_off >> 2;
} else if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET) {
assert(m_len >= 3);
m_off -= 1;
*op++ = ((m_len - 1) << 5) | ((m_off & 7) << 2);
*op++ = m_off >> 3;
assert(op[-2] >= M2_MARKER);
} else if (m_len == M2_MIN_LEN && m_off <= MX_MAX_OFFSET && c->r1_lit >= 4) {
assert(m_len == 3);
assert(m_off > M2_MAX_OFFSET);
m_off -= 1 + M2_MAX_OFFSET;
*op++ = M1_MARKER | ((m_off & 3) << 2);
*op++ = m_off >> 2;
} else if (m_off <= M3_MAX_OFFSET) {
assert(m_len >= 3);
m_off -= 1;
if (m_len <= M3_MAX_LEN)
*op++ = M3_MARKER | (m_len - 2);
else {
m_len -= M3_MAX_LEN;
*op++ = M3_MARKER | 0;
while (m_len > 255)
{
m_len -= 255;
*op++ = 0;
}
assert(m_len > 0);
*op++ = m_len;
}
*op++ = m_off << 2;
*op++ = m_off >> 6;
} else {
unsigned k;
assert(m_len >= 3);
assert(m_off > 0x4000); assert(m_off <= 0xbfff);
m_off -= 0x4000;
k = (m_off & 0x4000) >> 11;
if (m_len <= M4_MAX_LEN)
*op++ = M4_MARKER | k | (m_len - 2);
else {
m_len -= M4_MAX_LEN;
*op++ = M4_MARKER | k | 0;
while (m_len > 255)
{
m_len -= 255;
*op++ = 0;
}
assert(m_len > 0);
*op++ = m_len;
}
*op++ = m_off << 2;
*op++ = m_off >> 6;
}
return op;
}
static uint8_t *STORE_RUN(lzo1x_999_t *c, uint8_t *op,
const uint8_t *ii, unsigned t)
{
if (op == c->out && t <= 238) {
*op++ = 17 + t;
} else if (t <= 3) {
op[-2] |= t;
} else if (t <= 18) {
*op++ = t - 3;
} else {
unsigned tt = t - 18;
*op++ = 0;
while (tt > 255) {
tt -= 255;
*op++ = 0;
}
assert(tt > 0);
*op++ = tt;
}
do *op++ = *ii++; while (--t > 0);
return op;
}
static uint8_t *code_run(lzo1x_999_t *c, uint8_t *op, const uint8_t *ii,
unsigned lit)
{
if (lit > 0) {
assert(m_len >= 2);
op = STORE_RUN(c,op,ii,lit);
} else {
assert(m_len >= 3);
}
c->r1_lit = lit;
return op;
}
/***********************************************************************
//
************************************************************************/
static int len_of_coded_match(unsigned m_len, unsigned m_off, unsigned lit)
{
int n = 4;
if (m_len < 2)
return -1;
if (m_len == 2)
return (m_off <= M1_MAX_OFFSET && lit > 0 && lit < 4) ? 2 : -1;
if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET)
return 2;
if (m_len == M2_MIN_LEN && m_off <= MX_MAX_OFFSET && lit >= 4)
return 2;
if (m_off <= M3_MAX_OFFSET) {
if (m_len <= M3_MAX_LEN)
return 3;
m_len -= M3_MAX_LEN;
} else if (m_off <= M4_MAX_OFFSET) {
if (m_len <= M4_MAX_LEN)
return 3;
m_len -= M4_MAX_LEN;
} else
return -1;
while (m_len > 255) {
m_len -= 255;
n++;
}
return n;
}
static int min_gain(unsigned ahead, unsigned lit1,
unsigned lit2, int l1, int l2, int l3)
{
int lazy_match_min_gain = 0;
assert (ahead >= 1);
lazy_match_min_gain += ahead;
if (lit1 <= 3)
lazy_match_min_gain += (lit2 <= 3) ? 0 : 2;
else if (lit1 <= 18)
lazy_match_min_gain += (lit2 <= 18) ? 0 : 1;
lazy_match_min_gain += (l2 - l1) * 2;
if (l3 > 0)
lazy_match_min_gain -= (ahead - l3) * 2;
if (lazy_match_min_gain < 0)
lazy_match_min_gain = 0;
return lazy_match_min_gain;
}
/***********************************************************************
//
************************************************************************/
#if defined(SWD_BEST_OFF)
static void better_match(const lzo_swd_p swd,
unsigned *m_len, unsigned *m_off)
{
if (*m_len <= M2_MIN_LEN)
return;
if (*m_off <= M2_MAX_OFFSET)
return;
/* M3/M4 -> M2 */
if (*m_off > M2_MAX_OFFSET &&
*m_len >= M2_MIN_LEN + 1 && *m_len <= M2_MAX_LEN + 1 &&
swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= M2_MAX_OFFSET)
{
*m_len = *m_len - 1;
*m_off = swd->best_off[*m_len];
return;
}
/* M4 -> M2 */
if (*m_off > M3_MAX_OFFSET &&
*m_len >= M4_MAX_LEN + 1 && *m_len <= M2_MAX_LEN + 2 &&
swd->best_off[*m_len-2] && swd->best_off[*m_len-2] <= M2_MAX_OFFSET)
{
*m_len = *m_len - 2;
*m_off = swd->best_off[*m_len];
return;
}
/* M4 -> M3 */
if (*m_off > M3_MAX_OFFSET &&
*m_len >= M4_MAX_LEN + 1 && *m_len <= M3_MAX_LEN + 1 &&
swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= M3_MAX_OFFSET)
{
*m_len = *m_len - 1;
*m_off = swd->best_off[*m_len];
}
}
#endif
/***********************************************************************
//
************************************************************************/
static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len,
uint8_t *out, unsigned *out_len,
void *wrkmem,
unsigned good_length,
unsigned max_lazy,
unsigned max_chain,
uint32_t use_best_off)
{
uint8_t *op;
const uint8_t *ii;
unsigned lit;
unsigned m_len, m_off;
lzo1x_999_t cc;
lzo1x_999_t * const c = &cc;
lzo_swd_p const swd = (lzo_swd_p) wrkmem;
int r;
c->init = 0;
c->ip = c->in = in;
c->in_end = in + in_len;
c->out = out;
op = out;
ii = c->ip; /* point to start of literal run */
lit = 0;
c->r1_lit = 0;
r = init_match(c, swd, use_best_off);
if (r != 0)
return r;
swd->max_chain = max_chain;
r = find_match(c, swd, 0, 0);
if (r != 0)
return r;
while (c->look > 0) {
unsigned ahead;
unsigned max_ahead;
int l1, l2, l3;
m_len = c->m_len;
m_off = c->m_off;
assert(c->bp == c->ip - c->look);
assert(c->bp >= in);
if (lit == 0)
ii = c->bp;
assert(ii + lit == c->bp);
assert(swd->b_char == *(c->bp));
if ( m_len < 2 ||
(m_len == 2 && (m_off > M1_MAX_OFFSET || lit == 0 || lit >= 4)) ||
/* Do not accept this match for compressed-data compatibility
* with LZO v1.01 and before
* [ might be a problem for decompress() and optimize() ]
*/
(m_len == 2 && op == out) ||
(op == out && lit == 0))
{
/* a literal */
m_len = 0;
}
else if (m_len == M2_MIN_LEN) {
/* compression ratio improves if we code a literal in some cases */
if (m_off > MX_MAX_OFFSET && lit >= 4)
m_len = 0;
}
if (m_len == 0) {
/* a literal */
lit++;
swd->max_chain = max_chain;
r = find_match(c,swd,1,0);
assert(r == 0);
continue;
}
/* a match */
#if defined(SWD_BEST_OFF)
if (swd->use_best_off)
better_match(swd,&m_len,&m_off);
#endif
/* shall we try a lazy match ? */
ahead = 0;
if (m_len >= max_lazy) {
/* no */
l1 = 0;
max_ahead = 0;
} else {
/* yes, try a lazy match */
l1 = len_of_coded_match(m_len,m_off,lit);
assert(l1 > 0);
max_ahead = LZO_MIN(2, (unsigned)l1 - 1);
}
while (ahead < max_ahead && c->look > m_len) {
int lazy_match_min_gain;
if (m_len >= good_length)
swd->max_chain = max_chain >> 2;
else
swd->max_chain = max_chain;
r = find_match(c,swd,1,0);
ahead++;
assert(r == 0);
assert(c->look > 0);
assert(ii + lit + ahead == c->bp);
if (c->m_len < m_len)
continue;
if (c->m_len == m_len && c->m_off >= m_off)
continue;
#if defined(SWD_BEST_OFF)
if (swd->use_best_off)
better_match(swd,&c->m_len,&c->m_off);
#endif
l2 = len_of_coded_match(c->m_len,c->m_off,lit+ahead);
if (l2 < 0)
continue;
/* compressed-data compatibility [see above] */
l3 = (op == out) ? -1 : len_of_coded_match(ahead,m_off,lit);
lazy_match_min_gain = min_gain(ahead,lit,lit+ahead,l1,l2,l3);
if (c->m_len >= m_len + lazy_match_min_gain) {
if (l3 > 0) {
/* code previous run */
op = code_run(c,op,ii,lit);
lit = 0;
/* code shortened match */
op = code_match(c,op,ahead,m_off);
} else {
lit += ahead;
assert(ii + lit == c->bp);
}
goto lazy_match_done;
}
}
assert(ii + lit + ahead == c->bp);
/* 1 - code run */
op = code_run(c,op,ii,lit);
lit = 0;
/* 2 - code match */
op = code_match(c,op,m_len,m_off);
swd->max_chain = max_chain;
r = find_match(c,swd,m_len,1+ahead);
assert(r == 0);
lazy_match_done: ;
}
/* store final run */
if (lit > 0)
op = STORE_RUN(c,op,ii,lit);
#if defined(LZO_EOF_CODE)
*op++ = M4_MARKER | 1;
*op++ = 0;
*op++ = 0;
#endif
*out_len = op - out;
return LZO_E_OK;
}
/***********************************************************************
//
************************************************************************/
int lzo1x_999_compress_level(const uint8_t *in, unsigned in_len,
uint8_t *out, unsigned *out_len,
void *wrkmem,
int compression_level)
{
static const struct {
uint16_t good_length;
uint16_t max_lazy;
uint16_t max_chain;
uint16_t use_best_off;
} c[3] = {
{ 8, 32, 256, 0 },
{ 32, 128, 2048, 1 },
{ SWD_F, SWD_F, 4096, 1 } /* max. compression */
};
if (compression_level < 7 || compression_level > 9)
return LZO_E_ERROR;
compression_level -= 7;
return lzo1x_999_compress_internal(in, in_len, out, out_len, wrkmem,
c[compression_level].good_length,
c[compression_level].max_lazy,
c[compression_level].max_chain,
c[compression_level].use_best_off);
}
+296
View File
@@ -0,0 +1,296 @@
/* implementation of the LZO1[XY]-1 compression algorithm
This file is part of the LZO real-time data compression library.
Copyright (C) 1996..2008 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
Markus F.X.J. Oberhumer <markus@oberhumer.com>
http://www.oberhumer.com/opensource/lzo/
The LZO library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the LZO library; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/***********************************************************************
// compress a block of data.
************************************************************************/
static NOINLINE unsigned
do_compress(const uint8_t* in, unsigned in_len,
uint8_t* out, unsigned* out_len,
void* wrkmem)
{
register const uint8_t* ip;
uint8_t* op;
const uint8_t* const in_end = in + in_len;
const uint8_t* const ip_end = in + in_len - M2_MAX_LEN - 5;
const uint8_t* ii;
const void* *const dict = (const void**) wrkmem;
op = out;
ip = in;
ii = ip;
ip += 4;
for (;;) {
register const uint8_t* m_pos;
unsigned m_off;
unsigned m_len;
unsigned dindex;
D_INDEX1(dindex,ip);
GINDEX(m_pos,m_off,dict,dindex,in);
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
goto literal;
#if 1
if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
goto try_match;
D_INDEX2(dindex,ip);
#endif
GINDEX(m_pos,m_off,dict,dindex,in);
if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
goto literal;
if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
goto try_match;
goto literal;
try_match:
#if 1 && defined(LZO_UNALIGNED_OK_2)
if (* (const lzo_ushortp) m_pos != * (const lzo_ushortp) ip)
#else
if (m_pos[0] != ip[0] || m_pos[1] != ip[1])
#endif
{
} else {
if (m_pos[2] == ip[2]) {
#if 0
if (m_off <= M2_MAX_OFFSET)
goto match;
if (lit <= 3)
goto match;
if (lit == 3) { /* better compression, but slower */
assert(op - 2 > out); op[-2] |= (uint8_t)(3);
*op++ = *ii++; *op++ = *ii++; *op++ = *ii++;
goto code_match;
}
if (m_pos[3] == ip[3])
#endif
goto match;
}
else {
/* still need a better way for finding M1 matches */
#if 0
/* a M1 match */
#if 0
if (m_off <= M1_MAX_OFFSET && lit > 0 && lit <= 3)
#else
if (m_off <= M1_MAX_OFFSET && lit == 3)
#endif
{
register unsigned t;
t = lit;
assert(op - 2 > out); op[-2] |= (uint8_t)(t);
do *op++ = *ii++; while (--t > 0);
assert(ii == ip);
m_off -= 1;
*op++ = (uint8_t)(M1_MARKER | ((m_off & 3) << 2));
*op++ = (uint8_t)(m_off >> 2);
ip += 2;
goto match_done;
}
#endif
}
}
/* a literal */
literal:
UPDATE_I(dict, 0, dindex, ip, in);
++ip;
if (ip >= ip_end)
break;
continue;
/* a match */
match:
UPDATE_I(dict, 0, dindex, ip, in);
/* store current literal run */
if (pd(ip, ii) > 0) {
register unsigned t = pd(ip, ii);
if (t <= 3) {
assert(op - 2 > out);
op[-2] |= (uint8_t)(t);
}
else if (t <= 18)
*op++ = (uint8_t)(t - 3);
else {
register unsigned tt = t - 18;
*op++ = 0;
while (tt > 255) {
tt -= 255;
*op++ = 0;
}
assert(tt > 0);
*op++ = (uint8_t)(tt);
}
do *op++ = *ii++; while (--t > 0);
}
/* code the match */
assert(ii == ip);
ip += 3;
if (m_pos[3] != *ip++ || m_pos[4] != *ip++ || m_pos[5] != *ip++
|| m_pos[6] != *ip++ || m_pos[7] != *ip++ || m_pos[8] != *ip++
#ifdef LZO1Y
|| m_pos[ 9] != *ip++ || m_pos[10] != *ip++ || m_pos[11] != *ip++
|| m_pos[12] != *ip++ || m_pos[13] != *ip++ || m_pos[14] != *ip++
#endif
) {
--ip;
m_len = pd(ip, ii);
assert(m_len >= 3);
assert(m_len <= M2_MAX_LEN);
if (m_off <= M2_MAX_OFFSET) {
m_off -= 1;
#if defined(LZO1X)
*op++ = (uint8_t)(((m_len - 1) << 5) | ((m_off & 7) << 2));
*op++ = (uint8_t)(m_off >> 3);
#elif defined(LZO1Y)
*op++ = (uint8_t)(((m_len + 1) << 4) | ((m_off & 3) << 2));
*op++ = (uint8_t)(m_off >> 2);
#endif
}
else if (m_off <= M3_MAX_OFFSET) {
m_off -= 1;
*op++ = (uint8_t)(M3_MARKER | (m_len - 2));
goto m3_m4_offset;
} else {
#if defined(LZO1X)
m_off -= 0x4000;
assert(m_off > 0);
assert(m_off <= 0x7fff);
*op++ = (uint8_t)(M4_MARKER | ((m_off & 0x4000) >> 11) | (m_len - 2));
goto m3_m4_offset;
#elif defined(LZO1Y)
goto m4_match;
#endif
}
}
else {
{
const uint8_t* end = in_end;
const uint8_t* m = m_pos + M2_MAX_LEN + 1;
while (ip < end && *m == *ip)
m++, ip++;
m_len = pd(ip, ii);
}
assert(m_len > M2_MAX_LEN);
if (m_off <= M3_MAX_OFFSET) {
m_off -= 1;
if (m_len <= 33)
*op++ = (uint8_t)(M3_MARKER | (m_len - 2));
else {
m_len -= 33;
*op++ = M3_MARKER | 0;
goto m3_m4_len;
}
} else {
#if defined(LZO1Y)
m4_match:
#endif
m_off -= 0x4000;
assert(m_off > 0);
assert(m_off <= 0x7fff);
if (m_len <= M4_MAX_LEN)
*op++ = (uint8_t)(M4_MARKER | ((m_off & 0x4000) >> 11) | (m_len - 2));
else {
m_len -= M4_MAX_LEN;
*op++ = (uint8_t)(M4_MARKER | ((m_off & 0x4000) >> 11));
m3_m4_len:
while (m_len > 255) {
m_len -= 255;
*op++ = 0;
}
assert(m_len > 0);
*op++ = (uint8_t)(m_len);
}
}
m3_m4_offset:
*op++ = (uint8_t)((m_off & 63) << 2);
*op++ = (uint8_t)(m_off >> 6);
}
#if 0
match_done:
#endif
ii = ip;
if (ip >= ip_end)
break;
}
*out_len = pd(op, out);
return pd(in_end, ii);
}
/***********************************************************************
// public entry point
************************************************************************/
int DO_COMPRESS(const uint8_t* in, unsigned in_len,
uint8_t* out, unsigned* out_len,
void* wrkmem)
{
uint8_t* op = out;
unsigned t;
if (in_len <= M2_MAX_LEN + 5)
t = in_len;
else {
t = do_compress(in,in_len,op,out_len,wrkmem);
op += *out_len;
}
if (t > 0) {
const uint8_t* ii = in + in_len - t;
if (op == out && t <= 238)
*op++ = (uint8_t)(17 + t);
else if (t <= 3)
op[-2] |= (uint8_t)(t);
else if (t <= 18)
*op++ = (uint8_t)(t - 3);
else {
unsigned tt = t - 18;
*op++ = 0;
while (tt > 255) {
tt -= 255;
*op++ = 0;
}
assert(tt > 0);
*op++ = (uint8_t)(tt);
}
do *op++ = *ii++; while (--t > 0);
}
*op++ = M4_MARKER | 1;
*op++ = 0;
*op++ = 0;
*out_len = pd(op, out);
return 0; /*LZO_E_OK*/
}
+420
View File
@@ -0,0 +1,420 @@
/* implementation of the LZO1X decompression algorithm
This file is part of the LZO real-time data compression library.
Copyright (C) 1996..2008 Markus Franz Xaver Johannes Oberhumer
All Rights Reserved.
Markus F.X.J. Oberhumer <markus@oberhumer.com>
http://www.oberhumer.com/opensource/lzo/
The LZO library is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the LZO library; see the file COPYING.
If not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "libbb.h"
#include "liblzo.h"
/***********************************************************************
// decompress a block of data.
************************************************************************/
/* safe decompression with overrun testing */
int lzo1x_decompress_safe(const uint8_t* in, unsigned in_len,
uint8_t* out, unsigned* out_len,
void* wrkmem UNUSED_PARAM)
{
register uint8_t* op;
register const uint8_t* ip;
register unsigned t;
#if defined(COPY_DICT)
unsigned m_off;
const uint8_t* dict_end;
#else
register const uint8_t* m_pos = NULL; /* possibly not needed */
#endif
const uint8_t* const ip_end = in + in_len;
#if defined(HAVE_ANY_OP)
uint8_t* const op_end = out + *out_len;
#endif
#if defined(LZO1Z)
unsigned last_m_off = 0;
#endif
// LZO_UNUSED(wrkmem);
#if defined(COPY_DICT)
if (dict) {
if (dict_len > M4_MAX_OFFSET) {
dict += dict_len - M4_MAX_OFFSET;
dict_len = M4_MAX_OFFSET;
}
dict_end = dict + dict_len;
} else {
dict_len = 0;
dict_end = NULL;
}
#endif /* COPY_DICT */
*out_len = 0;
op = out;
ip = in;
if (*ip > 17) {
t = *ip++ - 17;
if (t < 4)
goto match_next;
assert(t > 0); NEED_OP(t); NEED_IP(t+1);
do *op++ = *ip++; while (--t > 0);
goto first_literal_run;
}
while (TEST_IP && TEST_OP) {
t = *ip++;
if (t >= 16)
goto match;
/* a literal run */
if (t == 0) {
NEED_IP(1);
while (*ip == 0) {
t += 255;
ip++;
NEED_IP(1);
}
t += 15 + *ip++;
}
/* copy literals */
assert(t > 0);
NEED_OP(t+3);
NEED_IP(t+4);
#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
# if !defined(LZO_UNALIGNED_OK_4)
if (PTR_ALIGNED2_4(op, ip))
# endif
{
COPY4(op, ip);
op += 4;
ip += 4;
if (--t > 0) {
if (t >= 4) {
do {
COPY4(op, ip);
op += 4;
ip += 4;
t -= 4;
} while (t >= 4);
if (t > 0)
do *op++ = *ip++; while (--t > 0);
} else {
do *op++ = *ip++; while (--t > 0);
}
}
}
# if !defined(LZO_UNALIGNED_OK_4)
else
# endif
#endif
#if !defined(LZO_UNALIGNED_OK_4)
{
*op++ = *ip++;
*op++ = *ip++;
*op++ = *ip++;
do *op++ = *ip++; while (--t > 0);
}
#endif
first_literal_run:
t = *ip++;
if (t >= 16)
goto match;
#if defined(COPY_DICT)
#if defined(LZO1Z)
m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
last_m_off = m_off;
#else
m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
#endif
NEED_OP(3);
t = 3; COPY_DICT(t,m_off)
#else /* !COPY_DICT */
#if defined(LZO1Z)
t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
m_pos = op - t;
last_m_off = t;
#else
m_pos = op - (1 + M2_MAX_OFFSET);
m_pos -= t >> 2;
m_pos -= *ip++ << 2;
#endif
TEST_LB(m_pos); NEED_OP(3);
*op++ = *m_pos++;
*op++ = *m_pos++;
*op++ = *m_pos;
#endif /* COPY_DICT */
goto match_done;
/* handle matches */
do {
match:
if (t >= 64) { /* a M2 match */
#if defined(COPY_DICT)
#if defined(LZO1X)
m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
t = (t >> 5) - 1;
#elif defined(LZO1Y)
m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
t = (t >> 4) - 3;
#elif defined(LZO1Z)
m_off = t & 0x1f;
if (m_off >= 0x1c)
m_off = last_m_off;
else {
m_off = 1 + (m_off << 6) + (*ip++ >> 2);
last_m_off = m_off;
}
t = (t >> 5) - 1;
#endif
#else /* !COPY_DICT */
#if defined(LZO1X)
m_pos = op - 1;
m_pos -= (t >> 2) & 7;
m_pos -= *ip++ << 3;
t = (t >> 5) - 1;
#elif defined(LZO1Y)
m_pos = op - 1;
m_pos -= (t >> 2) & 3;
m_pos -= *ip++ << 2;
t = (t >> 4) - 3;
#elif defined(LZO1Z)
{
unsigned off = t & 0x1f;
m_pos = op;
if (off >= 0x1c) {
assert(last_m_off > 0);
m_pos -= last_m_off;
} else {
off = 1 + (off << 6) + (*ip++ >> 2);
m_pos -= off;
last_m_off = off;
}
}
t = (t >> 5) - 1;
#endif
TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
goto copy_match;
#endif /* COPY_DICT */
}
else if (t >= 32) { /* a M3 match */
t &= 31;
if (t == 0) {
NEED_IP(1);
while (*ip == 0) {
t += 255;
ip++;
NEED_IP(1);
}
t += 31 + *ip++;
}
#if defined(COPY_DICT)
#if defined(LZO1Z)
m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
last_m_off = m_off;
#else
m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
#endif
#else /* !COPY_DICT */
#if defined(LZO1Z)
{
unsigned off = 1 + (ip[0] << 6) + (ip[1] >> 2);
m_pos = op - off;
last_m_off = off;
}
#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
m_pos = op - 1;
m_pos -= (* (const lzo_ushortp) ip) >> 2;
#else
m_pos = op - 1;
m_pos -= (ip[0] >> 2) + (ip[1] << 6);
#endif
#endif /* COPY_DICT */
ip += 2;
}
else if (t >= 16) { /* a M4 match */
#if defined(COPY_DICT)
m_off = (t & 8) << 11;
#else /* !COPY_DICT */
m_pos = op;
m_pos -= (t & 8) << 11;
#endif /* COPY_DICT */
t &= 7;
if (t == 0) {
NEED_IP(1);
while (*ip == 0) {
t += 255;
ip++;
NEED_IP(1);
}
t += 7 + *ip++;
}
#if defined(COPY_DICT)
#if defined(LZO1Z)
m_off += (ip[0] << 6) + (ip[1] >> 2);
#else
m_off += (ip[0] >> 2) + (ip[1] << 6);
#endif
ip += 2;
if (m_off == 0)
goto eof_found;
m_off += 0x4000;
#if defined(LZO1Z)
last_m_off = m_off;
#endif
#else /* !COPY_DICT */
#if defined(LZO1Z)
m_pos -= (ip[0] << 6) + (ip[1] >> 2);
#elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
m_pos -= (* (const lzo_ushortp) ip) >> 2;
#else
m_pos -= (ip[0] >> 2) + (ip[1] << 6);
#endif
ip += 2;
if (m_pos == op)
goto eof_found;
m_pos -= 0x4000;
#if defined(LZO1Z)
last_m_off = pd((const uint8_t*)op, m_pos);
#endif
#endif /* COPY_DICT */
}
else { /* a M1 match */
#if defined(COPY_DICT)
#if defined(LZO1Z)
m_off = 1 + (t << 6) + (*ip++ >> 2);
last_m_off = m_off;
#else
m_off = 1 + (t >> 2) + (*ip++ << 2);
#endif
NEED_OP(2);
t = 2; COPY_DICT(t,m_off)
#else /* !COPY_DICT */
#if defined(LZO1Z)
t = 1 + (t << 6) + (*ip++ >> 2);
m_pos = op - t;
last_m_off = t;
#else
m_pos = op - 1;
m_pos -= t >> 2;
m_pos -= *ip++ << 2;
#endif
TEST_LB(m_pos); NEED_OP(2);
*op++ = *m_pos++;
*op++ = *m_pos;
#endif /* COPY_DICT */
goto match_done;
}
/* copy match */
#if defined(COPY_DICT)
NEED_OP(t+3-1);
t += 3-1; COPY_DICT(t,m_off)
#else /* !COPY_DICT */
TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
#if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
# if !defined(LZO_UNALIGNED_OK_4)
if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) {
assert((op - m_pos) >= 4); /* both pointers are aligned */
# else
if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) {
# endif
COPY4(op,m_pos);
op += 4; m_pos += 4; t -= 4 - (3 - 1);
do {
COPY4(op,m_pos);
op += 4; m_pos += 4; t -= 4;
} while (t >= 4);
if (t > 0)
do *op++ = *m_pos++; while (--t > 0);
}
else
#endif
{
copy_match:
*op++ = *m_pos++; *op++ = *m_pos++;
do *op++ = *m_pos++; while (--t > 0);
}
#endif /* COPY_DICT */
match_done:
#if defined(LZO1Z)
t = ip[-1] & 3;
#else
t = ip[-2] & 3;
#endif
if (t == 0)
break;
/* copy literals */
match_next:
assert(t > 0);
assert(t < 4);
NEED_OP(t);
NEED_IP(t+1);
#if 0
do *op++ = *ip++; while (--t > 0);
#else
*op++ = *ip++;
if (t > 1) {
*op++ = *ip++;
if (t > 2)
*op++ = *ip++;
}
#endif
t = *ip++;
} while (TEST_IP && TEST_OP);
}
//#if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
/* no EOF code was found */
*out_len = pd(op, out);
return LZO_E_EOF_NOT_FOUND;
//#endif
eof_found:
assert(t == 1);
*out_len = pd(op, out);
return (ip == ip_end ? LZO_E_OK :
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
//#if defined(HAVE_NEED_IP)
input_overrun:
*out_len = pd(op, out);
return LZO_E_INPUT_OVERRUN;
//#endif
//#if defined(HAVE_NEED_OP)
output_overrun:
*out_len = pd(op, out);
return LZO_E_OUTPUT_OVERRUN;
//#endif
//#if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
lookbehind_overrun:
*out_len = pd(op, out);
return LZO_E_LOOKBEHIND_OVERRUN;
//#endif
}
+1075
View File
File diff suppressed because it is too large. Load diff
+22 -12
View File
@@ -115,8 +115,8 @@ int rpm_main(int argc, char **argv)
}
}
argv += optind;
argc -= optind;
if (!argc) bb_show_usage();
//argc -= optind;
if (!argv[0]) bb_show_usage();
while (*argv) {
rpm_fd = xopen(*argv++, O_RDONLY);
@@ -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 FAST_FUNC (*xformer)(int src_fd, int dst_fd);
IF_DESKTOP(long long) int FAST_FUNC (*xformer)(int src_fd, int dst_fd);
enum { xformer_prog = 0 };
#else
enum { xformer = 0 };
@@ -202,7 +202,12 @@ 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->ah_flags = ARCHIVE_PRESERVE_DATE | ARCHIVE_CREATE_LEADING_DIRS;
archive_handle->ah_flags = ARCHIVE_PRESERVE_DATE | ARCHIVE_CREATE_LEADING_DIRS
/* compat: overwrite existing files.
* try "rpm -i foo.src.rpm" few times in a row -
* standard rpm will not complain.
* (TODO? real rpm creates "file;1234" and then renames it) */
| ARCHIVE_EXTRACT_UNCONDITIONAL;
archive_handle->src_fd = fd;
/*archive_handle->offset = 0; - init_handle() did it */
@@ -219,7 +224,7 @@ static void extract_cpio_gz(int fd)
|| magic[0] != 'B' || magic[1] != 'Z'
) {
bb_error_msg_and_die("no gzip"
USE_FEATURE_SEAMLESS_BZ2("/bzip2")
IF_FEATURE_SEAMLESS_BZ2("/bzip2")
" magic");
}
#if BB_MMU
@@ -246,7 +251,7 @@ static void extract_cpio_gz(int fd)
static rpm_index **rpm_gettags(int fd, int *num_tags)
{
/* We should never need mode than 200, and realloc later */
rpm_index **tags = xzalloc(200 * sizeof(struct rpmtag *));
rpm_index **tags = xzalloc(200 * sizeof(tags[0]));
int pass, tagindex = 0;
xlseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */
@@ -260,6 +265,9 @@ static rpm_index **rpm_gettags(int fd, int *num_tags)
uint32_t entries; /* Number of entries in header (4 bytes) */
uint32_t size; /* Size of store (4 bytes) */
} header;
struct BUG_header {
char BUG_header[sizeof(header) == 16 ? 1 : -1];
};
rpm_index *tmpindex;
int storepos;
@@ -273,8 +281,8 @@ static rpm_index **rpm_gettags(int fd, int *num_tags)
storepos = xlseek(fd,0,SEEK_CUR) + header.entries * 16;
while (header.entries--) {
tmpindex = tags[tagindex++] = xmalloc(sizeof(rpm_index));
xread(fd, tmpindex, sizeof(rpm_index));
tmpindex = tags[tagindex++] = xmalloc(sizeof(*tmpindex));
xread(fd, tmpindex, sizeof(*tmpindex));
tmpindex->tag = ntohl(tmpindex->tag);
tmpindex->type = ntohl(tmpindex->type);
tmpindex->count = ntohl(tmpindex->count);
@@ -287,7 +295,7 @@ static rpm_index **rpm_gettags(int fd, int *num_tags)
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 */
tags = xrealloc(tags, tagindex * sizeof(tags[0])); /* realloc tags to save space */
*num_tags = tagindex;
return tags; /* All done, leave the file at the start of the gzipped cpio archive */
}
@@ -378,9 +386,11 @@ static void fileaction_dobackup(char *filename, int fileref)
static void fileaction_setowngrp(char *filename, int fileref)
{
int uid, gid;
uid = xuname2uid(rpm_getstr(TAG_FILEUSERNAME, fileref));
gid = xgroup2gid(rpm_getstr(TAG_FILEGROUPNAME, fileref));
/* real rpm warns: "user foo does not exist - using <you>" */
struct passwd *pw = getpwnam(rpm_getstr(TAG_FILEUSERNAME, fileref));
int uid = pw ? pw->pw_uid : getuid(); /* or euid? */
struct group *gr = getgrnam(rpm_getstr(TAG_FILEGROUPNAME, fileref));
int gid = gr ? gr->gr_gid : getgid();
chown(filename, uid, gid);
}
+40 -31
View File
@@ -357,7 +357,8 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
if (tbInfo->verboseFlag) {
FILE *vbFd = stdout;
if (tbInfo->tarFd == STDOUT_FILENO) /* If the archive goes to stdout, verbose to stderr */
/* If archive goes to stdout, verbose goes to stderr */
if (tbInfo->tarFd == STDOUT_FILENO)
vbFd = stderr;
/* GNU "tar cvvf" prints "extended" listing a-la "ls -l" */
/* We don't have such excesses here: for us "v" == "vv" */
@@ -576,7 +577,7 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip)
#endif
if (vfork_exec_errno) {
errno = vfork_exec_errno;
bb_perror_msg_and_die("cannot exec %s", zip_exec);
bb_perror_msg_and_die("can't execute '%s'", zip_exec);
}
}
#endif /* ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 */
@@ -591,8 +592,6 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
struct TarBallInfo tbInfo;
tbInfo.hlInfoHead = NULL;
fchmod(tar_fd, 0644);
tbInfo.tarFd = tar_fd;
tbInfo.verboseFlag = verboseFlag;
@@ -729,16 +728,17 @@ 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_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 ,)
IF_FEATURE_TAR_CREATE( OPTBIT_CREATE ,)
IF_FEATURE_TAR_CREATE( OPTBIT_DEREFERENCE ,)
IF_FEATURE_SEAMLESS_BZ2( OPTBIT_BZIP2 ,)
IF_FEATURE_SEAMLESS_LZMA(OPTBIT_LZMA ,)
IF_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,)
IF_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,)
IF_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,)
IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,)
OPTBIT_NOPRESERVE_OWN,
OPTBIT_NOPRESERVE_PERM,
OPTBIT_NUMERIC_OWNER,
OPT_TEST = 1 << 0, // t
OPT_EXTRACT = 1 << 1, // x
OPT_BASEDIR = 1 << 2, // C
@@ -747,16 +747,17 @@ 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_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_CREATE = IF_FEATURE_TAR_CREATE( (1 << OPTBIT_CREATE )) + 0, // c
OPT_DEREFERENCE = IF_FEATURE_TAR_CREATE( (1 << OPTBIT_DEREFERENCE )) + 0, // h
OPT_BZIP2 = IF_FEATURE_SEAMLESS_BZ2( (1 << OPTBIT_BZIP2 )) + 0, // j
OPT_LZMA = IF_FEATURE_SEAMLESS_LZMA((1 << OPTBIT_LZMA )) + 0, // a
OPT_INCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T
OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
OPT_COMPRESS = IF_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
OPT_NUMERIC_OWNER = 1 << OPTBIT_NUMERIC_OWNER,
};
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
static const char tar_longopts[] ALIGN1 =
@@ -788,6 +789,7 @@ static const char tar_longopts[] ALIGN1 =
# if ENABLE_FEATURE_SEAMLESS_Z
"compress\0" No_argument "Z"
# endif
"numeric-owner\0" No_argument "\xfc"
"no-same-owner\0" No_argument "\xfd"
"no-same-permissions\0" No_argument "\xfe"
/* --exclude takes next bit position in option mask, */
@@ -818,6 +820,10 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
| ARCHIVE_PRESERVE_DATE
| ARCHIVE_EXTRACT_UNCONDITIONAL;
/* Apparently only root's tar preserves perms (see bug 3844) */
if (getuid() != 0)
tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_PERM;
/* Prepend '-' to the first argument if required */
opt_complementary = "--:" // first arg is options
"tt:vv:" // count -t,-v
@@ -826,24 +832,24 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
"\xff::" // cumulative lists for --exclude
#endif
USE_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd
USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
IF_FEATURE_TAR_CREATE("c:") "t:x:" // at least one of these is reqd
IF_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
IF_NOT_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
applet_long_options = tar_longopts;
#endif
opt = getopt32(argv,
"txC:f:Opvk"
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" )
IF_FEATURE_TAR_CREATE( "ch" )
IF_FEATURE_SEAMLESS_BZ2( "j" )
IF_FEATURE_SEAMLESS_LZMA("a" )
IF_FEATURE_TAR_FROM( "T:X:")
IF_FEATURE_SEAMLESS_GZ( "z" )
IF_FEATURE_SEAMLESS_Z( "Z" )
, &base_dir // -C dir
, &tar_filename // -f filename
USE_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
USE_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X
IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
IF_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
, &excludes // --exclude
#endif
@@ -870,6 +876,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
if (opt & OPT_NOPRESERVE_PERM)
tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_PERM;
if (opt & OPT_NUMERIC_OWNER)
tar_handle->ah_flags |= ARCHIVE_NUMERIC_OWNER;
if (opt & OPT_GZIP)
get_header_ptr = get_header_tar_gz;
+197 -47
View File
@@ -16,12 +16,7 @@
*/
/* TODO
* Endian issues
* Zip64 + other methods
* Improve handling of zip format, ie.
* - deferred CRC, comp. & uncomp. lengths (zip header flags bit 3)
* - unix file permissions, etc.
* - central directory
*/
#include "libbb.h"
@@ -31,12 +26,12 @@ enum {
#if BB_BIG_ENDIAN
ZIP_FILEHEADER_MAGIC = 0x504b0304,
ZIP_CDS_MAGIC = 0x504b0102,
ZIP_CDS_END_MAGIC = 0x504b0506,
ZIP_CDE_MAGIC = 0x504b0506,
ZIP_DD_MAGIC = 0x504b0708,
#else
ZIP_FILEHEADER_MAGIC = 0x04034b50,
ZIP_CDS_MAGIC = 0x02014b50,
ZIP_CDS_END_MAGIC = 0x06054b50,
ZIP_CDE_MAGIC = 0x06054b50,
ZIP_DD_MAGIC = 0x08074b50,
#endif
};
@@ -46,16 +41,16 @@ enum {
typedef union {
uint8_t raw[ZIP_HEADER_LEN];
struct {
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 */
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) */
@@ -65,11 +60,11 @@ typedef union {
*/
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];
offsetof(zip_header_t, formatted.extra_len) + 2
== ZIP_HEADER_LEN ? 1 : -1];
};
#define FIX_ENDIANNESS(zip_header) do { \
#define FIX_ENDIANNESS_ZIP(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 ); \
@@ -82,9 +77,139 @@ struct BUG_zip_header_must_be_26_bytes {
(zip_header).formatted.extra_len = SWAP_LE16((zip_header).formatted.extra_len ); \
} while (0)
static void unzip_skip(int fd, off_t skip)
#define CDS_HEADER_LEN 42
typedef union {
uint8_t raw[CDS_HEADER_LEN];
struct {
/* uint32_t signature; 50 4b 01 02 */
uint16_t version_made_by; /* 0-1 */
uint16_t version_needed; /* 2-3 */
uint16_t cds_flags; /* 4-5 */
uint16_t method; /* 6-7 */
uint16_t mtime; /* 8-9 */
uint16_t mdate; /* 10-11 */
uint32_t crc32; /* 12-15 */
uint32_t cmpsize; /* 16-19 */
uint32_t ucmpsize; /* 20-23 */
uint16_t file_name_length; /* 24-25 */
uint16_t extra_field_length; /* 26-27 */
uint16_t file_comment_length; /* 28-29 */
uint16_t disk_number_start; /* 30-31 */
uint16_t internal_file_attributes; /* 32-33 */
uint32_t external_file_attributes PACKED; /* 34-37 */
uint32_t relative_offset_of_local_header PACKED; /* 38-41 */
} formatted PACKED;
} cds_header_t;
struct BUG_cds_header_must_be_42_bytes {
char BUG_cds_header_must_be_42_bytes[
offsetof(cds_header_t, formatted.relative_offset_of_local_header) + 4
== CDS_HEADER_LEN ? 1 : -1];
};
#define FIX_ENDIANNESS_CDS(cds_header) do { \
(cds_header).formatted.crc32 = SWAP_LE32((cds_header).formatted.crc32 ); \
(cds_header).formatted.cmpsize = SWAP_LE32((cds_header).formatted.cmpsize ); \
(cds_header).formatted.ucmpsize = SWAP_LE32((cds_header).formatted.ucmpsize ); \
(cds_header).formatted.file_name_length = SWAP_LE16((cds_header).formatted.file_name_length); \
(cds_header).formatted.extra_field_length = SWAP_LE16((cds_header).formatted.extra_field_length); \
(cds_header).formatted.file_comment_length = SWAP_LE16((cds_header).formatted.file_comment_length); \
} while (0)
#define CDE_HEADER_LEN 16
typedef union {
uint8_t raw[CDE_HEADER_LEN];
struct {
/* uint32_t signature; 50 4b 05 06 */
uint16_t this_disk_no;
uint16_t disk_with_cds_no;
uint16_t cds_entries_on_this_disk;
uint16_t cds_entries_total;
uint32_t cds_size;
uint32_t cds_offset;
/* uint16_t file_comment_length; */
/* .ZIP file comment (variable size) */
} formatted PACKED;
} cde_header_t;
struct BUG_cde_header_must_be_16_bytes {
char BUG_cde_header_must_be_16_bytes[
sizeof(cde_header_t) == CDE_HEADER_LEN ? 1 : -1];
};
#define FIX_ENDIANNESS_CDE(cde_header) do { \
(cde_header).formatted.cds_offset = SWAP_LE32((cde_header).formatted.cds_offset); \
} while (0)
enum { zip_fd = 3 };
#if ENABLE_DESKTOP
/* NB: does not preserve file position! */
static uint32_t find_cds_offset(void)
{
bb_copyfd_exact_size(fd, -1, skip);
unsigned char buf[1024];
cde_header_t cde_header;
unsigned char *p;
off_t end;
end = xlseek(zip_fd, 0, SEEK_END);
if (end < 1024)
end = 1024;
end -= 1024;
xlseek(zip_fd, end, SEEK_SET);
full_read(zip_fd, buf, 1024);
p = buf;
while (p <= buf + 1024 - CDE_HEADER_LEN - 4) {
if (*p != 'P') {
p++;
continue;
}
if (*++p != 'K')
continue;
if (*++p != 5)
continue;
if (*++p != 6)
continue;
/* we found CDE! */
memcpy(cde_header.raw, p + 1, CDE_HEADER_LEN);
FIX_ENDIANNESS_CDE(cde_header);
return cde_header.formatted.cds_offset;
}
bb_error_msg_and_die("can't find file table");
};
static uint32_t read_next_cds(int count_m1, uint32_t cds_offset, cds_header_t *cds_ptr)
{
off_t org;
org = xlseek(zip_fd, 0, SEEK_CUR);
if (!cds_offset)
cds_offset = find_cds_offset();
while (count_m1-- >= 0) {
xlseek(zip_fd, cds_offset + 4, SEEK_SET);
xread(zip_fd, cds_ptr->raw, CDS_HEADER_LEN);
FIX_ENDIANNESS_CDS(*cds_ptr);
cds_offset += 4 + CDS_HEADER_LEN
+ cds_ptr->formatted.file_name_length
+ cds_ptr->formatted.extra_field_length
+ cds_ptr->formatted.file_comment_length;
}
xlseek(zip_fd, org, SEEK_SET);
return cds_offset;
};
#endif
static void unzip_skip(off_t skip)
{
if (lseek(zip_fd, skip, SEEK_CUR) == (off_t)-1)
bb_copyfd_exact_size(zip_fd, -1, skip);
}
static void unzip_create_leading_dirs(const char *fn)
@@ -97,17 +222,17 @@ static void unzip_create_leading_dirs(const char *fn)
free(name);
}
static void unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
static void unzip_extract(zip_header_t *zip_header, int dst_fd)
{
if (zip_header->formatted.method == 0) {
/* Method 0 - stored (not compressed) */
off_t size = zip_header->formatted.ucmpsize;
if (size)
bb_copyfd_exact_size(src_fd, dst_fd, size);
bb_copyfd_exact_size(zip_fd, dst_fd, size);
} else {
/* Method 8 - inflate */
inflate_unzip_result res;
if (inflate_unzip(&res, zip_header->formatted.cmpsize, src_fd, dst_fd) < 0)
if (inflate_unzip(&res, zip_header->formatted.cmpsize, zip_fd, dst_fd) < 0)
bb_error_msg_and_die("inflate error");
/* Validate decompression - crc */
if (zip_header->formatted.crc32 != (res.crc ^ 0xffffffffL)) {
@@ -131,9 +256,12 @@ int unzip_main(int argc, char **argv)
smallint verbose = 1;
smallint listing = 0;
smallint overwrite = O_PROMPT;
#if ENABLE_DESKTOP
uint32_t cds_offset;
unsigned cds_entries;
#endif
unsigned total_size;
unsigned total_entries;
int src_fd = -1;
int dst_fd = -1;
char *src_fn = NULL;
char *dst_fn = NULL;
@@ -221,13 +349,14 @@ int unzip_main(int argc, char **argv)
/* Open input file */
if (LONE_DASH(src_fn)) {
src_fd = STDIN_FILENO;
xdup2(STDIN_FILENO, zip_fd);
/* Cannot use prompt mode since zip data is arriving on STDIN */
if (overwrite == O_PROMPT)
overwrite = O_NEVER;
} else {
static const char extn[][5] = {"", ".zip", ".ZIP"};
int orig_src_fn_len = strlen(src_fn);
int src_fd = -1;
for (i = 0; (i < 3) && (src_fd == -1); i++) {
strcpy(src_fn + orig_src_fn_len, extn[i]);
@@ -237,6 +366,7 @@ int unzip_main(int argc, char **argv)
src_fn[orig_src_fn_len] = '\0';
bb_error_msg_and_die("can't open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
}
xmove_fd(src_fd, zip_fd);
}
/* Change dir if necessary */
@@ -253,37 +383,63 @@ int unzip_main(int argc, char **argv)
total_size = 0;
total_entries = 0;
#if ENABLE_DESKTOP
cds_entries = 0;
cds_offset = 0;
#endif
while (1) {
uint32_t magic;
/* Check magic number */
xread(src_fd, &magic, 4);
xread(zip_fd, &magic, 4);
/* Central directory? It's at the end, so exit */
if (magic == ZIP_CDS_MAGIC)
break;
#if ENABLE_DESKTOP
/* Data descriptor? It was a streaming file, go on */
if (magic == ZIP_DD_MAGIC) {
/* skip over duplicate crc32, cmpsize and ucmpsize */
unzip_skip(3 * 4);
continue;
}
#endif
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, ZIP_HEADER_LEN);
FIX_ENDIANNESS(zip_header);
xread(zip_fd, zip_header.raw, ZIP_HEADER_LEN);
FIX_ENDIANNESS_ZIP(zip_header);
if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) {
bb_error_msg_and_die("unsupported method %d", zip_header.formatted.method);
}
if (zip_header.formatted.flags & (0x0008|0x0001)) {
#if !ENABLE_DESKTOP
if (zip_header.formatted.flags & 0x0009) {
bb_error_msg_and_die("zip flags 1 and 8 are not supported");
}
#else
if (zip_header.formatted.flags & 0x0001) {
/* 0x0001 - encrypted */
bb_error_msg_and_die("zip flag 1 (encryption) is not supported");
}
if (zip_header.formatted.flags & 0x0008) {
cds_header_t cds_header;
/* 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");
cds_offset = read_next_cds(total_entries - cds_entries, cds_offset, &cds_header);
cds_entries = total_entries + 1;
zip_header.formatted.crc32 = cds_header.formatted.crc32;
zip_header.formatted.cmpsize = cds_header.formatted.cmpsize;
zip_header.formatted.ucmpsize = cds_header.formatted.ucmpsize;
}
#endif
/* Read filename */
free(dst_fn);
dst_fn = xzalloc(zip_header.formatted.filename_len + 1);
xread(src_fd, dst_fn, zip_header.formatted.filename_len);
xread(zip_fd, dst_fn, zip_header.formatted.filename_len);
/* Skip extra header bytes */
unzip_skip(src_fd, zip_header.formatted.extra_len);
unzip_skip(zip_header.formatted.extra_len);
/* Filter zip entries */
if (find_list_entry(zreject, dst_fn)
@@ -304,7 +460,6 @@ int unzip_main(int argc, char **argv)
(dostime & 0x000007e0) >> 5,
dst_fn);
total_size += zip_header.formatted.ucmpsize;
total_entries++;
} else {
/* short listing -- filenames only */
puts(dst_fn);
@@ -315,7 +470,7 @@ int unzip_main(int argc, char **argv)
} 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("can't stat '%s'", dst_fn);
}
if (verbose) {
printf(" creating: %s\n", dst_fn);
@@ -335,7 +490,7 @@ int unzip_main(int argc, char **argv)
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("can't stat '%s'", dst_fn);
}
i = 'y';
} else { /* File already exists */
@@ -347,7 +502,7 @@ int unzip_main(int argc, char **argv)
} else {
printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
if (!fgets(key_buf, sizeof(key_buf), stdin)) {
bb_perror_msg_and_die("cannot read input");
bb_perror_msg_and_die("can't read input");
}
i = key_buf[0];
}
@@ -368,7 +523,7 @@ int unzip_main(int argc, char **argv)
if (verbose) {
printf(" inflating: %s\n", dst_fn);
}
unzip_extract(&zip_header, src_fd, dst_fd);
unzip_extract(&zip_header, dst_fd);
if (dst_fd != STDOUT_FILENO) {
/* closing STDOUT is potentially bad for future business */
close(dst_fd);
@@ -379,14 +534,14 @@ int unzip_main(int argc, char **argv)
overwrite = O_NEVER;
case 'n':
/* Skip entry data */
unzip_skip(src_fd, zip_header.formatted.cmpsize);
unzip_skip(zip_header.formatted.cmpsize);
break;
case 'r':
/* Prompt for new name */
printf("new name: ");
if (!fgets(key_buf, sizeof(key_buf), stdin)) {
bb_perror_msg_and_die("cannot read input");
bb_perror_msg_and_die("can't read input");
}
free(dst_fn);
dst_fn = xstrdup(key_buf);
@@ -398,12 +553,7 @@ int unzip_main(int argc, char **argv)
goto check_file;
}
// 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);
// }
total_entries++;
}
if (listing && verbose) {
Binary file not shown.
+16 -1
View File
@@ -91,7 +91,7 @@ config SETCONSOLE
config FEATURE_SETCONSOLE_LONG_OPTIONS
bool "Enable long options"
default n
depends on SETCONSOLE && GETOPT_LONG
depends on SETCONSOLE && LONG_OPTS
help
Support long options for the setconsole applet.
@@ -101,6 +101,21 @@ config SETFONT
help
Allows to load console screen map. Useful for i18n.
config FEATURE_SETFONT_TEXTUAL_MAP
bool "Support reading textual screen maps"
default n
depends on SETFONT
help
Support reading textual screen maps.
config DEFAULT_SETFONT_DIR
string "Default directory for console-tools files"
default ""
depends on SETFONT
help
Directory to use if setfont's params are simple filenames
(not /path/to/file or ./file). Default is "" (no default directory).
config SETKEYCODES
bool "setkeycodes"
default n
+11 -10
View File
@@ -2,37 +2,37 @@
/*
* Mini kbd_mode implementation for busybox
*
* Copyright (C) 2007 Loïc Grenié <loic.grenie@gmail.com>
* Copyright (C) 2007 Loic Grenie <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)
UNICODE = (1 << 3),
};
static const char KD_xxx[] ALIGN1 = "saku";
opt = getopt32(argv, KD_xxx);
fd = get_console_fd_or_die();
int fd;
unsigned opt;
const char *tty_name = CURRENT_TTY;
opt = getopt32(argv, "sakuC:", &tty_name);
fd = xopen(tty_name, O_NONBLOCK);
opt &= 0xf; /* clear -C bit, see (*) */
if (!opt) { /* print current setting */
const char *mode = "unknown";
int m;
ioctl(fd, KDGKBMODE, &m);
xioctl(fd, KDGKBMODE, &m);
if (m == K_RAW)
mode = "raw (scancode)";
else if (m == K_XLATE)
@@ -43,6 +43,7 @@ int kbd_mode_main(int argc UNUSED_PARAM, char **argv)
mode = "Unicode (UTF-8)";
printf("The keyboard is in %s mode\n", mode);
} else {
/* here we depend on specific bits assigned to options (*) */
opt = opt & UNICODE ? 3 : opt >> 1;
/* double cast prevents warnings about widening conversion */
xioctl(fd, KDSKBMODE, (void*)(ptrdiff_t)opt);
+187 -11
View File
@@ -6,10 +6,34 @@
*
* Loads the console font, and possibly the corresponding screen map(s).
* (Adapted for busybox by Matej Vela.)
*
* Licensed under GPLv2, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include <sys/kd.h>
#ifndef KDFONTOP
#define KDFONTOP 0x4B72
struct console_font_op {
unsigned op; /* KD_FONT_OP_* */
unsigned flags; /* KD_FONT_FLAG_* */
unsigned width, height;
unsigned charcount;
unsigned char *data; /* font data with height fixed to 32 */
};
#define KD_FONT_OP_SET 0 /* Set font */
#define KD_FONT_OP_GET 1 /* Get font */
#define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default,
data points to name / NULL */
#define KD_FONT_OP_COPY 3 /* Copy from another console */
#define KD_FONT_FLAG_OLD 0x80000000 /* Invoked via old interface */
#define KD_FONT_FLAG_DONT_RECALC 1 /* Don't call adjust_height() */
/* (Used internally for PIO_FONT support) */
#endif /* KDFONTOP */
enum {
PSF_MAGIC1 = 0x36,
PSF_MAGIC2 = 0x04,
@@ -17,7 +41,7 @@ enum {
PSF_MODE512 = 0x01,
PSF_MODEHASTAB = 0x02,
PSF_MAXMODE = 0x03,
PSF_SEPARATOR = 0xFFFF
PSF_SEPARATOR = 0xffff
};
struct psf_header {
@@ -40,6 +64,28 @@ static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
for (i = 0; i < fontsize; i++)
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
{ /* KDFONTOP */
struct console_font_op cfo;
cfo.op = KD_FONT_OP_SET;
cfo.flags = 0;
cfo.width = 8;
cfo.height = unit;
cfo.charcount = fontsize;
cfo.data = (void*)buf;
#if 0
if (!ioctl_or_perror(fd, KDFONTOP, &cfo, "KDFONTOP ioctl failed (will try PIO_FONTX)"))
goto ret; /* success */
#else
xioctl(fd, KDFONTOP, &cfo);
#endif
}
#if 0
/* These ones do not honour -C tty (they set font on current tty regardless)
* On x86, this distinction is visible on framebuffer consoles
* (regular character consoles may have only one shared font anyway)
*/
#if defined(PIO_FONTX) && !defined(__sparc__)
{
struct consolefontdesc cfd;
@@ -49,11 +95,12 @@ static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
cfd.chardata = buf;
if (!ioctl_or_perror(fd, PIO_FONTX, &cfd, "PIO_FONTX ioctl failed (will try PIO_FONT)"))
goto ret; /* success */
goto ret; /* success */
}
#endif
xioctl(fd, PIO_FONT, buf);
ret:
#endif /* 0 */
free(buf);
}
@@ -155,7 +202,7 @@ int loadfont_main(int argc UNUSED_PARAM, char **argv)
* just read the entire file.
*/
len = 32*1024; // can't be larger
psfhdr = (struct psf_header *) xmalloc_read(STDIN_FILENO, &len);
psfhdr = xmalloc_read(STDIN_FILENO, &len);
// xmalloc_open_zipped_read_close(filename, &len);
if (!psfhdr)
bb_perror_msg_and_die("error reading input font");
@@ -166,30 +213,159 @@ int loadfont_main(int argc UNUSED_PARAM, char **argv)
#endif
#if ENABLE_SETFONT
/*
kbd-1.12:
setfont [-O font+umap.orig] [-o font.orig] [-om cmap.orig]
[-ou umap.orig] [-N] [font.new ...] [-m cmap] [-u umap] [-C console]
[-hNN] [-v] [-V]
-h NN Override font height
-o file
Save previous font in file
-O file
Save previous font and Unicode map in file
-om file
Store console map in file
-ou file
Save previous Unicode map in file
-m file
Load console map or Unicode console map from file
-u file
Load Unicode table describing the font from file
Example:
# cp866
0x00-0x7f idem
#
0x80 U+0410 # CYRILLIC CAPITAL LETTER A
0x81 U+0411 # CYRILLIC CAPITAL LETTER BE
0x82 U+0412 # CYRILLIC CAPITAL LETTER VE
-C console
Set the font for the indicated console
-v Verbose
-V Version
*/
#if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
static int ctoi(char *s)
{
if (s[0] == '\'' && s[1] != '\0' && s[2] == '\'' && s[3] == '\0')
return s[1];
// U+ means 0x
if (s[0] == 'U' && s[1] == '+') {
s[0] = '0';
s[1] = 'x';
}
if (!isdigit(s[0]))
return -1;
return xstrtoul(s, 0);
}
#endif
int setfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int setfont_main(int argc UNUSED_PARAM, char **argv)
{
size_t len;
unsigned opts;
int fd;
struct psf_header *psfhdr;
char *mapfilename;
int fd;
const char *tty_name = CURRENT_TTY;
opt_complementary = "=1";
getopt32(argv, "m:", &mapfilename);
opts = getopt32(argv, "m:C:", &mapfilename, &tty_name);
argv += optind;
fd = xopen(tty_name, O_NONBLOCK);
if (sizeof(CONFIG_DEFAULT_SETFONT_DIR) > 1) { // if not ""
if (*argv[0] != '/') {
// goto default fonts location. don't die if doesn't exist
chdir(CONFIG_DEFAULT_SETFONT_DIR "/consolefonts");
}
}
// 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();
psfhdr = xmalloc_open_zipped_read_close(*argv, &len);
if (!psfhdr)
bb_simple_perror_msg_and_die(*argv);
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);
if (opts & 1) { // -m
unsigned mode = PIO_SCRNMAP;
void *map;
if (sizeof(CONFIG_DEFAULT_SETFONT_DIR) > 1) { // if not ""
if (mapfilename[0] != '/') {
// goto default keymaps location
chdir(CONFIG_DEFAULT_SETFONT_DIR "/consoletrans");
}
}
// fetch keymap
map = xmalloc_open_zipped_read_close(mapfilename, &len);
if (!map)
bb_simple_perror_msg_and_die(mapfilename);
// file size is 256 or 512 bytes? -> assume binary map
if (len == E_TABSZ || len == 2*E_TABSZ) {
if (len == 2*E_TABSZ)
mode = PIO_UNISCRNMAP;
}
#if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
// assume textual Unicode console maps:
// 0x00 U+0000 # NULL (NUL)
// 0x01 U+0001 # START OF HEADING (SOH)
// 0x02 U+0002 # START OF TEXT (STX)
// 0x03 U+0003 # END OF TEXT (ETX)
else {
int i;
char *token[2];
parser_t *parser;
if (ENABLE_FEATURE_CLEAN_UP)
free(map);
map = xmalloc(E_TABSZ * sizeof(unsigned short));
#define unicodes ((unsigned short *)map)
// fill vanilla map
for (i = 0; i < E_TABSZ; i++)
unicodes[i] = 0xf000 + i;
parser = config_open(mapfilename);
while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL | PARSE_MIN_DIE)) {
// parse code/value pair
int a = ctoi(token[0]);
int b = ctoi(token[1]);
if (a < 0 || a >= E_TABSZ
|| b < 0 || b > 65535
) {
bb_error_msg_and_die("map format");
}
// patch map
unicodes[a] = b;
// unicode character is met?
if (b > 255)
mode = PIO_UNISCRNMAP;
}
if (ENABLE_FEATURE_CLEAN_UP)
config_close(parser);
if (mode != PIO_UNISCRNMAP) {
#define asciis ((unsigned char *)map)
for (i = 0; i < E_TABSZ; i++)
asciis[i] = unicodes[i];
#undef asciis
}
#undef unicodes
}
#endif // ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
// do set screen map
xioctl(fd, mode, map);
if (ENABLE_FEATURE_CLEAN_UP)
free(map);
}
return EXIT_SUCCESS;
+6 -4
View File
@@ -5,9 +5,7 @@
* Copyright (C) 1998 Enrique Zanardi <ezanardi@ull.es>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
*/
#include "libbb.h"
#define BINARY_KEYMAP_MAGIC "bkeymap"
@@ -31,11 +29,15 @@ int loadkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
struct kbentry ke;
int i, j, fd;
uint16_t ibuff[NR_KEYS];
/* const char *tty_name = CURRENT_TTY; */
RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
/* bb_warn_ignoring_args(argc>=2);*/
/* bb_warn_ignoring_args(argc >= 2); */
fd = get_console_fd_or_die();
/* or maybe:
opt = getopt32(argv, "C:", &tty_name);
fd = xopen(tty_name, O_NONBLOCK);
*/
xread(STDIN_FILENO, flags, 7);
if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7))
+1 -1
View File
@@ -2,7 +2,7 @@
/*
* resize - set terminal width and height.
*
* Copyright 2006 Bernhard Fischer
* Copyright 2006 Bernhard Reutner-Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
+1 -1
View File
@@ -3,7 +3,7 @@
* setconsole.c - redirect system console output
*
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
* Copyright (C) 2008 Bernhard Fischer
* Copyright (C) 2008 Bernhard Reutner-Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
+5 -5
View File
@@ -50,7 +50,7 @@ static void signal_handler(int signo)
{
// restore keyboard and console settings
xset1(STDIN_FILENO, &tio0, "stdin");
xioctl(STDIN_FILENO, KDSKBMODE, (void *)kbmode);
xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)kbmode);
// alarmed? -> exit 0
exit(SIGALRM == signo);
}
@@ -72,9 +72,9 @@ int showkey_main(int argc UNUSED_PARAM, char **argv)
// 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_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"
);
@@ -95,7 +95,7 @@ int showkey_main(int argc UNUSED_PARAM, char **argv)
// we should exit on any signal
bb_signals(BB_FATAL_SIGS, signal_handler);
// set raw keyboard mode
xioctl(STDIN_FILENO, KDSKBMODE, (void *)((option_mask32 & OPT_k) ? K_MEDIUMRAW : K_RAW));
xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)((option_mask32 & OPT_k) ? K_MEDIUMRAW : K_RAW));
// read and show scancodes
while (1) {
+33 -15
View File
@@ -136,12 +136,12 @@ config DF
df reports the amount of disk space used and available
on filesystems.
config FEATURE_DF_INODE
bool "Enable -i (inode information)"
config FEATURE_DF_FANCY
bool "Enable -a, -i, -B"
default n
depends on DF
help
This option enables support for df -i.
This option enables -a, -i and -B.
config DIRNAME
bool "dirname"
@@ -189,7 +189,7 @@ config ECHO
config FEATURE_FANCY_ECHO
bool "Enable echo options (-n and -e)"
default y
depends on ECHO
depends on ECHO || ASH_BUILTIN_ECHO || HUSH
help
This adds options (-n and -e) to echo.
@@ -204,7 +204,7 @@ config ENV
config FEATURE_ENV_LONG_OPTIONS
bool "Enable long options"
default n
depends on ENV && GETOPT_LONG
depends on ENV && LONG_OPTS
help
Support long options for the env applet.
@@ -217,7 +217,7 @@ config EXPAND
config FEATURE_EXPAND_LONG_OPTIONS
bool "Enable long options"
default n
depends on EXPAND && GETOPT_LONG
depends on EXPAND && LONG_OPTS
help
Support long options for the expand applet.
@@ -249,6 +249,12 @@ config FOLD
help
Wrap text to fit a specific width.
config FSYNC
bool "fsync"
default n
help
fsync is used to flush file-related cached blocks to disk.
config HEAD
bool "head"
default n
@@ -285,7 +291,7 @@ config INSTALL
config FEATURE_INSTALL_LONG_OPTIONS
bool "Enable long options"
default n
depends on INSTALL && GETOPT_LONG
depends on INSTALL && LONG_OPTS
help
Support long options for the install applet.
@@ -358,7 +364,7 @@ config FEATURE_LS_USERNAME
config FEATURE_LS_COLOR
bool "Allow use of color to identify file types"
default y
depends on LS && GETOPT_LONG
depends on LS && LONG_OPTS
help
This enables the --color option to ls.
@@ -388,7 +394,7 @@ config MKDIR
config FEATURE_MKDIR_LONG_OPTIONS
bool "Enable long options"
default n
depends on MKDIR && GETOPT_LONG
depends on MKDIR && LONG_OPTS
help
Support long options for the mkdir applet.
@@ -415,7 +421,7 @@ config MV
config FEATURE_MV_LONG_OPTIONS
bool "Enable long options"
default n
depends on MV && GETOPT_LONG
depends on MV && LONG_OPTS
help
Support long options for the mv applet.
@@ -492,7 +498,7 @@ config RMDIR
config FEATURE_RMDIR_LONG_OPTIONS
bool "Enable long options"
default n
depends on RMDIR && GETOPT_LONG
depends on RMDIR && LONG_OPTS
help
Support long options for the rmdir applet, including
--ignore-fail-on-non-empty for compatibility with GNU rmdir.
@@ -509,6 +515,18 @@ config SHA1SUM
help
Compute and check SHA1 message digest
config SHA256SUM
bool "sha256sum"
default n
help
Compute and check SHA256 message digest
config SHA512SUM
bool "sha512sum"
default n
help
Compute and check SHA512 message digest
config SLEEP
bool "sleep"
default n
@@ -617,7 +635,7 @@ config TAIL
from files.
config FEATURE_FANCY_TAIL
bool "Enable extra tail options (-q, -s, and -v)"
bool "Enable extra tail options (-q, -s, -v, and -F)"
default y
depends on TAIL
help
@@ -649,7 +667,7 @@ config TEST
config FEATURE_TEST_64
bool "Extend test to 64 bit"
default n
depends on TEST
depends on TEST || ASH_BUILTIN_TEST || HUSH
help
Enable 64-bit support in test.
@@ -714,7 +732,7 @@ config UNEXPAND
config FEATURE_UNEXPAND_LONG_OPTIONS
bool "Enable long options"
default n
depends on UNEXPAND && GETOPT_LONG
depends on UNEXPAND && LONG_OPTS
help
Support long options for the unexpand applet.
@@ -754,7 +772,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 counter variables.
config WHO
bool "who"
+4
View File
@@ -36,6 +36,7 @@ lib-$(CONFIG_EXPR) += expr.o
lib-$(CONFIG_EXPAND) += expand.o
lib-$(CONFIG_FALSE) += false.o
lib-$(CONFIG_FOLD) += fold.o
lib-$(CONFIG_FSYNC) += fsync.o
lib-$(CONFIG_HEAD) += head.o
lib-$(CONFIG_HOSTID) += hostid.o
lib-$(CONFIG_ID) += id.o
@@ -44,6 +45,7 @@ lib-$(CONFIG_LENGTH) += length.o
lib-$(CONFIG_LN) += ln.o
lib-$(CONFIG_LOGNAME) += logname.o
lib-$(CONFIG_LS) += ls.o
lib-$(CONFIG_FTPD) += ls.o
lib-$(CONFIG_MD5SUM) += md5_sha1_sum.o
lib-$(CONFIG_MKDIR) += mkdir.o
lib-$(CONFIG_MKFIFO) += mkfifo.o
@@ -62,6 +64,8 @@ lib-$(CONFIG_RM) += rm.o
lib-$(CONFIG_RMDIR) += rmdir.o
lib-$(CONFIG_SEQ) += seq.o
lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
lib-$(CONFIG_SHA256SUM) += md5_sha1_sum.o
lib-$(CONFIG_SHA512SUM) += md5_sha1_sum.o
lib-$(CONFIG_SLEEP) += sleep.o
lib-$(CONFIG_SPLIT) += split.o
lib-$(CONFIG_SORT) += sort.o
+2 -1
View File
@@ -48,5 +48,6 @@ int basename_main(int argc, char **argv)
/* 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;
/* NB: != is correct here: */
return full_write(STDOUT_FILENO, s, m) != (ssize_t)m;
}
+4 -4
View File
@@ -20,10 +20,10 @@
#define OPT_RECURSE (option_mask32 & 1)
#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 2) SKIP_DESKTOP(0))
#define OPT_CHANGED (USE_DESKTOP(option_mask32 & 4) SKIP_DESKTOP(0))
#define OPT_QUIET (USE_DESKTOP(option_mask32 & 8) SKIP_DESKTOP(0))
#define OPT_STR "R" USE_DESKTOP("vcf")
#define OPT_VERBOSE (IF_DESKTOP(option_mask32 & 2) IF_NOT_DESKTOP(0))
#define OPT_CHANGED (IF_DESKTOP(option_mask32 & 4) IF_NOT_DESKTOP(0))
#define OPT_QUIET (IF_DESKTOP(option_mask32 & 8) IF_NOT_DESKTOP(0))
#define OPT_STR "R" IF_DESKTOP("vcf")
/* coreutils:
* chmod never changes the permissions of symbolic links; the chmod
+7 -7
View File
@@ -16,13 +16,13 @@
/* This is a NOEXEC applet. Be very careful! */
#define OPT_STR ("Rh" USE_DESKTOP("vcfLHP"))
#define OPT_STR ("Rh" IF_DESKTOP("vcfLHP"))
#define BIT_RECURSE 1
#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))
#define OPT_VERBOSE (IF_DESKTOP(opt & 0x04) IF_NOT_DESKTOP(0))
#define OPT_CHANGED (IF_DESKTOP(opt & 0x08) IF_NOT_DESKTOP(0))
#define OPT_QUIET (IF_DESKTOP(opt & 0x10) IF_NOT_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,10 +32,10 @@
* The last option specified shall determine the behavior of the utility." */
/* -L */
#define BIT_TRAVERSE 0x20
#define OPT_TRAVERSE (USE_DESKTOP(opt & BIT_TRAVERSE) SKIP_DESKTOP(0))
#define OPT_TRAVERSE (IF_DESKTOP(opt & BIT_TRAVERSE) IF_NOT_DESKTOP(0))
/* -H or -L */
#define BIT_TRAVERSE_TOP (0x20|0x40)
#define OPT_TRAVERSE_TOP (USE_DESKTOP(opt & BIT_TRAVERSE_TOP) SKIP_DESKTOP(0))
#define OPT_TRAVERSE_TOP (IF_DESKTOP(opt & BIT_TRAVERSE_TOP) IF_NOT_DESKTOP(0))
typedef int (*chown_fptr)(const char *, uid_t, gid_t);
@@ -85,7 +85,7 @@ int chown_main(int argc UNUSED_PARAM, char **argv)
/* This matches coreutils behavior (almost - see below) */
if (OPT_NODEREF
/* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */
USE_DESKTOP( || (opt & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
IF_DESKTOP( || (opt & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
) {
param.chown_func = lchown;
}
+1 -1
View File
@@ -33,5 +33,5 @@ int chroot_main(int argc, char **argv)
}
BB_EXECVP(*argv, argv);
bb_perror_msg_and_die("cannot execute %s", *argv);
bb_perror_msg_and_die("can't execute '%s'", *argv);
}
+18 -7
View File
@@ -13,8 +13,9 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
{
uint32_t *crc32_table = crc32_filltable(NULL, 1);
uint32_t crc;
long length, filesize;
off_t length, filesize;
int bytes_read;
int exit_code = EXIT_SUCCESS;
uint8_t *cp;
#if ENABLE_DESKTOP
@@ -27,8 +28,10 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
do {
int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input);
if (fd < 0)
if (fd < 0) {
exit_code = EXIT_FAILURE;
continue;
}
crc = 0;
length = 0;
@@ -44,13 +47,21 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
filesize = length;
for (; length; length >>= 8)
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xff];
crc ^= 0xffffffffL;
while (length) {
crc = (crc << 8) ^ crc32_table[(uint8_t)(crc >> 24) ^ (uint8_t)length];
/* must ensure that shift is unsigned! */
if (sizeof(length) <= sizeof(unsigned))
length = (unsigned)length >> 8;
else if (sizeof(length) <= sizeof(unsigned long))
length = (unsigned long)length >> 8;
else
length = (unsigned long long)length >> 8;
}
crc = ~crc;
printf((*argv ? "%" PRIu32 " %li %s\n" : "%" PRIu32 " %li\n"),
printf((*argv ? "%"PRIu32" %"OFF_FMT"i %s\n" : "%"PRIu32" %"OFF_FMT"i\n"),
crc, filesize, *argv);
} while (*argv && *++argv);
fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(exit_code);
}
+49 -1
View File
@@ -46,7 +46,55 @@ int cp_main(int argc, char **argv)
// -R (and therefore -r) turns on -d (coreutils does this)
// -a = -pdR
opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR:HL";
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPH");
// -v (--verbose) is ignored
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPHv");
/* Options of cp from GNU coreutils 6.10:
* -a, --archive
* -f, --force
* -i, --interactive
* -l, --link
* -L, --dereference
* -P, --no-dereference
* -R, -r, --recursive
* -s, --symbolic-link
* -v, --verbose
* -H follow command-line symbolic links in SOURCE
* -d same as --no-dereference --preserve=links
* -p same as --preserve=mode,ownership,timestamps
* -c same as --preserve=context
* NOT SUPPORTED IN BBOX:
* long options are not supported (even those above).
* --backup[=CONTROL]
* make a backup of each existing destination file
* -b like --backup but does not accept an argument
* --copy-contents
* copy contents of special files when recursive
* --preserve[=ATTR_LIST]
* preserve attributes (default: mode,ownership,timestamps),
* if possible additional attributes: security context,links,all
* --no-preserve=ATTR_LIST
* --parents
* use full source file name under DIRECTORY
* --remove-destination
* remove each existing destination file before attempting to open
* --sparse=WHEN
* control creation of sparse files
* --strip-trailing-slashes
* remove any trailing slashes from each SOURCE argument
* -S, --suffix=SUFFIX
* override the usual backup suffix
* -t, --target-directory=DIRECTORY
* copy all SOURCE arguments into DIRECTORY
* -T, --no-target-directory
* treat DEST as a normal file
* -u, --update
* copy only when the SOURCE file is newer than the destination
* file or when the destination file is missing
* -x, --one-file-system
* stay on this file system
* -Z, --context=CONTEXT
* (SELinux) set SELinux security context of copy to CONTEXT
*/
argc -= optind;
argv += optind;
flags ^= FILEUTILS_DEREFERENCE; /* the sense of this flag was reversed */
+1 -1
View File
@@ -4,7 +4,7 @@
*
* Copyright (C) 1999,2000,2001 by Lineo, inc.
* Written by Mark Whitley <markw@codepoet.org>
* debloated by Bernhard Fischer
* debloated by Bernhard Reutner-Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
+61 -88
View File
@@ -5,13 +5,11 @@
* by Matthew Grant <grantma@anathoth.gen.nz>
*
* iso-format handling added by Robert Griebl <griebl@gmx.de>
* bugfixes and cleanup by Bernhard Fischer
* bugfixes and cleanup by Bernhard Reutner-Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
/* This 'date' command supports only 2 time setting formats,
all the GNU strftime stuff (its in libc, lets use it),
setting time using UTC and displaying it, as well as
@@ -23,18 +21,51 @@
/* Default input handling to save surprising some people */
/* GNU coreutils 6.9 man page:
* date [OPTION]... [+FORMAT]
* date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
* -d, --date=STRING
* display time described by STRING, not `now'
* -f, --file=DATEFILE
* like --date once for each line of DATEFILE
* -r, --reference=FILE
* display the last modification time of FILE
* -R, --rfc-2822
* output date and time in RFC 2822 format.
* Example: Mon, 07 Aug 2006 12:34:56 -0600
* --rfc-3339=TIMESPEC
* output date and time in RFC 3339 format.
* TIMESPEC='date', 'seconds', or 'ns'
* Date and time components are separated by a single space:
* 2006-08-07 12:34:56-06:00
* -s, --set=STRING
* set time described by STRING
* -u, --utc, --universal
* print or set Coordinated Universal Time
*
* Busybox:
* long options are not supported
* -f is not supported
* -I seems to roughly match --rfc-3339, but -I has _optional_ param
* (thus "-I seconds" doesn't work, only "-Iseconds"),
* and does not support -Ins
* -D FMT is a bbox extension for _input_ conversion of -d DATE
*/
#include "libbb.h"
#define DATE_OPT_RFC2822 0x01
#define DATE_OPT_SET 0x02
#define DATE_OPT_UTC 0x04
#define DATE_OPT_DATE 0x08
#define DATE_OPT_REFERENCE 0x10
#define DATE_OPT_TIMESPEC 0x20
#define DATE_OPT_HINT 0x40
enum {
OPT_RFC2822 = (1 << 0), /* R */
OPT_SET = (1 << 1), /* s */
OPT_UTC = (1 << 2), /* u */
OPT_DATE = (1 << 3), /* d */
OPT_REFERENCE = (1 << 4), /* r */
OPT_TIMESPEC = (1 << 5) * ENABLE_FEATURE_DATE_ISOFMT, /* I */
OPT_HINT = (1 << 6) * ENABLE_FEATURE_DATE_ISOFMT, /* D */
};
static void maybe_set_utc(int opt)
{
if (opt & DATE_OPT_UTC)
if (opt & OPT_UTC)
putenv((char*)"TZ=UTC0");
}
@@ -52,15 +83,15 @@ int date_main(int argc UNUSED_PARAM, char **argv)
char *isofmt_arg = NULL;
opt_complementary = "d--s:s--d"
USE_FEATURE_DATE_ISOFMT(":R--I:I--R");
IF_FEATURE_DATE_ISOFMT(":R--I:I--R");
opt = getopt32(argv, "Rs:ud:r:"
USE_FEATURE_DATE_ISOFMT("I::D:"),
IF_FEATURE_DATE_ISOFMT("I::D:"),
&date_str, &date_str, &filename
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt));
IF_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt));
argv += optind;
maybe_set_utc(opt);
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_TIMESPEC)) {
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & OPT_TIMESPEC)) {
ifmt = 0; /* default is date */
if (isofmt_arg) {
static const char isoformats[] ALIGN1 =
@@ -76,8 +107,8 @@ int date_main(int argc UNUSED_PARAM, char **argv)
fmt_dt2str = &argv[0][1]; /* Skip over the '+' */
argv++;
}
if (!(opt & (DATE_OPT_SET | DATE_OPT_DATE))) {
opt |= DATE_OPT_SET;
if (!(opt & (OPT_SET | OPT_DATE))) {
opt |= OPT_SET;
date_str = argv[0]; /* can be NULL */
if (date_str)
argv++;
@@ -88,13 +119,14 @@ int date_main(int argc UNUSED_PARAM, char **argv)
/* Now we have parsed all the information except the date format
which depends on whether the clock is being set or read */
if (opt & DATE_OPT_REFERENCE) {
if (opt & OPT_REFERENCE) {
struct stat statbuf;
xstat(filename, &statbuf);
tm = statbuf.st_mtime;
} else
} else {
time(&tm);
memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
}
localtime_r(&tm, &tm_time);
/* If date string is given, update tm_time, and maybe set date */
if (date_str != NULL) {
@@ -104,80 +136,21 @@ int date_main(int argc UNUSED_PARAM, char **argv)
tm_time.tm_hour = 0;
/* Process any date input to UNIX time since 1 Jan 1970 */
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_HINT)) {
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & OPT_HINT)) {
if (strptime(date_str, fmt_str2dt, &tm_time) == NULL)
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
} else {
char end = '\0';
const char *last_colon = strrchr(date_str, ':');
if (last_colon != NULL) {
/* Parse input and assign appropriately to tm_time */
if (sscanf(date_str, "%u:%u%c",
&tm_time.tm_hour,
&tm_time.tm_min,
&end) >= 2) {
/* no adjustments needed */
} else if (sscanf(date_str, "%u.%u-%u:%u%c",
&tm_time.tm_mon, &tm_time.tm_mday,
&tm_time.tm_hour, &tm_time.tm_min,
&end) >= 4) {
/* Adjust dates from 1-12 to 0-11 */
tm_time.tm_mon -= 1;
} else if (sscanf(date_str, "%u.%u.%u-%u:%u%c", &tm_time.tm_year,
&tm_time.tm_mon, &tm_time.tm_mday,
&tm_time.tm_hour, &tm_time.tm_min,
&end) >= 5) {
tm_time.tm_year -= 1900; /* Adjust years */
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else if (sscanf(date_str, "%u-%u-%u %u:%u%c", &tm_time.tm_year,
&tm_time.tm_mon, &tm_time.tm_mday,
&tm_time.tm_hour, &tm_time.tm_min,
&end) >= 5) {
tm_time.tm_year -= 1900; /* Adjust years */
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
//TODO: coreutils 6.9 also accepts "YYYY-MM-DD HH" (no minutes)
} else {
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
}
if (end == ':') {
if (sscanf(last_colon + 1, "%u%c", &tm_time.tm_sec, &end) == 1)
end = '\0';
/* else end != NUL and we error out */
}
} else {
if (sscanf(date_str, "%2u%2u%2u%2u%u%c", &tm_time.tm_mon,
&tm_time.tm_mday, &tm_time.tm_hour, &tm_time.tm_min,
&tm_time.tm_year, &end) < 4)
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
/* correct for century - minor Y2K problem here? */
if (tm_time.tm_year >= 1900) {
tm_time.tm_year -= 1900;
}
/* adjust date */
tm_time.tm_mon -= 1;
if (end == '.') {
if (sscanf(strchr(date_str, '.') + 1, "%u%c",
&tm_time.tm_sec, &end) == 1)
end = '\0';
/* else end != NUL and we error out */
}
}
if (end != '\0') {
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
}
parse_datestr(date_str, &tm_time);
}
/* Correct any day of week and day of year etc. fields */
tm_time.tm_isdst = -1; /* Be sure to recheck dst. */
tm = mktime(&tm_time);
if (tm < 0) {
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
}
tm_time.tm_isdst = -1; /* Be sure to recheck dst */
tm = validate_tm_time(date_str, &tm_time);
maybe_set_utc(opt);
/* if setting time, set it */
if ((opt & DATE_OPT_SET) && stime(&tm) < 0) {
if ((opt & OPT_SET) && stime(&tm) < 0) {
bb_perror_msg("cannot set date");
}
}
@@ -207,9 +180,9 @@ int date_main(int argc UNUSED_PARAM, char **argv)
}
format_utc:
fmt_dt2str[i++] = '%';
fmt_dt2str[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
fmt_dt2str[i] = (opt & OPT_UTC) ? 'Z' : 'z';
}
} else if (opt & DATE_OPT_RFC2822) {
} else if (opt & OPT_RFC2822) {
/* Undo busybox.c for date -R */
if (ENABLE_LOCALE_SUPPORT)
setlocale(LC_TIME, "C");
+7 -5
View File
@@ -8,7 +8,6 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <signal.h> /* For FEATURE_DD_SIGNAL_HANDLING */
#include "libbb.h"
/* This is a NOEXEC applet. Be very careful! */
@@ -287,23 +286,26 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
}
while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) {
if (flags & FLAG_NOERROR) /* Pre-zero the buffer if conv=noerror */
memset(ibuf, 0, ibs);
n = safe_read(ifd, ibuf, ibs);
if (n == 0)
break;
if (n < 0) {
/* "Bad block" */
if (!(flags & FLAG_NOERROR))
goto die_infile;
n = ibs;
bb_simple_perror_msg(infile);
/* GNU dd with conv=noerror skips over bad blocks */
xlseek(ifd, ibs, SEEK_CUR);
/* conv=noerror,sync writes NULs,
* conv=noerror just ignores input bad blocks */
n = 0;
}
if ((size_t)n == ibs)
G.in_full++;
else {
G.in_part++;
if (flags & FLAG_SYNC) {
memset(ibuf + n, '\0', ibs - n);
memset(ibuf + n, 0, ibs - n);
n = ibs;
}
}
+61 -40
View File
@@ -8,7 +8,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* BB_AUDIT SUSv3 _NOT_ compliant -- options -P and -t missing. Also blocksize. */
/* BB_AUDIT SUSv3 _NOT_ compliant -- option -t missing. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/df.html */
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
@@ -16,6 +16,10 @@
* Size reduction. Removed floating point dependency. Added error checking
* on output. Output stats on 0-sized filesystems if specifically listed on
* the command line. Properly round *-blocks, Used, and Available quantities.
*
* Aug 28, 2008 Bernhard Reutner-Fischer
*
* Implement -P and -B; better coreutils compat; cleanup
*/
#include <mntent.h>
@@ -34,51 +38,71 @@ int df_main(int argc, char **argv)
{
unsigned long blocks_used;
unsigned blocks_percent_used;
#if ENABLE_FEATURE_HUMAN_READABLE
unsigned df_disp_hr = 1024;
#endif
unsigned long df_disp_hr = 1024;
int status = EXIT_SUCCESS;
unsigned opt;
FILE *mount_table;
struct mntent *mount_entry;
struct statfs s;
/* default display is kilobytes */
const char *disp_units_hdr = "1k-blocks";
enum {
OPT_ALL = (1 << 0),
OPT_INODE = (ENABLE_FEATURE_HUMAN_READABLE ? (1 << 4) : (1 << 2))
* ENABLE_FEATURE_DF_INODE
OPT_KILO = (1 << 0),
OPT_POSIX = (1 << 1),
OPT_ALL = (1 << 2) * ENABLE_FEATURE_DF_FANCY,
OPT_INODE = (1 << 3) * ENABLE_FEATURE_DF_FANCY,
OPT_BSIZE = (1 << 4) * ENABLE_FEATURE_DF_FANCY,
OPT_HUMAN = (1 << (2 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
OPT_MEGA = (1 << (3 + 3*ENABLE_FEATURE_DF_FANCY)) * ENABLE_FEATURE_HUMAN_READABLE,
};
const char *disp_units_hdr = NULL;
char *chp;
#if ENABLE_FEATURE_HUMAN_READABLE
opt_complementary = "h-km:k-hm:m-hk";
opt = getopt32(argv, "ahmk" USE_FEATURE_DF_INODE("i"));
if (opt & (1 << 1)) { // -h
#if ENABLE_FEATURE_HUMAN_READABLE && ENABLE_FEATURE_DF_FANCY
opt_complementary = "k-mB:m-Bk:B-km";
#elif ENABLE_FEATURE_HUMAN_READABLE
opt_complementary = "k-m:m-k";
#endif
opt = getopt32(argv, "kP"
IF_FEATURE_DF_FANCY("aiB:")
IF_FEATURE_HUMAN_READABLE("hm")
IF_FEATURE_DF_FANCY(, &chp));
if (opt & OPT_MEGA)
df_disp_hr = 1024*1024;
if (opt & OPT_BSIZE)
df_disp_hr = xatoul_range(chp, 1, ULONG_MAX); /* disallow 0 */
/* From the manpage of df from coreutils-6.10:
Disk space is shown in 1K blocks by default, unless the environment
variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
*/
if (getenv("POSIXLY_CORRECT")) /* TODO - a new libbb function? */
df_disp_hr = 512;
if (opt & OPT_HUMAN) {
df_disp_hr = 0;
disp_units_hdr = " Size";
}
if (opt & (1 << 2)) { // -m
df_disp_hr = 1024*1024;
disp_units_hdr = "1M-blocks";
}
if (opt & OPT_INODE) {
if (opt & OPT_INODE)
disp_units_hdr = " Inodes";
}
#else
opt = getopt32(argv, "ak" USE_FEATURE_DF_INODE("i"));
#endif
printf("Filesystem %-15sUsed Available Use%% Mounted on\n",
disp_units_hdr);
if (disp_units_hdr == NULL) {
#if ENABLE_FEATURE_HUMAN_READABLE
disp_units_hdr = xasprintf("%s-blocks",
make_human_readable_str(df_disp_hr, 0, !!(opt & OPT_POSIX)));
#else
disp_units_hdr = xasprintf("%lu-blocks", df_disp_hr);
#endif
}
printf("Filesystem %-15sUsed Available %s Mounted on\n",
disp_units_hdr, (opt & OPT_POSIX) ? "Capacity" : "Use%");
mount_table = NULL;
argv += optind;
if (optind >= argc) {
mount_table = setmntent(bb_path_mtab_file, "r");
if (!mount_table) {
if (!mount_table)
bb_perror_msg_and_die(bb_path_mtab_file);
}
}
while (1) {
@@ -93,13 +117,12 @@ int df_main(int argc, char **argv)
}
} else {
mount_point = *argv++;
if (!mount_point) {
if (!mount_point)
break;
}
mount_entry = find_mount_point(mount_point, bb_path_mtab_file);
mount_entry = find_mount_point(mount_point, 1);
if (!mount_entry) {
bb_error_msg("%s: can't find mount point", mount_point);
SET_ERROR:
set_error:
status = EXIT_FAILURE;
continue;
}
@@ -110,7 +133,7 @@ int df_main(int argc, char **argv)
if (statfs(mount_point, &s) != 0) {
bb_simple_perror_msg(mount_point);
goto SET_ERROR;
goto set_error;
}
if ((s.f_blocks > 0) || !mount_table || (opt & OPT_ALL)) {
@@ -118,10 +141,9 @@ int df_main(int argc, char **argv)
s.f_blocks = s.f_files;
s.f_bavail = s.f_bfree = s.f_ffree;
s.f_bsize = 1;
#if ENABLE_FEATURE_HUMAN_READABLE
if (df_disp_hr)
df_disp_hr = 1;
#endif
}
blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = 0;
@@ -131,11 +153,10 @@ int df_main(int argc, char **argv)
) / (blocks_used + s.f_bavail);
}
#ifdef WHY_IT_SHOULD_BE_HIDDEN
if (strcmp(device, "rootfs") == 0) {
/* GNU coreutils 6.10 skips certain mounts, try to be compatible. */
if (strcmp(device, "rootfs") == 0)
continue;
}
#endif
#ifdef WHY_WE_DO_IT_FOR_DEV_ROOT_ONLY
/* ... and also this is the only user of find_block_device */
if (strcmp(device, "/dev/root") == 0) {
@@ -143,7 +164,7 @@ int df_main(int argc, char **argv)
* or leaves device alone if it can't find it */
device = find_block_device("/");
if (!device) {
goto SET_ERROR;
goto set_error;
}
}
#endif
@@ -164,12 +185,12 @@ int df_main(int argc, char **argv)
#else
printf(" %9lu %9lu %9lu %3u%% %s\n",
kscale(s.f_blocks, s.f_bsize),
kscale(s.f_blocks-s.f_bfree, s.f_bsize),
kscale(s.f_blocks - s.f_bfree, s.f_bsize),
kscale(s.f_bavail, s.f_bsize),
blocks_percent_used, mount_point);
#endif
}
}
fflush_stdout_and_exit(status);
return status;
}
+39 -51
View File
@@ -25,19 +25,28 @@
#include "libbb.h"
enum {
OPT_a_files_too = (1 << 0),
OPT_H_follow_links = (1 << 1),
OPT_k_kbytes = (1 << 2),
OPT_L_follow_links = (1 << 3),
OPT_s_total_norecurse = (1 << 4),
OPT_x_one_FS = (1 << 5),
OPT_d_maxdepth = (1 << 6),
OPT_l_hardlinks = (1 << 7),
OPT_c_total = (1 << 8),
OPT_h_for_humans = (1 << 9),
OPT_m_mbytes = (1 << 10),
};
struct globals {
#if ENABLE_FEATURE_HUMAN_READABLE
unsigned long disp_hr;
#else
unsigned disp_k;
#endif
int max_print_depth;
nlink_t count_hardlinks;
bool status;
bool one_file_system;
int print_files;
int slink_depth;
int du_depth;
dev_t dir_dev;
@@ -72,7 +81,7 @@ static unsigned long du(const char *filename)
return 0;
}
if (G.one_file_system) {
if (option_mask32 & OPT_x_one_FS) {
if (G.du_depth == 0) {
G.dir_dev = statbuf.st_dev;
} else if (G.dir_dev != statbuf.st_dev) {
@@ -83,7 +92,7 @@ static unsigned long du(const char *filename)
sum = statbuf.st_blocks;
if (S_ISLNK(statbuf.st_mode)) {
if (G.slink_depth > G.du_depth) { /* -H or -L */
if (G.slink_depth > G.du_depth) { /* -H or -L */
if (stat(filename, &statbuf) != 0) {
bb_simple_perror_msg(filename);
G.status = EXIT_FAILURE;
@@ -91,12 +100,15 @@ static unsigned long du(const char *filename)
}
sum = statbuf.st_blocks;
if (G.slink_depth == 1) {
G.slink_depth = INT_MAX; /* Convert -H to -L. */
/* Convert -H to -L */
G.slink_depth = INT_MAX;
}
}
}
if (statbuf.st_nlink > G.count_hardlinks) {
if (!(option_mask32 & OPT_l_hardlinks)
&& statbuf.st_nlink > 1
) {
/* Add files/directories with links only once */
if (is_in_ino_dev_hashtable(&statbuf)) {
return 0;
@@ -115,14 +127,8 @@ static unsigned long du(const char *filename)
return sum;
}
newfile = last_char_is(filename, '/');
if (newfile)
*newfile = '\0';
while ((entry = readdir(dir))) {
char *name = entry->d_name;
newfile = concat_subpath_file(filename, name);
newfile = concat_subpath_file(filename, entry->d_name);
if (newfile == NULL)
continue;
++G.du_depth;
@@ -131,8 +137,9 @@ static unsigned long du(const char *filename)
free(newfile);
}
closedir(dir);
} else if (G.du_depth > G.print_files) {
return sum;
} else {
if (!(option_mask32 & OPT_a_files_too) && G.du_depth != 0)
return sum;
}
if (G.du_depth <= G.max_print_depth) {
print(sum, filename);
@@ -145,20 +152,18 @@ int du_main(int argc UNUSED_PARAM, char **argv)
{
unsigned long total;
int slink_depth_save;
bool print_final_total;
unsigned opt;
#if ENABLE_FEATURE_HUMAN_READABLE
USE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 1024;)
SKIP_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 512;)
IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 1024;)
IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_hr = 512;)
if (getenv("POSIXLY_CORRECT")) /* TODO - a new libbb function? */
G.disp_hr = 512;
#else
USE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_k = 1;)
/* SKIP_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_k = 0;) - G is pre-zeroed */
IF_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_k = 1;)
/* IF_NOT_FEATURE_DU_DEFAULT_BLOCKSIZE_1K(G.disp_k = 0;) - G is pre-zeroed */
#endif
G.max_print_depth = INT_MAX;
G.count_hardlinks = 1;
/* Note: SUSv3 specifies that -a and -s options cannot be used together
* in strictly conforming applications. However, it also says that some
@@ -170,16 +175,13 @@ int du_main(int argc UNUSED_PARAM, char **argv)
opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s:d+";
opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &G.max_print_depth);
argv += optind;
if (opt & (1 << 9)) {
/* -h opt */
if (opt & OPT_h_for_humans) {
G.disp_hr = 0;
}
if (opt & (1 << 10)) {
/* -m opt */
if (opt & OPT_m_mbytes) {
G.disp_hr = 1024*1024;
}
if (opt & (1 << 2)) {
/* -k opt */
if (opt & OPT_k_kbytes) {
G.disp_hr = 1024;
}
#else
@@ -187,34 +189,20 @@ int du_main(int argc UNUSED_PARAM, char **argv)
opt = getopt32(argv, "aHkLsx" "d:" "lc", &G.max_print_depth);
argv += optind;
#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
if (opt & (1 << 2)) {
/* -k opt */
if (opt & OPT_k_kbytes) {
G.disp_k = 1;
}
#endif
#endif
if (opt & (1 << 0)) {
/* -a opt */
G.print_files = INT_MAX;
}
if (opt & (1 << 1)) {
/* -H opt */
if (opt & OPT_H_follow_links) {
G.slink_depth = 1;
}
if (opt & (1 << 3)) {
/* -L opt */
if (opt & OPT_L_follow_links) {
G.slink_depth = INT_MAX;
}
if (opt & (1 << 4)) {
/* -s opt */
if (opt & OPT_s_total_norecurse) {
G.max_print_depth = 0;
}
G.one_file_system = opt & (1 << 5); /* -x opt */
if (opt & (1 << 7)) {
/* -l opt */
G.count_hardlinks = MAXINT(nlink_t);
}
print_final_total = opt & (1 << 8); /* -c opt */
/* go through remaining args (if any) */
if (!*argv) {
@@ -228,12 +216,12 @@ int du_main(int argc UNUSED_PARAM, char **argv)
total = 0;
do {
total += du(*argv);
/* otherwise du /dir /dir won't show /dir twice: */
reset_ino_dev_hashtable();
G.slink_depth = slink_depth_save;
} while (*++argv);
if (ENABLE_FEATURE_CLEAN_UP)
reset_ino_dev_hashtable();
if (print_final_total)
if (opt & OPT_c_total)
print(total, "total");
fflush_stdout_and_exit(G.status);
+12 -10
View File
@@ -29,6 +29,8 @@
* - use xfunc_error_retval
*/
/* This is a NOEXEC applet. Be very careful! */
#include "libbb.h"
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
@@ -41,8 +43,6 @@ static const char env_longopts[] ALIGN1 =
int env_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int env_main(int argc UNUSED_PARAM, char **argv)
{
/* cleanenv was static - why? */
char *cleanenv[1];
char **ep;
unsigned opt;
llist_t *unset_env = NULL;
@@ -58,12 +58,16 @@ int env_main(int argc UNUSED_PARAM, char **argv)
++argv;
}
if (opt & 1) {
cleanenv[0] = NULL;
environ = cleanenv;
} else {
while (unset_env) {
unsetenv(llist_pop(&unset_env));
}
clearenv();
}
while (unset_env) {
char *var = llist_pop(&unset_env);
/* This does not handle -uVAR=VAL
* (coreutils _sets_ the variable in that case): */
/*unsetenv(var);*/
/* This does, but uses somewhan undocumented feature that
* putenv("name_without_equal_sign") unsets the variable: */
putenv(var);
}
while (*argv && (strchr(*argv, '=') != NULL)) {
@@ -119,5 +123,3 @@ int env_main(int argc UNUSED_PARAM, char **argv)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+54 -74
View File
@@ -29,98 +29,78 @@ enum {
OPT_ALL = 1 << 2,
};
static void xputchar(char c)
{
if (putchar(c) < 0)
bb_error_msg_and_die(bb_msg_write_error);
}
#if ENABLE_EXPAND
static void expand(FILE *file, unsigned tab_size, unsigned opt)
static void expand(FILE *file, int tab_size, unsigned opt)
{
char *line;
char *ptr;
int convert;
unsigned pos;
/* Increment tab_size by 1 locally.*/
tab_size++;
tab_size = -tab_size;
while ((line = xmalloc_fgets(file)) != NULL) {
convert = 1;
pos = 0;
ptr = line;
while (*line) {
pos++;
if (*line == '\t' && convert) {
for (; pos < tab_size; pos++) {
xputchar(' ');
}
} else {
if ((opt & OPT_INITIAL) && !isblank(*line)) {
convert = 0;
}
xputchar(*line);
int pos;
unsigned char c;
char *ptr = line;
goto start;
while ((c = *ptr) != '\0') {
if ((opt & OPT_INITIAL) && !isblank(c)) {
fputs(ptr, stdout);
break;
}
if (pos == tab_size) {
pos = 0;
ptr++;
if (c == '\t') {
c = ' ';
while (++pos < 0)
bb_putchar(c);
}
bb_putchar(c);
if (++pos >= 0) {
start:
pos = tab_size;
}
line++;
}
free(ptr);
free(line);
}
}
#endif
#if ENABLE_UNEXPAND
static void unexpand(FILE *file, unsigned int tab_size, unsigned opt)
static void unexpand(FILE *file, unsigned tab_size, unsigned opt)
{
char *line;
char *ptr;
int convert;
int pos;
int i = 0;
unsigned column = 0;
while ((line = xmalloc_fgets(file)) != NULL) {
convert = 1;
pos = 0;
ptr = line;
while (*line) {
while ((*line == ' ' || *line == '\t') && convert) {
pos += (*line == ' ') ? 1 : tab_size;
line++;
char *ptr = line;
unsigned column = 0;
while (*ptr) {
unsigned n;
while (*ptr == ' ') {
column++;
if ((opt & OPT_ALL) && column == tab_size) {
column = 0;
goto put_tab;
}
ptr++;
}
if (pos) {
i = pos / tab_size;
if (i) {
for (; i > 0; i--) {
put_tab:
xputchar('\t');
}
} else {
for (i = pos % tab_size; i > 0; i--) {
xputchar(' ');
}
}
pos = 0;
} else {
if (opt & OPT_INITIAL) {
convert = 0;
}
if (opt & OPT_ALL) {
column++;
}
xputchar(*line);
line++;
if (*ptr == '\t') {
column += tab_size - (column % tab_size);
ptr++;
continue;
}
n = column / tab_size;
column = column % tab_size;
while (n--)
putchar('\t');
if ((opt & OPT_INITIAL) && ptr != line) {
printf("%*s%s", column, "", ptr);
break;
}
n = strcspn(ptr, "\t ");
printf("%*s%.*s", column, "", n, ptr);
ptr += n;
column = (column + n) % tab_size;
}
free(ptr);
free(line);
}
}
#endif
@@ -152,10 +132,10 @@ int expand_main(int argc UNUSED_PARAM, char **argv)
#endif
if (ENABLE_EXPAND && (!ENABLE_UNEXPAND || applet_name[0] == 'e')) {
USE_FEATURE_EXPAND_LONG_OPTIONS(applet_long_options = expand_longopts);
IF_FEATURE_EXPAND_LONG_OPTIONS(applet_long_options = expand_longopts);
opt = getopt32(argv, "it:", &opt_t);
} else {
USE_FEATURE_UNEXPAND_LONG_OPTIONS(applet_long_options = unexpand_longopts);
IF_FEATURE_UNEXPAND_LONG_OPTIONS(applet_long_options = unexpand_longopts);
/* -t NUM sets also -a */
opt_complementary = "ta";
opt = getopt32(argv, "ft:a", &opt_t);
@@ -177,9 +157,9 @@ int expand_main(int argc UNUSED_PARAM, char **argv)
}
if (ENABLE_EXPAND && (!ENABLE_UNEXPAND || applet_name[0] == 'e'))
USE_EXPAND(expand(file, tab_size, opt));
IF_EXPAND(expand(file, tab_size, opt));
else
USE_UNEXPAND(unexpand(file, tab_size, opt));
IF_UNEXPAND(unexpand(file, tab_size, opt));
/* Check and close the file */
if (fclose_if_not_stdin(file)) {
+10 -13
View File
@@ -223,13 +223,13 @@ static VALUE *docolon(VALUE *sv, VALUE *pv)
tostring(pv);
if (pv->u.s[0] == '^') {
bb_error_msg("\
warning: unportable BRE: `%s': using `^' as the first character\n\
of a basic regular expression is not portable; it is being ignored", pv->u.s);
bb_error_msg(
"warning: '%s': using '^' as the first character\n"
"of a basic regular expression is not portable; it is ignored", pv->u.s);
}
memset(&re_buffer, 0, sizeof(re_buffer));
memset(re_regs, 0, sizeof(*re_regs));
memset(re_regs, 0, sizeof(re_regs));
xregcomp(&re_buffer, pv->u.s, 0);
/* expr uses an anchored pattern match, so check that there was a
@@ -238,7 +238,7 @@ of a basic regular expression is not portable; it is being ignored", pv->u.s);
&& re_regs[0].rm_so == 0
) {
/* Were \(...\) used? */
if (re_buffer.re_nsub > 0) {
if (re_buffer.re_nsub > 0 && re_regs[1].rm_so >= 0) {
sv->u.s[re_regs[1].rm_eo] = '\0';
v = str_value(sv->u.s + re_regs[1].rm_so);
} else {
@@ -251,7 +251,7 @@ of a basic regular expression is not portable; it is being ignored", pv->u.s);
else
v = int_value(0);
}
//FIXME: sounds like here is a bit missing: regfree(&re_buffer);
regfree(&re_buffer);
return v;
}
@@ -481,24 +481,21 @@ static VALUE *eval(void)
}
int expr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int expr_main(int argc, char **argv)
int expr_main(int argc UNUSED_PARAM, char **argv)
{
VALUE *v;
if (argc == 1) {
xfunc_error_retval = 2; /* coreutils compat */
G.args = argv + 1;
if (*G.args == NULL) {
bb_error_msg_and_die("too few arguments");
}
G.args = argv + 1;
v = eval();
if (*G.args)
bb_error_msg_and_die("syntax error");
if (v->type == INTEGER)
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
else
puts(v->u.s);
fflush_stdout_and_exit(null(v));
}
+41
View File
@@ -0,0 +1,41 @@
/* vi: set sw=4 ts=4: */
/*
* Mini fsync implementation for busybox
*
* Copyright (C) 2008 Nokia Corporation. All rights reserved.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
int fsync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int fsync_main(int argc UNUSED_PARAM, char **argv)
{
int status;
int opts;
opts = getopt32(argv, "d"); /* fdatasync */
argv += optind;
if (!*argv) {
bb_show_usage();
}
status = EXIT_SUCCESS;
do {
int fd = open3_or_warn(*argv, O_NOATIME | O_NOCTTY | O_RDONLY, 0);
if (fd == -1) {
status = EXIT_FAILURE;
continue;
}
if ((opts ? fdatasync(fd) : fsync(fd))) {
//status = EXIT_FAILURE; - do we want this?
bb_simple_perror_msg(*argv);
}
close(fd);
} while (*++argv);
return status;
}
+4 -4
View File
@@ -40,7 +40,6 @@ int head_main(int argc, char **argv)
int count_bytes = 0;
int header_threshhold = 1;
#endif
FILE *fp;
const char *fmt;
char *p;
@@ -50,7 +49,7 @@ int head_main(int argc, char **argv)
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
/* Allow legacy syntax of an initial numeric option without -n. */
if (argc > 1 && argv[1][0] == '-'
if (argv[1] && argv[1][0] == '-'
&& isdigit(argv[1][1])
) {
--argc;
@@ -79,7 +78,6 @@ int head_main(int argc, char **argv)
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
GET_COUNT:
#endif
#if !ENABLE_FEATURE_FANCY_HEAD
count = xatoul(p);
#else
@@ -128,10 +126,12 @@ int head_main(int argc, char **argv)
putchar(c);
}
if (fclose_if_not_stdin(fp)) {
bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
bb_simple_perror_msg(*argv);
retval = EXIT_FAILURE;
}
die_if_ferror_stdout();
} else {
retval = EXIT_FAILURE;
}
fmt = header_fmt_str;
} while (*++argv);
+171 -83
View File
@@ -3,124 +3,212 @@
* Mini id implementation for busybox
*
* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
* Copyright (C) 2008 by Tito Ragusa <farmatito@tiscali.it>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* BB_AUDIT SUSv3 _NOT_ compliant -- option -G is not currently supported. */
/* Hacked by Tito Ragusa (C) 2004 to handle usernames of whatever length and to
* be more similar to GNU id.
/* BB_AUDIT SUSv3 compliant. */
/* Hacked by Tito Ragusa (C) 2004 to handle usernames of whatever
* length and to be more similar to GNU id.
* -Z option support: by Yuichi Nakamura <ynakam@hitachisoft.jp>
* Added -G option Tito Ragusa (C) 2008 for SUSv3.
*/
#include "libbb.h"
#define PRINT_REAL 1
#define NAME_NOT_NUMBER 2
#define JUST_USER 4
#define JUST_GROUP 8
#if ENABLE_SELINUX
#define JUST_CONTEXT 16
#if !ENABLE_USE_BB_PWD_GRP
#if defined(__UCLIBC_MAJOR__) && (__UCLIBC_MAJOR__ == 0)
#if (__UCLIBC_MINOR__ < 9) || (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 30)
#error "Sorry, you need at least uClibc version 0.9.30 for id applet to build"
#endif
#endif
#endif
static int printf_full(unsigned int id, const char *arg, const char prefix)
{
const char *fmt = "%cid=%u";
int status = EXIT_FAILURE;
enum {
PRINT_REAL = (1 << 0),
NAME_NOT_NUMBER = (1 << 1),
JUST_USER = (1 << 2),
JUST_GROUP = (1 << 3),
JUST_ALL_GROUPS = (1 << 4),
#if ENABLE_SELINUX
JUST_CONTEXT = (1 << 5),
#endif
};
if (arg) {
fmt = "%cid=%u(%s)";
status = EXIT_SUCCESS;
static int print_common(unsigned id, const char *name, const char *prefix)
{
if (prefix) {
printf("%s", prefix);
}
printf(fmt, prefix, id, arg);
return status;
if (!(option_mask32 & NAME_NOT_NUMBER) || !name) {
printf("%u", id);
}
if (!option_mask32 || (option_mask32 & NAME_NOT_NUMBER)) {
if (name) {
printf(option_mask32 ? "%s" : "(%s)", name);
} else {
/* Don't set error status flag in default mode */
if (option_mask32) {
if (ENABLE_DESKTOP)
bb_error_msg("unknown ID %u", id);
return EXIT_FAILURE;
}
}
}
return EXIT_SUCCESS;
}
static int print_group(gid_t id, const char *prefix)
{
return print_common(id, gid2group(id), prefix);
}
static int print_user(uid_t id, const char *prefix)
{
return print_common(id, uid2uname(id), prefix);
}
/* On error set *n < 0 and return >= 0
* If *n is too small, update it and return < 0
* (ok to trash groups[] in both cases)
* Otherwise fill in groups[] and return >= 0
*/
static int get_groups(const char *username, gid_t rgid, gid_t *groups, int *n)
{
int m;
if (username) {
/* If the user is a member of more than
* *n groups, then -1 is returned. Otherwise >= 0.
* (and no defined way of detecting errors?!) */
m = getgrouplist(username, rgid, groups, n);
/* I guess *n < 0 might indicate error. Anyway,
* malloc'ing -1 bytes won't be good, so: */
//if (*n < 0)
// return 0;
//return m;
//commented out here, happens below anyway
} else {
/* On error -1 is returned, which ends up in *n */
int nn = getgroups(*n, groups);
/* 0: nn <= *n, groups[] was big enough; -1 otherwise */
m = - (nn > *n);
*n = nn;
}
if (*n < 0)
return 0; /* error, don't return < 0! */
return m;
}
int id_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int id_main(int argc UNUSED_PARAM, char **argv)
{
struct passwd *p;
uid_t uid;
gid_t gid;
unsigned long flags;
short status;
uid_t ruid;
gid_t rgid;
uid_t euid;
gid_t egid;
unsigned opt;
int i;
int status = EXIT_SUCCESS;
const char *prefix;
const char *username;
#if ENABLE_SELINUX
security_context_t scontext;
security_context_t scontext = NULL;
#endif
/* Don't allow -n -r -nr -ug -rug -nug -rnug */
/* Don't allow -n -r -nr -ug -rug -nug -rnug -uZ -gZ -GZ*/
/* Don't allow more than one username */
opt_complementary = "?1:u--g:g--u:r?ug:n?ug" USE_SELINUX(":u--Z:Z--u:g--Z:Z--g");
flags = getopt32(argv, "rnug" USE_SELINUX("Z"));
opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG"
IF_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
opt = getopt32(argv, "rnugG" IF_SELINUX("Z"));
/* This values could be overwritten later */
uid = geteuid();
gid = getegid();
if (flags & PRINT_REAL) {
uid = getuid();
gid = getgid();
username = argv[optind];
if (username) {
struct passwd *p = xgetpwnam(username);
euid = ruid = p->pw_uid;
egid = rgid = p->pw_gid;
} else {
egid = getegid();
rgid = getgid();
euid = geteuid();
ruid = getuid();
}
/* JUST_ALL_GROUPS ignores -r PRINT_REAL flag even if man page for */
/* id says: print the real ID instead of the effective ID, with -ugG */
/* in fact in this case egid is always printed if egid != rgid */
if (!opt || (opt & JUST_ALL_GROUPS)) {
gid_t *groups;
int n;
if (argv[optind]) {
p = getpwnam(argv[optind]);
/* xuname2uid is needed because it exits on failure */
uid = xuname2uid(argv[optind]);
gid = p->pw_gid;
/* in this case PRINT_REAL is the same */
}
if (flags & (JUST_GROUP | JUST_USER USE_SELINUX(| JUST_CONTEXT))) {
/* JUST_GROUP and JUST_USER are mutually exclusive */
if (flags & NAME_NOT_NUMBER) {
/* bb_getXXXid(-1) exit on failure, puts cannot segfault */
puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid));
if (!opt) {
/* Default Mode */
status |= print_user(ruid, "uid=");
status |= print_group(rgid, " gid=");
if (euid != ruid)
status |= print_user(euid, " euid=");
if (egid != rgid)
status |= print_group(egid, " egid=");
} else {
if (flags & JUST_USER) {
printf("%u\n", uid);
}
if (flags & JUST_GROUP) {
printf("%u\n", gid);
}
/* JUST_ALL_GROUPS */
status |= print_group(rgid, NULL);
if (egid != rgid)
status |= print_group(egid, " ");
}
/* We are supplying largish buffer, trying
* to not run get_groups() twice. That might be slow
* ("user database in remote SQL server" case) */
groups = xmalloc(64 * sizeof(gid_t));
n = 64;
if (get_groups(username, rgid, groups, &n) < 0) {
/* Need bigger buffer after all */
groups = xrealloc(groups, n * sizeof(gid_t));
get_groups(username, rgid, groups, &n);
}
if (n > 0) {
/* Print the list */
prefix = " groups=";
for (i = 0; i < n; i++) {
if (opt && (groups[i] == rgid || groups[i] == egid))
continue;
status |= print_group(groups[i], opt ? " " : prefix);
prefix = ",";
}
} else if (n < 0) { /* error in get_groups() */
if (!ENABLE_DESKTOP)
bb_error_msg_and_die("cannot get groups");
else
return EXIT_FAILURE;
}
if (ENABLE_FEATURE_CLEAN_UP)
free(groups);
#if ENABLE_SELINUX
if (flags & JUST_CONTEXT) {
selinux_or_die();
if (argc - optind == 1) {
bb_error_msg_and_die("user name can't be passed with -Z");
}
if (getcon(&scontext)) {
bb_error_msg_and_die("can't get process context");
}
puts(scontext);
if (is_selinux_enabled()) {
if (getcon(&scontext) == 0)
printf(" context=%s", scontext);
}
#endif
/* exit */
fflush_stdout_and_exit(EXIT_SUCCESS);
} else if (opt & PRINT_REAL) {
euid = ruid;
egid = rgid;
}
/* Print full info like GNU id */
/* bb_getpwuid(0) doesn't exit on failure (returns NULL) */
status = printf_full(uid, bb_getpwuid(NULL, 0, uid), 'u');
bb_putchar(' ');
status |= printf_full(gid, bb_getgrgid(NULL, 0, gid), 'g');
if (opt & JUST_USER)
status |= print_user(euid, NULL);
else if (opt & JUST_GROUP)
status |= print_group(egid, NULL);
#if ENABLE_SELINUX
if (is_selinux_enabled()) {
security_context_t mysid;
const char *context;
context = "unknown";
getcon(&mysid);
if (mysid) {
context = alloca(strlen(mysid) + 1);
strcpy((char*)context, mysid);
freecon(mysid);
else if (opt & JUST_CONTEXT) {
selinux_or_die();
if (username || getcon(&scontext)) {
bb_error_msg_and_die("can't get process context%s",
username ? " for a different user" : "");
}
printf(" context=%s", context);
fputs(scontext, stdout);
}
/* freecon(NULL) seems to be harmless */
if (ENABLE_FEATURE_CLEAN_UP)
freecon(scontext);
#endif
bb_putchar('\n');
fflush_stdout_and_exit(status);
}
+244
View File
@@ -0,0 +1,244 @@
#!/bin/bash
# Test script for busybox id vs. coreutils id.
# Needs root privileges for some tests.
cp /usr/bin/id .
BUSYBOX=./busybox
ID=./id
LIST=`awk -F: '{ printf "%s\n", $1 }' /etc/passwd`
FLAG_USER_EXISTS="no"
TEST_USER="f583ca884c1d93458fb61ed137ff44f6"
echo "test 1: id [options] nousername"
rm -f foo bar
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
do
#echo "$OPTIONS"
$BUSYBOX id $OPTIONS >foo 2>/dev/null
RET1=$?
$ID $OPTIONS >bar 2>/dev/null
RET2=$?
if test "$RET1" != "$RET2"; then
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
fi
diff foo bar
done
echo "test 2: id [options] username"
rm -f foo bar
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
do
#echo "$OPTIONS"
for i in $LIST ; do
if test "$i" = "$TEST_USER"; then
FLAG_USER_EXISTS="yes"
fi
$BUSYBOX id $OPTIONS $i >foo 2>/dev/null
RET1=$?
$ID $OPTIONS $i >bar 2>/dev/null
RET2=$?
if test "$RET1" != "$RET2"; then
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
fi
diff foo bar
done
done
if test $FLAG_USER_EXISTS = "yes"; then
echo "test 3,4,5,6,7,8,9,10,11,12 skipped because test user $TEST_USER already exists"
rm -f foo bar
exit 1
fi
adduser -s /bin/true -g "" -H -D "$TEST_USER" || exit 1
chown $TEST_USER.$TEST_USER $BUSYBOX
chmod u+s $BUSYBOX 2>&1 /dev/null
chown $TEST_USER.$TEST_USER $ID
chmod u+s $ID 2>&1 /dev/null
echo "test 3 setuid, existing user: id [options] no username"
rm -f foo bar
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
do
#echo "$OPTIONS"
$BUSYBOX id $OPTIONS >foo 2>/dev/null
RET1=$?
$ID $OPTIONS >bar 2>/dev/null
RET2=$?
if test "$RET1" != "$RET2"; then
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
fi
diff foo bar
#done
done
echo "test 4 setuid, existing user: id [options] username"
rm -f foo bar
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
do
#echo "$OPTIONS"
for i in $LIST ; do
$BUSYBOX id $OPTIONS $i >foo 2>/dev/null
RET1=$?
$ID $OPTIONS $i >bar 2>/dev/null
RET2=$?
if test "$RET1" != "$RET2"; then
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
fi
diff foo bar
done
done
chown $TEST_USER.$TEST_USER $BUSYBOX
chmod g+s $BUSYBOX 2>&1 /dev/null
chown $TEST_USER.$TEST_USER $ID
chmod g+s $ID 2>&1 /dev/null
echo "test 5 setgid, existing user: id [options] no username"
rm -f foo bar
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
do
#echo "$OPTIONS"
$BUSYBOX id $OPTIONS >foo 2>/dev/null
RET1=$?
$ID $OPTIONS >bar 2>/dev/null
RET2=$?
if test "$RET1" != "$RET2"; then
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
fi
diff foo bar
#done
done
echo "test 6 setgid, existing user: id [options] username"
rm -f foo bar
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
do
#echo "$OPTIONS"
for i in $LIST ; do
$BUSYBOX id $OPTIONS $i >foo 2>/dev/null
RET1=$?
$ID $OPTIONS $i >bar 2>/dev/null
RET2=$?
if test "$RET1" != "$RET2"; then
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
fi
diff foo bar
done
done
chown $TEST_USER.$TEST_USER $BUSYBOX
chmod u+s,g+s $BUSYBOX 2>&1 /dev/null
chown $TEST_USER.$TEST_USER $ID
chmod u+s,g+s $ID 2>&1 /dev/null
echo "test 7 setuid, setgid, existing user: id [options] no username"
rm -f foo bar
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
do
#echo "$OPTIONS"
$BUSYBOX id $OPTIONS >foo 2>/dev/null
RET1=$?
$ID $OPTIONS >bar 2>/dev/null
RET2=$?
if test "$RET1" != "$RET2"; then
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
fi
diff foo bar
#done
done
echo "test 8 setuid, setgid, existing user: id [options] username"
rm -f foo bar
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
do
#echo "$OPTIONS"
for i in $LIST ; do
$BUSYBOX id $OPTIONS $i >foo 2>/dev/null
RET1=$?
$ID $OPTIONS $i >bar 2>/dev/null
RET2=$?
if test "$RET1" != "$RET2"; then
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
fi
diff foo bar
done
done
deluser $TEST_USER || exit 1
echo "test 9 setuid, setgid, not existing user: id [options] no username"
rm -f foo bar
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
do
#echo "$OPTIONS"
$BUSYBOX id $OPTIONS >foo 2>/dev/null
RET1=$?
$ID $OPTIONS >bar 2>/dev/null
RET2=$?
if test "$RET1" != "$RET2"; then
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
fi
diff foo bar
done
echo "test 10 setuid, setgid, not existing user: id [options] username"
rm -f foo bar
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
do
#echo "$OPTIONS"
for i in $LIST ; do
$BUSYBOX id $OPTIONS $i >foo 2>/dev/null
RET1=$?
$ID $OPTIONS $i >bar 2>/dev/null
RET2=$?
if test "$RET1" != "$RET2"; then
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
fi
diff foo bar
done
done
chown .root $BUSYBOX 2>&1 /dev/null
chown .root $ID 2>&1 /dev/null
chmod g+s $BUSYBOX 2>&1 /dev/null
chmod g+s $ID 2>&1 /dev/null
echo "test 11 setgid, not existing group: id [options] no username"
rm -f foo bar
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
do
#echo "$OPTIONS"
$BUSYBOX id $OPTIONS >foo 2>/dev/null
RET1=$?
$ID $OPTIONS >bar 2>/dev/null
RET2=$?
if test "$RET1" != "$RET2"; then
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
fi
diff foo bar
#done
done
echo "test 12 setgid, not existing group: id [options] username"
rm -f foo bar
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
do
#echo "$OPTIONS"
for i in $LIST ; do
$BUSYBOX id $OPTIONS $i >foo 2>/dev/null
RET1=$?
$ID $OPTIONS $i >bar 2>/dev/null
RET2=$?
if test "$RET1" != "$RET2"; then
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
fi
diff foo bar
done
done
chown root.root $BUSYBOX 2>&1 /dev/null
chown root.root $ID 2>&1 /dev/null
rm -f $ID
rm -f foo bar
+39 -31
View File
@@ -4,9 +4,6 @@
* SELinux support: by Yuichi Nakamura <ynakam@hitachisoft.jp>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* TODO: -d option, need a way of recursively making directories and changing
* owner/group, will probably modify bb_make_directory(...)
*/
#include "libbb.h"
@@ -53,7 +50,8 @@ static void setdefaultfilecon(const char *path)
if (lsetfilecon(path, scontext) < 0) {
if (errno != ENOTSUP) {
bb_perror_msg("warning: failed to change context of %s to %s", path, scontext);
bb_perror_msg("warning: failed to change context"
" of %s to %s", path, scontext);
}
}
@@ -75,7 +73,7 @@ int install_main(int argc, char **argv)
const char *uid_str;
const char *mode_str;
int copy_flags = FILEUTILS_DEREFERENCE | FILEUTILS_FORCE;
int flags;
int opts;
int min_args = 1;
int ret = EXIT_SUCCESS;
int isdir = 0;
@@ -87,56 +85,58 @@ int install_main(int argc, char **argv)
OPT_c = 1 << 0,
OPT_v = 1 << 1,
OPT_b = 1 << 2,
OPT_DIRECTORY = 1 << 3,
OPT_PRESERVE_TIME = 1 << 4,
OPT_STRIP = 1 << 5,
OPT_GROUP = 1 << 6,
OPT_MODE = 1 << 7,
OPT_OWNER = 1 << 8,
OPT_MKDIR_LEADING = 1 << 3,
OPT_DIRECTORY = 1 << 4,
OPT_PRESERVE_TIME = 1 << 5,
OPT_STRIP = 1 << 6,
OPT_GROUP = 1 << 7,
OPT_MODE = 1 << 8,
OPT_OWNER = 1 << 9,
#if ENABLE_SELINUX
OPT_SET_SECURITY_CONTEXT = 1 << 9,
OPT_PRESERVE_SECURITY_CONTEXT = 1 << 10,
OPT_SET_SECURITY_CONTEXT = 1 << 10,
OPT_PRESERVE_SECURITY_CONTEXT = 1 << 11,
#endif
};
#if ENABLE_FEATURE_INSTALL_LONG_OPTIONS
applet_long_options = install_longopts;
#endif
opt_complementary = "s--d:d--s" USE_SELINUX(":Z--\xff:\xff--Z");
opt_complementary = "s--d:d--s" IF_SELINUX(":Z--\xff:\xff--Z");
/* -c exists for backwards compatibility, it's needed */
/* -v is ignored ("print name of each created directory") */
/* -b is ignored ("make a backup of each existing destination file") */
flags = getopt32(argv, "cvb" "dpsg:m:o:" USE_SELINUX("Z:"),
&gid_str, &mode_str, &uid_str USE_SELINUX(, &scontext));
opts = getopt32(argv, "cvb" "Ddpsg:m:o:" IF_SELINUX("Z:"),
&gid_str, &mode_str, &uid_str IF_SELINUX(, &scontext));
argc -= optind;
argv += optind;
#if ENABLE_SELINUX
if (flags & (OPT_PRESERVE_SECURITY_CONTEXT|OPT_SET_SECURITY_CONTEXT)) {
if (opts & (OPT_PRESERVE_SECURITY_CONTEXT|OPT_SET_SECURITY_CONTEXT)) {
selinux_or_die();
use_default_selinux_context = 0;
if (flags & OPT_PRESERVE_SECURITY_CONTEXT) {
if (opts & OPT_PRESERVE_SECURITY_CONTEXT) {
copy_flags |= FILEUTILS_PRESERVE_SECURITY_CONTEXT;
}
if (flags & OPT_SET_SECURITY_CONTEXT) {
if (opts & OPT_SET_SECURITY_CONTEXT) {
setfscreatecon_or_die(scontext);
copy_flags |= FILEUTILS_SET_SECURITY_CONTEXT;
}
}
#endif
/* preserve access and modification time, this is GNU behaviour, BSD only preserves modification time */
if (flags & OPT_PRESERVE_TIME) {
/* preserve access and modification time, this is GNU behaviour,
* BSD only preserves modification time */
if (opts & OPT_PRESERVE_TIME) {
copy_flags |= FILEUTILS_PRESERVE_STATUS;
}
mode = 0666;
if (flags & OPT_MODE)
mode = 0755; /* GNU coreutils 6.10 compat */
if (opts & OPT_MODE)
bb_parse_mode(mode_str, &mode);
uid = (flags & OPT_OWNER) ? get_ug_id(uid_str, xuname2uid) : getuid();
gid = (flags & OPT_GROUP) ? get_ug_id(gid_str, xgroup2gid) : getgid();
uid = (opts & OPT_OWNER) ? get_ug_id(uid_str, xuname2uid) : getuid();
gid = (opts & OPT_GROUP) ? get_ug_id(gid_str, xgroup2gid) : getgid();
last = argv[argc - 1];
if (!(flags & OPT_DIRECTORY)) {
if (!(opts & OPT_DIRECTORY)) {
argv[argc - 1] = NULL;
min_args++;
@@ -149,7 +149,7 @@ int install_main(int argc, char **argv)
while ((arg = *argv++) != NULL) {
char *dest = last;
if (flags & OPT_DIRECTORY) {
if (opts & OPT_DIRECTORY) {
dest = arg;
/* GNU coreutils 6.9 does not set uid:gid
* on intermediate created directories
@@ -159,6 +159,13 @@ int install_main(int argc, char **argv)
goto next;
}
} else {
if (opts & OPT_MKDIR_LEADING) {
char *ddir = xstrdup(dest);
bb_make_directory(dirname(ddir), 0755, FILEUTILS_RECUR);
/* errors are not checked. copy_file
* will fail if dir is not created. */
free(ddir);
}
if (isdir)
dest = concat_path_file(last, basename(arg));
if (copy_file(arg, dest, copy_flags)) {
@@ -168,8 +175,9 @@ int install_main(int argc, char **argv)
}
}
/* Set the file mode */
if ((flags & OPT_MODE) && chmod(dest, mode) == -1) {
/* Set the file mode (always, not only with -m).
* GNU coreutils 6.10 is not affected by umask. */
if (chmod(dest, mode) == -1) {
bb_perror_msg("can't change %s of %s", "permissions", dest);
ret = EXIT_FAILURE;
}
@@ -178,13 +186,13 @@ int install_main(int argc, char **argv)
setdefaultfilecon(dest);
#endif
/* Set the user and group id */
if ((flags & (OPT_OWNER|OPT_GROUP))
if ((opts & (OPT_OWNER|OPT_GROUP))
&& lchown(dest, uid, gid) == -1
) {
bb_perror_msg("can't change %s of %s", "ownership", dest);
ret = EXIT_FAILURE;
}
if (flags & OPT_STRIP) {
if (opts & OPT_STRIP) {
char *args[3];
args[0] = (char*)"strip";
args[1] = dest;
+3
View File
@@ -1,4 +1,7 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2, see file LICENSE in this tarball for details.
*/
/* BB_AUDIT SUSv3 N/A -- Apparently a busybox (obsolete?) extension. */
+3 -7
View File
@@ -4,11 +4,9 @@
*/
#ifndef COREUTILS_H
#define COREUTILS_H 1
#define COREUTILS_H 1
#if __GNUC_PREREQ(4,1)
# pragma GCC visibility push(hidden)
#endif
PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
typedef int (*stat_func)(const char *fn, struct stat *ps);
@@ -17,8 +15,6 @@ int cp_mv_stat(const char *fn, struct stat *fn_stat) FAST_FUNC;
mode_t getopt_mk_fifo_nod(char **argv) FAST_FUNC;
#if __GNUC_PREREQ(4,1)
# pragma GCC visibility pop
#endif
POP_SAVED_FUNCTION_VISIBILITY
#endif
+1 -1
View File
@@ -31,7 +31,7 @@ mode_t FAST_FUNC getopt_mk_fifo_nod(char **argv)
security_context_t scontext;
#endif
int opt;
opt = getopt32(argv, "m:" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
opt = getopt32(argv, "m:" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext));
if (opt & 1) {
if (bb_parse_mode(smode, &mode))
umask(0);
+339 -258
View File
@@ -6,7 +6,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/*
/* [date unknown. Perhaps before year 2000]
* To achieve a small memory footprint, this version of 'ls' doesn't do any
* file sorting, and only has the most essential command line switches
* (i.e., the ones I couldn't live without :-) All features which involve
@@ -18,8 +18,7 @@
*
* KNOWN BUGS:
* 1. ls -l of a directory doesn't give "total <blocks>" header
* 2. ls of a symlink to a directory doesn't list directory contents
* 3. hidden files can make column width too large
* 2. hidden files can make column width too large
*
* NON-OPTIMAL BEHAVIOUR:
* 1. autowidth reads directories twice
@@ -27,17 +26,32 @@
* appended, there's no need to stat each one
* PORTABILITY:
* 1. requires lstat (BSD) - how do you do it without?
*
* [2009-03]
* ls sorts listing now, and supports almost all options.
*/
#include "libbb.h"
#include "unicode.h"
#if ENABLE_FEATURE_ASSUME_UNICODE
#include <wchar.h>
#endif
/* This is a NOEXEC applet. Be very careful! */
#if ENABLE_FTPD
/* ftpd uses ls, and without timestamps Mozilla won't understand
* ftpd's LIST output.
*/
# undef CONFIG_FEATURE_LS_TIMESTAMPS
# undef ENABLE_FEATURE_LS_TIMESTAMPS
# undef IF_FEATURE_LS_TIMESTAMPS
# undef IF_NOT_FEATURE_LS_TIMESTAMPS
# define CONFIG_FEATURE_LS_TIMESTAMPS 1
# define ENABLE_FEATURE_LS_TIMESTAMPS 1
# define IF_FEATURE_LS_TIMESTAMPS(...) __VA_ARGS__
# define IF_NOT_FEATURE_LS_TIMESTAMPS(...)
#endif
enum {
TERMINAL_WIDTH = 80, /* use 79 if terminal has linefold bug */
@@ -59,7 +73,7 @@ LIST_ID_NAME = 1 << 4,
LIST_ID_NUMERIC = 1 << 5,
LIST_CONTEXT = 1 << 6,
LIST_SIZE = 1 << 7,
LIST_DEV = 1 << 8,
//LIST_DEV = 1 << 8, - unused, synonym to LIST_SIZE
LIST_DATE_TIME = 1 << 9,
LIST_FULLTIME = 1 << 10,
LIST_FILENAME = 1 << 11,
@@ -110,13 +124,111 @@ SPLIT_SUBDIR = 2,
};
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)])
#define COLOR(mode) ("\000\043\043\043\042\000\043\043"\
"\000\000\044\000\043\000\000\040" [TYPEINDEX(mode)])
#define ATTR(mode) ("\00\00\01\00\01\00\01\00"\
"\00\00\01\00\01\00\00\01" [TYPEINDEX(mode)])
/* "[-]Cadil1", POSIX mandated options, busybox always supports */
/* "[-]gnsx", POSIX non-mandated options, busybox always supports */
/* "[-]Q" GNU option? busybox always supports */
/* "[-]Ak" GNU options, busybox always supports */
/* "[-]FLRctur", POSIX mandated options, busybox optionally supports */
/* "[-]p", POSIX non-mandated options, busybox optionally supports */
/* "[-]SXvThw", GNU options, busybox optionally supports */
/* "[-]K", SELinux mandated options, busybox optionally supports */
/* "[-]e", I think we made this one up */
static const char ls_options[] ALIGN1 =
"Cadil1gnsxQAk" /* 13 opts, total 13 */
IF_FEATURE_LS_TIMESTAMPS("cetu") /* 4, 17 */
IF_FEATURE_LS_SORTFILES("SXrv") /* 4, 21 */
IF_FEATURE_LS_FILETYPES("Fp") /* 2, 23 */
IF_FEATURE_LS_FOLLOWLINKS("L") /* 1, 24 */
IF_FEATURE_LS_RECURSIVE("R") /* 1, 25 */
IF_FEATURE_HUMAN_READABLE("h") /* 1, 26 */
IF_SELINUX("KZ") /* 2, 28 */
IF_FEATURE_AUTOWIDTH("T:w:") /* 2, 30 */
;
enum {
//OPT_C = (1 << 0),
//OPT_a = (1 << 1),
//OPT_d = (1 << 2),
//OPT_i = (1 << 3),
//OPT_l = (1 << 4),
//OPT_1 = (1 << 5),
OPT_g = (1 << 6),
//OPT_n = (1 << 7),
//OPT_s = (1 << 8),
//OPT_x = (1 << 9),
OPT_Q = (1 << 10),
//OPT_A = (1 << 11),
//OPT_k = (1 << 12),
OPTBIT_color = 13
+ 4 * ENABLE_FEATURE_LS_TIMESTAMPS
+ 4 * ENABLE_FEATURE_LS_SORTFILES
+ 2 * ENABLE_FEATURE_LS_FILETYPES
+ 1 * ENABLE_FEATURE_LS_FOLLOWLINKS
+ 1 * ENABLE_FEATURE_LS_RECURSIVE
+ 1 * ENABLE_FEATURE_HUMAN_READABLE
+ 2 * ENABLE_SELINUX
+ 2 * ENABLE_FEATURE_AUTOWIDTH,
OPT_color = 1 << OPTBIT_color,
};
enum {
LIST_MASK_TRIGGER = 0,
STYLE_MASK_TRIGGER = STYLE_MASK,
DISP_MASK_TRIGGER = DISP_ROWS,
SORT_MASK_TRIGGER = SORT_MASK,
};
/* TODO: simple toggles may be stored as OPT_xxx bits instead */
static const unsigned opt_flags[] = {
LIST_SHORT | STYLE_COLUMNS, /* C */
DISP_HIDDEN | DISP_DOT, /* a */
DISP_NOLIST, /* d */
LIST_INO, /* i */
LIST_LONG | STYLE_LONG, /* l - remember LS_DISP_HR in mask! */
LIST_SHORT | STYLE_SINGLE, /* 1 */
0, /* g (don't show group) - handled via OPT_g */
LIST_ID_NUMERIC, /* n */
LIST_BLOCKS, /* s */
DISP_ROWS, /* x */
0, /* Q (quote filename) - handled via OPT_Q */
DISP_HIDDEN, /* A */
ENABLE_SELINUX * LIST_CONTEXT, /* k (ignored if !SELINUX) */
#if ENABLE_FEATURE_LS_TIMESTAMPS
TIME_CHANGE | (ENABLE_FEATURE_LS_SORTFILES * SORT_CTIME), /* c */
LIST_FULLTIME, /* e */
ENABLE_FEATURE_LS_SORTFILES * SORT_MTIME, /* t */
TIME_ACCESS | (ENABLE_FEATURE_LS_SORTFILES * SORT_ATIME), /* u */
#endif
#if ENABLE_FEATURE_LS_SORTFILES
SORT_SIZE, /* S */
SORT_EXT, /* X */
SORT_REVERSE, /* r */
SORT_VERSION, /* v */
#endif
#if ENABLE_FEATURE_LS_FILETYPES
LIST_FILETYPE | LIST_EXEC, /* F */
LIST_FILETYPE, /* p */
#endif
#if ENABLE_FEATURE_LS_FOLLOWLINKS
FOLLOW_LINKS, /* L */
#endif
#if ENABLE_FEATURE_LS_RECURSIVE
DISP_RECURSIVE, /* R */
#endif
#if ENABLE_FEATURE_HUMAN_READABLE
LS_DISP_HR, /* h */
#endif
#if ENABLE_SELINUX
LIST_MODEBITS|LIST_NLINKS|LIST_CONTEXT|LIST_SIZE|LIST_DATE_TIME, /* K */
#endif
#if ENABLE_SELINUX
LIST_MODEBITS|LIST_ID_NAME|LIST_CONTEXT, /* Z */
#endif
(1U<<31)
/* options after Z are not processed through opt_flags:
* T, w - ignored
*/
};
/*
* a directory entry and its stat info are stored here
@@ -126,7 +238,7 @@ struct dnode { /* the basic node */
const char *fullname; /* the dir entry name */
int allocated;
struct stat dstat; /* the file stat info */
USE_SELINUX(security_context_t sid;)
IF_SELINUX(security_context_t sid;)
struct dnode *next; /* point at the next node */
};
@@ -171,32 +283,17 @@ enum {
/* memset: we have to zero it out because of NOEXEC */
#define INIT_G() do { \
memset(&G, 0, sizeof(G)); \
USE_FEATURE_AUTOWIDTH(tabstops = COLUMN_GAP;) \
USE_FEATURE_AUTOWIDTH(terminal_width = TERMINAL_WIDTH;) \
USE_FEATURE_LS_TIMESTAMPS(time(&current_time_t);) \
IF_FEATURE_AUTOWIDTH(tabstops = COLUMN_GAP;) \
IF_FEATURE_AUTOWIDTH(terminal_width = TERMINAL_WIDTH;) \
IF_FEATURE_LS_TIMESTAMPS(time(&current_time_t);) \
} while (0)
#if ENABLE_FEATURE_ASSUME_UNICODE
/* libbb candidate */
static size_t mbstrlen(const char *string)
{
size_t width = mbsrtowcs(NULL /*dest*/, &string,
MAXINT(size_t) /*len*/, NULL /*state*/);
if (width == (size_t)-1)
return strlen(string);
return width;
}
#else
#define mbstrlen(string) strlen(string)
#endif
static struct dnode *my_stat(const char *fullname, const char *name, int force_follow)
{
struct stat dstat;
struct dnode *cur;
USE_SELINUX(security_context_t sid = NULL;)
IF_SELINUX(security_context_t sid = NULL;)
if ((all_fmt & FOLLOW_LINKS) || force_follow) {
#if ENABLE_SELINUX
@@ -226,22 +323,50 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
cur->fullname = fullname;
cur->name = name;
cur->dstat = dstat;
USE_SELINUX(cur->sid = sid;)
IF_SELINUX(cur->sid = sid;)
return cur;
}
/* FYI type values: 1:fifo 2:char 4:dir 6:blk 8:file 10:link 12:socket
* (various wacky OSes: 13:Sun door 14:BSD whiteout 5:XENIX named file
* 3/7:multiplexed char/block device)
* and we use 0 for unknown and 15 for executables (see below) */
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
#define APPCHAR(mode) ("\0|\0\0/\0\0\0\0\0@\0=\0\0\0" [TYPEINDEX(mode)])
/* 036 black foreground 050 black background
037 red foreground 051 red background
040 green foreground 052 green background
041 brown foreground 053 brown background
042 blue foreground 054 blue background
043 magenta (purple) foreground 055 magenta background
044 cyan (light blue) foreground 056 cyan background
045 gray foreground 057 white background
*/
#define COLOR(mode) ( \
/*un fi chr dir blk file link sock exe */ \
"\037\043\043\045\042\045\043\043\000\045\044\045\043\045\045\040" \
[TYPEINDEX(mode)])
/* Select normal (0) [actually "reset all"] or bold (1)
* (other attributes are 2:dim 4:underline 5:blink 7:reverse,
* let's use 7 for "impossible" types, just for fun)
* Note: coreutils 6.9 uses inverted red for setuid binaries.
*/
#define ATTR(mode) ( \
/*un fi chr dir blk file link sock exe */ \
"\01\00\01\07\01\07\01\07\00\07\01\07\01\07\07\01" \
[TYPEINDEX(mode)])
#if ENABLE_FEATURE_LS_COLOR
/* mode of zero is interpreted as "unknown" (stat failed) */
static char fgcolor(mode_t mode)
{
/* Check wheter the file is existing (if so, color it red!) */
if (errno == ENOENT)
return '\037';
if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
return COLOR(0xF000); /* File is executable ... */
return COLOR(mode);
}
static char bgcolor(mode_t mode)
static char bold(mode_t mode)
{
if (S_ISREG(mode) && (mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
return ATTR(0xF000); /* File is executable ... */
@@ -264,6 +389,7 @@ static char append_char(mode_t mode)
}
#endif
#define countdirs(A, B) count_dirs((A), (B), 1)
#define countsubdirs(A, B) count_dirs((A), (B), 0)
static int count_dirs(struct dnode **dn, int nfiles, int notsubdirs)
@@ -430,12 +556,12 @@ static void showfiles(struct dnode **dn, int nfiles)
} else {
/* find the longest file name, use that as the column width */
for (i = 0; i < nfiles; i++) {
int len = mbstrlen(dn[i]->name);
int len = bb_mbstrlen(dn[i]->name);
if (column_width < len)
column_width = len;
}
column_width += tabstops +
USE_SELINUX( ((all_fmt & LIST_CONTEXT) ? 33 : 0) + )
IF_SELINUX( ((all_fmt & LIST_CONTEXT) ? 33 : 0) + )
((all_fmt & LIST_INO) ? 8 : 0) +
((all_fmt & LIST_BLOCKS) ? 5 : 0);
ncols = (int) (terminal_width / column_width);
@@ -573,10 +699,41 @@ static struct dnode **list_dir(const char *path)
}
static int print_name(const char *name)
{
if (option_mask32 & OPT_Q) {
#if ENABLE_FEATURE_ASSUME_UNICODE
int len = 2 + bb_mbstrlen(name);
#else
int len = 2;
#endif
putchar('"');
while (*name) {
if (*name == '"') {
putchar('\\');
len++;
}
putchar(*name++);
if (!ENABLE_FEATURE_ASSUME_UNICODE)
len++;
}
putchar('"');
return len;
}
/* No -Q: */
#if ENABLE_FEATURE_ASSUME_UNICODE
fputs(name, stdout);
return bb_mbstrlen(name);
#else
return printf("%s", name);
#endif
}
static int list_single(const struct dnode *dn)
{
int i, column = 0;
int column = 0;
char *lpath = lpath; /* for compiler */
#if ENABLE_FEATURE_LS_TIMESTAMPS
char *filetime;
time_t ttime, age;
@@ -601,230 +758,128 @@ static int list_single(const struct dnode *dn)
append = append_char(dn->dstat.st_mode);
#endif
for (i = 0; i <= 31; i++) {
switch (all_fmt & (1 << i)) {
case LIST_INO:
column += printf("%7ld ", (long) dn->dstat.st_ino);
break;
case LIST_BLOCKS:
column += printf("%4"OFF_FMT"d ", (off_t) dn->dstat.st_blocks >> 1);
break;
case LIST_MODEBITS:
column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode));
break;
case LIST_NLINKS:
column += printf("%4ld ", (long) dn->dstat.st_nlink);
break;
case LIST_ID_NAME:
/* Do readlink early, so that if it fails, error message
* does not appear *inside* of the "ls -l" line */
if (all_fmt & LIST_SYMLINK)
if (S_ISLNK(dn->dstat.st_mode))
lpath = xmalloc_readlink_or_warn(dn->fullname);
if (all_fmt & LIST_INO)
column += printf("%7lu ", (long) dn->dstat.st_ino);
if (all_fmt & LIST_BLOCKS)
column += printf("%4"OFF_FMT"u ", (off_t) dn->dstat.st_blocks >> 1);
if (all_fmt & LIST_MODEBITS)
column += printf("%-10s ", (char *) bb_mode_string(dn->dstat.st_mode));
if (all_fmt & LIST_NLINKS)
column += printf("%4lu ", (long) dn->dstat.st_nlink);
#if ENABLE_FEATURE_LS_USERNAME
printf("%-8.8s %-8.8s",
if (all_fmt & LIST_ID_NAME) {
if (option_mask32 & OPT_g) {
column += printf("%-8.8s",
get_cached_username(dn->dstat.st_uid));
} else {
column += printf("%-8.8s %-8.8s",
get_cached_username(dn->dstat.st_uid),
get_cached_groupname(dn->dstat.st_gid));
column += 17;
break;
}
}
#endif
case LIST_ID_NUMERIC:
column += printf("%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
break;
case LIST_SIZE:
case LIST_DEV:
if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
column += printf("%4d, %3d ", (int) major(dn->dstat.st_rdev),
(int) minor(dn->dstat.st_rdev));
if (all_fmt & LIST_ID_NUMERIC) {
if (option_mask32 & OPT_g)
column += printf("%-8u", (int) dn->dstat.st_uid);
else
column += printf("%-8u %-8u",
(int) dn->dstat.st_uid,
(int) dn->dstat.st_gid);
}
if (all_fmt & (LIST_SIZE /*|LIST_DEV*/ )) {
if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
column += printf("%4u, %3u ",
(int) major(dn->dstat.st_rdev),
(int) minor(dn->dstat.st_rdev));
} else {
if (all_fmt & LS_DISP_HR) {
column += printf("%9s ",
make_human_readable_str(dn->dstat.st_size, 1, 0));
} else {
if (all_fmt & LS_DISP_HR) {
column += printf("%9s ",
make_human_readable_str(dn->dstat.st_size, 1, 0));
} else {
column += printf("%9"OFF_FMT"d ", (off_t) dn->dstat.st_size);
}
column += printf("%9"OFF_FMT"u ", (off_t) dn->dstat.st_size);
}
break;
}
}
#if ENABLE_FEATURE_LS_TIMESTAMPS
case LIST_FULLTIME:
printf("%24.24s ", filetime);
column += 25;
break;
case LIST_DATE_TIME:
if ((all_fmt & LIST_FULLTIME) == 0) {
/* current_time_t ~== time(NULL) */
age = current_time_t - ttime;
printf("%6.6s ", filetime + 4);
if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
/* hh:mm if less than 6 months old */
printf("%5.5s ", filetime + 11);
} else {
printf(" %4.4s ", filetime + 20);
}
column += 13;
if (all_fmt & LIST_FULLTIME)
column += printf("%24.24s ", filetime);
if (all_fmt & LIST_DATE_TIME)
if ((all_fmt & LIST_FULLTIME) == 0) {
/* current_time_t ~== time(NULL) */
age = current_time_t - ttime;
printf("%6.6s ", filetime + 4);
if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
/* hh:mm if less than 6 months old */
printf("%5.5s ", filetime + 11);
} else {
printf(" %4.4s ", filetime + 20);
}
break;
column += 13;
}
#endif
#if ENABLE_SELINUX
case LIST_CONTEXT:
{
char context[80];
int len = 0;
if (dn->sid) {
/* I assume sid initilized with NULL */
len = strlen(dn->sid) + 1;
safe_strncpy(context, dn->sid, len);
freecon(dn->sid);
} else {
safe_strncpy(context, "unknown", 8);
}
printf("%-32s ", context);
column += MAX(33, len);
}
break;
if (all_fmt & LIST_CONTEXT) {
column += printf("%-32s ", dn->sid ? dn->sid : "unknown");
freecon(dn->sid);
}
#endif
case LIST_FILENAME:
errno = 0;
if (all_fmt & LIST_FILENAME) {
#if ENABLE_FEATURE_LS_COLOR
if (show_color && !lstat(dn->fullname, &info)) {
printf("\033[%d;%dm", bgcolor(info.st_mode),
fgcolor(info.st_mode));
if (show_color) {
info.st_mode = 0; /* for fgcolor() */
lstat(dn->fullname, &info);
printf("\033[%u;%um", bold(info.st_mode),
fgcolor(info.st_mode));
}
#endif
column += print_name(dn->name);
if (show_color) {
printf("\033[0m");
}
}
if (all_fmt & LIST_SYMLINK) {
if (S_ISLNK(dn->dstat.st_mode) && lpath) {
printf(" -> ");
#if ENABLE_FEATURE_LS_FILETYPES || ENABLE_FEATURE_LS_COLOR
#if ENABLE_FEATURE_LS_COLOR
info.st_mode = 0; /* for fgcolor() */
#endif
if (stat(dn->fullname, &info) == 0) {
append = append_char(info.st_mode);
}
#endif
#if ENABLE_FEATURE_ASSUME_UNICODE
printf("%s", dn->name);
column += mbstrlen(dn->name);
#else
column += printf("%s", dn->name);
#if ENABLE_FEATURE_LS_COLOR
if (show_color) {
printf("\033[%u;%um", bold(info.st_mode),
fgcolor(info.st_mode));
}
#endif
column += print_name(lpath) + 4;
if (show_color) {
printf("\033[0m");
}
break;
case LIST_SYMLINK:
if (S_ISLNK(dn->dstat.st_mode)) {
char *lpath = xmalloc_readlink_or_warn(dn->fullname);
if (!lpath) break;
printf(" -> ");
#if ENABLE_FEATURE_LS_FILETYPES || ENABLE_FEATURE_LS_COLOR
if (!stat(dn->fullname, &info)) {
append = append_char(info.st_mode);
}
#endif
#if ENABLE_FEATURE_LS_COLOR
if (show_color) {
errno = 0;
printf("\033[%d;%dm", bgcolor(info.st_mode),
fgcolor(info.st_mode));
}
#endif
column += printf("%s", lpath) + 4;
if (show_color) {
printf("\033[0m");
}
free(lpath);
}
break;
#if ENABLE_FEATURE_LS_FILETYPES
case LIST_FILETYPE:
if (append) {
putchar(append);
column++;
}
break;
#endif
free(lpath);
}
}
#if ENABLE_FEATURE_LS_FILETYPES
if (all_fmt & LIST_FILETYPE) {
if (append) {
putchar(append);
column++;
}
}
#endif
return column;
}
/* "[-]Cadil1", POSIX mandated options, busybox always supports */
/* "[-]gnsx", POSIX non-mandated options, busybox always supports */
/* "[-]Ak" GNU options, busybox always supports */
/* "[-]FLRctur", POSIX mandated options, busybox optionally supports */
/* "[-]p", POSIX non-mandated options, busybox optionally supports */
/* "[-]SXvThw", GNU options, busybox optionally supports */
/* "[-]K", SELinux mandated options, busybox optionally supports */
/* "[-]e", I think we made this one up */
static const char ls_options[] ALIGN1 =
"Cadil1gnsxAk"
USE_FEATURE_LS_TIMESTAMPS("cetu")
USE_FEATURE_LS_SORTFILES("SXrv")
USE_FEATURE_LS_FILETYPES("Fp")
USE_FEATURE_LS_FOLLOWLINKS("L")
USE_FEATURE_LS_RECURSIVE("R")
USE_FEATURE_HUMAN_READABLE("h")
USE_SELINUX("K")
USE_FEATURE_AUTOWIDTH("T:w:")
USE_SELINUX("Z");
enum {
LIST_MASK_TRIGGER = 0,
STYLE_MASK_TRIGGER = STYLE_MASK,
DISP_MASK_TRIGGER = DISP_ROWS,
SORT_MASK_TRIGGER = SORT_MASK,
};
static const unsigned opt_flags[] = {
LIST_SHORT | STYLE_COLUMNS, /* C */
DISP_HIDDEN | DISP_DOT, /* a */
DISP_NOLIST, /* d */
LIST_INO, /* i */
LIST_LONG | STYLE_LONG, /* l - remember LS_DISP_HR in mask! */
LIST_SHORT | STYLE_SINGLE, /* 1 */
0, /* g - ingored */
LIST_ID_NUMERIC, /* n */
LIST_BLOCKS, /* s */
DISP_ROWS, /* x */
DISP_HIDDEN, /* A */
ENABLE_SELINUX * LIST_CONTEXT, /* k (ignored if !SELINUX) */
#if ENABLE_FEATURE_LS_TIMESTAMPS
TIME_CHANGE | (ENABLE_FEATURE_LS_SORTFILES * SORT_CTIME), /* c */
LIST_FULLTIME, /* e */
ENABLE_FEATURE_LS_SORTFILES * SORT_MTIME, /* t */
TIME_ACCESS | (ENABLE_FEATURE_LS_SORTFILES * SORT_ATIME), /* u */
#endif
#if ENABLE_FEATURE_LS_SORTFILES
SORT_SIZE, /* S */
SORT_EXT, /* X */
SORT_REVERSE, /* r */
SORT_VERSION, /* v */
#endif
#if ENABLE_FEATURE_LS_FILETYPES
LIST_FILETYPE | LIST_EXEC, /* F */
LIST_FILETYPE, /* p */
#endif
#if ENABLE_FEATURE_LS_FOLLOWLINKS
FOLLOW_LINKS, /* L */
#endif
#if ENABLE_FEATURE_LS_RECURSIVE
DISP_RECURSIVE, /* R */
#endif
#if ENABLE_FEATURE_HUMAN_READABLE
LS_DISP_HR, /* h */
#endif
#if ENABLE_SELINUX
LIST_MODEBITS|LIST_NLINKS|LIST_CONTEXT|LIST_SIZE|LIST_DATE_TIME, /* K */
#endif
#if ENABLE_FEATURE_AUTOWIDTH
0, 0, /* T, w - ignored */
#endif
#if ENABLE_SELINUX
LIST_MODEBITS|LIST_ID_NAME|LIST_CONTEXT, /* Z */
#endif
(1U<<31)
};
/* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
#if ENABLE_FEATURE_LS_COLOR
/* long option entry used only for --color, which has no short option
* equivalent */
static const char ls_color_opt[] ALIGN1 =
"color\0" Optional_argument "\xff" /* no short equivalent */
;
#endif
int ls_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ls_main(int argc UNUSED_PARAM, char **argv)
{
struct dnode **dnd;
@@ -837,29 +892,48 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
int dnfiles;
int dndirs;
int i;
#if ENABLE_FEATURE_LS_COLOR
/* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
/* coreutils 6.10:
* # ls --color=BOGUS
* ls: invalid argument 'BOGUS' for '--color'
* Valid arguments are:
* 'always', 'yes', 'force'
* 'never', 'no', 'none'
* 'auto', 'tty', 'if-tty'
* (and substrings: "--color=alwa" work too)
*/
static const char ls_longopts[] ALIGN1 =
"color\0" Optional_argument "\xff"; /* no short equivalent */
static const char color_str[] ALIGN1 =
"always\0""yes\0""force\0"
"auto\0""tty\0""if-tty\0";
/* need to initialize since --color has _an optional_ argument */
USE_FEATURE_LS_COLOR(const char *color_opt = "always";)
const char *color_opt = color_str; /* "always" */
#endif
INIT_G();
check_unicode_in_env();
all_fmt = LIST_SHORT |
(ENABLE_FEATURE_LS_SORTFILES * (SORT_NAME | SORT_FORWARD));
#if ENABLE_FEATURE_AUTOWIDTH
/* Obtain the terminal width */
/* obtain the terminal width */
get_terminal_width_height(STDIN_FILENO, &terminal_width, NULL);
/* Go one less... */
/* go one less... */
terminal_width--;
#endif
/* process options */
USE_FEATURE_LS_COLOR(applet_long_options = ls_color_opt;)
IF_FEATURE_LS_COLOR(applet_long_options = ls_longopts;)
#if ENABLE_FEATURE_AUTOWIDTH
opt_complementary = "T+:w+"; /* -T N, -w N */
opt = getopt32(argv, ls_options, &tabstops, &terminal_width
USE_FEATURE_LS_COLOR(, &color_opt));
IF_FEATURE_LS_COLOR(, &color_opt));
#else
opt = getopt32(argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt));
opt = getopt32(argv, ls_options IF_FEATURE_LS_COLOR(, &color_opt));
#endif
for (i = 0; opt_flags[i] != (1U<<31); i++) {
if (opt & (1 << i)) {
@@ -892,13 +966,20 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
if (!p || (p[0] && strcmp(p, "none") != 0))
show_color = 1;
}
if (opt & (1 << i)) { /* next flag after short options */
if (strcmp("always", color_opt) == 0)
show_color = 1;
else if (strcmp("never", color_opt) == 0)
if (opt & OPT_color) {
if (color_opt[0] == 'n')
show_color = 0;
else if (strcmp("auto", color_opt) == 0 && isatty(STDOUT_FILENO))
show_color = 1;
else switch (index_in_substrings(color_str, color_opt)) {
case 3:
case 4:
case 5:
if (isatty(STDOUT_FILENO)) {
case 0:
case 1:
case 2:
show_color = 1;
}
}
}
#endif
@@ -932,8 +1013,8 @@ int ls_main(int argc UNUSED_PARAM, char **argv)
dn = NULL;
nfiles = 0;
do {
/* ls w/o -l follows links on command line */
cur = my_stat(*argv, *argv, !(all_fmt & STYLE_LONG));
/* NB: follow links on command line unless -l or -s */
cur = my_stat(*argv, *argv, !(all_fmt & (STYLE_LONG|LIST_BLOCKS)));
argv++;
if (!cur)
continue;
+26 -9
View File
@@ -8,7 +8,13 @@
#include "libbb.h"
typedef enum { HASH_SHA1, HASH_MD5 } hash_algo_t;
typedef enum {
/* 4th letter of applet_name is... */
HASH_MD5 = 's', /* "md5>s<um" */
HASH_SHA1 = '1',
HASH_SHA256 = '2',
HASH_SHA512 = '5',
} hash_algo_t;
#define FLAG_SILENT 1
#define FLAG_CHECK 2
@@ -24,10 +30,12 @@ static unsigned char *hash_bin_to_hex(unsigned char *hash_value,
return (unsigned char *)hex_value;
}
static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
static uint8_t *hash_file(const char *filename /*, hash_algo_t hash_algo*/)
{
int src_fd, hash_len, count;
union _ctx_ {
sha512_ctx_t sha512;
sha256_ctx_t sha256;
sha1_ctx_t sha1;
md5_ctx_t md5;
} context;
@@ -35,6 +43,7 @@ static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
RESERVE_CONFIG_UBUFFER(in_buf, 4096);
void FAST_FUNC (*update)(const void*, size_t, void*);
void FAST_FUNC (*final)(void*, void*);
hash_algo_t hash_algo = applet_name[3];
src_fd = open_or_warn_stdin(filename);
if (src_fd < 0) {
@@ -42,16 +51,26 @@ static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
}
/* figure specific hash algorithims */
if (ENABLE_MD5SUM && hash_algo==HASH_MD5) {
if (ENABLE_MD5SUM && hash_algo == HASH_MD5) {
md5_begin(&context.md5);
update = (void*)md5_hash;
final = (void*)md5_end;
hash_len = 16;
} else if (ENABLE_SHA1SUM && hash_algo==HASH_SHA1) {
} else if (ENABLE_SHA1SUM && hash_algo == HASH_SHA1) {
sha1_begin(&context.sha1);
update = (void*)sha1_hash;
final = (void*)sha1_end;
hash_len = 20;
} else if (ENABLE_SHA256SUM && hash_algo == HASH_SHA256) {
sha256_begin(&context.sha256);
update = (void*)sha256_hash;
final = (void*)sha256_end;
hash_len = 32;
} else if (ENABLE_SHA512SUM && hash_algo == HASH_SHA512) {
sha512_begin(&context.sha512);
update = (void*)sha512_hash;
final = (void*)sha512_end;
hash_len = 64;
} else {
bb_error_msg_and_die("algorithm not supported");
}
@@ -80,9 +99,7 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
int return_value = EXIT_SUCCESS;
uint8_t *hash_value;
unsigned flags;
hash_algo_t hash_algo = ENABLE_MD5SUM
? (ENABLE_SHA1SUM ? (applet_name[0] == 'm' ? HASH_MD5 : HASH_SHA1) : HASH_MD5)
: HASH_SHA1;
/*hash_algo_t hash_algo = applet_name[3];*/
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
flags = getopt32(argv, "scw");
@@ -136,7 +153,7 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
*filename_ptr = '\0';
filename_ptr += 2;
hash_value = hash_file(filename_ptr, hash_algo);
hash_value = hash_file(filename_ptr /*, hash_algo*/);
if (hash_value && (strcmp((char*)hash_value, line) == 0)) {
if (!(flags & FLAG_SILENT))
@@ -162,7 +179,7 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
*/
} else {
do {
hash_value = hash_file(*argv, hash_algo);
hash_value = hash_file(*argv/*, hash_algo*/);
if (hash_value == NULL) {
return_value = EXIT_FAILURE;
} else {
+1 -1
View File
@@ -48,7 +48,7 @@ int mkdir_main(int argc, char **argv)
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
applet_long_options = mkdir_longopts;
#endif
opt = getopt32(argv, "m:p" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
opt = getopt32(argv, "m:p" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext));
if (opt & 1) {
mode = 0777;
if (!bb_parse_mode(smode, &mode)) {
+1 -1
View File
@@ -5,7 +5,7 @@
* http://www.opengroup.org/onlinepubs/007904975/utilities/nohup.html
*
* Copyright 2006 Rob Landley <rob@landley.net>
* Copyright 2006 Bernhard Fischer
* Copyright 2006 Bernhard Reutner-Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
+6 -6
View File
@@ -832,7 +832,7 @@ format_address_std(off_t address, char c)
printf(address_fmt, address);
}
#if ENABLE_GETOPT_LONG
#if ENABLE_LONG_OPTS
/* only used with --traditional */
static void
format_address_paren(off_t address, char c)
@@ -953,7 +953,7 @@ get_lcm(void)
return l_c_m;
}
#if ENABLE_GETOPT_LONG
#if ENABLE_LONG_OPTS
/* If S is a valid traditional offset specification with an optional
leading '+' return nonzero and set *OFFSET to the offset it denotes. */
@@ -1199,9 +1199,9 @@ int od_main(int argc, char **argv)
OPT_s = 1 << 15,
OPT_S = 1 << 16,
OPT_w = 1 << 17,
OPT_traditional = (1 << 18) * ENABLE_GETOPT_LONG,
OPT_traditional = (1 << 18) * ENABLE_LONG_OPTS,
};
#if ENABLE_GETOPT_LONG
#if ENABLE_LONG_OPTS
static const char od_longopts[] ALIGN1 =
"skip-bytes\0" Required_argument "j"
"address-radix\0" Required_argument "A"
@@ -1235,7 +1235,7 @@ int od_main(int argc, char **argv)
/* Parse command line */
opt_complementary = "w+:t::"; /* -w N, -t is a list */
#if ENABLE_GETOPT_LONG
#if ENABLE_LONG_OPTS
applet_long_options = od_longopts;
#endif
opt = getopt32(argv, "A:N:abcdfhij:lot:vxsS:"
@@ -1306,7 +1306,7 @@ int od_main(int argc, char **argv)
* FIXME: POSIX 1003.1-2001 with XSI requires support for the
* traditional syntax even if --traditional is not given. */
#if ENABLE_GETOPT_LONG
#if ENABLE_LONG_OPTS
if (opt & OPT_traditional) {
off_t o1, o2;
+5 -1
View File
@@ -13,6 +13,8 @@
int printenv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int printenv_main(int argc UNUSED_PARAM, char **argv)
{
int exit_code = EXIT_SUCCESS;
/* no variables specified, show whole env */
if (!argv[1]) {
int e = 0;
@@ -26,8 +28,10 @@ int printenv_main(int argc UNUSED_PARAM, char **argv)
env = getenv(arg);
if (env)
puts(env);
else
exit_code = EXIT_FAILURE;
}
}
fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(exit_code);
}
+92 -65
View File
@@ -53,10 +53,7 @@
* (but negative numbers are not "bad").
* Both accept negative numbers for %u specifier.
*
* We try to be compatible. We are not compatible here:
* - we do not accept -NUM for %u
* - exit code is 0 even if "invalid number" was seen (FIXME)
* See "if (errno)" checks in the code below.
* We try to be compatible.
*/
typedef void FAST_FUNC (*converter)(const char *arg, void *result);
@@ -75,13 +72,21 @@ static int multiconvert(const char *arg, void *result, converter convert)
return 0;
}
static void FAST_FUNC conv_strtoul(const char *arg, void *result)
static void FAST_FUNC conv_strtoull(const char *arg, void *result)
{
*(unsigned long*)result = bb_strtoul(arg, NULL, 0);
*(unsigned long long*)result = bb_strtoull(arg, NULL, 0);
/* both coreutils 6.10 and bash 3.2:
* $ printf '%x\n' -2
* fffffffffffffffe
* Mimic that:
*/
if (errno) {
*(unsigned long long*)result = bb_strtoll(arg, NULL, 0);
}
}
static void FAST_FUNC conv_strtol(const char *arg, void *result)
static void FAST_FUNC conv_strtoll(const char *arg, void *result)
{
*(long*)result = bb_strtol(arg, NULL, 0);
*(long long*)result = bb_strtoll(arg, NULL, 0);
}
static void FAST_FUNC conv_strtod(const char *arg, void *result)
{
@@ -96,17 +101,17 @@ static void FAST_FUNC conv_strtod(const char *arg, void *result)
}
/* Callers should check errno to detect errors */
static unsigned long my_xstrtoul(const char *arg)
static unsigned long long my_xstrtoull(const char *arg)
{
unsigned long result;
if (multiconvert(arg, &result, conv_strtoul))
unsigned long long result;
if (multiconvert(arg, &result, conv_strtoull))
result = 0;
return result;
}
static long my_xstrtol(const char *arg)
static long long my_xstrtoll(const char *arg)
{
long result;
if (multiconvert(arg, &result, conv_strtol))
long long result;
if (multiconvert(arg, &result, conv_strtoll))
result = 0;
return result;
}
@@ -134,18 +139,20 @@ static void print_direc(char *format, unsigned fmt_length,
int field_width, int precision,
const char *argument)
{
long lv;
long long llv;
double dv;
char saved;
char *have_prec, *have_width;
saved = format[fmt_length];
format[fmt_length] = '\0';
have_prec = strstr(format, ".*");
have_width = strchr(format, '*');
if (have_width - 1 == have_prec)
have_width = NULL;
saved = format[fmt_length];
format[fmt_length] = '\0';
errno = 0;
switch (format[fmt_length - 1]) {
case 'c':
@@ -153,42 +160,43 @@ static void print_direc(char *format, unsigned fmt_length,
break;
case 'd':
case 'i':
lv = my_xstrtol(argument);
llv = my_xstrtoll(argument);
print_long:
/* if (errno) return; - see comment at the top */
if (!have_width) {
if (!have_prec)
printf(format, lv);
printf(format, llv);
else
printf(format, precision, lv);
printf(format, precision, llv);
} else {
if (!have_prec)
printf(format, field_width, lv);
printf(format, field_width, llv);
else
printf(format, field_width, precision, lv);
printf(format, field_width, precision, llv);
}
break;
case 'o':
case 'u':
case 'x':
case 'X':
lv = my_xstrtoul(argument);
llv = my_xstrtoull(argument);
/* cheat: unsigned long and long have same width, so... */
goto print_long;
case 's':
/* Are char* and long the same? (true for most arches) */
if (sizeof(argument) == sizeof(lv)) {
lv = (long)(ptrdiff_t)argument;
/* Are char* and long long the same? */
if (sizeof(argument) == sizeof(llv)) {
llv = (long long)(ptrdiff_t)argument;
goto print_long;
} else { /* Hope compiler will optimize it out */
} else {
/* Hope compiler will optimize it out by moving call
* instruction after the ifs... */
if (!have_width) {
if (!have_prec)
printf(format, argument);
printf(format, argument, /*unused:*/ argument, argument);
else
printf(format, precision, argument);
printf(format, precision, argument, /*unused:*/ argument);
} else {
if (!have_prec)
printf(format, field_width, argument);
printf(format, field_width, argument, /*unused:*/ argument);
else
printf(format, field_width, precision, argument);
}
@@ -200,7 +208,6 @@ static void print_direc(char *format, unsigned fmt_length,
case 'g':
case 'G':
dv = my_xstrtod(argument);
/* if (errno) return; */
if (!have_width) {
if (!have_prec)
printf(format, dv);
@@ -231,7 +238,7 @@ static int get_width_prec(const char *str)
/* Print the text in FORMAT, using ARGV for arguments to any '%' directives.
Return advanced ARGV. */
static char **print_formatted(char *f, char **argv)
static char **print_formatted(char *f, char **argv, int *conv_err)
{
char *direc_start; /* Start of % directive. */
unsigned direc_length; /* Length of % directive. */
@@ -286,38 +293,48 @@ static char **print_formatted(char *f, char **argv)
}
}
}
/* Remove size modifiers - "%Ld" would try to printf
* long long, we pass long, and it spews garbage */
if ((*f | 0x20) == 'l' || *f == 'h' || *f == 'z') {
/* Remove "lLhz" size modifiers, repeatedly.
* bash does not like "%lld", but coreutils
* happily takes even "%Llllhhzhhzd"!
* We are permissive like coreutils */
while ((*f | 0x20) == 'l' || *f == 'h' || *f == 'z') {
overlapping_strcpy(f, f + 1);
}
//FIXME: actually, the same happens with bare "%d":
//it printfs an int, but we pass long!
//What saves us is that on most arches stack slot
//is pointer-sized -> long-sized -> ints are promoted to longs
// for variadic functions -> printf("%d", int_v) is in reality
// indistinqushable from printf("%d", long_v) ->
// since printf("%d", int_v) works, printf("%d", long_v) has to work.
//But "clean" solution would be to add "l" to d,i,o,x,X.
//Probably makes sense to go all the way to "ll" then.
//Coreutils support long long-sized arguments.
/* needed - try "printf %" without it */
if (!strchr("diouxXfeEgGcs", *f)) {
bb_error_msg("%s: invalid format", direc_start);
/* causes main() to exit with error */
return saved_argv - 1;
/* Add "ll" if integer modifier, then print */
{
static const char format_chars[] ALIGN1 = "diouxXfeEgGcs";
char *p = strchr(format_chars, *f);
/* needed - try "printf %" without it */
if (p == NULL) {
bb_error_msg("%s: invalid format", direc_start);
/* causes main() to exit with error */
return saved_argv - 1;
}
++direc_length;
if (p - format_chars <= 5) {
/* it is one of "diouxX" */
p = xmalloc(direc_length + 3);
memcpy(p, direc_start, direc_length);
p[direc_length + 1] = p[direc_length - 1];
p[direc_length - 1] = 'l';
p[direc_length] = 'l';
//bb_error_msg("<%s>", p);
direc_length += 2;
direc_start = p;
} else {
p = NULL;
}
if (*argv) {
print_direc(direc_start, direc_length, field_width,
precision, *argv++);
} else {
print_direc(direc_start, direc_length, field_width,
precision, "");
}
*conv_err |= errno;
free(p);
}
++direc_length;
if (*argv) {
print_direc(direc_start, direc_length, field_width,
precision, *argv);
++argv;
} else {
print_direc(direc_start, direc_length, field_width,
precision, "");
}
/* if (errno) return saved_argv - 1; */
break;
case '\\':
if (*++f == 'c') {
@@ -336,6 +353,7 @@ static char **print_formatted(char *f, char **argv)
int printf_main(int argc UNUSED_PARAM, char **argv)
{
int conv_err;
char *format;
char **argv2;
@@ -359,15 +377,23 @@ int printf_main(int argc UNUSED_PARAM, char **argv)
* We will mimic coreutils. */
if (argv[1] && argv[1][0] == '-' && argv[1][1] == '-' && !argv[1][2])
argv++;
if (!argv[1])
if (!argv[1]) {
if (ENABLE_ASH_BUILTIN_PRINTF
&& applet_name[0] != 'p'
) {
bb_error_msg("usage: printf FORMAT [ARGUMENT...]");
return 2; /* bash compat */
}
bb_show_usage();
}
format = argv[1];
argv2 = argv + 2;
conv_err = 0;
do {
argv = argv2;
argv2 = print_formatted(format, argv);
argv2 = print_formatted(format, argv, &conv_err);
} while (argv2 > argv && *argv2);
/* coreutils compat (bash doesn't do this):
@@ -375,5 +401,6 @@ int printf_main(int argc UNUSED_PARAM, char **argv)
fprintf(stderr, "excess args ignored");
*/
return (argv2 < argv); /* if true, print_formatted errored out */
return (argv2 < argv) /* if true, print_formatted errored out */
|| conv_err; /* print_formatted saw invalid number */
}
+30 -7
View File
@@ -6,9 +6,31 @@
*
* Licensed under GPL v2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
/*
* # readlink --version
* readlink (GNU coreutils) 6.10
* # readlink --help
* -f, --canonicalize
* canonicalize by following every symlink in
* every component of the given name recursively;
* all but the last component must exist
* -e, --canonicalize-existing
* canonicalize by following every symlink in
* every component of the given name recursively,
* all components must exist
* -m, --canonicalize-missing
* canonicalize by following every symlink in
* every component of the given name recursively,
* without requirements on components existence
* -n, --no-newline do not output the trailing newline
* -q, --quiet, -s, --silent suppress most error messages
* -v, --verbose report error messages
*
* bbox supports: -f -n -v (fully), -q -s (accepts but ignores)
*/
int readlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int readlink_main(int argc UNUSED_PARAM, char **argv)
{
@@ -16,23 +38,24 @@ int readlink_main(int argc UNUSED_PARAM, char **argv)
char *fname;
char pathbuf[PATH_MAX];
USE_FEATURE_READLINK_FOLLOW(
IF_FEATURE_READLINK_FOLLOW(
unsigned opt;
/* We need exactly one non-option argument. */
opt_complementary = "=1";
opt = getopt32(argv, "f");
opt = getopt32(argv, "fnvsq");
fname = argv[optind];
)
SKIP_FEATURE_READLINK_FOLLOW(
IF_NOT_FEATURE_READLINK_FOLLOW(
const unsigned opt = 0;
if (argc != 2) bb_show_usage();
fname = argv[1];
)
/* compat: coreutils readlink reports errors silently via exit code */
logmode = LOGMODE_NONE;
if (!(opt & 4)) /* not -v */
logmode = LOGMODE_NONE;
if (opt) {
if (opt & 1) { /* -f */
buf = realpath(fname, pathbuf);
} else {
buf = xmalloc_readlink_or_warn(fname);
@@ -40,7 +63,7 @@ int readlink_main(int argc UNUSED_PARAM, char **argv)
if (!buf)
return EXIT_FAILURE;
puts(buf);
printf((opt & 2) ? "%s" : "%s\n", buf);
if (ENABLE_FEATURE_CLEAN_UP && !opt)
free(buf);
+3 -2
View File
@@ -27,13 +27,14 @@ int rm_main(int argc UNUSED_PARAM, char **argv)
unsigned opt;
opt_complementary = "f-i:i-f";
opt = getopt32(argv, "fiRr");
/* -v (verbose) is ignored */
opt = getopt32(argv, "fiRrv");
argv += optind;
if (opt & 1)
flags |= FILEUTILS_FORCE;
if (opt & 2)
flags |= FILEUTILS_INTERACTIVE;
if (opt & 12)
if (opt & (8|4))
flags |= FILEUTILS_RECUR;
if (*argv != NULL) {
+72 -13
View File
@@ -6,35 +6,94 @@
*
* Licensed under the GPL v2, see the file LICENSE in this tarball.
*/
#include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
int seq_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int seq_main(int argc, char **argv)
{
double last, increment, i;
enum {
OPT_w = (1 << 0),
OPT_s = (1 << 1),
};
double first, last, increment, v;
unsigned n;
unsigned width;
unsigned frac_part;
const char *sep, *opt_s = "\n";
unsigned opt;
i = increment = 1;
#if ENABLE_LOCALE_SUPPORT
/* Undo busybox.c: on input, we want to use dot
* as fractional separator, regardless of current locale */
setlocale(LC_NUMERIC, "C");
#endif
opt = getopt32(argv, "+ws:", &opt_s);
argc -= optind;
argv += optind;
first = increment = 1;
errno = 0;
switch (argc) {
case 4:
increment = atof(argv[2]);
char *pp;
case 3:
i = atof(argv[1]);
increment = strtod(argv[1], &pp);
errno |= *pp;
case 2:
last = atof(argv[argc-1]);
break;
first = strtod(argv[0], &pp);
errno |= *pp;
case 1:
last = strtod(argv[argc-1], &pp);
if (!errno && *pp == '\0')
break;
default:
bb_show_usage();
}
/* You should note that this is pos-5.0.91 semantics, -- FK. */
while ((increment > 0 && i <= last) || (increment < 0 && i >= last)) {
printf("%g\n", i);
i += increment;
#if ENABLE_LOCALE_SUPPORT
setlocale(LC_NUMERIC, "");
#endif
/* Last checked to be compatible with: coreutils-6.10 */
width = 0;
frac_part = 0;
while (1) {
char *dot = strchrnul(*argv, '.');
int w = (dot - *argv);
int f = strlen(dot);
if (width < w)
width = w;
argv++;
if (!*argv)
break;
/* Why do the above _before_ frac check below?
* Try "seq 1 2.0" and "seq 1.0 2.0":
* coreutils never pay attention to the number
* of fractional digits in last arg. */
if (frac_part < f)
frac_part = f;
}
if (frac_part) {
frac_part--;
if (frac_part)
width += frac_part + 1;
}
if (!(opt & OPT_w))
width = 0;
sep = "";
v = first;
n = 0;
while (increment >= 0 ? v <= last : v >= last) {
printf("%s%0*.*f", sep, width, frac_part, v);
sep = opt_s;
/* v += increment; - would accumulate floating point errors */
n++;
v = first + n * increment;
}
if (n) /* if while loop executed at least once */
bb_putchar('\n');
return fflush(stdout);
}
+4 -2
View File
@@ -54,11 +54,13 @@ int sleep_main(int argc UNUSED_PARAM, char **argv)
char *arg = *argv;
if (strchr(arg, '.')) {
double d;
char *pp;
int len = strspn(arg, "0123456789.");
char sv = arg[len];
arg[len] = '\0';
d = bb_strtod(arg, NULL);
if (errno)
errno = 0;
d = strtod(arg, &pp);
if (errno || *pp)
bb_show_usage();
arg[len] = sv;
len--;
+1 -1
View File
@@ -1,7 +1,7 @@
/* vi: set sw=4 ts=4: */
/*
* split - split a file into pieces
* Copyright (c) 2007 Bernhard Fischer
* Copyright (c) 2007 Bernhard Reutner-Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
+33 -18
View File
@@ -125,6 +125,20 @@ static const char *human_fstype(uint32_t f_type)
return humantypes[i].fs;
}
/* "man statfs" says that statfsbuf->f_fsid is a mess */
/* coreutils treats it as an array of ints, most significant first */
static unsigned long long get_f_fsid(const struct statfs *statfsbuf)
{
const unsigned *p = (const void*) &statfsbuf->f_fsid;
unsigned sz = sizeof(statfsbuf->f_fsid) / sizeof(unsigned);
unsigned long long r = 0;
do
r = (r << (sizeof(unsigned)*8)) | *p++;
while (--sz > 0);
return r;
}
#if ENABLE_FEATURE_STAT_FORMAT
static void strcatc(char *str, char c)
{
@@ -142,17 +156,17 @@ static void printfs(char *pformat, const char *msg)
/* print statfs info */
static void print_statfs(char *pformat, const char m,
const char *const filename, const void *data
USE_SELINUX(, security_context_t scontext))
IF_SELINUX(, security_context_t scontext))
{
const struct statfs *statfsbuf = data;
if (m == 'n') {
printfs(pformat, filename);
} else if (m == 'i') {
strcat(pformat, "Lx");
printf(pformat, statfsbuf->f_fsid);
strcat(pformat, "llx");
printf(pformat, get_f_fsid(statfsbuf));
} else if (m == 'l') {
strcat(pformat, "lu");
printf(pformat, statfsbuf->f_namelen);
printf(pformat, (unsigned long) (statfsbuf->f_namelen));
} else if (m == 't') {
strcat(pformat, "lx");
printf(pformat, (unsigned long) (statfsbuf->f_type)); /* no equiv */
@@ -189,7 +203,7 @@ static void print_statfs(char *pformat, const char m,
/* print stat info */
static void print_stat(char *pformat, const char m,
const char *const filename, const void *data
USE_SELINUX(, security_context_t scontext))
IF_SELINUX(, security_context_t scontext))
{
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
struct stat *statbuf = (struct stat *) data;
@@ -292,9 +306,9 @@ static void print_stat(char *pformat, const char m,
}
static void print_it(const char *masterformat, const char *filename,
void (*print_func) (char*, char, const char*, const void* USE_SELINUX(, security_context_t scontext)),
void (*print_func) (char*, char, const char*, const void* IF_SELINUX(, security_context_t scontext)),
const void *data
USE_SELINUX(, security_context_t scontext) )
IF_SELINUX(, security_context_t scontext) )
{
/* Create a working copy of the format string */
char *format = xstrdup(masterformat);
@@ -333,7 +347,7 @@ static void print_it(const char *masterformat, const char *filename,
break;
default:
/* Completes "%<modifiers>" with specifier and printfs */
print_func(dest, *p, filename, data USE_SELINUX(,scontext));
print_func(dest, *p, filename, data IF_SELINUX(,scontext));
break;
}
}
@@ -349,10 +363,11 @@ static void print_it(const char *masterformat, const char *filename,
#endif
static bool do_statfs(const char *filename, const char *format)
{
struct statfs statfsbuf;
#if !ENABLE_FEATURE_STAT_FORMAT
const char *format;
#endif
struct statfs statfsbuf;
#if ENABLE_SELINUX
security_context_t scontext = NULL;
@@ -401,15 +416,15 @@ static bool do_statfs(const char *filename, const char *format)
);
#endif /* SELINUX */
}
print_it(format, filename, print_statfs, &statfsbuf USE_SELINUX(, scontext));
print_it(format, filename, print_statfs, &statfsbuf IF_SELINUX(, scontext));
#else /* FEATURE_STAT_FORMAT */
format = (option_mask32 & OPT_TERSE
? "%s %llx %lu "
: " File: \"%s\"\n"
" ID: %-8Lx Namelen: %-7lu ");
" ID: %-8llx Namelen: %-7lu ");
printf(format,
filename,
statfsbuf.f_fsid,
get_f_fsid(&statfsbuf),
statfsbuf.f_namelen);
if (option_mask32 & OPT_TERSE)
@@ -545,11 +560,11 @@ static bool do_stat(const char *filename, const char *format)
}
#endif
}
print_it(format, filename, print_stat, &statbuf USE_SELINUX(, scontext));
print_it(format, filename, print_stat, &statbuf IF_SELINUX(, scontext));
#else /* FEATURE_STAT_FORMAT */
if (option_mask32 & OPT_TERSE) {
printf("%s %ju %ju %lx %lu %lu %jx %ju %lu %lx %lx %lu %lu %lu %lu"
SKIP_SELINUX("\n"),
IF_NOT_SELINUX("\n"),
filename,
(uintmax_t) (statbuf.st_size),
(uintmax_t) statbuf.st_blocks,
@@ -627,14 +642,14 @@ static bool do_stat(const char *filename, const char *format)
int stat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int stat_main(int argc, char **argv)
{
USE_FEATURE_STAT_FORMAT(char *format = NULL;)
IF_FEATURE_STAT_FORMAT(char *format = NULL;)
int i;
int ok = 1;
statfunc_ptr statfunc = do_stat;
getopt32(argv, "ftL"
USE_SELINUX("Z")
USE_FEATURE_STAT_FORMAT("c:", &format)
IF_SELINUX("Z")
IF_FEATURE_STAT_FORMAT("c:", &format)
);
if (option_mask32 & OPT_FILESYS) /* -f */
@@ -648,7 +663,7 @@ int stat_main(int argc, char **argv)
}
#endif /* ENABLE_SELINUX */
for (i = optind; i < argc; ++i)
ok &= statfunc(argv[i] USE_FEATURE_STAT_FORMAT(, format));
ok &= statfunc(argv[i] IF_FEATURE_STAT_FORMAT(, format));
return (ok ? EXIT_SUCCESS : EXIT_FAILURE);
}
+3 -3
View File
@@ -677,8 +677,8 @@ static tcflag_t *mode_type_flag(unsigned type, const struct termios *mode)
return NULL;
}
static void set_speed_or_die(enum speed_setting type, const char *const arg,
struct termios * const mode)
static void set_speed_or_die(enum speed_setting type, const char *arg,
struct termios *mode)
{
speed_t baud;
@@ -801,7 +801,7 @@ enum {
param_ospeed = 8 | 0x80,
};
static int find_param(const char *const name)
static int find_param(const char *name)
{
static const char params[] ALIGN1 =
"line\0" /* 1 */
+104 -38
View File
@@ -50,12 +50,12 @@ static ssize_t tail_read(int fd, char *buf, size_t count)
off_t current;
struct stat sbuf;
/* (A good comment is missing here) */
current = lseek(fd, 0, SEEK_CUR);
/* /proc files report zero st_size, don't lseek them. */
if (fstat(fd, &sbuf) == 0 && sbuf.st_size)
if (fstat(fd, &sbuf) == 0 && sbuf.st_size > 0) {
current = lseek(fd, 0, SEEK_CUR);
if (sbuf.st_size < current)
lseek(fd, 0, SEEK_SET);
xlseek(fd, 0, SEEK_SET);
}
r = full_read(fd, buf, count);
if (r < 0) {
@@ -85,18 +85,15 @@ int tail_main(int argc, char **argv)
unsigned count = 10;
unsigned sleep_period = 1;
bool from_top;
int header_threshhold = 1;
const char *str_c, *str_n;
char *tailbuf;
size_t tailbufsize;
int taillen = 0;
int newlines_seen = 0;
int nfiles, nread, nwrite, i, opt;
unsigned seen;
unsigned header_threshhold = 1;
unsigned nfiles;
int i, opt;
int *fds;
char *s, *buf;
const char *fmt;
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_TAIL
@@ -104,23 +101,29 @@ int tail_main(int argc, char **argv)
if (argv[1] && (argv[1][0] == '+' || argv[1][0] == '-')
&& isdigit(argv[1][1])
) {
count = eat_num(&argv[1][1]);
count = eat_num(argv[1]);
argv++;
argc--;
}
#endif
USE_FEATURE_FANCY_TAIL(opt_complementary = "s+";) /* -s N */
opt = getopt32(argv, "fc:n:" USE_FEATURE_FANCY_TAIL("qs:v"),
&str_c, &str_n USE_FEATURE_FANCY_TAIL(,&sleep_period));
/* -s NUM, -F imlies -f */
IF_FEATURE_FANCY_TAIL(opt_complementary = "s+:Ff";)
opt = getopt32(argv, "fc:n:" IF_FEATURE_FANCY_TAIL("qs:vF"),
&str_c, &str_n IF_FEATURE_FANCY_TAIL(,&sleep_period));
#define FOLLOW (opt & 0x1)
#define COUNT_BYTES (opt & 0x2)
//if (opt & 0x1) // -f
if (opt & 0x2) count = eat_num(str_c); // -c
if (opt & 0x4) count = eat_num(str_n); // -n
#if ENABLE_FEATURE_FANCY_TAIL
if (opt & 0x8) header_threshhold = INT_MAX; // -q
/* q: make it impossible for nfiles to be > header_threshhold */
if (opt & 0x8) header_threshhold = UINT_MAX; // -q
//if (opt & 0x10) // -s
if (opt & 0x20) header_threshhold = 0; // -v
# define FOLLOW_RETRY (opt & 0x40)
#else
# define FOLLOW_RETRY 0
#endif
argc -= optind;
argv += optind;
@@ -128,19 +131,21 @@ int tail_main(int argc, char **argv)
G.status = EXIT_SUCCESS;
/* open all the files */
fds = xmalloc(sizeof(int) * (argc + 1));
fds = xmalloc(sizeof(fds[0]) * (argc + 1));
if (!argv[0]) {
struct stat statbuf;
if (!fstat(STDIN_FILENO, &statbuf) && S_ISFIFO(statbuf.st_mode)) {
if (fstat(STDIN_FILENO, &statbuf) == 0
&& S_ISFIFO(statbuf.st_mode)
) {
opt &= ~1; /* clear FOLLOW */
}
*argv = (char *) bb_msg_standard_input;
argv[0] = (char *) bb_msg_standard_input;
}
nfiles = i = 0;
do {
int fd = open_or_warn_stdin(argv[i]);
if (fd < 0) {
if (fd < 0 && !FOLLOW_RETRY) {
G.status = EXIT_FAILURE;
continue;
}
@@ -161,44 +166,73 @@ int tail_main(int argc, char **argv)
tailbuf = xmalloc(tailbufsize);
/* tail the files */
fmt = header_fmt + 1; /* Skip header leading newline on first output. */
fmt = header_fmt + 1; /* skip header leading newline on first output */
i = 0;
do {
char *buf;
int taillen;
int newlines_seen;
unsigned seen;
int nread;
int fd = fds[i];
if (ENABLE_FEATURE_FANCY_TAIL && fd < 0)
continue; /* may happen with -E */
if (nfiles > header_threshhold) {
tail_xprint_header(fmt, argv[i]);
fmt = header_fmt;
}
/* Optimizing count-bytes case if the file is seekable.
* Beware of backing up too far.
* Also we exclude files with size 0 (because of /proc/xxx) */
if (COUNT_BYTES && !from_top) {
off_t current = lseek(fds[i], 0, SEEK_END);
if (!from_top) {
off_t current = lseek(fd, 0, SEEK_END);
if (current > 0) {
if (count == 0)
continue; /* showing zero lines is easy :) */
current -= count;
unsigned off;
if (COUNT_BYTES) {
/* Optimizing count-bytes case if the file is seekable.
* Beware of backing up too far.
* Also we exclude files with size 0 (because of /proc/xxx) */
if (count == 0)
continue; /* showing zero bytes is easy :) */
current -= count;
if (current < 0)
current = 0;
xlseek(fd, current, SEEK_SET);
bb_copyfd_size(fd, STDOUT_FILENO, count);
continue;
}
#if 1 /* This is technically incorrect for *LONG* strings, but very useful */
/* Optimizing count-lines case if the file is seekable.
* We assume the lines are <64k.
* (Users complain that tail takes too long
* on multi-gigabyte files) */
off = (count | 0xf); /* for small counts, be more paranoid */
if (off > (INT_MAX / (64*1024)))
off = (INT_MAX / (64*1024));
current -= off * (64*1024);
if (current < 0)
current = 0;
xlseek(fds[i], current, SEEK_SET);
bb_copyfd_size(fds[i], STDOUT_FILENO, count);
continue;
xlseek(fd, current, SEEK_SET);
#endif
}
}
buf = tailbuf;
taillen = 0;
/* "We saw 1st line/byte".
* Used only by +N code ("start from Nth", 1-based): */
seen = 1;
newlines_seen = 0;
while ((nread = tail_read(fds[i], buf, tailbufsize-taillen)) > 0) {
while ((nread = tail_read(fd, buf, tailbufsize-taillen)) > 0) {
if (from_top) {
nwrite = nread;
int nwrite = nread;
if (seen < count) {
/* We need to skip a few more bytes/lines */
if (COUNT_BYTES) {
nwrite -= (count - seen);
seen = count;
} else {
s = buf;
char *s = buf;
do {
--nwrite;
if (*s++ == '\n' && ++seen == count) {
@@ -231,6 +265,7 @@ int tail_main(int argc, char **argv)
taillen += nread;
} else {
int extra = (buf[nread-1] != '\n');
char *s;
k = newlines_seen + newlines_in_buf + extra - count;
s = tailbuf;
@@ -257,23 +292,54 @@ int tail_main(int argc, char **argv)
}
} while (++i < nfiles);
buf = xrealloc(tailbuf, BUFSIZ);
tailbuf = xrealloc(tailbuf, BUFSIZ);
fmt = NULL;
if (FOLLOW) while (1) {
sleep(sleep_period);
i = 0;
do {
int nread;
const char *filename = argv[i];
int fd = fds[i];
if (FOLLOW_RETRY) {
struct stat sbuf, fsbuf;
if (fd < 0
|| fstat(fd, &fsbuf) < 0
|| stat(filename, &sbuf) < 0
|| fsbuf.st_dev != sbuf.st_dev
|| fsbuf.st_ino != sbuf.st_ino
) {
int new_fd;
if (fd >= 0)
close(fd);
new_fd = open(filename, O_RDONLY);
if (new_fd >= 0) {
bb_error_msg("%s has %s; following end of new file",
filename, (fd < 0) ? "appeared" : "been replaced"
);
} else if (fd >= 0) {
bb_perror_msg("%s has become inaccessible", filename);
}
fds[i] = fd = new_fd;
}
}
if (ENABLE_FEATURE_FANCY_TAIL && fd < 0)
continue;
if (nfiles > header_threshhold) {
fmt = header_fmt;
}
while ((nread = tail_read(fds[i], buf, BUFSIZ)) > 0) {
while ((nread = tail_read(fd, tailbuf, BUFSIZ)) > 0) {
if (fmt) {
tail_xprint_header(fmt, argv[i]);
tail_xprint_header(fmt, filename);
fmt = NULL;
}
xwrite(STDOUT_FILENO, buf, nread);
xwrite(STDOUT_FILENO, tailbuf, nread);
}
} while (++i < nfiles);
}
-1
View File
@@ -11,7 +11,6 @@
/* http://www.opengroup.org/onlinepubs/007904975/utilities/tee.html */
#include "libbb.h"
#include <signal.h>
int tee_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int tee_main(int argc, char **argv)
+183 -84
View File
@@ -12,14 +12,13 @@
* modified by Herbert Xu to be used as built-in in ash.
* modified by Erik Andersen <andersen@codepoet.org> to be used
* in busybox.
* modified by Bernhard Fischer to be useable (i.e. a bit less bloaty).
* modified by Bernhard Reutner-Fischer to be useable (i.e. a bit less bloaty).
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* Original copyright notice states:
* "This program is in the Public Domain."
*/
#include "libbb.h"
#include <setjmp.h>
@@ -29,7 +28,6 @@
* This is true regardless of PREFER_APPLETS and STANDALONE_SHELL
* state. */
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;
aexpr ::= nexpr | nexpr "-a" aexpr ;
@@ -47,43 +45,97 @@
operand ::= <any legal UNIX file name>
*/
/* TODO: handle [[ expr ]] bashism bash-compatibly.
* [[ ]] is meant to be a "better [ ]", with less weird syntax
* and without the risk of variables and quoted strings misinterpreted
* as operators.
* This will require support from shells - we need to know quote status
* of each parameter (see below).
*
* Word splitting and pathname expansion should NOT be performed:
* # a="a b"; [[ $a = "a b" ]] && echo YES
* YES
* # [[ /bin/m* ]] && echo YES
* YES
*
* =~ should do regexp match
* = and == should do pattern match against right side:
* # [[ *a* == bab ]] && echo YES
* # [[ bab == *a* ]] && echo YES
* YES
* != does the negated == (i.e., also with pattern matching).
* Pattern matching is quotation-sensitive:
* # [[ bab == "b"a* ]] && echo YES
* YES
* # [[ bab == b"a*" ]] && echo YES
*
* Conditional operators such as -f must be unquoted literals to be recognized:
* # [[ -e /bin ]] && echo YES
* YES
* # [[ '-e' /bin ]] && echo YES
* bash: conditional binary operator expected...
* # A='-e'; [[ $A /bin ]] && echo YES
* bash: conditional binary operator expected...
*
* || and && should work as -o and -a work in [ ]
* -a and -o aren't recognized (&& and || are to be used instead)
* ( and ) do not need to be quoted unlike in [ ]:
* # [[ ( abc ) && '' ]] && echo YES
* # [[ ( abc ) || '' ]] && echo YES
* YES
* # [[ ( abc ) -o '' ]] && echo YES
* bash: syntax error in conditional expression...
*
* Apart from the above, [[ expr ]] should work as [ expr ]
*/
#define TEST_DEBUG 0
enum token {
EOI,
FILRD,
FILRD, /* file access */
FILWR,
FILEX,
FILEXIST,
FILREG,
FILREG, /* file type */
FILDIR,
FILCDEV,
FILBDEV,
FILFIFO,
FILSOCK,
FILSYM,
FILGZ,
FILTT,
FILSUID,
FILSUID, /* file bit */
FILSGID,
FILSTCK,
FILNT,
FILNT, /* file ops */
FILOT,
FILEQ,
FILUID,
FILGID,
STREZ,
STREZ, /* str ops */
STRNZ,
STREQ,
STRNE,
STRLT,
STRGT,
INTEQ,
INTEQ, /* int ops */
INTNE,
INTGE,
INTGT,
INTLE,
INTLT,
UNOT,
BAND,
BOR,
@@ -170,7 +222,7 @@ static const char *const TOKSTR[] = {
#define unnest_msg_and_return(expr, ...) return expr
#endif
enum token_types {
enum {
UNOP,
BINOP,
BUNOP,
@@ -179,53 +231,96 @@ enum token_types {
};
struct operator_t {
char op_text[4];
unsigned char op_num, op_type;
};
static const struct operator_t ops[] = {
{ "-r", FILRD , UNOP },
{ "-w", FILWR , UNOP },
{ "-x", FILEX , UNOP },
{ "-e", FILEXIST, UNOP },
{ "-f", FILREG , UNOP },
{ "-d", FILDIR , UNOP },
{ "-c", FILCDEV , UNOP },
{ "-b", FILBDEV , UNOP },
{ "-p", FILFIFO , UNOP },
{ "-u", FILSUID , UNOP },
{ "-g", FILSGID , UNOP },
{ "-k", FILSTCK , UNOP },
{ "-s", FILGZ , UNOP },
{ "-t", FILTT , UNOP },
{ "-z", STREZ , UNOP },
{ "-n", STRNZ , UNOP },
{ "-h", FILSYM , UNOP }, /* for backwards compat */
static const struct operator_t ops_table[] = {
{ /* "-r" */ FILRD , UNOP },
{ /* "-w" */ FILWR , UNOP },
{ /* "-x" */ FILEX , UNOP },
{ /* "-e" */ FILEXIST, UNOP },
{ /* "-f" */ FILREG , UNOP },
{ /* "-d" */ FILDIR , UNOP },
{ /* "-c" */ FILCDEV , UNOP },
{ /* "-b" */ FILBDEV , UNOP },
{ /* "-p" */ FILFIFO , UNOP },
{ /* "-u" */ FILSUID , UNOP },
{ /* "-g" */ FILSGID , UNOP },
{ /* "-k" */ FILSTCK , UNOP },
{ /* "-s" */ FILGZ , UNOP },
{ /* "-t" */ FILTT , UNOP },
{ /* "-z" */ STREZ , UNOP },
{ /* "-n" */ STRNZ , UNOP },
{ /* "-h" */ FILSYM , UNOP }, /* for backwards compat */
{ "-O" , FILUID , UNOP },
{ "-G" , FILGID , UNOP },
{ "-L" , FILSYM , UNOP },
{ "-S" , FILSOCK, UNOP },
{ "=" , STREQ , BINOP },
{ "==" , STREQ , BINOP },
{ "!=" , STRNE , BINOP },
{ "<" , STRLT , BINOP },
{ ">" , STRGT , BINOP },
{ "-eq", INTEQ , BINOP },
{ "-ne", INTNE , BINOP },
{ "-ge", INTGE , BINOP },
{ "-gt", INTGT , BINOP },
{ "-le", INTLE , BINOP },
{ "-lt", INTLT , BINOP },
{ "-nt", FILNT , BINOP },
{ "-ot", FILOT , BINOP },
{ "-ef", FILEQ , BINOP },
{ "!" , UNOT , BUNOP },
{ "-a" , BAND , BBINOP },
{ "-o" , BOR , BBINOP },
{ "(" , LPAREN , PAREN },
{ ")" , RPAREN , PAREN },
{ /* "-O" */ FILUID , UNOP },
{ /* "-G" */ FILGID , UNOP },
{ /* "-L" */ FILSYM , UNOP },
{ /* "-S" */ FILSOCK , UNOP },
{ /* "=" */ STREQ , BINOP },
{ /* "==" */ STREQ , BINOP },
{ /* "!=" */ STRNE , BINOP },
{ /* "<" */ STRLT , BINOP },
{ /* ">" */ STRGT , BINOP },
{ /* "-eq"*/ INTEQ , BINOP },
{ /* "-ne"*/ INTNE , BINOP },
{ /* "-ge"*/ INTGE , BINOP },
{ /* "-gt"*/ INTGT , BINOP },
{ /* "-le"*/ INTLE , BINOP },
{ /* "-lt"*/ INTLT , BINOP },
{ /* "-nt"*/ FILNT , BINOP },
{ /* "-ot"*/ FILOT , BINOP },
{ /* "-ef"*/ FILEQ , BINOP },
{ /* "!" */ UNOT , BUNOP },
{ /* "-a" */ BAND , BBINOP },
{ /* "-o" */ BOR , BBINOP },
{ /* "(" */ LPAREN , PAREN },
{ /* ")" */ RPAREN , PAREN },
};
/* Please keep these two tables in sync */
static const char ops_texts[] ALIGN1 =
"-r" "\0"
"-w" "\0"
"-x" "\0"
"-e" "\0"
"-f" "\0"
"-d" "\0"
"-c" "\0"
"-b" "\0"
"-p" "\0"
"-u" "\0"
"-g" "\0"
"-k" "\0"
"-s" "\0"
"-t" "\0"
"-z" "\0"
"-n" "\0"
"-h" "\0"
"-O" "\0"
"-G" "\0"
"-L" "\0"
"-S" "\0"
"=" "\0"
"==" "\0"
"!=" "\0"
"<" "\0"
">" "\0"
"-eq" "\0"
"-ne" "\0"
"-ge" "\0"
"-gt" "\0"
"-le" "\0"
"-lt" "\0"
"-nt" "\0"
"-ot" "\0"
"-ef" "\0"
"!" "\0"
"-a" "\0"
"-o" "\0"
"(" "\0"
")" "\0"
;
#if ENABLE_FEATURE_TEST_64
@@ -332,29 +427,22 @@ static int equalf(const char *f1, const char *f2)
*/
static enum token check_operator(char *s)
static enum token check_operator(const char *s)
{
static const struct operator_t no_op = {
.op_num = -1,
.op_type = -1
};
const struct operator_t *op;
int n;
last_operator = &no_op;
if (s == NULL) {
if (s == NULL)
return EOI;
}
op = ops;
do {
if (strcmp(s, op->op_text) == 0) {
last_operator = op;
return op->op_num;
}
op++;
} while (op < ops + ARRAY_SIZE(ops));
return OPERAND;
n = index_in_strings(ops_texts, s);
if (n < 0)
return OPERAND;
last_operator = &ops_table[n];
return ops_table[n].op_num;
}
@@ -370,7 +458,7 @@ static int binop(void)
opnd2 = *++args;
if (opnd2 == NULL)
syntax(op->op_text, "argument expected");
syntax(args[-1], "argument expected");
if (is_int_op(op->op_num)) {
val1 = getn(opnd1);
@@ -385,8 +473,8 @@ static int binop(void)
return val1 > val2;
if (op->op_num == INTLE)
return val1 <= val2;
if (op->op_num == INTLT)
return val1 < val2;
/*if (op->op_num == INTLT)*/
return val1 < val2;
}
if (is_str_op(op->op_num)) {
val1 = strcmp(opnd1, opnd2);
@@ -396,8 +484,8 @@ static int binop(void)
return val1 != 0;
if (op->op_num == STRLT)
return val1 < 0;
if (op->op_num == STRGT)
return val1 > 0;
/*if (op->op_num == STRGT)*/
return val1 > 0;
}
/* We are sure that these three are by now the only binops we didn't check
* yet, so we do not check if the class is correct:
@@ -412,25 +500,29 @@ static int binop(void)
return b1.st_mtime > b2.st_mtime;
if (op->op_num == FILOT)
return b1.st_mtime < b2.st_mtime;
if (op->op_num == FILEQ)
return b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino;
/*if (op->op_num == FILEQ)*/
return b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino;
}
return 1; /* NOTREACHED */
/*return 1; - NOTREACHED */
}
static void initialize_group_array(void)
{
ngroups = getgroups(0, NULL);
if (ngroups > 0) {
int n;
/* getgroups may be expensive, try to use it only once */
ngroups = 32;
do {
/* FIXME: ash tries so hard to not die on OOM,
* and we spoil it with just one xrealloc here */
/* We realloc, because test_main can be entered repeatedly by shell.
* Testcase (ash): 'while true; do test -x some_file; done'
* and watch top. (some_file must have owner != you) */
group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
getgroups(ngroups, group_array);
}
n = ngroups;
group_array = xrealloc(group_array, n * sizeof(gid_t));
ngroups = getgroups(n, group_array);
} while (ngroups > n);
}
@@ -571,7 +663,14 @@ static number_t nexpr(enum token n)
nest_msg(">nexpr(%s)\n", TOKSTR[n]);
if (n == UNOT) {
res = !nexpr(check_operator(*++args));
n = check_operator(*++args);
if (n == EOI) {
/* special case: [ ! ], [ a -a ! ] are valid */
/* IOW, "! ARG" may miss ARG */
unnest_msg("<nexpr:1 (!EOI)\n");
return 1;
}
res = !nexpr(n);
unnest_msg("<nexpr:%lld\n", res);
return res;
}
@@ -717,7 +816,7 @@ int test_main(int argc, char **argv)
* isn't likely in the case of a shell. paranoia
* prevails...
*/
ngroups = 0;
/*ngroups = 0; - done by INIT_S() */
//argc--;
argv++;
@@ -742,7 +841,7 @@ int test_main(int argc, char **argv)
check_operator(argv[1]);
if (last_operator->op_type == BINOP) {
/* "test [!] arg1 <binary_op> arg2" */
args = &argv[0];
args = argv;
res = (binop() == 0);
goto ret;
}
@@ -755,7 +854,7 @@ int test_main(int argc, char **argv)
argv--;
}
#endif
args = &argv[0];
args = argv;
res = !oexpr(check_operator(*args));
if (*args != NULL && *++args != NULL) {
+45 -7
View File
@@ -41,19 +41,40 @@ int touch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int touch_main(int argc UNUSED_PARAM, char **argv)
{
#if ENABLE_DESKTOP
# if ENABLE_LONG_OPTS
static const char touch_longopts[] ALIGN1 =
/* name, has_arg, val */
"no-create\0" No_argument "c"
"reference\0" Required_argument "r"
"date\0" Required_argument "d"
;
# endif
struct utimbuf timebuf;
char *reference_file = NULL;
char *date_str = NULL;
#else
#define reference_file NULL
#define timebuf (*(struct utimbuf*)NULL)
# define reference_file NULL
# define date_str NULL
# define timebuf (*(struct utimbuf*)NULL)
#endif
int fd;
int status = EXIT_SUCCESS;
int flags = getopt32(argv, "c" USE_DESKTOP("r:")
/*ignored:*/ "fma"
USE_DESKTOP(, &reference_file));
int opts;
flags &= 1; /* only -c bit is left */
#if ENABLE_DESKTOP && ENABLE_LONG_OPTS
applet_long_options = touch_longopts;
#endif
/* -d and -t both set time. In coreutils,
* accepted data format differs a bit between -d and -t.
* We accept the same formats for both */
opts = getopt32(argv, "c" IF_DESKTOP("r:d:t:")
/*ignored:*/ "fma"
IF_DESKTOP(, &reference_file)
IF_DESKTOP(, &date_str)
IF_DESKTOP(, &date_str)
);
opts &= 1; /* only -c bit is left */
argv += optind;
if (!*argv) {
bb_show_usage();
@@ -66,10 +87,27 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
timebuf.modtime = stbuf.st_mtime;
}
if (date_str) {
struct tm tm_time;
time_t t;
//time(&t);
//localtime_r(&t, &tm_time);
memset(&tm_time, 0, sizeof(tm_time));
parse_datestr(date_str, &tm_time);
/* Correct any day of week and day of year etc. fields */
tm_time.tm_isdst = -1; /* Be sure to recheck dst */
t = validate_tm_time(date_str, &tm_time);
timebuf.actime = t;
timebuf.modtime = t;
}
do {
if (utime(*argv, reference_file ? &timebuf : NULL)) {
if (errno == ENOENT) { /* no such file */
if (flags) { /* creation is disabled, so ignore */
if (opts) { /* creation is disabled, so ignore */
continue;
}
/* Try to create the file. */
+174 -125
View File
@@ -16,235 +16,284 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* http://www.opengroup.org/onlinepubs/009695399/utilities/tr.html
* TODO: xdigit, graph, print
* TODO: graph, print
*/
#include "libbb.h"
#define ASCII 0377
enum {
ASCII = 256,
/* string buffer needs to be at least as big as the whole "alphabet".
* BUFSIZ == ASCII is ok, but we will realloc in expand
* even for smallest patterns, let's avoid that by using *2:
*/
TR_BUFSIZ = (BUFSIZ > ASCII*2) ? BUFSIZ : ASCII*2,
};
static void map(char *pvector,
unsigned char *string1, unsigned int string1_len,
unsigned char *string2, unsigned int string2_len)
char *string1, unsigned string1_len,
char *string2, unsigned string2_len)
{
char last = '0';
unsigned int i, j;
unsigned i, j;
for (j = 0, i = 0; i < string1_len; i++) {
if (string2_len <= j)
pvector[string1[i]] = last;
pvector[(unsigned char)(string1[i])] = last;
else
pvector[string1[i]] = last = string2[j++];
pvector[(unsigned char)(string1[i])] = last = string2[j++];
}
}
/* supported constructs:
* Ranges, e.g., 0-9 ==> 0123456789
* Ranges, e.g., [0-9] ==> 0123456789
* Escapes, e.g., \a ==> Control-G
* Character classes, e.g. [:upper:] ==> A...Z
* Equiv classess, e.g. [=A=] ==> A (hmmmmmmm?)
* not supported:
* \ooo-\ooo - octal ranges
* [x*N] - repeat char x N times
* [x*] - repeat char x until it fills STRING2:
* # echo qwe123 | /usr/bin/tr 123456789 '[d]'
* qwe[d]
* # echo qwe123 | /usr/bin/tr 123456789 '[d*]'
* qweddd
*/
static unsigned int expand(const char *arg, char *buffer)
static unsigned expand(const char *arg, char **buffer_p)
{
char *buffer_start = buffer;
char *buffer = *buffer_p;
unsigned pos = 0;
unsigned size = TR_BUFSIZ;
unsigned i; /* can't be unsigned char: must be able to hold 256 */
unsigned char ac;
while (*arg) {
if (pos + ASCII > size) {
size += ASCII;
*buffer_p = buffer = xrealloc(buffer, size);
}
if (*arg == '\\') {
arg++;
*buffer++ = bb_process_escape_sequence(&arg);
buffer[pos++] = bb_process_escape_sequence(&arg);
continue;
}
if (arg[1] == '-') { /* "0-9..." */
ac = arg[2];
if (ac == '\0') { /* "0-": copy verbatim */
*buffer++ = *arg++; /* copy '0' */
buffer[pos++] = *arg++; /* copy '0' */
continue; /* next iter will copy '-' and stop */
}
i = *arg;
i = (unsigned char) *arg;
while (i <= ac) /* ok: i is unsigned _int_ */
*buffer++ = i++;
buffer[pos++] = i++;
arg += 3; /* skip 0-9 */
continue;
}
if (*arg == '[') { /* "[xyz..." */
if ((ENABLE_FEATURE_TR_CLASSES || ENABLE_FEATURE_TR_EQUIV)
&& *arg == '['
) {
arg++;
i = *arg++;
/* "[xyz...", i=x, arg points to y */
if (ENABLE_FEATURE_TR_CLASSES && i == ':') {
i = (unsigned char) *arg++;
/* "[xyz...". i=x, arg points to y */
if (ENABLE_FEATURE_TR_CLASSES && i == ':') { /* [:class:] */
#define CLO ":]\0"
static const char classes[] ALIGN1 =
"alpha"CLO "alnum"CLO "digit"CLO
"lower"CLO "upper"CLO "space"CLO
"blank"CLO "punct"CLO "cntrl"CLO;
#define CLASS_invalid 0 /* we increment the retval */
#define CLASS_alpha 1
#define CLASS_alnum 2
#define CLASS_digit 3
#define CLASS_lower 4
#define CLASS_upper 5
#define CLASS_space 6
#define CLASS_blank 7
#define CLASS_punct 8
#define CLASS_cntrl 9
//#define CLASS_xdigit 10
//#define CLASS_graph 11
//#define CLASS_print 12
"blank"CLO "punct"CLO "cntrl"CLO
"xdigit"CLO;
enum {
CLASS_invalid = 0, /* we increment the retval */
CLASS_alpha = 1,
CLASS_alnum = 2,
CLASS_digit = 3,
CLASS_lower = 4,
CLASS_upper = 5,
CLASS_space = 6,
CLASS_blank = 7,
CLASS_punct = 8,
CLASS_cntrl = 9,
CLASS_xdigit = 10,
//CLASS_graph = 11,
//CLASS_print = 12,
};
smalluint j;
{ /* not really pretty.. */
char *tmp = xstrndup(arg, 7); // warning: xdigit would need 8, not 7
j = index_in_strings(classes, tmp) + 1;
free(tmp);
}
if (j == CLASS_alnum || j == CLASS_digit) {
char *tmp;
/* xdigit needs 8, not 7 */
i = 7 + (arg[0] == 'x');
tmp = xstrndup(arg, i);
j = index_in_strings(classes, tmp) + 1;
free(tmp);
if (j == CLASS_invalid)
goto skip_bracket;
arg += i;
if (j == CLASS_alnum || j == CLASS_digit || j == CLASS_xdigit) {
for (i = '0'; i <= '9'; i++)
*buffer++ = i;
buffer[pos++] = i;
}
if (j == CLASS_alpha || j == CLASS_alnum || j == CLASS_upper) {
for (i = 'A'; i <= 'Z'; i++)
*buffer++ = i;
buffer[pos++] = i;
}
if (j == CLASS_alpha || j == CLASS_alnum || j == CLASS_lower) {
for (i = 'a'; i <= 'z'; i++)
*buffer++ = i;
buffer[pos++] = i;
}
if (j == CLASS_space || j == CLASS_blank) {
*buffer++ = '\t';
buffer[pos++] = '\t';
if (j == CLASS_space) {
*buffer++ = '\n';
*buffer++ = '\v';
*buffer++ = '\f';
*buffer++ = '\r';
buffer[pos++] = '\n';
buffer[pos++] = '\v';
buffer[pos++] = '\f';
buffer[pos++] = '\r';
}
*buffer++ = ' ';
buffer[pos++] = ' ';
}
if (j == CLASS_punct || j == CLASS_cntrl) {
for (i = '\0'; i <= ASCII; i++)
for (i = '\0'; i < ASCII; i++) {
if ((j == CLASS_punct && isprint(i) && !isalnum(i) && !isspace(i))
|| (j == CLASS_cntrl && iscntrl(i)))
*buffer++ = i;
|| (j == CLASS_cntrl && iscntrl(i))
) {
buffer[pos++] = i;
}
}
}
if (j == CLASS_invalid) {
*buffer++ = '[';
*buffer++ = ':';
continue;
if (j == CLASS_xdigit) {
for (i = 'A'; i <= 'F'; i++) {
buffer[pos + 6] = i | 0x20;
buffer[pos++] = i;
}
pos += 6;
}
break;
continue;
}
/* "[xyz...", i=x, arg points to y */
if (ENABLE_FEATURE_TR_EQUIV && i == '=') { /* [=CHAR=] */
*buffer++ = *arg; /* copy CHAR */
if (!*arg || arg[1] != '=' || arg[2] != ']')
buffer[pos++] = *arg; /* copy CHAR */
if (!arg[0] || arg[1] != '=' || arg[2] != ']')
bb_show_usage();
arg += 3; /* skip CHAR=] */
continue;
}
if (i == '\0' || *arg != '-') { /* not [x-...] - copy verbatim */
*buffer++ = '[';
arg--; /* points to x */
continue; /* copy all, including eventual ']' */
}
/* [x-z] */
arg++; /* skip - */
if (arg[0] == '\0' || arg[1] != ']')
bb_show_usage();
ac = *arg++;
while (i <= ac)
*buffer++ = i++;
arg++; /* skip ] */
continue;
/* The rest of "[xyz..." cases is treated as normal
* string, "[" has no special meaning here:
* tr "[a-z]" "[A-Z]" can be written as tr "a-z" "A-Z",
* also try tr "[a-z]" "_A-Z+" and you'll see that
* [] is not special here.
*/
skip_bracket:
arg -= 2; /* points to "[" in "[xyz..." */
}
*buffer++ = *arg++;
buffer[pos++] = *arg++;
}
return (buffer - buffer_start);
return pos;
}
/* NB: buffer is guaranteed to be at least TR_BUFSIZE
* (which is >= ASCII) big.
*/
static int complement(char *buffer, int buffer_len)
{
int i, j, ix;
char conv[ASCII + 2];
int len;
char conv[ASCII];
unsigned char ch;
ix = 0;
for (i = '\0'; i <= ASCII; i++) {
for (j = 0; j < buffer_len; j++)
if (buffer[j] == i)
break;
if (j == buffer_len)
conv[ix++] = i & ASCII;
len = 0;
ch = '\0';
while (1) {
if (memchr(buffer, ch, buffer_len) == NULL)
conv[len++] = ch;
if (++ch == '\0')
break;
}
memcpy(buffer, conv, ix);
return ix;
memcpy(buffer, conv, len);
return len;
}
int tr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int tr_main(int argc UNUSED_PARAM, char **argv)
{
int output_length = 0, input_length;
int i;
smalluint flags;
ssize_t read_chars = 0;
size_t in_index = 0, out_index = 0;
smalluint opts;
ssize_t read_chars;
size_t in_index, out_index;
unsigned last = UCHAR_MAX + 1; /* not equal to any char */
unsigned char coded, c;
unsigned char *output = xmalloc(BUFSIZ);
char *vector = xzalloc((ASCII+1) * 3);
char *invec = vector + (ASCII+1);
char *outvec = vector + (ASCII+1) * 2;
char *str1 = xmalloc(TR_BUFSIZ);
char *str2 = xmalloc(TR_BUFSIZ);
int str2_length;
int str1_length;
char *vector = xzalloc(ASCII * 3);
char *invec = vector + ASCII;
char *outvec = vector + ASCII * 2;
#define TR_OPT_complement (1 << 0)
#define TR_OPT_delete (1 << 1)
#define TR_OPT_squeeze_reps (1 << 2)
#define TR_OPT_complement (3 << 0)
#define TR_OPT_delete (1 << 2)
#define TR_OPT_squeeze_reps (1 << 3)
flags = getopt32(argv, "+cds"); /* '+': stop at first non-option */
argv += optind;
for (i = 0; i <= ASCII; i++) {
for (i = 0; i < ASCII; i++) {
vector[i] = i;
/*invec[i] = outvec[i] = FALSE; - done by xzalloc */
}
#define tr_buf bb_common_bufsiz1
if (*argv != NULL) {
input_length = expand(*argv++, tr_buf);
if (flags & TR_OPT_complement)
input_length = complement(tr_buf, input_length);
if (*argv) {
if (argv[0][0] == '\0')
bb_error_msg_and_die("STRING2 cannot be empty");
output_length = expand(*argv, (char *)output);
map(vector, (unsigned char *)tr_buf, input_length, output, output_length);
}
for (i = 0; i < input_length; i++)
invec[(unsigned char)tr_buf[i]] = TRUE;
for (i = 0; i < output_length; i++)
outvec[output[i]] = TRUE;
}
/* -C/-c difference is that -C complements "characters",
* and -c complements "values" (binary bytes I guess).
* In POSIX locale, these are the same.
*/
opt_complementary = "-1";
opts = getopt32(argv, "+Ccds"); /* '+': stop at first non-option */
argv += optind;
str1_length = expand(*argv++, &str1);
str2_length = 0;
if (opts & TR_OPT_complement)
str1_length = complement(str1, str1_length);
if (*argv) {
if (argv[0][0] == '\0')
bb_error_msg_and_die("STRING2 cannot be empty");
str2_length = expand(*argv, &str2);
map(vector, str1, str1_length,
str2, str2_length);
}
for (i = 0; i < str1_length; i++)
invec[(unsigned char)(str1[i])] = TRUE;
for (i = 0; i < str2_length; i++)
outvec[(unsigned char)(str2[i])] = TRUE;
goto start_from;
/* In this loop, str1 space is reused as input buffer,
* str2 - as output one. */
for (;;) {
/* If we're out of input, flush output and read more input. */
if ((ssize_t)in_index == read_chars) {
if (out_index) {
xwrite(STDOUT_FILENO, (char *)output, out_index);
xwrite(STDOUT_FILENO, str2, out_index);
start_from:
out_index = 0;
}
read_chars = safe_read(STDIN_FILENO, tr_buf, BUFSIZ);
read_chars = safe_read(STDIN_FILENO, str1, TR_BUFSIZ);
if (read_chars <= 0) {
if (read_chars < 0)
bb_perror_msg_and_die(bb_msg_read_error);
exit(EXIT_SUCCESS);
break;
}
in_index = 0;
}
c = tr_buf[in_index++];
c = str1[in_index++];
if ((opts & TR_OPT_delete) && invec[c])
continue;
coded = vector[c];
if ((flags & TR_OPT_delete) && invec[c])
if ((opts & TR_OPT_squeeze_reps) && last == coded
&& (invec[c] || outvec[coded])
) {
continue;
if ((flags & TR_OPT_squeeze_reps) && last == coded
&& (invec[c] || outvec[coded]))
continue;
output[out_index++] = last = coded;
}
str2[out_index++] = last = coded;
}
/* NOTREACHED */
return EXIT_SUCCESS;
}
+8 -8
View File
@@ -13,32 +13,32 @@
#include "libbb.h"
int tty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int tty_main(int argc, char **argv SKIP_INCLUDE_SUSv2(UNUSED_PARAM))
int tty_main(int argc, char **argv IF_NOT_INCLUDE_SUSv2(UNUSED_PARAM))
{
const char *s;
USE_INCLUDE_SUSv2(int silent;) /* Note: No longer relevant in SUSv3. */
IF_INCLUDE_SUSv2(int silent;) /* Note: No longer relevant in SUSv3. */
int retval;
xfunc_error_retval = 2; /* SUSv3 requires > 1 for error. */
USE_INCLUDE_SUSv2(silent = getopt32(argv, "s");)
USE_INCLUDE_SUSv2(argc -= optind;)
SKIP_INCLUDE_SUSv2(argc -= 1;)
IF_INCLUDE_SUSv2(silent = getopt32(argv, "s");)
IF_INCLUDE_SUSv2(argc -= optind;)
IF_NOT_INCLUDE_SUSv2(argc -= 1;)
/* gnu tty outputs a warning that it is ignoring all args. */
bb_warn_ignoring_args(argc);
retval = 0;
s = ttyname(0);
s = xmalloc_ttyname(0);
if (s == NULL) {
/* According to SUSv3, ttyname can fail with EBADF or ENOTTY.
* We know the file descriptor is good, so failure means not a tty. */
s = "not a tty";
retval = 1;
}
USE_INCLUDE_SUSv2(if (!silent) puts(s);)
SKIP_INCLUDE_SUSv2(puts(s);)
IF_INCLUDE_SUSv2(if (!silent) puts(s);)
IF_NOT_INCLUDE_SUSv2(puts(s);)
fflush_stdout_and_exit(retval);
}
+90 -35
View File
@@ -9,25 +9,43 @@
/* http://www.opengroup.org/onlinepubs/007904975/utilities/uname.html */
/* Option Example
-s, --sysname SunOS
-n, --nodename rocky8
-r, --release 4.0
-v, --version
-m, --machine sun
-a, --all SunOS rocky8 4.0 sun
The default behavior is equivalent to '-s'.
David MacKenzie <djm@gnu.ai.mit.edu> */
/* Busyboxed by Erik Andersen */
/* Further size reductions by Glenn McGrath and Manuel Novoa III. */
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
* -s, --sysname SunOS
* -n, --nodename rocky8
* -r, --release 4.0
* -v, --version
* -m, --machine sun
* -a, --all SunOS rocky8 4.0 sun
*
* Now does proper error checking on i/o. Plus some further space savings.
* The default behavior is equivalent to '-s'.
*
* David MacKenzie <djm@gnu.ai.mit.edu>
*
* GNU coreutils 6.10:
* Option: struct Example(s):
* utsname
* field:
* -s, --kernel-name sysname Linux
* -n, --nodename nodename localhost.localdomain
* -r, --kernel-release release 2.6.29
* -v, --kernel-version version #1 SMP Sun Jan 11 20:52:37 EST 2009
* -m, --machine machine x86_64 i686
* -p, --processor (none) x86_64 i686
* -i, --hardware-platform (none) x86_64 i386
* NB: vanilla coreutils reports "unknown" -p and -i,
* x86_64 and i686/i386 shown above are Fedora's inventions.
* -o, --operating-system (none) GNU/Linux
* -a, --all: all of the above, in the order shown.
* If -p or -i is not known, don't show them
*/
/* Busyboxed by Erik Andersen
*
* Before 2003: Glenn McGrath and Manuel Novoa III
* Further size reductions.
* Mar 16, 2003: Manuel Novoa III (mjn3@codepoet.org)
* Now does proper error checking on i/o. Plus some further space savings.
* Jan 2009:
* Fix handling of -a to not print "unknown", add -o and -i support.
*/
#include <sys/utsname.h>
@@ -35,37 +53,60 @@
typedef struct {
struct utsname name;
char processor[8]; /* for "unknown" */
char processor[sizeof(((struct utsname*)NULL)->machine)];
char platform[sizeof(((struct utsname*)NULL)->machine)];
char os[sizeof("GNU/Linux")];
} uname_info_t;
static const char options[] ALIGN1 = "snrvmpa";
static const char options[] ALIGN1 = "snrvmpioa";
static const unsigned short utsname_offset[] = {
offsetof(uname_info_t, name.sysname),
offsetof(uname_info_t, name.nodename),
offsetof(uname_info_t, name.release),
offsetof(uname_info_t, name.version),
offsetof(uname_info_t, name.machine),
offsetof(uname_info_t, processor)
offsetof(uname_info_t, name.sysname), /* -s */
offsetof(uname_info_t, name.nodename), /* -n */
offsetof(uname_info_t, name.release), /* -r */
offsetof(uname_info_t, name.version), /* -v */
offsetof(uname_info_t, name.machine), /* -m */
offsetof(uname_info_t, processor), /* -p */
offsetof(uname_info_t, platform), /* -i */
offsetof(uname_info_t, os), /* -o */
};
int uname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int uname_main(int argc UNUSED_PARAM, char **argv)
{
#if ENABLE_LONG_OPTS
static const char uname_longopts[] ALIGN1 =
/* name, has_arg, val */
"all\0" No_argument "a"
"kernel-name\0" No_argument "s"
"nodename\0" No_argument "n"
"kernel-release\0" No_argument "r"
"release\0" No_argument "r"
"kernel-version\0" No_argument "v"
"machine\0" No_argument "m"
"processor\0" No_argument "p"
"hardware-platform\0" No_argument "i"
"operating-system\0" No_argument "o"
;
#endif
uname_info_t uname_info;
#if defined(__sparc__) && defined(__linux__)
char *fake_sparc = getenv("FAKE_SPARC");
#endif
const char *unknown_str = "unknown";
const char *fmt;
const unsigned short *delta;
char toprint;
unsigned toprint;
IF_LONG_OPTS(applet_long_options = uname_longopts);
toprint = getopt32(argv, options);
if (argv[optind]) { /* coreutils-6.9 compat */
bb_show_usage();
}
if (toprint & (1 << 6)) { /* -a => all opts on */
toprint = 0x3f;
if (toprint & (1 << 8)) { /* -a => all opts on */
toprint = (1 << 8) - 1;
unknown_str = ""; /* -a does not print unknown fields */
}
if (toprint == 0) { /* no opts => -s (sysname) */
@@ -79,16 +120,30 @@ int uname_main(int argc UNUSED_PARAM, char **argv)
strcpy(uname_info.name.machine, "sparc");
}
#endif
strcpy(uname_info.processor, "unknown");
strcpy(uname_info.processor, unknown_str);
strcpy(uname_info.platform, unknown_str);
strcpy(uname_info.os, "GNU/Linux");
#if 0
/* Fedora does something like this */
strcpy(uname_info.processor, uname_info.name.machine);
strcpy(uname_info.platform, uname_info.name.machine);
if (uname_info.platform[0] == 'i'
&& uname_info.platform[1]
&& uname_info.platform[2] == '8'
&& uname_info.platform[3] == '6'
) {
uname_info.platform[1] = '3';
}
#endif
delta = utsname_offset;
fmt = " %s" + 1;
do {
if (toprint & 1) {
/* printf would not be safe here */
fputs((char *)(&uname_info) + *delta, stdout);
if (toprint > 1) {
bb_putchar(' ');
const char *p = (char *)(&uname_info) + *delta;
if (p[0]) {
printf(fmt, p);
fmt = " %s";
}
}
++delta;
+2 -1
View File
@@ -45,7 +45,7 @@ int uniq_main(int argc UNUSED_PARAM, char **argv)
};
skip_fields = skip_chars = 0;
max_chars = -1;
max_chars = INT_MAX;
opt_complementary = "f+:s+:w+";
opt = getopt32(argv, "cduf:s:w:", &skip_fields, &skip_chars, &max_chars);
@@ -84,6 +84,7 @@ int uniq_main(int argc UNUSED_PARAM, char **argv)
break;
}
free((char*)s1);
++dups; /* note: testing for overflow seems excessive. */
}
-1
View File
@@ -20,7 +20,6 @@
#include "libbb.h"
#include <utmp.h>
#include <time.h>
static void idle_string(char *str6, time_t t)
{
+1 -1
View File
@@ -20,7 +20,7 @@ int whoami_main(int argc, char **argv UNUSED_PARAM)
bb_show_usage();
/* Will complain and die if username not found */
puts(bb_getpwuid(NULL, -1, geteuid()));
puts(xuid2uname(geteuid()));
return fflush(stdout);
}
+3 -2
View File
@@ -35,7 +35,7 @@ config RUN_PARTS
config FEATURE_RUN_PARTS_LONG_OPTIONS
bool "Enable long options"
default n
depends on RUN_PARTS && GETOPT_LONG
depends on RUN_PARTS && LONG_OPTS
help
Support long options for the run-parts applet.
@@ -64,11 +64,12 @@ config FEATURE_START_STOP_DAEMON_FANCY
Support additional arguments.
-o|--oknodo ignored since we exit with 0 anyway
-v|--verbose
-N|--nicelevel N
config FEATURE_START_STOP_DAEMON_LONG_OPTIONS
bool "Enable long options"
default n
depends on START_STOP_DAEMON && GETOPT_LONG
depends on START_STOP_DAEMON && LONG_OPTS
help
Support long options for the start-stop-daemon applet.
Loaded 100 of 757 files, more files were not shown because too many files have changed in this diff. Show more