Compare commits

...
455 Commits
Author SHA1 Message Date
Denis Vlasenko 4a81fe4173 apply post-1.11.2 fixes, bump version to 1.11.3 2008-09-28 16:40:02 +00:00
Bernhard Reutner-Fischer 3e7eca97b9 - sync with trunk 2008-09-05 15:30:24 +00:00
Bernhard Reutner-Fischer 9e6fe061d4 - fix typo 2008-09-05 15:23:53 +00:00
Bernhard Reutner-Fischer a959a858a3 - pull r22872 from trunk:
pidof/killall: allow find_pid_by_name to find running
 processes started as scripts_with_name_longer_than_15_bytes.sh
 closes bug 4054 (and is generally neat)
2008-09-05 12:05:47 +00:00
Denis Vlasenko 2957fc6992 apply post-1.11.1 patches, bump version to 1.11.2 2008-08-21 08:32:12 +00:00
Bernhard Reutner-Fischer 6857e4e2f3 - fix typo 2008-08-06 17:39:05 +00:00
Bernhard Reutner-Fischer 9a22b56d36 - remove erroneous & from &var. By Vladimir. (r23056 from trunk) 2008-08-06 08:21:27 +00:00
Bernhard Reutner-Fischer a4d0cd0a31 - don't free user-supplied string (via -e)
- fix helptext
(r23046 from trunk)
2008-08-05 14:33:37 +00:00
Denis Vlasenko f2b846e277 cpio: dont use UNUSED_PARAM, it exists only in 1.11.1 2008-07-11 21:50:45 +00:00
Denis Vlasenko fa1649e9ac cpio: backport the fix for
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=466771
2008-07-11 21:47:23 +00:00
Denis Vlasenko dee8587d92 Apply post-1.11.0 patches. Bump version to 1.11.1. 2008-07-11 12:19:14 +00:00
Denis Vlasenko f941306199 defconfig fix; "help output to fd 2" fix 2008-06-25 12:52:37 +00:00
Denis Vlasenko dabe36e4a0 This is 1.11.0 2008-06-25 10:16:17 +00:00
Denis Vlasenko e06f61d273 mkfs_minix, fsck_minix: code shrink
function                                             old     new   delta
fsck_minix_main                                     3092    3094      +2
next                                                 539     538      -1
get_free_block                                       165     164      -1
check_zone_nr2                                       121     120      -1
alarm_intr                                            94      93      -1
recursive_check2                                     587     583      -4
recursive_check                                      587     583      -4
mkfs_minix_main                                     2974    2968      -6
map_block                                            237     231      -6
map_block2                                           341     333      -8
bad_zone                                              64      56      -8
write_block                                          619     610      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/11 up/down: 2/-49)            Total: -47 bytes
2008-06-25 10:00:58 +00:00
Denis Vlasenko 7049ff8696 whitespace fixes. no code changes 2008-06-25 09:53:17 +00:00
Denis Vlasenko f26e3d2e41 mount: fix mishandling of proto=tcp/udp
function                                             old     new   delta
singlemount                                         4729    4695     -34
2008-06-24 21:39:32 +00:00
Denis Vlasenko d0cc3f4ade mount: code shrink without logic changes. Added a comment
on possible mismatch with util-linux in -o remount handling.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

BASH_COMPAT off:
scanleft                                             101     262    +161
subevalvar                                           346     335     -11
BASH_COMPAT on:
subevalvar                                           346    1397   +1051
scanleft                                             101     262    +161
readtoken1                                          2739    2807     +68
cmdputs                                              397     399      +2
static.vstype                                         64      48     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 1282/-16)         Total: 1266 bytes
2008-03-25 01:17:40 +00:00
Denis Vlasenko 59f351ccda ash: add read -u; fix read -t and read -n; add testsuite entries. 2008-03-25 00:07:12 +00:00
Denis Vlasenko f39653e306 lpd: debugging by Vladimir: he found vda's breakage (trashed s[0])! 2008-03-24 21:19:51 +00:00
Denis Vlasenko cee01cfb2e diff: add testsuite entry for it 2008-03-24 20:33:47 +00:00
Denis Vlasenko dccfe05e17 diff: improve comments (no code chages) 2008-03-24 18:40:32 +00:00
Denis Vlasenko 64a76d7b44 patch: support for patches without dates and generated with -U1; shrink
function                                             old     new   delta
extract_filename                                       -      92     +92
extract_filename_and_free_line                        70       -     -70
patch_main                                          1096    1009     -87
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/1 up/down: 92/-157)           Total: -65 bytes
2008-03-24 18:18:03 +00:00
Denis Vlasenko c4c2cd44d2 diff: exclude D_EMPTY code if there is no support for -r
function                                             old     new   delta
diffreg                                             1808    1825     +17
files_differ                                         189     166     -23
2008-03-24 16:55:13 +00:00
Denis Vlasenko e9d67a81c8 diff: fix small bug; don't make a copy for "/dev/null" case 2008-03-24 16:28:47 +00:00
Denis Vlasenko 7fe0ebac5f diff: reordering and renaming of variables
function                                             old     new   delta
diff_main                                            843     848      +5
get_recursive_dirlist                                177     180      +3
add_to_dirlist                                        64      66      +2
change                                               329     326      -3
files_differ                                         182     176      -6
diffreg                                             1823    1808     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/3 up/down: 10/-24)            Total: -14 bytes
2008-03-24 16:19:21 +00:00
Denis Vlasenko 73132b9c12 diff: make a few variables local
function                                             old     new   delta
diffreg                                             1844    1823     -21
2008-03-24 15:04:24 +00:00
Denis Vlasenko 04211fd204 diff: make it work on pipes etc (needed for kernel compile)
function                                             old     new   delta
get_recursive_dirlist                                  -     177    +177
make_temp                                              -     144    +144
diffreg                                             1818    1844     +26
files_differ                                         175     182      +7
diff_main                                            842     843      +1
get_dir                                              177       -    -177
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 3/0 up/down: 355/-177)          Total: 178 bytes
2008-03-24 14:44:59 +00:00
Denis Vlasenko dc1cbf839d diff: shrink
function                                             old     new   delta
check                                                678    1607    +929
files_differ                                           -     175    +175
do_diff                                              436     433      -3
asciifile                                             94      90      -4
print_only                                            23      16      -7
diff_main                                            868     842     -26
prepare                                              339     301     -38
print_status                                         316     178    -138
diffreg                                             2993    1818   -1175
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/7 up/down: 1104/-1391)       Total: -287 bytes
2008-03-24 14:44:20 +00:00
Denis Vlasenko c693840fe8 *: whitespace fixes, no code changes 2008-03-24 02:18:03 +00:00
Denis Vlasenko 42cc304e90 lpr: add more accurate comments
*: trailing whitespace removal
2008-03-24 02:05:58 +00:00
Denis Vlasenko 39c77c3738 lpd: much safer against malicious input. Does not fork anymore,
as this is not needed.
2008-03-24 01:52:52 +00:00
Denis Vlasenko 0b6c6a9c9f lpd: fix OOM vulnerability (was eating arbitrarily large commands) 2008-03-24 00:04:42 +00:00
Denis Vlasenko a79428998d lpd: maintainer's update: now with spool helpers
function                                             old     new   delta
exec_helper                                            -     227    +227
sane                                                  66     117     +51
packed_usage                                       23806   23828     +22
lpd_main                                             486     504     +18
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 318/0)             Total: 318 bytes
2008-03-23 23:40:18 +00:00
Denis Vlasenko c93b162248 patch: shrink by Pascal Bellard <pascal.bellard AT ads-lu.com> (-80 bytes)
*: removal of #include <getopt.h>
2008-03-23 22:55:25 +00:00
Denis Vlasenko 324d26f9aa pscan: fix a typo in help text 2008-03-23 18:44:59 +00:00
Denis Vlasenko 715c16ab0a pscan: add -c, -b: report closed, blocked ports 2008-03-23 14:46:14 +00:00
Denis Vlasenko 69ca5a70fd tail: fix fallout from tail -c optimization 2008-03-23 03:28:40 +00:00
Denis Vlasenko c8bac033f3 bump version to 1.11.0.svn 2008-03-22 17:46:43 +00:00
Denis Vlasenko 45ecfc2f5c taskset: fix false failure in testsuite 2008-03-22 17:46:16 +00:00
Denis Vlasenko b9d0f0c762 webpage: typo fix 2008-03-21 21:22:24 +00:00
453 changed files with 17128 additions and 9177 deletions

No files matched your search

+44 -31
View File
@@ -13,22 +13,6 @@ menu "Busybox Settings"
menu "General Configuration"
config NITPICK
bool "See lots more (probably unnecessary) configuration options."
default n
help
Some BusyBox applets have more configuration options than anyone
will ever care about. To avoid drowining people in complexity, most
of the applet features that can be set to a sane default value are
hidden, unless you hit the above switch.
This is better than to telling people to edit the busybox source
code, but not by much.
See http://en.wikipedia.org/wiki/Fibber_McGee_and_Molly#The_Closet
You have been warned.
config DESKTOP
bool "Enable options for full-blown desktop systems"
default n
@@ -37,10 +21,21 @@ config DESKTOP
Select this only if you plan to use busybox on full-blown
desktop machine with common Linux distro, not on an embedded box.
config FEATURE_ASSUME_UNICODE
bool "Assume that 1:1 char/glyph correspondence is not true"
default n
help
This makes various applets aware that one byte is not
one character on screen.
Busybox aims to eventually work correctly with Unicode displays.
Any older encodings are not guaranteed to work.
Probably by the time when busybox will be fully Unicode-clean,
other encodings will be mainly of historic interest.
choice
prompt "Buffer allocation policy"
default FEATURE_BUFFERS_USE_MALLOC
depends on NITPICK
help
There are 3 ways BusyBox can handle buffer allocations:
- Use malloc. This costs code size for the call to xmalloc.
@@ -130,7 +125,6 @@ config FEATURE_DEVPTS
config FEATURE_CLEAN_UP
bool "Clean up all memory before exiting (usually not needed)"
default n
depends on NITPICK
help
As a size optimization, busybox normally exits without explicitly
freeing dynamically allocated memory or closing files. This saves
@@ -280,6 +274,14 @@ config STATIC
Most people will leave this set to 'N'.
config PIE
bool "Build BusyBox as a position independent executable"
default n
depends on !STATIC
help
(TODO: what is it and why/when is it useful?)
Most people will leave this set to 'N'.
config NOMMU
bool "Force NOMMU build"
default n
@@ -291,10 +293,12 @@ config NOMMU
Most people will leave this set to 'N'.
# PIE can be made to work with BUILD_LIBBUSYBOX, but currently
# build system does not support that
config BUILD_LIBBUSYBOX
bool "Build shared libbusybox"
default n
depends on !FEATURE_PREFER_APPLETS
depends on !FEATURE_PREFER_APPLETS && !PIE && !STATIC
help
Build a shared library libbusybox.so.N.N.N which contains all
busybox code.
@@ -381,6 +385,16 @@ config LFS
cp, mount, tar, and many others. If you want to access files larger
than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.
config CROSS_COMPILER_PREFIX
string "Cross Compiler prefix"
default ""
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.
endmenu
menu 'Debugging Options'
@@ -396,6 +410,17 @@ config DEBUG
Most people should answer N.
config DEBUG_PESSIMIZE
bool "Disable compiler optimizations."
default n
depends on DEBUG
help
The compiler's optimization of source code can eliminate and reorder
code, resulting in an executable that's hard to understand when
stepping through it with a debugger. This switches it off, resulting
in a much bigger executable that more closely matches the source
code.
config WERROR
bool "Abort compilation on any warning"
default n
@@ -404,18 +429,6 @@ config WERROR
Most people should answer N.
# Seems to be unused
#config DEBUG_PESSIMIZE
# bool "Disable compiler optimizations."
# default n
# depends on DEBUG
# help
# The compiler's optimization of source code can eliminate and reorder
# code, resulting in an executable that's hard to understand when
# stepping through it with a debugger. This switches it off, resulting
# in a much bigger executable that more closely matches the source
# code.
choice
prompt "Additional debugging library"
default NO_DEBUG_LIB
+36 -24
View File
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 10
SUBLEVEL = 0
PATCHLEVEL = 11
SUBLEVEL = 3
EXTRAVERSION =
NAME = Unnamed
@@ -142,17 +142,6 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
export srctree objtree VPATH TOPDIR
# SUBARCH tells the usermode build what the underlying arch is. That is set
# first, and if a usermode build is happening, the "ARCH=um" on the command
# line overrides the setting of ARCH below. If a native build is happening,
# then ARCH is assigned, getting whatever value it gets normally, and
# SUBARCH is subsequently ignored.
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ \
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
# Cross compiling and selecting different set of gcc/bin-utils
# ---------------------------------------------------------------------------
#
@@ -172,8 +161,32 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
# Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
CROSS_COMPILE ?=
# bbox: we may have CONFIG_CROSS_COMPILER_PREFIX in .config,
# and it has not been included yet... thus using an awkward syntax.
ifeq ($(CROSS_COMPILE),)
CROSS_COMPILE := $(shell grep ^CONFIG_CROSS_COMPILER_PREFIX .config 2>/dev/null)
CROSS_COMPILE := $(subst CONFIG_CROSS_COMPILER_PREFIX=,,$(CROSS_COMPILE))
CROSS_COMPILE := $(subst ",,$(CROSS_COMPILE))
endif
# SUBARCH tells the usermode build what the underlying arch is. That is set
# first, and if a usermode build is happening, the "ARCH=um" on the command
# line overrides the setting of ARCH below. If a native build is happening,
# then ARCH is assigned, getting whatever value it gets normally, and
# SUBARCH is subsequently ignored.
ifneq ($(CROSS_COMPILE),)
SUBARCH := $(shell echo $(CROSS_COMPILE) | cut -d- -f1)
else
SUBARCH := $(shell uname -m)
endif
SUBARCH := $(shell echo $(SUBARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ \
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
ARCH ?= $(SUBARCH)
# Architecture as present in compile.h
UTS_MACHINE := $(ARCH)
@@ -302,6 +315,8 @@ AFLAGS_KERNEL =
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
CFLAGS := $(CFLAGS)
# Added only to final link stage of busybox binary
CFLAGS_busybox := $(CFLAGS_busybox)
CPPFLAGS := $(CPPFLAGS)
AFLAGS := $(AFLAGS)
LDFLAGS := $(LDFLAGS)
@@ -361,7 +376,8 @@ endif
# of make so .config is not included in this case either (for *config).
no-dot-config-targets := clean mrproper distclean \
cscope TAGS tags help %docs check%
cscope TAGS tags help %docs
#bbox# check% is removed from above
config-targets := 0
mixed-targets := 0
@@ -497,12 +513,6 @@ all: busybox
#bbox# NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
CHECKFLAGS += $(NOSTDINC_FLAGS)
# warn about C99 declaration after statement
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
# disable pointer signedness warnings in gcc 4.0
CFLAGS += $(call cc-option,-Wno-pointer-sign,)
# Default kernel image to build when no specific target is given.
# KBUILD_IMAGE may be overruled on the commandline or
# set in the environment
@@ -572,7 +582,7 @@ quiet_cmd_busybox__ ?= LINK $@
cmd_busybox__ ?= $(srctree)/scripts/trylink \
"$@" \
"$(CC)" \
"$(CFLAGS)" \
"$(CFLAGS) $(CFLAGS_busybox)" \
"$(LDFLAGS) $(EXTRA_LDFLAGS)" \
"$(core-y)" \
"$(libs-y)" \
@@ -688,6 +698,8 @@ ifeq ($(SKIP_STRIP),y)
else
$(Q)$(STRIP) -s --remove-section=.note --remove-section=.comment \
busybox_unstripped -o $@
# strip is confused by PIE executable and does not set exec bits
$(Q)chmod a+x $@
endif
# The actual objects are generated when descending,
@@ -921,7 +933,7 @@ endif # CONFIG_MODULES
# Directories & files removed with 'make clean'
CLEAN_DIRS += $(MODVERDIR)
CLEAN_FILES += busybox* System.map .kernelrelease \
CLEAN_FILES += busybox busybox_unstripped* System.map .kernelrelease \
.tmp_kallsyms* .tmp_version .tmp_busybox* .tmp_System.map
# Directories & files removed with 'make mrproper'
+9 -4
View File
@@ -46,15 +46,20 @@ ifneq ($(strip $(DO_INSTALL_LIBS)),n)
done
endif
# Not very elegant: copies testsuite to objdir...
# (cp -pPR is POSIX-compliant (cp -dpR or cp -a would not be))
.PHONY: check
.PHONY: test
check test: busybox busybox.links
bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \
$(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)
test -d $(objtree)/testsuite || cp -pPR $(srctree)/testsuite $(objtree)
bindir=$(objtree) srcdir=$(srctree)/testsuite \
$(SHELL) -c "cd $(objtree)/testsuite && $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)"
.PHONY: release
release: distclean
cd ..; \
rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
cp -a busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
cp -pPR busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
-name .svn \
-print \
@@ -94,7 +99,7 @@ stksizes: busybox_unstripped
.PHONY: bigdata
bigdata: busybox_unstripped
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [tr] '
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [trw] '
# Documentation Targets
.PHONY: doc
+40 -27
View File
@@ -11,38 +11,31 @@ CPPFLAGS += $(call cc-option,-std=gnu99,)
CPPFLAGS += \
-Iinclude -Ilibbb \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include -I$(srctree)/libbb) \
-include include/autoconf.h \
-D_GNU_SOURCE -DNDEBUG \
$(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
-D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
# flag checks are grouped together to speed the checks up a bit..
CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,)
CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
CFLAGS += $(call cc-option,-Wall,)
CFLAGS += $(call cc-option,-Wshadow,)
CFLAGS += $(call cc-option,-Wwrite-strings,)
CFLAGS += $(call cc-option,-Wundef,)
CFLAGS += $(call cc-option,-Wstrict-prototypes,)
CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
# If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
# (or anything else for that matter) make sure that it is still possible
# to build bbox without warnings. Current offender: find.c:alloc_action().
# Looks more like gcc bug: gcc will warn on it with or without prototype.
# But still, warning-free compile is a must, or else we will drown
# in warnings pretty soon.
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
# warn about C99 declaration after statement
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
# If you want to add more -Wsomething above, make sure that it is
# still possible to build bbox without warnings.
ifeq ($(CONFIG_WERROR),y)
CFLAGS += $(call cc-option,-Werror,)
else
# for development, warn a little bit about unused results..
CPPFLAGS += -D_FORTIFY_SOURCE=2
endif
# gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
# gcc emits bogus "no prev proto" warning on find.c:alloc_action()
ifneq ($(CONFIG_WERROR),y)
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
endif
CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
CFLAGS += $(call cc-option,-fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
# -fno-guess-branch-probability: prohibit pseudo-random guessing
# of branch probabilities (hopefully makes bloatcheck more stable):
CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
@@ -53,21 +46,38 @@ CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1
# be fixed..
#CFLAGS+=$(call cc-option,-Wconversion,)
ifeq ($(CONFIG_DEBUG),y)
CFLAGS += $(call cc-option,-g)
ifneq ($(CONFIG_DEBUG),y)
CFLAGS += $(call cc-option,-Os,)
else
CFLAGS += $(call cc-option,-g,)
ifeq ($(CONFIG_DEBUG_PESSIMIZE),y)
CFLAGS += $(call cc-option,-O0,)
else
CFLAGS += $(call cc-option,-Os,)
endif
endif
# If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
ARCH_FPIC ?= -fpic
ARCH_FPIE ?= -fpie
ARCH_PIE ?= -pie
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
# on i386: 14% smaller libbusybox.so
# (code itself is 9% bigger, we save on relocs/PLT/GOT)
CFLAGS += -fpic
CFLAGS += $(ARCH_FPIC)
# and another 4% reduction of libbusybox.so:
# (external entry points must be marked EXTERNALLY_VISIBLE)
CFLAGS += $(call cc-option,-fvisibility=hidden)
endif
ifeq ($(CONFIG_STATIC),y)
LDFLAGS += -static
CFLAGS_busybox += -static
endif
ifeq ($(CONFIG_PIE),y)
CFLAGS_busybox += $(ARCH_PIE)
CFLAGS += $(ARCH_FPIE)
endif
LDLIBS += m crypt
@@ -88,10 +98,13 @@ ifeq ($(CONFIG_DMALLOC),y)
LDLIBS += dmalloc
endif
#LDFLAGS += -nostdlib
LDFLAGS_ELF2FLT = -Wl,-elf2flt
ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
# If a flat binary should be built, CFLAGS_busybox="-Wl,-elf2flt"
# env var should be set for make invocation.
# Here we check whether CFLAGS_busybox indeed contains that flag.
# (For historical reasons, we also check LDFLAGS, which doesn't
# seem to be entirely correct variable to put "-Wl,-elf2flt" into).
W_ELF2FLT = -Wl,-elf2flt
ifneq (,$(findstring $(W_ELF2FLT),$(LDFLAGS) $(CFLAGS_busybox)))
SKIP_STRIP = y
endif
+4 -11
View File
@@ -6,7 +6,7 @@ do one of these bounce an email off the person it's listed under to see if they
have any suggestions how they plan to go about it, and to minimize conflicts
between your work and theirs. But otherwise, all of these are fair game.
Rob Landley <rob@landley.net>:
Rob Landley suggested these:
Add a libbb/platform.c
Implement fdprintf() for platforms that haven't got one.
Implement bb_realpath() that can handle NULL on non-glibc.
@@ -24,11 +24,6 @@ Rob Landley <rob@landley.net>:
but less buggy :)
init
General cleanup (should use ENABLE_FEATURE_INIT_SYSLOG and ENABLE_FEATURE_INIT_DEBUG).
depmod
busybox lacks a way to update module deps when running from firmware without the
use of the depmod.pl (perl is to bloated for most embedded setups) and or orig
modutils. The orig depmod is rather pointless to have to add to a firmware image
in when we already have a insmod/rmmod and friends.
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
@@ -146,7 +141,7 @@ man
(How doclifter might work into this is anybody's guess.)
---
ar
Write support?
Write support!
---
stty / catv
stty's visible() function and catv's guts are identical. Merge them into
@@ -282,10 +277,6 @@ Minor stuff:
---
use bb_perror_msg where appropriate: See
egrep "[^_]perror"
---
Remove superfluous fmt occurances: e.g.
fprintf(stderr, "%s: %s not found\n", "unalias", *argptr);
-> fprintf(stderr, "unalias: %s not found\n", *argptr);
---
possible code duplication ingroup() and is_a_group_member()
---
@@ -294,6 +285,8 @@ Minor stuff:
See grep -r strtod
Alot of duplication that wants cleanup.
---
in_ether duplicated in network/{interface,ifconfig}.c
---
Code cleanup:
+12 -6
View File
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Busybox version: 1.10.0.svn
# Thu Mar 20 14:54:21 2008
# Busybox version: 1.11.0.svn
# Mon Apr 21 23:20:35 2008
#
CONFIG_HAVE_DOT_CONFIG=y
@@ -12,7 +12,6 @@ CONFIG_HAVE_DOT_CONFIG=y
#
# General Configuration
#
CONFIG_NITPICK=y
CONFIG_DESKTOP=y
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
@@ -100,6 +99,7 @@ CONFIG_FEATURE_AR_LONG_FILENAMES=y
CONFIG_BUNZIP2=y
CONFIG_BZIP2=y
CONFIG_CPIO=y
CONFIG_FEATURE_CPIO_O=y
CONFIG_DPKG=y
CONFIG_DPKG_DEB=y
CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY=y
@@ -130,7 +130,6 @@ CONFIG_UNZIP=y
#
# Common options for cpio and tar
#
CONFIG_FEATURE_UNARCHIVE_TAPE=y
#
# Common options for dpkg and dpkg_deb
@@ -486,6 +485,7 @@ CONFIG_LOSETUP=y
CONFIG_MDEV=y
CONFIG_FEATURE_MDEV_CONF=y
CONFIG_FEATURE_MDEV_RENAME=y
CONFIG_FEATURE_MDEV_RENAME_REGEXP=y
CONFIG_FEATURE_MDEV_EXEC=y
CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
CONFIG_MKSWAP=y
@@ -522,6 +522,7 @@ CONFIG_PIVOT_ROOT=y
CONFIG_RDATE=y
CONFIG_READPROFILE=y
CONFIG_RTCWAKE=y
CONFIG_SCRIPT=y
CONFIG_SETARCH=y
CONFIG_SWAPONOFF=y
CONFIG_SWITCH_ROOT=y
@@ -560,6 +561,7 @@ CONFIG_DC=y
# CONFIG_FEATURE_DEVFS is not set
CONFIG_EJECT=y
CONFIG_FEATURE_EJECT_SCSI=y
CONFIG_FBSPLASH=y
CONFIG_LAST=y
CONFIG_LESS=y
CONFIG_FEATURE_LESS_MAXLINES=9999999
@@ -578,6 +580,7 @@ CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA=y
CONFIG_MAKEDEVS=y
# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
CONFIG_FEATURE_MAKEDEVS_TABLE=y
CONFIG_MAN=y
CONFIG_MICROCOM=y
CONFIG_MOUNTPOINT=y
CONFIG_MT=y
@@ -585,9 +588,9 @@ CONFIG_RAIDAUTORUN=y
CONFIG_READAHEAD=y
CONFIG_RUNLEVEL=y
CONFIG_RX=y
CONFIG_SCRIPT=y
CONFIG_STRINGS=y
CONFIG_SETSID=y
CONFIG_STRINGS=y
CONFIG_SYMLINKS=y
CONFIG_TASKSET=y
CONFIG_FEATURE_TASKSET_FANCY=y
CONFIG_TIME=y
@@ -604,6 +607,7 @@ CONFIG_ARP=y
CONFIG_ARPING=y
CONFIG_BRCTL=y
CONFIG_FEATURE_BRCTL_FANCY=y
CONFIG_FEATURE_BRCTL_SHOW=y
CONFIG_DNSD=y
CONFIG_ETHER_WAKE=y
CONFIG_FAKEIDENTD=y
@@ -752,6 +756,7 @@ CONFIG_WATCH=y
# 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
@@ -781,6 +786,7 @@ CONFIG_MSH=y
#
CONFIG_FEATURE_SH_EXTRA_QUIET=y
CONFIG_FEATURE_SH_STANDALONE=y
CONFIG_FEATURE_SH_NOFORK=y
CONFIG_CTTYHACK=y
#
+15 -4
View File
@@ -47,6 +47,7 @@ int main(int argc, char **argv)
{
int i;
int ofs;
unsigned MAX_APPLET_NAME_LEN = 1;
qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name);
@@ -69,15 +70,23 @@ int main(int argc, char **argv)
/* Keep in sync with include/busybox.h! */
puts("/* This is a generated file, don't edit */");
puts("/* This is a generated file, don't edit */\n");
puts("const char applet_names[] ALIGN1 = \"\"\n");
printf("#define NUM_APPLETS %u\n", NUM_APPLETS);
if (NUM_APPLETS == 1) {
printf("#define SINGLE_APPLET_STR \"%s\"\n", applets[0].name);
printf("#define SINGLE_APPLET_MAIN %s_main\n", applets[0].name);
}
puts("\nconst char applet_names[] ALIGN1 = \"\"");
for (i = 0; i < NUM_APPLETS; i++) {
printf("\"%s\" \"\\0\"\n", applets[i].name);
if (MAX_APPLET_NAME_LEN < strlen(applets[i].name))
MAX_APPLET_NAME_LEN = strlen(applets[i].name);
}
puts(";");
puts("int (*const applet_main[])(int argc, char **argv) = {");
puts("\nint (*const applet_main[])(int argc, char **argv) = {");
for (i = 0; i < NUM_APPLETS; i++) {
printf("%s_main,\n", applets[i].main);
}
@@ -108,8 +117,10 @@ int main(int argc, char **argv)
printf("0x%02x,\n", v);
i++;
}
puts("};");
puts("};\n");
#endif
printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
return 0;
}
+2 -4
View File
@@ -14,13 +14,11 @@ const char *applet_name;
int main(int argc, char **argv)
{
applet_name = argv[0];
return APPLET_main(argc,argv);
}
void bb_show_usage(void)
{
printf(APPLET_full_usage "\n");
exit(1);
fputs(APPLET_full_usage "\n", stdout);
exit(EXIT_FAILURE);
}
+1 -1
View File
@@ -37,7 +37,7 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
for i in $DO_INSTALL_LIBS; do
rm -f $prefix/$libdir/$i || exit 1
if [ -f $i ]; then
cp -a $i $prefix/$libdir/ || exit 1
cp -pPR $i $prefix/$libdir/ || exit 1
chmod 0644 $prefix/$libdir/$i || exit 1
fi
done
+12 -1
View File
@@ -5,6 +5,17 @@
* object directory */
#include "../include/autoconf.h"
/* Since we can't use platform.h, have to do this again by hand: */
#if ENABLE_NOMMU
#define BB_MMU 0
#define USE_FOR_NOMMU(...) __VA_ARGS__
#define USE_FOR_MMU(...)
#else
#define BB_MMU 1
#define USE_FOR_NOMMU(...)
#define USE_FOR_MMU(...) __VA_ARGS__
#endif
static const char usage_messages[] = ""
#define MAKE_USAGE
#include "usage.h"
@@ -13,6 +24,6 @@ static const char usage_messages[] = ""
int main(void)
{
write(1, usage_messages, sizeof(usage_messages));
write(STDOUT_FILENO, usage_messages, sizeof(usage_messages));
return 0;
}
+11 -4
View File
@@ -14,14 +14,21 @@ exec >"$target"
echo 'static const char packed_usage[] ALIGN1 = {'
# Extra effort to avoid using "od -t x1": -t is not available
# in non-CONFIG_DESKTOPed busybox od
## 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 -x \
"$loc/usage" | bzip2 -1 | od -v -t x1 \
| $SED -e 's/^[^ ]*//' \
| $SED -e 's/ //g' \
| grep -v '^$' \
| $SED -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
| $SED -e 's/\(..\)/0x\1,/g'
echo '};'
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
+9 -8
View File
@@ -78,6 +78,14 @@ config CPIO
Unless you have a specific application which requires cpio, you should
probably say N here.
config FEATURE_CPIO_O
bool "Support for archive creation"
default n
depends on CPIO
help
This implementation of cpio can create cpio archives in the "newc"
format only.
config DPKG
bool "dpkg"
default n
@@ -279,7 +287,7 @@ config UNLZMA
should probably say N here.
config FEATURE_LZMA_FAST
bool "Optimze unlzma for speed"
bool "Optimize unlzma for speed"
default n
depends on UNLZMA
help
@@ -299,13 +307,6 @@ config UNZIP
comment "Common options for cpio and tar"
depends on CPIO || TAR
config FEATURE_UNARCHIVE_TAPE
bool "Enable tape drive support"
default n
depends on CPIO || TAR
help
I don't think this is needed anymore.
comment "Common options for dpkg and dpkg_deb"
depends on DPKG || DPKG_DEB
+15 -1
View File
@@ -256,10 +256,24 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
return status;
}
/*
* Linux kernel build uses gzip -d -n. We accept and ignore it.
* Man page says:
* -n --no-name
* gzip: do not save the original file name and time stamp.
* (The original name is always saved if the name had to be truncated.)
* gunzip: do not restore the original file name/time even if present
* (remove only the gzip suffix from the compressed file name).
* This option is the default when decompressing.
* -N --name
* gzip: always save the original file name and time stamp (this is the default)
* gunzip: restore the original file name and time stamp if present.
*/
int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int gunzip_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
getopt32(argv, "cfvdt");
getopt32(argv, "cfvdtn");
argv += optind;
/* if called as zcat */
if (applet_name[1] == 'c')
+287 -20
View File
@@ -7,35 +7,298 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* Limitations:
* Doesn't check CRC's
* Only supports new ASCII and CRC formats
* Doesn't check CRC's
* Only supports new ASCII and CRC formats
*
*/
#include "libbb.h"
#include "unarchive.h"
#define CPIO_OPT_EXTRACT 0x01
#define CPIO_OPT_TEST 0x02
#define CPIO_OPT_UNCONDITIONAL 0x04
#define CPIO_OPT_VERBOSE 0x08
#define CPIO_OPT_FILE 0x10
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
#define CPIO_OPT_PRESERVE_MTIME 0x40
#if ENABLE_FEATURE_CPIO_O
static off_t cpio_pad4(off_t size)
{
int i;
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 (GNU cpio) 2.9 help (abridged):
Main operation mode:
-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
Operation modifiers valid in any mode:
--block-size=SIZE I/O block size = SIZE * 512 bytes
-B I/O block size = 5120 bytes
-c Use the old portable (ASCII) archive format
-C, --io-size=NUMBER I/O block size to the given NUMBER bytes
-f, --nonmatching Only copy files that do not match given pattern
-F, --file=FILE Use FILE instead of standard input or output
-H, --format=FORMAT Use given archive FORMAT
-M, --message=STRING Print STRING when the end of a volume of the
backup media is reached
-n, --numeric-uid-gid If -v, show numeric UID and GID
--quiet Do not print the number of blocks copied
--rsh-command=COMMAND Use remote COMMAND instead of rsh
-v, --verbose Verbosely list the files processed
-V, --dot Print a "." for each file processed
-W, --warning=FLAG Control warning display: 'none','truncate','all';
multiple options accumulate
Operation modifiers valid only in --extract mode:
-b, --swap Swap both halfwords of words and bytes of
halfwords in the data (equivalent to -sS)
-r, --rename Interactively rename files
-s, --swap-bytes Swap the bytes of each halfword in the files
-S, --swap-halfwords Swap the halfwords of each word (4 bytes)
--to-stdout Extract files to standard output
-E, --pattern-file=FILE Read additional patterns specifying filenames to
extract or list from FILE
--only-verify-crc Verify CRC's, don't actually extract the files
Operation modifiers valid only in --create mode:
-A, --append Append to an existing archive
-O FILE File to use instead of standard output
Operation modifiers valid only in --pass-through mode:
-l, --link Link files instead of copying them, when possible
Operation modifiers valid in --extract and --create modes:
--absolute-filenames Do not strip file system prefix components from
the file names
--no-absolute-filenames Create all files relative to the current dir
Operation modifiers valid in --create and --pass-through modes:
-0, --null A list of filenames is terminated by a NUL
-a, --reset-access-time Reset the access times of files after reading them
-I FILE File to use instead of standard input
-L, --dereference Dereference symbolic links (copy the files
that they point to instead of copying the links)
-R, --owner=[USER][:.][GROUP] Set owner of created files
Operation modifiers valid in --extract and --pass-through modes:
-d, --make-directories Create leading directories where needed
-m, --preserve-modification-time
Retain previous file modification times when
creating files
--no-preserve-owner Do not change the ownership of the files
--sparse Write files with blocks of zeros as sparse files
-u, --unconditional Replace all files unconditionally
*/
int cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cpio_main(int argc, char **argv)
int cpio_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
archive_handle_t *archive_handle;
char *cpio_filename = NULL;
char *cpio_filename;
USE_FEATURE_CPIO_O(const char *cpio_fmt = "";)
unsigned opt;
enum {
CPIO_OPT_EXTRACT = (1 << 0),
CPIO_OPT_TEST = (1 << 1),
CPIO_OPT_UNCONDITIONAL = (1 << 2),
CPIO_OPT_VERBOSE = (1 << 3),
CPIO_OPT_FILE = (1 << 4),
CPIO_OPT_CREATE_LEADING_DIR = (1 << 5),
CPIO_OPT_PRESERVE_MTIME = (1 << 6),
CPIO_OPT_CREATE = (1 << 7),
CPIO_OPT_FORMAT = (1 << 8),
};
/* Initialise */
#if ENABLE_GETOPT_LONG && ENABLE_DESKTOP
applet_long_options =
"extract\0" No_argument "i"
"list\0" No_argument "t"
#if ENABLE_FEATURE_CPIO_O
"create\0" No_argument "o"
"format\0" Required_argument "H"
#endif
;
#endif
/* Initialize */
archive_handle = init_handle();
archive_handle->src_fd = STDIN_FILENO;
archive_handle->seek = seek_by_read;
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
archive_handle->flags = ARCHIVE_EXTRACT_NEWER;
#if ENABLE_FEATURE_CPIO_O
opt = getopt32(argv, "ituvF:dmoH:", &cpio_filename, &cpio_fmt);
if (opt & CPIO_OPT_CREATE) {
if (*cpio_fmt != 'n')
bb_show_usage();
if (opt & CPIO_OPT_FILE) {
fclose(stdout);
stdout = fopen(cpio_filename, "w");
/* Paranoia: I don't trust libc that much */
xdup2(fileno(stdout), STDOUT_FILENO);
}
return cpio_o();
}
#else
opt = getopt32(argv, "ituvF:dm", &cpio_filename);
#endif
argv += optind;
/* One of either extract or test options must be given */
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
@@ -63,21 +326,25 @@ int cpio_main(int argc, char **argv)
archive_handle->action_header = header_list;
}
}
if (cpio_filename) { /* CPIO_OPT_FILE */
if (opt & CPIO_OPT_FILE) { /* -F */
archive_handle->src_fd = xopen(cpio_filename, O_RDONLY);
archive_handle->seek = seek_by_jump;
}
if (opt & CPIO_OPT_CREATE_LEADING_DIR) {
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
}
while (optind < argc) {
archive_handle->filter = filter_accept_list;
llist_add_to(&(archive_handle->accept), argv[optind]);
optind++;
if (opt & CPIO_OPT_PRESERVE_MTIME) {
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
}
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
while (*argv) {
archive_handle->filter = filter_accept_list;
llist_add_to(&(archive_handle->accept), *argv);
argv++;
}
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
continue;
return EXIT_SUCCESS;
}
+107 -81
View File
@@ -75,10 +75,21 @@ typedef struct status_node_s {
unsigned status:16; /* was:14 */ /* has to fit STATUS_HASH_PRIME */
} status_node_t;
/* Were statically declared here, but such a big bss is nommu-unfriendly */
static char **name_hashtable; /* [NAME_HASH_PRIME + 1] */
static common_node_t **package_hashtable; /* [PACKAGE_HASH_PRIME + 1] */
static status_node_t **status_hashtable; /* [STATUS_HASH_PRIME + 1] */
/* Globals */
struct globals {
char *name_hashtable[NAME_HASH_PRIME + 1];
common_node_t *package_hashtable[PACKAGE_HASH_PRIME + 1];
status_node_t *status_hashtable[STATUS_HASH_PRIME + 1];
};
#define G (*ptr_to_globals)
#define name_hashtable (G.name_hashtable )
#define package_hashtable (G.package_hashtable)
#define status_hashtable (G.status_hashtable )
#define INIT_G() do { \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
} while (0)
/* Even numbers are for 'extras', like ored dependencies or null */
enum edge_type_e {
@@ -124,7 +135,7 @@ static void make_hash(const char *key, unsigned *start, unsigned *decrement, con
* shift amount is mod 24 because long int is 32 bit and data
* to be shifted is 8, don't want to shift data to where it has
* no effect*/
hash_num += ((key[i] + key[i-1]) << ((key[i] * i) % 24));
hash_num += (key[i] + key[i-1]) << ((key[i] * i) % 24);
}
*start = (unsigned) hash_num % hash_prime;
*decrement = (unsigned) 1 + (hash_num % (hash_prime - 1));
@@ -133,8 +144,8 @@ static void make_hash(const char *key, unsigned *start, unsigned *decrement, con
/* this adds the key to the hash table */
static int search_name_hashtable(const char *key)
{
unsigned probe_address = 0;
unsigned probe_decrement = 0;
unsigned probe_address;
unsigned probe_decrement;
make_hash(key, &probe_address, &probe_decrement, NAME_HASH_PRIME);
while (name_hashtable[probe_address] != NULL) {
@@ -155,8 +166,8 @@ static int search_name_hashtable(const char *key)
*/
static unsigned search_status_hashtable(const char *key)
{
unsigned probe_address = 0;
unsigned probe_decrement = 0;
unsigned probe_address;
unsigned probe_decrement;
make_hash(key, &probe_address, &probe_decrement, STATUS_HASH_PRIME);
while (status_hashtable[probe_address] != NULL) {
@@ -312,11 +323,10 @@ static int test_version(const unsigned version1, const unsigned version2, const
return FALSE;
}
static int search_package_hashtable(const unsigned name, const unsigned version, const unsigned operator)
{
unsigned probe_address = 0;
unsigned probe_decrement = 0;
unsigned probe_address;
unsigned probe_decrement;
make_hash(name_hashtable[name], &probe_address, &probe_decrement, PACKAGE_HASH_PRIME);
while (package_hashtable[probe_address] != NULL) {
@@ -410,10 +420,10 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
if ((edge_type == EDGE_DEPENDS || edge_type == EDGE_PRE_DEPENDS)
&& (strcmp(field, field2) != 0)
) {
or_edge = xmalloc(sizeof(edge_t));
or_edge = xzalloc(sizeof(edge_t));
or_edge->type = edge_type + 1;
or_edge->name = search_name_hashtable(field);
or_edge->version = 0; // tracks the number of alternatives
//or_edge->version = 0; // tracks the number of alternatives
add_edge_to_node(parent_node, or_edge);
}
@@ -439,17 +449,13 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
if (offset_ch > 0) {
if (strncmp(version, "=", offset_ch) == 0) {
edge->operator = VER_EQUAL;
}
else if (strncmp(version, "<<", offset_ch) == 0) {
} else if (strncmp(version, "<<", offset_ch) == 0) {
edge->operator = VER_LESS;
}
else if (strncmp(version, "<=", offset_ch) == 0) {
} else if (strncmp(version, "<=", offset_ch) == 0) {
edge->operator = VER_LESS_EQUAL;
}
else if (strncmp(version, ">>", offset_ch) == 0) {
} else if (strncmp(version, ">>", offset_ch) == 0) {
edge->operator = VER_MORE;
}
else if (strncmp(version, ">=", offset_ch) == 0) {
} else if (strncmp(version, ">=", offset_ch) == 0) {
edge->operator = VER_MORE_EQUAL;
} else {
bb_error_msg_and_die("illegal operator");
@@ -735,7 +741,6 @@ static const char *describe_status(int status_num)
return "is not installed or flagged to be installed";
}
static void index_status_file(const char *filename)
{
FILE *status_file;
@@ -1152,9 +1157,9 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
static char **create_list(const char *filename)
{
FILE *list_stream;
char **file_list = NULL;
char *line = NULL;
int count = 0;
char **file_list;
char *line;
int count;
/* don't use [xw]fopen here, handle error ourself */
list_stream = fopen(filename, "r");
@@ -1162,17 +1167,15 @@ static char **create_list(const char *filename)
return NULL;
}
while ((line = xmalloc_getline(list_stream)) != NULL) {
file_list = NULL;
count = 0;
while ((line = xmalloc_fgetline(list_stream)) != NULL) {
file_list = xrealloc(file_list, sizeof(char *) * (count + 2));
file_list[count] = line;
count++;
file_list[count++] = line;
file_list[count] = NULL;
}
fclose(list_stream);
if (count == 0) {
return NULL;
}
file_list[count] = NULL;
return file_list;
}
@@ -1209,24 +1212,54 @@ static int remove_file_array(char **remove_names, char **exclude_names)
return (remove_flag == 0);
}
static int run_package_script(const char *package_name, const char *script_type)
static void run_package_script_or_die(const char *package_name, const char *script_type)
{
struct stat path_stat;
char *script_path;
int result;
script_path = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, script_type);
/* If the file doesnt exist is isnt a fatal */
result = lstat(script_path, &path_stat) < 0 ? EXIT_SUCCESS : system(script_path);
/* If the file doesnt exist is isnt fatal */
result = access(script_path, F_OK) ? EXIT_SUCCESS : system(script_path);
free(script_path);
return result;
if (result)
bb_error_msg_and_die("%s failed, exit code %d", script_type, result);
}
/*
The policy manual defines what scripts get called when and with
what arguments. I realize that busybox does not support all of
these scenarios, but it does support some of them; it does not,
however, run them with any parameters in run_package_script_or_die().
Here are the scripts:
preinst install
preinst install <old_version>
preinst upgrade <old_version>
preinst abort_upgrade <new_version>
postinst configure <most_recent_version>
postinst abort-upgade <new_version>
postinst abort-remove
postinst abort-remove in-favour <package> <version>
postinst abort-deconfigure in-favor <failed_install_package> removing <conflicting_package> <version>
prerm remove
prerm upgrade <new_version>
prerm failed-upgrade <old_version>
prerm remove in-favor <package> <new_version>
prerm deconfigure in-favour <package> <version> removing <package> <version>
postrm remove
postrm purge
postrm upgrade <new_version>
postrm failed-upgrade <old_version>
postrm abort-install
postrm abort-install <old_version>
postrm abort-upgrade <old_version>
postrm disappear <overwriter> <version>
*/
static const char *const all_control_files[] = {
"preinst", "postinst", "prerm", "postrm",
"list", "md5sums", "shlibs", "conffiles",
"config", "templates", NULL
"config", "templates"
};
static char **all_control_list(const char *package_name)
@@ -1235,9 +1268,10 @@ static char **all_control_list(const char *package_name)
char **remove_files;
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = xzalloc(sizeof(all_control_files));
while (all_control_files[i]) {
remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, all_control_files[i]);
remove_files = xzalloc(sizeof(all_control_files) + sizeof(char*));
while (i < ARRAY_SIZE(all_control_files)) {
remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s",
package_name, all_control_files[i]);
i++;
}
@@ -1310,27 +1344,26 @@ static void remove_package(const unsigned package_num, int noisy)
if (noisy)
printf("Removing %s (%s)...\n", package_name, package_version);
/* run prerm script */
if (run_package_script(package_name, "prerm") != 0) {
bb_error_msg_and_die("script failed, prerm failure");
}
/* Run prerm script */
run_package_script_or_die(package_name, "prerm");
/* Create a list of files to remove, and a separate list of those to keep */
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
remove_files = create_list(list_name);
sprintf(conffile_name, "/var/lib/dpkg/info/%s.conffiles", package_name);
sprintf(conffile_name, "/var/lib/dpkg/info/%s.%s", package_name, "conffiles");
exclude_files = create_list(conffile_name);
/* Some directories can't be removed straight away, so do multiple passes */
while (remove_file_array(remove_files, exclude_files)) /*repeat */;
while (remove_file_array(remove_files, exclude_files))
continue;
free_array(exclude_files);
free_array(remove_files);
/* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
exclude_files = xzalloc(sizeof(char*) * 3);
exclude_files[0] = xstrdup(conffile_name);
exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.postrm", package_name);
exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
/* Create a list of all /var/lib/dpkg/info/<package> files */
remove_files = all_control_list(package_name);
@@ -1339,8 +1372,10 @@ static void remove_package(const unsigned package_num, int noisy)
free_array(remove_files);
free_array(exclude_files);
/* rename <package>.conffile to <package>.list */
xrename(conffile_name, list_name);
/* rename <package>.conffiles to <package>.list
* The conffiles control file isn't required in Debian packages, so don't
* error out if it's missing. */
rename(conffile_name, list_name);
/* Change package status */
set_status(status_num, "config-files", 3);
@@ -1357,13 +1392,11 @@ static void purge_package(const unsigned package_num)
printf("Purging %s (%s)...\n", package_name, package_version);
/* run prerm script */
if (run_package_script(package_name, "prerm") != 0) {
bb_error_msg_and_die("script failed, prerm failure");
}
/* Run prerm script */
run_package_script_or_die(package_name, "prerm");
/* Create a list of files to remove */
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
remove_files = create_list(list_name);
exclude_files = xzalloc(sizeof(char*));
@@ -1378,10 +1411,8 @@ static void purge_package(const unsigned package_num)
free_array(remove_files);
free(exclude_files);
/* run postrm script */
if (run_package_script(package_name, "postrm") != 0) {
bb_error_msg_and_die("postrm failure.. set status to what?");
}
/* Run postrm script */
run_package_script_or_die(package_name, "postrm");
/* Change package status */
set_status(status_num, "not-installed", 3);
@@ -1471,8 +1502,8 @@ static void unpack_package(deb_file_t *deb_file)
char *list_filename;
archive_handle_t *archive_handle;
FILE *out_stream;
llist_t *accept_list = NULL;
int i = 0;
llist_t *accept_list;
int i;
/* If existing version, remove it first */
if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) {
@@ -1486,11 +1517,13 @@ static void unpack_package(deb_file_t *deb_file)
}
/* Extract control.tar.gz to /var/lib/dpkg/info/<package>.filename */
info_prefix = xasprintf("/var/lib/dpkg/info/%s.", package_name);
info_prefix = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "");
archive_handle = init_archive_deb_ar(deb_file->filename);
init_archive_deb_control(archive_handle);
while (all_control_files[i]) {
accept_list = NULL;
i = 0;
while (i < ARRAY_SIZE(all_control_files)) {
char *c = xasprintf("./%s", all_control_files[i]);
llist_add_to(&accept_list, c);
i++;
@@ -1503,10 +1536,7 @@ static void unpack_package(deb_file_t *deb_file)
unpack_ar_archive(archive_handle);
/* Run the preinst prior to extracting */
if (run_package_script(package_name, "preinst") != 0) {
/* when preinst returns exit code != 0 then quit installation process */
bb_error_msg_and_die("subprocess pre-installation script returned error");
}
run_package_script_or_die(package_name, "preinst");
/* Extract data.tar.gz to the root directory */
archive_handle = init_archive_deb_ar(deb_file->filename);
@@ -1517,7 +1547,7 @@ static void unpack_package(deb_file_t *deb_file)
unpack_ar_archive(archive_handle);
/* Create the list file */
list_filename = xasprintf("/var/lib/dpkg/info/%s.list", package_name);
list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list");
out_stream = xfopen(list_filename, "w");
while (archive_handle->sub_archive->passed) {
/* the leading . has been stripped by data_extract_all_prefix already */
@@ -1544,17 +1574,16 @@ static void configure_package(deb_file_t *deb_file)
printf("Setting up %s (%s)...\n", package_name, package_version);
/* Run the postinst script */
if (run_package_script(package_name, "postinst") != 0) {
/* TODO: handle failure gracefully */
bb_error_msg_and_die("postinst failure.. set status to what?");
}
/* TODO: handle failure gracefully */
run_package_script_or_die(package_name, "postinst");
/* Change status to reflect success */
set_status(status_num, "install", 1);
set_status(status_num, "installed", 3);
}
int dpkg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dpkg_main(int argc, char **argv)
int dpkg_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
deb_file_t **deb_file = NULL;
status_node_t *status_node;
@@ -1575,6 +1604,8 @@ int dpkg_main(int argc, char **argv)
OPT_unpack = 0x40,
};
INIT_G();
opt = getopt32(argv, "CF:ilPru", &str_f);
//if (opt & OPT_configure) ... // -C
if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg)
@@ -1586,16 +1617,11 @@ int dpkg_main(int argc, char **argv)
//if (opt & OPT_purge) ... // -P
//if (opt & OPT_remove) ... // -r
//if (opt & OPT_unpack) ... // -u (--unpack in official dpkg)
argc -= optind;
argv += optind;
/* check for non-option argument if expected */
if (!opt || (!argc && !(opt && OPT_list_installed)))
if (!opt || (!argv[0] && !(opt && OPT_list_installed)))
bb_show_usage();
name_hashtable = xzalloc(sizeof(name_hashtable[0]) * (NAME_HASH_PRIME + 1));
package_hashtable = xzalloc(sizeof(package_hashtable[0]) * (PACKAGE_HASH_PRIME + 1));
status_hashtable = xzalloc(sizeof(status_hashtable[0]) * (STATUS_HASH_PRIME + 1));
/* puts("(Reading database ... xxxxx files and directories installed.)"); */
index_status_file("/var/lib/dpkg/status");
+15 -1
View File
@@ -2025,6 +2025,20 @@ USE_DESKTOP(long long) int pack_gzip(void)
return 0;
}
/*
* Linux kernel build uses gzip -d -n. We accept and ignore it.
* Man page says:
* -n --no-name
* gzip: do not save the original file name and time stamp.
* (The original name is always saved if the name had to be truncated.)
* gunzip: do not restore the original file name/time even if present
* (remove only the gzip suffix from the compressed file name).
* This option is the default when decompressing.
* -N --name
* gzip: always save the original file name and time stamp (this is the default)
* gunzip: restore the original file name and time stamp if present.
*/
int gzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
#if ENABLE_GUNZIP
int gzip_main(int argc, char **argv)
@@ -2035,7 +2049,7 @@ int gzip_main(int argc ATTRIBUTE_UNUSED, char **argv)
unsigned opt;
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
opt = getopt32(argv, "cfv" USE_GUNZIP("d") "q123456789" );
opt = getopt32(argv, "cfv" USE_GUNZIP("d") "q123456789n" );
#if ENABLE_GUNZIP /* gunzip_main may not be visible... */
if (opt & 0x8) // -d
return gunzip_main(argc, argv);
@@ -12,7 +12,7 @@ ssize_t archive_xread_all_eof(archive_handle_t *archive_handle,
ssize_t size;
size = full_read(archive_handle->src_fd, buf, count);
if (size != 0 && size != count) {
if (size != 0 && size != (ssize_t)count) {
bb_error_msg_and_die("short read: %u of %u",
(unsigned)size, (unsigned)count);
}
+1 -1
View File
@@ -20,7 +20,7 @@ void data_extract_all(archive_handle_t *archive_handle)
/* Check if the file already exists */
if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
/* Remove the existing entry if it exists */
/* Remove the entry if it exists */
if (((file_header->mode & S_IFMT) != S_IFDIR)
&& (unlink(file_header->name) == -1)
&& (errno != ENOENT)
+16 -80
View File
@@ -66,7 +66,6 @@ struct group_data {
* | grep 'bd->' | sed 's/^.*bd->/bd->/' | sort | $PAGER
* and moved it (inbufBitCount) to offset 0.
*/
struct bunzip_data {
/* I/O tracking data (file handles, buffers, positions, etc.) */
unsigned inbufBitCount, inbufBits;
@@ -102,11 +101,9 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
/* If we need to get more data from the byte buffer, do so. (Loop getting
one byte at a time to enforce endianness and avoid unaligned access.) */
while (bd->inbufBitCount < bits_wanted) {
while ((int)(bd->inbufBitCount) < bits_wanted) {
/* If we need to read more data from file into byte buffer, do so */
if (bd->inbufPos == bd->inbufCount) {
/* if "no input fd" case: in_fd == -1, read fails, we jump */
bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE);
@@ -116,7 +113,6 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
}
/* Avoid 32-bit overflow (dump bit buffer to top of output) */
if (bd->inbufBitCount >= 24) {
bits = bd->inbufBits & ((1 << bd->inbufBitCount) - 1);
bits_wanted -= bd->inbufBitCount;
@@ -125,13 +121,11 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
}
/* Grab next 8 bits of input from buffer. */
bd->inbufBits = (bd->inbufBits << 8) | bd->inbuf[bd->inbufPos++];
bd->inbufBitCount += 8;
}
/* Calculate result */
bd->inbufBitCount -= bits_wanted;
bits |= (bd->inbufBits >> bd->inbufBitCount) & ((1 << bits_wanted) - 1);
@@ -139,7 +133,6 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
}
/* Unpacks the next block and sets up for the inverse burrows-wheeler step. */
static int get_next_block(bunzip_data *bd)
{
struct group_data *hufGroup;
@@ -153,13 +146,11 @@ static int get_next_block(bunzip_data *bd)
selectors = bd->selectors;
/* Reset longjmp I/O error handling */
i = setjmp(bd->jmpbuf);
if (i) return i;
/* Read in header signature and CRC, then validate signature.
(last block signature means CRC is for whole file, return now) */
i = get_bits(bd, 24);
j = get_bits(bd, 24);
bd->headerCRC = get_bits(bd, 32);
@@ -169,17 +160,15 @@ static int get_next_block(bunzip_data *bd)
/* We can add support for blockRandomised if anybody complains. There was
some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
it didn't actually work. */
if (get_bits(bd, 1)) return RETVAL_OBSOLETE_INPUT;
origPtr = get_bits(bd, 24);
if (origPtr > dbufSize) return RETVAL_DATA_ERROR;
if ((int)origPtr > dbufSize) return RETVAL_DATA_ERROR;
/* mapping table: if some byte values are never used (encoding things
like ascii text), the compression code removes the gaps to have fewer
symbols to deal with, and writes a sparse bitfield indicating which
values were present. We make a translation table to convert the symbols
back to the corresponding bytes. */
t = get_bits(bd, 16);
symTotal = 0;
for (i = 0; i < 16; i++) {
@@ -192,7 +181,6 @@ static int get_next_block(bunzip_data *bd)
}
/* How many different Huffman coding groups does this block use? */
groupCount = get_bits(bd, 3);
if (groupCount < 2 || groupCount > MAX_GROUPS)
return RETVAL_DATA_ERROR;
@@ -201,19 +189,16 @@ static int get_next_block(bunzip_data *bd)
group. Read in the group selector list, which is stored as MTF encoded
bit runs. (MTF=Move To Front, as each value is used it's moved to the
start of the list.) */
nSelectors = get_bits(bd, 15);
if (!nSelectors) return RETVAL_DATA_ERROR;
for (i = 0; i < groupCount; i++) mtfSymbol[i] = i;
for (i = 0; i < nSelectors; i++) {
/* Get next value */
for (j = 0; get_bits(bd, 1); j++)
if (j >= groupCount) return RETVAL_DATA_ERROR;
/* Decode MTF to get the next selector */
uc = mtfSymbol[j];
for (;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
mtfSymbol[0] = selectors[i] = uc;
@@ -221,10 +206,11 @@ static int get_next_block(bunzip_data *bd)
/* Read the Huffman coding tables for each group, which code for symTotal
literal symbols, plus two run symbols (RUNA, RUNB) */
symCount = symTotal + 2;
for (j = 0; j < groupCount; j++) {
unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1];
unsigned char length[MAX_SYMBOLS];
/* 8 bits is ALMOST enough for temp[], see below */
unsigned temp[MAX_HUFCODE_BITS+1];
int minLen, maxLen, pp;
/* Read Huffman code lengths for each symbol. They're stored in
@@ -233,7 +219,6 @@ static int get_next_block(bunzip_data *bd)
(Subtracting 1 before the loop and then adding it back at the end is
an optimization that makes the test inside the loop simpler: symbol
length 0 becomes negative, so an unsigned inequality catches it.) */
t = get_bits(bd, 5) - 1;
for (i = 0; i < symCount; i++) {
for (;;) {
@@ -243,7 +228,6 @@ static int get_next_block(bunzip_data *bd)
/* If first bit is 0, stop. Else second bit indicates whether
to increment or decrement the value. Optimization: grab 2
bits and unget the second if the first was 0. */
k = get_bits(bd, 2);
if (k < 2) {
bd->inbufBitCount++;
@@ -251,17 +235,14 @@ static int get_next_block(bunzip_data *bd)
}
/* Add one if second bit 1, else subtract 1. Avoids if/else */
t += (((k+1) & 2) - 1);
}
/* Correct for the initial -1, to get the final symbol length */
length[i] = t + 1;
}
/* Find largest and smallest lengths in this group */
minLen = maxLen = length[0];
for (i = 1; i < symCount; i++) {
if (length[i] > maxLen) maxLen = length[i];
@@ -278,7 +259,6 @@ static int get_next_block(bunzip_data *bd)
* number of bits can have. This is how the Huffman codes can vary in
* length: each code with a value>limit[length] needs another bit.
*/
hufGroup = bd->groups + j;
hufGroup->minLen = minLen;
hufGroup->maxLen = maxLen;
@@ -286,12 +266,10 @@ static int get_next_block(bunzip_data *bd)
/* Note that minLen can't be smaller than 1, so we adjust the base
and limit array pointers so we're not always wasting the first
entry. We do this again when using them (during symbol decoding).*/
base = hufGroup->base - 1;
limit = hufGroup->limit - 1;
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
pp = 0;
for (i = minLen; i <= maxLen; i++) {
temp[i] = limit[i] = 0;
@@ -301,14 +279,14 @@ static int get_next_block(bunzip_data *bd)
}
/* Count symbols coded for at each bit length */
/* NB: in pathological cases, temp[8] can end ip being 256.
* That's why uint8_t is too small for temp[]. */
for (i = 0; i < symCount; i++) temp[length[i]]++;
/* Calculate limit[] (the largest symbol-coding value at each bit
* length, which is (previous limit<<1)+symbols at this level), and
* base[] (number of symbols to ignore at each bit length, which is
* limit minus the cumulative count of symbols coded for already). */
pp = t = 0;
for (i = minLen; i < maxLen; i++) {
pp += temp[i];
@@ -319,7 +297,6 @@ static int get_next_block(bunzip_data *bd)
each level we're really only interested in the first few bits,
so here we set all the trailing to-be-ignored bits to 1 so they
don't affect the value>limit[length] comparison. */
limit[i] = (pp << (maxLen - i)) - 1;
pp <<= 1;
t += temp[i];
@@ -335,7 +312,6 @@ static int get_next_block(bunzip_data *bd)
and run length encoding, saving the result into dbuf[dbufCount++] = uc */
/* Initialize symbol occurrence counters and symbol Move To Front table */
memset(byteCount, 0, sizeof(byteCount)); /* smaller, maybe slower? */
for (i = 0; i < 256; i++) {
//byteCount[i] = 0;
@@ -347,8 +323,7 @@ static int get_next_block(bunzip_data *bd)
runPos = dbufCount = selector = 0;
for (;;) {
/* fetch next Huffman coding group from list. */
/* Fetch next Huffman coding group from list. */
symCount = GROUP_SIZE - 1;
if (selector >= nSelectors) return RETVAL_DATA_ERROR;
hufGroup = bd->groups + selectors[selector++];
@@ -367,8 +342,7 @@ static int get_next_block(bunzip_data *bd)
dry). The following (up to got_huff_bits:) is equivalent to
j = get_bits(bd, hufGroup->maxLen);
*/
while (bd->inbufBitCount < hufGroup->maxLen) {
while ((int)(bd->inbufBitCount) < hufGroup->maxLen) {
if (bd->inbufPos == bd->inbufCount) {
j = get_bits(bd, hufGroup->maxLen);
goto got_huff_bits;
@@ -382,13 +356,11 @@ static int get_next_block(bunzip_data *bd)
got_huff_bits:
/* Figure how how many bits are in next symbol and unget extras */
i = hufGroup->minLen;
while (j > limit[i]) ++i;
bd->inbufBitCount += (hufGroup->maxLen - i);
/* Huffman decode value to get nextSym (with bounds checking) */
if (i > hufGroup->maxLen)
return RETVAL_DATA_ERROR;
j = (j >> (hufGroup->maxLen - i)) - base[i];
@@ -400,11 +372,9 @@ static int get_next_block(bunzip_data *bd)
byte, or a repeated run of the most recent literal byte. First,
check if nextSym indicates a repeated run, and if so loop collecting
how many times to repeat the last literal. */
if ((unsigned)nextSym <= SYMBOL_RUNB) { /* RUNA or RUNB */
/* If this is the start of a new run, zero out counter */
if (!runPos) {
runPos = 1;
t = 0;
@@ -417,7 +387,6 @@ static int get_next_block(bunzip_data *bd)
the basic or 0/1 method (except all bits 0, which would use no
symbols, but a run of length 0 doesn't mean anything in this
context). Thus space is saved. */
t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
if (runPos < dbufSize) runPos <<= 1;
goto end_of_huffman_loop;
@@ -427,7 +396,6 @@ static int get_next_block(bunzip_data *bd)
how many times to repeat the last literal, so append that many
copies to our buffer of decoded symbols (dbuf) now. (The last
literal used is the one at the head of the mtfSymbol array.) */
if (runPos) {
runPos = 0;
if (dbufCount + t >= dbufSize) return RETVAL_DATA_ERROR;
@@ -438,7 +406,6 @@ static int get_next_block(bunzip_data *bd)
}
/* Is this the terminating symbol? */
if (nextSym > symTotal) break;
/* At this point, nextSym indicates a new literal character. Subtract
@@ -448,7 +415,6 @@ static int get_next_block(bunzip_data *bd)
first symbol in the mtf array, position 0, would have been handled
as part of a run above. Therefore 1 unused mtf position minus
2 non-literal nextSym values equals -1.) */
if (dbufCount >= dbufSize) return RETVAL_DATA_ERROR;
i = nextSym - 1;
uc = mtfSymbol[i];
@@ -457,7 +423,6 @@ static int get_next_block(bunzip_data *bd)
* small number of symbols, and are bound by 256 in any case, using
* memmove here would typically be bigger and slower due to function
* call overhead and other assorted setup costs. */
do {
mtfSymbol[i] = mtfSymbol[i-1];
} while (--i);
@@ -465,13 +430,11 @@ static int get_next_block(bunzip_data *bd)
uc = symToByte[uc];
/* We have our literal byte. Save it into dbuf. */
byteCount[uc]++;
dbuf[dbufCount++] = (unsigned)uc;
/* Skip group initialization if we're not done with this group. Done
* this way to avoid compiler warning. */
end_of_huffman_loop:
if (symCount--) goto continue_this_group;
}
@@ -484,7 +447,6 @@ static int get_next_block(bunzip_data *bd)
*/
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
j = 0;
for (i = 0; i < 256; i++) {
k = j + byteCount[i];
@@ -493,7 +455,6 @@ static int get_next_block(bunzip_data *bd)
}
/* Figure out what order dbuf would be in if we sorted it. */
for (i = 0; i < dbufCount; i++) {
uc = (unsigned char)(dbuf[i] & 0xff);
dbuf[byteCount[uc]] |= (i << 8);
@@ -503,11 +464,10 @@ static int get_next_block(bunzip_data *bd)
/* Decode first byte by hand to initialize "previous" byte. Note that it
doesn't get output, and if the first three characters are identical
it doesn't qualify as a run (hence writeRunCountdown=5). */
if (dbufCount) {
if (origPtr >= dbufCount) return RETVAL_DATA_ERROR;
if ((int)origPtr >= dbufCount) return RETVAL_DATA_ERROR;
bd->writePos = dbuf[origPtr];
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
bd->writePos >>= 8;
bd->writeRunCountdown = 5;
}
@@ -522,7 +482,6 @@ static int get_next_block(bunzip_data *bd)
error (all errors are negative numbers). If out_fd!=-1, outbuf and len
are ignored, data is written to out_fd and return is RETVAL_OK or error.
*/
int read_bunzip(bunzip_data *bd, char *outbuf, int len)
{
const unsigned *dbuf;
@@ -539,19 +498,15 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
/* We will always have pending decoded data to write into the output
buffer unless this is the very first call (in which case we haven't
Huffman-decoded a block into the intermediate buffer yet). */
if (bd->writeCopies) {
/* Inside the loop, writeCopies means extra copies (beyond 1) */
--bd->writeCopies;
/* Loop outputting bytes */
for (;;) {
/* If the output buffer is full, snapshot state and return */
if (gotcount >= len) {
bd->writePos = pos;
bd->writeCurrent = current;
@@ -560,13 +515,11 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
}
/* Write next byte into output buffer, updating CRC */
outbuf[gotcount++] = current;
bd->writeCRC = (bd->writeCRC << 8)
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
/* Loop now if we're outputting multiple copies of this byte */
if (bd->writeCopies) {
--bd->writeCopies;
continue;
@@ -582,35 +535,29 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
/* After 3 consecutive copies of the same byte, the 4th
* is a repeat count. We count down from 4 instead
* of counting up because testing for non-zero is faster */
if (--bd->writeRunCountdown) {
if (current != previous)
bd->writeRunCountdown = 4;
} else {
/* We have a repeated run, this byte indicates the count */
bd->writeCopies = current;
current = previous;
bd->writeRunCountdown = 5;
/* Sometimes there are just 3 bytes (run length 0) */
if (!bd->writeCopies) goto decode_next_byte;
/* Subtract the 1 copy we'd output anyway to get extras */
--bd->writeCopies;
}
}
/* Decompression of this block completed successfully */
bd->writeCRC = ~bd->writeCRC;
bd->totalCRC = ((bd->totalCRC << 1) | (bd->totalCRC >> 31)) ^ bd->writeCRC;
/* If this block had a CRC error, force file level CRC error. */
if (bd->writeCRC != bd->headerCRC) {
bd->totalCRC = bd->headerCRC + 1;
return RETVAL_LAST_BLOCK;
@@ -619,7 +566,6 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
/* Refill the intermediate buffer by Huffman-decoding next block of input */
/* (previous is just a convenient unused temp variable here) */
previous = get_next_block(bd);
if (previous) {
bd->writeCount = previous;
@@ -631,7 +577,6 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
goto decode_next_byte;
}
/* Allocate the structure, read file header. If in_fd==-1, inbuf must contain
a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are
ignored, and data is read from file handle into temporary buffer. */
@@ -639,7 +584,6 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
/* Because bunzip2 is used for help text unpacking, and because bb_show_usage()
should work for NOFORK applets too, we must be extremely careful to not leak
any allocations! */
int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
int len)
{
@@ -650,16 +594,13 @@ int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
};
/* Figure out how much data to allocate */
i = sizeof(bunzip_data);
if (in_fd != -1) i += IOBUF_SIZE;
/* Allocate bunzip_data. Most fields initialize to zero. */
bd = *bdp = xzalloc(i);
/* Setup input buffer */
bd->in_fd = in_fd;
if (-1 == in_fd) {
/* in this case, bd->inbuf is read-only */
@@ -669,22 +610,18 @@ int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
bd->inbuf = (unsigned char *)(bd + 1);
/* Init the CRC32 table (big endian) */
crc32_filltable(bd->crc32Table, 1);
/* Setup for I/O error handling via longjmp */
i = setjmp(bd->jmpbuf);
if (i) return i;
/* Ensure that file starts with "BZh['1'-'9']." */
i = get_bits(bd, 32);
if ((unsigned)(i - BZh0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA;
/* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
/* Fourth byte (ascii '1'-'9') indicates block size in units of 100k of
uncompressed data. Allocate intermediate buffer for block. */
bd->dbufSize = 100000 * (i - BZh0);
/* Cannot use xmalloc - may leak bd in NOFORK case! */
@@ -704,7 +641,6 @@ void dealloc_bunzip(bunzip_data *bd)
/* Decompress src_fd to dst_fd. Stops at end of bzip data, not end of file. */
USE_DESKTOP(long long) int
unpack_bz2_stream(int src_fd, int dst_fd)
{
@@ -761,9 +697,9 @@ int main(int argc, char **argv)
char c;
if (i < 0)
fprintf(stderr,"%s\n", bunzip_errors[-i]);
else if (read(0, &c, 1))
fprintf(stderr,"Trailing garbage ignored\n");
fprintf(stderr, "%s\n", bunzip_errors[-i]);
else if (read(STDIN_FILENO, &c, 1))
fprintf(stderr, "Trailing garbage ignored\n");
return -i;
}
#endif
+3 -3
View File
@@ -329,7 +329,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
if (full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
}
@@ -480,7 +480,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
if (full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
}
@@ -489,7 +489,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
}
}
if (full_write(dst_fd, buffer, buffer_pos) != buffer_pos) {
if (full_write(dst_fd, buffer, buffer_pos) != (ssize_t)buffer_pos) {
bad:
rc_free(rc);
return -1;
+3 -3
View File
@@ -922,7 +922,7 @@ static int inflate_block(STATE_PARAM smallint *e)
/* Two callsites, both in inflate_get_next_window */
static void calculate_gunzip_crc(STATE_PARAM_ONLY)
{
int n;
unsigned n;
for (n = 0; n < gunzip_outbuf_count; n++) {
gunzip_crc = gunzip_crc_table[((int) gunzip_crc ^ (gunzip_window[n])) & 0xff] ^ (gunzip_crc >> 8);
}
@@ -1003,7 +1003,7 @@ inflate_unzip_internal(STATE_PARAM int in, int out)
while (1) {
int r = inflate_get_next_window(PASS_STATE_ONLY);
nwrote = full_write(out, gunzip_window, gunzip_outbuf_count);
if (nwrote != gunzip_outbuf_count) {
if (nwrote != (ssize_t)gunzip_outbuf_count) {
bb_perror_msg("write");
n = -1;
goto ret;
@@ -1064,7 +1064,7 @@ static int top_up(STATE_PARAM unsigned n)
{
int count = bytebuffer_size - bytebuffer_offset;
if (count < n) {
if (count < (int)n) {
memmove(bytebuffer, &bytebuffer[bytebuffer_offset], count);
bytebuffer_offset = 0;
bytebuffer_size = full_read(gunzip_src_fd, &bytebuffer[count], bytebuffer_max - count);
+98 -90
View File
@@ -7,71 +7,33 @@
#include "libbb.h"
#include "unarchive.h"
typedef struct hardlinks_s {
char *name;
int inode;
struct hardlinks_s *next;
typedef struct hardlinks_t {
struct hardlinks_t *next;
int inode; /* TODO: must match maj/min too! */
int mode ;
int mtime; /* These three are useful only in corner case */
int uid ; /* of hardlinks with zero size body */
int gid ;
char name[1];
} hardlinks_t;
char get_header_cpio(archive_handle_t *archive_handle)
{
static hardlinks_t *saved_hardlinks = NULL;
static unsigned pending_hardlinks = 0;
static int inode;
static hardlinks_t *saved_hardlinks_created = NULL;
file_header_t *file_header = archive_handle->file_header;
char cpio_header[110];
int namesize;
char dummy[16];
int major, minor, nlink;
if (pending_hardlinks) { /* Deal with any pending hardlinks */
hardlinks_t *tmp, *oldtmp;
tmp = saved_hardlinks;
oldtmp = NULL;
file_header->link_target = file_header->name;
file_header->size = 0;
while (tmp) {
if (tmp->inode != inode) {
tmp = tmp->next;
continue;
}
file_header->name = tmp->name;
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_data(archive_handle);
archive_handle->action_header(archive_handle->file_header);
}
pending_hardlinks--;
oldtmp = tmp;
tmp = tmp->next;
free(oldtmp->name);
free(oldtmp);
if (oldtmp == saved_hardlinks)
saved_hardlinks = tmp;
}
file_header->name = file_header->link_target;
if (pending_hardlinks > 1) {
bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?");
}
/* No more pending hardlinks, read next file entry */
pending_hardlinks = 0;
}
int namesize;
int major, minor, nlink, mode, inode;
unsigned size, uid, gid, mtime;
/* There can be padding before archive header */
data_align(archive_handle, 4);
if (archive_xread_all_eof(archive_handle, (unsigned char*)cpio_header, 110) == 0) {
return EXIT_FAILURE;
goto create_hardlinks;
}
archive_handle->offset += 110;
@@ -81,17 +43,19 @@ char get_header_cpio(archive_handle_t *archive_handle)
bb_error_msg_and_die("unsupported cpio format, use newc or crc");
}
{
unsigned long tmpsize;
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
dummy, &inode, (unsigned int*)&file_header->mode,
(unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
&nlink, &file_header->mtime, &tmpsize,
dummy, &major, &minor, &namesize, dummy);
file_header->size = tmpsize;
}
sscanf(cpio_header + 6,
"%8x" "%8x" "%8x" "%8x"
"%8x" "%8x" "%8x" /*maj,min:*/ "%16c"
/*rmaj,rmin:*/"%8x" "%8x" "%8x" /*chksum:*/ "%8c",
&inode, &mode, &uid, &gid,
&nlink, &mtime, &size, dummy,
&major, &minor, &namesize, dummy);
file_header->mode = mode;
file_header->uid = uid;
file_header->gid = gid;
file_header->mtime = mtime;
file_header->size = size;
free(file_header->name);
file_header->name = xzalloc(namesize + 1);
/* Read in filename */
xread(archive_handle->src_fd, file_header->name, namesize);
@@ -101,25 +65,9 @@ char get_header_cpio(archive_handle_t *archive_handle)
data_align(archive_handle, 4);
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
/* Always round up */
printf("%d blocks\n", (int) (archive_handle->offset % 512 ?
archive_handle->offset / 512 + 1 :
archive_handle->offset / 512
));
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
hardlinks_t *tmp = saved_hardlinks;
hardlinks_t *oldtmp = NULL;
while (tmp) {
bb_error_msg("%s not created: cannot resolve hardlink", tmp->name);
oldtmp = tmp;
tmp = tmp->next;
free(oldtmp->name);
free(oldtmp);
}
saved_hardlinks = NULL;
pending_hardlinks = 0;
}
return EXIT_FAILURE;
/* Always round up. ">> 9" divides by 512 */
printf("%"OFF_FMT"u blocks\n", (archive_handle->offset + 511) >> 9);
goto create_hardlinks;
}
if (S_ISLNK(file_header->mode)) {
@@ -130,25 +78,33 @@ char get_header_cpio(archive_handle_t *archive_handle)
} else {
file_header->link_target = NULL;
}
if (nlink > 1 && !S_ISDIR(file_header->mode)) {
if (file_header->size == 0) { /* Put file on a linked list for later */
hardlinks_t *new = xmalloc(sizeof(hardlinks_t));
// TODO: data_extract_all can't deal with hardlinks to non-files...
// (should be !S_ISDIR instead of S_ISREG here)
if (nlink > 1 && S_ISREG(file_header->mode)) {
hardlinks_t *new = xmalloc(sizeof(*new) + namesize);
new->inode = inode;
new->mode = mode ;
new->mtime = mtime;
new->uid = uid ;
new->gid = gid ;
strcpy(new->name, file_header->name);
/* Put file on a linked list for later */
if (size == 0) {
new->next = saved_hardlinks;
new->inode = inode;
/* name current allocated, freed later */
new->name = file_header->name;
file_header->name = NULL;
saved_hardlinks = new;
return EXIT_SUCCESS; /* Skip this one */
/* TODO: this breaks cpio -t (it does not show hardlinks) */
}
/* Found the file with data in */
pending_hardlinks = nlink;
new->next = saved_hardlinks_created;
saved_hardlinks_created = new;
}
file_header->device = makedev(major, minor);
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_data(archive_handle);
archive_handle->action_header(archive_handle->file_header);
archive_handle->action_header(file_header);
} else {
data_skip(archive_handle);
}
@@ -156,6 +112,58 @@ char get_header_cpio(archive_handle_t *archive_handle)
archive_handle->offset += file_header->size;
free(file_header->link_target);
free(file_header->name);
file_header->link_target = NULL;
file_header->name = NULL;
return EXIT_SUCCESS;
create_hardlinks:
free(file_header->link_target);
free(file_header->name);
while (saved_hardlinks) {
hardlinks_t *cur;
hardlinks_t *make_me = saved_hardlinks;
saved_hardlinks = make_me->next;
memset(file_header, 0, sizeof(*file_header));
file_header->name = make_me->name;
file_header->mode = make_me->mode;
/*file_header->size = 0;*/
/* Try to find a file we are hardlinked to */
cur = saved_hardlinks_created;
while (cur) {
/* TODO: must match maj/min too! */
if (cur->inode == make_me->inode) {
file_header->link_target = cur->name;
/* link_target != NULL, size = 0: "I am a hardlink" */
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS)
archive_handle->action_data(archive_handle);
free(make_me);
goto next_link;
}
cur = cur->next;
}
/* Oops... no file with such inode was created... do it now
* (happens when hardlinked files are empty (zero length)) */
file_header->mtime = make_me->mtime;
file_header->uid = make_me->uid ;
file_header->gid = make_me->gid ;
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS)
archive_handle->action_data(archive_handle);
/* Move to the list of created hardlinked files */
make_me->next = saved_hardlinks_created;
saved_hardlinks_created = make_me;
next_link: ;
}
while (saved_hardlinks_created) {
hardlinks_t *p = saved_hardlinks_created;
saved_hardlinks_created = p->next;
free(p);
}
return EXIT_FAILURE; /* "No more files to process" */
}
+12 -9
View File
@@ -99,7 +99,7 @@ char get_header_tar(archive_handle_t *archive_handle)
* "tar: A lone zero block at N", where N = kilobyte
* where EOF was met (not EOF block, actual EOF!),
* and tar will exit with error code 0.
* We will mimic exit(0), although we will not mimic
* We will mimic exit(EXIT_SUCCESS), although we will not mimic
* the message and we don't check whether we indeed
* saw zero block directly before this. */
if (i == 0)
@@ -112,7 +112,7 @@ char get_header_tar(archive_handle_t *archive_handle)
archive_handle->offset += 512;
/* If there is no filename its an empty header */
if (tar.name[0] == 0) {
if (tar.name[0] == 0 && tar.prefix[0] == 0) {
if (end) {
/* This is the second consecutive empty header! End of archive!
* Read until the end to empty the pipe from gz or bz2
@@ -138,12 +138,12 @@ char get_header_tar(archive_handle_t *archive_handle)
/* tar gz/bz autodetect: check for gz/bz2 magic.
* If it is the very first block, and we see the magic,
* we can switch to get_header_tar_gz/bz2/lzma().
* Needs seekable fd. I wish recv(MSG_PEEK) would work
* Needs seekable fd. I wish recv(MSG_PEEK) works
* on any fd... */
if (not_first)
goto err;
#if ENABLE_FEATURE_TAR_GZIP
if (tar.name[0] == 0x1f && tar.name[1] == 0x8b) { /* gzip */
if (tar.name[0] == 0x1f && tar.name[1] == (char)0x8b) { /* gzip */
get_header_ptr = get_header_tar_gz;
} else
#endif
@@ -211,15 +211,16 @@ char get_header_tar(archive_handle_t *archive_handle)
/* getOctal trashes subsequent field, therefore we call it
* on fields in reverse order */
if (tar.devmajor[0]) {
char t = tar.prefix[0];
/* we trash prefix[0] here, but we DO need it later! */
unsigned minor = GET_OCTAL(tar.devminor);
unsigned major = GET_OCTAL(tar.devmajor);
file_header->device = makedev(major, minor);
tar.prefix[0] = t;
}
file_header->link_target = NULL;
if (!linkname && parse_names && tar.linkname[0]) {
/* we trash magic[0] here, it's ok */
tar.linkname[sizeof(tar.linkname)] = '\0';
file_header->link_target = xstrdup(tar.linkname);
file_header->link_target = xstrndup(tar.linkname, sizeof(tar.linkname));
/* FIXME: what if we have non-link object with link_target? */
/* Will link_target be free()ed? */
}
@@ -237,10 +238,12 @@ char get_header_tar(archive_handle_t *archive_handle)
file_header->name = NULL;
if (!longname && parse_names) {
/* we trash mode[0] here, it's ok */
tar.name[sizeof(tar.name)] = '\0';
//tar.name[sizeof(tar.name)] = '\0'; - gcc 4.3.0 would complain
tar.mode[0] = '\0';
if (tar.prefix[0]) {
/* and padding[0] */
tar.prefix[sizeof(tar.prefix)] = '\0';
//tar.prefix[sizeof(tar.prefix)] = '\0'; - gcc 4.3.0 would complain
tar.padding[0] = '\0';
file_header->name = concat_path_file(tar.prefix, tar.name);
} else
file_header->name = xstrdup(tar.name);
+6 -4
View File
@@ -22,11 +22,13 @@ int open_transformer(int src_fd,
#if BB_MMU
pid = fork();
if (pid == -1)
bb_perror_msg_and_die("can't fork");
#else
pid = vfork();
#endif
if (pid == -1)
bb_perror_msg_and_die("fork failed");
bb_perror_msg_and_die("can't vfork");
#endif
if (pid == 0) {
/* child process */
@@ -38,7 +40,7 @@ int open_transformer(int src_fd,
close(fd_pipe.wr); /* Send EOF */
close(src_fd);
}
exit(0);
exit(EXIT_SUCCESS);
#else
{
char *argv[4];
@@ -49,7 +51,7 @@ int open_transformer(int src_fd,
argv[2] = (char*)"-";
argv[3] = NULL;
BB_EXECVP(transform_prog, argv);
bb_perror_msg_and_die("exec failed");
bb_perror_msg_and_die("can't exec %s", transform_prog);
}
#endif
/* notreached */
+2 -4
View File
@@ -9,11 +9,9 @@
void seek_by_jump(const archive_handle_t *archive_handle, unsigned amount)
{
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
#if ENABLE_FEATURE_UNARCHIVE_TAPE
if (errno == ESPIPE) {
if (errno == ESPIPE)
seek_by_read(archive_handle, amount);
} else
#endif
else
bb_perror_msg_and_die("seek failure");
}
}
+8 -8
View File
@@ -13,14 +13,14 @@
#define RPM_HEADER_MAGIC "\216\255\350"
struct rpm_lead {
unsigned char magic[4];
uint8_t major, minor;
uint16_t type;
uint16_t archnum;
char name[66];
uint16_t osnum;
uint16_t signature_type;
char reserved[16];
unsigned char magic[4];
uint8_t major, minor;
uint16_t type;
uint16_t archnum;
char name[66];
uint16_t osnum;
uint16_t signature_type;
char reserved[16];
};
struct rpm_header {
+117 -119
View File
@@ -24,7 +24,6 @@
*/
#include <fnmatch.h>
#include <getopt.h>
#include "libbb.h"
#include "unarchive.h"
@@ -85,26 +84,26 @@ struct TarHeader { /* byte offset */
*/
typedef struct HardLinkInfo HardLinkInfo;
struct HardLinkInfo {
HardLinkInfo *next; /* Next entry in list */
dev_t dev; /* Device number */
ino_t ino; /* Inode number */
short linkCount; /* (Hard) Link Count */
char name[1]; /* Start of filename (must be last) */
HardLinkInfo *next; /* Next entry in list */
dev_t dev; /* Device number */
ino_t ino; /* Inode number */
short linkCount; /* (Hard) Link Count */
char name[1]; /* Start of filename (must be last) */
};
/* Some info to be carried along when creating a new tarball */
typedef struct TarBallInfo TarBallInfo;
struct TarBallInfo {
int tarFd; /* Open-for-write file descriptor
for the tarball */
struct stat statBuf; /* Stat info for the tarball, letting
us know the inode and device that the
tarball lives, so we can avoid trying
to include the tarball into itself */
int verboseFlag; /* Whether to print extra stuff or not */
const llist_t *excludeList; /* List of files to not include */
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
int tarFd; /* Open-for-write file descriptor
* for the tarball */
struct stat statBuf; /* Stat info for the tarball, letting
* us know the inode and device that the
* tarball lives, so we can avoid trying
* to include the tarball into itself */
int verboseFlag; /* Whether to print extra stuff or not */
const llist_t *excludeList; /* List of files to not include */
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
};
/* A nice enum with all the possible tar file content types */
@@ -504,11 +503,90 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
return TRUE;
}
static int writeTarFile(const int tar_fd, const int verboseFlag,
const unsigned long dereferenceFlag, const llist_t *include,
const llist_t *exclude, const int gzip)
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
#if !(ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2)
#define vfork_compressor(tar_fd, gzip) vfork_compressor(tar_fd)
#endif
/* Don't inline: vfork scares gcc and pessimizes code */
static void NOINLINE vfork_compressor(int tar_fd, int gzip)
{
pid_t gzipPid;
#if ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
#elif ENABLE_FEATURE_TAR_GZIP
const char *zip_exec = "gzip";
#else /* only ENABLE_FEATURE_TAR_BZIP2 */
const char *zip_exec = "bzip2";
#endif
// On Linux, vfork never unpauses parent early, although standard
// allows for that. Do we want to waste bytes checking for it?
#define WAIT_FOR_CHILD 0
volatile int vfork_exec_errno = 0;
struct fd_pair gzipDataPipe;
#if WAIT_FOR_CHILD
struct fd_pair gzipStatusPipe;
xpiped_pair(gzipStatusPipe);
#endif
xpiped_pair(gzipDataPipe);
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
#if defined(__GNUC__) && __GNUC__
/* Avoid vfork clobbering */
(void) &zip_exec;
#endif
gzipPid = vfork();
if (gzipPid < 0)
bb_perror_msg_and_die("can't vfork");
if (gzipPid == 0) {
/* child */
/* NB: close _first_, then move fds! */
close(gzipDataPipe.wr);
#if WAIT_FOR_CHILD
close(gzipStatusPipe.rd);
/* gzipStatusPipe.wr will close only on exec -
* parent waits for this close to happen */
fcntl(gzipStatusPipe.wr, F_SETFD, FD_CLOEXEC);
#endif
xmove_fd(gzipDataPipe.rd, 0);
xmove_fd(tar_fd, 1);
/* exec gzip/bzip2 program/applet */
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
vfork_exec_errno = errno;
_exit(EXIT_FAILURE);
}
/* parent */
xmove_fd(gzipDataPipe.wr, tar_fd);
close(gzipDataPipe.rd);
#if WAIT_FOR_CHILD
close(gzipStatusPipe.wr);
while (1) {
char buf;
int n;
/* Wait until child execs (or fails to) */
n = full_read(gzipStatusPipe.rd, &buf, 1);
if (n < 0 /* && errno == EAGAIN */)
continue; /* try it again */
}
close(gzipStatusPipe.rd);
#endif
if (vfork_exec_errno) {
errno = vfork_exec_errno;
bb_perror_msg_and_die("cannot exec %s", zip_exec);
}
}
#endif /* ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2 */
/* gcc 4.2.1 inlines it, making code bigger */
static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
int dereferenceFlag, const llist_t *include,
const llist_t *exclude, int gzip)
{
pid_t gzipPid = 0;
int errorFlag = FALSE;
struct TarBallInfo tbInfo;
@@ -524,80 +602,8 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
bb_perror_msg_and_die("cannot stat tar file");
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
if (gzip) {
#if ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
#elif ENABLE_FEATURE_TAR_GZIP
const char *zip_exec = "gzip";
#else /* only ENABLE_FEATURE_TAR_BZIP2 */
const char *zip_exec = "bzip2";
#endif
// On Linux, vfork never unpauses parent early, although standard
// allows for that. Do we want to waste bytes checking for it?
#define WAIT_FOR_CHILD 0
volatile int vfork_exec_errno = 0;
#if WAIT_FOR_CHILD
struct fd_pair gzipStatusPipe;
#endif
struct fd_pair gzipDataPipe;
xpiped_pair(gzipDataPipe);
#if WAIT_FOR_CHILD
xpiped_pair(gzipStatusPipe);
#endif
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
#if defined(__GNUC__) && __GNUC__
/* Avoid vfork clobbering */
(void) &include;
(void) &errorFlag;
(void) &zip_exec;
#endif
gzipPid = vfork();
if (gzipPid < 0)
bb_perror_msg_and_die("vfork gzip");
if (gzipPid == 0) {
/* child */
/* NB: close _first_, then move fds! */
close(gzipDataPipe.wr);
#if WAIT_FOR_CHILD
close(gzipStatusPipe.rd);
/* gzipStatusPipe.wr will close only on exec -
* parent waits for this close to happen */
fcntl(gzipStatusPipe.wr, F_SETFD, FD_CLOEXEC);
#endif
xmove_fd(gzipDataPipe.rd, 0);
xmove_fd(tbInfo.tarFd, 1);
/* exec gzip/bzip2 program/applet */
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
vfork_exec_errno = errno;
_exit(1);
}
/* parent */
xmove_fd(gzipDataPipe.wr, tbInfo.tarFd);
close(gzipDataPipe.rd);
#if WAIT_FOR_CHILD
close(gzipStatusPipe.wr);
while (1) {
char buf;
int n;
/* Wait until child execs (or fails to) */
n = full_read(gzipStatusPipe.rd, &buf, 1);
if (n < 0 /* && errno == EAGAIN */)
continue; /* try it again */
}
close(gzipStatusPipe.rd);
#endif
if (vfork_exec_errno) {
errno = vfork_exec_errno;
bb_perror_msg_and_die("cannot exec %s", zip_exec);
}
}
if (gzip)
vfork_compressor(tbInfo.tarFd, gzip);
#endif
tbInfo.excludeList = exclude;
@@ -631,37 +637,34 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
if (errorFlag)
bb_error_msg("error exit delayed from previous errors");
if (gzipPid) {
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
if (gzip) {
int status;
if (safe_waitpid(gzipPid, &status, 0) == -1)
if (safe_waitpid(-1, &status, 0) == -1)
bb_perror_msg("waitpid");
else if (!WIFEXITED(status) || WEXITSTATUS(status))
/* gzip was killed or has exited with nonzero! */
errorFlag = TRUE;
}
#endif
return errorFlag;
}
#else
int writeTarFile(const int tar_fd, const int verboseFlag,
const unsigned long dereferenceFlag, const llist_t *include,
const llist_t *exclude, const int gzip);
int writeTarFile(int tar_fd, int verboseFlag,
int dereferenceFlag, const llist_t *include,
const llist_t *exclude, int gzip);
#endif /* FEATURE_TAR_CREATE */
#if ENABLE_FEATURE_TAR_FROM
static llist_t *append_file_list_to_list(llist_t *list)
{
FILE *src_stream;
llist_t *cur = list;
llist_t *tmp;
char *line;
llist_t *newlist = NULL;
while (cur) {
src_stream = xfopen(cur->data, "r");
tmp = cur;
cur = cur->link;
free(tmp);
while ((line = xmalloc_getline(src_stream)) != NULL) {
while (list) {
src_stream = xfopen(llist_pop(&list), "r");
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
/* kill trailing '/' unless the string is just "/" */
char *cp = last_char_is(line, '/');
if (cp > line)
@@ -797,7 +800,7 @@ static const char tar_longopts[] ALIGN1 =
#endif
int tar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int tar_main(int argc, char **argv)
int tar_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
char (*get_header_ptr)(archive_handle_t *) = get_header_tar;
archive_handle_t *tar_handle;
@@ -847,6 +850,7 @@ int tar_main(int argc, char **argv)
, &verboseFlag // combined count for -t and -v
, &verboseFlag // combined count for -t and -v
);
argv += optind;
if (verboseFlag) tar_handle->action_header = header_verbose_list;
if (verboseFlag == 1) tar_handle->action_header = header_list;
@@ -892,21 +896,15 @@ int tar_main(int argc, char **argv)
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
#endif
/* Check if we are reading from stdin */
if (argv[optind] && *argv[optind] == '-') {
/* Default is to read from stdin, so just skip to next arg */
optind++;
}
/* Setup an array of filenames to work with */
/* TODO: This is the same as in ar, separate function ? */
while (optind < argc) {
while (*argv) {
/* kill trailing '/' unless the string is just "/" */
char *cp = last_char_is(argv[optind], '/');
if (cp > argv[optind])
char *cp = last_char_is(*argv, '/');
if (cp > *argv)
*cp = '\0';
llist_add_to_end(&tar_handle->accept, argv[optind]);
optind++;
llist_add_to_end(&tar_handle->accept, *argv);
argv++;
}
if (tar_handle->accept || tar_handle->reject)
+2 -10
View File
@@ -9,25 +9,17 @@
#include "libbb.h"
/* From <linux/vt.h> */
enum {
VT_ACTIVATE = 0x5606, /* make vt active */
VT_WAITACTIVE = 0x5607 /* wait for vt active */
};
int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int chvt_main(int argc, char **argv)
{
int fd, num;
int num;
if (argc != 2) {
bb_show_usage();
}
fd = get_console_fd();
num = xatou_range(argv[1], 1, 63);
/* double cast suppresses "cast to ptr from int of different size" */
xioctl(fd, VT_ACTIVATE, (void *)(ptrdiff_t)num);
xioctl(fd, VT_WAITACTIVE, (void *)(ptrdiff_t)num);
console_make_active(get_console_fd(), num);
return EXIT_SUCCESS;
}
+11 -8
View File
@@ -7,6 +7,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
*/
/* no options, no getopt */
#include "libbb.h"
@@ -23,18 +24,17 @@ struct kbentry {
#define MAX_NR_KEYMAPS 256
int dumpkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dumpkmap_main(int argc, char **argv)
int dumpkmap_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv)
{
struct kbentry ke;
int i, j, fd;
char flags[MAX_NR_KEYMAPS];
RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
if (argc >= 2 && argv[1][0] == '-')
bb_show_usage();
/* bb_warn_ignoring_args(argc>=2);*/
fd = xopen(CURRENT_VC, O_RDWR);
write(1, "bkeymap", 7);
write(STDOUT_FILENO, "bkeymap", 7);
/* Here we want to set everything to 0 except for indexes:
* [0-2] [4-6] [8-10] [12] */
@@ -43,7 +43,7 @@ int dumpkmap_main(int argc, char **argv)
flags[3] = flags[7] = flags[11] = 0;
/* dump flags */
write(1, flags, MAX_NR_KEYMAPS);
write(STDOUT_FILENO, flags, MAX_NR_KEYMAPS);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
@@ -56,11 +56,14 @@ int dumpkmap_main(int argc, char **argv)
(char *)&ke.kb_table,
&ke.kb_value)
) {
write(1, (void*)&ke.kb_value, 2);
write(STDOUT_FILENO, (void*)&ke.kb_value, 2);
}
}
}
}
close(fd);
if (ENABLE_FEATURE_CLEAN_UP) {
close(fd);
RELEASE_CONFIG_BUFFER(flags);
}
return EXIT_SUCCESS;
}
+31 -46
View File
@@ -1,8 +1,8 @@
/* vi: set sw=4 ts=4: */
/*
* Mini loadkmap implementation for busybox
* 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
*
@@ -10,59 +10,44 @@
*
*/
#include <getopt.h>
#include "libbb.h"
#include <linux/kd.h>
int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int kbd_mode_main(int argc, char **argv)
int kbd_mode_main(int ATTRIBUTE_UNUSED argc, char **argv)
{
static const char opts[] = "saku";
const char *opt = argv[1];
const char *p;
int fd;
unsigned opt;
enum {
SCANCODE = (1<<0),
ASCII = (1<<1),
MEDIUMRAW= (1<<2),
UNICODE = (1<<3)
};
static const char KD_xxx[] ALIGN1 = "saku";
opt = getopt32(argv, KD_xxx);
fd = get_console_fd();
if (fd < 0) /* get_console_fd() already complained */
/* if (fd < 0)
return EXIT_FAILURE;
*/
if (!opt) { /* print current setting */
const char *mode = "unknown";
int m;
if (opt == NULL) {
/* No arg */
const char *msg = "unknown";
int mode;
ioctl(fd, KDGKBMODE, &mode);
switch(mode) {
case K_RAW:
msg = "raw (scancode)";
break;
case K_XLATE:
msg = "default (ASCII)";
break;
case K_MEDIUMRAW:
msg = "mediumraw (keycode)";
break;
case K_UNICODE:
msg = "Unicode (UTF-8)";
break;
}
printf("The keyboard is in %s mode\n", msg);
}
else if (argc > 2 /* more than 1 arg */
|| *opt != '-' /* not an option */
|| (p = strchr(opts, opt[1])) == NULL /* not an option we expect */
|| opt[2] != '\0' /* more than one option char */
) {
bb_show_usage();
/* return EXIT_FAILURE; - not reached */
}
else {
#if K_RAW != 0 || K_XLATE != 1 || K_MEDIUMRAW != 2 || K_UNICODE != 3
#error kbd_mode must be changed
#endif
/* The options are in the order of the various K_xxx */
ioctl(fd, KDSKBMODE, p - opts);
ioctl(fd, KDGKBMODE, &m);
if (m == K_RAW)
mode = "raw (scancode)";
else if (m == K_XLATE)
mode = "default (ASCII)";
else if (m == K_MEDIUMRAW)
mode = "mediumraw (keycode)";
else if (m == K_UNICODE)
mode = "Unicode (UTF-8)";
printf("The keyboard is in %s mode\n", mode);
} else {
opt = opt & UNICODE ? 3 : opt >> 1;
/* double cast prevents warnings about widening conversion */
xioctl(fd, KDSKBMODE, (void*)(ptrdiff_t)opt);
}
if (ENABLE_FEATURE_CLEAN_UP)
+13 -12
View File
@@ -26,28 +26,26 @@ struct kbentry {
#define MAX_NR_KEYMAPS 256
int loadkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int loadkmap_main(int argc, char **argv ATTRIBUTE_UNUSED)
int loadkmap_main(int ATTRIBUTE_UNUSED argc, char **argv ATTRIBUTE_UNUSED)
{
struct kbentry ke;
int i, j, fd;
uint16_t ibuff[NR_KEYS];
char flags[MAX_NR_KEYMAPS];
char buff[7];
RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
if (argc != 1)
bb_show_usage();
/* bb_warn_ignoring_args(argc>=2);*/
fd = xopen(CURRENT_VC, O_RDWR);
xread(0, buff, 7);
if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
bb_error_msg_and_die("this is not a valid binary keymap");
xread(STDIN_FILENO, flags, 7);
if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7))
bb_error_msg_and_die("not a valid binary keymap");
xread(0, flags, MAX_NR_KEYMAPS);
xread(STDIN_FILENO, flags, MAX_NR_KEYMAPS);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
xread(0, ibuff, NR_KEYS * sizeof(uint16_t));
xread(STDIN_FILENO, ibuff, NR_KEYS * sizeof(uint16_t));
for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j;
ke.kb_table = i;
@@ -57,6 +55,9 @@ int loadkmap_main(int argc, char **argv ATTRIBUTE_UNUSED)
}
}
if (ENABLE_FEATURE_CLEAN_UP) close(fd);
return 0;
if (ENABLE_FEATURE_CLEAN_UP) {
close(fd);
RELEASE_CONFIG_BUFFER(flags);
}
return EXIT_SUCCESS;
}
+162 -17
View File
@@ -8,29 +8,174 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* getopt not needed */
#include <linux/vt.h>
#include "libbb.h"
int openvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int openvt_main(int argc, char **argv)
/* "Standard" openvt's man page (we do not support all of this):
openvt [-c NUM] [-fsulv] [--] [command [args]]
Find the first available VT, and run command on it. Stdio is directed
to that VT. If no command is specified then $SHELL is used.
-c NUM
Use the given VT number, not the first free one.
-f
Force opening a VT: don't try to check if VT is already in use.
-s
Switch to the new VT when starting the command.
The VT of the new command will be made the new current VT.
-u
Figure out the owner of the current VT, and run login as that user.
Suitable to be called by init. Shouldn't be used with -c or -l.
-l
Make the command a login shell: a "-" is prepended to the argv[0]
when command is executed.
-v
Verbose.
-w
Wait for command to complete. If -w and -s are used together,
switch back to the controlling terminal when the command completes.
bbox:
-u: not implemented
-f: always in effect
-l: not implemented, ignored
-v: ignored
-ws: does NOT switch back
*/
/* Helper: does this fd understand VT_xxx? */
static int not_vt_fd(int fd)
{
char vtname[sizeof(VC_FORMAT) + 2];
struct vt_stat vtstat;
return ioctl(fd, VT_GETSTATE, &vtstat); /* !0: error, it's not VT fd */
}
if (argc < 3)
bb_show_usage();
/* Helper: get a fd suitable for VT_xxx */
static int get_vt_fd(void)
{
int fd;
/* check for illegal vt number: < 1 or > 63 */
sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63));
/* Do we, by chance, already have it? */
for (fd = 0; fd < 3; fd++)
if (!not_vt_fd(fd))
return fd;
/* _only_ O_NONBLOCK: ask for neither read nor write perms */
/*FIXME: use? device_open(DEV_CONSOLE,0); */
fd = open(DEV_CONSOLE, O_NONBLOCK);
if (fd >= 0 && !not_vt_fd(fd))
return fd;
bb_error_msg_and_die("can't find open VT");
}
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
/* grab new one */
close(0);
static int find_free_vtno(void)
{
int vtno;
int fd = get_vt_fd();
errno = 0;
/*xfunc_error_retval = 3; - do we need compat? */
if (ioctl(fd, VT_OPENQRY, &vtno) != 0 || vtno <= 0)
bb_perror_msg_and_die("can't find open VT");
// Not really needed, grep for DAEMON_ONLY_SANITIZE
// if (fd > 2)
// close(fd);
return vtno;
}
/* vfork scares gcc, it generates bigger code.
* Keep it away from main program.
* TODO: move to libbb; or adapt existing libbb's spawn().
*/
static NOINLINE void vfork_child(char **argv)
{
if (vfork() == 0) {
/* CHILD */
/* Try to make this VT our controlling tty */
setsid(); /* lose old ctty */
ioctl(STDIN_FILENO, TIOCSCTTY, 0 /* 0: don't forcibly steal */);
//bb_error_msg("our sid %d", getsid(0));
//bb_error_msg("our pgrp %d", getpgrp());
//bb_error_msg("VT's sid %d", tcgetsid(0));
//bb_error_msg("VT's pgrp %d", tcgetpgrp(0));
BB_EXECVP(argv[0], argv);
bb_perror_msg_and_die("exec %s", argv[0]);
}
}
int openvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int openvt_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
char vtname[sizeof(VC_FORMAT) + sizeof(int)*3];
struct vt_stat vtstat;
char *str_c;
int vtno;
int flags;
enum {
OPT_c = (1 << 0),
OPT_w = (1 << 1),
OPT_s = (1 << 2),
OPT_l = (1 << 3),
OPT_f = (1 << 4),
OPT_v = (1 << 5),
};
/* "+" - stop on first non-option */
flags = getopt32(argv, "+c:wslfv", &str_c);
argv += optind;
if (flags & OPT_c) {
/* Check for illegal vt number: < 1 or > 63 */
vtno = xatou_range(str_c, 1, 63);
} else {
vtno = find_free_vtno();
}
/* Grab new VT */
sprintf(vtname, VC_FORMAT, vtno);
/* (Try to) clean up stray open fds above fd 2 */
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS | DAEMON_ONLY_SANITIZE, NULL);
close(STDIN_FILENO);
/*setsid(); - BAD IDEA: after we exit, child is SIGHUPed... */
xopen(vtname, O_RDWR);
xdup2(0, STDOUT_FILENO);
xdup2(0, STDERR_FILENO);
xioctl(STDIN_FILENO, VT_GETSTATE, &vtstat);
if (flags & OPT_s) {
console_make_active(STDIN_FILENO, vtno);
}
if (!argv[0]) {
argv--;
argv[0] = getenv("SHELL");
if (!argv[0])
argv[0] = (char *) DEFAULT_SHELL;
/*argv[1] = NULL; - already is */
}
xdup2(STDIN_FILENO, STDOUT_FILENO);
xdup2(STDIN_FILENO, STDERR_FILENO);
#ifdef BLOAT
{
/* Handle -l (login shell) option */
const char *prog = argv[0];
if (flags & OPT_l)
argv[0] = xasprintf("-%s", argv[0]);
}
#endif
argv += 2;
BB_EXECVP(argv[0], argv);
_exit(1);
vfork_child(argv);
if (flags & OPT_w) {
/* We have only one child, wait for it */
safe_waitpid(-1, NULL, 0); /* loops on EINTR */
if (flags & OPT_s) {
console_make_active(STDIN_FILENO, vtstat.v_active);
// Compat: even with -c N (try to) disallocate:
// # /usr/app/kbd-1.12/bin/openvt -f -c 9 -ws sleep 5
// openvt: could not deallocate console 9
xioctl(STDIN_FILENO, VT_DISALLOCATE, (void*)(ptrdiff_t)vtno);
}
}
return EXIT_SUCCESS;
}
+1 -1
View File
@@ -26,7 +26,7 @@ int reset_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
/* no options, no getopt */
if (isatty(0) && isatty(1)) {
if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
/* See 'man 4 console_codes' for details:
* "ESC c" -- Reset
* "ESC ( K" -- Select user mapping
+1 -1
View File
@@ -17,7 +17,7 @@ static void
onintr(int sig ATTRIBUTE_UNUSED)
{
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
exit(1);
exit(EXIT_FAILURE);
}
int resize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+13 -20
View File
@@ -3,41 +3,34 @@
* setconsole.c - redirect system console output
*
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
* Copyright (C) 2008 Bernhard Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <getopt.h>
#include "libbb.h"
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
static const char setconsole_longopts[] ALIGN1 =
"reset\0" No_argument "r"
;
#endif
#define OPT_SETCONS_RESET 1
int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int setconsole_main(int argc, char **argv)
int setconsole_main(int ATTRIBUTE_UNUSED argc, char **argv)
{
unsigned long flags;
const char *device = CURRENT_TTY;
bool reset;
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
static const char setconsole_longopts[] ALIGN1 =
"reset\0" No_argument "r"
;
applet_long_options = setconsole_longopts;
#endif
flags = getopt32(argv, "r");
/* at most one non-option argument */
opt_complementary = "?1";
reset = getopt32(argv, "r");
if (argc - optind > 1)
bb_show_usage();
if (argc - optind == 1) {
if (flags & OPT_SETCONS_RESET)
bb_show_usage();
device = argv[optind];
argv += 1 + reset;
if (*argv) {
device = *argv;
} else {
if (flags & OPT_SETCONS_RESET)
if (reset)
device = DEV_CONSOLE;
}
+4 -5
View File
@@ -17,15 +17,14 @@ int setlogcons_main(int argc ATTRIBUTE_UNUSED, char **argv)
struct {
char fn;
char subarg;
} arg;
arg.fn = 11; /* redirect kernel messages */
arg.subarg = 0; /* to specified console (current as default) */
} arg = { 11, /* redirect kernel messages */
0 /* to specified console (current as default) */
};
if (argv[1])
arg.subarg = xatou_range(argv[1], 0, 63);
xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
return 0;
return EXIT_SUCCESS;
}
+6 -2
View File
@@ -30,6 +30,7 @@ lib-$(CONFIG_DOS2UNIX) += dos2unix.o
lib-$(CONFIG_DU) += du.o
lib-$(CONFIG_ECHO) += echo.o
lib-$(CONFIG_ASH) += echo.o # used by ash
lib-$(CONFIG_HUSH) += echo.o # used by hush
lib-$(CONFIG_ENV) += env.o
lib-$(CONFIG_EXPR) += expr.o
lib-$(CONFIG_EXPAND) += expand.o
@@ -53,6 +54,7 @@ lib-$(CONFIG_NOHUP) += nohup.o
lib-$(CONFIG_OD) += od.o
lib-$(CONFIG_PRINTENV) += printenv.o
lib-$(CONFIG_PRINTF) += printf.o
lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o
lib-$(CONFIG_PWD) += pwd.o
lib-$(CONFIG_READLINK) += readlink.o
lib-$(CONFIG_REALPATH) += realpath.o
@@ -70,8 +72,10 @@ lib-$(CONFIG_SYNC) += sync.o
lib-$(CONFIG_TAC) += tac.o
lib-$(CONFIG_TAIL) += tail.o
lib-$(CONFIG_TEE) += tee.o
lib-$(CONFIG_TEST) += test.o
lib-$(CONFIG_ASH) += test.o # used by ash
lib-$(CONFIG_TEST) += test.o test_ptr_hack.o
lib-$(CONFIG_ASH) += test.o test_ptr_hack.o # used by ash
lib-$(CONFIG_HUSH) += test.o test_ptr_hack.o # used by hush
lib-$(CONFIG_MSH) += test.o test_ptr_hack.o # used by msh
lib-$(CONFIG_TOUCH) += touch.o
lib-$(CONFIG_TR) += tr.o
lib-$(CONFIG_TRUE) += true.o
+6 -5
View File
@@ -37,15 +37,16 @@ int basename_main(int argc, char **argv)
/* It should strip slash: /abc/def/ -> def */
s = bb_get_last_path_component_strip(*++argv);
m = strlen(s);
if (*++argv) {
n = strlen(*argv);
m = strlen(s);
if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) {
s[m-n] = '\0';
m -= n;
/*s[m] = '\0'; - redundant */
}
}
puts(s);
return fflush(stdout);
/* puts(s) will do, but we can do without stdio this way: */
s[m++] = '\n';
return full_write(STDOUT_FILENO, s, m) != (ssize_t)m;
}
+1 -1
View File
@@ -179,7 +179,7 @@ int cal_main(int argc, char **argv)
}
}
fflush_stdout_and_exit(0);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
/*
-1
View File
@@ -61,7 +61,6 @@ static int fileAction(const char *fileName, struct stat *statbuf,
return FALSE;
}
int chown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int chown_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int retval = EXIT_SUCCESS;
+1 -1
View File
@@ -34,7 +34,7 @@ int cksum_main(int argc ATTRIBUTE_UNUSED, char **argv)
#define read_buf bb_common_bufsiz1
while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 0) {
cp = read_buf;
cp = (uint8_t *) read_buf;
length += bytes_read;
do {
crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *cp++];
+13 -11
View File
@@ -37,25 +37,27 @@ int cp_main(int argc, char **argv)
OPT_r = 1 << (sizeof(FILEUTILS_CP_OPTSTR)),
OPT_P = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+1),
OPT_H = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+2),
OPT_L = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+3),
};
// Need at least two arguments
// Soft- and hardlinking don't mix
// Soft- and hardlinking doesn't mix
// -P and -d are the same (-P is POSIX, -d is GNU)
// -r and -R are the same
// -R (and therefore -r) switches on -d (coreutils does this)
// -R (and therefore -r) turns on -d (coreutils does this)
// -a = -pdR
opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR";
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPHL");
opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR:HL";
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPH");
argc -= optind;
argv += optind;
flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */
/* Default behavior of cp is to dereference, so we don't have to do
* anything special when we are given -L.
* The behavior of -H is *almost* like -L, but not quite, so let's
* just ignore it too for fun.
if (flags & OPT_L) ...
flags ^= FILEUTILS_DEREFERENCE; /* the sense of this flag was reversed */
/* coreutils 6.9 compat:
* by default, "cp" derefs symlinks (creates regular dest files),
* but "cp -R" does not. We switch off deref if -r or -R (see above).
* However, "cp -RL" must still deref symlinks: */
if (flags & FILEUTILS_DEREF_SOFTLINK) /* -L */
flags |= FILEUTILS_DEREFERENCE;
/* The behavior of -H is *almost* like -L, but not quite, so let's
* just ignore it too for fun. TODO.
if (flags & OPT_H) ... // deref command-line params only
*/
+5 -5
View File
@@ -51,7 +51,7 @@ static void cut_file(FILE *file, char delim)
unsigned int linenum = 0; /* keep these zero-based to be consistent */
/* go through every line in the file */
while ((line = xmalloc_getline(file)) != NULL) {
while ((line = xmalloc_fgetline(file)) != NULL) {
/* set up a list so we can keep track of what's been printed */
char * printed = xzalloc(strlen(line) * sizeof(char));
@@ -64,7 +64,7 @@ static void cut_file(FILE *file, char delim)
/* print the chars specified in each cut list */
for (; cl_pos < nlists; cl_pos++) {
spos = cut_lists[cl_pos].startpos;
while (spos < strlen(line)) {
while (spos < (int)strlen(line)) {
if (!printed[spos]) {
printed[spos] = 'X';
putchar(line[spos]);
@@ -80,12 +80,12 @@ static void cut_file(FILE *file, char delim)
/* get out if we have no more lists to process or if the lines
* are lower than what we're interested in */
if (linenum < spos || cl_pos >= nlists)
if (((int)linenum < spos) || (cl_pos >= nlists))
goto next_line;
/* if the line we're looking for is lower than the one we were
* passed, it means we displayed it already, so move on */
while (spos < linenum) {
while (spos < (int)linenum) {
spos++;
/* go to the next list if we're at the end of this one */
if (spos > cut_lists[cl_pos].endpos
@@ -97,7 +97,7 @@ static void cut_file(FILE *file, char delim)
spos = cut_lists[cl_pos].startpos;
/* get out if the current line is lower than the one
* we just became interested in */
if (linenum < spos)
if ((int)linenum < spos)
goto next_line;
}
}
+108 -106
View File
@@ -39,131 +39,135 @@ static void maybe_set_utc(int opt)
}
int date_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int date_main(int argc, char **argv)
int date_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
time_t tm;
struct tm tm_time;
time_t tm;
unsigned opt;
int ifmt = -1;
char *date_str = NULL;
char *date_fmt = NULL;
char *filename = NULL;
char *isofmt_arg;
char *hintfmt_arg;
char *date_str;
char *fmt_dt2str;
char *fmt_str2dt;
char *filename;
char *isofmt_arg = NULL;
opt_complementary = "d--s:s--d"
USE_FEATURE_DATE_ISOFMT(":R--I:I--R");
opt = getopt32(argv, "Rs:ud:r:"
USE_FEATURE_DATE_ISOFMT("I::D:"),
&date_str, &date_str, &filename
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg));
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt));
argv += optind;
maybe_set_utc(opt);
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_TIMESPEC)) {
if (!isofmt_arg) {
ifmt = 0; /* default is date */
} else {
static const char *const isoformats[] = {
"date", "hours", "minutes", "seconds"
};
for (ifmt = 0; ifmt < 4; ifmt++)
if (!strcmp(isofmt_arg, isoformats[ifmt]))
goto found;
/* parse error */
bb_show_usage();
found: ;
ifmt = 0; /* default is date */
if (isofmt_arg) {
static const char isoformats[] ALIGN1 =
"date\0""hours\0""minutes\0""seconds\0";
ifmt = index_in_strings(isoformats, isofmt_arg);
if (ifmt < 0)
bb_show_usage();
}
}
/* XXX, date_fmt == NULL from this always */
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+')) {
date_fmt = &argv[optind][1]; /* Skip over the '+' */
} else if (date_str == NULL) {
opt |= DATE_OPT_SET;
date_str = argv[optind];
fmt_dt2str = NULL;
if (argv[0] && argv[0][0] == '+') {
fmt_dt2str = &argv[0][1]; /* Skip over the '+' */
argv++;
}
if (!(opt & (DATE_OPT_SET | DATE_OPT_DATE))) {
opt |= DATE_OPT_SET;
date_str = argv[0]; /* can be NULL */
if (date_str)
argv++;
}
if (*argv)
bb_show_usage();
/* Now we have parsed all the information except the date format
which depends on whether the clock is being set or read */
if (filename) {
if (opt & DATE_OPT_REFERENCE) {
struct stat statbuf;
xstat(filename, &statbuf);
tm = statbuf.st_mtime;
} else
time(&tm);
memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
/* Zero out fields - take her back to midnight! */
/* If date string is given, update tm_time, and maybe set date */
if (date_str != NULL) {
/* Zero out fields - take her back to midnight! */
tm_time.tm_sec = 0;
tm_time.tm_min = 0;
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)) {
strptime(date_str, hintfmt_arg, &tm_time);
} else if (strchr(date_str, ':') != NULL) {
/* Parse input and assign appropriately to tm_time */
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 (sscanf(date_str, "%d:%d:%d", &tm_time.tm_hour, &tm_time.tm_min,
&tm_time.tm_sec) == 3) {
/* no adjustments needed */
} else if (sscanf(date_str, "%d:%d", &tm_time.tm_hour,
&tm_time.tm_min) == 2) {
/* no adjustments needed */
} else if (sscanf(date_str, "%d.%d-%d:%d:%d", &tm_time.tm_mon,
&tm_time.tm_mday, &tm_time.tm_hour,
&tm_time.tm_min, &tm_time.tm_sec) == 5) {
/* Adjust dates from 1-12 to 0-11 */
tm_time.tm_mon -= 1;
} else if (sscanf(date_str, "%d.%d-%d:%d", &tm_time.tm_mon,
&tm_time.tm_mday,
&tm_time.tm_hour, &tm_time.tm_min) == 4) {
/* Adjust dates from 1-12 to 0-11 */
tm_time.tm_mon -= 1;
} else if (sscanf(date_str, "%d.%d.%d-%d:%d:%d", &tm_time.tm_year,
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,
&tm_time.tm_sec) == 6) {
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, "%d.%d.%d-%d:%d", &tm_time.tm_year,
&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) == 5) {
tm_time.tm_year -= 1900; /* Adjust years */
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
} else {
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
}
} else {
int nr;
char *cp;
nr = sscanf(date_str, "%2d%2d%2d%2d%d", &tm_time.tm_mon,
&tm_time.tm_mday, &tm_time.tm_hour, &tm_time.tm_min,
&tm_time.tm_year);
if (nr < 4 || nr > 5) {
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
}
cp = strchr(date_str, '.');
if (cp) {
nr = sscanf(cp + 1, "%2d", &tm_time.tm_sec);
if (nr != 1) {
&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 */
}
}
/* correct for century - minor Y2K problem here? */
if (tm_time.tm_year >= 1900) {
tm_time.tm_year -= 1900;
if (end != '\0') {
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
}
/* adjust date */
tm_time.tm_mon -= 1;
}
/* 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);
@@ -181,55 +185,53 @@ int date_main(int argc, char **argv)
/* Display output */
/* Deal with format string */
if (date_fmt == NULL) {
if (fmt_dt2str == NULL) {
int i;
date_fmt = xzalloc(32);
fmt_dt2str = xzalloc(32);
if (ENABLE_FEATURE_DATE_ISOFMT && ifmt >= 0) {
strcpy(date_fmt, "%Y-%m-%d");
strcpy(fmt_dt2str, "%Y-%m-%d");
if (ifmt > 0) {
i = 8;
date_fmt[i++] = 'T';
date_fmt[i++] = '%';
date_fmt[i++] = 'H';
fmt_dt2str[i++] = 'T';
fmt_dt2str[i++] = '%';
fmt_dt2str[i++] = 'H';
if (ifmt > 1) {
date_fmt[i++] = ':';
date_fmt[i++] = '%';
date_fmt[i++] = 'M';
}
if (ifmt > 2) {
date_fmt[i++] = ':';
date_fmt[i++] = '%';
date_fmt[i++] = 'S';
fmt_dt2str[i++] = ':';
fmt_dt2str[i++] = '%';
fmt_dt2str[i++] = 'M';
if (ifmt > 2) {
fmt_dt2str[i++] = ':';
fmt_dt2str[i++] = '%';
fmt_dt2str[i++] = 'S';
}
}
format_utc:
date_fmt[i++] = '%';
date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
fmt_dt2str[i++] = '%';
fmt_dt2str[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
}
} else if (opt & DATE_OPT_RFC2822) {
/* Undo busybox.c for date -R */
if (ENABLE_LOCALE_SUPPORT)
setlocale(LC_TIME, "C");
strcpy(date_fmt, "%a, %d %b %Y %H:%M:%S ");
strcpy(fmt_dt2str, "%a, %d %b %Y %H:%M:%S ");
i = 22;
goto format_utc;
} else /* default case */
date_fmt = (char*)"%a %b %e %H:%M:%S %Z %Y";
fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y";
}
#define date_buf bb_common_bufsiz1
if (*date_fmt == '\0') {
if (*fmt_dt2str == '\0') {
/* With no format string, just print a blank line */
date_buf[0] = '\0';
} else {
/* Handle special conversions */
if (strncmp(date_fmt, "%f", 2) == 0) {
date_fmt = (char*)"%Y.%m.%d-%H:%M:%S";
if (strncmp(fmt_dt2str, "%f", 2) == 0) {
fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S";
}
/* Generate output string */
strftime(date_buf, sizeof(date_buf), date_fmt, &tm_time);
strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time);
}
puts(date_buf);
+89 -63
View File
@@ -65,7 +65,7 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
ssize_t n = full_write_or_warn(buf, len, filename);
if (n < 0)
return 1;
if (n == obs)
if ((size_t)n == obs)
G.out_full++;
else if (n) /* > 0 */
G.out_part++;
@@ -79,23 +79,31 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
#endif
int dd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int dd_main(int argc, char **argv)
int dd_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
enum {
FLAG_SYNC = 1 << 0,
FLAG_NOERROR = 1 << 1,
FLAG_NOTRUNC = 1 << 2,
FLAG_TWOBUFS = 1 << 3,
FLAG_COUNT = 1 << 4,
/* Must be in the same order as OP_conv_XXX! */
/* (see "flags |= (1 << what)" below) */
FLAG_NOTRUNC = 1 << 0,
FLAG_SYNC = 1 << 1,
FLAG_NOERROR = 1 << 2,
FLAG_FSYNC = 1 << 3,
/* end of conv flags */
FLAG_TWOBUFS = 1 << 4,
FLAG_COUNT = 1 << 5,
};
static const char keywords[] ALIGN1 =
"bs=\0""count=\0""seek=\0""skip=\0""if=\0""of=\0"
"bs\0""count\0""seek\0""skip\0""if\0""of\0"
#if ENABLE_FEATURE_DD_IBS_OBS
"ibs=\0""obs=\0""conv=\0""notrunc\0""sync\0""noerror\0"
"ibs\0""obs\0""conv\0"
#endif
;
#if ENABLE_FEATURE_DD_IBS_OBS
static const char conv_words[] ALIGN1 =
"notrunc\0""sync\0""noerror\0""fsync\0";
#endif
enum {
OP_bs = 1,
OP_bs = 0,
OP_count,
OP_seek,
OP_skip,
@@ -105,9 +113,23 @@ int dd_main(int argc, char **argv)
OP_ibs,
OP_obs,
OP_conv,
OP_conv_notrunc,
/* Must be in the same order as FLAG_XXX! */
OP_conv_notrunc = 0,
OP_conv_sync,
OP_conv_noerror,
OP_conv_fsync,
/* Unimplemented conv=XXX: */
//nocreat do not create the output file
//excl fail if the output file already exists
//fdatasync physically write output file data before finishing
//swab swap every pair of input bytes
//lcase change upper case to lower case
//ucase change lower case to upper case
//block pad newline-terminated records with spaces to cbs-size
//unblock replace trailing spaces in cbs-size records with newline
//ascii from EBCDIC to ASCII
//ebcdic from ASCII to EBCDIC
//ibm from ASCII to alternate EBCDIC
#endif
};
int exitcode = EXIT_FAILURE;
@@ -138,85 +160,85 @@ int dd_main(int argc, char **argv)
signal_SA_RESTART_empty_mask(SIGUSR1, dd_output_status);
#endif
for (n = 1; n < argc; n++) {
smalluint key_len;
smalluint what;
char *key;
for (n = 1; argv[n]; n++) {
int what;
char *val;
char *arg = argv[n];
//XXX:FIXME: we reject plain "dd --" This would cost ~20 bytes, so..
//if (*arg == '-' && *++arg == '-' && !*++arg) continue;
key = strstr(arg, "=");
if (key == NULL)
#if ENABLE_DESKTOP
/* "dd --". NB: coreutils 6.9 will complain if they see
* more than one of them. We wouldn't. */
if (arg[0] == '-' && arg[1] == '-' && arg[2] == '\0')
continue;
#endif
val = strchr(arg, '=');
if (val == NULL)
bb_show_usage();
key_len = key - arg + 1;
key = xstrndup(arg, key_len);
what = index_in_strings(keywords, key) + 1;
if (ENABLE_FEATURE_CLEAN_UP)
free(key);
if (what == 0)
*val = '\0';
what = index_in_strings(keywords, arg);
if (what < 0)
bb_show_usage();
arg += key_len;
/* *val = '='; - to preserve ps listing? */
val++;
#if ENABLE_FEATURE_DD_IBS_OBS
if (what == OP_ibs) {
/* Must fit into positive ssize_t */
ibs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
continue;
ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
/*continue;*/
}
if (what == OP_obs) {
obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
continue;
obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
/*continue;*/
}
if (what == OP_conv) {
while (1) {
/* find ',', replace them with NUL so we can use arg for
/* find ',', replace them with NUL so we can use val for
* index_in_strings() without copying.
* We rely on arg being non-null, else strchr would fault.
* We rely on val being non-null, else strchr would fault.
*/
key = strchr(arg, ',');
if (key)
*key = '\0';
what = index_in_strings(keywords, arg) + 1;
if (what < OP_conv_notrunc)
bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv");
if (what == OP_conv_notrunc)
flags |= FLAG_NOTRUNC;
if (what == OP_conv_sync)
flags |= FLAG_SYNC;
if (what == OP_conv_noerror)
flags |= FLAG_NOERROR;
if (!key) /* no ',' left, so this was the last specifier */
arg = strchr(val, ',');
if (arg)
*arg = '\0';
what = index_in_strings(conv_words, val);
if (what < 0)
bb_error_msg_and_die(bb_msg_invalid_arg, val, "conv");
flags |= (1 << what);
if (!arg) /* no ',' left, so this was the last specifier */
break;
arg = key + 1; /* skip this keyword and ',' */
/* *arg = ','; - to preserve ps listing? */
val = arg + 1; /* skip this keyword and ',' */
}
continue;
continue; /* we trashed 'what', can't fall through */
}
#endif
if (what == OP_bs) {
ibs = obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
continue;
ibs = obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
/*continue;*/
}
/* These can be large: */
if (what == OP_count) {
flags |= FLAG_COUNT;
count = XATOU_SFX(arg, dd_suffixes);
continue;
count = XATOU_SFX(val, dd_suffixes);
/*continue;*/
}
if (what == OP_seek) {
seek = XATOU_SFX(arg, dd_suffixes);
continue;
seek = XATOU_SFX(val, dd_suffixes);
/*continue;*/
}
if (what == OP_skip) {
skip = XATOU_SFX(arg, dd_suffixes);
continue;
skip = XATOU_SFX(val, dd_suffixes);
/*continue;*/
}
if (what == OP_if) {
infile = arg;
continue;
infile = val;
/*continue;*/
}
if (what == OP_of)
outfile = arg;
}
if (what == OP_of) {
outfile = val;
/*continue;*/
}
} /* end of "for (argv[n])" */
//XXX:FIXME for huge ibs or obs, malloc'ing them isn't the brightest idea ever
ibuf = obuf = xmalloc(ibs);
if (ibs != obs) {
@@ -290,7 +312,7 @@ int dd_main(int argc, char **argv)
while (n) {
size_t d = obs - oc;
if (d > n)
if (d > (size_t)n)
d = n;
memcpy(obuf + oc, tmp, d);
n -= d;
@@ -304,13 +326,17 @@ int dd_main(int argc, char **argv)
}
} else if (write_and_stats(ibuf, n, obs, outfile))
goto out_status;
if (flags & FLAG_FSYNC) {
if (fsync(ofd) < 0)
goto die_outfile;
}
}
if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
w = full_write_or_warn(obuf, oc, outfile);
if (w < 0) goto out_status;
if (w > 0)
G.out_part++;
if (w > 0) G.out_part++;
}
if (close(ifd) < 0) {
die_infile:
+18 -15
View File
@@ -24,24 +24,27 @@ static void convert(char *fn, int conv_type)
{
FILE *in, *out;
int i;
char *name_buf = name_buf; /* for compiler */
char *temp_fn = temp_fn; /* for compiler */
char *resolved_fn = resolved_fn;
in = stdin;
out = stdout;
if (fn != NULL) {
in = xfopen(fn, "r");
/*
The file is then created with mode read/write and
permissions 0666 for glibc 2.0.6 and earlier or
0600 for glibc 2.0.7 and later.
*/
name_buf = xasprintf("%sXXXXXX", fn);
i = mkstemp(name_buf);
struct stat st;
resolved_fn = xmalloc_follow_symlinks(fn);
if (resolved_fn == NULL)
bb_simple_perror_msg_and_die(fn);
in = xfopen(resolved_fn, "r");
fstat(fileno(in), &st);
temp_fn = xasprintf("%sXXXXXX", resolved_fn);
i = mkstemp(temp_fn);
if (i == -1
|| fchmod(i, 0600) == -1
|| fchmod(i, st.st_mode) == -1
|| !(out = fdopen(i, "w+"))
) {
bb_perror_nomsg_and_die();
bb_simple_perror_msg_and_die(temp_fn);
}
}
@@ -56,12 +59,12 @@ static void convert(char *fn, int conv_type)
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0) {
unlink(name_buf);
unlink(temp_fn);
bb_perror_nomsg_and_die();
}
// TODO: destroys symlinks. See how passwd handles this
xrename(name_buf, fn);
free(name_buf);
xrename(temp_fn, resolved_fn);
free(temp_fn);
free(resolved_fn);
}
}
+9 -7
View File
@@ -27,10 +27,8 @@
/* This is a NOFORK applet. Be very careful! */
/* argc is unused, but removing it precludes compiler from
* using call -> jump optimization */
/* NB: can be used by shell even if not enabled as applet */
int echo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int echo_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
const char *arg;
@@ -110,15 +108,19 @@ int echo_main(int argc ATTRIBUTE_UNUSED, char **argv)
}
#if !ENABLE_FEATURE_FANCY_ECHO
/* SUSv3 specifies that octal escapes must begin with '0'. */
if ( (((unsigned char)*arg) - '1') >= 7)
if ( ((int)(unsigned char)(*arg) - '0') >= 8) /* '8' or bigger */
#endif
{
/* Since SUSv3 mandates a first digit of 0, 4-digit octals
* of the form \0### are accepted. */
if (*arg == '0' && ((unsigned char)(arg[1]) - '0') < 8) {
arg++;
if (*arg == '0') {
/* NB: don't turn "...\0" into "...\" */
if (arg[1] && ((unsigned char)(arg[1]) - '0') < 8) {
arg++;
}
}
/* bb_process_escape_sequence can handle nul correctly */
/* bb_process_escape_sequence handles NUL correctly
* ("...\" case). */
c = bb_process_escape_sequence(&arg);
}
}
+2 -4
View File
@@ -29,7 +29,6 @@
* - use xfunc_error_retval
*/
#include <getopt.h> /* struct option */
#include "libbb.h"
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
@@ -63,8 +62,7 @@ int env_main(int argc ATTRIBUTE_UNUSED, char **argv)
environ = cleanenv;
} else {
while (unset_env) {
unsetenv(unset_env->data);
unset_env = unset_env->link;
unsetenv(llist_pop(&unset_env));
}
}
@@ -86,7 +84,7 @@ int env_main(int argc ATTRIBUTE_UNUSED, char **argv)
puts(*ep);
}
fflush_stdout_and_exit(0);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
/*
+2 -2
View File
@@ -41,7 +41,7 @@ static void expand(FILE *file, unsigned tab_size, unsigned opt)
char *line;
char *ptr;
int convert;
int pos;
unsigned pos;
/* Increment tab_size by 1 locally.*/
tab_size++;
@@ -80,7 +80,7 @@ static void unexpand(FILE *file, unsigned int tab_size, unsigned opt)
int convert;
int pos;
int i = 0;
int column = 0;
unsigned column = 0;
while ((line = xmalloc_fgets(file)) != NULL) {
convert = 1;
+84 -87
View File
@@ -28,13 +28,6 @@
#include "libbb.h"
#include "xregex.h"
/* The kinds of value we can have. */
enum valtype {
integer,
string
};
typedef enum valtype TYPE;
#if ENABLE_EXPR_MATH_SUPPORT_64
typedef int64_t arith_t;
@@ -51,10 +44,16 @@ typedef long arith_t;
/* TODO: use bb_strtol[l]? It's easier to check for errors... */
/* The kinds of value we can have. */
enum {
INTEGER,
STRING
};
/* A value is.... */
struct valinfo {
TYPE type; /* Which kind. */
union { /* The value itself. */
smallint type; /* Which kind. */
union { /* The value itself. */
arith_t i;
char *s;
} u;
@@ -77,8 +76,9 @@ static VALUE *int_value(arith_t i)
{
VALUE *v;
v = xmalloc(sizeof(VALUE));
v->type = integer;
v = xzalloc(sizeof(VALUE));
if (INTEGER) /* otherwise xzaaloc did it already */
v->type = INTEGER;
v->u.i = i;
return v;
}
@@ -89,46 +89,47 @@ static VALUE *str_value(const char *s)
{
VALUE *v;
v = xmalloc(sizeof(VALUE));
v->type = string;
v = xzalloc(sizeof(VALUE));
if (STRING) /* otherwise xzaaloc did it already */
v->type = STRING;
v->u.s = xstrdup(s);
return v;
}
/* Free VALUE V, including structure components. */
static void freev(VALUE * v)
static void freev(VALUE *v)
{
if (v->type == string)
if (v->type == STRING)
free(v->u.s);
free(v);
}
/* Return nonzero if V is a null-string or zero-number. */
static int null(VALUE * v)
static int null(VALUE *v)
{
if (v->type == integer)
if (v->type == INTEGER)
return v->u.i == 0;
/* string: */
/* STRING: */
return v->u.s[0] == '\0' || LONE_CHAR(v->u.s, '0');
}
/* Coerce V to a string value (can't fail). */
/* Coerce V to a STRING value (can't fail). */
static void tostring(VALUE * v)
static void tostring(VALUE *v)
{
if (v->type == integer) {
if (v->type == INTEGER) {
v->u.s = xasprintf("%" PF_REZ "d", PF_REZ_TYPE v->u.i);
v->type = string;
v->type = STRING;
}
}
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
/* Coerce V to an INTEGER value. Return 1 on success, 0 on failure. */
static bool toarith(VALUE * v)
static bool toarith(VALUE *v)
{
if (v->type == string) {
if (v->type == STRING) {
arith_t i;
char *e;
@@ -139,50 +140,54 @@ static bool toarith(VALUE * v)
return 0;
free(v->u.s);
v->u.i = i;
v->type = integer;
v->type = INTEGER;
}
return 1;
}
/* Return nonzero if the next token matches STR exactly.
/* Return str[0]+str[1] if the next token matches STR exactly.
STR must not be NULL. */
static bool nextarg(const char *str)
static int nextarg(const char *str)
{
if (*G.args == NULL)
if (*G.args == NULL || strcmp(*G.args, str) != 0)
return 0;
return strcmp(*G.args, str) == 0;
return (unsigned char)str[0] + (unsigned char)str[1];
}
/* The comparison operator handling functions. */
static int cmp_common(VALUE * l, VALUE * r, int op)
static int cmp_common(VALUE *l, VALUE *r, int op)
{
int cmpval;
arith_t ll, rr;
if (l->type == string || r->type == string) {
ll = l->u.i;
rr = r->u.i;
if (l->type == STRING || r->type == STRING) {
tostring(l);
tostring(r);
cmpval = strcmp(l->u.s, r->u.s);
} else
cmpval = l->u.i - r->u.i;
ll = strcmp(l->u.s, r->u.s);
rr = 0;
}
/* calculating ll - rr and checking the result is prone to overflows.
* We'll do it differently: */
if (op == '<')
return cmpval < 0;
if (op == ('L' + 'E'))
return cmpval <= 0;
if (op == '=')
return cmpval == 0;
if (op == '!')
return cmpval != 0;
return ll < rr;
if (op == ('<' + '='))
return ll <= rr;
if (op == '=' || (op == '=' + '='))
return ll == rr;
if (op == '!' + '=')
return ll != rr;
if (op == '>')
return cmpval > 0;
return ll > rr;
/* >= */
return cmpval >= 0;
return ll >= rr;
}
/* The arithmetic operator handling functions. */
static arith_t arithmetic_common(VALUE * l, VALUE * r, int op)
static arith_t arithmetic_common(VALUE *l, VALUE *r, int op)
{
arith_t li, ri;
@@ -190,25 +195,24 @@ static arith_t arithmetic_common(VALUE * l, VALUE * r, int op)
bb_error_msg_and_die("non-numeric argument");
li = l->u.i;
ri = r->u.i;
if ((op == '/' || op == '%') && ri == 0)
bb_error_msg_and_die("division by zero");
if (op == '+')
return li + ri;
else if (op == '-')
if (op == '-')
return li - ri;
else if (op == '*')
if (op == '*')
return li * ri;
else if (op == '/')
if (ri == 0)
bb_error_msg_and_die("division by zero");
if (op == '/')
return li / ri;
else
return li % ri;
return li % ri;
}
/* Do the : operator.
SV is the VALUE for the lhs (the string),
PV is the VALUE for the rhs (the pattern). */
static VALUE *docolon(VALUE * sv, VALUE * pv)
static VALUE *docolon(VALUE *sv, VALUE *pv)
{
VALUE *v;
regex_t re_buffer;
@@ -230,14 +234,16 @@ of a basic regular expression is not portable; it is being ignored", pv->u.s);
/* expr uses an anchored pattern match, so check that there was a
* match and that the match starts at offset 0. */
if (regexec(&re_buffer, sv->u.s, NMATCH, re_regs, 0) != REG_NOMATCH &&
re_regs[0].rm_so == 0) {
if (regexec(&re_buffer, sv->u.s, NMATCH, re_regs, 0) != REG_NOMATCH
&& re_regs[0].rm_so == 0
) {
/* Were \(...\) used? */
if (re_buffer.re_nsub > 0) {
sv->u.s[re_regs[1].rm_eo] = '\0';
v = str_value(sv->u.s + re_regs[1].rm_so);
} else
} else {
v = int_value(re_regs[0].rm_eo);
}
} else {
/* Match failed -- return the right kind of null. */
if (re_buffer.re_nsub > 0)
@@ -327,7 +333,7 @@ static VALUE *eval6(void)
v = str_value("");
else {
v = xmalloc(sizeof(VALUE));
v->type = string;
v->type = STRING;
v->u.s = xstrndup(l->u.s + i1->u.i - 1, i2->u.i);
}
freev(l);
@@ -367,14 +373,11 @@ static VALUE *eval4(void)
l = eval5();
while (1) {
if (nextarg("*"))
op = '*';
else if (nextarg("/"))
op = '/';
else if (nextarg("%"))
op = '%';
else
return l;
op = nextarg("*");
if (!op) { op = nextarg("/");
if (!op) { op = nextarg("%");
if (!op) return l;
}}
G.args++;
r = eval5();
val = arithmetic_common(l, r, op);
@@ -394,12 +397,11 @@ static VALUE *eval3(void)
l = eval4();
while (1) {
if (nextarg("+"))
op = '+';
else if (nextarg("-"))
op = '-';
else
return l;
op = nextarg("+");
if (!op) {
op = nextarg("-");
if (!op) return l;
}
G.args++;
r = eval4();
val = arithmetic_common(l, r, op);
@@ -419,20 +421,15 @@ static VALUE *eval2(void)
l = eval3();
while (1) {
if (nextarg("<"))
op = '<';
else if (nextarg("<="))
op = 'L' + 'E';
else if (nextarg("=") || nextarg("=="))
op = '=';
else if (nextarg("!="))
op = '!';
else if (nextarg(">="))
op = 'G' + 'E';
else if (nextarg(">"))
op = '>';
else
return l;
op = nextarg("<");
if (!op) { op = nextarg("<=");
if (!op) { op = nextarg("=");
if (!op) { op = nextarg("==");
if (!op) { op = nextarg("!=");
if (!op) { op = nextarg(">=");
if (!op) { op = nextarg(">");
if (!op) return l;
}}}}}}
G.args++;
r = eval3();
toarith(l);
@@ -498,7 +495,7 @@ int expr_main(int argc, char **argv)
if (*G.args)
bb_error_msg_and_die("syntax error");
if (v->type == integer)
if (v->type == INTEGER)
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
else
puts(v->u.s);
+1 -1
View File
@@ -8,7 +8,7 @@
*/
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/false.html */
/* http://www.opengroup.org/onlinepubs/000095399/utilities/false.html */
#include "libbb.h"
-3
View File
@@ -9,9 +9,6 @@
* owner/group, will probably modify bb_make_directory(...)
*/
#include <libgen.h>
#include <getopt.h> /* struct option */
#include "libbb.h"
#include "libcoreutils/coreutils.h"
+8
View File
@@ -6,6 +6,10 @@
#ifndef COREUTILS_H
#define COREUTILS_H 1
#if __GNUC_PREREQ(4,1)
# pragma GCC visibility push(hidden)
#endif
typedef int (*stat_func)(const char *fn, struct stat *ps);
int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf);
@@ -13,4 +17,8 @@ int cp_mv_stat(const char *fn, struct stat *fn_stat);
mode_t getopt_mk_fifo_nod(char **argv);
#if __GNUC_PREREQ(4,1)
# pragma GCC visibility pop
#endif
#endif
+87 -63
View File
@@ -29,9 +29,12 @@
* 1. requires lstat (BSD) - how do you do it without?
*/
#include <getopt.h>
#include "libbb.h"
#if ENABLE_FEATURE_ASSUME_UNICODE
#include <wchar.h>
#endif
/* This is a NOEXEC applet. Be very careful! */
@@ -115,18 +118,6 @@ SPLIT_SUBDIR = 2,
#define ATTR(mode) ("\00\00\01\00\01\00\01\00"\
"\00\00\01\00\01\00\00\01" [TYPEINDEX(mode)])
/* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
#if ENABLE_FEATURE_LS_COLOR
static smallint show_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 */
;
#else
enum { show_color = 0 };
#endif
/*
* a directory entry and its stat info are stored here
*/
@@ -138,25 +129,68 @@ struct dnode { /* the basic node */
USE_SELINUX(security_context_t sid;)
struct dnode *next; /* point at the next node */
};
typedef struct dnode dnode_t;
static struct dnode **list_dir(const char *);
static struct dnode **dnalloc(int);
static int list_single(struct dnode *);
static int list_single(const struct dnode *);
static unsigned all_fmt;
struct globals {
#if ENABLE_FEATURE_LS_COLOR
smallint show_color;
#endif
smallint exit_code;
unsigned all_fmt;
#if ENABLE_FEATURE_AUTOWIDTH
static unsigned tabstops = COLUMN_GAP;
static unsigned terminal_width = TERMINAL_WIDTH;
unsigned tabstops; // = COLUMN_GAP;
unsigned terminal_width; // = TERMINAL_WIDTH;
#endif
#if ENABLE_FEATURE_LS_TIMESTAMPS
/* Do time() just once. Saves one syscall per file for "ls -l" */
time_t current_time_t;
#endif
};
#define G (*(struct globals*)&bb_common_bufsiz1)
#if ENABLE_FEATURE_LS_COLOR
#define show_color (G.show_color )
#else
enum { show_color = 0 };
#endif
#define exit_code (G.exit_code )
#define all_fmt (G.all_fmt )
#if ENABLE_FEATURE_AUTOWIDTH
#define tabstops (G.tabstops )
#define terminal_width (G.terminal_width)
#else
enum {
tabstops = COLUMN_GAP,
terminal_width = TERMINAL_WIDTH,
};
#endif
#define current_time_t (G.current_time_t)
/* 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);) \
} 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 int status = EXIT_SUCCESS;
static struct dnode *my_stat(const char *fullname, const char *name, int force_follow)
{
@@ -172,7 +206,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
#endif
if (stat(fullname, &dstat)) {
bb_simple_perror_msg(fullname);
status = EXIT_FAILURE;
exit_code = EXIT_FAILURE;
return 0;
}
} else {
@@ -183,7 +217,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
#endif
if (lstat(fullname, &dstat)) {
bb_simple_perror_msg(fullname);
status = EXIT_FAILURE;
exit_code = EXIT_FAILURE;
return 0;
}
}
@@ -396,7 +430,7 @@ 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 = strlen(dn[i]->name);
int len = mbstrlen(dn[i]->name);
if (column_width < len)
column_width = len;
}
@@ -495,7 +529,7 @@ static struct dnode **list_dir(const char *path)
nfiles = 0;
dir = warn_opendir(path);
if (dir == NULL) {
status = EXIT_FAILURE;
exit_code = EXIT_FAILURE;
return NULL; /* could not open the dir */
}
while ((entry = readdir(dir)) != NULL) {
@@ -539,13 +573,7 @@ static struct dnode **list_dir(const char *path)
}
#if ENABLE_FEATURE_LS_TIMESTAMPS
/* Do time() just once. Saves one syscall per file for "ls -l" */
/* Initialized in main() */
static time_t current_time_t;
#endif
static int list_single(struct dnode *dn)
static int list_single(const struct dnode *dn)
{
int i, column = 0;
@@ -659,7 +687,12 @@ static int list_single(struct dnode *dn)
fgcolor(info.st_mode));
}
#endif
#if ENABLE_FEATURE_ASSUME_UNICODE
printf("%s", dn->name);
column += mbstrlen(dn->name);
#else
column += printf("%s", dn->name);
#endif
if (show_color) {
printf("\033[0m");
}
@@ -702,6 +735,7 @@ static int list_single(struct dnode *dn)
return column;
}
/* "[-]Cadil1", POSIX mandated options, busybox always supports */
/* "[-]gnsx", POSIX non-mandated options, busybox always supports */
/* "[-]Ak" GNU options, busybox always supports */
@@ -780,11 +814,18 @@ static const unsigned opt_flags[] = {
};
/* THIS IS A "SAFE" APPLET, main() MAY BE CALLED INTERNALLY FROM SHELL */
/* BE CAREFUL! */
/* 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, char **argv)
int ls_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
struct dnode **dnd;
struct dnode **dnf;
@@ -792,18 +833,13 @@ int ls_main(int argc, char **argv)
struct dnode *dn;
struct dnode *cur;
unsigned opt;
int nfiles = 0;
int nfiles;
int dnfiles;
int dndirs;
int oi;
int ac;
int i;
char **av;
USE_FEATURE_LS_COLOR(char *color_opt;)
#if ENABLE_FEATURE_LS_TIMESTAMPS
time(&current_time_t);
#endif
INIT_G();
all_fmt = LIST_SHORT |
(ENABLE_FEATURE_LS_SORTFILES * (SORT_NAME | SORT_FORWARD));
@@ -884,39 +920,27 @@ int ls_main(int argc, char **argv)
if (!(all_fmt & STYLE_MASK))
all_fmt |= (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE);
/*
* when there are no cmd line args we have to supply a default "." arg.
* we will create a second argv array, "av" that will hold either
* our created "." arg, or the real cmd line args. The av array
* just holds the pointers- we don't move the date the pointers
* point to.
*/
ac = argc - optind; /* how many cmd line args are left */
if (ac < 1) {
static const char *const dotdir[] = { "." };
argv += optind;
if (!argv[0])
*--argv = (char*)".";
av = (char **) dotdir;
ac = 1;
} else {
av = argv + optind;
}
/* now, everything is in the av array */
if (ac > 1)
all_fmt |= DISP_DIRNAME; /* 2 or more items? label directories */
if (argv[1])
all_fmt |= DISP_DIRNAME; /* 2 or more items? label directories */
/* stuff the command line file names into a dnode array */
dn = NULL;
for (oi = 0; oi < ac; oi++) {
nfiles = 0;
do {
/* ls w/o -l follows links on command line */
cur = my_stat(av[oi], av[oi], !(all_fmt & STYLE_LONG));
cur = my_stat(*argv, *argv, !(all_fmt & STYLE_LONG));
argv++;
if (!cur)
continue;
cur->allocated = 0;
cur->next = dn;
dn = cur;
nfiles++;
}
} while (*argv);
/* now that we know how many files there are
* allocate memory for an array to hold dnode pointers
@@ -951,5 +975,5 @@ int ls_main(int argc, char **argv)
}
if (ENABLE_FEATURE_CLEAN_UP)
dfree(dnp, nfiles);
return status;
return exit_code;
}
+2 -2
View File
@@ -21,7 +21,7 @@ static unsigned char *hash_bin_to_hex(unsigned char *hash_value,
/* xzalloc zero-terminates */
char *hex_value = xzalloc((hash_length * 2) + 1);
bin2hex(hex_value, (char*)hash_value, hash_length);
return hex_value;
return (unsigned char *)hex_value;
}
static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
@@ -115,7 +115,7 @@ int md5_sha1_sum_main(int argc ATTRIBUTE_UNUSED, char **argv)
pre_computed_stream = xfopen_stdin(argv[0]);
while ((line = xmalloc_getline(pre_computed_stream)) != NULL) {
while ((line = xmalloc_fgetline(pre_computed_stream)) != NULL) {
char *filename_ptr;
count_total++;
-1
View File
@@ -19,7 +19,6 @@
/* Nov 28, 2006 Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support.
*/
#include <getopt.h> /* struct option */
#include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
+5 -5
View File
@@ -13,10 +13,6 @@
* Size reduction and improved error checking.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <getopt.h> /* struct option */
#include "libbb.h"
#include "libcoreutils/coreutils.h"
@@ -75,7 +71,8 @@ int mv_main(int argc, char **argv)
}
DO_MOVE:
if (dest_exists && !(flags & OPT_FILEUTILS_FORCE)
if (dest_exists
&& !(flags & OPT_FILEUTILS_FORCE)
&& ((access(dest, W_OK) < 0 && isatty(0))
|| (flags & OPT_FILEUTILS_INTERACTIVE))
) {
@@ -112,6 +109,9 @@ int mv_main(int argc, char **argv)
goto RET_1;
}
}
/* FILEUTILS_RECUR also prevents nasties like
* "read from device and write contents to dst"
* instead of "create same device node" */
copy_flag = FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS;
#if ENABLE_SELINUX
copy_flag |= FILEUTILS_PRESERVE_SECURITY_CONTEXT;
-1
View File
@@ -17,7 +17,6 @@
/* This one provides -t (busybox's own build script needs it) */
#include "od_bloaty.c"
#else
#include <getopt.h>
#include "dump.h"
+11 -15
View File
@@ -50,7 +50,6 @@ diff -u -a std bbox >bbox.diff || { echo Different!; sleep 1; }
*/
#include "libbb.h"
#include <getopt.h>
#define assert(a) ((void)0)
@@ -509,10 +508,10 @@ check_and_close(void)
}
/* If S points to a single valid modern od format string, put
a description of that format in *TSPEC, make *NEXT point at the
character following the just-decoded format (if *NEXT is non-NULL),
and return zero. For example, if S were "d4afL"
*NEXT would be set to "afL" and *TSPEC would be
a description of that format in *TSPEC, return pointer to
character following the just-decoded format.
For example, if S were "d4afL", we will return a rtp to "afL"
and *TSPEC would be
{
fmt = SIGNED_DECIMAL;
size = INT or LONG; (whichever integral_type_size[4] resolves to)
@@ -522,9 +521,8 @@ check_and_close(void)
S_ORIG is solely for reporting errors. It should be the full format
string argument. */
static void
decode_one_format(const char *s_orig, const char *s, const char **next,
struct tspec *tspec)
static const char *
decode_one_format(const char *s_orig, const char *s, struct tspec *tspec)
{
enum size_spec size_spec;
unsigned size;
@@ -537,7 +535,6 @@ decode_one_format(const char *s_orig, const char *s, const char **next,
unsigned field_width = 0;
int pos;
assert(tspec != NULL);
switch (*s) {
case 'd':
@@ -563,13 +560,14 @@ decode_one_format(const char *s_orig, const char *s, const char **next,
s = end;
}
} else {
static const uint8_t CSIL_sizeof[] = {
static const uint8_t CSIL_sizeof[4] = {
sizeof(char),
sizeof(short),
sizeof(int),
sizeof(long),
};
size = CSIL_sizeof[p - CSIL];
s++; /* skip C/S/I/L */
}
#define ISPEC_TO_FORMAT(Spec, Min_format, Long_format, Max_format) \
@@ -717,8 +715,7 @@ decode_one_format(const char *s_orig, const char *s, const char **next,
if (tspec->hexl_mode_trailer)
s++;
if (next != NULL)
*next = s;
return s;
}
/* Decode the modern od format string S. Append the decoded
@@ -734,7 +731,7 @@ decode_format_string(const char *s)
struct tspec tspec;
const char *next;
decode_one_format(s_orig, s, &next, &tspec);
next = decode_one_format(s_orig, s, &tspec);
assert(s != next);
s = next;
@@ -1284,8 +1281,7 @@ int od_main(int argc, char **argv)
if (opt & OPT_o) decode_format_string("o2");
//if (opt & OPT_t)...
while (lst_t) {
decode_format_string(lst_t->data);
lst_t = lst_t->link;
decode_format_string(llist_pop(&lst_t));
}
if (opt & OPT_v) verbose = 1;
if (opt & OPT_x) decode_format_string("x2");
+1 -1
View File
@@ -29,5 +29,5 @@ int printenv_main(int argc ATTRIBUTE_UNUSED, char **argv)
}
}
fflush_stdout_and_exit(0);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
+64 -57
View File
@@ -107,28 +107,28 @@ static void print_esc_string(char *str)
}
}
static void print_direc(char *start, size_t length, int field_width, int precision,
static void print_direc(char *format, unsigned fmt_length,
int field_width, int precision,
const char *argument)
{
char *p; /* Null-terminated copy of % directive. */
char saved;
p = xmalloc((unsigned) (length + 1));
strncpy(p, start, length);
p[length] = 0;
saved = format[fmt_length];
format[fmt_length] = '\0';
switch (p[length - 1]) {
switch (format[fmt_length - 1]) {
case 'd':
case 'i':
if (field_width < 0) {
if (precision < 0)
printf(p, my_xstrtol(argument));
printf(format, my_xstrtol(argument));
else
printf(p, precision, my_xstrtol(argument));
printf(format, precision, my_xstrtol(argument));
} else {
if (precision < 0)
printf(p, field_width, my_xstrtol(argument));
printf(format, field_width, my_xstrtol(argument));
else
printf(p, field_width, precision, my_xstrtol(argument));
printf(format, field_width, precision, my_xstrtol(argument));
}
break;
case 'o':
@@ -137,14 +137,14 @@ static void print_direc(char *start, size_t length, int field_width, int precisi
case 'X':
if (field_width < 0) {
if (precision < 0)
printf(p, my_xstrtoul(argument));
printf(format, my_xstrtoul(argument));
else
printf(p, precision, my_xstrtoul(argument));
printf(format, precision, my_xstrtoul(argument));
} else {
if (precision < 0)
printf(p, field_width, my_xstrtoul(argument));
printf(format, field_width, my_xstrtoul(argument));
else
printf(p, field_width, precision, my_xstrtoul(argument));
printf(format, field_width, precision, my_xstrtoul(argument));
}
break;
case 'f':
@@ -154,51 +154,48 @@ static void print_direc(char *start, size_t length, int field_width, int precisi
case 'G':
if (field_width < 0) {
if (precision < 0)
printf(p, my_xstrtod(argument));
printf(format, my_xstrtod(argument));
else
printf(p, precision, my_xstrtod(argument));
printf(format, precision, my_xstrtod(argument));
} else {
if (precision < 0)
printf(p, field_width, my_xstrtod(argument));
printf(format, field_width, my_xstrtod(argument));
else
printf(p, field_width, precision, my_xstrtod(argument));
printf(format, field_width, precision, my_xstrtod(argument));
}
break;
case 'c':
printf(p, *argument);
printf(format, *argument);
break;
case 's':
if (field_width < 0) {
if (precision < 0)
printf(p, argument);
printf(format, argument);
else
printf(p, precision, argument);
printf(format, precision, argument);
} else {
if (precision < 0)
printf(p, field_width, argument);
printf(format, field_width, argument);
else
printf(p, field_width, precision, argument);
printf(format, field_width, precision, argument);
}
break;
}
free(p);
format[fmt_length] = saved;
}
/* Print the text in FORMAT, using ARGV (with ARGC elements) for
arguments to any '%' directives.
Return the number of elements of ARGV used. */
static int print_formatted(char *format, int argc, char **argv)
/* Print the text in FORMAT, using ARGV for arguments to any '%' directives.
Return advanced ARGV. */
static char **print_formatted(char *f, char **argv)
{
int save_argc = argc; /* Preserve original value. */
char *f; /* Pointer into 'format'. */
char *direc_start; /* Start of % directive. */
size_t direc_length; /* Length of % directive. */
unsigned direc_length; /* Length of % directive. */
int field_width; /* Arg to first '*', or -1 if none. */
int precision; /* Arg to second '*', or -1 if none. */
char **saved_argv = argv;
for (f = format; *f; ++f) {
for (; *f; ++f) {
switch (*f) {
case '%':
direc_start = f++;
@@ -209,10 +206,9 @@ static int print_formatted(char *format, int argc, char **argv)
break;
}
if (*f == 'b') {
if (argc > 0) {
if (*argv) {
print_esc_string(*argv);
++argv;
--argc;
}
break;
}
@@ -223,10 +219,9 @@ static int print_formatted(char *format, int argc, char **argv)
if (*f == '*') {
++f;
++direc_length;
if (argc > 0) {
if (*argv) {
field_width = my_xstrtoul(*argv);
++argv;
--argc;
} else
field_width = 0;
} else {
@@ -241,10 +236,9 @@ static int print_formatted(char *format, int argc, char **argv)
if (*f == '*') {
++f;
++direc_length;
if (argc > 0) {
if (*argv) {
precision = my_xstrtoul(*argv);
++argv;
--argc;
} else
precision = 0;
} else
@@ -262,18 +256,18 @@ static int print_formatted(char *format, int argc, char **argv)
fprintf(stderr, "%%%c: invalid directive", *f);
*/
++direc_length;
if (argc > 0) {
if (*argv) {
print_direc(direc_start, direc_length, field_width,
precision, *argv);
++argv;
--argc;
} else
print_direc(direc_start, direc_length, field_width,
precision, "");
break;
case '\\':
if (*++f == 'c')
exit(0);
if (*++f == 'c') {
return saved_argv; /* causes main() to exit */
}
bb_putchar(bb_process_escape_sequence((const char **)&f));
f--;
break;
@@ -282,32 +276,45 @@ static int print_formatted(char *format, int argc, char **argv)
}
}
return save_argc - argc;
return argv;
}
int printf_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int printf_main(int argc, char **argv)
int printf_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
char *format;
int args_used;
char **argv2;
if (argc <= 1 || argv[1][0] == '-') {
/* We must check that stdout is not closed.
* The reason for this is highly non-obvious. printf_main is used from shell.
* Shell must correctly handle 'printf "%s" foo'
* if stdout is closed. With stdio, output gets shoveled into
* stdout buffer, and even fflush cannot clear it out. It seems that
* even if libc receives EBADF on write attempts, it feels determined
* to output data no matter what. So it will try later,
* and possibly will clobber future output. Not good. */
if (dup2(1, 1) != 1)
return -1;
/* bash builtin errors out on "printf '-%s-\n' foo",
* coreutils-6.9 works. Both work with "printf -- '-%s-\n' foo".
* We will mimic coreutils. */
if (argv[1] && argv[1][0] == '-' && argv[1][1] == '-' && argv[1][2] == '\0')
argv++;
if (!argv[1])
bb_show_usage();
}
format = argv[1];
argc -= 2;
argv += 2;
argv2 = argv + 2;
do {
args_used = print_formatted(format, argc, argv);
argc -= args_used;
argv += args_used;
} while (args_used > 0 && argc > 0);
argv = argv2;
argv2 = print_formatted(format, argv);
} while (argv2 != argv && *argv2);
/* if (argc > 0)
/* coreutils compat (bash doesn't do this):
if (*argv)
fprintf(stderr, "excess args ignored");
*/
*/
return EXIT_SUCCESS;
}
-1
View File
@@ -7,7 +7,6 @@
* Licensed under GPL v2 or later, see file LICENSE in this tarball for details.
*/
#include <getopt.h>
#include "libbb.h"
int readlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
+5 -6
View File
@@ -59,7 +59,8 @@ static struct sort_key {
static char *get_key(char *str, struct sort_key *key, int flags)
{
int start = 0, end = 0, len, i, j;
int start = 0, end = 0, len, j;
unsigned i;
/* Special case whole string, so we don't have to make a copy */
if (key->range[0] == 1 && !key->range[1] && !key->range[2] && !key->range[3]
@@ -150,9 +151,9 @@ static struct sort_key *add_key(void)
#define GET_LINE(fp) \
((option_mask32 & FLAG_z) \
? bb_get_chunk_from_file(fp, NULL) \
: xmalloc_getline(fp))
: xmalloc_fgetline(fp))
#else
#define GET_LINE(fp) xmalloc_getline(fp)
#define GET_LINE(fp) xmalloc_fgetline(fp)
#endif
/* Iterate through keys list and perform comparisons */
@@ -313,7 +314,7 @@ int sort_main(int argc ATTRIBUTE_UNUSED, char **argv)
0
};
struct sort_key *key = add_key();
char *str_k = lst_k->data;
char *str_k = llist_pop(&lst_k);
const char *temp2;
i = 0; /* i==0 before comma, 1 after (-k3,6) */
@@ -343,8 +344,6 @@ int sort_main(int argc ATTRIBUTE_UNUSED, char **argv)
str_k++;
}
}
/* leaking lst_k... */
lst_k = lst_k->link;
}
#endif
/* global b strips leading and trailing spaces */
+2 -2
View File
@@ -98,7 +98,7 @@ int split_main(int argc ATTRIBUTE_UNUSED, char **argv)
}
while (1) {
bytes_read = safe_read(0, read_buffer, READ_BUFFER_SIZE);
bytes_read = safe_read(STDIN_FILENO, read_buffer, READ_BUFFER_SIZE);
if (!bytes_read)
break;
if (bytes_read < 0)
@@ -130,7 +130,7 @@ int split_main(int argc ATTRIBUTE_UNUSED, char **argv)
}
}
xwrite(1, src, to_write);
xwrite(STDOUT_FILENO, src, to_write);
bytes_read -= to_write;
src += to_write;
} while (bytes_read);
+5 -6
View File
@@ -627,11 +627,10 @@ struct globals {
char buf[10];
};
#define G (*(struct globals*)&bb_common_bufsiz1)
#define INIT_G() \
do { \
G.device_name = bb_msg_standard_input; \
G.max_col = 80; \
} while (0)
#define INIT_G() do { \
G.device_name = bb_msg_standard_input; \
G.max_col = 80; \
} while (0)
/* Return a string that is the printable representation of character CH */
@@ -710,7 +709,7 @@ static void wrapf(const char *message, ...)
{
char buf[128];
va_list args;
int buflen;
unsigned buflen;
va_start(args, message);
buflen = vsnprintf(buf, sizeof(buf), message, args);
+14 -17
View File
@@ -92,7 +92,8 @@ int tail_main(int argc, char **argv)
size_t tailbufsize;
int taillen = 0;
int newlines_seen = 0;
int nfiles, nread, nwrite, seen, i, opt;
int nfiles, nread, nwrite, i, opt;
unsigned seen;
int *fds;
char *s, *buf;
@@ -163,8 +164,6 @@ int tail_main(int argc, char **argv)
fmt = header_fmt + 1; /* Skip header leading newline on first output. */
i = 0;
do {
off_t current;
if (nfiles > header_threshhold) {
tail_xprint_header(fmt, argv[i]);
fmt = header_fmt;
@@ -173,19 +172,17 @@ int tail_main(int argc, char **argv)
/* 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) */
current = lseek(fds[i], 0, SEEK_END);
if (current > 0) {
if (!from_top) {
if (COUNT_BYTES && !from_top) {
off_t current = lseek(fds[i], 0, SEEK_END);
if (current > 0) {
if (count == 0)
continue; /* showing zero lines is easy :) */
if (COUNT_BYTES) {
current -= count;
if (current < 0)
current = 0;
xlseek(fds[i], current, SEEK_SET);
bb_copyfd_size(fds[i], STDOUT_FILENO, count);
continue;
}
current -= count;
if (current < 0)
current = 0;
xlseek(fds[i], current, SEEK_SET);
bb_copyfd_size(fds[i], STDOUT_FILENO, count);
continue;
}
}
@@ -214,7 +211,7 @@ int tail_main(int argc, char **argv)
} else if (count) {
if (COUNT_BYTES) {
taillen += nread;
if (taillen > count) {
if (taillen > (int)count) {
memmove(tailbuf, tailbuf + taillen - count, count);
taillen = count;
}
@@ -229,7 +226,7 @@ int tail_main(int argc, char **argv)
}
} while (k);
if (newlines_seen + newlines_in_buf < count) {
if (newlines_seen + newlines_in_buf < (int)count) {
newlines_seen += newlines_in_buf;
taillen += nread;
} else {
@@ -247,7 +244,7 @@ int tail_main(int argc, char **argv)
memmove(tailbuf, s, taillen);
newlines_seen = count - extra;
}
if (tailbufsize < taillen + BUFSIZ) {
if (tailbufsize < (size_t)taillen + BUFSIZ) {
tailbufsize = taillen + BUFSIZ;
tailbuf = xrealloc(tailbuf, tailbufsize);
}
+7 -8
View File
@@ -159,7 +159,7 @@ typedef int arith_t;
/* We try to minimize both static and stack usage. */
struct statics {
struct test_statics {
char **t_wp;
const struct t_op *t_wp_op;
gid_t *group_array;
@@ -167,11 +167,10 @@ struct statics {
jmp_buf leaving;
};
/* Make it reside in writable memory, yet make compiler understand
* that it is not going to change. */
static struct statics *const ptr_to_statics __attribute__ ((section (".data")));
/* See test_ptr_hack.c */
extern struct test_statics *const test_ptr_to_statics;
#define S (*ptr_to_statics)
#define S (*test_ptr_to_statics)
#define t_wp (S.t_wp )
#define t_wp_op (S.t_wp_op )
#define group_array (S.group_array )
@@ -179,11 +178,11 @@ static struct statics *const ptr_to_statics __attribute__ ((section (".data")));
#define leaving (S.leaving )
#define INIT_S() do { \
(*(struct statics**)&ptr_to_statics) = xzalloc(sizeof(S)); \
(*(struct test_statics**)&test_ptr_to_statics) = xzalloc(sizeof(S)); \
barrier(); \
} while (0)
#define DEINIT_S() do { \
free(ptr_to_statics); \
free(test_ptr_to_statics); \
} while (0)
static arith_t primary(enum token n);
@@ -413,7 +412,7 @@ static int test_eaccess(char *path, int mode)
static int filstat(char *nm, enum token mode)
{
struct stat s;
int i = i; /* gcc 3.x thinks it can be used uninitialized */
unsigned i = i; /* gcc 3.x thinks it can be used uninitialized */
if (mode == FILSYM) {
#ifdef S_IFLNK
+23
View File
@@ -0,0 +1,23 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2008 by Denys Vlasenko <vda.linux@googlemail.com>
*
* Licensed under GPLv2, see file LICENSE in this tarball for details.
*/
struct test_statics;
#ifndef GCC_COMBINE
/* We cheat here. It is declared as const ptr in libbb.h,
* but here we make it live in R/W memory */
struct test_statics *test_ptr_to_statics;
#else
/* gcc -combine will see through and complain */
/* Using alternative method which is more likely to break
* on weird architectures, compilers, linkers and so on */
struct test_statics *const test_ptr_to_statics __attribute__ ((section (".data")));
#endif
+3 -3
View File
@@ -208,8 +208,8 @@ int tr_main(int argc ATTRIBUTE_UNUSED, char **argv)
if (*argv) {
if (argv[0][0] == '\0')
bb_error_msg_and_die("STRING2 cannot be empty");
output_length = expand(*argv, output);
map(vector, tr_buf, input_length, output, output_length);
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;
@@ -219,7 +219,7 @@ int tr_main(int argc ATTRIBUTE_UNUSED, char **argv)
for (;;) {
/* If we're out of input, flush output and read more input. */
if (in_index == read_chars) {
if ((ssize_t)in_index == read_chars) {
if (out_index) {
xwrite(STDOUT_FILENO, (char *)output, out_index);
out_index = 0;
+19 -22
View File
@@ -17,7 +17,7 @@
-m, --machine sun
-a, --all SunOS rocky8 4.0 sun
The default behavior is equivalent to `-s'.
The default behavior is equivalent to '-s'.
David MacKenzie <djm@gnu.ai.mit.edu> */
@@ -39,47 +39,43 @@ typedef struct {
} uname_info_t;
static const char options[] ALIGN1 = "snrvmpa";
static const unsigned short utsname_offset[] ALIGN2 = {
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)
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)
};
int uname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int uname_main(int argc, char **argv)
int uname_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
uname_info_t uname_info;
#if defined(__sparc__) && defined(__linux__)
char *fake_sparc = getenv("FAKE_SPARC");
#endif
const unsigned short int *delta;
const unsigned short *delta;
char toprint;
toprint = getopt32(argv, options);
if (argc != optind) {
if (argv[optind]) { /* coreutils-6.9 compat */
bb_show_usage();
}
if (toprint & (1 << 6)) {
if (toprint & (1 << 6)) { /* -a => all opts on */
toprint = 0x3f;
}
if (toprint == 0) {
toprint = 1; /* sysname */
if (toprint == 0) { /* no opts => -s (sysname) */
toprint = 1;
}
if (uname(&uname_info.name) == -1) {
bb_error_msg_and_die("cannot get system name");
}
uname(&uname_info.name); /* never fails */
#if defined(__sparc__) && defined(__linux__)
if ((fake_sparc != NULL)
&& ((fake_sparc[0] == 'y')
|| (fake_sparc[0] == 'Y'))) {
if (fake_sparc && (fake_sparc[0] | 0x20) == 'y') {
strcpy(uname_info.name.machine, "sparc");
}
#endif
@@ -89,7 +85,8 @@ int uname_main(int argc, char **argv)
delta = utsname_offset;
do {
if (toprint & 1) {
printf(((char *)(&uname_info)) + *delta);
/* printf would not be safe here */
fputs((char *)(&uname_info) + *delta, stdout);
if (toprint > 1) {
bb_putchar(' ');
}
@@ -98,5 +95,5 @@ int uname_main(int argc, char **argv)
} while (toprint >>= 1);
bb_putchar('\n');
fflush_stdout_and_exit(EXIT_SUCCESS);
fflush_stdout_and_exit(EXIT_SUCCESS); /* coreutils-6.9 compat */
}
+12 -13
View File
@@ -12,8 +12,6 @@
#include "libbb.h"
static const char uniq_opts[] ALIGN1 = "cdu" "f:s:" "cdu\0\1\2\4";
static FILE *xgetoptfile_uniq_s(char **argv, int read0write2)
{
const char *n;
@@ -31,9 +29,11 @@ int uniq_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
FILE *in, *out;
unsigned long dups, skip_fields, skip_chars, i;
const char *s0, *e0, *s1, *e1, *input_filename;
unsigned long dups;
unsigned skip_fields, skip_chars, max_chars;
unsigned opt;
unsigned i;
enum {
OPT_c = 0x1,
@@ -41,15 +41,14 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
OPT_u = 0x4,
OPT_f = 0x8,
OPT_s = 0x10,
OPT_w = 0x20,
};
skip_fields = skip_chars = 0;
max_chars = -1;
opt = getopt32(argv, "cduf:s:", &s0, &s1);
if (opt & OPT_f)
skip_fields = xatoul(s0);
if (opt & OPT_s)
skip_chars = xatoul(s1);
opt_complementary = "f+:s+:w+";
opt = getopt32(argv, "cduf:s:w:", &skip_fields, &skip_chars, &max_chars);
argv += optind;
input_filename = *argv;
@@ -63,7 +62,7 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
bb_show_usage();
}
s1 = e1 = NULL; /* prime the pump */
s1 = e1 = NULL; /* prime the pump */
do {
s0 = s1;
@@ -71,7 +70,7 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
dups = 0;
/* gnu uniq ignores newlines */
while ((s1 = xmalloc_getline(in)) != NULL) {
while ((s1 = xmalloc_fgetline(in)) != NULL) {
e1 = s1;
for (i = skip_fields; i; i--) {
e1 = skip_whitespace(e1);
@@ -81,16 +80,16 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
++e1;
}
if (!s0 || strcmp(e0, e1)) {
if (!s0 || strncmp(e0, e1, max_chars)) {
break;
}
++dups; /* Note: Testing for overflow seems excessive. */
++dups; /* note: testing for overflow seems excessive. */
}
if (s0) {
if (!(opt & (OPT_d << !!dups))) { /* (if dups, opt & OPT_e) */
fprintf(out, "\0%d " + (opt & 1), dups + 1);
fprintf(out, "\0%ld " + (opt & 1), dups + 1); /* 1 == OPT_c */
fprintf(out, "%s\n", s0);
}
free((void *)s0);
+2 -2
View File
@@ -18,7 +18,7 @@ static void read_stduu(FILE *src_stream, FILE *dst_stream)
{
char *line;
while ((line = xmalloc_getline(src_stream)) != NULL) {
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
int encoded_len, str_len;
char *line_ptr, *dst;
@@ -151,7 +151,7 @@ int uudecode_main(int argc ATTRIBUTE_UNUSED, char **argv)
src_stream = xfopen_stdin(*argv);
/* Search for the start of the encoding */
while ((line = xmalloc_getline(src_stream)) != NULL) {
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
void (*decode_fn_ptr)(FILE * src, FILE * dst);
char *line_ptr;
FILE *dst_stream;
+5 -1
View File
@@ -56,16 +56,20 @@ int who_main(int argc ATTRIBUTE_UNUSED, char **argv)
printf("USER TTY IDLE TIME HOST\n");
while ((ut = getutent()) != NULL) {
if (ut->ut_user[0] && (opt || ut->ut_type == USER_PROCESS)) {
time_t tmp;
/* ut->ut_line is device name of tty - "/dev/" */
name = concat_path_file("/dev", ut->ut_line);
str6[0] = '?';
str6[1] = '\0';
if (stat(name, &st) == 0)
idle_string(str6, st.st_atime);
/* manpages say ut_tv.tv_sec *is* time_t,
* but some systems have it wrong */
tmp = ut->ut_tv.tv_sec;
/* 15 chars for time: Nov 10 19:33:20 */
printf("%-10s %-8s %-9s %-15.15s %s\n",
ut->ut_user, ut->ut_line, str6,
ctime(&(ut->ut_tv.tv_sec)) + 4, ut->ut_host);
ctime(&tmp) + 4, ut->ut_host);
if (ENABLE_FEATURE_CLEAN_UP)
free(name);
}
+30 -11
View File
@@ -9,34 +9,53 @@
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
/* Coreutils 6.12 man page says:
* mktemp [OPTION]... [TEMPLATE]
* Create a temporary file or directory, safely, and print its name. If
* TEMPLATE is not specified, use tmp.XXXXXXXXXX.
* -d, --directory
* create a directory, not a file
* -q, --quiet
* suppress diagnostics about file/dir-creation failure
* -u, --dry-run
* do not create anything; merely print a name (unsafe)
* --tmpdir[=DIR]
* interpret TEMPLATE relative to DIR. If DIR is not specified,
* use $TMPDIR if set, else /tmp. With this option, TEMPLATE must
* not be an absolute name. Unlike with -t, TEMPLATE may contain
* slashes, but even here, mktemp still creates only the final com-
* ponent.
* -p DIR use DIR as a prefix; implies -t [deprecated]
* -t interpret TEMPLATE as a single file name component, relative to
* a directory: $TMPDIR, if set; else the directory specified via
* -p; else /tmp [deprecated]
*/
#include "libbb.h"
int mktemp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int mktemp_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
// -d Make a directory instead of a file
// -q Fail silently if an error occurs [bbox: ignored]
// -t Generate a path rooted in temporary directory
// -p DIR Use DIR as a temporary directory (implies -t)
const char *path;
char *chp;
unsigned flags;
unsigned opt;
opt_complementary = "=1"; /* exactly one arg */
flags = getopt32(argv, "dqtp:", &path);
chp = argv[optind];
opt_complementary = "?1"; /* 1 argument max */
opt = getopt32(argv, "dqtp:", &path);
chp = argv[optind] ? argv[optind] : xstrdup("tmp.XXXXXX");
if (flags & (4|8)) { /* -t and/or -p */
if (opt & (4|8)) { /* -t and/or -p */
const char *dir = getenv("TMPDIR");
if (dir && *dir != '\0')
path = dir;
else if (!(flags & 8)) /* No -p */
else if (!(opt & 8)) /* no -p */
path = "/tmp/";
/* else path comes from -p DIR */
chp = concat_path_file(path, chp);
}
if (flags & 1) { /* -d */
if (opt & 1) { /* -d */
if (mkdtemp(chp) == NULL)
return EXIT_FAILURE;
} else {
+2 -6
View File
@@ -30,8 +30,6 @@
* -u MASK umask. Set the umask of the program executed to MASK.
*/
#include <getopt.h>
#include "libbb.h"
struct globals {
@@ -44,7 +42,7 @@ struct globals {
#define cur (G.cur )
#define cmd (G.cmd )
enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(struct globals)) / sizeof(cmd[0]) };
enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 };
enum {
OPT_r = (1 << 0),
@@ -132,9 +130,7 @@ int run_parts_main(int argc ATTRIBUTE_UNUSED, char **argv)
n = 1;
while (arg_list && n < NUM_CMD) {
cmd[n] = arg_list->data;
arg_list = arg_list->link;
n++;
cmd[n++] = llist_pop(&arg_list);
}
/* cmd[n] = NULL; - is already zeroed out */
+186 -102
View File
@@ -8,10 +8,54 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* NB: we have a problem here with /proc/NN/exe usage, similar to
* one fixed in killall/pidof */
/*
This is how it is supposed to work:
start-stop-daemon [OPTIONS] [--start|--stop] [[--] arguments...]
One (only) of these must be given:
-S,--start Start
-K,--stop Stop
Search for matching processes.
If --stop is given, stop all matching processes (by sending a signal).
If --start is given, start a new process unless a matching process was found.
Options controlling process matching
(if multiple conditions are specified, all must match):
-u,--user USERNAME|UID Only consider this user's processes
-n,--name PROCESS_NAME Look for processes by matching PROCESS_NAME
with comm field in /proc/$PID/stat.
Only basename is compared:
"ntpd" == "./ntpd" == "/path/to/ntpd".
[TODO: can PROCESS_NAME be a full pathname? Should we require full match then
with /proc/$PID/exe or argv[0] (comm can't be matched, it never contains path)]
-x,--exec EXECUTABLE Look for processes that were started with this
command in /proc/$PID/cmdline.
Unlike -n, we match against the full path:
"ntpd" != "./ntpd" != "/path/to/ntpd"
-p,--pidfile PID_FILE Look for processes with PID from this file
Options which are valid for --start only:
-x,--exec EXECUTABLE Program to run (1st arg of execvp). Mandatory.
-a,--startas NAME argv[0] (defaults to EXECUTABLE)
-b,--background Put process into background
-N,--nicelevel N Add N to process' nice level
-c,--chuid USER[:[GRP]] Change to specified user [and group]
-m,--make-pidfile Write PID to the pidfile
(both -m and -p must be given!)
Options which are valid for --stop only:
-s,--signal SIG Signal to send (default:TERM)
-t,--test Exit with status 0 if process is found
(we don't actually start or stop daemons)
Misc options:
-o,--oknodo Exit with status 0 if nothing is done
-q,--quiet Quiet
-v,--verbose Verbose
*/
#include <getopt.h>
#include <sys/resource.h>
/* Override ENABLE_FEATURE_PIDFILE */
@@ -23,6 +67,26 @@ struct pid_list {
pid_t pid;
};
enum {
CTX_STOP = (1 << 0),
CTX_START = (1 << 1),
OPT_BACKGROUND = (1 << 2), // -b
OPT_QUIET = (1 << 3), // -q
OPT_TEST = (1 << 4), // -t
OPT_MAKEPID = (1 << 5), // -m
OPT_a = (1 << 6), // -a
OPT_n = (1 << 7), // -n
OPT_s = (1 << 8), // -s
OPT_u = (1 << 9), // -u
OPT_c = (1 << 10), // -c
OPT_x = (1 << 11), // -x
OPT_p = (1 << 12), // -p
OPT_OKNODO = (1 << 13) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -o
OPT_VERBOSE = (1 << 14) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -v
OPT_NICELEVEL = (1 << 15) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -N
};
#define QUIET (option_mask32 & OPT_QUIET)
#define TEST (option_mask32 & OPT_TEST)
struct globals {
struct pid_list *found;
@@ -31,7 +95,6 @@ struct globals {
char *execname;
char *pidfile;
int user_id;
smallint quiet;
smallint signal_nr;
};
#define G (*(struct globals*)&bb_common_bufsiz1)
@@ -41,77 +104,93 @@ struct globals {
#define execname (G.execname )
#define pidfile (G.pidfile )
#define user_id (G.user_id )
#define quiet (G.quiet )
#define signal_nr (G.signal_nr )
#define INIT_G() \
do { \
user_id = -1; \
signal_nr = 15; \
} while (0)
#define INIT_G() do { \
user_id = -1; \
signal_nr = 15; \
} while (0)
static int pid_is_exec(pid_t pid, const char *name)
#ifdef OLDER_VERSION_OF_X
/* -x,--exec EXECUTABLE
* Look for processes with matching /proc/$PID/exe.
* Match is performed using device+inode.
*/
static int pid_is_exec(pid_t pid)
{
struct stat st;
char buf[sizeof("/proc//exe") + sizeof(int)*3];
char *execbuf;
int n;
sprintf(buf, "/proc/%u/exe", pid);
n = strlen(name) + 1;
execbuf = xzalloc(n + 1);
readlink(buf, execbuf, n);
/* if readlink fails because link target is longer than strlen(name),
* execbuf still contains "", and strcmp will return !0. */
n = strcmp(execbuf, name);
if (ENABLE_FEATURE_CLEAN_UP)
free(execbuf);
return !n; /* nonzero (true) if execbuf == name */
sprintf(buf, "/proc/%u/exe", (unsigned)pid);
if (stat(buf, &st) < 0)
return 0;
if (st.st_dev == execstat.st_dev
&& st.st_ino == execstat.st_ino)
return 1;
return 0;
}
#endif
static int pid_is_exec(pid_t pid)
{
ssize_t bytes;
char buf[PATH_MAX];
sprintf(buf, "/proc/%u/cmdline", (unsigned)pid);
bytes = open_read_close(buf, buf, sizeof(buf) - 1);
if (bytes > 0) {
buf[bytes] = '\0';
return strcmp(buf, execname) == 0;
}
return 0;
}
static int pid_is_user(int pid, int uid)
static int pid_is_name(pid_t pid)
{
/* /proc/PID/stat is "PID (comm_15_bytes_max) ..." */
char buf[32]; /* should be enough */
char *p, *pe;
sprintf(buf, "/proc/%u/stat", (unsigned)pid);
if (open_read_close(buf, buf, sizeof(buf) - 1) < 0)
return 0;
buf[sizeof(buf) - 1] = '\0'; /* paranoia */
p = strchr(buf, '(');
if (!p)
return 0;
pe = strrchr(++p, ')');
if (!pe)
return 0;
*pe = '\0';
/* we require comm to match and to not be truncated */
/* in Linux, if comm is 15 chars, it may be a truncated
* name, so we don't allow that to match */
if (strlen(p) >= COMM_LEN - 1) /* COMM_LEN is 16 */
return 0;
return strcmp(p, cmdname) == 0;
}
static int pid_is_user(int pid)
{
struct stat sb;
char buf[sizeof("/proc/") + sizeof(int)*3];
sprintf(buf, "/proc/%u", pid);
sprintf(buf, "/proc/%u", (unsigned)pid);
if (stat(buf, &sb) != 0)
return 0;
return (sb.st_uid == uid);
}
static int pid_is_cmd(pid_t pid, const char *name)
{
char fname[sizeof("/proc//stat") + sizeof(int)*3];
char *buf;
int r = 0;
sprintf(fname, "/proc/%u/stat", pid);
buf = xmalloc_open_read_close(fname, NULL);
if (buf) {
char *p = strchr(buf, '(');
if (p) {
char *pe = strrchr(++p, ')');
if (pe) {
*pe = '\0';
r = !strcmp(p, name);
}
}
free(buf);
}
return r;
return (sb.st_uid == (uid_t)user_id);
}
static void check(int pid)
{
struct pid_list *p;
if (execname && !pid_is_exec(pid, execname)) {
if (execname && !pid_is_exec(pid)) {
return;
}
if (userspec && !pid_is_user(pid, user_id)) {
if (cmdname && !pid_is_name(pid)) {
return;
}
if (cmdname && !pid_is_cmd(pid, cmdname)) {
if (userspec && !pid_is_user(pid)) {
return;
}
p = xmalloc(sizeof(*p));
@@ -148,9 +227,17 @@ static void do_procinit(void)
procdir = xopendir("/proc");
pid = 0;
while ((entry = readdir(procdir)) != NULL) {
while (1) {
errno = 0; /* clear any previous error */
entry = readdir(procdir);
// TODO: this check is too generic, it's better
// to check for exact errno(s) which mean that we got stale entry
if (errno) /* Stale entry, process has died after opendir */
continue;
if (!entry) /* EOF, no more entries */
break;
pid = bb_strtou(entry->d_name, NULL, 10);
if (errno)
if (errno) /* NaN */
continue;
check(pid);
}
@@ -165,40 +252,39 @@ static int do_stop(void)
struct pid_list *p;
int killed = 0;
do_procinit();
if (cmdname) {
if (ENABLE_FEATURE_CLEAN_UP) what = xstrdup(cmdname);
if (!ENABLE_FEATURE_CLEAN_UP) what = cmdname;
} else if (execname) {
if (ENABLE_FEATURE_CLEAN_UP) what = xstrdup(execname);
if (!ENABLE_FEATURE_CLEAN_UP) what = execname;
} else if (pidfile)
} else if (pidfile) {
what = xasprintf("process in pidfile '%s'", pidfile);
else if (userspec)
} else if (userspec) {
what = xasprintf("process(es) owned by '%s'", userspec);
else
} else {
bb_error_msg_and_die("internal error, please report");
}
if (!found) {
if (!quiet)
if (!QUIET)
printf("no %s found; none killed\n", what);
killed = -1;
goto ret;
}
for (p = found; p; p = p->next) {
if (kill(p->pid, signal_nr) == 0) {
p->pid = - p->pid;
if (TEST || kill(p->pid, signal_nr) == 0) {
killed++;
} else {
bb_perror_msg("warning: killing process %u", p->pid);
p->pid = 0;
bb_perror_msg("warning: killing process %u", (unsigned)p->pid);
}
}
if (!quiet && killed) {
if (!QUIET && killed) {
printf("stopped %s (pid", what);
for (p = found; p; p = p->next)
if (p->pid < 0)
printf(" %u", - p->pid);
if (p->pid)
printf(" %u", (unsigned)p->pid);
puts(")");
}
ret:
@@ -213,6 +299,7 @@ static const char start_stop_daemon_longopts[] ALIGN1 =
"start\0" No_argument "S"
"background\0" No_argument "b"
"quiet\0" No_argument "q"
"test\0" No_argument "t"
"make-pidfile\0" No_argument "m"
#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
"oknodo\0" No_argument "o"
@@ -232,31 +319,16 @@ static const char start_stop_daemon_longopts[] ALIGN1 =
;
#endif
enum {
CTX_STOP = 0x1,
CTX_START = 0x2,
OPT_BACKGROUND = 0x4, // -b
OPT_QUIET = 0x8, // -q
OPT_MAKEPID = 0x10, // -m
OPT_a = 0x20, // -a
OPT_n = 0x40, // -n
OPT_s = 0x80, // -s
OPT_u = 0x100, // -u
OPT_c = 0x200, // -c
OPT_x = 0x400, // -x
OPT_p = 0x800, // -p
OPT_OKNODO = 0x1000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -o
OPT_VERBOSE = 0x2000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -v
OPT_NICELEVEL = 0x4000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -N
};
int start_stop_daemon_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int start_stop_daemon_main(int argc, char **argv)
int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
unsigned opt;
char *signame;
char *startas;
char *chuid;
#ifdef OLDER_VERSION_OF_X
struct stat execstat;
#endif
#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
// char *retry_arg = NULL;
// int retries = -1;
@@ -269,9 +341,14 @@ int start_stop_daemon_main(int argc, char **argv)
applet_long_options = start_stop_daemon_longopts;
#endif
/* Check required one context option was given */
opt_complementary = "K:S:K--S:S--K:m?p:K?xpun:S?xa";
opt = getopt32(argv, "KSbqma:n:s:u:c:x:p:"
/* -K or -S is required; they are mutually exclusive */
/* -p is required if -m is given */
/* -xpun (at least one) is required if -K is given */
/* -xa (at least one) is required if -S is given */
/* -q turns off -v */
opt_complementary = "K:S:K--S:S--K:m?p:K?xpun:S?xa"
USE_FEATURE_START_STOP_DAEMON_FANCY("q-v");
opt = getopt32(argv, "KSbqtma:n:s:u:c:x:p:"
USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:"),
// USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:R:"),
&startas, &cmdname, &signame, &userspec, &chuid, &execname, &pidfile
@@ -279,8 +356,6 @@ int start_stop_daemon_main(int argc, char **argv)
// USE_FEATURE_START_STOP_DAEMON_FANCY(,&retry_arg)
);
quiet = (opt & OPT_QUIET) && !(opt & OPT_VERBOSE);
if (opt & OPT_s) {
signal_nr = get_signum(signame);
if (signal_nr < 0) bb_show_usage();
@@ -288,12 +363,14 @@ int start_stop_daemon_main(int argc, char **argv)
if (!(opt & OPT_a))
startas = execname;
if (!execname) /* in case -a is given and -x is not */
execname = startas;
// USE_FEATURE_START_STOP_DAEMON_FANCY(
// if (retry_arg)
// retries = xatoi_u(retry_arg);
// )
argc -= optind;
//argc -= optind;
argv += optind;
if (userspec) {
@@ -301,23 +378,31 @@ int start_stop_daemon_main(int argc, char **argv)
if (errno)
user_id = xuname2uid(userspec);
}
/* Both start and stop need to know current processes */
do_procinit();
if (opt & CTX_STOP) {
int i = do_stop();
return (opt & OPT_OKNODO) ? 0 : (i <= 0);
}
do_procinit();
if (found) {
if (!quiet)
printf("%s already running\n%d\n", execname, found->pid);
if (!QUIET)
printf("%s is already running\n%u\n", execname, (unsigned)found->pid);
return !(opt & OPT_OKNODO);
}
#ifdef OLDER_VERSION_OF_X
if (execname)
xstat(execname, &execstat);
#endif
*--argv = startas;
if (opt & OPT_BACKGROUND) {
#if BB_MMU
bb_daemonize(0);
bb_daemonize(DAEMON_DEVNULL_STDIO + DAEMON_CLOSE_EXTRA_FDS);
/* DAEMON_DEVNULL_STDIO is superfluous -
* it's always done by bb_daemonize() */
#else
pid_t pid = vfork();
if (pid < 0) /* error */
@@ -326,21 +411,20 @@ int start_stop_daemon_main(int argc, char **argv)
/* parent */
/* why _exit? the child may have changed the stack,
* so "return 0" may do bad things */
_exit(0);
_exit(EXIT_SUCCESS);
}
/* child */
/* Child */
setsid(); /* detach from controlling tty */
/* Redirect stdio to /dev/null, close extra FDs.
* We do not actually daemonize because of DAEMON_ONLY_SANITIZE */
bb_daemonize_or_rexec(
DAEMON_DEVNULL_STDIO
bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO
+ DAEMON_CLOSE_EXTRA_FDS
+ DAEMON_ONLY_SANITIZE,
NULL /* argv, unused */ );
#endif
}
if (opt & OPT_MAKEPID) {
/* user wants _us_ to make the pidfile */
/* User wants _us_ to make the pidfile */
write_pidfile(pidfile);
}
if (opt & OPT_c) {
@@ -358,6 +442,6 @@ int start_stop_daemon_main(int argc, char **argv)
}
}
#endif
execv(startas, argv);
execvp(startas, argv);
bb_perror_msg_and_die("cannot start %s", startas);
}
+52 -12
View File
@@ -13,30 +13,69 @@
#include "libbb.h"
int which_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int which_main(int argc, char **argv)
int which_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
USE_DESKTOP(int opt;)
int status = EXIT_SUCCESS;
char *path;
char *p;
if (argc <= 1 || argv[1][0] == '-') {
bb_show_usage();
opt_complementary = "-1"; /* at least one argument */
USE_DESKTOP(opt =) getopt32(argv, "a");
argv += optind;
/* This matches what is seen on e.g. ubuntu.
* "which" there is a shell script. */
path = getenv("PATH");
if (!path) {
path = (char*)bb_PATH_root_path;
putenv(path);
path += 5; /* skip "PATH=" */
}
/* This matches what is seen on e.g. ubuntu
* "which" there is a shell script */
if (!getenv("PATH")) {
putenv((char*)bb_PATH_root_path);
}
do {
#if ENABLE_DESKTOP
/* Much bloat just to support -a */
if (strchr(*argv, '/')) {
if (execable_file(*argv)) {
puts(*argv);
continue;
}
status = EXIT_FAILURE;
} else {
char *path2 = xstrdup(path);
char *tmp = path2;
while (--argc > 0) {
argv++;
p = find_execable(*argv, &tmp);
if (!p)
status = EXIT_FAILURE;
else {
print:
puts(p);
free(p);
if (opt) {
/* -a: show matches in all PATH components */
if (tmp) {
p = find_execable(*argv, &tmp);
if (p)
goto print;
}
}
}
free(path2);
}
#else
/* Just ignoring -a */
if (strchr(*argv, '/')) {
if (execable_file(*argv)) {
puts(*argv);
continue;
}
} else {
p = find_execable(*argv);
char *path2 = xstrdup(path);
char *tmp = path2;
p = find_execable(*argv, &tmp);
free(path2);
if (p) {
puts(p);
free(p);
@@ -44,7 +83,8 @@ int which_main(int argc, char **argv)
}
}
status = EXIT_FAILURE;
}
#endif
} while (*(++argv) != NULL);
fflush_stdout_and_exit(status);
}
+1 -1
View File
@@ -17,7 +17,7 @@ your embedded systems. To create a working system, just add some device
nodes in /dev, a few configuration files in /etc, and a Linux kernel.</p>
<p>BusyBox is maintained by
<a href="mailto:vda.linux@googlemail.com">Denis Vlasenko</a>,
<a href="mailto:vda.linux@googlemail.com">Denys Vlasenko</a>,
and licensed under the <a href="/license.html">GNU GENERAL PUBLIC LICENSE</a>
version 2.</p>
+3
View File
@@ -14,6 +14,9 @@ Also there are patches on top of latest bug fix release.
<p>
Latest releases and patch directories for each branch:
<br>
<a href=http://busybox.net/downloads/busybox-1.10.1.tar.bz2>1.10.1</a>,
<a href=http://busybox.net/downloads/fixes-1.10.1/>patches</a>,
<br>
<a href=http://busybox.net/downloads/busybox-1.9.2.tar.bz2>1.9.2</a>,
<a href=http://busybox.net/downloads/fixes-1.9.2/>patches</a>,
<br>
+1 -1
View File
@@ -16,7 +16,7 @@
<br>
Mail all comments, insults, suggestions and bribes to
<br>
Denis Vlasenko <a href="mailto:vda.linux@googlemail.com">vda.linux@googlemail.com</a><br>
Denys Vlasenko <a href="mailto:vda.linux@googlemail.com">vda.linux@googlemail.com</a><br>
</font>
</td>
+8 -7
View File
@@ -65,7 +65,7 @@
<ul>
<li><a href="/cgi-bin/viewcvs.cgi/trunk/busybox/">Browse Source</a></li>
<li><a href="subversion.html">Source Control</a></li>
<li><a href="/downloads/patches/recent.html">Recent Changes</a></li>
<!--li><a href="/downloads/patches/recent.html">Recent Changes</a></li-->
<li><a href="lists.html">Mailing Lists</a></li>
<li><a href="http://bugs.busybox.net/">Bug Tracking</a></li>
</ul>
@@ -79,12 +79,13 @@
<ul>
<li><a href="http://busybox.net/~landley">Rob</a></li>
<li><a href="http://busybox.net/~aldot">Bernhard</a></li>
<li><a href="http://busybox.net/~vda">Denis</a>
<br>-<a href=http://busybox.net/~vda/mboot/>mboot</a>
<br>-<a href=http://busybox.net/~vda/linld/>linld</a>
<br>-<a href=http://busybox.net/~vda/init_vs_runsv.html>init must die</a>
<br>-<a href=http://busybox.net/~vda/no_ifup.txt>no ifup</a>
<br>-<a href=http://busybox.net/~vda/unscd/>unscd</a>
<li><a href="http://busybox.net/~vda">Denys</a>
<br>- <a href=http://busybox.net/~vda/resume/denys_vlasenko.htm>resume</a>
<br>- <a href=http://busybox.net/~vda/mboot/>mboot</a>
<br>- <a href=http://busybox.net/~vda/linld/>linld</a>
<br>- <a href=http://busybox.net/~vda/init_vs_runsv.html>init must die</a>
<br>- <a href=http://busybox.net/~vda/no_ifup.txt>no ifup</a>
<br>- <a href=http://busybox.net/~vda/unscd/>unscd</a>
</li>
</ul>
+60 -801
View File
@@ -1,6 +1,63 @@
<!--#include file="header.html" -->
<ul>
<li><b>12 June 2008 -- Sponsors!</b>
<p>We want to thank the following companies which are providing support
for BusyBox project:
<ul>
<li>AOE media, a <a href=http://www.aoemedia.com/typo3-development.html>
TYPO3 development agency</a> contributes financially.
<p>
<li><a href=http://www.analog.com/en/>Analog Devices, Inc.</a> provided
a <a href=http://docs.blackfin.uclinux.org/doku.php?id=bf537_quick_start>
Blackfin development board</a> free of charge.
<a href=http://www.analog.com/blackfin>Blackfin<a>
is a NOMMU processor, and its availability for testing is invaluable.
If you are an embedded device developer,
please note that Analog Devices has entire Linux distribution available
for download for this board. Visit
<a href=http://blackfin.uclinux.org/>http://blackfin.uclinux.org/</a>
for more information.
</ul>
</p>
<li><b>5 June 2008 -- BusyBox 1.10.3 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.10.3.tar.bz2>BusyBox 1.10.3</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_10_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.10.3/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>
Bugfix-only release for 1.10.x branch. It contains fixes for dnsd, fuser, hush,
ip, mdev and syslogd.
<p>
<a href=http://busybox.net/~vda/HOWTO/i486-linux-uclibc/HOWTO.txt>
How to build static busybox for i486-linux-uclibc</a>
<p>
The email address gpl@busybox.net is the recommended way to contact
the Software Freedom Law Center to report BusyBox license violations.
</p>
<li><b>8 May 2008 -- BusyBox 1.10.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.10.2.tar.bz2>BusyBox 1.10.2</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_10_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.10.2/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>
Bugfix-only release for 1.10.x branch. It contains fixes for echo, httpd, pidof,
start-stop-daemon, tar, taskset, tab completion in shells, build system.
<p>Please note that mdev was backported from current svn trunk. Please
report if you encounter any problems with it.
</p>
<li><b>19 April 2008 -- BusyBox 1.10.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.10.1.tar.bz2>BusyBox 1.10.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_10_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.10.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>
Bugfix-only release for 1.10.x branch. It contains fixes for
fuser, init, less, nameif, tail, taskset, tcpudp, top, udhcp.
<li><b>21 March 2008 -- BusyBox 1.10.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.10.0.tar.bz2>BusyBox 1.10.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_10_stable/>svn</a>,
@@ -134,7 +191,7 @@ iproute_list_or_flush 3680 readhere 2308
<li>tail: fix "tail -c 20 /dev/huge_disk" (was taking ages)
<li>tar: compat: handle tarballs with only one zero block at the end
<li>tar: autodetection of gz/bz2 compressed tarballs. Closes bug 992
<li>tar: real support for -p. By Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>tar: real support for -p. By Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>tcpudp: narrow down time window where we have no wildcard socket
<li>telnetd: use login always, not "sometimes login, sometimes shell"
<li>test: fix mishandling of "test ! arg1 op arg2 more args"
@@ -152,11 +209,11 @@ iproute_list_or_flush 3680 readhere 2308
<li>unzip: handle short reads correctly
<li>vi: many fixes
<li>zcip: don't chdir to root
<li>zcip: open ARP socket before openlog (else we can thrash syslog socket)
<li>zcip: open ARP socket before openlog (else we can trash syslog socket)
</ul>
</p>
<li><b>21 March 2008 -- BusyBox stable releases</b>
<li><b>21 March 2008 -- BusyBox old stable releases</b>
<p>
Bugfix-only releases for four past branches. Links to locations
for future hot patches are in parentheses.
@@ -178,804 +235,6 @@ iproute_list_or_flush 3680 readhere 2308
the Software Freedom Law Center to report BusyBox license violations.
</p>
<li><b>12 February 2008 -- BusyBox 1.9.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.9.1.tar.bz2>BusyBox 1.9.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_9_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.9.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to fsck,
iproute, mdev, mkswap, msh, nameif, stty, test, zcip.</p>
<p>hush has `command` expansion re-enabled for NOMMU, although it is
inherently unsafe (by virtue of NOMMU's use of vfork instead of fork).
The plan is to make this less likely to bite people in future versions.</p>
</li>
<li><b>24 December 2007 -- BusyBox 1.9.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.9.0.tar.bz2>BusyBox 1.9.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_9_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.9.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Sizes of busybox-1.8.2 and busybox-1.9.0 (with almost full config, static uclibc build):<pre>
text data bss dec hex filename
792796 978 9724 803498 c42aa busybox-1.8.2
783803 683 7508 791994 c15ba busybox-1.9.0
</pre>
<p>Top 10 stack users:<pre>
busybox-1.8.2: busybox-1.9.0:
input_tab 10428 echo_dg 4116
umount_main 8252 bb_full_fd_action 4112
rtnl_talk 8240 discard_dg 4096
xrtnl_dump_filter 8240 echo_stream 4096
sendMTFValues 5316 discard_stream 4096
mainSort 4700 find_list_entry2 4096
mkfs_minix_main 4288 readlink_main 4096
grave 4260 ipaddr_list_or_flush 3900
unix_do_one 4156 iproute_list_or_flush 3680
parse_prompt 4132 insmod_main 3152
</pre>
<p>lash is deleted from this release. hush can be configured down to almost
the same size, but it is significantly less buggy. It even works
on NOMMU machines (interactive mode and backticks are not working on NOMMU,
though). "lash" applet is still available, but it runs hush.
<p>init has some changes in this release, please report if it causes
problems for you.
<p>Changes since previous release:
<ul>
<li>Build system improvements
<li>Testsuite additions
<li>Stack size reductions, code size reductions, data/bss reductions
<li>An option to prefer IPv4 address if host has both
<li>New applets: hd, sestatus
<li>Removed applets: lash
<li>hush: fixed a few bugs, wired up echo and test to be builtins
<li>init: simplify forking of children
<li>getty: special handling of '#' and '@' is removed
<li>[su]login: sanitize environment if called by non-root
<li>udhcpc: support "bad" servers which send oversized packets
(Cristian Ionescu-Idbohrn &lt;cristian.ionescu-idbohrn at axis.com&gt;)
<li>udhcpc: -O option allows to specify which options to ask for
(Stefan Hellermann &lt;stefan at the2masters.de&gt;)
<li>udhcpc: optionally check whether given IP is really free (by ARP ping)
(Jonas Danielsson &lt;jonas.danielsson at axis.com&gt;)
<li>vi: now handles files with unlimited line length
<li>vi: speedup for huge line lengths
<li>vi: Del key works
<li>sed: support GNUism '\t'
<li>cp/mv/install: optionally use bigger buffer for bulk copying
<li>line editing: don't eat stack like crazy
<li>passwd: follows symlinked /etc/passwd
<li>renice: accepts priority with +N too
<li>netstat: wide output mode
<li>nameif: extended matching (Nico Erfurth &lt;masta at perlgolf.de&gt;)
<li>test: become NOFORK applet
<li>find: -iname (Alexander Griesser &lt;alexander.griesser at lkh-vil.or.at&gt;)
<li>df: -i option (show inode info) (Pascal Bellard &lt;pascal.bellard at ads-lu.com&gt;)
<li>hexdump: -R option (Pascal Bellard &lt;pascal.bellard at ads-lu.com&gt;)
</ul>
</p>
<li><b>23 November 2007 -- BusyBox 1.8.2 (stable), BusyBox 1.7.4 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.8.2.tar.bz2>BusyBox 1.8.2</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.8.2/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p><a href=http://busybox.net/downloads/busybox-1.7.4.tar.bz2>BusyBox 1.7.4</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.4/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>These are bugfix-only releases.
1.8.2 contains fixes for inetd, lash, tar, tr, and build system.
1.7.4 contains a fix for inetd.</p>
</li>
<li><b>9 November 2007 -- BusyBox 1.8.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.8.1.tar.bz2>BusyBox 1.8.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.8.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to login (PAM), modprobe, syslogd, telnetd, unzip.</p>
</li>
<li><b>4 November 2007 -- BusyBox 1.8.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.8.0.tar.bz2>BusyBox 1.8.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.8.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Note: this is probably the very last release with lash. It will be dropped. Please migrate to hush.
<p>Applets which had many changes since 1.7.x:
<p>httpd:
<ul>
<li>does not clear environment, CGIs will see all environment variables which were set for httpd
<li>fix bug where we were trying to read more POSTDATA than content-length
<li>fix trivial bug (spotted by Alex Landau)
<li>optional support for partial downloads
<li>simplified CGI i/o loop (now it looks good to me)
<li>small auth and IPv6 fixes (Kim B. Heino &lt;Kim.Heino at bluegiga.com>)
<li>support for proxying connection to other http server (by Alex Landau &lt;landau_alex at yahoo.com>)
</ul>
<p>top:
<ul>
<li>TOPMEM feature - 's(how sizes)' command
<li>don't wait before final bailout (try top -b -n1)
<li>fix for command line wrapping
</ul>
<p>Build system improvements: libbusybox mode restored (it was lost in transition to new makefiles).
<p>Code and data size in comparison with 1.7.3:<pre>
Equivalent .config, i386 uclibc static builds:
text data bss dec hex filename
768123 1055 10768 779946 be6aa busybox-1.7.3/busybox
759693 974 9420 770087 bc027 busybox-1.8.0/busybox</pre>
<p>New applets:
<ul>
<li>microcom: new applet by Vladimir Dronnikov &lt;dronnikov at gmail.ru&gt;
<li>kbd_mode: new applet by Loic Grenie &lt;loic.grenie at gmail.com&gt;
<li>bzip2: port bzip2 1.0.4 to busybox, 9 kb of code
<li>pgrep, pkill: new applets by Loic Grenie &lt;loic.grenie at gmail.com&gt;
<li>setsebool: new applet (Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
</ul>
<p>Other changes since previous release (abridged):
<ul>
<li>cp: -r and -R imply -d (coreutils compat)
<li>cp: detect and prevent infinite recursion
<li>cp: make it a bit closer to POSIX, but still refuse to open and overwrite symbolic link
<li>hdparm: reduce possibility of numeric overflow in -T
<li>hdparm: simplify timing measurement
<li>wget: -O FILE is allowed to overwrite existing file (compat)
<li>wget: allow dots in header field names
<li>telnetd: add -K option to close sessions as soon as child exits
<li>telnetd: don't SIGKILL child when closing the session, kernel will send SIGHUP for us
<li>ed: large cleanup, add line editing
<li>hush: feeble attempt at making it more NOMMU-friendly
<li>hush: fix glob()
<li>hush: stop doing manual accounting of open fd's, kernel can do it for us
<li>adduser: implement -S and fix uid selection
<li>ash: fix prompt expansion (Natanael Copa &lt;natanael.copa at gmail.com&gt;)
<li>ash: revert "cat | jobs" fix, it causes more problems than good
<li>find: fix -xdev behavior in the presence of two or more nested mount points
<li>grep: fix grep -F -e str1 -e str2 (was matching str2 only)
<li>grep: optimization: stop on first -e match
<li>gunzip: support concatenated gz files
<li>inetd: fix bug 1562 "inetd does not set argv[0] properly" (fix by Ilya Panfilov)
<li>install: 'support' (by ignoring) -v and -b
<li>install: fix bug in "install -c file dir" (tried to copy dir into dir too)
<li>ip: tunnel parameter parsing fix by Jean Wolter &lt;jw5 at os.inf.tu-dresden.de&gt;
<li>isrv: use monotonic_sec
<li>less: make 'f' key page forward
<li>libiproute: add missing break statements
<li>load_policy: update (Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
<li>logger: fix a problem of losing all argv except first
<li>login: do reject wrong passwords with PAM auth
<li>losetup: support -f (Loic Grenie &lt;loic.grenie at gmail.com&gt;)
<li>fdisk: make fdisk compile on libc without llseek64
<li>libbb: by popular request allow PATH to be customized at build time
<li>mkswap: selinux support by KaiGai Kohei &lt;kaigai at ak.jp.nec.com&gt;
<li>mount: allow (and ignore) -i
<li>mount: ignore NFS bg option on NOMMU machines
<li>mount: mount helpers support (by Vladimir Dronnikov &lt;dronnikov at gmail.ru&gt;)
<li>passwd: handle Ctrl-C, restore termios on Ctrl-C
<li>passwd: SELinux support by KaiGai Kohei &lt;kaigai at ak.jp.nec.com&gt;
<li>ping: make -I ethN work too (-I addr already worked)
<li>ps: fix RSS parsing (rss field in /proc/PID/stat is in pages, not bytes)
<li>read_line_input: fix it to not do any fancy editing if echoing is disabled
<li>run_parts: make it sort executables by name (required by API)
<li>runsv: do not use clock_gettime if !MONOTONIC_CLOCK
<li>runsvdir: fix "linear wait time" bug
<li>sulogin: remove alarm handling, it is redundant there
<li>svlogd: compat: svlogd -tt should timestamp stderr too
<li>syslogd: bail out if you see null read from Unix socket
<li>syslogd: do not need to poll(), we can just block in read()
<li>tail: work correctly on /proc files (Kazuo TAKADA &lt;kztakada at sm.sony.co.jp&gt;)
<li>tar + gzip/bzip2/etc: support NOMMU machines (by Alex Landau &lt;landau_alex at yahoo.com&gt;)
<li>tar: strip leading '/' BEFORE memorizing hardlink's name
<li>tftp: fix infinite retry bug
<li>umount: support (by ignoring) -i; style fixes
<li>unzip: fix endianness bugs
<li>vi: don't wait 50 ms before reading ESC sequences
<li>watchdog: allow millisecond spec (-t 250ms)
<li>zcip: fix unaligned trap on ARM
</ul>
</p>
</li>
<li><b>4 November 2007 -- BusyBox 1.7.3 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.3.tar.bz2>BusyBox 1.7.3</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.3/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to ash, httpd, inetd, iptun, logger, login, tail.</p>
</li>
<li><b>30 September 2007 -- BusyBox 1.7.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.2.tar.bz2>BusyBox 1.7.2</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.2/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to install, find, login, httpd, runsvdir, chcon, setfiles, fdisk and line editing.</p>
</li>
<li><b>16 September 2007 -- BusyBox 1.7.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.1.tar.bz2>BusyBox 1.7.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to cp, runsv, tar, busybox --install and build system.</p>
</li>
<li><b>24 August 2007 -- BusyBox 1.7.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.0.tar.bz2>BusyBox 1.7.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Applets which had many changes since 1.6.x:
<p>httpd:
<ul>
<li>works in standalone mode on NOMMU machines now (partly by Alex Landau &lt;landau_alex at yahoo.com&gt;)
<li>indexer example is rewritten in C
<li>optional support for error pages (by Pierre Metras &lt;genepi at sympatico.ca&gt;)
<li>stop reading headers using 1-byte reads
<li>new option -v[v]: prints client addresses, HTTP codes returned, URLs
<li>extended -p PORT to -p [IP[v6]:]PORT
<li>sendfile support (by Pierre Metras &lt;genepi at sympatico.ca&gt;)
<li>add support for Status: CGI header
<li>fix CGI handling bug (we were closing wrong fd)
<li>CGI I/O loop still doesn't look 100% ok to me...
</ul>
<p>udhcp[cd]:
<ul>
<li>add -f "foreground" and -S "syslog" options
<li>fixed "ifupdown + udhcpc_without_pidfile_creation" bug
<li>new config option "Rewrite the lease file at every new acknowledge" (Mats Erik Andersson &lt;mats at blue2net.com&gt; (Blue2Net AB))
<li>consistently treat server_config.start/end IPs as host-order
<li>fix IP parsing for 64bit machines
<li>fix unsafe hton macro usage in read_opt()
<li>do not chdir to / when daemonizing
</ul>
<p>top, ps, killall, pidof:
<ul>
<li>simpler loadavg processing
<li>truncate usernames to 8 chars
<li>fix non-CONFIG_DESKTOP ps -ww (by rockeychu)
<li>improve /proc/PID/cmdinfo reading code
<li>use cmdline, not comm field (fixes problems with re-execed applets showing as processes with name "exe", and not being found by pidof/killall by applet name)
<li>reduce CPU usage in decimal conversion (optional) (corresponding speedup on kernel side is accepted in mainline Linux kernel, yay!)
<li>make percentile (0.1%) calculations configurable
<li>add config option and code for global CPU% display
<li>reorder columns, so that [P]PIDs are together and VSZ/%MEM are together - makes more sense
</ul>
<p>Build system improvements: doesn't link against libraries we don't need,
generates verbose link output and map file, allows for custom link
scripts (useful for removing extra padding, among other things).
<p>Code and data size in comparison with 1.6.1:<pre>
Equivalent .config, i386 glibc dynamic builds:
text data bss dec hex filename
672671 2768 16808 692247 a9017 busybox-1.6.1/busybox
662948 2660 13528 679136 a5ce0 busybox-1.7.0/busybox
662783 2631 13416 678830 a5bae busybox-1.7.0/busybox.customld
Same .config built against static uclibc:
765021 1059 11020 777100 bdb8c busybox-1.7.0/busybox_uc</pre>
<p>Code/data shrink done in applets: crond, hdparm, dd, cal, od, nc, expr, uuencode,
test, slattach, diff, ping, tr, syslogd, hwclock, zcip, find, pidof, ash, uudecode,
runit/*, in libbb.
<p>New applets:
<ul>
<li>pscan, expand, unexpand (from Tito &lt;farmatito at tiscali.it&gt;)
<li>setfiles, restorecon (by Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
<li>chpasswd (by Alexander Shishkin &lt;virtuoso at slind.org&gt;)
<li>slattach, ttysize
</ul>
<p>Unfortunately, not much work is done on shells. This was mostly stalled
by lack of time (read: laziness) on my part to learn how to adapt existing
qemu-runnable image for a NOMMU architechture (available on qemu website)
for local testing of cross-compiled busybox on my machine.
<p>Other changes since previous release (abridged):
<ul>
<li>addgroup: disallow addgroup -g num user group; make -g 0 work (Tito &lt;farmatito at tiscali.it&gt;)
<li>adduser: close /etc/{passwd,shadow} before calling passwd etc. Spotted by Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>arping: -i should be -I, fixed
<li>ash: make "jobs | cat" work like in bash (was giving empty output)
<li>ash: recognize -l as --login equivalent; do not recognize +-login
<li>ash: fix buglet in DEBUG code (Nguyen Thai Ngoc Duy &lt;pclouds at gmail.com&gt;)
<li>ash: fix SEGV if type has zero parameters
<li>awk: fix -F 'regex' bug (miscounted fields if last field is empty)
<li>catv: catv without arguments was trying to use environ as argv (Alex Landau &lt;landau_alex at yahoo.com&gt;)
<li>catv: don't die on open error (emit warning)
<li>chown/chgrp: completely match coreutils 6.8 wrt symlink handling
<li>correct_password: do not print "no shadow passwd..." message
<li>crond: don't start sendmail with absolute path, don't report obsolete version (report true bbox version)
<li>dd: fix bug where we assume count=INT_MAX when count is unspecified
<li>devfsd: sanitization by Tito &lt;farmatito at tiscali.it&gt;
<li>echo: fix non-fancy echo
<li>fdisk: make it work with big disks (read: typical today's disks) even if CONFIG_LFS is unset
<li>find: -context support for SELinux (KaiGai Kohei &lt;kaigai at kaigai.gr.jp&gt;)
<li>find: add conditional support for -maxdepth and -regex, make -size match GNU find
<li>find: fix build failure on certain configs (found by Cristian Ionescu-Idbohrn &lt;cristian.ionescu-idbohrn at axis.com&gt;)
<li>fsck_minix: make it print bb version, not it's own (outdated/irrelevant) one
<li>grep: implement -m MAX_MATCHES, fix buglets with context printing
<li>grep: fix selection done by FEATURE_GREP_EGREP_ALIAS (Maxime Bizon &lt;mbizon at freebox.fr&gt; (Freebox))
<li>hush: add missing dependencies (Maxime Bizon &lt;mbizon at freebox.fr&gt; (Freebox))
<li>hush: fix read builtin to not read ahead past EOL and to not use insane amounts of stack
<li>ifconfig: make it work with ifaces with interface no. &gt; 255
<li>ifup/ifdown: make location of ifstate configurable
<li>ifupdown: make netmask parsing smaller and more strict (was accepting 255.0.255.0, 255.1234.0.0 etc...)
<li>install: fix -s (strip) option, fix install a b /a/link/to/dir
<li>libbb: consolidate ARRAY_SIZE macro (Walter Harms &lt;wharms at bfs.de&gt;)
<li>libbb: make /etc/network parsing configurable. -200 bytes when off
<li>libbb: nuke BB_GETOPT_ERROR, always die if there are mutually exclusive options
<li>libbb: xioctl and friends by Tito &lt;farmatito at tiscali.it&gt;
<li>login: optional support for PAM
<li>login: make /etc/nologin support configurable (-240 bytes)
<li>login: ask passwords even for wrong usernames
<li>md5_sha1_sum: fix mishandling when run as /bin/md5sum
<li>mdev: add support for firmware loading
<li>mdev: work even when CONFIG_SYSFS_DEPRECATED in kernel is off
<li>modprobe: add scanning of /lib/modules/`uname -r`/modules.symbols (by Yann E. MORIN &lt;yann.morin.1998 at anciens.enib.fr&gt;)
<li>more: fixes by Tristan Schmelcher &lt;tpkschme at engmail.uwaterloo.ca&gt;
<li>nc: make connecting to IPv4 from IPv6-enabled hosts easier (was requiring -s local_addr)
<li>passwd: fix bug "updating shadow even if user's record is in passwd"
<li>patch: fix -p -1 handling
<li>patch: fix bad line ending handling (Nguyen Thai Ngoc Duy &lt;pclouds at gmail.com&gt;)
<li>ping: display roundtrip times with 1/1000th of ms, not 1/10 ms precision.
<li>ping: fix incorrect handling of -I (Iouri Kharon &lt;bc-info at styx.cabel.net&gt;)
<li>ping: fix non-fancy ping6
<li>printenv: fix "printenv VAR1 VAR2" bug (spotted by Kalyanatejaswi Balabhadrapatruni &lt;kalyanatejaswi at yahoo.co.in&gt;)
<li>ps: fix -Z (by Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
<li>rpm: add optional support for bz2 data. +50 bytes of code
<li>rpm: fix bogus "package is not installed" case
<li>sed: fix 'q' command handling (by Nguyen Thai Ngoc Duy &lt;pclouds at gmail.com&gt;)
<li>start_stop_daemon: NOMMU fixes by Alex Landau &lt;landau_alex at yahoo.com&gt;
<li>stat: fix option -Z SEGV
<li>strings: strings a b was processing a twice, fix that
<li>svlogd: fix timestamping, do not warn if config is missing
<li>syslogd, logread: get rid of head pointer, fix logread bug in the process
<li>syslogd: do not convert tabs to ^I, set syslog IPC buffer to mode 0644
<li>tar: improve OLDGNU compat, make old SUN compat configurable
<li>test: fix testing primary expressions like '"-u" = "-u"'
<li>uudecode: fix to base64 decode by Jorgen Cederlof &lt;jcz at google.com&gt;
<li>vi: multiple fixes by Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>wget: fix bug in base64 encoding (bug 1404). +10 bytes
<li>wget: lift 256 chars limitation on terminal width
<li>wget, zcip: use monotonic_sec instead of gettimeofday
</ul>
</p>
</li>
<li><b>30 June 2007 -- BusyBox 1.6.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.6.1.tar.bz2>BusyBox 1.6.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_6_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.6.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to echo, hush, and wget.</p>
</li>
<li><b>1 June 2007 -- BusyBox 1.6.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.6.0.tar.bz2>BusyBox 1.6.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_6_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.6.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Since this is a x.x.0 release, it probably does not deserve "stable"
label. Please help making 1.6.1 stable by testing 1.6.0.</p>
<p>Note that hush shell had many changes and (hopefully) is much improved now,
but there is a possibility that it regressed in some obscure cases. Please
report any such cases.</p>
<p>lash users please note: lash is going to be deprecated in busybox 1.7.0
and removed in the more distant future. Please migrate to hush.</p>
<p><a href=http://busybox.net/~vda/mem_usage-1.6.0.txt>Memory usage has decreased, but we can do better still</a></p>
<p>Other changes since previous release:
<ul>
<li>NOFORK: audit small applets and mark some of them as NOFORK. Put big scary warnings in relevant places
<li>NOFORK: factor out NOFORK/NOEXEC code from find. Use NOFORK/NOEXEC in find and xargs
<li>NOFORK: remove potential xmalloc from NOFORK path in bb_full_fd_action
<li>NOMMU: random fixes; compressed --help now works for NOMMU
<li>SELinux: load_policy applet
<li>[u]mount: extend -t option (Roy Marples &lt;uberlord at gentoo.org&gt;)
<li>addgroup: clean up, fix adding users to existing groups and make it optional (Tito)
<li>adduser: don't bomb out if shadow password file doesn't exist (from Tito &lt;farmatito at tiscali.it&gt;)
<li>applet.c: do not even try to read config if run by real root; fix suid config handling
<li>ash: fix infinite loop on exit if tty is not there anymore
<li>ash: fix kill -l (by Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>ash: implement type -p, costs less than 10 bytes (patch by Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>awk: don't segfault on printf(%*s). Closes bug 1337
<li>awk: guard against empty environment
<li>awk: some 'lineno' vars were shorts, made them ints (code got smaller)
<li>cat: stop using stdio.h opens
<li>config system: clarify PREFER_APPLETS/SH_STANDALONE effects in help text
<li>cryptpw: new applet (by Thomas Lundquist &lt;lists at zelow.no&gt;)
<li>cttyhack: new applet
<li>dd: NOEXEC fix; fix skip= parse error (spotted by Dirk Clemens &lt;develop at cle-mens.de&gt;)
<li>deluser: add optional support for removing users from groups (by Tito &lt;farmatito at tiscali.it&gt;)
<li>diff: fix SEGV (NULL deref) in diff -N
<li>diff: fix segfault on empty dirs (Peter Korsgaard &lt;peter.korsgaard at barco.com&gt;)
<li>dnsd: fix several buglets, make smaller; openlog(), so that applet's name is logged
<li>dpkg: run_package_script() returns 0 if all ok and non-zero if failure. The result code was checked incorrectly in two places. (from Kim B. Heino &lt;Kim.Heino at bluegiga.com&gt;)
<li>dpkg: use bitfields which are a bit closer to typical short/char. Code size -800 bytes
<li>dumpleases: getopt32()-ization (from Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>e2fsprogs: stop using statics in chattr. Minor code shrinkage (-130 bytes)
<li>ether-wake: close bug 1317. Reorder fuctions to avoid forward refs while at it
<li>ether-wake: save a few more bytes of code
<li>find: -group, -depth (Natanael Copa &lt;natanael.copa at gmail.com&gt;)
<li>find: add support for -delete, -path (by Natanael Copa)
<li>find: fix -prune. Add big comment about it
<li>find: improve usage text (Natanael Copa &lt;natanael.copa at gmail.com&gt;)
<li>find: missed 'static' on const data; size and prune were mixed up; use index_in_str_array
<li>find: un-DESKTOPize (Kai Schwenzfeier &lt;niteblade at gmx.net&gt;)
<li>find_root_device: teach to deal with /dev/ subdirs (by Kirill K. Smirnov &lt;lich at math.spbu.ru&gt;)
<li>find_root_device: use lstat - don't follow links
<li>getopt32: fix llist_t options ordering. llist_rev is now unused
<li>getopt: use getopt32 for option parsing - inspired by patch by Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;
<li>hdparm: fix multisector mode setting (from Toni Mirabete &lt;amirabete at catix.cat&gt;)
<li>hdparm: make -T -t code smaller (-194 bytes), and output prettier
<li>ifupdown: make it possible to use DHCP clients different from udhcp
<li>ifupdown: reread state file before rewriting it. Fixes "ifup started another ifup" state corruption bug. Patch by Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>ifupdown: small optimization (avoid doing useless work if we are not going to update state file)
<li>ip: fix compilation if FEATURE_TR_CLASSES is off
<li>ip: mv ip*_main into ip.c; use a dispatcher to save on needless duplication. Saves a minor 12b
<li>ip: rewrite the ip applet to be less bloaty. Convert to index_in_(sub)str_array()
<li>ip: set the scope properly. Thanks to Jean Wolter
<li>iplink: shrink iplink; sanitize libiproute a bit (-916 bytes)
<li>iproute: shrink a bit (-200 bytes)
<li>kill: know much more signals; make code smaller; use common code for kill applet and ash kill builtin
<li>klogd: remove dependency on syslogd
<li>lash: "forking" applets are actually can be treated the same way as "non-forked". Also save a bit of space on trailing NULL array elements.
<li>lash: fix kill buglet (didn't properly recognize ESRCH)
<li>lash: make -c work; crush buffer overrun and free of non-malloced ptr (from Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>lash: recognize and use NOFORK applets
<li>less: fix case when regex search finds nothing; fix very obscure memory corruption bug; fix less &lt;HUGEFILE + [End] busy loop
<li>libbb: add xsendto, xunlink, xpipe
<li>libbb: fix segfault in reset_ino_dev_hashtable() when *hashtable was NULL
<li>libbb: make pidfile writing configurable
<li>libbb: make xsocket die with address family printed (if VERBOSE_RESOLUTION_ERRORS=y)
<li>libbb: rework NOMMU helper API so that it makes more sense and easier to use
<li>libiproute: audit callgraph, shortcut error paths into die() functions
<li>lineedit: do not try to open NULL history file
<li>lineedit: nuke two unused variables and code which sets them
<li>login: remove setpgrp call (makes it work from shell prompt again); sanitize stdio descriptors (we are suid, need to be careful!)
<li>login: shrink login and set_environment by ~100 bytes
<li>mount: fix incorrect usage of strtok (inadvertently used NULL sometimes)
<li>mount: fix mounting of symlinks (mount from util-linux allows that)
<li>msh: data/bss reduction (more than 9k of it); fix "underscore bug" (a_b=1111 didn't work); fix obscure case with backticks and closed fd 1
<li>nc: port nc 1.10 to busybox
<li>netstat: fix for bogus state value for raw sockets
<li>netstat: introduce -W: wide, ipv6-friendly output; shrink by ~500 bytes
<li>nmeter: should die if stdout doesn't like him anymore
<li>patch: do not try to delete same file twice
<li>ping: fix wrong sign extension of packet id (bug 1373)
<li>ps: add -o tty and -o rss support; make a bit smaller; work around libc bug: printf("%.*s\n", MAX_INT, buffer)
<li>run_parts: rewrite
<li>run_parts: do not check path portion of a name for "bad chars". Needed for ifupdown. Patch by Gabriel L. Somlo &lt;somlo at cmu.edu&gt;
<li>sed: fix escaped newlines in -f
<li>split: new applet
<li>stat: remove superfluous bss user (flags) and manually unswitch some areas
<li>stty: fix option parsing bug (spotted by Sascha Hauer &lt;s.hauer at pengutronix.de&gt;)
<li>svlogd: fix 'SEGV on uninitialized data' and make it honor TERM
<li>tail: fix SEGV on "tail -N"
<li>ipsvd: tcpsvd,udpsvd are new applets, GPL-ed 'clones' of Dan Bernstein's tcpserver. Author: Gerrit Pape &lt;pape at smarden.org&gt;, http://smarden.sunsite.dk/ipsvd/
<li>test: close bug 1371; plug a memory leak; code size reduction
<li>tftp: code diet, and I think retransmits were broken
<li>tr: fix bug where we did not reject invalid classes like '[[:alpha'. debloat while at it
<li>udhcp: MAC_BCAST_ADDR and blank_chaddr are in fact constant, move to rodata; use pipe instead of socketpair
<li>udhcp[cd]: stop using atexit magic fir pidfile removal; stop deleting our own pidfile if we daemonize
<li>xargs: shrink code, ~80 bytes; simplify word list management
<li>zcip: make it work on NOMMU (+ improve NOMMU support machinery)
</ul>
</p>
</li>
<li><b>20 May 2007 -- BusyBox 1.5.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.5.1.tar.bz2>BusyBox 1.5.1</a>.
(<a href=http://busybox.net/downloads/fixes-1.5.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to hdparm, hush, ifupdown, ps
and sed.</p>
</li>
<li><b>23 March 2007 -- BusyBox 1.5.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.5.0.tar.bz2>BusyBox 1.5.0</a>.
(<a href=http://busybox.net/downloads/fixes-1.5.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Since this is a x.x.0 release, it probably does not deserve "stable"
label. Please help making 1.5.1 stable by testing 1.5.0.</p>
<p>Notable changes since previous release:
<ul>
<li>find: added support for -user, -not, fixed -mtime, -mmin, -perm
<li>[de]archivers: merge common logic into one module
<li>ping[6]: unified code for both
<li>less: regex search improved
<li>ash: more readable code, testsuite added
<li>sed: several very obscure bugs fixed
<li>chown: -H, -L, -P support (required by POSIX)
<li>tar: handle (broken) checksums a-la Sun; tar restores mode again
<li>grep: implement -w, "implement" -a and -I by ignoring them
<li>cp: more sane behavior when overwriting existing files
<li>init: stop doing silly things with the console (-400 bytes)
<li>httpd: make httpd usable for NOMMU CPUs; fix POSTDATA handling bugs
<li>httpd: run interpreter for configured file extensions in any dir,
not only in /cgi-bin/
<li>chrt: new applet
<li>SELinux: SELinux-related code and -Z option added to several applets,
new SELinux-specific applets: chcon, runcon.
<li>Build system: produces link map, uses -Wwrite-strings to catch
improper usage of string constants.
<li>Data and bss section usage audited and reduced - should help NOMMU
targets.
<li>Applets with bug fixes: gunzip, vi, syslogd, dpkg, ls, adjtimex, resize,
sv, printf, diff, awk, sort, dpkg, diff, tftp
<li>Applets with usability improvements: swapon, more, ifup/ifdown, hwclock,
udhcpd, start_stop_daemon, cmp
<li>Applets with code cleaned up: telnet, fdisk, fsck_minix, mkfs_minix,
syslogd, swapon, runsv, svlogd, klogd
</ul>
</p>
</li>
<li><b>18 March 2007 -- BusyBox 1.4.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.4.2.tar.bz2>BusyBox 1.4.2</a>.
</p>
<p>This release includes only trivial fixes accumulated since 1.4.1.
</p>
</li>
<li><b>25 January 2007 -- BusyBox 1.4.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.4.1.tar.bz2>BusyBox 1.4.1</a>.
(<a href=http://busybox.net/downloads/fixes-1.4.1/>patches</a>)</p>
<p>This release includes only trivial fixes accumulated since 1.4.0.
</p>
</li>
<li><b>20 January 2007 -- BusyBox 1.4.0 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.4.0.tar.bz2>BusyBox 1.4.0</a>.
(<a href=http://busybox.net/downloads/fixes-1.4.0/>patches</a>)</p>
<p>Since this is a x.x.0 release, it probably is a bit less "stable"
than usual.</p>
<p>Changes since previous release:
<ul>
<li>e2fsprogs are mostly removed from busybox. Some smaller parts remain,
the rest of it sits disabled in e2fsprogs/old_e2fsprogs/*, because
it's too bloated. Really. I'm afraid it's about the only way we can
ever get e2fsprogs cleaned up.
<li>less: many improvements. Now can display binary files
(although I expect it to have trouble with displays where 8bit chars
don't have 1-to-1 char/glyph relationship). Regexp search is not buggy
anymore. Less does not read entire input up-front. Reads input
as it appears (yay!). Works rather nice as man pager. I recommend it
for general use now.
<li>IPv6: generic support is in place, many networking applets are
upgraded to be IPv6 capable. Probably some work remains, but it is
already much better than what we had previously.
<li>arp: new applet (thanks to Eric Spakman).
<li>fakeidentd: non-forking standalone server part was taking ~90%
of the applet. Factored it out (in fact, rewrote it).
<li>syslogd: mostly rewritten.
<li>decompress_unzip, gzip: sanitized a bit.
<li>sed: better hadling of NULs
<li>httpd: stop adding our own "Content-type:" to CGI output
<li>chown: user.grp works again.
<li>minor bugfixes to: passwd, date, tftp, start_stop_daemon, tar,
ps, ifupdown, time, su, stty, awk, ping[6], sort,...
</ul>
</p>
</li>
<li><b>20 January 2007 -- BusyBox 1.3.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.3.2.tar.bz2>BusyBox 1.3.2</a>.</p>
<p>This release includes only one trivial fix accumulated since 1.3.1
</p>
</li>
<li><b>27 December 2006 -- BusyBox 1.3.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.3.1.tar.bz2>BusyBox 1.3.1</a>.
(<a href=http://busybox.net/downloads/fixes-1.3.1/>patches</a>)</p>
<p>Closing 2006 with new release. It includes only trivial fixes accumulated since 1.3.0
</p>
</li>
<li><b>14 December 2006 -- BusyBox 1.3.0 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.3.0.tar.bz2>BusyBox 1.3.0</a>.
(<a href=http://busybox.net/downloads/fixes-1.3.0/>patches</a>)</p>
<p>This release has CONFIG_DESKTOP option which enables features
needed for busybox usage on desktop machine. For example, find, chmod
and chown get several less frequently used options, od is significantly
bigger but matches GNU coreutils, etc. Intended to eventually make
busybox a viable alternative for "standard" utilities for slightly
adventurous desktop users.
<p>Changes since previous release:
<ul>
<li>find: taking many more of standard options
<li>ps: POSIX-compliant -o implemented
<li>cp: added -s, -l
<li>grep: added -r, fixed -h
<li>watch: make it exec child like standard one does (was totally
incompatible)
<li>tar: fix limitations which were preventing bbox tar usage
on big directories: long names and linknames, pax headers
(Linux kernel tarballs have that). Fixed a number of obscure bugs.
Raised max file limit (now 64Gb). Security fixes (/../ attacks).
<li>httpd: added -i (inetd), -f (foreground), support for
directory indexer CGI (example is included), bugfixes.
<li>telnetd: fixed/improved IPv6 support, inetd+standalone support,
other fixes. Useful IPv6 stuff factored out into libbb.
<li>runit/*: new applets adapted from http://smarden.sunsite.dk/runit/
(these are my personal favorite small-and-beautiful toys)
<li>minor bugfixes to: login, dd, mount, umount, chmod, chown, ln, udhcp,
fdisk, ifconfig, sort, tee, mkswap, wget, insmod.
</ul>
<p>Note that GnuPG key used to sign this release is different.
1.2.2.1 is also signed post-factum now. Sorry for the mess.
</p>
</li>
<li><b>29 October 2006 -- BusyBox 1.2.2.1 (fix)</b>
<p><a href=http://busybox.net/downloads/busybox-1.2.2.1.tar.bz2>BusyBox 1.2.2.1</a>.</p>
<p>Added compile-time warning that static linking against glibc
produces buggy executables.
</li>
<li><b>24 October 2006 -- BusyBox 1.2.2 (stable)</b>
<p>It's a bit overdue, but
<a href=http://busybox.net/downloads/busybox-1.2.2.tar.bz2>here is
BusyBox 1.2.2</a>.</p>
<p>This release has dozens of fixes backported from the ongoing development
branch. There are a couple of bugfixes to sed, two fixes to documentation
generation (BusyBox.html shouldn't have USE() macros in it anymore), fix
umount to report the right errno on failure and to umount block devices by
name with newer kernels, fix mount to handle symlinks properly, make mdev
delete device nodes when called for hotplug remove, fix a segfault
in traceroute, a minor portability fix to md5sum option parsing, a build
fix for httpd with old gccs, an options parsing tweak to hdparm, make test
fail gracefully when getgroups() returns -1, fix a race condition in
modprobe when two instances run at once (hotplug does this), make "tar xf
foo.tar dir/dir" extract all subdirectories, make our getty initialize the
terminal more like mingetty, an selinux build fix, an endianness fix in
ping6, fix for zcip defending addresses, clean up some global variables in
gzip to save memory, fix sulogin -tNNN, a help text tweak, several warning
fixes and build fixes, fixup dnsd a bit, and a partridge in a pear tree.</p>
<p>As <a href=http://lwn.net/Articles/202106/>Linux Weekly News noted</a>,
this is my (Rob's) last release of BusyBox. The new maintainer is Denis
Vlasenko, I'm off to do <a href=http://landley.net/code>other things</a>.
</p>
</li>
<li><b>29 September 2006 -- New license email address.</b>
<p>The email address gpl@busybox.net is now the recommended way to contact
the Software Freedom Law Center to report BusyBox license violations.</p>
<li><b>31 July 2006 -- BusyBox 1.2.1 (stable)</b>
<p>Since nobody seems to have objected too loudly over the weekend, I
might as well point you all at
<a href="http://busybox.net/downloads/busybox-1.2.1.tar.bz2">Busybox
1.2.1</a>, a bugfix-only release with no new features.</p>
<p>It has three shell fixes (two to lash: going "var=value" without
saying "export" should now work, plus a missing null pointer check, and
one to ash when redirecting output to a file that fills up.) Fix three
embarassing thinkos in the new dmesg command. Two build tweaks
(dependencies for the compressed usage messages and running make in the
libbb subdirectory). One fix to tar so it can extract git-generated
tarballs (rather than barfing on the pax extensions). And a partridge
in a pear... Ahem.</p>
<p>But wait, there's more! A passwd changing fix so an empty
gecos field doesn't trigger a false objection that the new passwd contains
the gecos field. Make all our setuid() and setgid() calls check the return
value in case somebody's using per-process resource limits that prevent
a user from having too many processes (and thus prevent a process from
switching away from root, in which case the process will now _die_ rather
than continue with root privileges). A fix to adduser to make sure that
/etc/group gets updated. And a fix to modprobe to look for modules.conf
in the right place on 2.6 kernels.</p>
<li><b>30 June 2006 -- BusyBox 1.2.0</b>
<p>The -devel branch has been stabilized and the result is
<a href="http://busybox.net/downloads/busybox-1.2.0.tar.bz2">Busybox
1.2.0</a>. Lots of stuff changed, I need to work up a decent changelog
over the weekend.</p>
<p>I'm still experimenting with how long is best for the development
cycle, and since we've got some largeish projects queued up I'm going to
try a longer one. Expect 1.3.0 in December. (Expect 1.2.1 any time
we fix enough bugs. :)</p>
<p>Update: Here are <a href="http://busybox.net/downloads/busybox-1.2.0.fixes.patch">the first few bug fixes</a> that will go into 1.2.1.</p>
<li><b>17 May 2006 -- BusyBox 1.1.3 (stable)</b>
<p><a href="http://busybox.net/downloads/busybox-1.1.3.tar.bz2">BusyBox
1.1.3</a> is another bugfix release. It makes passwd use salt, fixes a
memory freeing bug in ls, fixes "build all sources at once" mode, makes
mount -a not abort on the first failure, fixes msh so ctrl-c doesn't kill
background processes, makes patch work with patch hunks that don't have a
timestamp, make less's text search a lot more robust (the old one could
segfault), and fixes readlink -f when built against uClibc.</p>
<p>Expect 1.2.0 sometime next month, which won't be a bugfix release.</p>
<li><b>10 April 2006 -- BusyBox 1.1.2 (stable)</b>
<p>You can now download <a href="http://busybox.net/downloads/busybox-1.1.2.tar.bz2">BusyBox 1.1.2</a>, a bug fix release consisting of 11 patches
backported from the development branch: Some build fixes, several fixes
for mount and nfsmount, a fix for insmod on big endian systems, a fix for
find -xdev, and a fix for comm. Check the file "changelog" in the tarball
for more info.</p>
<p>The next new development release (1.2.0) is slated for June. A 1.1.3
will be released before then if more bug fixes crop up. (The new plan is
to have a 1.x.0 new development release every 3 months, with 1.x.y stable
bugfix only releases based on that as appropriate.)</p>
<li><b>27 March 2006 -- Software Freedom Law Center representing BusyBox and uClibc</b>
<p>One issue Erik Andersen wanted to resolve when handing off BusyBox
maintainership to Rob Landley was license enforcement. BusyBox and
uClibc's existing license enforcement efforts (pro-bono representation
by Erik's father's law firm, and the
<a href="http://www.busybox.net/shame.html">Hall of Shame</a>), haven't
scaled to match the popularity of the projects. So we put our heads
together and did the obvious thing: ask Pamela Jones of
<a href="http://www.groklaw.net">Groklaw</a> for suggestions. She
referred us to the fine folks at softwarefreedom.org.</p>
<p>As a result, we're pleased to announce that the
<a href="http://www.softwarefreedom.org">Software Freedom Law Center</a>
has agreed to represent BusyBox and uClibc. We join a number of other
free and open source software projects (such as
<a href="http://lwn.net/Articles/141806/">X.org</a>,
<a href="http://lwn.net/Articles/135413/">Wine</a>, and
<a href="http://plone.org/foundation/newsitems/software-freedom-law-center-support/">Plone</a>
in being represented by a fairly cool bunch of lawyers, which is not a
phrase you get to use every day.</p>
<li><b>22 March 2006 -- BusyBox 1.1.1</b>
<p>The new maintainer is Rob Landley, and the new release is <a href="http://busybox.net/downloads/busybox-1.1.1.tar.bz2">BusyBox 1.1.1</a>. Expect a "what's new" document in a few days. (Also, Erik and I have have another announcement pending...)</p>
<p>Update: Rather than put out an endless stream of 1.1.1.x releases,
the various small fixes have been collected together into a
<a href="http://busybox.net/downloads/busybox-1.1.1.fixes.patch">patch</a>,
and new fixes will be appended to that as needed. Expect 1.1.2 around
June.</p>
</li>
<li><b>11 January 2006 -- 1.1.0 is out</b>
<p>The new stable release is
<a href="http://www.busybox.net/downloads/busybox-1.1.0.tar.bz2">BusyBox
1.1.0</a>. It has a number of improvements, including several new applets.
(It also has <a href="http://www.busybox.net/lists/busybox/2006-January/017733.html">a few rough spots</a>,
but we're trying out a "release early, release often" strategy to see how
that works. Expect 1.1.1 sometime in March.)</p>
<li><b>Old News</b><p>
<a href="/oldnews.html">Click here to read older news</a>
+799
View File
@@ -2,6 +2,805 @@
<ul>
<li><b>12 February 2008 -- BusyBox 1.9.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.9.1.tar.bz2>BusyBox 1.9.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_9_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.9.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to fsck,
iproute, mdev, mkswap, msh, nameif, stty, test, zcip.</p>
<p>hush has `command` expansion re-enabled for NOMMU, although it is
inherently unsafe (by virtue of NOMMU's use of vfork instead of fork).
The plan is to make this less likely to bite people in future versions.</p>
</li>
<li><b>24 December 2007 -- BusyBox 1.9.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.9.0.tar.bz2>BusyBox 1.9.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_9_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.9.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Sizes of busybox-1.8.2 and busybox-1.9.0 (with almost full config, static uclibc build):<pre>
text data bss dec hex filename
792796 978 9724 803498 c42aa busybox-1.8.2
783803 683 7508 791994 c15ba busybox-1.9.0
</pre>
<p>Top 10 stack users:<pre>
busybox-1.8.2: busybox-1.9.0:
input_tab 10428 echo_dg 4116
umount_main 8252 bb_full_fd_action 4112
rtnl_talk 8240 discard_dg 4096
xrtnl_dump_filter 8240 echo_stream 4096
sendMTFValues 5316 discard_stream 4096
mainSort 4700 find_list_entry2 4096
mkfs_minix_main 4288 readlink_main 4096
grave 4260 ipaddr_list_or_flush 3900
unix_do_one 4156 iproute_list_or_flush 3680
parse_prompt 4132 insmod_main 3152
</pre>
<p>lash is deleted from this release. hush can be configured down to almost
the same size, but it is significantly less buggy. It even works
on NOMMU machines (interactive mode and backticks are not working on NOMMU,
though). "lash" applet is still available, but it runs hush.
<p>init has some changes in this release, please report if it causes
problems for you.
<p>Changes since previous release:
<ul>
<li>Build system improvements
<li>Testsuite additions
<li>Stack size reductions, code size reductions, data/bss reductions
<li>An option to prefer IPv4 address if host has both
<li>New applets: hd, sestatus
<li>Removed applets: lash
<li>hush: fixed a few bugs, wired up echo and test to be builtins
<li>init: simplify forking of children
<li>getty: special handling of '#' and '@' is removed
<li>[su]login: sanitize environment if called by non-root
<li>udhcpc: support "bad" servers which send oversized packets
(Cristian Ionescu-Idbohrn &lt;cristian.ionescu-idbohrn at axis.com&gt;)
<li>udhcpc: -O option allows to specify which options to ask for
(Stefan Hellermann &lt;stefan at the2masters.de&gt;)
<li>udhcpc: optionally check whether given IP is really free (by ARP ping)
(Jonas Danielsson &lt;jonas.danielsson at axis.com&gt;)
<li>vi: now handles files with unlimited line length
<li>vi: speedup for huge line lengths
<li>vi: Del key works
<li>sed: support GNUism '\t'
<li>cp/mv/install: optionally use bigger buffer for bulk copying
<li>line editing: don't eat stack like crazy
<li>passwd: follows symlinked /etc/passwd
<li>renice: accepts priority with +N too
<li>netstat: wide output mode
<li>nameif: extended matching (Nico Erfurth &lt;masta at perlgolf.de&gt;)
<li>test: become NOFORK applet
<li>find: -iname (Alexander Griesser &lt;alexander.griesser at lkh-vil.or.at&gt;)
<li>df: -i option (show inode info) (Pascal Bellard &lt;pascal.bellard at ads-lu.com&gt;)
<li>hexdump: -R option (Pascal Bellard &lt;pascal.bellard at ads-lu.com&gt;)
</ul>
</p>
<li><b>23 November 2007 -- BusyBox 1.8.2 (stable), BusyBox 1.7.4 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.8.2.tar.bz2>BusyBox 1.8.2</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.8.2/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p><a href=http://busybox.net/downloads/busybox-1.7.4.tar.bz2>BusyBox 1.7.4</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.4/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>These are bugfix-only releases.
1.8.2 contains fixes for inetd, lash, tar, tr, and build system.
1.7.4 contains a fix for inetd.</p>
</li>
<li><b>9 November 2007 -- BusyBox 1.8.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.8.1.tar.bz2>BusyBox 1.8.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.8.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to login (PAM), modprobe, syslogd, telnetd, unzip.</p>
</li>
<li><b>4 November 2007 -- BusyBox 1.8.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.8.0.tar.bz2>BusyBox 1.8.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.8.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Note: this is probably the very last release with lash. It will be dropped. Please migrate to hush.
<p>Applets which had many changes since 1.7.x:
<p>httpd:
<ul>
<li>does not clear environment, CGIs will see all environment variables which were set for httpd
<li>fix bug where we were trying to read more POSTDATA than content-length
<li>fix trivial bug (spotted by Alex Landau)
<li>optional support for partial downloads
<li>simplified CGI i/o loop (now it looks good to me)
<li>small auth and IPv6 fixes (Kim B. Heino &lt;Kim.Heino at bluegiga.com>)
<li>support for proxying connection to other http server (by Alex Landau &lt;landau_alex at yahoo.com>)
</ul>
<p>top:
<ul>
<li>TOPMEM feature - 's(how sizes)' command
<li>don't wait before final bailout (try top -b -n1)
<li>fix for command line wrapping
</ul>
<p>Build system improvements: libbusybox mode restored (it was lost in transition to new makefiles).
<p>Code and data size in comparison with 1.7.3:<pre>
Equivalent .config, i386 uclibc static builds:
text data bss dec hex filename
768123 1055 10768 779946 be6aa busybox-1.7.3/busybox
759693 974 9420 770087 bc027 busybox-1.8.0/busybox</pre>
<p>New applets:
<ul>
<li>microcom: new applet by Vladimir Dronnikov &lt;dronnikov at gmail.ru&gt;
<li>kbd_mode: new applet by Loic Grenie &lt;loic.grenie at gmail.com&gt;
<li>bzip2: port bzip2 1.0.4 to busybox, 9 kb of code
<li>pgrep, pkill: new applets by Loic Grenie &lt;loic.grenie at gmail.com&gt;
<li>setsebool: new applet (Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
</ul>
<p>Other changes since previous release (abridged):
<ul>
<li>cp: -r and -R imply -d (coreutils compat)
<li>cp: detect and prevent infinite recursion
<li>cp: make it a bit closer to POSIX, but still refuse to open and overwrite symbolic link
<li>hdparm: reduce possibility of numeric overflow in -T
<li>hdparm: simplify timing measurement
<li>wget: -O FILE is allowed to overwrite existing file (compat)
<li>wget: allow dots in header field names
<li>telnetd: add -K option to close sessions as soon as child exits
<li>telnetd: don't SIGKILL child when closing the session, kernel will send SIGHUP for us
<li>ed: large cleanup, add line editing
<li>hush: feeble attempt at making it more NOMMU-friendly
<li>hush: fix glob()
<li>hush: stop doing manual accounting of open fd's, kernel can do it for us
<li>adduser: implement -S and fix uid selection
<li>ash: fix prompt expansion (Natanael Copa &lt;natanael.copa at gmail.com&gt;)
<li>ash: revert "cat | jobs" fix, it causes more problems than good
<li>find: fix -xdev behavior in the presence of two or more nested mount points
<li>grep: fix grep -F -e str1 -e str2 (was matching str2 only)
<li>grep: optimization: stop on first -e match
<li>gunzip: support concatenated gz files
<li>inetd: fix bug 1562 "inetd does not set argv[0] properly" (fix by Ilya Panfilov)
<li>install: 'support' (by ignoring) -v and -b
<li>install: fix bug in "install -c file dir" (tried to copy dir into dir too)
<li>ip: tunnel parameter parsing fix by Jean Wolter &lt;jw5 at os.inf.tu-dresden.de&gt;
<li>isrv: use monotonic_sec
<li>less: make 'f' key page forward
<li>libiproute: add missing break statements
<li>load_policy: update (Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
<li>logger: fix a problem of losing all argv except first
<li>login: do reject wrong passwords with PAM auth
<li>losetup: support -f (Loic Grenie &lt;loic.grenie at gmail.com&gt;)
<li>fdisk: make fdisk compile on libc without llseek64
<li>libbb: by popular request allow PATH to be customized at build time
<li>mkswap: selinux support by KaiGai Kohei &lt;kaigai at ak.jp.nec.com&gt;
<li>mount: allow (and ignore) -i
<li>mount: ignore NFS bg option on NOMMU machines
<li>mount: mount helpers support (by Vladimir Dronnikov &lt;dronnikov at gmail.ru&gt;)
<li>passwd: handle Ctrl-C, restore termios on Ctrl-C
<li>passwd: SELinux support by KaiGai Kohei &lt;kaigai at ak.jp.nec.com&gt;
<li>ping: make -I ethN work too (-I addr already worked)
<li>ps: fix RSS parsing (rss field in /proc/PID/stat is in pages, not bytes)
<li>read_line_input: fix it to not do any fancy editing if echoing is disabled
<li>run_parts: make it sort executables by name (required by API)
<li>runsv: do not use clock_gettime if !MONOTONIC_CLOCK
<li>runsvdir: fix "linear wait time" bug
<li>sulogin: remove alarm handling, it is redundant there
<li>svlogd: compat: svlogd -tt should timestamp stderr too
<li>syslogd: bail out if you see null read from Unix socket
<li>syslogd: do not need to poll(), we can just block in read()
<li>tail: work correctly on /proc files (Kazuo TAKADA &lt;kztakada at sm.sony.co.jp&gt;)
<li>tar + gzip/bzip2/etc: support NOMMU machines (by Alex Landau &lt;landau_alex at yahoo.com&gt;)
<li>tar: strip leading '/' BEFORE memorizing hardlink's name
<li>tftp: fix infinite retry bug
<li>umount: support (by ignoring) -i; style fixes
<li>unzip: fix endianness bugs
<li>vi: don't wait 50 ms before reading ESC sequences
<li>watchdog: allow millisecond spec (-t 250ms)
<li>zcip: fix unaligned trap on ARM
</ul>
</p>
</li>
<li><b>4 November 2007 -- BusyBox 1.7.3 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.3.tar.bz2>BusyBox 1.7.3</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.3/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to ash, httpd, inetd, iptun, logger, login, tail.</p>
</li>
<li><b>30 September 2007 -- BusyBox 1.7.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.2.tar.bz2>BusyBox 1.7.2</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.2/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to install, find, login, httpd, runsvdir, chcon, setfiles, fdisk and line editing.</p>
</li>
<li><b>16 September 2007 -- BusyBox 1.7.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.1.tar.bz2>BusyBox 1.7.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to cp, runsv, tar, busybox --install and build system.</p>
</li>
<li><b>24 August 2007 -- BusyBox 1.7.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.7.0.tar.bz2>BusyBox 1.7.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.7.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Applets which had many changes since 1.6.x:
<p>httpd:
<ul>
<li>works in standalone mode on NOMMU machines now (partly by Alex Landau &lt;landau_alex at yahoo.com&gt;)
<li>indexer example is rewritten in C
<li>optional support for error pages (by Pierre Metras &lt;genepi at sympatico.ca&gt;)
<li>stop reading headers using 1-byte reads
<li>new option -v[v]: prints client addresses, HTTP codes returned, URLs
<li>extended -p PORT to -p [IP[v6]:]PORT
<li>sendfile support (by Pierre Metras &lt;genepi at sympatico.ca&gt;)
<li>add support for Status: CGI header
<li>fix CGI handling bug (we were closing wrong fd)
<li>CGI I/O loop still doesn't look 100% ok to me...
</ul>
<p>udhcp[cd]:
<ul>
<li>add -f "foreground" and -S "syslog" options
<li>fixed "ifupdown + udhcpc_without_pidfile_creation" bug
<li>new config option "Rewrite the lease file at every new acknowledge" (Mats Erik Andersson &lt;mats at blue2net.com&gt; (Blue2Net AB))
<li>consistently treat server_config.start/end IPs as host-order
<li>fix IP parsing for 64bit machines
<li>fix unsafe hton macro usage in read_opt()
<li>do not chdir to / when daemonizing
</ul>
<p>top, ps, killall, pidof:
<ul>
<li>simpler loadavg processing
<li>truncate usernames to 8 chars
<li>fix non-CONFIG_DESKTOP ps -ww (by rockeychu)
<li>improve /proc/PID/cmdinfo reading code
<li>use cmdline, not comm field (fixes problems with re-execed applets showing as processes with name "exe", and not being found by pidof/killall by applet name)
<li>reduce CPU usage in decimal conversion (optional) (corresponding speedup on kernel side is accepted in mainline Linux kernel, yay!)
<li>make percentile (0.1%) calculations configurable
<li>add config option and code for global CPU% display
<li>reorder columns, so that [P]PIDs are together and VSZ/%MEM are together - makes more sense
</ul>
<p>Build system improvements: doesn't link against libraries we don't need,
generates verbose link output and map file, allows for custom link
scripts (useful for removing extra padding, among other things).
<p>Code and data size in comparison with 1.6.1:<pre>
Equivalent .config, i386 glibc dynamic builds:
text data bss dec hex filename
672671 2768 16808 692247 a9017 busybox-1.6.1/busybox
662948 2660 13528 679136 a5ce0 busybox-1.7.0/busybox
662783 2631 13416 678830 a5bae busybox-1.7.0/busybox.customld
Same .config built against static uclibc:
765021 1059 11020 777100 bdb8c busybox-1.7.0/busybox_uc</pre>
<p>Code/data shrink done in applets: crond, hdparm, dd, cal, od, nc, expr, uuencode,
test, slattach, diff, ping, tr, syslogd, hwclock, zcip, find, pidof, ash, uudecode,
runit/*, in libbb.
<p>New applets:
<ul>
<li>pscan, expand, unexpand (from Tito &lt;farmatito at tiscali.it&gt;)
<li>setfiles, restorecon (by Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
<li>chpasswd (by Alexander Shishkin &lt;virtuoso at slind.org&gt;)
<li>slattach, ttysize
</ul>
<p>Unfortunately, not much work is done on shells. This was mostly stalled
by lack of time (read: laziness) on my part to learn how to adapt existing
qemu-runnable image for a NOMMU architechture (available on qemu website)
for local testing of cross-compiled busybox on my machine.
<p>Other changes since previous release (abridged):
<ul>
<li>addgroup: disallow addgroup -g num user group; make -g 0 work (Tito &lt;farmatito at tiscali.it&gt;)
<li>adduser: close /etc/{passwd,shadow} before calling passwd etc. Spotted by Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>arping: -i should be -I, fixed
<li>ash: make "jobs | cat" work like in bash (was giving empty output)
<li>ash: recognize -l as --login equivalent; do not recognize +-login
<li>ash: fix buglet in DEBUG code (Nguyen Thai Ngoc Duy &lt;pclouds at gmail.com&gt;)
<li>ash: fix SEGV if type has zero parameters
<li>awk: fix -F 'regex' bug (miscounted fields if last field is empty)
<li>catv: catv without arguments was trying to use environ as argv (Alex Landau &lt;landau_alex at yahoo.com&gt;)
<li>catv: don't die on open error (emit warning)
<li>chown/chgrp: completely match coreutils 6.8 wrt symlink handling
<li>correct_password: do not print "no shadow passwd..." message
<li>crond: don't start sendmail with absolute path, don't report obsolete version (report true bbox version)
<li>dd: fix bug where we assume count=INT_MAX when count is unspecified
<li>devfsd: sanitization by Tito &lt;farmatito at tiscali.it&gt;
<li>echo: fix non-fancy echo
<li>fdisk: make it work with big disks (read: typical today's disks) even if CONFIG_LFS is unset
<li>find: -context support for SELinux (KaiGai Kohei &lt;kaigai at kaigai.gr.jp&gt;)
<li>find: add conditional support for -maxdepth and -regex, make -size match GNU find
<li>find: fix build failure on certain configs (found by Cristian Ionescu-Idbohrn &lt;cristian.ionescu-idbohrn at axis.com&gt;)
<li>fsck_minix: make it print bb version, not it's own (outdated/irrelevant) one
<li>grep: implement -m MAX_MATCHES, fix buglets with context printing
<li>grep: fix selection done by FEATURE_GREP_EGREP_ALIAS (Maxime Bizon &lt;mbizon at freebox.fr&gt; (Freebox))
<li>hush: add missing dependencies (Maxime Bizon &lt;mbizon at freebox.fr&gt; (Freebox))
<li>hush: fix read builtin to not read ahead past EOL and to not use insane amounts of stack
<li>ifconfig: make it work with ifaces with interface no. &gt; 255
<li>ifup/ifdown: make location of ifstate configurable
<li>ifupdown: make netmask parsing smaller and more strict (was accepting 255.0.255.0, 255.1234.0.0 etc...)
<li>install: fix -s (strip) option, fix install a b /a/link/to/dir
<li>libbb: consolidate ARRAY_SIZE macro (Walter Harms &lt;wharms at bfs.de&gt;)
<li>libbb: make /etc/network parsing configurable. -200 bytes when off
<li>libbb: nuke BB_GETOPT_ERROR, always die if there are mutually exclusive options
<li>libbb: xioctl and friends by Tito &lt;farmatito at tiscali.it&gt;
<li>login: optional support for PAM
<li>login: make /etc/nologin support configurable (-240 bytes)
<li>login: ask passwords even for wrong usernames
<li>md5_sha1_sum: fix mishandling when run as /bin/md5sum
<li>mdev: add support for firmware loading
<li>mdev: work even when CONFIG_SYSFS_DEPRECATED in kernel is off
<li>modprobe: add scanning of /lib/modules/`uname -r`/modules.symbols (by Yann E. MORIN &lt;yann.morin.1998 at anciens.enib.fr&gt;)
<li>more: fixes by Tristan Schmelcher &lt;tpkschme at engmail.uwaterloo.ca&gt;
<li>nc: make connecting to IPv4 from IPv6-enabled hosts easier (was requiring -s local_addr)
<li>passwd: fix bug "updating shadow even if user's record is in passwd"
<li>patch: fix -p -1 handling
<li>patch: fix bad line ending handling (Nguyen Thai Ngoc Duy &lt;pclouds at gmail.com&gt;)
<li>ping: display roundtrip times with 1/1000th of ms, not 1/10 ms precision.
<li>ping: fix incorrect handling of -I (Iouri Kharon &lt;bc-info at styx.cabel.net&gt;)
<li>ping: fix non-fancy ping6
<li>printenv: fix "printenv VAR1 VAR2" bug (spotted by Kalyanatejaswi Balabhadrapatruni &lt;kalyanatejaswi at yahoo.co.in&gt;)
<li>ps: fix -Z (by Yuichi Nakamura &lt;ynakam at hitachisoft.jp&gt;)
<li>rpm: add optional support for bz2 data. +50 bytes of code
<li>rpm: fix bogus "package is not installed" case
<li>sed: fix 'q' command handling (by Nguyen Thai Ngoc Duy &lt;pclouds at gmail.com&gt;)
<li>start_stop_daemon: NOMMU fixes by Alex Landau &lt;landau_alex at yahoo.com&gt;
<li>stat: fix option -Z SEGV
<li>strings: strings a b was processing a twice, fix that
<li>svlogd: fix timestamping, do not warn if config is missing
<li>syslogd, logread: get rid of head pointer, fix logread bug in the process
<li>syslogd: do not convert tabs to ^I, set syslog IPC buffer to mode 0644
<li>tar: improve OLDGNU compat, make old SUN compat configurable
<li>test: fix testing primary expressions like '"-u" = "-u"'
<li>uudecode: fix to base64 decode by Jorgen Cederlof &lt;jcz at google.com&gt;
<li>vi: multiple fixes by Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>wget: fix bug in base64 encoding (bug 1404). +10 bytes
<li>wget: lift 256 chars limitation on terminal width
<li>wget, zcip: use monotonic_sec instead of gettimeofday
</ul>
</p>
</li>
<li><b>30 June 2007 -- BusyBox 1.6.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.6.1.tar.bz2>BusyBox 1.6.1</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_6_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.6.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to echo, hush, and wget.</p>
</li>
<li><b>1 June 2007 -- BusyBox 1.6.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.6.0.tar.bz2>BusyBox 1.6.0</a>.
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_6_stable/>svn</a>,
<a href=http://busybox.net/downloads/fixes-1.6.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Since this is a x.x.0 release, it probably does not deserve "stable"
label. Please help making 1.6.1 stable by testing 1.6.0.</p>
<p>Note that hush shell had many changes and (hopefully) is much improved now,
but there is a possibility that it regressed in some obscure cases. Please
report any such cases.</p>
<p>lash users please note: lash is going to be deprecated in busybox 1.7.0
and removed in the more distant future. Please migrate to hush.</p>
<p><a href=http://busybox.net/~vda/mem_usage-1.6.0.txt>Memory usage has decreased, but we can do better still</a></p>
<p>Other changes since previous release:
<ul>
<li>NOFORK: audit small applets and mark some of them as NOFORK. Put big scary warnings in relevant places
<li>NOFORK: factor out NOFORK/NOEXEC code from find. Use NOFORK/NOEXEC in find and xargs
<li>NOFORK: remove potential xmalloc from NOFORK path in bb_full_fd_action
<li>NOMMU: random fixes; compressed --help now works for NOMMU
<li>SELinux: load_policy applet
<li>[u]mount: extend -t option (Roy Marples &lt;uberlord at gentoo.org&gt;)
<li>addgroup: clean up, fix adding users to existing groups and make it optional (Tito)
<li>adduser: don't bomb out if shadow password file doesn't exist (from Tito &lt;farmatito at tiscali.it&gt;)
<li>applet.c: do not even try to read config if run by real root; fix suid config handling
<li>ash: fix infinite loop on exit if tty is not there anymore
<li>ash: fix kill -l (by Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>ash: implement type -p, costs less than 10 bytes (patch by Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>awk: don't segfault on printf(%*s). Closes bug 1337
<li>awk: guard against empty environment
<li>awk: some 'lineno' vars were shorts, made them ints (code got smaller)
<li>cat: stop using stdio.h opens
<li>config system: clarify PREFER_APPLETS/SH_STANDALONE effects in help text
<li>cryptpw: new applet (by Thomas Lundquist &lt;lists at zelow.no&gt;)
<li>cttyhack: new applet
<li>dd: NOEXEC fix; fix skip= parse error (spotted by Dirk Clemens &lt;develop at cle-mens.de&gt;)
<li>deluser: add optional support for removing users from groups (by Tito &lt;farmatito at tiscali.it&gt;)
<li>diff: fix SEGV (NULL deref) in diff -N
<li>diff: fix segfault on empty dirs (Peter Korsgaard &lt;peter.korsgaard at barco.com&gt;)
<li>dnsd: fix several buglets, make smaller; openlog(), so that applet's name is logged
<li>dpkg: run_package_script() returns 0 if all ok and non-zero if failure. The result code was checked incorrectly in two places. (from Kim B. Heino &lt;Kim.Heino at bluegiga.com&gt;)
<li>dpkg: use bitfields which are a bit closer to typical short/char. Code size -800 bytes
<li>dumpleases: getopt32()-ization (from Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>e2fsprogs: stop using statics in chattr. Minor code shrinkage (-130 bytes)
<li>ether-wake: close bug 1317. Reorder fuctions to avoid forward refs while at it
<li>ether-wake: save a few more bytes of code
<li>find: -group, -depth (Natanael Copa &lt;natanael.copa at gmail.com&gt;)
<li>find: add support for -delete, -path (by Natanael Copa)
<li>find: fix -prune. Add big comment about it
<li>find: improve usage text (Natanael Copa &lt;natanael.copa at gmail.com&gt;)
<li>find: missed 'static' on const data; size and prune were mixed up; use index_in_str_array
<li>find: un-DESKTOPize (Kai Schwenzfeier &lt;niteblade at gmx.net&gt;)
<li>find_root_device: teach to deal with /dev/ subdirs (by Kirill K. Smirnov &lt;lich at math.spbu.ru&gt;)
<li>find_root_device: use lstat - don't follow links
<li>getopt32: fix llist_t options ordering. llist_rev is now unused
<li>getopt: use getopt32 for option parsing - inspired by patch by Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;
<li>hdparm: fix multisector mode setting (from Toni Mirabete &lt;amirabete at catix.cat&gt;)
<li>hdparm: make -T -t code smaller (-194 bytes), and output prettier
<li>ifupdown: make it possible to use DHCP clients different from udhcp
<li>ifupdown: reread state file before rewriting it. Fixes "ifup started another ifup" state corruption bug. Patch by Natanael Copa &lt;natanael.copa at gmail.com&gt;
<li>ifupdown: small optimization (avoid doing useless work if we are not going to update state file)
<li>ip: fix compilation if FEATURE_TR_CLASSES is off
<li>ip: mv ip*_main into ip.c; use a dispatcher to save on needless duplication. Saves a minor 12b
<li>ip: rewrite the ip applet to be less bloaty. Convert to index_in_(sub)str_array()
<li>ip: set the scope properly. Thanks to Jean Wolter
<li>iplink: shrink iplink; sanitize libiproute a bit (-916 bytes)
<li>iproute: shrink a bit (-200 bytes)
<li>kill: know much more signals; make code smaller; use common code for kill applet and ash kill builtin
<li>klogd: remove dependency on syslogd
<li>lash: "forking" applets are actually can be treated the same way as "non-forked". Also save a bit of space on trailing NULL array elements.
<li>lash: fix kill buglet (didn't properly recognize ESRCH)
<li>lash: make -c work; crush buffer overrun and free of non-malloced ptr (from Mats Erik Andersson &lt;mats.andersson64 at comhem.se&gt;)
<li>lash: recognize and use NOFORK applets
<li>less: fix case when regex search finds nothing; fix very obscure memory corruption bug; fix less &lt;HUGEFILE + [End] busy loop
<li>libbb: add xsendto, xunlink, xpipe
<li>libbb: fix segfault in reset_ino_dev_hashtable() when *hashtable was NULL
<li>libbb: make pidfile writing configurable
<li>libbb: make xsocket die with address family printed (if VERBOSE_RESOLUTION_ERRORS=y)
<li>libbb: rework NOMMU helper API so that it makes more sense and easier to use
<li>libiproute: audit callgraph, shortcut error paths into die() functions
<li>lineedit: do not try to open NULL history file
<li>lineedit: nuke two unused variables and code which sets them
<li>login: remove setpgrp call (makes it work from shell prompt again); sanitize stdio descriptors (we are suid, need to be careful!)
<li>login: shrink login and set_environment by ~100 bytes
<li>mount: fix incorrect usage of strtok (inadvertently used NULL sometimes)
<li>mount: fix mounting of symlinks (mount from util-linux allows that)
<li>msh: data/bss reduction (more than 9k of it); fix "underscore bug" (a_b=1111 didn't work); fix obscure case with backticks and closed fd 1
<li>nc: port nc 1.10 to busybox
<li>netstat: fix for bogus state value for raw sockets
<li>netstat: introduce -W: wide, ipv6-friendly output; shrink by ~500 bytes
<li>nmeter: should die if stdout doesn't like him anymore
<li>patch: do not try to delete same file twice
<li>ping: fix wrong sign extension of packet id (bug 1373)
<li>ps: add -o tty and -o rss support; make a bit smaller; work around libc bug: printf("%.*s\n", MAX_INT, buffer)
<li>run_parts: rewrite
<li>run_parts: do not check path portion of a name for "bad chars". Needed for ifupdown. Patch by Gabriel L. Somlo &lt;somlo at cmu.edu&gt;
<li>sed: fix escaped newlines in -f
<li>split: new applet
<li>stat: remove superfluous bss user (flags) and manually unswitch some areas
<li>stty: fix option parsing bug (spotted by Sascha Hauer &lt;s.hauer at pengutronix.de&gt;)
<li>svlogd: fix 'SEGV on uninitialized data' and make it honor TERM
<li>tail: fix SEGV on "tail -N"
<li>ipsvd: tcpsvd,udpsvd are new applets, GPL-ed 'clones' of Dan Bernstein's tcpserver. Author: Gerrit Pape &lt;pape at smarden.org&gt;, http://smarden.sunsite.dk/ipsvd/
<li>test: close bug 1371; plug a memory leak; code size reduction
<li>tftp: code diet, and I think retransmits were broken
<li>tr: fix bug where we did not reject invalid classes like '[[:alpha'. debloat while at it
<li>udhcp: MAC_BCAST_ADDR and blank_chaddr are in fact constant, move to rodata; use pipe instead of socketpair
<li>udhcp[cd]: stop using atexit magic fir pidfile removal; stop deleting our own pidfile if we daemonize
<li>xargs: shrink code, ~80 bytes; simplify word list management
<li>zcip: make it work on NOMMU (+ improve NOMMU support machinery)
</ul>
</p>
</li>
<li><b>20 May 2007 -- BusyBox 1.5.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.5.1.tar.bz2>BusyBox 1.5.1</a>.
(<a href=http://busybox.net/downloads/fixes-1.5.1/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>This is a bugfix-only release, with fixes to hdparm, hush, ifupdown, ps
and sed.</p>
</li>
<li><b>23 March 2007 -- BusyBox 1.5.0 (unstable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.5.0.tar.bz2>BusyBox 1.5.0</a>.
(<a href=http://busybox.net/downloads/fixes-1.5.0/>patches</a>,
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
<p>Since this is a x.x.0 release, it probably does not deserve "stable"
label. Please help making 1.5.1 stable by testing 1.5.0.</p>
<p>Notable changes since previous release:
<ul>
<li>find: added support for -user, -not, fixed -mtime, -mmin, -perm
<li>[de]archivers: merge common logic into one module
<li>ping[6]: unified code for both
<li>less: regex search improved
<li>ash: more readable code, testsuite added
<li>sed: several very obscure bugs fixed
<li>chown: -H, -L, -P support (required by POSIX)
<li>tar: handle (broken) checksums a-la Sun; tar restores mode again
<li>grep: implement -w, "implement" -a and -I by ignoring them
<li>cp: more sane behavior when overwriting existing files
<li>init: stop doing silly things with the console (-400 bytes)
<li>httpd: make httpd usable for NOMMU CPUs; fix POSTDATA handling bugs
<li>httpd: run interpreter for configured file extensions in any dir,
not only in /cgi-bin/
<li>chrt: new applet
<li>SELinux: SELinux-related code and -Z option added to several applets,
new SELinux-specific applets: chcon, runcon.
<li>Build system: produces link map, uses -Wwrite-strings to catch
improper usage of string constants.
<li>Data and bss section usage audited and reduced - should help NOMMU
targets.
<li>Applets with bug fixes: gunzip, vi, syslogd, dpkg, ls, adjtimex, resize,
sv, printf, diff, awk, sort, dpkg, diff, tftp
<li>Applets with usability improvements: swapon, more, ifup/ifdown, hwclock,
udhcpd, start_stop_daemon, cmp
<li>Applets with code cleaned up: telnet, fdisk, fsck_minix, mkfs_minix,
syslogd, swapon, runsv, svlogd, klogd
</ul>
</p>
</li>
<li><b>18 March 2007 -- BusyBox 1.4.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.4.2.tar.bz2>BusyBox 1.4.2</a>.
</p>
<p>This release includes only trivial fixes accumulated since 1.4.1.
</p>
</li>
<li><b>25 January 2007 -- BusyBox 1.4.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.4.1.tar.bz2>BusyBox 1.4.1</a>.
(<a href=http://busybox.net/downloads/fixes-1.4.1/>patches</a>)</p>
<p>This release includes only trivial fixes accumulated since 1.4.0.
</p>
</li>
<li><b>20 January 2007 -- BusyBox 1.4.0 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.4.0.tar.bz2>BusyBox 1.4.0</a>.
(<a href=http://busybox.net/downloads/fixes-1.4.0/>patches</a>)</p>
<p>Since this is a x.x.0 release, it probably is a bit less "stable"
than usual.</p>
<p>Changes since previous release:
<ul>
<li>e2fsprogs are mostly removed from busybox. Some smaller parts remain,
the rest of it sits disabled in e2fsprogs/old_e2fsprogs/*, because
it's too bloated. Really. I'm afraid it's about the only way we can
ever get e2fsprogs cleaned up.
<li>less: many improvements. Now can display binary files
(although I expect it to have trouble with displays where 8bit chars
don't have 1-to-1 char/glyph relationship). Regexp search is not buggy
anymore. Less does not read entire input up-front. Reads input
as it appears (yay!). Works rather nice as man pager. I recommend it
for general use now.
<li>IPv6: generic support is in place, many networking applets are
upgraded to be IPv6 capable. Probably some work remains, but it is
already much better than what we had previously.
<li>arp: new applet (thanks to Eric Spakman).
<li>fakeidentd: non-forking standalone server part was taking ~90%
of the applet. Factored it out (in fact, rewrote it).
<li>syslogd: mostly rewritten.
<li>decompress_unzip, gzip: sanitized a bit.
<li>sed: better hadling of NULs
<li>httpd: stop adding our own "Content-type:" to CGI output
<li>chown: user.grp works again.
<li>minor bugfixes to: passwd, date, tftp, start_stop_daemon, tar,
ps, ifupdown, time, su, stty, awk, ping[6], sort,...
</ul>
</p>
</li>
<li><b>20 January 2007 -- BusyBox 1.3.2 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.3.2.tar.bz2>BusyBox 1.3.2</a>.</p>
<p>This release includes only one trivial fix accumulated since 1.3.1
</p>
</li>
<li><b>27 December 2006 -- BusyBox 1.3.1 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.3.1.tar.bz2>BusyBox 1.3.1</a>.
(<a href=http://busybox.net/downloads/fixes-1.3.1/>patches</a>)</p>
<p>Closing 2006 with new release. It includes only trivial fixes accumulated since 1.3.0
</p>
</li>
<li><b>14 December 2006 -- BusyBox 1.3.0 (stable)</b>
<p><a href=http://busybox.net/downloads/busybox-1.3.0.tar.bz2>BusyBox 1.3.0</a>.
(<a href=http://busybox.net/downloads/fixes-1.3.0/>patches</a>)</p>
<p>This release has CONFIG_DESKTOP option which enables features
needed for busybox usage on desktop machine. For example, find, chmod
and chown get several less frequently used options, od is significantly
bigger but matches GNU coreutils, etc. Intended to eventually make
busybox a viable alternative for "standard" utilities for slightly
adventurous desktop users.
<p>Changes since previous release:
<ul>
<li>find: taking many more of standard options
<li>ps: POSIX-compliant -o implemented
<li>cp: added -s, -l
<li>grep: added -r, fixed -h
<li>watch: make it exec child like standard one does (was totally
incompatible)
<li>tar: fix limitations which were preventing bbox tar usage
on big directories: long names and linknames, pax headers
(Linux kernel tarballs have that). Fixed a number of obscure bugs.
Raised max file limit (now 64Gb). Security fixes (/../ attacks).
<li>httpd: added -i (inetd), -f (foreground), support for
directory indexer CGI (example is included), bugfixes.
<li>telnetd: fixed/improved IPv6 support, inetd+standalone support,
other fixes. Useful IPv6 stuff factored out into libbb.
<li>runit/*: new applets adapted from http://smarden.sunsite.dk/runit/
(these are my personal favorite small-and-beautiful toys)
<li>minor bugfixes to: login, dd, mount, umount, chmod, chown, ln, udhcp,
fdisk, ifconfig, sort, tee, mkswap, wget, insmod.
</ul>
<p>Note that GnuPG key used to sign this release is different.
1.2.2.1 is also signed post-factum now. Sorry for the mess.
</p>
</li>
<li><b>29 October 2006 -- BusyBox 1.2.2.1 (fix)</b>
<p><a href=http://busybox.net/downloads/busybox-1.2.2.1.tar.bz2>BusyBox 1.2.2.1</a>.</p>
<p>Added compile-time warning that static linking against glibc
produces buggy executables.
</li>
<li><b>24 October 2006 -- BusyBox 1.2.2 (stable)</b>
<p>It's a bit overdue, but
<a href=http://busybox.net/downloads/busybox-1.2.2.tar.bz2>here is
BusyBox 1.2.2</a>.</p>
<p>This release has dozens of fixes backported from the ongoing development
branch. There are a couple of bugfixes to sed, two fixes to documentation
generation (BusyBox.html shouldn't have USE() macros in it anymore), fix
umount to report the right errno on failure and to umount block devices by
name with newer kernels, fix mount to handle symlinks properly, make mdev
delete device nodes when called for hotplug remove, fix a segfault
in traceroute, a minor portability fix to md5sum option parsing, a build
fix for httpd with old gccs, an options parsing tweak to hdparm, make test
fail gracefully when getgroups() returns -1, fix a race condition in
modprobe when two instances run at once (hotplug does this), make "tar xf
foo.tar dir/dir" extract all subdirectories, make our getty initialize the
terminal more like mingetty, an selinux build fix, an endianness fix in
ping6, fix for zcip defending addresses, clean up some global variables in
gzip to save memory, fix sulogin -tNNN, a help text tweak, several warning
fixes and build fixes, fixup dnsd a bit, and a partridge in a pear tree.</p>
<p>As <a href=http://lwn.net/Articles/202106/>Linux Weekly News noted</a>,
this is my (Rob's) last release of BusyBox. The new maintainer is Denis
Vlasenko, I'm off to do <a href=http://landley.net/code>other things</a>.
</p>
</li>
<li><b>29 September 2006 -- New license email address.</b>
<p>The email address gpl@busybox.net is now the recommended way to contact
the Software Freedom Law Center to report BusyBox license violations.</p>
<li><b>31 July 2006 -- BusyBox 1.2.1 (stable)</b>
<p>Since nobody seems to have objected too loudly over the weekend, I
might as well point you all at
<a href="http://busybox.net/downloads/busybox-1.2.1.tar.bz2">Busybox
1.2.1</a>, a bugfix-only release with no new features.</p>
<p>It has three shell fixes (two to lash: going "var=value" without
saying "export" should now work, plus a missing null pointer check, and
one to ash when redirecting output to a file that fills up.) Fix three
embarassing thinkos in the new dmesg command. Two build tweaks
(dependencies for the compressed usage messages and running make in the
libbb subdirectory). One fix to tar so it can extract git-generated
tarballs (rather than barfing on the pax extensions). And a partridge
in a pear... Ahem.</p>
<p>But wait, there's more! A passwd changing fix so an empty
gecos field doesn't trigger a false objection that the new passwd contains
the gecos field. Make all our setuid() and setgid() calls check the return
value in case somebody's using per-process resource limits that prevent
a user from having too many processes (and thus prevent a process from
switching away from root, in which case the process will now _die_ rather
than continue with root privileges). A fix to adduser to make sure that
/etc/group gets updated. And a fix to modprobe to look for modules.conf
in the right place on 2.6 kernels.</p>
<li><b>30 June 2006 -- BusyBox 1.2.0</b>
<p>The -devel branch has been stabilized and the result is
<a href="http://busybox.net/downloads/busybox-1.2.0.tar.bz2">Busybox
1.2.0</a>. Lots of stuff changed, I need to work up a decent changelog
over the weekend.</p>
<p>I'm still experimenting with how long is best for the development
cycle, and since we've got some largeish projects queued up I'm going to
try a longer one. Expect 1.3.0 in December. (Expect 1.2.1 any time
we fix enough bugs. :)</p>
<p>Update: Here are <a href="http://busybox.net/downloads/busybox-1.2.0.fixes.patch">the first few bug fixes</a> that will go into 1.2.1.</p>
<li><b>17 May 2006 -- BusyBox 1.1.3 (stable)</b>
<p><a href="http://busybox.net/downloads/busybox-1.1.3.tar.bz2">BusyBox
1.1.3</a> is another bugfix release. It makes passwd use salt, fixes a
memory freeing bug in ls, fixes "build all sources at once" mode, makes
mount -a not abort on the first failure, fixes msh so ctrl-c doesn't kill
background processes, makes patch work with patch hunks that don't have a
timestamp, make less's text search a lot more robust (the old one could
segfault), and fixes readlink -f when built against uClibc.</p>
<p>Expect 1.2.0 sometime next month, which won't be a bugfix release.</p>
<li><b>10 April 2006 -- BusyBox 1.1.2 (stable)</b>
<p>You can now download <a href="http://busybox.net/downloads/busybox-1.1.2.tar.bz2">BusyBox 1.1.2</a>, a bug fix release consisting of 11 patches
backported from the development branch: Some build fixes, several fixes
for mount and nfsmount, a fix for insmod on big endian systems, a fix for
find -xdev, and a fix for comm. Check the file "changelog" in the tarball
for more info.</p>
<p>The next new development release (1.2.0) is slated for June. A 1.1.3
will be released before then if more bug fixes crop up. (The new plan is
to have a 1.x.0 new development release every 3 months, with 1.x.y stable
bugfix only releases based on that as appropriate.)</p>
<li><b>27 March 2006 -- Software Freedom Law Center representing BusyBox and uClibc</b>
<p>One issue Erik Andersen wanted to resolve when handing off BusyBox
maintainership to Rob Landley was license enforcement. BusyBox and
uClibc's existing license enforcement efforts (pro-bono representation
by Erik's father's law firm, and the
<a href="http://www.busybox.net/shame.html">Hall of Shame</a>), haven't
scaled to match the popularity of the projects. So we put our heads
together and did the obvious thing: ask Pamela Jones of
<a href="http://www.groklaw.net">Groklaw</a> for suggestions. She
referred us to the fine folks at softwarefreedom.org.</p>
<p>As a result, we're pleased to announce that the
<a href="http://www.softwarefreedom.org">Software Freedom Law Center</a>
has agreed to represent BusyBox and uClibc. We join a number of other
free and open source software projects (such as
<a href="http://lwn.net/Articles/141806/">X.org</a>,
<a href="http://lwn.net/Articles/135413/">Wine</a>, and
<a href="http://plone.org/foundation/newsitems/software-freedom-law-center-support/">Plone</a>
in being represented by a fairly cool bunch of lawyers, which is not a
phrase you get to use every day.</p>
<li><b>22 March 2006 -- BusyBox 1.1.1</b>
<p>The new maintainer is Rob Landley, and the new release is <a href="http://busybox.net/downloads/busybox-1.1.1.tar.bz2">BusyBox 1.1.1</a>. Expect a "what's new" document in a few days. (Also, Erik and I have have another announcement pending...)</p>
<p>Update: Rather than put out an endless stream of 1.1.1.x releases,
the various small fixes have been collected together into a
<a href="http://busybox.net/downloads/busybox-1.1.1.fixes.patch">patch</a>,
and new fixes will be appended to that as needed. Expect 1.1.2 around
June.</p>
</li>
<li><b>11 January 2006 -- 1.1.0 is out</b>
<p>The new stable release is
<a href="http://www.busybox.net/downloads/busybox-1.1.0.tar.bz2">BusyBox
1.1.0</a>. It has a number of improvements, including several new applets.
(It also has <a href="http://www.busybox.net/lists/busybox/2006-January/017733.html">a few rough spots</a>,
but we're trying out a "release early, release often" strategy to see how
that works. Expect 1.1.1 sometime in March.)</p>
<li><b>31 October 2005 -- 1.1.0-pre1</b>
<p>The development branch of busybox is stable enough for wider testing, so
you can now
+50 -41
View File
@@ -12,52 +12,61 @@ Everybody loves to look at screenshots, so here is a live action screenshot of B
font-family: monospace; font-size: smaller;" width="100">
$ busybox
BusyBox v1.8.0 (2007-11-04 15:42:38 GMT) multi-call binary
Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others.
Licensed under GPLv2. See source distribution for full notice.
BusyBox v1.10.1 (2008-04-24 11:30:07 CEST) multi-call binary
Copyright (C) 1998-2007 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
See source distribution for full notice.
Usage: busybox [function] [arguments]...
or: [function] [arguments]...
or: function [arguments]...
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as!
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as!
Currently defined functions:
[, [[, addgroup, adduser, adjtimex, ar, arp, arping, ash,
awk, basename, bunzip2, bzcat, bzip2, cal, cat, catv, chattr,
chgrp, chmod, chown, chpasswd, chpst, chroot, chrt, chvt,
cksum, clear, cmp, comm, cp, cpio, crond, crontab, cryptpw,
cut, date, dc, dd, deallocvt, delgroup, deluser, df, dhcprelay,
diff, dirname, dmesg, dnsd, dos2unix, dpkg, du, dumpkmap,
dumpleases, echo, ed, egrep, eject, env, envdir, envuidgid,
expand, expr, fakeidentd, false, fbset, fdflush, fdformat,
fdisk, fgrep, find, fold, free, freeramdisk, fsck, fsck.minix,
ftpget, ftpput, fuser, getopt, getty, grep, gunzip, gzip,
hdparm, head, hexdump, hostid, hostname, httpd, hush, hwclock,
id, ifconfig, inetd, insmod, install, ip, ipaddr, ipcalc,
ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kbd_mode,
kill, killall, killall5, klogd, lash, last, length, less,
linux32, linux64, ln, loadfont, loadkmap, logger, login, logname,
logread, losetup, ls, lsattr, lsmod, lzmacat, md5sum, mdev,
mesg, microcom, mkdir, mkfifo, mkfs.minix, mknod, mkswap,
mktemp, modprobe, more, mount, mountpoint, msh, mt, mv, nameif,
nc, netstat, nice, nmeter, nohup, nslookup, od, openvt, passwd,
patch, pgrep, pidof, ping, ping6, pipe_progress, pivot_root,
pkill, printenv, printf, ps, pscan, pwd, raidautorun, rdate,
readlink, readprofile, realpath, renice, reset, resize, rm,
rmdir, rmmod, route, rpm, rpm2cpio, run-parts, runlevel, runsv,
runsvdir, rx, sed, seq, setarch, setconsole, setkeycodes,
setlogcons, setsid, setuidgid, sha1sum, slattach, sleep, softlimit,
sort, split, start-stop-daemon, stat, strings, stty, su, sulogin,
sum, sv, svlogd, swapoff, swapon, switch_root, sync, sysctl,
syslogd, tail, tar, tcpsvd, tee, telnet, telnetd, test, tftp,
time, top, touch, tr, traceroute, true, tty, ttysize, udhcpc,
udhcpd, udpsvd, umount, uname, uncompress, unexpand, uniq,
unix2dos, unlzma, unzip, uptime, usleep, uudecode, uuencode,
vconfig, vi, vlock, watch, watchdog, wc, wget, which, who,
whoami, xargs, yes, zcat, zcip
[, [[, addgroup, adduser, adjtimex, ar, arp, arping, ash,
awk, basename, bbconfig, brctl, bunzip2, bzcat, bzip2,
cal, cat, catv, chat, chattr, chcon, chgrp, chmod, chown,
chpasswd, chpst, chroot, chrt, chvt, cksum, clear, cmp,
comm, cp, cpio, crond, crontab, cryptpw, cttyhack, cut,
date, dc, dd, deallocvt, delgroup, deluser, devfsd, df,
dhcprelay, diff, dirname, dmesg, dnsd, dos2unix, dpkg,
dpkg-deb, du, dumpkmap, dumpleases, echo, ed, egrep, eject,
env, envdir, envuidgid, ether-wake, expand, expr, fakeidentd,
false, fbset, fdflush, fdformat, fdisk, fetchmail, fgrep,
find, findfs, fold, free, freeramdisk, fsck, fsck.minix,
ftpget, ftpput, fuser, getenforce, getopt, getsebool,
getty, grep, gunzip, gzip, halt, hd, hdparm, head, hexdump,
hostid, hostname, httpd, hush, hwclock, id, ifconfig,
ifdown, ifenslave, ifup, inetd, init, insmod, install,
ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule,
iptunnel, kbd_mode, kill, killall, killall5, klogd, lash,
last, length, less, linux32, linux64, linuxrc, ln, load_policy,
loadfont, loadkmap, logger, login, logname, logread, losetup,
lpd, lpq, lpr, ls, lsattr, lsmod, lzmacat, makedevs, matchpathcon,
md5sum, mdev, mesg, microcom, mkdir, mkfifo, mkfs.minix,
mknod, mkswap, mktemp, modprobe, more, mount, mountpoint,
msh, mt, mv, nameif, nc, netstat, nice, nmeter, nohup,
nslookup, od, openvt, passwd, patch, pgrep, pidof, ping,
ping6, pipe_progress, pivot_root, pkill, poweroff, printenv,
printf, ps, pscan, pwd, raidautorun, rdate, readahead,
readlink, readprofile, realpath, reboot, renice, reset,
resize, restorecon, rm, rmdir, rmmod, route, rpm, rpm2cpio,
rtcwake, run-parts, runcon, runlevel, runsv, runsvdir,
rx, script, sed, selinuxenabled, sendmail, seq, sestatus,
setarch, setconsole, setenforce, setfiles, setkeycodes,
setlogcons, setsebool, setsid, setuidgid, sha1sum, slattach,
sleep, softlimit, sort, split, start-stop-daemon, stat,
strings, stty, su, sulogin, sum, sv, svlogd, swapoff,
swapon, switch_root, sync, sysctl, syslogd, tac, tail,
tar, taskset, tcpsvd, tee, telnet, telnetd, test, tftp,
tftpd, time, top, touch, tr, traceroute, true, tty, ttysize,
udhcpc, udhcpd, udpsvd, umount, uname, uncompress, unexpand,
uniq, unix2dos, unlzma, unzip, uptime, usleep, uudecode,
uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget,
which, who, whoami, xargs, yes, zcat, zcip
$ <span style="text-decoration:blink;">_</span>
+26 -9
View File
@@ -12,24 +12,41 @@ project, consider these fine companies!</p>
OSU OSL kindly provides hosting for BusyBox and uClibc.
</li>
<li><a href="http://www.codepoet-consulting.com">Codepoet Consulting</a><br>
Custom Linux, embedded Linux, BusyBox, and uClibc development.
</li>
<li>AOE media, a <a href=http://www.aoemedia.com/typo3-development.html>
TYPO3 development agency</a> contributes financially.
</li>
<li><a href=http://www.analog.com/en/>Analog Devices, Inc.</a> provided
a <a href=http://docs.blackfin.uclinux.org/doku.php?id=bf537_quick_start>
Blackfin development board</a> free of charge.
<a href=http://www.analog.com/blackfin>Blackfin<a>
is a NOMMU processor, and its availability for testing is invaluable.
If you are an embedded device developer,
please note that Analog Devices has entire Linux distribution available
for download for this board. Visit
<a href=http://blackfin.uclinux.org/>http://blackfin.uclinux.org/</a>
for more information.
</li>
<li><a href="http://www.timesys.com">TimeSys</a><br>
Embedded Linux development, cross-compilers, real-time, KGDB, tsrpm and cygwin.
</li>
<li><a href="http://www.penguru.net">Penguru Consulting</a><br>
Custom development for embedded Linux systems and multimedia platforms
Custom development for embedded Linux systems and multimedia platforms.
</li>
<li><a href="http://opensource.se/">opensource.se</a><br>
Embedded open source consulting in Europe.
</li>
<li><a href="http://www.codepoet-consulting.com">Codepoet Consulting</a><br>
Custom Linux, embedded Linux, BusyBox, and uClibc development.
</li>
<li><a href="http://www.timesys.com">TimeSys</a><br>
Embedded Linux development, cross-compilers, real-time, KGDB, tsrpm and cygwin.
</li>
</ul>
<p>If you wish to be a sponsor, or if you have already contributed and would
like your name added here, email <a href="mailto:rob@landley.net">Rob</a>.</p>
like your name added here, email <a href="mailto:vda.linux@gmail.com">Denys</a>.</p>
<!--#include file="footer.html" -->
+9 -3
View File
@@ -15,13 +15,20 @@ require sysfs support in the kernel and have it mounted at /sys. For dynamic
updates, you also need to have hotplugging enabled in your kernel.
Here's a typical code snippet from the init script:
[0] mount -t proc proc /proc
[1] mount -t sysfs sysfs /sys
[2] echo /bin/mdev > /proc/sys/kernel/hotplug
[3] mdev -s
Alternatively, without procfs the above becomes:
[1] mount -t sysfs sysfs /sys
[2] sysctl -w kernel.hotplug=/bin/mdev
[3] mdev -s
Of course, a more "full" setup would entail executing this before the previous
code snippet:
[4] mount -t tmpfs mdev /dev
[4] mount -t tmpfs -o size=64k,mode=0755 tmpfs /dev
[5] mkdir /dev/pts
[6] mount -t devpts devpts /dev/pts
@@ -87,5 +94,4 @@ properly initialize a device. Place all such firmware files into the
/lib/firmware/ directory. At runtime, the kernel will invoke mdev with the
filename of the firmware which mdev will load out of /lib/firmware/ and into
the kernel via the sysfs interface. The exact filename is hardcoded in the
kernel, so look there if you need to want to know what to name the file in
userspace.
kernel, so look there if you need to know how to name the file in userspace.
+1 -1
View File
@@ -192,7 +192,7 @@ static const char e2attr_flags_lname[] =
"Top_of_Directory_Hierarchies" "\0"
/* Another trailing NUL is added by compiler */;
void print_flags(FILE *f, unsigned long flags, unsigned options)
void print_e2flags(FILE *f, unsigned long flags, unsigned options)
{
const uint32_t *fv;
const char *fn;
+9 -1
View File
@@ -9,6 +9,10 @@
/* Constants and structures */
#include "e2fs_defs.h"
#if __GNUC_PREREQ(4,1)
# pragma GCC visibility push(hidden)
#endif
/* Iterate a function on each entry of a directory */
int iterate_on_dir(const char *dir_name,
int (*func)(const char *, struct dirent *, void *),
@@ -27,7 +31,7 @@ int fgetsetflags(const char *name, unsigned long *get_flags, unsigned long set_f
/* Must be 1 for compatibility with `int long_format'. */
#define PFOPT_LONG 1
/* Print file attributes on an ext2 file system */
void print_flags(FILE *f, unsigned long flags, unsigned options);
void print_e2flags(FILE *f, unsigned long flags, unsigned options);
extern const uint32_t e2attr_flags_value[];
extern const char e2attr_flags_sname[];
@@ -41,3 +45,7 @@ extern const char e2attr_flags_sname[];
#define e2attr_flags_value_chattr (&e2attr_flags_value[1])
#define e2attr_flags_sname_chattr (&e2attr_flags_sname[1])
#endif
#if __GNUC_PREREQ(4,1)
# pragma GCC visibility pop
#endif
+1 -1
View File
@@ -391,7 +391,7 @@ static void load_fs_info(const char *filename)
}
while (1) {
int r;
char *buf = xmalloc_getline(f);
char *buf = xmalloc_fgetline(f);
if (!buf) break;
r = parse_fstab_line(buf, &fs);
free(buf);
+2 -2
View File
@@ -45,10 +45,10 @@ static void list_attributes(const char *name)
if (option_mask32 & OPT_PF_LONG) {
printf("%-28s ", name);
print_flags(stdout, fsflags, PFOPT_LONG);
print_e2flags(stdout, fsflags, PFOPT_LONG);
bb_putchar('\n');
} else {
print_flags(stdout, fsflags, 0);
print_e2flags(stdout, fsflags, 0);
printf(" %s\n", name);
}
+1 -1
View File
@@ -13,7 +13,7 @@
#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040
#endif
/* `options' for print_flags() */
/* `options' for print_e2flags() */
#define PFOPT_LONG 1 /* Must be 1 for compatibility with `int long_format'. */
+1 -1
View File
@@ -285,7 +285,7 @@ static char *string_copy(const char *s)
if (!s)
return 0;
ret = strdup(s);
ret = xstrdup(s);
return ret;
}
+2 -2
View File
@@ -56,10 +56,10 @@ static void list_attributes(const char *name)
if (flags & OPT_PF_LONG) {
printf("%-28s ", name);
print_flags(stdout, fsflags, PFOPT_LONG);
print_e2flags(stdout, fsflags, PFOPT_LONG);
bb_putchar('\n');
} else {
print_flags(stdout, fsflags, 0);
print_e2flags(stdout, fsflags, 0);
printf(" %s\n", name);
}
+24 -30
View File
@@ -676,16 +676,11 @@ static char nextchar(char **s)
return c;
}
static int ALWAYS_INLINE isalnum_(int c)
static ALWAYS_INLINE int isalnum_(int c)
{
return (isalnum(c) || c == '_');
}
static FILE *afopen(const char *path, const char *mode)
{
return (*path == '-' && *(path+1) == '\0') ? stdin : xfopen(path, mode);
}
/* -------- working with variables (set/get/copy/etc) -------- */
static xhash *iamarray(var *v)
@@ -1682,7 +1677,7 @@ static void hashwalk_init(var *v, xhash *array)
{
char **w;
hash_item *hi;
int i;
unsigned i;
if (v->type & VF_WALK)
free(v->x.walker);
@@ -1996,7 +1991,7 @@ static var *exec_builtin(node *op, var *res)
}
nargs = i;
if (nargs < (info >> 30))
if ((uint32_t)nargs < (info >> 30))
syntax_error(EMSG_TOO_FEW_ARGS);
switch (info & OPNMASK) {
@@ -2740,7 +2735,7 @@ static rstream *next_input_file(void)
ind = getvar_s(incvar(intvar[ARGIND]));
fname = getvar_s(findvar(iamarray(intvar[ARGV]), ind));
if (fname && *fname && !is_assignment(fname))
F = afopen(fname, "r");
F = xfopen_stdin(fname);
}
} while (!F);
@@ -2757,8 +2752,9 @@ int awk_main(int argc, char **argv)
{
unsigned opt;
char *opt_F, *opt_W;
llist_t *opt_v = NULL;
int i, j, flen;
llist_t *list_v = NULL;
llist_t *list_f = NULL;
int i, j;
var *v;
var tv;
char **envp;
@@ -2816,35 +2812,33 @@ int awk_main(int argc, char **argv)
*s1 = '=';
}
}
opt_complementary = "v::";
opt = getopt32(argv, "F:v:f:W:", &opt_F, &opt_v, &g_progname, &opt_W);
opt_complementary = "v::f::"; /* -v and -f can occur multiple times */
opt = getopt32(argv, "F:v:f:W:", &opt_F, &list_v, &list_f, &opt_W);
argv += optind;
argc -= optind;
if (opt & 0x1)
setvar_s(intvar[FS], opt_F); // -F
while (opt_v) { /* -v */
if (!is_assignment(llist_pop(&opt_v)))
while (list_v) { /* -v */
if (!is_assignment(llist_pop(&list_v)))
bb_show_usage();
}
if (opt & 0x4) { // -f
char *s = s; /* die, gcc, die */
FILE *from_file = afopen(g_progname, "r");
/* one byte is reserved for some trick in next_token */
if (fseek(from_file, 0, SEEK_END) == 0) {
flen = ftell(from_file);
s = xmalloc(flen + 4);
fseek(from_file, 0, SEEK_SET);
i = 1 + fread(s + 1, 1, flen, from_file);
} else {
if (list_f) { /* -f */
do {
char *s = NULL;
FILE *from_file;
g_progname = llist_pop(&list_f);
from_file = xfopen_stdin(g_progname);
/* one byte is reserved for some trick in next_token */
for (i = j = 1; j > 0; i += j) {
s = xrealloc(s, i + 4096);
j = fread(s + i, 1, 4094, from_file);
}
}
s[i] = '\0';
fclose(from_file);
parse_program(s + 1);
free(s);
s[i] = '\0';
fclose(from_file);
parse_program(s + 1);
free(s);
} while (list_f);
} else { // no -f: take program from 1st parameter
if (!argc)
bb_show_usage();
+299 -233
View File
File diff suppressed because it is too large. Load diff
+131 -136
View File
@@ -119,7 +119,7 @@ int ed_main(int argc ATTRIBUTE_UNUSED, char **argv)
static void doCommands(void)
{
const char *cp;
char *endbuf, *newname, buf[USERSIZE];
char *endbuf, buf[USERSIZE];
int len, num1, num2;
smallint have1, have2;
@@ -168,162 +168,157 @@ static void doCommands(void)
num2 = num1;
switch (*cp++) {
case 'a':
addLines(num1 + 1);
break;
case 'a':
addLines(num1 + 1);
break;
case 'c':
deleteLines(num1, num2);
addLines(num1);
break;
case 'c':
deleteLines(num1, num2);
addLines(num1);
break;
case 'd':
deleteLines(num1, num2);
break;
case 'd':
deleteLines(num1, num2);
break;
case 'f':
if (*cp && !isblank(*cp)) {
bb_error_msg("bad file command");
break;
}
cp = skip_blank(cp);
if (*cp == '\0') {
if (fileName)
printf("\"%s\"\n", fileName);
else
printf("No file name\n");
break;
}
newname = strdup(cp);
if (newname == NULL) {
bb_error_msg("no memory for file name");
break;
}
free(fileName);
fileName = newname;
case 'f':
if (*cp && !isblank(*cp)) {
bb_error_msg("bad file command");
break;
case 'i':
addLines(num1);
}
cp = skip_blank(cp);
if (*cp == '\0') {
if (fileName)
printf("\"%s\"\n", fileName);
else
printf("No file name\n");
break;
}
free(fileName);
fileName = xstrdup(cp);
break;
case 'k':
cp = skip_blank(cp);
if ((*cp < 'a') || (*cp > 'z') || cp[1]) {
bb_error_msg("bad mark name");
break;
}
marks[*cp - 'a'] = num2;
case 'i':
addLines(num1);
break;
case 'k':
cp = skip_blank(cp);
if ((*cp < 'a') || (*cp > 'z') || cp[1]) {
bb_error_msg("bad mark name");
break;
}
marks[*cp - 'a'] = num2;
break;
case 'l':
printLines(num1, num2, TRUE);
case 'l':
printLines(num1, num2, TRUE);
break;
case 'p':
printLines(num1, num2, FALSE);
break;
case 'q':
cp = skip_blank(cp);
if (have1 || *cp) {
bb_error_msg("bad quit command");
break;
}
if (!dirty)
return;
len = read_line_input("Really quit? ", buf, 16, NULL);
/* read error/EOF - no way to continue */
if (len < 0)
return;
cp = skip_blank(buf);
if ((*cp | 0x20) == 'y') /* Y or y */
return;
break;
case 'p':
printLines(num1, num2, FALSE);
case 'r':
if (*cp && !isblank(*cp)) {
bb_error_msg("bad read command");
break;
case 'q':
cp = skip_blank(cp);
if (have1 || *cp) {
bb_error_msg("bad quit command");
break;
}
if (!dirty)
return;
len = read_line_input("Really quit? ", buf, 16, NULL);
/* read error/EOF - no way to continue */
if (len < 0)
return;
cp = skip_blank(buf);
if ((*cp | 0x20) == 'y') /* Y or y */
return;
}
cp = skip_blank(cp);
if (*cp == '\0') {
bb_error_msg("no file name");
break;
case 'r':
if (*cp && !isblank(*cp)) {
bb_error_msg("bad read command");
break;
}
cp = skip_blank(cp);
if (*cp == '\0') {
bb_error_msg("no file name");
break;
}
if (!have1)
num1 = lastNum;
if (readLines(cp, num1 + 1))
break;
if (fileName == NULL)
fileName = strdup(cp);
}
if (!have1)
num1 = lastNum;
if (readLines(cp, num1 + 1))
break;
if (fileName == NULL)
fileName = xstrdup(cp);
break;
case 's':
subCommand(cp, num1, num2);
case 's':
subCommand(cp, num1, num2);
break;
case 'w':
if (*cp && !isblank(*cp)) {
bb_error_msg("bad write command");
break;
case 'w':
if (*cp && !isblank(*cp)) {
bb_error_msg("bad write command");
break;
}
cp = skip_blank(cp);
if (!have1) {
num1 = 1;
num2 = lastNum;
}
if (*cp == '\0')
cp = fileName;
if (cp == NULL) {
bb_error_msg("no file name specified");
break;
}
writeLines(cp, num1, num2);
break;
case 'z':
switch (*cp) {
case '-':
printLines(curNum - 21, curNum, FALSE);
break;
case '.':
printLines(curNum - 11, curNum + 10, FALSE);
break;
default:
printLines(curNum, curNum + 21, FALSE);
break;
}
break;
case '.':
if (have1) {
bb_error_msg("no arguments allowed");
break;
}
printLines(curNum, curNum, FALSE);
}
cp = skip_blank(cp);
if (!have1) {
num1 = 1;
num2 = lastNum;
}
if (*cp == '\0')
cp = fileName;
if (cp == NULL) {
bb_error_msg("no file name specified");
break;
}
writeLines(cp, num1, num2);
break;
case 'z':
switch (*cp) {
case '-':
if (setCurNum(curNum - 1))
printLines(curNum, curNum, FALSE);
printLines(curNum - 21, curNum, FALSE);
break;
case '=':
printf("%d\n", num1);
case '.':
printLines(curNum - 11, curNum + 10, FALSE);
break;
case '\0':
if (have1) {
printLines(num2, num2, FALSE);
break;
}
if (setCurNum(curNum + 1))
printLines(curNum, curNum, FALSE);
break;
default:
bb_error_msg("unimplemented command");
printLines(curNum, curNum + 21, FALSE);
break;
}
break;
case '.':
if (have1) {
bb_error_msg("no arguments allowed");
break;
}
printLines(curNum, curNum, FALSE);
break;
case '-':
if (setCurNum(curNum - 1))
printLines(curNum, curNum, FALSE);
break;
case '=':
printf("%d\n", num1);
break;
case '\0':
if (have1) {
printLines(num2, num2, FALSE);
break;
}
if (setCurNum(curNum + 1))
printLines(curNum, curNum, FALSE);
break;
default:
bb_error_msg("unimplemented command");
break;
}
}
}
@@ -830,7 +825,7 @@ static int printLines(int num1, int num2, int expandFlag)
while (num1 <= num2) {
if (!expandFlag) {
write(1, lp->data, lp->len);
write(STDOUT_FILENO, lp->data, lp->len);
setCurNum(num1++);
lp = lp->next;
continue;
+135 -152
View File
@@ -19,253 +19,236 @@
* - Reject file isnt saved
*/
#include <getopt.h>
#include "libbb.h"
static unsigned int copy_lines(FILE *src_stream, FILE *dest_stream, const unsigned int lines_count)
static unsigned copy_lines(FILE *src_stream, FILE *dst_stream, unsigned lines_count)
{
unsigned int i = 0;
while (src_stream && (i < lines_count)) {
while (src_stream && lines_count) {
char *line;
line = xmalloc_fgets(src_stream);
if (line == NULL) {
break;
}
if (fputs(line, dest_stream) == EOF) {
if (fputs(line, dst_stream) == EOF) {
bb_perror_msg_and_die("error writing to new file");
}
free(line);
i++;
lines_count--;
}
return i;
return lines_count;
}
/* If patch_level is -1 it will remove all directory names
* char *line must be greater than 4 chars
* returns NULL if the file doesnt exist or error
* returns malloc'ed filename
* NB: frees 1st argument!
*/
static char *extract_filename(char *line, int patch_level)
static char *extract_filename(char *line, int patch_level, const char *pat)
{
char *temp, *filename_start_ptr = line + 4;
int i;
char *temp = NULL, *filename_start_ptr = line + 4;
/* Terminate string at end of source filename */
temp = strchrnul(filename_start_ptr, '\t');
*temp = '\0';
if (strncmp(line, pat, 4) == 0) {
/* Terminate string at end of source filename */
line[strcspn(line,"\t\n\r")] = '\0';
/* Skip over (patch_level) number of leading directories */
if (patch_level == -1)
patch_level = INT_MAX;
for (i = 0; i < patch_level; i++) {
temp = strchr(filename_start_ptr, '/');
if (!temp)
break;
filename_start_ptr = temp + 1;
/* Skip over (patch_level) number of leading directories */
while (patch_level--) {
temp = strchr(filename_start_ptr, '/');
if (!temp)
break;
filename_start_ptr = temp + 1;
}
temp = xstrdup(filename_start_ptr);
}
return xstrdup(filename_start_ptr);
free(line);
return temp;
}
int patch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int patch_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int patch_level = -1;
char *patch_line;
int ret;
FILE *patch_file = NULL;
struct stat saved_stat;
char *patch_line;
FILE *patch_file;
int patch_level;
int ret = 0;
char plus = '+';
xfunc_error_retval = 2;
{
char *p, *i;
ret = getopt32(argv, "p:i:", &p, &i);
if (ret & 1)
patch_level = xatol_range(p, -1, USHRT_MAX);
if (ret & 2) {
patch_file = xfopen(i, "r");
} else {
patch_file = stdin;
}
ret = 0;
const char *p = "-1";
const char *i = "-"; /* compat */
if (getopt32(argv, "p:i:R", &p, &i) & 4)
plus = '-';
patch_level = xatoi(p); /* can be negative! */
patch_file = xfopen_stdin(i);
}
patch_line = xmalloc_getline(patch_file);
patch_line = xmalloc_fgetline(patch_file);
while (patch_line) {
FILE *src_stream;
FILE *dst_stream;
char *original_filename;
//char *old_filename;
char *new_filename;
char *backup_filename;
unsigned int src_cur_line = 1;
unsigned int dest_cur_line = 0;
unsigned int dest_beg_line;
unsigned int bad_hunk_count = 0;
unsigned int hunk_count = 0;
char copy_trailing_lines_flag = 0;
unsigned src_cur_line = 1;
unsigned dst_cur_line = 0;
unsigned dst_beg_line;
unsigned bad_hunk_count = 0;
unsigned hunk_count = 0;
smallint copy_trailing_lines_flag = 0;
/* Skip everything upto the "---" marker
* No need to parse the lines "Only in <dir>", and "diff <args>"
*/
while (patch_line && strncmp(patch_line, "--- ", 4) != 0) {
free(patch_line);
patch_line = xmalloc_getline(patch_file);
}
/* FIXME: patch_line NULL check?? */
do {
/* Extract the filename used before the patch was generated */
new_filename = extract_filename(patch_line, patch_level, "--- ");
// was old_filename above
patch_line = xmalloc_fgetline(patch_file);
if (!patch_line) goto quit;
} while (!new_filename);
free(new_filename); // "source" filename is irrelevant
/* Extract the filename used before the patch was generated */
original_filename = extract_filename(patch_line, patch_level);
free(patch_line);
patch_line = xmalloc_getline(patch_file);
/* FIXME: NULL check?? */
if (strncmp(patch_line, "+++ ", 4) != 0) {
ret = 2;
bb_error_msg("invalid patch");
continue;
new_filename = extract_filename(patch_line, patch_level, "+++ ");
if (!new_filename) {
bb_error_msg_and_die("invalid patch");
}
new_filename = extract_filename(patch_line, patch_level);
free(patch_line);
/* Get access rights from the file to be patched, -1 file does not exist */
if (stat(new_filename, &saved_stat)) {
char *line_ptr;
/* Create leading directories */
line_ptr = strrchr(new_filename, '/');
if (line_ptr) {
*line_ptr = '\0';
/* Get access rights from the file to be patched */
if (stat(new_filename, &saved_stat) != 0) {
char *slash = strrchr(new_filename, '/');
if (slash) {
/* Create leading directories */
*slash = '\0';
bb_make_directory(new_filename, -1, FILEUTILS_RECUR);
*line_ptr = '/';
*slash = '/';
}
dst_stream = xfopen(new_filename, "w+");
backup_filename = NULL;
} else {
backup_filename = xmalloc(strlen(new_filename) + 6);
strcpy(backup_filename, new_filename);
strcat(backup_filename, ".orig");
xrename(new_filename, backup_filename);
dst_stream = xfopen(new_filename, "w");
fchmod(fileno(dst_stream), saved_stat.st_mode);
}
if ((backup_filename == NULL) || stat(original_filename, &saved_stat)) {
src_stream = NULL;
saved_stat.st_mode = 0644;
} else {
if (strcmp(original_filename, new_filename) == 0) {
src_stream = xfopen(backup_filename, "r");
} else {
src_stream = xfopen(original_filename, "r");
}
backup_filename = xasprintf("%s.orig", new_filename);
xrename(new_filename, backup_filename);
src_stream = xfopen(backup_filename, "r");
}
dst_stream = xfopen(new_filename, "w");
fchmod(fileno(dst_stream), saved_stat.st_mode);
printf("patching file %s\n", new_filename);
/* Handle each hunk */
/* Handle all hunks for this file */
patch_line = xmalloc_fgets(patch_file);
while (patch_line) {
unsigned int count;
unsigned int src_beg_line;
unsigned int unused;
unsigned int hunk_offset_start = 0;
int hunk_error = 0;
unsigned count;
unsigned src_beg_line;
unsigned hunk_offset_start;
unsigned src_last_line = 1;
unsigned dst_last_line = 1;
/* This bit should be improved */
if ((sscanf(patch_line, "@@ -%d,%d +%d,%d @@", &src_beg_line, &unused, &dest_beg_line, &unused) != 4) &&
(sscanf(patch_line, "@@ -%d,%d +%d @@", &src_beg_line, &unused, &dest_beg_line) != 3) &&
(sscanf(patch_line, "@@ -%d +%d,%d @@", &src_beg_line, &dest_beg_line, &unused) != 3)) {
if ((sscanf(patch_line, "@@ -%d,%d +%d,%d", &src_beg_line, &src_last_line, &dst_beg_line, &dst_last_line) < 3)
&& (sscanf(patch_line, "@@ -%d +%d,%d", &src_beg_line, &dst_beg_line, &dst_last_line) < 2)
) {
/* No more hunks for this file */
break;
}
free(patch_line);
if (plus != '+') {
/* reverse patch */
unsigned tmp = src_last_line;
src_last_line = dst_last_line;
dst_last_line = tmp;
tmp = src_beg_line;
src_beg_line = dst_beg_line;
dst_beg_line = tmp;
}
hunk_count++;
if (src_beg_line && dest_beg_line) {
if (src_beg_line && dst_beg_line) {
/* Copy unmodified lines upto start of hunk */
/* src_beg_line will be 0 if its a new file */
/* src_beg_line will be 0 if it's a new file */
count = src_beg_line - src_cur_line;
if (copy_lines(src_stream, dst_stream, count) != count) {
if (copy_lines(src_stream, dst_stream, count)) {
bb_error_msg_and_die("bad src file");
}
src_cur_line += count;
dest_cur_line += count;
dst_cur_line += count;
copy_trailing_lines_flag = 1;
}
hunk_offset_start = src_cur_line;
src_last_line += hunk_offset_start = src_cur_line;
dst_last_line += dst_cur_line;
while ((patch_line = xmalloc_fgets(patch_file)) != NULL) {
if ((*patch_line == '-') || (*patch_line == ' ')) {
while (1) {
free(patch_line);
patch_line = xmalloc_fgets(patch_file);
if (patch_line == NULL)
break; /* EOF */
if ((*patch_line != '-') && (*patch_line != '+')
&& (*patch_line != ' ')
) {
break; /* End of hunk */
}
if (*patch_line != plus) { /* '-' or ' ' */
char *src_line = NULL;
if (src_cur_line == src_last_line)
break;
if (src_stream) {
src_line = xmalloc_fgets(src_stream);
if (!src_line) {
hunk_error++;
break;
} else {
if (src_line) {
int diff = strcmp(src_line, patch_line + 1);
src_cur_line++;
free(src_line);
if (diff)
src_line = NULL;
}
if (strcmp(src_line, patch_line + 1) != 0) {
bb_error_msg("hunk #%d FAILED at %d", hunk_count, hunk_offset_start);
hunk_error++;
free(patch_line);
/* Probably need to find next hunk, etc... */
/* but for now we just bail out */
patch_line = NULL;
break;
}
free(src_line);
}
if (*patch_line == ' ') {
fputs(patch_line + 1, dst_stream);
dest_cur_line++;
if (!src_line) {
bb_error_msg("hunk #%u FAILED at %u", hunk_count, hunk_offset_start);
bad_hunk_count++;
break;
}
if (*patch_line != ' ') { /* '-' */
continue;
}
} else if (*patch_line == '+') {
fputs(patch_line + 1, dst_stream);
dest_cur_line++;
} else {
break;
}
free(patch_line);
}
if (hunk_error) {
bad_hunk_count++;
}
}
if (dst_cur_line == dst_last_line)
break;
fputs(patch_line + 1, dst_stream);
dst_cur_line++;
} /* end of while loop handling one hunk */
} /* end of while loop handling one file */
/* Cleanup last patched file */
if (copy_trailing_lines_flag) {
copy_lines(src_stream, dst_stream, -1);
copy_lines(src_stream, dst_stream, (unsigned)(-1));
}
if (src_stream) {
fclose(src_stream);
}
if (dst_stream) {
fclose(dst_stream);
}
fclose(dst_stream);
if (bad_hunk_count) {
if (!ret) {
ret = 1;
}
bb_error_msg("%d out of %d hunk FAILED", bad_hunk_count, hunk_count);
ret = 1;
bb_error_msg("%u out of %u hunk FAILED", bad_hunk_count, hunk_count);
} else {
/* It worked, we can remove the backup */
if (backup_filename) {
unlink(backup_filename);
}
if ((dest_cur_line == 0) || (dest_beg_line == 0)) {
if ((dst_cur_line == 0) || (dst_beg_line == 0)) {
/* The new patched file is empty, remove it */
xunlink(new_filename);
if (strcmp(new_filename, original_filename) != 0)
xunlink(original_filename);
// /* old_filename and new_filename may be the same file */
// unlink(old_filename);
}
}
}
free(backup_filename);
//free(old_filename);
free(new_filename);
} /* end of "while there are patch lines" */
quit:
/* 0 = SUCCESS
* 1 = Some hunks failed
* 2 = More serious problems
* 2 = More serious problems (exited earlier)
*/
return ret;
}
+8 -10
View File
@@ -628,7 +628,7 @@ static int do_subst_command(sed_cmd_t *sed_cmd, char **line)
{
char *oldline = *line;
int altered = 0;
int match_count = 0;
unsigned match_count = 0;
regex_t *current_regex;
/* Handle empty regex. */
@@ -665,7 +665,9 @@ static int do_subst_command(sed_cmd_t *sed_cmd, char **line)
/* If we aren't interested in this match, output old line to
end of match and continue */
if (sed_cmd->which_match && sed_cmd->which_match != match_count) {
if (sed_cmd->which_match
&& (sed_cmd->which_match != match_count)
) {
for (i = 0; i < G.regmatch[0].rm_eo; i++)
pipe_putc(*oldline++);
continue;
@@ -1028,7 +1030,7 @@ static void process_files(void)
if (rfile) {
char *line;
while ((line = xmalloc_getline(rfile))
while ((line = xmalloc_fgetline(rfile))
!= NULL)
append(line);
xprint_and_close_file(rfile);
@@ -1265,21 +1267,17 @@ int sed_main(int argc ATTRIBUTE_UNUSED, char **argv)
if (opt & 0x2) G.regex_type |= REG_EXTENDED; // -r
//if (opt & 0x4) G.be_quiet++; // -n
while (opt_e) { // -e
add_cmd_block(opt_e->data);
opt_e = opt_e->link;
/* we leak opt_e here... */
add_cmd_block(llist_pop(&opt_e));
}
while (opt_f) { // -f
char *line;
FILE *cmdfile;
cmdfile = xfopen(opt_f->data, "r");
while ((line = xmalloc_getline(cmdfile)) != NULL) {
cmdfile = xfopen(llist_pop(&opt_f), "r");
while ((line = xmalloc_fgetline(cmdfile)) != NULL) {
add_cmd(line);
free(line);
}
fclose(cmdfile);
opt_f = opt_f->link;
/* we leak opt_f here... */
}
/* if we didn't get a pattern from -e or -f, use argv[0] */
if (!(opt & 0x18)) {
+214 -183
View File
@@ -112,11 +112,19 @@ enum {
S_END_ALNUM = 5, // used in skip_thing() for moving "dot"
};
/* vi.c expects chars to be unsigned. */
/* busybox build system provides that, but it's better */
/* to audit and fix the source */
static smallint vi_setops;
struct globals {
/* many references - keep near the top of globals */
char *text, *end; // pointers to the user data in memory
char *dot; // where all the action takes place
int text_size; // size of the allocated buffer
/* the rest */
smallint vi_setops;
#define VI_AUTOINDENT 1
#define VI_SHOWMATCH 2
#define VI_IGNORECASE 4
@@ -127,83 +135,76 @@ static smallint vi_setops;
/* indicate error with beep or flash */
#define err_method (vi_setops & VI_ERR_METHOD)
static smallint editing; // >0 while we are editing a file
// [code audit says "can be 0 or 1 only"]
static smallint cmd_mode; // 0=command 1=insert 2=replace
static smallint file_modified; // buffer contents changed
static smallint last_file_modified = -1;
static int fn_start; // index of first cmd line file name
static int save_argc; // how many file names on cmd line
static int cmdcnt; // repetition count
static int rows, columns; // the terminal screen is this size
static int crow, ccol; // cursor is on Crow x Ccol
static int offset; // chars scrolled off the screen to the left
static char *status_buffer; // mesages to the user
#define STATUS_BUFFER_LEN 200
static int have_status_msg; // is default edit status needed?
// [don't make smallint!]
static int last_status_cksum; // hash of current status line
static char *current_filename; // current file name
//static char *text, *end; // pointers to the user data in memory
static char *screen; // pointer to the virtual screen buffer
static int screensize; // and its size
static char *screenbegin; // index into text[], of top line on the screen
//static char *dot; // where all the action takes place
static int tabstop;
static char erase_char; // the users erase character
static char last_input_char; // last char read from user
static char last_forward_char; // last char searched for with 'f'
#if ENABLE_FEATURE_VI_READONLY
//static smallint vi_readonly, readonly;
static smallint readonly_mode = 0;
smallint readonly_mode;
#define SET_READONLY_FILE(flags) ((flags) |= 0x01)
#define SET_READONLY_MODE(flags) ((flags) |= 0x02)
#define UNSET_READONLY_FILE(flags) ((flags) &= 0xfe)
#else
#define readonly_mode 0
#define SET_READONLY_FILE(flags)
#define SET_READONLY_MODE(flags)
#define UNSET_READONLY_FILE(flags)
#define SET_READONLY_FILE(flags) ((void)0)
#define SET_READONLY_MODE(flags) ((void)0)
#define UNSET_READONLY_FILE(flags) ((void)0)
#endif
smallint editing; // >0 while we are editing a file
// [code audit says "can be 0, 1 or 2 only"]
smallint cmd_mode; // 0=command 1=insert 2=replace
int file_modified; // buffer contents changed (counter, not flag!)
int last_file_modified; // = -1;
int fn_start; // index of first cmd line file name
int save_argc; // how many file names on cmd line
int cmdcnt; // repetition count
unsigned rows, columns; // the terminal screen is this size
int crow, ccol; // cursor is on Crow x Ccol
int offset; // chars scrolled off the screen to the left
int have_status_msg; // is default edit status needed?
// [don't make smallint!]
int last_status_cksum; // hash of current status line
char *current_filename;
char *screenbegin; // index into text[], of top line on the screen
char *screen; // pointer to the virtual screen buffer
int screensize; // and its size
int tabstop;
char erase_char; // the users erase character
char last_input_char; // last char read from user
char last_forward_char; // last char searched for with 'f'
#if ENABLE_FEATURE_VI_DOT_CMD
static smallint adding2q; // are we currently adding user input to q
static char *last_modifying_cmd; // [MAX_INPUT_LEN] last modifying cmd for "."
static smallint lmc_len; // length of last_modifying_cmd
static char *ioq, *ioq_start; // pointer to string for get_one_char to "read"
smallint adding2q; // are we currently adding user input to q
int lmc_len; // length of last_modifying_cmd
char *ioq, *ioq_start; // pointer to string for get_one_char to "read"
#endif
#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
static int last_row; // where the cursor was last moved to
int last_row; // where the cursor was last moved to
#endif
#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME
static int my_pid;
int my_pid;
#endif
#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
static char *modifying_cmds; // cmds that modify text[]
char *modifying_cmds; // cmds that modify text[]
#endif
#if ENABLE_FEATURE_VI_SEARCH
static char *last_search_pattern; // last pattern from a '/' or '?' search
char *last_search_pattern; // last pattern from a '/' or '?' search
#endif
int chars_to_parse;
/* former statics */
#if ENABLE_FEATURE_VI_YANKMARK
char *edit_file__cur_line;
#endif
int refresh__old_offset;
int format_edit_status__tot;
/* Moving biggest data to malloced space... */
struct globals {
/* many references - keep near the top of globals */
char *text, *end; // pointers to the user data in memory
char *dot; // where all the action takes place
int text_size; // size of the allocated buffer
/* a few references only */
#if ENABLE_FEATURE_VI_YANKMARK
int YDreg, Ureg; // default delete register and orig line for "U"
char *reg[28]; // named register a-z, "D", and "U" 0-25,26,27
char *mark[28]; // user marks points somewhere in text[]- a-z and previous context ''
char *context_start, *context_end;
#endif
/* a few references only */
#if ENABLE_FEATURE_VI_USE_SIGNALS
sigjmp_buf restart; // catch_sig()
sigjmp_buf restart; // catch_sig()
#endif
struct termios term_orig, term_vi; // remember what the cooked mode was
struct termios term_orig, term_vi; // remember what the cooked mode was
#if ENABLE_FEATURE_VI_COLON
char *initial_cmds[3]; // currently 2 entries, NULL terminated
#endif
@@ -214,6 +215,12 @@ struct globals {
#else
char readbuffer[32];
#endif
#define STATUS_BUFFER_LEN 200
char status_buffer[STATUS_BUFFER_LEN]; // messages to the user
#if ENABLE_FEATURE_VI_DOT_CMD
char last_modifying_cmd[MAX_INPUT_LEN]; // last modifying cmd for "."
#endif
char get_input_line__buf[MAX_INPUT_LEN]; /* former static */
char scr_out_buf[MAX_SCR_COLS + MAX_TABSTOP * 2];
};
@@ -223,6 +230,50 @@ struct globals {
#define end (G.end )
#define dot (G.dot )
#define reg (G.reg )
#define vi_setops (G.vi_setops )
#define editing (G.editing )
#define cmd_mode (G.cmd_mode )
#define file_modified (G.file_modified )
#define last_file_modified (G.last_file_modified )
#define fn_start (G.fn_start )
#define save_argc (G.save_argc )
#define cmdcnt (G.cmdcnt )
#define rows (G.rows )
#define columns (G.columns )
#define crow (G.crow )
#define ccol (G.ccol )
#define offset (G.offset )
#define status_buffer (G.status_buffer )
#define have_status_msg (G.have_status_msg )
#define last_status_cksum (G.last_status_cksum )
#define current_filename (G.current_filename )
#define screen (G.screen )
#define screensize (G.screensize )
#define screenbegin (G.screenbegin )
#define tabstop (G.tabstop )
#define erase_char (G.erase_char )
#define last_input_char (G.last_input_char )
#define last_forward_char (G.last_forward_char )
#if ENABLE_FEATURE_VI_READONLY
#define readonly_mode (G.readonly_mode )
#else
#define readonly_mode 0
#endif
#define adding2q (G.adding2q )
#define lmc_len (G.lmc_len )
#define ioq (G.ioq )
#define ioq_start (G.ioq_start )
#define last_row (G.last_row )
#define my_pid (G.my_pid )
#define modifying_cmds (G.modifying_cmds )
#define last_search_pattern (G.last_search_pattern)
#define chars_to_parse (G.chars_to_parse )
#define edit_file__cur_line (G.edit_file__cur_line)
#define refresh__old_offset (G.refresh__old_offset)
#define format_edit_status__tot (G.format_edit_status__tot)
#define YDreg (G.YDreg )
#define Ureg (G.Ureg )
#define mark (G.mark )
@@ -234,10 +285,15 @@ struct globals {
#define initial_cmds (G.initial_cmds )
#define readbuffer (G.readbuffer )
#define scr_out_buf (G.scr_out_buf )
#define last_modifying_cmd (G.last_modifying_cmd )
#define get_input_line__buf (G.get_input_line__buf)
#define INIT_G() do { \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
last_file_modified = -1; \
} while (0)
static int init_text_buffer(char *); // init from file or create new
static void edit_file(char *); // edit one file
static void do_cmd(char); // execute a command
@@ -355,22 +411,15 @@ int vi_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int vi_main(int argc, char **argv)
{
int c;
RESERVE_CONFIG_BUFFER(STATUS_BUFFER, STATUS_BUFFER_LEN);
INIT_G();
#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME
my_pid = getpid();
#endif
INIT_G();
#if ENABLE_FEATURE_VI_CRASHME
srand((long) my_pid);
#endif
status_buffer = STATUS_BUFFER;
last_status_cksum = 0;
text = NULL;
#ifdef NO_SUCH_APPLET_YET
/* If we aren't "vi", we are "view" */
if (ENABLE_FEATURE_VI_READONLY && applet_name[2]) {
@@ -379,9 +428,6 @@ int vi_main(int argc, char **argv)
#endif
vi_setops = VI_AUTOINDENT | VI_SHOWMATCH | VI_IGNORECASE;
#if ENABLE_FEATURE_VI_YANKMARK
memset(reg, 0, sizeof(reg)); // init the yank regs
#endif
#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
modifying_cmds = (char *) "aAcCdDiIJoOpPrRsxX<>~"; // cmds modifying text[]
#endif
@@ -417,9 +463,8 @@ int vi_main(int argc, char **argv)
case 'H':
show_help();
/* fall through */
default:
bb_show_usage();
bb_show_usage();
return 1;
}
}
@@ -451,9 +496,7 @@ static int init_text_buffer(char *fn)
/* allocate/reallocate text buffer */
free(text);
text_size = size * 2;
if (text_size < 10240)
text_size = 10240; // have a minimum size for new files
text_size = size + 10240;
screenbegin = dot = end = text = xzalloc(text_size);
if (fn != current_filename) {
@@ -479,15 +522,14 @@ static int init_text_buffer(char *fn)
static void edit_file(char *fn)
{
#if ENABLE_FEATURE_VI_YANKMARK
#define cur_line edit_file__cur_line
#endif
char c;
int size;
#if ENABLE_FEATURE_VI_USE_SIGNALS
int sig;
#endif
#if ENABLE_FEATURE_VI_YANKMARK
static char *cur_line;
#endif
editing = 1; // 0 = exit, 1 = one file, 2 = multiple files
rawmode();
@@ -581,7 +623,7 @@ static void edit_file(char *fn)
// These are commands that change text[].
// Remember the input for the "." command
if (!adding2q && ioq_start == NULL
&& strchr(modifying_cmds, c)
&& c != '\0' && strchr(modifying_cmds, c)
) {
start_new_cmd_q(c);
}
@@ -603,9 +645,10 @@ static void edit_file(char *fn)
}
//-------------------------------------------------------------------
place_cursor(rows, 0, FALSE); // go to bottom of screen
clear_to_eol(); // Erase to end of line
place_cursor(rows - 1, 0, FALSE); // go to bottom of screen
clear_to_eol(); // erase to end of line
cookmode();
#undef cur_line
}
//----- The Colon commands -------------------------------------
@@ -1081,7 +1124,7 @@ static void colon(char *buf)
}
#endif /* FEATURE_VI_SEARCH */
} else if (strncasecmp(cmd, "version", i) == 0) { // show software version
status_line("%s", BB_VER " " BB_BT);
status_line(BB_VER " " BB_BT);
} else if (strncasecmp(cmd, "write", i) == 0 // write text to file
|| strncasecmp(cmd, "wq", i) == 0
|| strncasecmp(cmd, "wn", i) == 0
@@ -1231,9 +1274,8 @@ static void sync_cursor(char *d, int *row, int *col)
// handle tabs like real vi
if (d == tp && cmd_mode) {
break;
} else {
co = next_tabstop(co);
}
co = next_tabstop(co);
} else if ((unsigned char)*tp < ' ' || *tp == 0x7f) {
co++; // display as ^X, use 2 columns
}
@@ -1283,7 +1325,7 @@ static char *begin_line(char *p) // return pointer to first char cur line
return p;
}
static char *end_line(char *p) // return pointer to NL of cur line line
static char *end_line(char *p) // return pointer to NL of cur line
{
if (p < end - 1) {
p = memchr(p, '\n', end - p - 1);
@@ -1305,7 +1347,7 @@ static char *dollar_line(char *p) // return pointer to just before NL line
static char *prev_line(char *p) // return pointer first char prev line
{
p = begin_line(p); // goto begining of cur line
if (p[-1] == '\n' && p > text)
if (p > text && p[-1] == '\n')
p--; // step to prev line
p = begin_line(p); // goto begining of prev line
return p;
@@ -1314,7 +1356,7 @@ static char *prev_line(char *p) // return pointer first char prev line
static char *next_line(char *p) // return pointer first char next line
{
p = end_line(p);
if (*p == '\n' && p < end - 1)
if (p < end - 1 && *p == '\n')
p++; // step to next line
return p;
}
@@ -1497,7 +1539,7 @@ static char *new_screen(int ro, int co)
}
#if ENABLE_FEATURE_VI_SEARCH
static int mycmp(const char * s1, const char * s2, int len)
static int mycmp(const char *s1, const char *s2, int len)
{
int i;
@@ -1509,7 +1551,7 @@ static int mycmp(const char * s1, const char * s2, int len)
}
// search for pattern starting at p
static char *char_search(char * p, const char * pat, int dir, int range)
static char *char_search(char *p, const char *pat, int dir, int range)
{
#ifndef REGEX_SEARCH
char *start, *stop;
@@ -1602,7 +1644,7 @@ static char *char_search(char * p, const char * pat, int dir, int range)
}
#endif /* FEATURE_VI_SEARCH */
static char *char_insert(char * p, char c) // insert the char c at 'p'
static char *char_insert(char *p, char c) // insert the char c at 'p'
{
if (c == 22) { // Is this an ctrl-V?
p = stupid_insert(p, '^'); // use ^ to indicate literal next
@@ -1611,7 +1653,7 @@ static char *char_insert(char * p, char c) // insert the char c at 'p'
c = get_one_char();
*p = c;
p++;
file_modified++; // has the file been modified
file_modified++;
} else if (c == 27) { // Is this an ESC?
cmd_mode = 0;
cmdcnt = 0;
@@ -1651,18 +1693,15 @@ static char *char_insert(char * p, char c) // insert the char c at 'p'
return p;
}
static char *stupid_insert(char * p, char c) // stupidly insert the char c at 'p'
static char *stupid_insert(char *p, char c) // stupidly insert the char c at 'p'
{
p = text_hole_make(p, 1);
if (p != 0) {
*p = c;
file_modified++; // has the file been modified
p++;
}
return p;
*p = c;
//file_modified++; - done by text_hole_make()
return p + 1;
}
static int find_range(char ** start, char ** stop, char c)
static int find_range(char **start, char **stop, char c)
{
char *save_dot, *p, *q, *t;
int cnt, multiline = 0;
@@ -1718,7 +1757,7 @@ static int find_range(char ** start, char ** stop, char c)
p = t;
}
// backward char movements don't include start position
// backward char movements don't include start position
if (q > p && strchr("^0bBh\b\177", c)) q--;
multiline = 0;
@@ -1735,7 +1774,7 @@ static int find_range(char ** start, char ** stop, char c)
return multiline;
}
static int st_test(char * p, int type, int dir, char * tested)
static int st_test(char *p, int type, int dir, char *tested)
{
char c, c0, ci;
int test, inc;
@@ -1769,7 +1808,7 @@ static int st_test(char * p, int type, int dir, char * tested)
return test;
}
static char *skip_thing(char * p, int linecnt, int dir, int type)
static char *skip_thing(char *p, int linecnt, int dir, int type)
{
char c;
@@ -1787,7 +1826,7 @@ static char *skip_thing(char * p, int linecnt, int dir, int type)
}
// find matching char of pair () [] {}
static char *find_pair(char * p, const char c)
static char *find_pair(char *p, const char c)
{
char match, *q;
int dir, level;
@@ -1840,31 +1879,29 @@ static void showmatching(char *p)
#endif /* FEATURE_VI_SETOPTS */
// open a hole in text[]
static char *text_hole_make(char * p, int size) // at "p", make a 'size' byte hole
static char *text_hole_make(char *p, int size) // at "p", make a 'size' byte hole
{
char *src, *dest;
int cnt;
if (size <= 0)
goto thm0;
src = p;
dest = p + size;
cnt = end - src; // the rest of buffer
if ( ((end + size) >= (text + text_size)) // TODO: realloc here
|| memmove(dest, src, cnt) != dest) {
status_line_bold("can't create room for new characters");
p = NULL;
goto thm0;
}
memset(p, ' ', size); // clear new hole
return p;
end += size; // adjust the new END
file_modified++; // has the file been modified
thm0:
if (end >= (text + text_size)) {
char *new_text;
text_size += end - (text + text_size) + 10240;
new_text = xrealloc(text, text_size);
screenbegin = new_text + (screenbegin - text);
dot = new_text + (dot - text);
end = new_text + (end - text);
p = new_text + (p - text);
text = new_text;
}
memmove(p + size, p, end - size - p);
memset(p, ' ', size); // clear new hole
file_modified++;
return p;
}
// close a hole in text[]
static char *text_hole_delete(char * p, char * q) // delete "p" through "q", inclusive
static char *text_hole_delete(char *p, char *q) // delete "p" through "q", inclusive
{
char *src, *dest;
int cnt, hole_size;
@@ -1885,16 +1922,14 @@ static char *text_hole_delete(char * p, char * q) // delete "p" through "q", inc
goto thd0;
if (src >= end)
goto thd_atend; // just delete the end of the buffer
if (memmove(dest, src, cnt) != dest) {
status_line_bold("can't delete the character");
}
memmove(dest, src, cnt);
thd_atend:
end = end - hole_size; // adjust the new END
if (dest >= end)
dest = end - 1; // make sure dest in below end-1
if (end <= text)
dest = end = text; // keep pointers valid
file_modified++; // has the file been modified
file_modified++;
thd0:
return dest;
}
@@ -1902,7 +1937,7 @@ static char *text_hole_delete(char * p, char * q) // delete "p" through "q", inc
// copy text into register, then delete text.
// if dist <= 0, do not include, or go past, a NewLine
//
static char *yank_delete(char * start, char * stop, int dist, int yf)
static char *yank_delete(char *start, char *stop, int dist, int yf)
{
char *p;
@@ -1973,12 +2008,10 @@ static void show_help(void)
static void start_new_cmd_q(char c)
{
// get buffer for new cmd
if (!last_modifying_cmd)
last_modifying_cmd = xzalloc(MAX_INPUT_LEN);
// if there is a current cmd count put it in the buffer first
if (cmdcnt > 0)
if (cmdcnt > 0) {
lmc_len = sprintf(last_modifying_cmd, "%d%c", cmdcnt, c);
else { // just save char c onto queue
} else { // just save char c onto queue
last_modifying_cmd[0] = c;
lmc_len = 1;
}
@@ -1997,27 +2030,26 @@ static void end_cmd_q(void)
#if ENABLE_FEATURE_VI_YANKMARK \
|| (ENABLE_FEATURE_VI_COLON && ENABLE_FEATURE_VI_SEARCH) \
|| ENABLE_FEATURE_VI_CRASHME
static char *string_insert(char * p, char * s) // insert the string at 'p'
static char *string_insert(char *p, char *s) // insert the string at 'p'
{
int cnt, i;
i = strlen(s);
if (text_hole_make(p, i)) {
strncpy(p, s, i);
for (cnt = 0; *s != '\0'; s++) {
if (*s == '\n')
cnt++;
}
#if ENABLE_FEATURE_VI_YANKMARK
status_line("Put %d lines (%d chars) from [%c]", cnt, i, what_reg());
#endif
text_hole_make(p, i);
strncpy(p, s, i);
for (cnt = 0; *s != '\0'; s++) {
if (*s == '\n')
cnt++;
}
#if ENABLE_FEATURE_VI_YANKMARK
status_line("Put %d lines (%d chars) from [%c]", cnt, i, what_reg());
#endif
return p;
}
#endif
#if ENABLE_FEATURE_VI_YANKMARK
static char *text_yank(char * p, char * q, int dest) // copy text into a register
static char *text_yank(char *p, char *q, int dest) // copy text into a register
{
char *t;
int cnt;
@@ -2164,8 +2196,6 @@ static int mysleep(int hund) // sleep for 'h' 1/100 seconds
return safe_poll(pfd, 1, hund*10) > 0;
}
static int chars_to_parse;
//----- IO Routines --------------------------------------------
static char readit(void) // read (maybe cursor) key from stdin
{
@@ -2217,18 +2247,20 @@ static char readit(void) // read (maybe cursor) key from stdin
fflush(stdout);
n = chars_to_parse;
// get input from User- are there already input chars in Q?
// get input from User - are there already input chars in Q?
if (n <= 0) {
// the Q is empty, wait for a typed char
n = safe_read(0, readbuffer, sizeof(readbuffer));
if (n < 0) {
if (errno == EBADF || errno == EFAULT || errno == EINVAL
|| errno == EIO)
editing = 0; // want to exit
errno = 0;
again:
n = safe_read(STDIN_FILENO, readbuffer, sizeof(readbuffer));
if (n <= 0) {
place_cursor(rows - 1, 0, FALSE); // go to bottom of screen
clear_to_eol(); // erase to end of line
cookmode(); // terminal to "cooked"
bb_error_msg_and_die("can't read user input");
}
if (n <= 0)
return 0; // error
/* elsewhere we can get very confused by NULs */
if (readbuffer[0] == '\0')
goto again;
if (readbuffer[0] == 27) {
// This is an ESC char. Is this Esc sequence?
// Could be bare Esc key. See if there are any
@@ -2239,9 +2271,11 @@ static char readit(void) // read (maybe cursor) key from stdin
pfd[0].events = POLLIN;
// keep reading while there are input chars, and room in buffer
// for a complete ESC sequence (assuming 8 chars is enough)
while (safe_poll(pfd, 1, 0) > 0 && n <= (sizeof(readbuffer) - 8)) {
while ((safe_poll(pfd, 1, 0) > 0)
&& ((size_t)n <= (sizeof(readbuffer) - 8))
) {
// read the rest of the ESC string
int r = safe_read(0, readbuffer + n, sizeof(readbuffer) - n);
int r = safe_read(STDIN_FILENO, readbuffer + n, sizeof(readbuffer) - n);
if (r > 0)
n += r;
}
@@ -2298,13 +2332,11 @@ static char get_one_char(void)
} else {
// adding STDIN chars to q
c = readit(); // get the users input
if (last_modifying_cmd != NULL) {
if (lmc_len >= MAX_INPUT_LEN - 1) {
status_line_bold("last_modifying_cmd overrun");
} else {
// add new char to q
last_modifying_cmd[lmc_len++] = c;
}
if (lmc_len >= MAX_INPUT_LEN - 1) {
status_line_bold("last_modifying_cmd overrun");
} else {
// add new char to q
last_modifying_cmd[lmc_len++] = c;
}
}
#else
@@ -2316,13 +2348,12 @@ static char get_one_char(void)
// Get input line (uses "status line" area)
static char *get_input_line(const char *prompt)
{
static char *buf; // [MAX_INPUT_LEN]
// char [MAX_INPUT_LEN]
#define buf get_input_line__buf
char c;
int i;
if (!buf) buf = xmalloc(MAX_INPUT_LEN);
strcpy(buf, prompt);
last_status_cksum = 0; // force status update
place_cursor(rows - 1, 0, FALSE); // go to Status line, bottom of screen
@@ -2348,6 +2379,7 @@ static char *get_input_line(const char *prompt)
}
refresh(FALSE);
return buf;
#undef buf
}
static int file_size(const char *fn) // what is the byte size of "fn"
@@ -2361,7 +2393,7 @@ static int file_size(const char *fn) // what is the byte size of "fn"
return cnt;
}
static int file_insert(const char * fn, char *p
static int file_insert(const char *fn, char *p
USE_FEATURE_VI_READONLY(, int update_ro_status))
{
int cnt = -1;
@@ -2373,18 +2405,11 @@ static int file_insert(const char * fn, char *p
status_line_bold("\"%s\" %s", fn, strerror(errno));
goto fi0;
}
if ((statbuf.st_mode & S_IFREG) == 0) {
if (!S_ISREG(statbuf.st_mode)) {
// This is not a regular file
status_line_bold("\"%s\" Not a regular file", fn);
goto fi0;
}
/* // this check is done by open()
if ((statbuf.st_mode & (S_IRUSR | S_IRGRP | S_IROTH)) == 0) {
// dont have any read permissions
status_line_bold("\"%s\" Not readable", fn);
goto fi0;
}
*/
if (p < text || p > end) {
status_line_bold("Trying to insert file outside of memory");
goto fi0;
@@ -2398,8 +2423,6 @@ static int file_insert(const char * fn, char *p
}
size = statbuf.st_size;
p = text_hole_make(p, size);
if (p == NULL)
goto fi0;
cnt = safe_read(fd, p, size);
if (cnt < 0) {
status_line_bold("\"%s\" %s", fn, strerror(errno));
@@ -2427,8 +2450,7 @@ static int file_insert(const char * fn, char *p
return cnt;
}
static int file_write(char * fn, char * first, char * last)
static int file_write(char *fn, char *first, char *last)
{
int fd, cnt, charcnt;
@@ -2437,14 +2459,19 @@ static int file_write(char * fn, char * first, char * last)
return -2;
}
charcnt = 0;
fd = open(fn, (O_WRONLY | O_CREAT | O_TRUNC), 0666);
/* By popular request we do not open file with O_TRUNC,
* but instead ftruncate() it _after_ successful write.
* Might reduce amount of data lost on power fail etc.
*/
fd = open(fn, (O_WRONLY | O_CREAT), 0666);
if (fd < 0)
return -1;
cnt = last - first + 1;
charcnt = full_write(fd, first, cnt);
ftruncate(fd, charcnt);
if (charcnt == cnt) {
// good write
//file_modified = FALSE; // the file has not been modified
//file_modified = FALSE;
} else {
charcnt = 0;
}
@@ -2694,8 +2721,10 @@ static void not_implemented(const char *s)
// show file status on status line
static int format_edit_status(void)
{
static int tot;
static const char cmd_mode_indicator[] ALIGN1 = "-IR-";
#define tot format_edit_status__tot
int cur, percent, ret, trunc_at;
// file_modified is now a counter rather than a flag. this
@@ -2746,13 +2775,14 @@ static int format_edit_status(void)
return ret; /* it all fit */
return trunc_at; /* had to truncate */
#undef tot
}
//----- Force refresh of all Lines -----------------------------
static void redraw(int full_screen)
{
place_cursor(0, 0, FALSE); // put cursor in correct place
clear_to_eos(); // tel terminal to erase display
clear_to_eos(); // tell terminal to erase display
screen_erase(); // erase the internal screen buffer
last_status_cksum = 0; // force status update
refresh(full_screen); // this will redraw the entire display
@@ -2824,13 +2854,13 @@ static char* format_line(char *src /*, int li*/)
//
static void refresh(int full_screen)
{
static int old_offset;
#define old_offset refresh__old_offset
int li, changed;
char *tp, *sp; // pointer into text[] and screen[]
if (ENABLE_FEATURE_VI_WIN_RESIZE) {
int c = columns, r = rows;
unsigned c = columns, r = rows;
get_terminal_width_height(0, &columns, &rows);
if (rows > MAX_SCR_ROWS) rows = MAX_SCR_ROWS;
if (columns > MAX_SCR_COLS) columns = MAX_SCR_COLS;
@@ -2912,6 +2942,7 @@ static void refresh(int full_screen)
place_cursor(crow, ccol, TRUE);
old_offset = offset;
#undef old_offset
}
//---------------------------------------------------------------------
@@ -3269,7 +3300,7 @@ static void do_cmd(char c)
case '.': // .- repeat the last modifying command
// Stuff the last_modifying_cmd back into stdin
// and let it be re-executed.
if (last_modifying_cmd != NULL && lmc_len > 0) {
if (lmc_len > 0) {
last_modifying_cmd[lmc_len] = 0;
ioq = ioq_start = xstrdup(last_modifying_cmd);
}
@@ -3743,7 +3774,7 @@ static void do_cmd(char c)
c1 = get_one_char(); // get the replacement char
if (*dot != '\n') {
*dot = c1;
file_modified++; // has the file been modified
file_modified++;
}
end_cmd_q(); // stop adding to q
break;
@@ -3788,10 +3819,10 @@ static void do_cmd(char c)
} // repeat cnt
if (islower(*dot)) {
*dot = toupper(*dot);
file_modified++; // has the file been modified
file_modified++;
} else if (isupper(*dot)) {
*dot = tolower(*dot);
file_modified++; // has the file been modified
file_modified++;
}
dot_right();
end_cmd_q(); // stop adding to q
@@ -4028,7 +4059,7 @@ static void crash_test()
printf("\n\n%d: \'%c\' %s\n\n\n%s[Hit return to continue]%s",
totalcmds, last_input_char, msg, SOs, SOn);
fflush(stdout);
while (safe_read(0, d, 1) > 0) {
while (safe_read(STDIN_FILENO, d, 1) > 0) {
if (d[0] == '\n' || d[0] == '\r')
break;
}
+57
View File
@@ -0,0 +1,57 @@
#!/bin/sh
#
# Simple depmod, use to generate modprobe.conf
#
# Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
#
# Licensed under GPLv2
#
local BASE="${1:-/usr/lib/modules}"
find "$BASE" -name '*.ko.gz' | while read I ; do
N=`basename "$I" '.ko.gz'`
echo -n "@$N"
zcat "$I" | strings | grep '^depends=' | sed -e 's/^depends=$//' -e 's/^depends=/,/' -e 's/,/ @/g'
done | awk '
{
# modules which has no dependencies are resolved
if ( NF == 1 ) { res[$1] = ""; next }
# others have to be resolved based on those which already resolved
i = $1; $1 = ""; deps[i] = $0; ++ndeps
}
END {
# resolve implicit dependencies
while ( ndeps ) for (mod in deps) {
if ( index(deps[mod], "@") > 0 ) {
$0 = deps[mod]
for ( i=1; i<=NF; ++i ) {
if ( substr($i,1,1) == "@" ) {
if ( $i in res ) {
$i = res[$i] " " substr($i,2)
}
}
}
deps[mod] = $0
} else {
res[mod] = deps[mod]
delete deps[mod]
--ndeps
}
}
# output dependencies in modules.dep format
for ( mod in res ) {
$0 = res[mod]
s = ""
delete a
for ( i=1; i<=NF; ++i ) {
if ( ! ($i in a) ) {
a[$i] = $i
s = " ," $i s
}
}
print "," substr(mod,2) ":" s
}
}
' | sort | sed -r -e "s!,([^,: ]*)!/usr/lib/modules/\\1.ko.gz!g"
Loaded 100 of 453 files, more files were not shown because too many files have changed in this diff. Show more