Compare commits

..
971 Commits
Author SHA1 Message Date
Denis Vlasenko 43f0a0bb3a apply all post-1.7.1 patches, set version to 1.7.2 2007-09-29 23:55:30 +00:00
Denis Vlasenko e755e827f7 apply post 1.7.0 patches, set version to 1.7.1 2007-09-16 18:50:56 +00:00
Denis Vlasenko ed6ac53104 Change version to 1.7.1.svn 2007-08-24 11:08:27 +00:00
Denis Vlasenko e1022a9d6a news.html: add 1.7.0 announcement 2007-08-24 10:28:55 +00:00
Denis Vlasenko f87f495e65 Update defconfig; fix comments 2007-08-24 10:27:41 +00:00
Denis Vlasenko 028f2d651c build system: stop moaning about unset integer CONFIGs. 2007-08-23 14:11:30 +00:00
Denis Vlasenko 6ee023cf62 *: compile fixes for 64-bit build 2007-08-23 10:52:52 +00:00
Denis Vlasenko de4c5d3d8c httpd: code shrink of dir indexer example 2007-08-23 10:43:18 +00:00
Denis Vlasenko c6c2345ca6 login: fixes for PAM build 2007-08-22 18:14:44 +00:00
Denis Vlasenko 5750782fca httpd: style fix in indexer example 2007-08-22 10:46:44 +00:00
Denis Vlasenko 7642998190 httpd: replace shell-based dir indexer cgi example with C-based one. 2007-08-22 10:38:44 +00:00
Denis Vlasenko 72b6a65b2f httpd: fix buglet in hex conversion. Remove alloca NULL checks
(never happens, app just crashes if stack overflows)
svlogd: cosmetic messages and style fixes
2007-08-21 11:18:25 +00:00
Denis Vlasenko d6e81c7762 login: optional support for PAM 2007-08-21 10:58:18 +00:00
Denis Vlasenko 18f2a6bc5e s/communal/common/ part 2 2007-08-21 10:54:59 +00:00
Denis Vlasenko f7d9e84bc5 s/communal/common/ 2007-08-21 10:54:34 +00:00
Denis Vlasenko e58e8d9444 httpd: add optional support for error pages
(by Pierre Metras <genepi@sympatico.ca>)
2007-08-21 10:26:55 +00:00
Denis Vlasenko 45946f8b51 runit/*: get rid of tai[a] time abstraction, it's too bloaty.
text    data     bss     dec     hex filename
 772537    1058   11092  784687   bf92f busybox.t0/busybox
 772459    1058   11060  784577   bf8c1 busybox.t1/busybox
 772326    1058   11028  784412   bf81c busybox.t2/busybox
 772158    1058   10980  784196   bf744 busybox.t3/busybox
 771490    1055   10988  783533   bf4ad busybox.t4/busybox
2007-08-20 17:27:40 +00:00
Denis Vlasenko 63db27f9f4 removed stray debugging comments 2007-08-19 21:24:37 +00:00
Denis Vlasenko 3f1123103c max_option_length[] holds small ints, uint8_t is enough
function                                             old     new   delta
max_option_length                                     44      11     -33
2007-08-19 21:21:16 +00:00
Denis Vlasenko d867f32a7a httpd: explain IP/mask parsing, and simplify it a bit.
parse_conf                                          1258    1247     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-11)             Total: -11 bytes
   text    data     bss     dec     hex filename
 772602    1058   11092  784752   bf970 busybox_old
 772594    1058   11092  784744   bf968 busybox_unstripped
2007-08-19 21:15:42 +00:00
Denis Vlasenko 921799da4e httpd: reinstate (much lighter) paranoid connection close code
allegedly needed for some versions of IE. +45 bytes.
2007-08-19 19:28:09 +00:00
Denis Vlasenko 37c3316fd7 httpd: get rid of rmt_port and setenv_log 2007-08-19 18:54:22 +00:00
Denis Vlasenko 52e15dc50b httpd: get rid of sscanf usage. Rename some variables. 2007-08-19 18:53:43 +00:00
Denis Vlasenko f9000c51db crond: code shrink 2007-08-19 18:49:21 +00:00
Denis Vlasenko d37f22225b libbb,crond,lash: fix getopt32 (don't know how it managed to slip through)
*: fcntl(fd, F_GETFL) doesn't require third parameter at all.
2007-08-19 13:42:08 +00:00
Denis Vlasenko b9c02dd791 crond: don't start sendmail with absolute path
crond: don't report obsolete version, report true bbox version
2007-08-18 15:48:00 +00:00
Denis Vlasenko fe7cd642b0 don't pass argc in getopt32, it's superfluous
(add/remove: 0/0 grow/shrink: 12/131 up/down: 91/-727) Total: -636 bytes
   text    data     bss     dec     hex filename
 773469    1058   11092  785619   bfcd3 busybox_old
 772644    1058   11092  784794   bf99a busybox_unstripped
2007-08-18 15:32:12 +00:00
Denis Vlasenko d6cd9d7fe9 httpd: stop reading headers using 1-byte read()
get_line                                              73     105     +32
httpd_main                                           769     766      -3
send_cgi_and_exit                                   1583    1577      -6
send_headers                                         449     432     -17
handle_incoming_and_exit                            2217    2172     -45
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 32/-71)            Total: -39 bytes
2007-08-18 14:22:09 +00:00
Denis Vlasenko 367960ba9a make standalone httpd work on NOMMU machines 2007-08-18 14:20:21 +00:00
Denis Vlasenko 9611cb1215 get rid of server_ and accepted_socket globals.
get_line                                              74      73      -1
log_and_exit                                          33      32      -1
send_headers                                         457     449      -8
httpd_main                                           906     892     -14
handle_incoming_and_exit                            2136    2113     -23
send_cgi_and_exit                                   1743    1583    -160
2007-08-18 14:18:43 +00:00
Denis Vlasenko a27a11bb2c introduce and use xdup2(int, int)
stop checking whether setsockopt_reuseaddr(int fd) was successful (it always is)
remove second parameter (sockllen) from xmalloc_sockaddr2xxxxx functions

sockaddr2str                                         142     156     +14
collect_blk                                          467     474      +7
xdup2                                                 28      33      +5
singlemount                                         4456    4454      -2
print_host                                           214     212      -2
nslookup_main                                        139     137      -2
ftpgetput_main                                       414     412      -2
udhcpd_main                                         1258    1255      -3
udhcpc_main                                         2405    2402      -3
traceroute_main                                     4125    4122      -3
nc_main                                             1072    1069      -3
buffer_fill_and_print                                 76      73      -3
xmalloc_sockaddr2hostonly_noport                      18      14      -4
xmalloc_sockaddr2host_noport                          18      14      -4
xmalloc_sockaddr2host                                 15      11      -4
xmalloc_sockaddr2dotted_noport                        18      14      -4
xmalloc_sockaddr2dotted                               18      14      -4
wget_main                                           2618    2614      -4
ping_main                                            393     389      -4
ip_port_str                                          120     115      -5
dhcprelay_main                                      1146    1141      -5
dnsd_main                                           1531    1525      -6
passwd_main                                         1110    1102      -8
udhcp_kernel_packet                                  206     197      -9
udhcp_listen_socket                                  154     144     -10
getty_main                                          2576    2566     -10
setup                                                655     640     -15
xmove_fd                                              51      34     -17
dolisten                                             759     742     -17
tcpudpsvd_main                                      1866    1836     -30
startservice                                         339     299     -40
2007-08-18 14:16:39 +00:00
Denis Vlasenko b98c26ad68 httpd shrink and logging update, part 7 of 7
text    data     bss     dec     hex filename
   9836       0       0    9836    266c busybox.t1/networking/httpd.o.orig
   9724       0       0    9724    25fc busybox.t2/networking/httpd.o
   9657       0       0    9657    25b9 busybox.t3/networking/httpd.o
   9342       0       0    9342    247e busybox.t4/networking/httpd.o
   9342       0       0    9342    247e busybox.t5/networking/httpd.o
   9262       0       0    9262    242e busybox.t6/networking/httpd.o
   9283       0       0    9283    2443 busybox.t7/networking/httpd.o
   9334       0       0    9334    2476 busybox.t8/networking/httpd.o
2007-08-17 19:21:12 +00:00
Denis Vlasenko feac3ce8c0 httpd shrink and logging update, part 6 of 7
text    data     bss     dec     hex filename
   9836       0       0    9836    266c busybox.t1/networking/httpd.o.orig
   9724       0       0    9724    25fc busybox.t2/networking/httpd.o
   9657       0       0    9657    25b9 busybox.t3/networking/httpd.o
   9342       0       0    9342    247e busybox.t4/networking/httpd.o
   9342       0       0    9342    247e busybox.t5/networking/httpd.o
   9262       0       0    9262    242e busybox.t6/networking/httpd.o
   9283       0       0    9283    2443 busybox.t7/networking/httpd.o
   9334       0       0    9334    2476 busybox.t8/networking/httpd.o
2007-08-17 19:20:39 +00:00
Denis Vlasenko 073214f894 httpd shrink and logging update, part 5 of 7
text    data     bss     dec     hex filename
   9836       0       0    9836    266c busybox.t1/networking/httpd.o.orig
   9724       0       0    9724    25fc busybox.t2/networking/httpd.o
   9657       0       0    9657    25b9 busybox.t3/networking/httpd.o
   9342       0       0    9342    247e busybox.t4/networking/httpd.o
   9342       0       0    9342    247e busybox.t5/networking/httpd.o
   9262       0       0    9262    242e busybox.t6/networking/httpd.o
   9283       0       0    9283    2443 busybox.t7/networking/httpd.o
   9334       0       0    9334    2476 busybox.t8/networking/httpd.o
2007-08-17 19:20:07 +00:00
Denis Vlasenko 91adf7d587 httpd shrink and logging update, part 4 of 7
text    data     bss     dec     hex filename
   9836       0       0    9836    266c busybox.t1/networking/httpd.o.orig
   9724       0       0    9724    25fc busybox.t2/networking/httpd.o
   9657       0       0    9657    25b9 busybox.t3/networking/httpd.o
   9342       0       0    9342    247e busybox.t4/networking/httpd.o
   9342       0       0    9342    247e busybox.t5/networking/httpd.o
   9262       0       0    9262    242e busybox.t6/networking/httpd.o
   9283       0       0    9283    2443 busybox.t7/networking/httpd.o
   9334       0       0    9334    2476 busybox.t8/networking/httpd.o
2007-08-17 19:19:42 +00:00
Denis Vlasenko e45af73dc2 httpd shrink and logging update, part 3 of 7
text    data     bss     dec     hex filename
   9836       0       0    9836    266c busybox.t1/networking/httpd.o.orig
   9724       0       0    9724    25fc busybox.t2/networking/httpd.o
   9657       0       0    9657    25b9 busybox.t3/networking/httpd.o
   9342       0       0    9342    247e busybox.t4/networking/httpd.o
   9342       0       0    9342    247e busybox.t5/networking/httpd.o
   9262       0       0    9262    242e busybox.t6/networking/httpd.o
   9283       0       0    9283    2443 busybox.t7/networking/httpd.o
   9334       0       0    9334    2476 busybox.t8/networking/httpd.o
2007-08-17 19:19:15 +00:00
Denis Vlasenko 241b1567ad httpd shrink and logging update, part 2 of 7
text    data     bss     dec     hex filename
   9836       0       0    9836    266c busybox.t1/networking/httpd.o.orig
   9724       0       0    9724    25fc busybox.t2/networking/httpd.o
   9657       0       0    9657    25b9 busybox.t3/networking/httpd.o
   9342       0       0    9342    247e busybox.t4/networking/httpd.o
   9342       0       0    9342    247e busybox.t5/networking/httpd.o
   9262       0       0    9262    242e busybox.t6/networking/httpd.o
   9283       0       0    9283    2443 busybox.t7/networking/httpd.o
   9334       0       0    9334    2476 busybox.t8/networking/httpd.o
2007-08-17 19:18:47 +00:00
Denis Vlasenko 1b97efd66a httpd shring and logging update, part 1 or 7
text    data     bss     dec     hex filename
   9836       0       0    9836    266c busybox.t1/networking/httpd.o.orig
   9724       0       0    9724    25fc busybox.t2/networking/httpd.o
   9657       0       0    9657    25b9 busybox.t3/networking/httpd.o
   9342       0       0    9342    247e busybox.t4/networking/httpd.o
   9342       0       0    9342    247e busybox.t5/networking/httpd.o
   9262       0       0    9262    242e busybox.t6/networking/httpd.o
   9283       0       0    9283    2443 busybox.t7/networking/httpd.o
   9334       0       0    9334    2476 busybox.t8/networking/httpd.o
2007-08-17 19:18:06 +00:00
Denis Vlasenko 72d260dbda remove stray newline from help text 2007-08-17 08:45:58 +00:00
Denis Vlasenko 856be770a6 assorted fixes for breakage found by randomconfig 2007-08-17 08:29:48 +00:00
Denis Vlasenko 7f175ccbc3 add comments regarding SO_REUSEADDR 2007-08-16 18:27:47 +00:00
Denis Vlasenko 06b064c28d Comment out "#include <strings.h>" everywhere 2007-08-16 11:29:08 +00:00
Denis Vlasenko 838dacaa00 find: fix SELinux-related warning 2007-08-16 10:41:24 +00:00
Denis Vlasenko f848305afc modprobe: add scanning of /lib/modules/uname -r/modules.symbols
(by Yann E. MORIN)
2007-08-16 10:40:06 +00:00
Denis Vlasenko a0319ba936 hdparm: shrink rodata by ~250 bytes 2007-08-16 10:37:49 +00:00
Denis Vlasenko 6a2f7f41cf whitespace fixes, no code changes 2007-08-16 10:35:17 +00:00
Denis Vlasenko 033e592cbc more: by Tristan Schmelcher <tpkschme@engmail.uwaterloo.ca>:
- Fixed a number of deficiencies in the line wrapping.
- Fixed a bug where the page could scroll multiple times per keypress.
- Re-read terminal dimensions after user input, in case they
  resized the terminal while we were waiting.
- Added an 'R' key to print the rest of the file without prompting.
- Crudely support tabs in the line-wrapping code by converting
  them to 8 spaces.
2007-08-15 20:42:52 +00:00
Denis Vlasenko ab9c44b1a4 v[hp]error_msg have 2-3 callsites only -> incorporate there. 2007-08-15 20:07:53 +00:00
Denis Vlasenko bb23c06919 if pidfile turned out to be !regular file, do not unlink it.
It's most probably the /dev/null.
2007-08-15 20:05:37 +00:00
Denis Vlasenko 9f7b92a2e1 dhcpd: make -S and -f actually work 2007-08-15 20:03:36 +00:00
Denis Vlasenko 384b1d12f9 httpd: add -v[v]: prints client addresses, HTTP codes returned [and URLs]
get_line                                               -      70     +70
packed_usage                                       22811   22863     +52
handle_incoming_and_exit                            2246    2277     +31
httpd_main                                          1141    1155     +14
sendHeaders                                          489     482      -7
getLine                                               77       -     -77
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 3/1 up/down: 167/-84)            Total: 83 bytes
   text    data     bss     dec     hex filename
 774335    1058   11092  786485   c0035 busybox_old
 774447    1058   11092  786597   c00a5 busybox_unstripped
2007-08-14 16:55:01 +00:00
Denis Vlasenko 0372f0f199 httpd: extend -p PORT to -p [IP[v6]:]PORT
httpd: comment out strange code which "closes connection properly"
(isnt exit(0) good enough?)

handle_incoming_and_exit                               -    2246   +2246
httpd_main                                          1116    1141     +25
getLine                                               75      77      +2
packed_usage                                       22827   22811     -16
parse_conf                                          1303    1284     -19
shutdown                                              32       -     -32
handleIncoming                                      2578       -   -2578
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/2 up/down: 2273/-2645)       Total: -372 bytes
   text    data     bss     dec     hex filename
 774704    1058   11092  786854   c01a6 busybox_old
 774335    1058   11092  786485   c0035 busybox_unstripped
2007-08-14 16:50:01 +00:00
Denis Vlasenko 3d17d2b430 udhcpd: add -f "foreground" and -S "syslog" options
udhcpc: add -S "syslog" options
remove CONFIG_FEATURE_UDHCP_SYSLOG

function                                             old     new   delta
udhcpd_main                                         1168    1201     +33
udhcpc_main                                         2414    2425     +11
static.udhcpc_longopts                               191     200      +9
qgravechar                                           112     108      -4
packed_usage                                       22843   22827     -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 53/-20)             Total: 33 bytes
2007-08-14 16:45:29 +00:00
Denis Vlasenko dbe6e66d6a trylink: automatically use custom link script if user provides one
vinfo_msg: one user (info_msg), incorporate in it
*: style fixes
2007-08-14 16:43:01 +00:00
Denis Vlasenko a1120a8ea2 syslogd: set syslog IPC buffer to mode 0644 2007-08-14 10:27:56 +00:00
Denis Vlasenko 3952f20c24 expand, unexpand: new applets from Tito <farmatito@tiscali.it> 2007-08-13 14:10:24 +00:00
Denis Vlasenko 08294dbf5b df: match coreutils behavior of wrapping lines if filesystem name is too long.
df: trim help text
2007-08-13 12:27:49 +00:00
Denis Vlasenko 319f8ebef8 httpd: round down sendfile byte count to 64k
*: style fixes
2007-08-13 11:09:30 +00:00
Denis Vlasenko f5635f4d32 usage.h: style cleanup 2007-08-13 10:48:33 +00:00
Denis Vlasenko e324184c05 s/#ifdef CONFIG_/#if ENABLE_/g 2007-08-13 10:36:25 +00:00
Denis Vlasenko 5f1b149d54 syslogd,logread: get rid of head pointer, fix logread bug in the process
function                                             old     new   delta
logread_main                                         450     462     +12
syslogd_main                                        1246    1252      +6
shbuf                                                  -       4      +4
buf                                                   34      30      -4
packed_usage                                       22729   22724      -5
log_locally                                          957     767    -190
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/3 up/down: 22/-199)          Total: -177 bytes
   text    data     bss     dec     hex filename
 773886    1116   11316  786318   bff8e busybox_old
 773714    1116   11316  786146   bfee2 busybox_unstripped
2007-08-12 21:33:06 +00:00
Denis Vlasenko 1b9064d535 httpd: sendfile support 2007-08-12 21:05:49 +00:00
Denis Vlasenko ff65cd469b fix out-of-source-tree build 2007-08-12 20:59:07 +00:00
Denis Vlasenko 6ca409e0e4 trylink: produce even more info about final link stage
trylink: explain how to modify link and drastically decrease amount
  of padding (unfortunately, needs hand editing ATM).
*: add ALIGN1 / ALIGN2 to global strings and arrays of bytes and shorts

size saving: 0.5k
2007-08-12 20:58:27 +00:00
Denis Vlasenko 4185548984 httpd: CGI Status: header fix 2007-08-11 20:26:02 +00:00
Denis Vlasenko 1ec15cd818 httpd: add support for Status: CGI header 2007-08-11 20:20:43 +00:00
Denis Vlasenko e5d37ccb6e httpd: fix CGI handling bug (we were closing wrong fd). 2007-08-11 20:20:02 +00:00
Denis Vlasenko f893da875a ls,ps,watch: measure terminal width on fd 0, not 1 2007-08-09 08:27:24 +00:00
Denis Vlasenko 501bfe2630 stat: fix option -Z segv (bug 1454) 2007-08-09 08:10:13 +00:00
Denis Vlasenko 22a80d1e7d udhcpd: fix bug: s/memcmp() != 0/memcmp() == 0/
(by David Updegraff <dave@cray.com>)
2007-08-09 08:04:05 +00:00
Denis Vlasenko e5dbba22af bb_uudecode: now this is the more thorough fix... I hope... 2007-08-06 15:49:12 +00:00
Denis Vlasenko 4661117911 bb_uuencode: fix obscure case where we were using data past last byte of source
(fixes testsuite failure)

bb_uuencode                                          154     160      +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 6/0)                 Total: 6 bytes
   text    data     bss     dec     hex filename
 770284    1096   11228  782608   bf110 busybox_old
 770288    1096   11228  782612   bf114 busybox_unstripped
2007-08-06 15:43:17 +00:00
Denis Vlasenko eea72123a3 patch: fix -p -1 handling
checkstack.pl: add blackfin (by Alex Landau <landau_alex@yahoo.com>)
2007-08-06 13:34:10 +00:00
Denis Vlasenko 8e209c3787 catv: catv without arguments was trying to use environ as argv.
(Alex Landau <landau_alex@yahoo.com>)
2007-08-06 12:28:24 +00:00
Denis Vlasenko 73f21e9cb3 trylink: s/&& exit 1/|| exit 1/ (spotted by Alex Landau <landau_alex@yahoo.com>) 2007-08-06 12:18:01 +00:00
Denis Vlasenko 8274e06677 sed: fix 'q' command handling ("Nguyen Thai Ngoc Duy" <pclouds@gmail.com>)
add testsuite entry for it. Fix applet order checker. Fix cmp yelling.
trylink: fix error file and map file generation
applets: fix applet order
2007-08-06 03:41:08 +00:00
Denis Vlasenko e013475830 env: micro-optimization
printenv: fix "printenv VAR1 VAR2" bug (wasn't printing VAR2)
(spotted by kalyanatejaswi balabhadrapatruni <kalyanatejaswi@yahoo.co.in>)

env_main                                             267     260      -7
printenv_main                                        147      75     -72
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-79)             Total: -79 bytes
   text    data     bss     dec     hex filename
 770336    1096   11228  782660   bf144 busybox_old
 770256    1096   11228  782580   bf0f4 busybox_unstripped
2007-08-06 02:55:41 +00:00
Denis Vlasenko 84d71f33f5 setfiles:
* Bug fix: -f option did not work.
* Using bb_simplify_path to remove extra slash for smaller code.
(by Yuichi Nakamura <ynakam@hitachisoft.jp>)
2007-08-06 02:36:35 +00:00
Denis Vlasenko 46340e398e less: add a bit more robustness in keyboard reading code 2007-08-03 14:17:21 +00:00
Denis Vlasenko 0e2c9fb4e0 mount: print errno on NFS error (again) 2007-08-03 14:16:24 +00:00
Denis Vlasenko f223efbcde svlogd: fix timestamping; do not warn if config is missing
sv: extend help text
2007-08-03 10:58:12 +00:00
Denis Vlasenko 9a3b7b1db7 ttysize: update copyright 2007-08-03 08:48:44 +00:00
Denis Vlasenko 80edead5ea udhcp: slight shrink
udhcpd_main                                         1171    1208     +37
udhcpc_main                                         2363    2387     +24
dhcprelay_main                                      1145    1146      +1
dhcprelay_stopflag                                     4       1      -3
dhcprelay_signal_handler                              11       8      -3
client_background                                     46      42      -4
udhcp_read_interface                                 230     211     -19
udhcp_make_pidfile                                    76       -     -76
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 3/4 up/down: 62/-105)           Total: -43 bytes
   text    data     bss     dec     hex filename
 770052    1096   11228  782376   bf028 busybox_old
 769980    1096   11228  782304   befe0 busybox_unstripped
2007-08-02 22:31:05 +00:00
Denis Vlasenko c01af95c39 ttysize: new applet. +200 bytes 2007-08-02 22:23:47 +00:00
Denis Vlasenko 1caca34aa6 start_stop_daemon: NOMMU fixes, round 2 by Alex Landau <landau_alex@yahoo.com>
dhcpc: fixed "ifupdown + udhcpc_without_pidpile_creation" bug
2007-08-02 10:14:29 +00:00
Denis Vlasenko fc77eb54e7 patch: fix bad line ending handling ("Nguyen Thai Ngoc Duy" <pclouds@gmail.com>) 2007-08-01 23:30:54 +00:00
Denis Vlasenko a1b16f4d5c start_stop_daemon: NOMMU fix; smaller fixes 2007-07-31 17:09:44 +00:00
Denis Vlasenko f1f1b69dc1 addgroup: "disallow addgroup -g num user group"; make -g 0 work
(Tito <farmatito@tiscali.it>)
2007-07-30 12:32:37 +00:00
Denis Vlasenko 980864de08 dd: use unsigned printf specifier for # of blocks 2007-07-30 10:58:09 +00:00
Denis Vlasenko 2b03e5ef31 dd: fix newly introduced bug (introduced by me) 2007-07-29 14:59:06 +00:00
Denis Vlasenko 6b74b0241c interface.c: code shrink (IIRC ~30 bytes) 2007-07-29 14:17:48 +00:00
Denis Vlasenko dee82b6b78 ash: comment non-obvious code part 2007-07-29 14:05:27 +00:00
Denis Vlasenko 1bab1de698 fix for suffix optimization (which was in previous commit) 2007-07-27 15:30:39 +00:00
Denis Vlasenko f868963c67 multiplier suffixes are short, store them directly in struct suffix_mult
function                                             old     new   delta
xstrtoul_range_sfx                                   226     217      -9
xstrtoull_range_sfx                                  291     280     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-20)             Total: -20 bytes
   text    data     bss     dec     hex filename
 669128    2668   13616  685412   a7564 busybox_old
 669108    2668   13616  685392   a7550 busybox_unstripped
2007-07-27 15:06:25 +00:00
Denis Vlasenko 7587870617 dd: fix bug where we assume count=INT_MAX when count is unspecified;
shrink dd while at it

function                                             old     new   delta
dd_main                                             1453    1368     -85
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-85)             Total: -85 bytes
   text    data     bss     dec     hex filename
 669216    2668   13616  685500   a75bc busybox_old
 669128    2668   13616  685412   a7564 busybox_unstripped
2007-07-27 15:02:00 +00:00
Denis Vlasenko 1d10aaf116 passwd: fix bug: we are trying to update shadow even if user's record is in passwd!
getspnam is guilty, it lies that user record exists in shadow.
2007-07-27 11:22:34 +00:00
Denis Vlasenko 3734b946bf bb_getpwuid, bb_getgrgid: change order of arguments to more intuitive one;
comment thoroughly when they die and when they dont.
2007-07-27 11:20:10 +00:00
Denis Vlasenko 661f6fad77 cal: small code shrink 2007-07-26 11:12:51 +00:00
Denis Vlasenko 972fa099e6 setfiles: small code size reduction (Yuichi Nakamura <ynakam@hitachisoft.jp>) 2007-07-25 17:39:46 +00:00
Denis Vlasenko 7ce7594fa3 ps: fix non-desktop ps -ww -- thanks rockeychu 2007-07-25 17:27:58 +00:00
Denis Vlasenko f4cee7a174 getopt32: fix getopt32 breakage (forgot to memset(0) it) -- thanks rockeychu 2007-07-25 17:18:06 +00:00
Denis Vlasenko 990d0f63ee Replace index_in_[sub]str_array with index_in_[sub]strings,
which scans thru "abc\0def\0123\0\0" type strings. Saves 250 bytes.

   text    data     bss     dec     hex filename
 781266    1328   11844  794438   c1f46 busybox_old
 781010    1328   11844  794182   c1e46 busybox_unstripped
2007-07-24 15:54:42 +00:00
Denis Vlasenko bcb66ec22e od: shrink a bit
verbose                                               12      13      +1
open_next_file                                       102      99      -3
limit_bytes_to_format                                  4       1      -3
ioerror                                                4       1      -3
flag_pseudo_start                                      4       1      -3
flag_dump_strings                                      4       1      -3
abbreviate_duplicate_blocks                            4       -      -4
check_and_close                                       96      90      -6
od_main                                             2988    2955     -33
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/7 up/down: 1/-58)             Total: -57 bytes
   text    data     bss     dec     hex filename
 781314    1328   11876  794518   c1f96 busybox_old
 781266    1328   11844  794438   c1f46 busybox_unstripped
2007-07-24 12:28:03 +00:00
Denis Vlasenko 1da77728d7 setfiles: small tweaks to usage text and code 2007-07-24 06:17:43 +00:00
Denis Vlasenko 3e64e98570 zcip: remove stray seed48. It's the only thing which was pulling in
rand48 machinery:

zcip_main                                           1552    1537     -15
seed48                                                22       -     -22
__libc_drand48_data                                   24       -     -24
seed48_r                                              78       -     -78
__GI_seed48_r                                         78       -     -78
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 0/1 up/down: 0/-217)           Total: -217 bytes
2007-07-23 22:44:15 +00:00
Denis Vlasenko 65b8cfb2a0 add comment why preferred stack boundary is 4 on i386 2007-07-23 21:05:06 +00:00
Denis Vlasenko 64a8a3bd74 chpasswd: rename long options definition to match other applets. no code changes 2007-07-23 18:49:16 +00:00
Denis Vlasenko 5bfcb4d5ae getopt32 must remain NOFORK-safe (no mallocs!). Using alloca and pretending
stack is infinite. Unfortunately, +79 bytes.
2007-07-23 17:40:35 +00:00
Denis Vlasenko bdc88fdc68 rework long option handling. saves ~1.2k
function                                             old     new   delta
tar_longopts                                           -     222    +222
static.udhcpc_longopts                                 -     192    +192
start_stop_daemon_longopts                             -     150    +150
getopt32                                            1045    1185    +140
static.wget_longopts                                   -     111    +111
static.od_longopts                                     -     105    +105
getopt_longopts                                        -      96     +96
install_longopts                                       -      67     +67
ipcalc_longopts                                        -      63     +63
static.hwclock_longopts                                -      54     +54
ftpgetput_longopts                                     -      52     +52
static.dumpleases_longopts                             -      32     +32
env_longopts                                           -      31     +31
runparts_longopts                                      -      30     +30
mv_longopts                                            -      24     +24
mkdir_longopts                                         -      19     +19
find_pair                                            164     180     +16
bb_null_long_options                                   -      16     +16
setconsole_longopts                                    -      10     +10
display_speed                                         91      98      +7
collect_blk                                          467     474      +7
show_color                                             4       1      -3
ls_main                                              913     904      -9
bb_default_long_options                               16       -     -16
ls_color_opt                                          32      10     -22
setconsole_long_options                               32       -     -32
arith                                               2077    2030     -47
mv_long_options                                       48       -     -48
mkdir_long_options                                    48       -     -48
env_long_options                                      48       -     -48
static.options                                       248     184     -64
runparts_long_options                                 80       -     -80
ftpgetput_long_options                                96       -     -96
static.hwclock_long_options                          112       -    -112
install_long_options                                 112       -    -112
static.long_options                                  144       -    -144
static.wget_long_options                             160       -    -160
longopts                                             160       -    -160
static.arg_options                                   304       -    -304
tar_long_options                                     320       -    -320
long_options                                         384       -    -384
------------------------------------------------------------------------------
(add/remove: 17/15 grow/shrink: 4/5 up/down: 1444/-2209)     Total: -765 bytes
   text    data     bss     dec     hex filename
 782618    1328   11900  795846   c24c6 busybox_old
 781354    1328   11900  794582   c1fd6 busybox_unstripped
2007-07-23 17:14:14 +00:00
Denis Vlasenko 9fe9c1a6d8 setiles: cosmetics, no real code changes 2007-07-23 14:05:02 +00:00
Denis Vlasenko 397137b815 setfiles,restorecon: new SELinux applets by Yuichi Nakamura <ynakam@hitachisoft.jp> 2007-07-23 14:03:30 +00:00
Denis Vlasenko 845db2acf3 chpasswd: fix indentation 2007-07-21 22:29:26 +00:00
Denis Vlasenko b71c668c57 style fix (stray space before ';') 2007-07-21 15:08:09 +00:00
Denis Vlasenko 82bd9ee645 fix typo in last commit 2007-07-21 15:07:22 +00:00
Denis Vlasenko 6cd84dac84 Three patches from FreeWRT people 2007-07-21 14:57:54 +00:00
Denis Vlasenko e8feca085d chpasswd: fixes for shadow password handling 2007-07-21 13:54:26 +00:00
Denis Vlasenko 091965768d libbb: nuke BB_GETOPT_ERROR, always die if there are mutually exclusive options
find_pair                                            164     180     +16
passwd_main                                         1222    1230      +8
display_speed                                         91      96      +5
msh_main                                            1335    1339      +4
qrealloc                                              38      36      -2
refresh                                             1190    1182      -8
cut_main                                             543     532     -11
sendCgi                                             1807    1794     -13
getopt32                                            1063    1045     -18
arith                                               2077    2030     -47
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/6 up/down: 33/-99)            Total: -66 bytes
   text    data     bss     dec     hex filename
 781548    1168   11900  794616   c1ff8 busybox_old
 781452    1168   11900  794520   c1f98 busybox_unstripped
2007-07-21 13:27:44 +00:00
Denis Vlasenko 557fb713e0 chpasswd: fixes and code shrink
update_passwd                                        732     734      +2
chpasswd_main                                        318     292     -26
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 2/-26)             Total: -24 bytes
   text    data     bss     dec     hex filename
 781564    1168   11900  794632   c2008 busybox_old
 781548    1168   11900  794616   c1ff8 busybox_unstripped
2007-07-21 13:25:28 +00:00
Denis Vlasenko 1ec5eaecba chpasswd: now with svn add 2007-07-20 21:29:49 +00:00
Denis Vlasenko 21d1014b5b chpasswd: new applet by Alexander Shishkin <virtuoso@slind.org> 2007-07-20 21:28:41 +00:00
Denis Vlasenko 2f6ae43b9c stray trailing tabs removed 2007-07-19 22:50:47 +00:00
Denis Vlasenko 2a86a61c27 ifup/ifdown: make location of ifstate configurable 2007-07-19 21:49:30 +00:00
Denis Vlasenko 2414a96faa vi: comment out dead code 2007-07-18 22:03:40 +00:00
Denis Vlasenko b69e872229 Trim help text. With compressed help: -143 bytes
text    data     bss     dec     hex filename
 772572    1168   22680  796420   c2704 busybox_old
 772444    1168   22680  796292   c2684 busybox_unstripped
2007-07-18 21:57:24 +00:00
Denis Vlasenko d4293c77f1 ash: fix SEGV in forkchild (jp can be NULL). here documents were affected. 2007-07-18 21:35:43 +00:00
Denis Vlasenko de1c8b2e92 fix unpacker testsuite to match actual output 2007-07-18 18:47:13 +00:00
Denis Vlasenko 960eca66b5 awk: actually do "svn add" for testsuite 2007-07-18 18:33:18 +00:00
Denis Vlasenko af1bd09625 awk: fix -F 'regex' bug (miscounted fields if last field is empty) 2007-07-18 18:32:25 +00:00
Denis Vlasenko b78c782c85 awk: style fixes; remove one xstrdup/free pair; testsuite 2007-07-18 18:31:11 +00:00
Denis Vlasenko 91afdf8096 vi: style fixlet 2007-07-17 23:22:49 +00:00
Denis Vlasenko a3d15c8be7 fix typo in prev commit :( 2007-07-17 23:19:28 +00:00
Denis Vlasenko 27da707d06 vi: s/argv[0]/applet_name/ 2007-07-17 23:18:26 +00:00
Denis Vlasenko eaabf0675f vi: multiple fixes by Natanael Copa <natanael.copa@gmail.com>
* the puzzling message on error is replaced with strerror(errno)
  so it should be even more detailed and smaller at the same time.
* merged code in edit_file() and code for ':edit <file>' in colon() into
  new func init_text_buffer(). Was horribly duplicate. Moved most of
  error/sanity checking to file_insert(). Result is that you get a proper
  validation (prevent reading /dev/*) and error messages for ':r <file>' 
* renamed 'cfn' to 'current_filename' for improved readability
* merged smallint vi_readonly and readonly into bitfields into
  readonly_mode to save space.
* added text_size variable to keep track how big the text buffer is.
  This is used to fix a buffer overflow. To reproduce bug:
  ./busybox vi TODO
  :r Makefile
  vi segfaults due to no buffer checking is done at all. som redesign is
  needed here but i added a check in text_hole_make() to aviod the
  segfault at least.
* removed isblnk() and use isblank(3) instead.
* fixed compiler warning by displaying the return code for :!<command>
  This makes things bigger than needed but since the patch reduces the
  overall size... (see below)
* new func next_tabstop(int) merges some duplicate code. There are more
  cuplicode here but i couldnt find a good way to merge them.
* Fix *ANNOYING* placement of cursor on '\t' characters. To reproduce:
    echo -e "\thello" > file1
    ./busybox vi file1
  Try to insert some text at the beginning of line. Text will be inserted
  but cursor is blinking somewhere else. The patch should make busybox vi
  behave more like original vi(m). Costs a few bytes but its worth it
  imho.
* new_text() is moved into init_text_buffer()
* the previously added update_ro_status() was moved info file_insert due
  to duplication removal mentioned above.
function                                             old     new   delta
init_text_buffer                                       -     245    +245
file_insert                                          312     420    +108
next_tabstop                                           -      82     +82
text_hole_make                                       154     171     +17
do_cmd                                              5093    5100      +7
static.cmd_mode_indicator                              -       5      +5
refresh                                             1248    1253      +5
current_filename                                       -       4      +4
yank_delete                                          161     164      +3
what_reg                                              96      99      +3
end_cmd_q                                             78      81      +3
char_insert                                          440     442      +2
readonly_mode                                          -       1      +1
vi_readonly                                            1       -      -1
setops                                               154     153      -1
readonly                                               1       -      -1
vi_setops                                              4       1      -3
string_insert                                        161     158      -3
cfn                                                    4       -      -4
show_status_line                                     532     514     -18
readit                                               519     500     -19
move_to_col                                          161     138     -23
vi_main                                              495     433     -62
isblnk                                                75       -     -75
.rodata                                             4751    4655     -96
edit_file                                            892     787    -105
new_text                                             125       -    -125
update_ro_status                                     131       -    -131
colon                                               3848    3667    -181
------------------------------------------------------------------------------
(add/remove: 5/6 grow/shrink: 8/10 up/down: 485/-848)        Total: -363
bytes
   text    data     bss     dec     hex filename
  34751     873    4260   39884    9bcc busybox_old
  34439     877    4260   39576    9a98 busybox_unstripped
2007-07-17 23:14:07 +00:00
Denis Vlasenko 2851082d5d ifconfig: make it work with ifaces with ifnames > 255 2007-07-17 22:53:05 +00:00
Denis Vlasenko 49a128a156 remove accumulated stray trailing whitespace 2007-07-17 21:42:59 +00:00
Denis Vlasenko 150d2fa114 Modify method of linking against libs. Now we fisrt try all
specified libs, and if it succeeds, we try to remove them
one-by-one. If link succeeds, then library is thrown out.
Should solve the problem with SELinux linking in libsepol
even when not needed.
2007-07-17 20:39:27 +00:00
Denis Vlasenko c5f2426838 fix discrepancy in GPL version number. Pointed out by "Marsh David" <dmarsh@bigw.com.au> 2007-07-16 22:21:15 +00:00
Denis Vlasenko 110967a6f7 top: nested function allows us to reuse some code
(not everyone likes them - but code does get smaller).

display_generic                                        -     761    +761
static.fmt_100percent_8                                -     111    +111
fmt_100percent_8                                     101       -    -101
display_status                                      1489     581    -908
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 0/1 up/down: 872/-1009)        Total: -137 bytes
   text    data     bss     dec     hex filename
 677020    3344   13936  694300   a981c busybox_old
 676876    3344   13936  694156   a978c busybox_unstripped
2007-07-15 19:27:48 +00:00
Denis Vlasenko 24c5fbaf42 top: make "100%" case less ugly, and shrink code while at it
fmt_100percent_8                                       -     101    +101
.rodata                                           129185  129153     -32
display_status                                      1726    1489    -237
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/2 up/down: 101/-269)         Total: -168 bytes
   text    data     bss     dec     hex filename
 677180    3344   13936  694460   a98bc busybox_old
 677020    3344   13936  694300   a981c busybox_unstripped
2007-07-15 19:25:01 +00:00
Denis Vlasenko c1166c3a8c top: simpler loadavg processing
display_status                                      1787    1726     -61
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-61)             Total: -61 bytes
   text    data     bss     dec     hex filename
 677244    3344   13936  694524   a98fc busybox_old
 677180    3344   13936  694460   a98bc busybox_unstripped
2007-07-15 19:23:38 +00:00
Denis Vlasenko 9109fbeaa1 top: truncate usernames to 8 chars 2007-07-15 17:07:58 +00:00
Denis Vlasenko 4652daace9 grep: implement -m MAX_MATCHES; fix help text
grep_file                                            771     822     +51
packed_usage                                       22573   22610     +37
.rodata                                           128058  128090     +32
grep_main                                            842     853     +11
max_matches                                            -       4      +4
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/0 up/down: 135/0)             Total: 135 bytes
2007-07-15 12:39:08 +00:00
Denis Vlasenko 8d5aa870a6 grep: fix buglets with context printing
print_line                                           152     170     +18
did_print_line                                         -       1      +1
grep_file                                            788     771     -17
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 19/-17)              Total: 2 bytes
   text    data     bss     dec     hex filename
 673368    2740   13968  690076   a879c busybox_old
 673368    2740   13968  690076   a879c busybox_unstripped
2007-07-15 12:38:18 +00:00
Denis Vlasenko bdc406d15d ash: make "jobs | cat" work like in bash (was giving empty output) 2007-07-15 01:13:25 +00:00
Denis Vlasenko 39125bec38 adduser: close /etc/{passwd,shadow} before calling passwd etc.
Spotted by Natanael Copa <natanael.copa@gmail.com>
2007-07-14 22:51:28 +00:00
Denis Vlasenko 59a1f30450 vi: make status line less confusing when we open non-readable files,
require rood to use w! when saving non-writable files.
Patch by Natanael Copa <natanael.copa@gmail.com>

update_ro_status                                       -      73     +73
edit_file                                            819     822      +3
colon                                               3440    3425     -15
.rodata                                           128090  128058     -32
file_insert                                          288     235     -53
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/3 up/down: 76/-100)           Total: -24 bytes
   text    data     bss     dec     hex filename
 673344    2740   13968  690052   a8784 busybox_old
 673320    2740   13968  690028   a876c busybox_unstripped
2007-07-14 22:43:10 +00:00
Denis Vlasenko fb79a2e2cf xioctl and friends by Tito <farmatito@tiscali.it>
function                                             old     new   delta
do_iptunnel                                          203     977    +774
process_dev                                         5328    5494    +166
ioctl_or_perror                                        -      54     +54
ioctl_or_perror_and_die                                -      51     +51
ioctl_alt_func                                         -      49     +49
bb_ioctl_or_warn                                       -      47     +47
do_add_ioctl                                         102     145     +43
bb_xioctl                                              -      39     +39
print_value_on_off                                     -      31     +31
get_lcm                                              105     123     +18
arp_main                                            2155    2167     +12
..................
zcip_main                                           1576    1566     -10
setlogcons_main                                       92      82     -10
dumpkmap_main                                        263     253     -10
do_get_ioctl                                          85      75     -10
setkeycodes_main                                     165     154     -11
write_table                                          244     232     -12
vconfig_main                                         318     306     -12
do_del_ioctl                                          93      81     -12
set_address                                           75      62     -13
maybe_set_utc                                         30      16     -14
loadfont_main                                        495     479     -16
slattach_main                                        712     695     -17
do_loadfont                                          191     174     -17
do_iplink                                           1155    1136     -19
getty_main                                          2583    2562     -21
fbset_main                                          2058    2035     -23
do_time                                              588     565     -23
xioctl                                                25       -     -25
read_rtc                                             186     160     -26
parse_conf                                          1299    1270     -29
udhcp_read_interface                                 269     239     -30
bb_ioctl                                              45       -     -45
bb_ioctl_alt                                          70       -     -70
bb_ioctl_on_off                                       78       -     -78
.rodata                                           129370  129018    -352
do_show                                              799       -    -799
------------------------------------------------------------------------------
(add/remove: 6/5 grow/shrink: 13/49 up/down: 1316/-1864)     Total: -548 bytes
   text	   data	    bss	    dec	    hex	filename
 675352	   2740	  13968	 692060	  a8f5c	busybox_old
 674804	   2740	  13968	 691512	  a8d38	busybox_unstripped
2007-07-14 22:07:14 +00:00
Denis Vlasenko fcfaf2e18a ash: small size optimization
function                                             old     new   delta
makejob                                              263     270      +7
setjobctl                                            328     332      +4
jobscmd                                               96      94      -2
stoppedjobs                                           53      50      -3
jobctl                                                 4       1      -3
job_warning                                            4       1      -3
forkshell                                            644     641      -3
cmdloop                                              422     409     -13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/6 up/down: 11/-27)            Total: -16 bytes
   text    data     bss     dec     hex filename
 675392    2740   13968  692100   a8f84 busybox_old
 675380    2740   13968  692088   a8f78 busybox_unstripped
2007-07-14 18:45:37 +00:00
Denis Vlasenko 8fdc4b7b06 ash: recognize -l as --login equivalent; do not recognize +-login 2007-07-14 11:33:10 +00:00
Denis Vlasenko 40ba9984fd ash: fix for buglet in DEBUG code (Nguyen Thai Ngoc Duy <pclouds@gmail.com>) 2007-07-14 00:48:29 +00:00
Denis Vlasenko 153cd695e4 FAQ: add timezone Q 2007-07-13 15:26:53 +00:00
Denis Vlasenko 828e2a95da nc: minor code shrink
function                                             old     new   delta
dolisten                                             731     737      +6
tmtravel                                              32      21     -11
catch                                                 75      64     -11
oprint                                               272     229     -43
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 6/-65)             Total: -59 bytes
   text    data     bss     dec     hex filename
 676698    3340   13936  693974   a96d6 busybox_old
 676650    3340   13936  693926   a96a6 busybox_unstripped
2007-07-13 12:37:31 +00:00
Mike Frysinger 8cc9cb8bc5 remove last source id 2007-07-13 05:03:46 +00:00
Mike Frysinger d611cccd81 add support for --symbol-prefix/-P 2007-07-13 04:37:12 +00:00
Denis Vlasenko c540e75d74 fix applet order error 2007-07-06 16:57:06 +00:00
Denis Vlasenko d166f83d74 md5_sha1_sum: fix mishandling when run as /bin/md5sum (with path)
chown/chgrp: completely match coreutils 6.8 wrt symlink handling

function                                             old     new   delta
recursive_action                                     411     422     +11
arith                                               2033    2042      +9
collect_blk                                          467     474      +7
dhcprelay_main                                      1122    1125      +3
fsck_main                                           1909    1911      +2
singlemount                                         4555    4547      -8
xmalloc_realpath                                      14       -     -14
get_lcm                                              123     105     -18
ed_main                                             3111    3084     -27
chown_main                                           217     183     -34
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 5/4 up/down: 32/-101)           Total: -69 bytes
   text    data     bss     dec     hex filename
 684132    2744   14000  700876   ab1cc busybox_old
 684060    2744   14000  700804   ab184 busybox_unstripped
2007-07-05 00:12:55 +00:00
Denis Vlasenko 42b3dea9bf udhcp: many small fixes:
* arpping(): smaller and even probably fixed
* lots of variables/params converted: ulong -> uint32_t
* uptime() nuked in favor of monotonic_sec()
* udhcp_get_packet(): only one "bad vendor", simplify

function                                             old     new   delta
reservedIp                                            36      35      -1
udhcpc_main                                         2462    2460      -2
addStaticLease                                        64      62      -2
static.broken_vendors                                 16       -     -16
uptime                                                19       -     -19
udhcpd_main                                         1273    1238     -35
udhcp_get_packet                                     223     184     -39
.rodata                                           144162  144106     -56
arpping                                              690     609     -81
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/7 up/down: 0/-251)           Total: -251 bytes
   text    data     bss     dec     hex filename
 734241    3028   14400  751669   b7835 busybox_old
 734005    3028   14400  751433   b7749 busybox_unstripped
2007-07-03 15:47:50 +00:00
Denis Vlasenko 54e19da86d correct_password: if password is 'x' or '*' and there is no shadow, use
fake encrypted password 'aa' (which is guaranteed to fail password check).
2007-07-03 10:28:46 +00:00
Denis Vlasenko a48369183b ifupdown: kill -TERM is default, so drop -TERM
ifupdown: ferror() does not set errno, don't use perror
ifupdown: make netmask parsing smaller and more strict
(was accepting 255.0.255.0, 255.1234.0.0 etc...)

function                                             old     new   delta
count_bits                                            36       -     -36
execute                                             2573    2535     -38
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-74)             Total: -74 bytes
   text    data     bss     dec     hex filename
 684204    2744   14000  700948   ab214 busybox_old
 684132    2744   14000  700876   ab1cc busybox_unstripped
2007-07-03 08:26:24 +00:00
Denis Vlasenko e190c16636 correct_password: do not print "no shadow passwd..." message
function                                             old     new   delta
correct_password                                     204     191     -13
.rodata                                           129530  129466     -64
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-77)             Total: -77 bytes
   text    data     bss     dec     hex filename
 675984    2744   13968  692696   a91d8 busybox_old
 675908    2744   13968  692620   a918c busybox_unstripped
2007-07-03 06:15:42 +00:00
Denis Vlasenko 3483e85f6b ping: fix non-fancy ping6 2007-07-02 15:47:52 +00:00
Denis Vlasenko 10aea3e84e devfsd: futher sanitization by Tito <farmatito@tiscali.it> 2007-07-01 22:25:33 +00:00
Denis Vlasenko c6753c1666 expr: small code shrink 2007-07-01 18:33:35 +00:00
Denis Vlasenko 679b41237c devfsd: indentation fixes 2007-07-01 18:18:54 +00:00
Denis Vlasenko 4b9b0ced30 find: fix build failure on certain configs
(found by Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>)
2007-07-01 17:35:17 +00:00
Denis Vlasenko 99fcc62523 find: style fix 2007-07-01 17:29:44 +00:00
Denis Vlasenko aba7f49a22 ps: revert wrong "optimization": (i & 1) -> i 2007-07-01 17:25:59 +00:00
Denis Vlasenko e6bce979bf fix comment placement (no code changes) 2007-07-01 17:11:54 +00:00
Denis Vlasenko c82b5108e1 udhcp: new config option "Rewrite the lease file at every new acknowledge"
(Mats Erik Andersson <mats@blue2net.com> (Blue2Net AB))
udhcp: consistently treat server_config.start/end IPs as host-order
       fix IP parsing for 64bit machines
       fix unsafe hton macro usage in read_opt()
       do not chdir("/") when daemonizing
       fix help text
2007-07-01 17:05:57 +00:00
Denis Vlasenko dc7a5eae36 ps: fix "unused variable" warning; fix integer variable declared as char. 2007-07-01 14:53:06 +00:00
Denis Vlasenko 16b7cb455d web site: announce 1.6.1 2007-06-30 17:12:14 +00:00
Denis Vlasenko 98ebab8b76 top,ps: improve /proc/PID/cmdinfo reading code
function                                             old     new   delta
display_status                                         -    1231   +1231
read_cmdline                                           -     101    +101
parse_conf                                          1284    1303     +19
arith                                               2033    2042      +9
collect_blk                                          467     474      +7
fsck_main                                           1909    1911      +2
dhcprelay_main                                      1125    1122      -3
singlemount                                         4555    4547      -8
read_close                                            50      36     -14
get_lcm                                              123     105     -18
ed_main                                             3111    3084     -27
func_args                                             73      28     -45
procps_scan                                          732     658     -74
top_main                                            2187     899   -1288
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 4/8 up/down: 1369/-1477)       Total: -108 bytes
   text    data     bss     dec     hex filename
 676048    2744   13968  692760   a9218 busybox_old
 675940    2744   13968  692652   a91ac busybox_unstripped
2007-06-30 14:47:41 +00:00
Denis Vlasenko 8b1409896d add bb_basename.c 2007-06-30 10:58:08 +00:00
Denis Vlasenko dc757aa16c introduce and use bb_basename()
function                                             old     new   delta
bb_basename                                            -      26     +26
sv_main                                             1226    1225      -1
passwd_main                                         1985    1983      -2
showdirs                                             482     478      -4
sendCgi                                             1811    1807      -4
make_device                                         1354    1350      -4
handleIncoming                                      2443    2439      -4
func_name                                             82      78      -4
service_name                                        2292    2285      -7
main                                                 909     901      -8
cmp_main                                             555     547      -8
test_main                                            434     422     -12
act                                                  228     216     -12
find_pair                                            180     164     -16
rmmod_main                                           298     280     -18
find_pid_by_name                                     156     134     -22
modprobe_main                                       1606    1576     -30
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/16 up/down: 26/-156)         Total: -130 bytes
   text    data     bss     dec     hex filename
 734933    3028   14400  752361   b7ae9 busybox_old
 734801    3028   14400  752229   b7a65 busybox_unstripped
2007-06-30 08:04:05 +00:00
Denis Vlasenko f7d07b1723 killall, pidof: use argv0 for process matching too
top: show 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)

function                                             old     new   delta
find_pid_by_name                                      98     156     +58
procps_scan                                          692     732     +40
top_main                                            2724    2762     +38
find_pair                                            164     180     +16
collect_int                                          114     123      +9
cmp_main                                             547     555      +8
collect_fork                                         112     119      +7
collect_ctx                                          112     119      +7
read_package_field                                   253     257      +4
passwd_main                                         1983    1985      +2
process_stdin                                        435     433      -2
xstrtoul_range_sfx                                   229     226      -3
get_next_block                                      1852    1849      -3
arith                                               2042    2033      -9
sv_main                                             1236    1226     -10
singlemount                                         4690    4672     -18
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 10/6 up/down: 189/-45)          Total: 144 bytes
   text    data     bss     dec     hex filename
 734789    3028   14400  752217   b7a59 busybox_old
 734933    3028   14400  752361   b7ae9 busybox_unstripped
2007-06-30 08:03:26 +00:00
Denis Vlasenko 42ee26d00c procps: shrink /proc scanning code a bit
function                                             old     new   delta
skip_fields                                           16      15      -1
.rodata                                           144266  144258      -8
procps_scan                                          739     692     -47
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-56)             Total: -56 bytes
   text    data     bss     dec     hex filename
 734845    3028   14400  752273   b7a91 busybox_old
 734789    3028   14400  752217   b7a59 busybox_unstripped
2007-06-30 08:01:04 +00:00
Mike Frysinger ae7f7ebcb7 document firmware support 2007-06-28 17:13:51 +00:00
Denis Vlasenko 12d2129d50 wget: fix bug in base64 encoding (bug 1404). +10 bytes. 2007-06-27 21:40:07 +00:00
Denis Vlasenko c965f4b141 devfsd: style cleanup; size reduction (Tito <farmatito@tiscali.it>)
traceroute: suppress warning
2007-06-27 00:20:38 +00:00
Denis Vlasenko e8240f19bd uuencode: shrink
function                                             old     new   delta
uuencode_main                                        427     337     -90
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-90)             Total: -90 bytes
   text    data     bss     dec     hex filename
 734981    3028   14400  752409   b7b19 busybox_old
 734889    3028   14400  752317   b7abd busybox_unstripped
2007-06-26 15:59:37 +00:00
Denis Vlasenko 1fc6238ffa devfsd: fix formatting (Tito <farmatito@tiscali.it>)
ash: fix SEGV if type has zero parameters
2007-06-25 22:55:34 +00:00
Denis Vlasenko 80b8b39899 Consolidate ARRAY_SIZE macro; remove one unneeded global var (walter harms <wharms@bfs.de>) 2007-06-25 10:55:35 +00:00
Bernhard Reutner-Fischer 1399282b47 - need to pass the PATH down to the gcc-version check to be able to find the correct cc.
Fixes make PATH="$CROSS_BIN:$PATH" CROSS_COMPILE=foo- like invocations that previously failed to resolve since the information about the path set by the user was lost.
2007-06-25 10:41:01 +00:00
Denis Vlasenko 88308fec80 test: suppress gcc warning
telnetd: do not use suferfluous static variable.
2007-06-25 10:35:11 +00:00
Denis Vlasenko 56258b688c httpd: NOMMU fixes by Alex Landau <landau_alex@yahoo.com> 2007-06-23 23:14:02 +00:00
Denis Vlasenko 198badafd8 pidof: size optimizations (-50 bytes) 2007-06-23 14:56:43 +00:00
Bernhard Reutner-Fischer 118b81df76 - handy to have the cross_compile block here, too 2007-06-22 17:39:21 +00:00
Denis Vlasenko 2ee028dd5b syslogd: do not convert tabs to ^I 2007-06-21 13:44:53 +00:00
Denis Vlasenko b304eadca8 test: shrink a bit
function                                             old     new   delta
test_main                                              5     434    +429
bb_test                                              473       -    -473
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 429/-473)          Total: -44 bytes
   text    data     bss     dec     hex filename
 735073    3028   14408  752509   b7b7d busybox_old
 735029    3028   14408  752465   b7b51 busybox_unstripped
2007-06-21 13:35:52 +00:00
Denis Vlasenko d67a606489 build system: remove kernel .config locations (spotted by walter harms <wharms@bfs.de>) 2007-06-21 12:57:29 +00:00
Denis Vlasenko 931de892cc random shrinkage of statics, -60 bytes saved 2007-06-21 12:43:45 +00:00
Denis Vlasenko a80b4a0fa7 tar: improve OLDGNU compat, make old SUN compat configurable 2007-06-21 12:41:59 +00:00
Bernhard Reutner-Fischer 9a33780152 - add ATTRIBUTE_UNUSED_RESULT for internal use 2007-06-21 10:39:20 +00:00
Bernhard Reutner-Fischer b7e61485d6 since we removed the deprecated matches() now and thus not alot of warnings are currently seen, let's strive to fixup these:
- warn a little bit about unused results
2007-06-21 10:28:11 +00:00
Bernhard Reutner-Fischer 789b87edf5 - remove matches() from networking/. Untested.
text    data     bss     dec     hex filename
   1705       0       0    1705     6a9 networking/libiproute/utils.o.orig
   1676       0       0    1676     68c networking/libiproute/utils.o
    766       0       0     766     2fe networking/libiproute/rtm_map.o.orig
    670       0       0     670     29e networking/libiproute/rtm_map.o
   4942       0       0    4942    134e networking/libiproute/iptunnel.o.orig
   4687       0       0    4687    124f networking/libiproute/iptunnel.o
2007-06-21 10:20:13 +00:00
Denis Vlasenko 833358798a slattach: code shrink (Bernhard Fischer <rep.dot.nop@gmail.com>) 2007-06-21 07:27:43 +00:00
Denis Vlasenko 88976d00d8 remove extra ')' 2007-06-21 07:09:18 +00:00
Denis Vlasenko 14923db72f slattach: new applet. 2007-06-20 15:23:03 +00:00
Bernhard Reutner-Fischer cd0e80ce90 - move iprule and ipaddress from matches() to index_in_str_array
text    data     bss     dec     hex filename
   2544       0       0    2544     9f0 networking/libiproute/iprule.o.oorig
   2356       0       0    2356     934 networking/libiproute/iprule.o
   6481       0       0    6481    1951 networking/libiproute/ipaddress.o.oorig
   6464       0       0    6464    1940 networking/libiproute/ipaddress.o
2007-06-20 14:53:49 +00:00
Denis Vlasenko 7510384107 do not do utime() on links, it acts on link targets, and we don't want that.
rename link_name to link_target, less confusing this way.
2007-06-20 14:49:47 +00:00
Bernhard Reutner-Fischer 761ce14fd2 - remove another user of the deprecated matches() func by moving it to use index_in_str_array. Untested.
text    data     bss     dec     hex filename
    445       0       4     449     1c1 ip_parse_common_args.o.oorig
    391       0       4     395     18b ip_parse_common_args.o
2007-06-20 12:42:03 +00:00
Bernhard Reutner-Fischer ee921393a5 - do not hardcode HOSTCFLAGS to gcc specific flags. Fixes errors when not using gcc as HOSTCC 2007-06-20 10:01:12 +00:00
Bernhard Reutner-Fischer bb0baed564 - strndupa is a GNU extension. Using strdup to avoid several errors like:
util-linux/mdev.c:(.text+0x29a): undefined reference to `strndupa'
2007-06-20 09:56:47 +00:00
Denis Vlasenko bb98db2ed2 echo: fix yet another buglet in non-fancy echo 2007-06-19 23:04:17 +00:00
Denis Vlasenko 5ad1048c3d ping: fix incorrect handling of -I (Iouri Kharon <bc-info@styx.cabel.net>) 2007-06-19 22:54:21 +00:00
Denis Vlasenko a19faf8bb7 find: -context support for SELinux (KaiGai Kohei <kaigai@kaigai.gr.jp>)
find: make it a bit smaller

function                                             old     new   delta
.rodata                                           129018  129050     +32
parse_params                                        1509    1346    -163
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 32/-163)          Total: -131 bytes
2007-06-19 22:22:57 +00:00
Denis Vlasenko dcf6de552a pscan: size optimization (Tito <farmatito@tiscali.it>) 2007-06-19 16:57:47 +00:00
Mike Frysinger 5b5bcf24f5 punt %.bflt target in favor of proper LDFLAGS=-Wl,-elf2flt handling 2007-06-19 15:58:02 +00:00
Denis Vlasenko 31789a81d5 top,ps: 'stringify' tty only when needed. -60 bytes. 2007-06-19 14:43:17 +00:00
Denis Vlasenko 362c6ec694 top: speedup if tty info is not requested 2007-06-19 13:53:12 +00:00
Denis Vlasenko 3afac4ce06 top,ps: reduce CPU usage in decimal conversion (optional)
text    data     bss     dec     hex filename
 734651    3040   14416  752107   b79eb busybox_old
 734751    3040   14416  752207   b7a4f busybox_unstripped
2007-06-19 13:46:24 +00:00
Denis Vlasenko 08a61180ce ll_map: disable interface name caching code
function                                             old     new   delta
find_by_index                                          -      26     +26
static.icache                                          4       -      -4
ll_idx_n2a                                            71      59     -12
static.ncache                                         16       -     -16
ll_index_to_flags                                     40      24     -16
xll_name_to_index                                    206     104    -102
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 0/3 up/down: 26/-150)          Total: -124 bytes

   text    data     bss     dec     hex filename
 734703    3040   14440  752183   b7a37 busybox_old
 734599    3040   14416  752055   b79b7 busybox_unstripped
2007-06-19 12:11:20 +00:00
Denis Vlasenko 2d25491ed0 defconfig: update 2007-06-19 11:33:48 +00:00
Denis Vlasenko a61cb92f2d make /etc/network parsing configurable. -200 bytes when off. 2007-06-19 11:24:47 +00:00
Denis Vlasenko 6d9ea24611 networking/interface.c: huke remaining big statics; use malloc for INET[6]_rresolve
return value. Went thru callers and adjusted them - code got smaller too.

function                                             old     new   delta
ip_port_str                                            -     126    +126
INET6_rresolve                                       165     182     +17
static.cache                                          20      24      +4
route_main                                          2092    2091      -1
INET_sprint                                           61      59      -2
INET_nn                                                4       -      -4
INET6_sprint                                          59      53      -6
udp_do_one                                           518     508     -10
tcp_do_one                                           433     423     -10
raw_do_one                                           494     484     -10
traceroute_main                                     4117    4105     -12
INET_rresolve                                        334     321     -13
bb_displayroutes                                     494     456     -38
snprint_ip_port                                      244       -    -244
static.buff                                          264      16    -248
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 2/10 up/down: 147/-598)        Total: -451 bytes

size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 751073    3048   14688  768809   bbb29 busybox_old
 750873    3048   14440  768361   bb969 busybox_unstripped
2007-06-19 11:12:46 +00:00
Denis Vlasenko 1b16bdaebf networking/interface.c: reduce bss usage
function                                             old     new   delta
.rodata                                           158918  158950     +32
display_interfaces                                   133     153     +20
UNSPEC_print                                          56      68     +12
pr_ether                                              59      65      +6
static.proc_read                                       4       1      -3
interface_opt_a                                        4       1      -3
in_ether                                             139     136      -3
ifconfig_main                                       1296    1293      -3
if_readlist_proc                                     686     680      -6
ife_print                                           1350    1338     -12
do_if_print                                           46       -     -46
static.buff                                          369     264    -105
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 4/7 up/down: 70/-181)          Total: -111 bytes

# size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 751073    3080   14800  768953   bbbb9 busybox_old
 751073    3048   14688  768809   bbb29 busybox_unstripped
2007-06-19 11:10:02 +00:00
Denis Vlasenko 91e149a373 libbb: random hunt for statics
function                                             old     new   delta
bb_askpass                                           306     321     +15
pw_encrypt                                            38      39      +1
static.passwd                                         64       4     -60
static.cipher                                        128       4    -124
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 16/-184)          Total: -168 bytes

# size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 683705    2704   14240  700649   ab0e9 busybox_old
 683721    2704   14064  700489   ab049 busybox_unstripped
2007-06-18 10:35:06 +00:00
Denis Vlasenko 2c91efb7c2 libpwdgrp/pwd_grp.c: allocate local storage on first call, not in bss. -1k bss
function                                             old     new   delta
get_S                                                  -      31     +31
bb_internal_getpwnam                                  38      44      +6
bb_internal_getgrnam                                  38      44      +6
bb_internal_getgrgid                                  38      44      +6
ptr_to_statics                                         -       4      +4
static.resultbuf                                      88       -     -88
static.buffer                                       1024       -   -1024
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 3/0 up/down: 53/-1112)        Total: -1059 bytes
2007-06-18 10:08:27 +00:00
Denis Vlasenko 7679145cfa ping: fix write-after-allocated-mem bug
ping: use monotonic_us instead of gettimeofday: smaller code and
      needs only 4 bytes in the packet
ping: display roundtrip times with 1/1000th of ms, not 1/10 ms precision.
wget: small optimization

function                                             old     new   delta
pingstats                                            243     259     +16
sendping6                                             98      93      -5
sendping4                                            183     178      -5
.rodata                                           129715  129707      -8
progressmeter                                        867     855     -12
unpack_tail                                          320     272     -48
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/5 up/down: 16/-78)            Total: -62 bytes
2007-06-18 08:55:57 +00:00
Mike Frysinger ebd27aabaa fix an obvious typo while trying to access the tv_usec member 2007-06-18 07:12:31 +00:00
Denis Vlasenko bd7bb299c0 wget: use monotonic_sec instead of gettimeofday
zcip: use monotonic_us instead of gettimeofday
udhcpcd: simpler, shorter random_xid()

function                                             old     new   delta
monotonic_sec                                          -      41     +41
find_pair                                            164     180     +16
run_list_real                                       2018    2028     +10
cmp_main                                             547     555      +8
collect_ctx                                          112     119      +7
singlemount                                         4544    4549      +5
time_main                                           1124    1128      +4
static.start_sec                                       -       4      +4
static.lastupdate_sec                                  -       4      +4
sock                                                   -       4      +4
read_package_field                                   253     257      +4
pick                                                  38      40      +2
get_next_line                                        145     147      +2
count_lines                                           59      61      +2
process_stdin                                        435     433      -2
xstrtoul_range_sfx                                   229     226      -3
static.initialized                                     4       1      -3
dhcprelay_main                                      1125    1122      -3
catcher                                              380     377      -3
arping_main                                         1969    1966      -3
s                                                      8       4      -4
cfg                                                    4       -      -4
static.lastupdate                                      8       -      -8
start                                                  8       -      -8
random_xid                                            95      33     -62
.rodata                                           129114  129050     -64
zcip_main                                           1731    1576    -155
progressmeter                                       1035     867    -168
------------------------------------------------------------------------------
(add/remove: 4/3 grow/shrink: 10/11 up/down: 113/-490)       Total: -377 bytes
2007-06-17 23:40:26 +00:00
Denis Vlasenko 459be35234 hwclock: size optimizations
libbb/time.c: new file, introducing monotonic_us()
pscan, traceroute, arping: use it instead of gettimeofday
ping, zcip: TODO

function                                             old     new   delta
monotonic_us                                           -      89     +89
find_pair                                            164     180     +16
.rodata                                           129747  129763     +16
refresh                                             1144    1152      +8
............
timeout                                                8       4      -4
static.start                                           8       4      -4
last                                                   8       4      -4
parse_conf                                          1303    1284     -19
time_main                                           1149    1124     -25
gettimeofday_us                                       39       -     -39
arping_main                                         2042    1969     -73
hwclock_main                                         594     501     -93
catcher                                              485     380    -105
traceroute_main                                     4300    4117    -183
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 8/11 up/down: 157/-562)        Total: -405 bytes
2007-06-17 19:09:05 +00:00
Denis Vlasenko e79dd06782 time: *const str = "xxx" ==> str[] = "xxx" 2007-06-17 19:04:58 +00:00
Denis Vlasenko 787d92645b strings: strings a b was processing a twice, fix that 2007-06-17 12:19:07 +00:00
Denis Vlasenko ea9e798004 arping: -i should be -I 2007-06-17 00:36:57 +00:00
Denis Vlasenko a6163ca355 install: fix install a b /a/link/to/dir
install: fix -s (strip) option
nmeter: add TODO
2007-06-17 00:35:15 +00:00
Denis Vlasenko ab47eeee6a forgot svn add... 2007-06-16 20:52:33 +00:00
Denis Vlasenko 85532fc4d4 remove obsolete comment 2007-06-16 14:16:30 +00:00
Denis Vlasenko a7825f269d make FEATURE_HAVE_RPC auto-selectable by mount and inetd sub-features 2007-06-16 13:56:51 +00:00
Denis Vlasenko 7b72fc1200 pscan: new applet (portscanner). ~1350 bytes. By Tito <farmatito@tiscali.it>
wget: lift 256 chars limitation on terminal width
2007-06-16 13:37:59 +00:00
Denis Vlasenko 53a0e97196 find: make -size match GNU find 2007-06-16 00:30:52 +00:00
Denis Vlasenko b941129ccb find: add conditional support for -maxdepth and -regex
(needed for Linux 2.6.22-rc4 build)

-maxdepth:
# size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 675622    2792   15728  694142   a977e busybox_old
 675770    2792   15728  694290   a9812 busybox_unstripped

-regex:
# size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 675770    2792   15728  694290   a9812 busybox_old
 675894    2792   15728  694414   a988e busybox_unstripped
2007-06-15 23:43:11 +00:00
Denis Vlasenko d786cc5966 fdisk: fix minor issues with help text 2007-06-15 21:17:21 +00:00
Bernhard Reutner-Fischer be99243945 - fix test -f ./exists
Note that test -f ./exists -a "-u" = "-u" doesn't work and did not work even before r18282, so this is a breakage not caused by me..
2007-06-15 10:36:49 +00:00
Bernhard Reutner-Fischer 867266059b - vda perfers not to use the banner 2007-06-15 08:30:33 +00:00
Denis Vlasenko 432d69cb41 applets/Kbuild: straighten it a bit 2007-06-14 21:41:15 +00:00
Mike Frysinger 0e0639b702 Alex Landau writes: open firmware for reading, not writing 2007-06-14 09:29:48 +00:00
Denis Vlasenko d8540f71ac init: make sure fd 0,1,2 are not closed, + related optimizations.
init_main                                            929     920      -9
bb_daemonize_or_rexec                                145     127     -18
2007-06-14 07:53:06 +00:00
Denis Vlasenko 1adf681e87 traceroute: stop using floating point needlessly; nuke useless assignment.
.rodata                                           129308  129312      +4
freehostinfo                                          35      29      -6
traceroute_main                                     4308    4300      -8
2007-06-14 07:47:52 +00:00
Denis Vlasenko 26017b1b04 minix.h: add very simple test script 2007-06-13 12:49:46 +00:00
Denis Vlasenko 1fd46215b2 fsck_minix: forgotten bit of previous commit... 2007-06-13 12:35:34 +00:00
Denis Vlasenko a6691317e5 fsck_minix: stop using data/bss
10847       8     271   11126    2b76 busybox.t2/util-linux/fsck_minix.o
  10140       0       0   10140    279c busybox.t3/util-linux/fsck_minix.o
2007-06-13 12:28:21 +00:00
Denis Vlasenko ca525b4f24 *: BB_BANNER -> bb_banner (it is not a const or #define)!
correct_password: explain in detail why it is ok to use bb_banner
fsck_minix: make it print bb version, not it's own (outdated/irrelevant) one

Marginal size difference:
   text    data     bss     dec     hex filename
 679119    2700   15632  697451   aa46b busybox_old
 679091    2700   15632  697423   aa44f busybox_unstripped
2007-06-13 12:27:17 +00:00
Mike Frysinger b51fd3525e as suggested by Renaud Cerrato and Souf, switch over to recursive_action() for some nice shrinkage and so we work even when CONFIG_SYSFS_DEPRECATED is off 2007-06-13 09:24:50 +00:00
Mike Frysinger a78ef2ccf1 add support for firmware loading 2007-06-13 07:34:15 +00:00
Denis Vlasenko d67cef2425 hush: fix read builtin to not read ahead past eol and to not use
insane amounts of stack. Testsuite updated.
2007-06-13 06:47:47 +00:00
Denis Vlasenko f5f75c5e82 remove nearly-duplicate PATHs in several places
function                                             old     new   delta
bb_PATH_root_path                                      -      35     +35
varunset                                              60      58      -2
arith                                               2042    2033      -9
bb_default_root_login_path                            30       -     -30
.rodata                                           128794  128762     -32
which_main                                           152     117     -35
defpathvar                                            40       -     -40
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 0/4 up/down: 35/-148)          Total: -113 bytes
2007-06-12 22:35:19 +00:00
Denis Vlasenko f312e32662 login: make /etc/nologin support configurable. -240 bytes if not selected. 2007-06-12 22:04:57 +00:00
Denis Vlasenko 637c975098 fix "--help prints usage for wrong applet" bug 2007-06-12 20:55:38 +00:00
Denis Vlasenko 3ad5d0cbbe diff: shrink code (-85 bytes):
function                                             old     new   delta
fiddle_sum                                             8       -      -8
diffreg                                             2717    2690     -27
prepare                                              334     284     -50
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/2 up/down: 0/-85)             Total: -85 bytes

s/ATTRIBUTE_ALWAYS_INLINE/ALWAYS_INLINE/g
2007-06-12 20:54:54 +00:00
Bernhard Reutner-Fischer fdcbc4e709 - fix testing primary expressions like '"-u" = "-u"' 2007-06-12 13:21:08 +00:00
Denis Vlasenko 15611bb958 A few more string duplicates found & eliminated
# size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 679693    2700   15632  698025   aa6a9 busybox_old
 679523    2700   15632  697855   aa5ff busybox_unstripped
2007-06-12 08:52:02 +00:00
Denis Vlasenko 16d58d75ee catv: was abusing xopen, should not die on err, but warn only. 2007-06-12 08:13:34 +00:00
Denis Vlasenko cc5e090f12 move several applets to more correct ex-project. No code changes. 2007-06-12 08:12:33 +00:00
Denis Vlasenko aa198dd39c uudecode: nuke duplicate base64_table[]. saves 65 bytes 2007-06-12 07:24:11 +00:00
Denis Vlasenko 745119605e top: on user suggestion make percentile calculations configurable. -56 bytes when off. +600 bytes when on
top: reorder columns, so that [P]PIDs are together and VSZ/%MEM are together. Makes more sense
2007-06-11 16:31:55 +00:00
Bernhard Reutner-Fischer d71e45856e - use bb_msg_full_version instead of a separate string. Saves a minor 3 bytes. 2007-06-11 15:09:21 +00:00
Denis Vlasenko a7c5d2c6d9 getopt_mk_fifo_nod: heed warning 2007-06-10 19:29:37 +00:00
Denis Vlasenko b1e5addfed top: improve global CPU percentage (smaller & faster code) 2007-06-10 18:04:54 +00:00
Denis Vlasenko 5a65447e30 top: add config option and code for global CPU % display 2007-06-10 17:11:59 +00:00
Denis Vlasenko e8a0788b24 moved biggest stack buffers to malloc space, or made their size configurable
(8k of shell line edit buffer is an overkill)

# make ARCH=i386 bloatcheck
function                                             old     new   delta
read_line_input                                     3933    3967     +34
ifaddrlist                                           348     345      -3
do_loadfont                                          208     191     -17
edit_file                                            840     819     -21
.rodata                                           129112  129080     -32
uncompress                                          1305    1268     -37
loadfont_main                                        566     495     -71
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/6 up/down: 34/-181)          Total: -147 bytes
2007-06-10 15:08:44 +00:00
Denis Vlasenko d4fea900bd add script which measures stack consumption.
Current top users:

0x08052f52 uncompress []:                               393312
0x080c8a58 input_tab []:                                82104
0x08092d5b ifaddrlist []:                               32828
0x08056163 loadfont_main []:                            32796
0x0806e508 colon []:                                    16532
0x08056095 do_loadfont []:                              16400
0x0806da70 place_cursor []:                             16388
0x080792e8 login_main []:                               9176

393 kb of stack??? OMG...
2007-06-10 00:54:27 +00:00
Denis Vlasenko 77e44d60e6 httpd: move data off bss.
httpd: do not realpath() for SCRIPT_FILENAME - it resolves symlinks
but it should not:

-                /* SCRIPT_FILENAME required by PHP in CGI mode */
-               if (!realpath(purl + 1, realpath_buff))
-                       goto error_execing_cgi;
-               setenv1("SCRIPT_FILENAME", realpath_buff);
+
+               /* SCRIPT_FILENAME required by PHP in CGI mode */
+               fullpath = concat_path_file(home_httpd, purl);
+               setenv1("SCRIPT_FILENAME", fullpath);
2007-06-09 23:49:05 +00:00
Bernhard Reutner-Fischer 66db264a5f - also note where to checkout the 1_6_stable branch 2007-06-09 09:12:45 +00:00
Denis Vlasenko d6766c71a9 mdev: microscopic enhancement, should change nothing 2007-06-08 16:18:15 +00:00
Denis Vlasenko 9acfed2d14 grep: selection done by FEATURE_GREP_EGREP_ALIAS was broken, fix.
(Maxime Bizon <mbizon@freebox.fr>  (Freebox))
2007-06-08 15:41:27 +00:00
Denis Vlasenko 65e14b4588 login: ask passwords even for wrong usernames.
# size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 680099    2704   15648  698451   aa853 busybox_old
 680110    2704   15648  698462   aa85e busybox_unstripped
2007-06-08 15:27:06 +00:00
Denis Vlasenko bdbbb7ec49 make busybox --install work even if /proc/self/exe doesn't exist
# size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 680095    2704   15648  698447   aa84f busybox_old
 680099    2704   15648  698451   aa853 busybox_unstripped
2007-06-08 15:02:55 +00:00
Denis Vlasenko c14d39e83a rmp: add optional support for bz2 data. +50 bytes of code 2007-06-08 13:05:39 +00:00
Bernhard Reutner-Fischer def8260219 - fix invocation without any argument 2007-06-08 12:52:17 +00:00
Denis Vlasenko 42bffbf360 hush: add missing dependencies (Maxime Bizon <mbizon@freebox.fr> (Freebox)) 2007-06-08 08:02:53 +00:00
Denis Vlasenko dc4ab54ea7 test: fix thinko in previous commit 2007-06-08 07:59:54 +00:00
Denis Vlasenko 89bca27158 test: recognize /path/to/[ case too 2007-06-08 07:33:45 +00:00
Bernhard Reutner-Fischer 8936a19880 - Add a FAQ entry on "how do i cross compile busybox" 2007-06-08 07:19:06 +00:00
Bernhard Reutner-Fischer bb4b9f1fc9 - add a config-time range check for IPC_SYSLOG_BUFFER_SIZE
The upper-bound doesn't look like it is working since it accepts LONG_MAX as input. I suspect that this is an lxdialog feature or something like that ;)
2007-06-07 13:22:56 +00:00
Denis Vlasenko e16e6e79e4 awk: experimentally modify "global" trick to make code smaller
by minimizing data offsets

function                                             old     new   delta
parse_expr                                           752     782     +30
syntax_error                                          23      26      +3
nvfree                                               151     154      +3
nvalloc                                              172     175      +3
fsrealloc                                            111     114      +3
chain_node                                            99     102      +3
chain_loop                                           121     124      +3
chain_group                                          628     631      +3
awk_main                                            1002    1005      +3
awk_exit                                              99     102      +3
parse_program                                        308     310      +2
split_f0                                             172     170      -2
awk_split                                            510     507      -3
getvar_s                                             108     102      -6
awk_sub                                              643     637      -6
awk_getline                                          706     700      -6
next_token                                           943     927     -16
handle_special                                       470     446     -24
next_input_file                                      252     213     -39
evaluate                                            6703    6633     -70
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 11/9 up/down: 59/-172)         Total: -113 bytes

# size */*/awk.o
   text    data     bss     dec     hex filename
  18247       0       0   18247    4747 busybox.t0/editors/awk.o
  18134       0       0   18134    46d6 busybox.t1/editors/awk.o
2007-06-07 13:14:53 +00:00
Bernhard Reutner-Fischer 4b49512881 - update defconfig 2007-06-07 13:12:51 +00:00
Bernhard Reutner-Fischer 1622cb8cea - i need this disabled code for testing a patch. Please leave it in. 2007-06-07 12:11:24 +00:00
Bernhard Reutner-Fischer e8b2bd4d47 - fix wrong not operator which was essentially ignored. got introduced in r18282
http://busybox.net/lists/busybox/2007-June/027652.html
2007-06-06 19:27:58 +00:00
Denis Vlasenko ae5a8aac26 awk: move all data to malloc space
function                                             old     new   delta
evaluate                                            6448    6728    +280
awk_getline                                          676     705     +29
parse_expr                                           726     752     +26
next_token                                           917     943     +26
next_input_file                                      237     252     +15
awk_split                                            498     510     +12
awk_sub                                              632     643     +11
split_f0                                             160     170     +10
getvar_s                                              98     108     +10
...
chain_loop                                           128     121      -7
nvalloc                                              179     171      -8
chain_node                                           107      99      -8
mainseq                                               12       -     -12
endseq                                                12       -     -12
chain_group                                          640     628     -12
beginseq                                              12       -     -12
awk_exit                                             112     100     -12
fsrealloc                                            127     110     -17
static.v                                              20       -     -20
static.rsm                                            24       -     -24
ttt                                                   28       -     -28
parse_program                                        339     311     -28
static.sreg                                           32       -     -32
intvar                                                76       -     -76
static.tspl                                           84       -     -84
rsplitter                                             84       -     -84
fsplitter                                             84       -     -84
------------------------------------------------------------------------------
(add/remove: 0/39 grow/shrink: 16/11 up/down: 439/-685)      Total: -246 bytes
2007-06-06 17:01:00 +00:00
Denis Vlasenko c084d2f205 echo: fix non-fancy echo 2007-06-06 07:50:51 +00:00
Denis Vlasenko 0696b8aae8 ps: fix -Z (by Yuichi Nakamura <ynakam@hitachisoft.jp>) 2007-06-06 07:40:16 +00:00
Denis Vlasenko cd0df46d8c remove bashisms from testsuite 2007-06-05 22:29:14 +00:00
Denis Vlasenko 5c51a7ca52 nc: make connecting to IPv4 from IPv6-enabled hosts easier
(was requiring -s <local addr>)
2007-06-05 20:08:11 +00:00
Bernhard Reutner-Fischer 6c501a71ae - kiltedknight writes: Busybox incorrectly parses a line from the status file, claiming that a required package is not installed or tagged to be installed when it actually is.
Closes #1221
2007-06-05 17:28:56 +00:00
Bernhard Reutner-Fischer fa5f20755c - fix typo in error message. Closes #1308 2007-06-05 17:07:01 +00:00
Denis Vlasenko 746204b1b8 uudecode: fix to base64 decode by Jorgen Cederlof <jcz@google.com>
improved help texts

# make bloatcheck
function                                             old     new   delta
.rodata                                           127000  127032     +32
packed_usage                                       22156   22151      -5
uudecode_main                                        360     348     -12
uuencode_main                                        490     468     -22
read_base64                                          283     254     -29
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/4 up/down: 32/-68)            Total: -36 bytes
2007-06-04 23:32:35 +00:00
Denis Vlasenko 8c1aaf3297 snprintf(... "%s"...) => safe_strncpy 2007-06-04 21:03:51 +00:00
Denis Vlasenko 3c8b5ba8e8 syslogd: move some vectors from data to text. Needs uclibc patch
to have any effect (patch is submitted to uclibc ml).

# size *[67]/*/syslog*.o
   text    data     bss     dec     hex filename
   3169     288       0    3457     d81 busybox.t6/sysklogd/syslogd.o
   3457       0       0    3457     d81 busybox.t7/sysklogd/syslogd.o
2007-06-04 18:23:59 +00:00
Denis Vlasenko ef4bb26f93 diff: stop using data/bss
function                                             old     new   delta
do_diff                                              385     436     +51
diff_main                                            850     895     +45
dump_unified_vec                                     437     457     +20
prepare                                              335     334      -1
anychange                                              1       -      -1
suff                                                   4       -      -4
status                                               135     131      -4
static.max_context                                     4       -      -4
start                                                 12       8      -4
pref                                                   4       -      -4
member                                                 4       -      -4
label2                                                 4       -      -4
label1                                                 4       -      -4
klist                                                  4       -      -4
ixold                                                  4       -      -4
ixnew                                                  4       -      -4
dl_count                                               4       -      -4
dl                                                     4       -      -4
context_vec_start                                      4       -      -4
context_vec_ptr                                        4       -      -4
context_vec_end                                        4       -      -4
context                                                4       -      -4
clistlen                                               4       -      -4
clist                                                  4       -      -4
clen                                                   4       -      -4
class                                                  4       -      -4
J                                                      4       -      -4
add_to_dirlist                                        71      64      -7
slen                                                   8       -      -8
sfile                                                  8       -      -8
len                                                    8       -      -8
file                                                   8       -      -8
get_dir                                              196     185     -11
newcand                                               97      85     -12
change                                               351     331     -20
stb2                                                  96       -     -96
stb1                                                  96       -     -96
diffreg                                             2835    2717    -118
------------------------------------------------------------------------------
(add/remove: 0/27 grow/shrink: 3/8 up/down: 116/-482)        Total: -366 bytes

# size */*/diff.o
   text    data     bss     dec     hex filename
   7055       8     305    7368    1cc8 busybox.t2/coreutils/diff.o
   7002       0       0    7002    1b5a busybox.t3/coreutils/diff.o
2007-06-04 12:21:53 +00:00
Denis Vlasenko 821cc25f43 ping: stop using data/bss
function                                             old     new   delta
ping_main                                            375     392     +17
unpack_tail                                          317     320      +3
ping4                                                525     528      +3
ping6                                                772     773      +1
sendping6                                             99      98      -1
sendping4                                            184     183      -1
myid                                                   2       -      -2
sendping_tail                                        154     151      -3
tsum                                                   4       -      -4
tmin                                                   4       -      -4
tmax                                                   4       -      -4
source_lsa                                             4       -      -4
pingsock                                               4       -      -4
pingcount                                              4       -      -4
ntransmitted                                           4       -      -4
nrepeats                                               4       -      -4
nreceived                                              4       -      -4
if_index                                               4       -      -4
hostname                                               8       4      -4
dotted                                                 4       -      -4
datalen                                                4       -      -4
pingaddr                                              28       -     -28
rcvd_tbl                                             128       -    -128
------------------------------------------------------------------------------
(add/remove: 0/15 grow/shrink: 4/4 up/down: 24/-215)         Total: -191 bytes
   text    data     bss     dec     hex filename
 679835    2728   16736  699299   aaba3 busybox_old
 679851    2720   16536  699107   aaae3 busybox_unstripped
2007-06-04 10:33:48 +00:00
Denis Vlasenko 74324c8666 Audit bb_common_bufsiz usage, add script which looks for misuse.
tr: stop using globals needlessly.
code: -103 bytes
2007-06-04 10:16:52 +00:00
Denis Vlasenko 4e5f82c76f find_stray_communal_vars: script which finds communal variables
resize: remove globals var
mdev: remove globals var
2007-06-03 22:30:22 +00:00
Denis Vlasenko dd6e1f0deb start 1.7.x version 2007-06-02 12:54:09 +00:00
Denis Vlasenko 3f22b7f718 fdisk: make it work with big disks (read: typical today's disks)
even if CONFIG_LFS is unset.
2007-06-02 12:46:55 +00:00
Denis Vlasenko a0d7508748 website: announce 1.6.0 2007-06-01 14:40:03 +00:00
Denis Vlasenko fdcfa2aba7 less: less <HUGEFILE + [End] busy loops, fix it 2007-05-31 23:55:39 +00:00
Denis Vlasenko 342b0ab945 less: forgot trivial #if ENABLE_xxxx 2007-05-31 23:06:18 +00:00
Denis Vlasenko 9a7d38fe24 delete tons of extra #includes 2007-05-31 22:42:12 +00:00
Denis Vlasenko fad2b86c9e use "glibc errno" trick not only for ash, but for entire busybox
(add/remove: 1/1 grow/shrink: 37/37 up/down: 139/-228)        Total: -89 bytes
2007-05-31 22:16:38 +00:00
Denis Vlasenko c2f011aa03 more: stop using bss
# make && make bloatcheck
function                                             old     new   delta
gotsig                                                86     107     +21
more_main                                            777     781      +4
cin_fileno                                             4       -      -4
set_tty_to_initial_mode                               25       -     -25
new_settings                                         120      60     -60
initial_settings                                     120      60     -60
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 2/2 up/down: 25/-149)          Total: -124 bytes
2007-05-31 21:31:56 +00:00
Denis Vlasenko 22a9a3c6f8 less: fix very obscure memory corruption bug 2007-05-31 15:56:10 +00:00
Denis Vlasenko a1d24a0b6e less: stop using data/bss. Code got smaller too.
# size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 700719    2896   17880  721495   b0257 busybox_old
 700547    2832   17432  720811   affab busybox_unstripped
# size */*/less.o
   text    data     bss     dec     hex filename
   6861      50     344    7255    1c57 busybox.t0/miscutils/less.o
   6657       0       0    6657    1a01 busybox.t1/miscutils/less.o
2007-05-31 15:55:03 +00:00
Denis Vlasenko 199c0d542b nmeter: stop using data/bss; reduce amount of reads from /proc
# size */*/nmeter.o
   text    data     bss     dec     hex filename
   4366      80      16    4462    116e busybox.t0/miscutils/nmeter.o
   4386       0       0    4386    1122 busybox.t2/miscutils/nmeter.o
2007-05-30 14:48:38 +00:00
Denis Vlasenko 0b3b41b62a vi: move some data to malloc'ed space: ~500 less bss, code
size is smaller too (subject to arch differenced I guess)
2007-05-30 02:01:40 +00:00
Denis Vlasenko 27f79ff03d hush: trivial buglet found by randomconfig testing 2007-05-30 00:55:52 +00:00
Denis Vlasenko 4b924f3a5c whitespace fixes 2007-05-30 00:29:55 +00:00
Denis Vlasenko 4ef7d3a2de verror_msg: don't printf(NULL) 2007-05-29 21:41:28 +00:00
Denis Vlasenko fe3e1776ad test: close bug 1371
test: plug a memory leak
2007-05-27 03:39:50 +00:00
Denis Vlasenko 1c9ad62d26 ping: fix wrong sign extension of packet id (bug 1373) 2007-05-27 00:53:41 +00:00
Denis Vlasenko b6adbf1be2 usage.c: remove reference to busybox.h
*: s/include "busybox.h"/include "libbb.h"
2007-05-26 19:00:18 +00:00
Denis Vlasenko 5a6aeddfa7 xpipe: introduce (saves ~170 bytes)
udhcp/signalpipe.c: use pipe instead of socketpair.
2007-05-26 16:44:20 +00:00
Bernhard Reutner-Fischer 6239b1f50a - fix typo in help text and fix punctuation 2007-05-26 11:59:01 +00:00
Denis Vlasenko ba7cf260fd hush: fix 'echo abcsleep 5def' + Ctrl-Z and Ctrl-C bugs. +50 bytes of code. 2007-05-25 14:34:30 +00:00
Denis Vlasenko 0a83fc3984 hush: avoid duplicating HUSH_VERSION 2007-05-25 11:12:32 +00:00
Denis Vlasenko 201c72a8d6 hush: micro-optimization in new variable code 2007-05-25 10:00:36 +00:00
Denis Vlasenko 28c0f0f4fe hush: we can't do without variable->value member, saving 25 bytes of code
and some runtime memory. Rename few variables.
2007-05-25 02:46:01 +00:00
Denis Vlasenko d76c049cc4 hush: rework variable storage and environment handling.
More that -100 bytes of code + memory leak plugged.
Added a testcase for it.
2007-05-25 02:16:25 +00:00
Denis Vlasenko 163a855731 hush: update README with yet another failure case 2007-05-24 13:52:46 +00:00
Denis Vlasenko 5a1437d835 hush: fix segfaulting syntax error in interactive hush 2007-05-24 13:22:47 +00:00
Denis Vlasenko cd7f4d27a2 hush: improve 2 testsuite tests 2007-05-24 13:22:01 +00:00
Denis Vlasenko 2b6bbad4db hush: add 2 tests for correct syntax error reporting 2007-05-24 12:26:39 +00:00
Denis Vlasenko 0fe67b16ce udhcp: socketpair can fail if AF_UNIX is not available (e.g. if module is not loaded).
Error out on that.
2007-05-24 12:19:56 +00:00
Denis Vlasenko b055001b6a hush: fix handling of unmatched ${name (without closing '}') -
was eating all remaining input, potentially megabytes.
nofork: save/restore die_jmp too
nofork: use -2222 instead of -111 as "special" return valur for zero
(-111 is used by some applets. -2222 won't fit in exitcode and thus safer)
2007-05-24 12:18:16 +00:00
Denis Vlasenko 90e485ce79 hush: make syntax error messages a bit more useful 2007-05-23 15:22:50 +00:00
Denis Vlasenko 1744cb1861 hush: prepare testsuite for new, fixed error message format 2007-05-23 15:16:41 +00:00
Denis Vlasenko 170435c575 hush: fix job control with eval /bin/external_prog
hush: fix parsing of unterminated "str with no EOL
hush: improved make_string() (smaller, faster, needs less RAM)
hush: renamed several functions
2007-05-23 13:01:10 +00:00
Denis Vlasenko 1a7358612f hush: fix a bit different instance of "No EOL" bug,
add testsuite for that. Expand another testsuite.
2007-05-23 00:32:25 +00:00
Denis Vlasenko 94dace3016 fix execute bit on hush-misc/shift.tests 2007-05-23 00:26:32 +00:00
Denis Vlasenko 6963eb53a1 hdparm: make -T -t code smaller (-194 bytes), and output prettier 2007-05-22 21:46:11 +00:00
Denis Vlasenko 0681033918 hush: add 3 CONFIG_xxx, allowing for smaller and less capable hush.
Minimal hush is ~9k now (lash is ~7k).
2007-05-21 23:30:54 +00:00
Denis Vlasenko 8805eeb44a shells: update README and testsuite. environment memory leak
needs to be fixed - and documented!
2007-05-21 10:19:48 +00:00
Denis Vlasenko 219e88d050 hush: using smallints where we can. save ~20 bytes in code and
some data storage at runtime.
2007-05-21 10:18:23 +00:00
Denis Vlasenko 004baba2d6 hush: fix shift + $0 bug; add testcase 2007-05-20 22:22:18 +00:00
Denis Vlasenko 262d765351 hush: trivial size optimization 2007-05-20 21:52:49 +00:00
Denis Vlasenko 14b5dd9943 hush: make process substitution configurable; add a testcase 2007-05-20 21:51:38 +00:00
Denis Vlasenko fe52a74ecf busybox.net: announce 1.5.1 on the web site. 2007-05-20 17:12:43 +00:00
Denis Vlasenko 46846e25a4 ash: implement type -p, costs less than 10 bytes
(patch by Mats Erik Andersson <mats.andersson64@comhem.se>)
2007-05-20 13:08:31 +00:00
Denis Vlasenko 38ec147a18 mount: fix mounting of symlinks (mount from util-linux allows that) 2007-05-20 12:32:41 +00:00
Denis Vlasenko 6d709972cd cttyhack: new applet. 2007-05-18 09:45:36 +00:00
Denis Vlasenko 4500c58a07 make "static linking against glibc" an #error, not #warning 2007-05-18 07:37:06 +00:00
Denis Vlasenko d9b5ab868c awk: fix a trivial bug introduced by me.
This is how it goes. I break stuff by doing useless 'cleanups',
people fix the fallout. :(. Thanks rockeychu!
2007-05-18 07:30:43 +00:00
Denis Vlasenko 78e48b2c2c we were basically ignoring CONFIG_USE_BB_PWD_GRP (assuming =y),
fix this
2007-05-18 00:02:37 +00:00
Denis Vlasenko ffba941d29 awk: make code a bit less obfuscated 2007-05-17 23:03:35 +00:00
Denis Vlasenko 5b34083004 several *.c files:
move 'extern environ' up to the location of #includes
2007-05-17 23:02:14 +00:00
Denis Vlasenko cd5c7866e3 vi: remove two globals
awk: some 'lineno' vars were shorts, made them ints (code got smaller)
awk: rename global t to global ttt. still an awful name, but at least
     you can grep for it now.

function                                             old     new   delta
ttt                                                    -      28     +28
mysleep                                              104     120     +16
readit                                               408     418     +10
lineno                                                 2       4      +2
parse_program                                        338     339      +1
evaluate                                            6446    6445      -1
syntax_error                                          25      23      -2
next_token                                           917     915      -2
new_node                                              26      24      -2
tv                                                    16       8      -8
skip_spaces                                           68      53     -15
t                                                     28       -     -28
rfds                                                 128       -    -128
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 4/6 up/down: 57/-186)          Total: -129 bytes
2007-05-17 16:37:22 +00:00
Denis Vlasenko c8be5ee325 hush: do "struct globals" trick. hush.o data+bss = 0 bytes now.
+60 bytes to image, but -8000 bytes in bss.
2007-05-17 15:38:46 +00:00
Denis Vlasenko b6a741ffa7 hush: consolidated variable expansion for assignments and "normal" one.
-435 bytes. Tested against testsuite.
2007-05-17 14:38:17 +00:00
Denis Vlasenko 96f67dc69d more compile fixes from randomconfig run 2007-05-17 13:02:41 +00:00
Denis Vlasenko d46e6d1a55 fix trivial compile errors found by randomconfig run 2007-05-17 12:58:30 +00:00
Denis Vlasenko a35958d4ad netstat: fix error in new -W option handling 2007-05-16 22:25:35 +00:00
Denis Vlasenko c666f71e3b hush: take care of several easy FIXMEs. -228 bytes. 2007-05-16 22:18:54 +00:00
Denis Vlasenko 831dcc439c hush: another microscopic typo fix 2007-05-16 15:05:36 +00:00
Denis Vlasenko c29903221d hush: fix English in comment 2007-05-16 12:57:12 +00:00
Denis Vlasenko 3e7b0e6120 hush: simplify read builtin; fix set_local_var (misplaced 'goto skip;') 2007-05-16 12:52:15 +00:00
Denis Vlasenko 1f4cf517f5 hush: fix expansion of quoted $VAR, $* and $@ 2007-05-16 10:39:24 +00:00
Denis Vlasenko 8f6bdb42df hush: fix incorrect processing of echo "'$var'".
hush: rename map[] and MAP_xxx, making them easier to understand.
hush: move testcase (which now passes) from hush-bugs to hush-parsing
2007-05-16 09:36:55 +00:00
Denis Vlasenko 418a7fb29b netstat: introduce -W: wide, ipv6-friendly output
netstat: shrink by ~500 bytes
(patch by Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>)
netstat: fix for bogus state value for raw sockets
2007-05-15 23:57:46 +00:00
Bernhard Reutner-Fischer c2b3e370d6 - apply hunk that fixes an issue with (wrong?) dependencies. Initial notes were:
There is something wrong in the new buildsys: If one selects ip and has e.g.
  rule or route unset, ip still wants to build those.
  This fails (correctly) since rtnl_rttable_n2a and rtnl_rtrealm_n2a aren't
  available if they were turned off. TODO: Talk to vda about this
2007-05-15 09:33:32 +00:00
Bernhard Reutner-Fischer 64332bf857 - busybox.c was removed a while ago 2007-05-15 09:07:06 +00:00
Denis Vlasenko d6050949b8 hush: move testsuite files from hush-bugs to hush-parsing
(as these bugs are now fixed)
2007-05-14 22:09:52 +00:00
Denis Vlasenko 764d59d488 hush: more fixes to variable expansion, more testcases 2007-05-14 16:23:23 +00:00
Denis Vlasenko 03eb8bf6ce hush: move towards more correct variable expansion
hush: fix a few cases in FOR v IN ... construct
      unfortunately, code growth is big - ~600 bytes
2007-05-14 16:19:34 +00:00
Denis Vlasenko 602d13cba5 hush: fix '{ false; echo $?; }' bug.
hush: expand testsuite. variable expansion is still very broken
2007-05-13 18:34:53 +00:00
Denis Vlasenko 119b995437 hush: reinstate hush_test, add testcases for process subst 2007-05-11 12:57:35 +00:00
Denis Vlasenko 3e9aaae5dc hush: fix bug in interactive shell introduced yesterday
hush: fix `process subst` (2 bugs)
NB: will delete and re-add hush_test in order to change file modes
2007-05-11 12:56:43 +00:00
Denis Vlasenko e0a336747c hush: fix "unterminated last line loops forever" bug
hush: add testsuite infrastructure
2007-05-10 23:06:55 +00:00
Denis Vlasenko 53079d494e hush: fix recent breakage (VAR=VAL stopped working) 2007-05-10 23:05:28 +00:00
Denis Vlasenko 2b54aaa9bf msh: fix obscure case with backticks and closed fd 1 2007-05-09 22:16:08 +00:00
Denis Vlasenko 389f9d52d5 awk: don't segfault on printf(%*s). Close 1337. 2007-05-09 21:57:23 +00:00
Denis Vlasenko 57bf668d11 cryptpw: size reduction
function                                             old     new   delta
cryptpw_main                                         198     140     -58
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-58)             Total: -58 bytes
2007-05-09 21:27:15 +00:00
Denis Vlasenko 68de720723 mount: fix incorrect usage of strtok (inadvertently used NULL sometimes).
the change is "for(xxx)...." -> "if(var) for(xxx)...", but my gcc 4.1.2
adds _158 bytes_!! WTF?? 8(
2007-05-09 20:38:04 +00:00
Denis Vlasenko 8465a99ce7 less: fix case when regex search finds nothing 2007-05-09 18:32:54 +00:00
Denis Vlasenko bf678d5423 tftp: explain "block# 0" codepath; report our decision to bail out to server
if blocksize option doesn't look good (it was a FIXME. +33 bytes code);
make code more readable.
2007-05-09 12:50:08 +00:00
Denis Vlasenko a035e9f1a9 cryptpw: forgot svn add... how typical of me :( 2007-05-08 23:23:35 +00:00
Denis Vlasenko a04561f5f7 tftp: code diet, and I think retransmits were broken.
function                                             old     new   delta
static.errcode_str                                     -      32     +32
tftp_main                                            359     345     -14
tftp_bb_error_msg                                     32       -     -32
.rodata                                           130931  130899     -32
tftp                                                1720    1558    -162
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 0/3 up/down: 32/-240)          Total: -208 bytes
2007-05-08 23:12:21 +00:00
Denis Vlasenko 7e84e539de cryptpw: new applet (a bit less than 3k added)
(by Thomas Lundquist <lists@zelow.no>)
2007-05-08 17:52:17 +00:00
Denis Vlasenko 92c0b8222e tail: fix SEGV on "tail -N"
config system: clarify PREFER_APPLETS/SH_STANDALONE effects in help text
2007-05-08 17:27:17 +00:00
Denis Vlasenko 0cacc80952 kill: improve comment 2007-05-06 22:51:52 +00:00
Denis Vlasenko 02f47e9f81 kill: fix recent breakage of vda, also make code smaller by 21 bytes. 2007-05-06 22:48:55 +00:00
Denis Vlasenko 21f0d4c55e hush: fix double-free in "echo TEST &" 2007-05-06 14:15:42 +00:00
Denis Vlasenko b952835efe svlogd: fix 'SEGV on uninitialized data' and make it honor TERM 2007-05-06 01:37:21 +00:00
Denis Vlasenko dd4cb2b31e hush: stop generating extra empty pipes in parse stage. 2007-05-05 15:11:40 +00:00
Denis Vlasenko a6c467f6d1 hush: preparatory patch for removing extra empty pipes generation
in parse stage. No real code change here.
2007-05-05 15:10:52 +00:00
Denis Vlasenko 734e5ebc93 fix -Werror compile 2007-05-04 21:38:14 +00:00
Denis Vlasenko ac0e5ab96a hush: fix "while true; do true; done" + ctrl-z 2007-05-04 21:37:27 +00:00
Denis Vlasenko 3349fc4da9 applets: fix compile-time warning 2007-05-04 14:54:36 +00:00
Denis Vlasenko 400c5b6fc6 hush: add parse tree debug print 2007-05-04 13:07:27 +00:00
Denis Vlasenko 6e6d331d97 udhcpc: stop deleting our own pidfile if we daemonize.
udhcp[cd]: stop using atexit magic fir pidfile removal.
2007-05-03 23:39:35 +00:00
Denis Vlasenko f71d916b60 awk: guard against empty environment 2007-05-03 22:57:56 +00:00
Denis Vlasenko e725bfe6e0 hush: fix "true | exit 3; echo $?" bug 2007-05-03 22:45:39 +00:00
Denis Vlasenko f2fffd0014 hush: remove env builtin (it is buggy). Add comments 2007-05-02 23:39:04 +00:00
Denis Vlasenko 3bc18253b0 fix suid config handling 2007-05-02 23:01:32 +00:00
Denis Vlasenko f92df58d3d ifupdown: small optimization (avoid doing useless work if we are
not going to update state file)
2007-05-02 22:22:23 +00:00
Mike Frysinger 3c82e48923 allow people to stick custom things into Makefile.local so they dont need to update busybox files while integrating into other build systems (like uClinux-dist) 2007-05-02 22:07:03 +00:00
Denis Vlasenko eda43d7f45 ifupdown: mke it possible to use DHCP clients different from udhcp. 2007-05-02 22:04:38 +00:00
Denis Vlasenko d01ff13454 hush: simplify debugging prints a little bit 2007-05-02 21:40:23 +00:00
Denis Vlasenko dd999a2241 klogd: remove dependency on syslogd 2007-05-02 21:39:29 +00:00
Denis Vlasenko bd100b7478 ifupdown: reread state file before rewriting it.
Fixes "ifup started another ifup" state corruption bug.
Patch by Natanael Copa <natanael.copa@gmail.com>.
2007-05-02 21:38:44 +00:00
Denis Vlasenko 4ac530c0ef hush: add debugging for tracing execution,
add FIXME for 'true | exit 3; echo $?' case
2007-05-02 15:35:45 +00:00
Denis Vlasenko ef36ead370 hush: fix incorrect exitcodes without job control 2007-05-02 15:34:47 +00:00
Denis Vlasenko dcf4de20a1 test: code size saving, no logic changes
ps: fix warning, make a bit smaller
kill -l: make smaller & know much more signals

function                                             old     new   delta
get_signum                                           121     153     +32
kill_main                                            826     843     +17
get_signame                                           44      36      -8
signals                                              252     224     -28
.rodata                                           131955  131923     -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/3 up/down: 49/-68)            Total: -19 bytes
2007-05-01 20:07:29 +00:00
Denis Vlasenko f20de5bb42 ash,kill: use common code for kill applet/builtin
# make bloatcheck
function                                             old     new   delta
evaltreenr                                           644     654     +10
evaltree                                             644     654     +10
parse_conf                                          1440    1444      +4
dpkg_deb_main                                        426     429      +3
ed_main                                             3319    3321      +2
passwd_main                                         2093    2091      -2
kill_main                                            830     826      -4
singlemount                                         4609    4601      -8
find_command                                         962     954      -8
get_lcm                                              123     105     -18
.rodata                                           132243  132147     -96
killcmd                                              449     120    -329
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/7 up/down: 29/-465)          Total: -436 bytes

# size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 723901    2940   27504  754345   b82a9 busybox_old
 723457    2940   27504  753901   b80ed busybox_unstripped
2007-04-29 23:42:54 +00:00
Denis Vlasenko d4728145e3 run_parts: do not check path portion of a name for "bad chars".
Needed for ifupdown. Patch by "Gabriel L. Somlo" <somlo@cmu.edu>
2007-04-29 23:38:12 +00:00
Denis Vlasenko 08c8c1d3b3 ash: fix infinite loop on exit if tty is not there anymore 2007-04-28 22:39:02 +00:00
Denis Vlasenko e3f2f89891 hush: make job control and interactiveness configurable, part 2 2007-04-28 16:48:27 +00:00
Denis Vlasenko b81b3df1fa hush: make job control and interactiveness configurable, part 1 2007-04-28 16:48:04 +00:00
Denis Vlasenko 0937be5fa6 hush: make hush properly detect EOF on stdin (even interactive one -
think about pty being destroyed) and exit.
2007-04-28 16:47:08 +00:00
Denis Vlasenko b5eaabb322 hush: add Ctrl-C handling to nofork case 2007-04-28 16:45:59 +00:00
Denis Vlasenko 3ac0e00553 hush: better signal handling across ctrl-z 2007-04-28 16:45:22 +00:00
Denis Vlasenko 18e19f2b0d hush: fix nofork + ctrl-Z clobbering of globals 2007-04-28 16:43:18 +00:00
Denis Vlasenko a6a1785a30 hush: add ctrl-Z handling for nofork'ed case 2007-04-28 16:42:11 +00:00
Denis Vlasenko 706fdc98c3 find_root_device: use lstat - don't follow links 2007-04-21 23:28:03 +00:00
Denis Vlasenko 1359da6ac7 hush: make Ctrl-Z work (at least sometimes) 2007-04-21 23:27:30 +00:00
Denis Vlasenko 762d35c75f hust: add a comment 2007-04-21 17:28:51 +00:00
Denis Vlasenko 52881e9f23 hush: fix more backgrounding bugs. Plenty of them remains still. 2007-04-21 13:42:52 +00:00
Denis Vlasenko 2f1bb36a55 hush: explain why "pipe; exit $?" doesn't show correct exitcode 2007-04-21 10:01:14 +00:00
Denis Vlasenko 87cb2db703 hush: do not print message if killed by signal;
move some functions up before main()
2007-04-21 10:00:01 +00:00
Denis Vlasenko 54e7ffb3a4 hush: begin fixing non-functional job control 2007-04-21 00:03:36 +00:00
Denis Vlasenko 5f786c24e4 hush: small code shrink; style fixes 2007-04-20 08:35:45 +00:00
Denis Vlasenko f6250a3bee dd: NOEXEC fix
dd: correct wrongly capitalized constant
2007-04-19 20:16:14 +00:00
Denis Vlasenko d1801a4430 dd: fix skip= parse error (spotted by Dirk Clemens <develop@cle-mens.de>) 2007-04-19 20:08:19 +00:00
Denis Vlasenko 9ace613406 stty: fix option parsing bug (spotted by Sascha Hauer <s.hauer@pengutronix.de>) 2007-04-19 19:55:54 +00:00
Denis Vlasenko 05a6d9cbb2 doc: add README on shell job control 2007-04-19 17:26:34 +00:00
Denis Vlasenko 8581863a1b procps: remove all global variables
text    data     bss     dec     hex filename
   1462      14      24    1500     5dc busybox.t2/procps/ps.o
   1484       0       0    1484     5cc busybox.t3/procps/ps.o
   3122       0     252    3374     d2e busybox.t1/procps/top.o
   3117       0       0    3117     c2d busybox.t3/procps/top.o
2007-04-19 14:47:11 +00:00
Denis Vlasenko 516a0ca2dc ps: add -o tty and -o rss support
1373      14      24    1411     583 busybox.t1/procps/ps.o
   1462      14      24    1500     5dc busybox.t2/procps/ps.o
2007-04-19 14:46:14 +00:00
Denis Vlasenko c34d35557b loop device code: readability improvement 2007-04-19 00:09:34 +00:00
Denis Vlasenko 3ace9fa6d8 switch_root: error_msg -> perror_msg, reduce by 22 bytes while at it. 2007-04-18 21:40:30 +00:00
Denis Vlasenko 088b959d00 "Unify base64 handling" is done, remove TODO 2007-04-18 21:14:46 +00:00
Denis Vlasenko 2ace1e3f07 make "busybox" w/o args work again, and save 10 bytes in the process. 2007-04-18 21:00:21 +00:00
Denis Vlasenko 55b2de71d7 hush: remove stray semicolon (should change nothing) 2007-04-18 17:21:28 +00:00
Denis Vlasenko 517d1aac7f ether-wake: save a few more bytes of code 2007-04-16 23:23:33 +00:00
Denis Vlasenko 198714c0dd ether-wake: close bug 1317. Reorder fuctions to avoid
forward refs while at it
2007-04-16 23:16:37 +00:00
Denis Vlasenko 7d4c44e1b1 shells: remove few statics and duplicated code
(much more of the same remains, alas)
function                                             old     new   delta
doset                                                330     332      +2
warn                                                  53      51      -2
onecommand                                           463     461      -2
ioecho                                                40      38      -2
forkexec                                            1412    1410      -2
err                                                   81      79      -2
setdash                                               59      56      -3
flag                                                   4       -      -4
msh_main                                            1389    1384      -5
eval                                                 388     381      -7
subgetc                                              759     747     -12
static.local                                          14       -     -14
b_adduint                                             70      52     -18
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/10 up/down: 2/-73)            Total: -71 bytes
2007-04-16 22:34:39 +00:00
Denis Vlasenko ac678ec2f1 style fixes, no code changes 2007-04-16 22:32:04 +00:00
Denis Vlasenko 17e3c34aa7 applet.c: ruid is needed only if FEATURE_SUID=y 2007-04-16 20:55:27 +00:00
Bernhard Reutner-Fischer bc9d7d788b - we unconditionally need ruid. Fixes build error in line 334 2007-04-16 18:25:46 +00:00
Bernhard Reutner-Fischer ab51bf4e28 - fix compilation when ENABLE_FEATURE_IP_RULE was off 2007-04-16 14:56:01 +00:00
Bernhard Reutner-Fischer e468ef27b7 - fix compilation if ENABLE_FEATURE_DD_IBS_OBS is off 2007-04-16 12:21:05 +00:00
Denis Vlasenko 0922192740 lineedit: state->hist_file doesn't exist if !FEATURE_EDITING_SAVEHISTORY,
#ifdef it out
2007-04-15 13:21:01 +00:00
Denis Vlasenko 84f75b0b94 doc: fix code example which may provoke warning 2007-04-15 11:50:41 +00:00
Denis Vlasenko 8acf521432 e2fsprogs: stop using statics in chattr. Minor code shrinkage (-130 bytes) 2007-04-15 11:48:27 +00:00
Denis Vlasenko be1a9d4237 deluser: add optional support for removing users from groups
(by Tito <farmatito@tiscali.it>)
2007-04-15 08:43:23 +00:00
Denis Vlasenko 91de7c0328 update style-guide.txt 2007-04-15 08:39:39 +00:00
Denis Vlasenko 58394b1e29 xargs: simplify word list management 2007-04-15 08:38:50 +00:00
Denis Vlasenko e471275813 msh: style fixes
shell/README - a place to record things about busybox shells
2007-04-14 15:08:41 +00:00
Denis Vlasenko 5f9468e996 lineedit: nuke two unused variables and code which sets them
applets: do not even try to read config if run by real root
msh: use named constants (O_RDONLY etc) in open() instead of magic numbers,
     other minor code size reduction.
2007-04-14 13:22:09 +00:00
Denis Vlasenko 8a28e620ce lash: recognize and use NOFORK applets
lash,hush: fix kill buglet (didn't properly recognize ESRCH)
2007-04-14 11:16:29 +00:00
Denis Vlasenko bf3561fd15 lineedit: do not try to open NULL history file 2007-04-14 10:10:40 +00:00
Denis Vlasenko f5294e1f4c hush: use NOFORK applets as appropriate. Net reduction of code size. 2007-04-14 10:09:57 +00:00
Denis Vlasenko 16abcd90ae teach find_root_device to deal with /dev/ subdirs
(by "Kirill K. Smirnov" <lich@math.spbu.ru>)
2007-04-13 23:59:52 +00:00
Denis Vlasenko 334fa9bcb5 dpkg: use nitfields which are a bit closer to typical ushort.
Code size -800.
2007-04-13 23:22:58 +00:00
Denis Vlasenko 87468857f6 style fixes 2007-04-13 23:22:00 +00:00
Denis Vlasenko f7fcca4af7 sourse_route_list -> source_route_list 2007-04-13 22:07:21 +00:00
Denis Vlasenko 1d6a4aec2c make xsocket die with address family printed (if VERBOSE_RESOLUTION_ERRORS=y) 2007-04-13 21:26:20 +00:00
Denis Vlasenko fbf6dea5a2 hush: more style fixes. 2007-04-13 19:56:56 +00:00
Denis Vlasenko f03dbeda90 hush: comment out and replace bug in set_local_var:
-       if (value == 0 && ++value == 0) {
+       /*if (value == 0 && ++value == 0) ??? -vda */
+       if (value == NULL || value[1] == '\0') {

Style fixes.
2007-04-13 19:55:50 +00:00
Denis Vlasenko b636d8c18c shell/: add SUSv3 doc for fast & easy reference 2007-04-13 19:44:22 +00:00
Denis Vlasenko beaca811e4 fix typo in comment 2007-04-13 16:32:26 +00:00
Denis Vlasenko 62f0479cf1 find: add support for -delete, -path (by Natanael Copa) 2007-04-13 10:00:12 +00:00
Denis Vlasenko 945bd3dee8 sed: fix escaped newlines in -f; fix multiple -f and -e
(broke when getopt32 was fixed to not reverse the list)
2007-04-12 21:20:25 +00:00
Denis Vlasenko 3211adc184 login: fixing my brainfart: xspawn(t_argv) <- was using argv! 2007-04-12 20:33:01 +00:00
Mike Frysinger 3a62a737f7 make sure we free the grep data as well 2007-04-12 18:29:27 +00:00
Denis Vlasenko b69f35effe 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.
2007-04-12 17:10:45 +00:00
Denis Vlasenko 7cced6e574 fix realloc-of-non-malloced pointer, and reduce size while at it 2007-04-12 17:08:53 +00:00
Denis Vlasenko 0de3c55b42 login: remove setpgrp call (makes it work from shell prompt again).
login: sanitize stdio descriptors (we are suid, need to be careful!)
shrink login and set_environment by ~100 bytes.
2007-04-12 12:31:02 +00:00
Denis Vlasenko 831a20f512 pass a copy of argv[i] to NOFORK applets (they may permute it etc).
set/save/restore more shared global variables whan call one applet from another
2007-04-12 12:27:32 +00:00
Bernhard Reutner-Fischer c98c31783c - shrink iproute a bit (-200 bytes). Untested 2007-04-12 11:36:56 +00:00
Bernhard Reutner-Fischer b290889f02 - add xsendto and use where appropriate; shrink iplink; sanitize libiproute a bit.
-916 byte
2007-04-12 11:34:39 +00:00
Denis Vlasenko 51742f4bb0 style fixes. No code changes 2007-04-12 00:32:05 +00:00
Denis Vlasenko 50f7f446ec bb_full_fd_action: remove potential xmalloc from NOFORK path
cat: stop using stdio.h opens
libbb: introduce & use open[3]_or_warn
function                                             old     new   delta
open3_or_warn                                          -      54     +54
bb_cat                                               115     144     +29
open_or_warn                                           -      25     +25
unlzma                                              2404    2412      +8
chattr_main                                          334     339      +5
xstrtoul_range_sfx                                   251     255      +4
telnet_main                                         1514    1510      -4
static.opt                                             4       -      -4
qgravechar                                           122     118      -4
fuser_add_pid                                         61      54      -7
fuser_add_inode                                      154     147      -7
writeFileToTarball                                  1542    1534      -8
refresh                                             1156    1148      -8
do_show                                              856     846     -10
read_leases                                          212     200     -12
setup_redirects                                      236     222     -14
iproute_list_or_flush                               1582    1568     -14
read_config                                          427     411     -16
write_leases                                         284     264     -20
hash_file                                            338     318     -20
copy_file                                           1760    1740     -20
do_iproute                                          2610    2588     -22
bb_full_fd_action                                    320     269     -51
open_to_or_warn                                      103      49     -54
fuser_main                                          1660    1596     -64
.rodata                                           131160  131096     -64
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 4/19 up/down: 125/-423)        Total: -298 bytes
2007-04-11 23:20:53 +00:00
Denis Vlasenko d7c8196c1b ash: fix kill -l (by Mats Erik Andersson <mats.andersson64@comhem.se>) 2007-04-11 20:43:31 +00:00
Denis Vlasenko 8fd371276f fix typo in doc 2007-04-11 19:27:22 +00:00
Denis Vlasenko 6398cf477d style fixes, no code changes. 2007-04-11 17:04:29 +00:00
Denis Vlasenko e4f2d064b0 rename: run_applet_by_name -> run_applet_and_exit 2007-04-11 17:03:19 +00:00
Bernhard Reutner-Fischer 12c96a64a4 - set the scope properly. Thanks to Jean Wolter, who wrote:
busybox ip and the original ip utility behave differently when setting
the following route (verified with ip route show using the original ip
utility):

   ip route add 10.0.0.138 dev eth0

Result for busybox ip:

       # ip route add 10.0.0.138 dev eth0
       # /usr/local/bin/ip route show
       10.0.0.138 dev eth0

Result for ip:

       # /usr/local/bin/ip route add 10.0.0.138 dev eth0
       #  /usr/local/bin/ip route show
       10.0.0.138 dev eth0  scope link

A following "ip route add default via 10.0.0.138" fails for busybox
ip, since the kernel can not find a route to 10.0.0.138 (it replies
with Network is unreachable).

The reasons seems to be that the original ip utility explicitly sets
the scope after parsing all parameters. This is missing in busybox,
the attached patch fixes this. I took this from the original iproute
sources and removed some variables, which are not needed for busybox.
2007-04-11 16:23:57 +00:00
Denis Vlasenko 0d058361e7 Add NOFORK/NOEXEC documentation. 2007-04-11 16:16:41 +00:00
Denis Vlasenko 03fc408de6 fix typo in comment 2007-04-11 07:36:31 +00:00
Denis Vlasenko d571c08c25 fix misplaced #if 2007-04-11 07:26:56 +00:00
Denis Vlasenko 473dae080a add more convenient defines for [NO]MMU:
"#ifndef BB_NOMMU" is a double negative
2007-04-11 07:04:23 +00:00
Denis Vlasenko f1a7141cfc random NOMMU fixes. compressed --help really does work for NOMMU! /me happy 2007-04-10 23:32:37 +00:00
Denis Vlasenko 80d14beae9 Rename two config options:
FEATURE_SH_STANDALONE_SHELL => FEATURE_SH_STANDALONE
FEATURE_EXEC_PREFER_APPLETS => FEATURE_PREFER_APPLETS
Make SH_STANDALONE depend on PREFER_APPLETS.
getopt.c: more randomconfig-induced fixes
2007-04-10 23:03:30 +00:00
Denis Vlasenko 8905496444 xargs: fix my brain fart (resulted in memory leak) 2007-04-10 21:41:16 +00:00
Denis Vlasenko c6758a07c6 make compressed help code NOMMU- and NOFORK-friendly -
no forking anymore, bunzip2 unpack routine now does all it in memory.
2007-04-10 21:40:19 +00:00
Denis Vlasenko 335b63d8d1 make a few struct bb_applet members conditional
rename sllep_and_die -> xfunc_die
make fflush_stdout_and_exit NOFORK-safe
fix some buglets found by randomconfig
2007-04-10 21:38:30 +00:00
Bernhard Reutner-Fischer 07c394e69b - mv ip*_main into ip.c; use a dispatcher to save on needless duplication.
Saves a minor 12b.
2007-04-10 20:11:12 +00:00
Bernhard Reutner-Fischer 99003b8a87 - use enum for the OPs as suggested by vda. No obj-code changes. 2007-04-10 19:30:50 +00:00
Bernhard Reutner-Fischer f73cac8d3d - forgot this hunk that corrects the usage text of ip 2007-04-10 19:00:08 +00:00
Bernhard Reutner-Fischer e87d7955f8 - rewrite the ip applet to be less bloaty
- mark libiproute's matches() as deprecated. Convert to index_in_(sub)str_array()!
   text    data     bss     dec     hex filename
    314       0       0     314     13a ip.o.orig
    200       0       0     200      c8 ip.o
Using a smallint for the key would save another byte.
2007-04-10 18:43:27 +00:00
Bernhard Reutner-Fischer 51f7ab6162 - add ATTRIBUTE_DEPRECATED for functions that should be removed in the future.
This is ment to provide means to point at cruft marked for cleanup.
2007-04-10 18:40:05 +00:00
Denis Vlasenko 246b5c3916 one-liner: fix indentation 2007-04-10 17:18:12 +00:00
Denis Vlasenko b38cf3ff8a bunzip2: big style cleanup. No code changes apart from one s/write/safe_write/
(verified with objdump).
2007-04-10 17:16:33 +00:00
Denis Vlasenko a9d7d24e1f echo: fix regression ("echo" with no arguments didn't print newline.
echo: use fputs if no options are given. Code growth ~15 bytes.

Old:
# time ./busybox find $bigdir -exec echo {} \; >/dev/null
real    0m2.038s
user    0m0.761s
sys     0m0.953s

New:
# time ./busybox find $bigdir -exec echo {} \; >/dev/null
real    0m1.781s
user    0m0.781s
sys     0m0.939s

For comparison: without NOFORK:
# time find $bigdir -exec echo {} \; >/dev/null
real    1m51.129s
user    0m38.442s
sys     1m3.350s
2007-04-10 16:34:00 +00:00
Denis Vlasenko 99912ca733 audit small applets and mark some of them as NOFORK.
Put big scary warnings in relevant places.
2007-04-10 15:43:37 +00:00
Denis Vlasenko ff131b980d style fixes. No code changes. 2007-04-10 15:42:06 +00:00
Bernhard Reutner-Fischer 163516da3a - very minor shrinkage (-3b) 2007-04-10 14:16:19 +00:00
Bernhard Reutner-Fischer de17ece1db - use skip_non_whitespace() where appropriate 2007-04-10 09:38:35 +00:00
Bernhard Reutner-Fischer 8b1fab2879 - add prototype for str_tolower() 2007-04-10 09:38:07 +00:00
Bernhard Reutner-Fischer 7e8a53a335 - add libbb function str_tolower to convert a string to lowercase.
- shrink wget a bit
2007-04-10 09:37:29 +00:00
Denis Vlasenko 3f3aa2a57d make xfunctions optionally longjump instead of exit.
use it for making NOFORK more practical.
touch: make it a NOFORK applet
2007-04-09 21:35:07 +00:00
Denis Vlasenko cd7001f705 factor out NOFORK/NOEXEC code from find. Use it for xargs too. 2007-04-09 21:32:30 +00:00
Denis Vlasenko 1b4b2cb20e xargs: shrink code, ~80 bytes
applets.h: +#undef APPLET_NOEXEC
2007-04-09 21:30:53 +00:00
Denis Vlasenko 53d445aa75 wait4pid: if passed with pid < 0, do not set errno - it is already set by exec! 2007-04-09 13:21:33 +00:00
Denis Vlasenko 7e754f12d3 Implement first instance of NOFORK applet - echo
find: use NOFORK/NOEXEC; small -exec buglet also eliminated
vfork_daemon_rexec: honor PREFER_APPLETS
echo: small size improvements

find -exec echo {} \; with PREFER_APPLETS=y runs 4 times faster
2007-04-09 13:04:50 +00:00
Denis Vlasenko 2dfdd44d9d busybox: fix "<applet>: applet not found" message 2007-04-09 03:29:43 +00:00
Denis Vlasenko c44ab01b75 Improve STANDALONE_SHELL. "safe" applets are renamed NOEXEC applets
and now this fact is recorded in applets.h, not ash.c.

Several fixes to "--help + STANDALONE_SHELL" scenarios.

function                                             old     new   delta
run_current_applet_and_exit                            -     355    +355
arith                                               2064    2073      +9
refresh                                             1148    1156      +8
getopt32                                            1068    1073      +5
telnet_main                                         1510    1514      +4
md5_sha1_sum_main                                    565     566      +1
xstrtoul_range_sfx                                   255     251      -4
packed_usage                                       22523   22514      -9
tryexec                                              255     203     -52
static.safe_applets                                  152       -    -152
.rodata                                           131320  131128    -192
run_applet_by_name                                   869     506    -363
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 5/5 up/down: 382/-772)         Total: -390 bytes

./busybox ash -c 'i=20000; while test $i != 0; do touch z; i=$((i-1)); done'
runs more than twice as fast with STANDALONE_SHELL versus without.
2007-04-09 03:11:58 +00:00
Denis Vlasenko 95cb3263ae msh: smallish code shrinkage; cosmetics 2007-04-09 03:06:34 +00:00
Denis Vlasenko 32b633aa3f merge busybox.c into applets.c 2007-04-09 03:05:48 +00:00
Denis Vlasenko 786834bcee applets.h: de-obfuscate 2007-04-08 17:30:10 +00:00
Denis Vlasenko 240a1cfbbe add some missed statics on constant objects.
fix few #ifndef ENABLE_xxx

# size busybox_old busybox_unstripped
   text    data     bss     dec     hex filename
 677152    2920   18208  698280   aa7a8 busybox_old
 676420    2920   18208  697548   aa4cc busybox_unstripped
2007-04-08 16:07:02 +00:00
Denis Vlasenko 5694d5f8d2 adding small script, mostly for documentational purposes 2007-04-08 15:12:21 +00:00
Denis Vlasenko 8d9f495d68 getopt32: fix llist_t options ordering. llist_rev is not unused.
function                                             old     new   delta
tar_main                                             705     695     -10
sort_main                                            928     918     -10
decode_format_string                                 886     876     -10
run_parts_main                                       197     185     -12
ps_main                                              513     500     -13
wget_main                                           2764    2750     -14
awk_main                                            1014    1000     -14
od_main                                             2886    2866     -20
llist_rev                                             25       -     -25
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/8 up/down: 0/-128)           Total: -128 bytes
2007-04-08 15:08:42 +00:00
Denis Vlasenko b04b4357ff find: fix -prune more. Add big comment about it. 2007-04-08 11:10:43 +00:00
Denis Vlasenko bbd695d801 find: fix handling of -prune
recursive_actions: uppercase flag constants
2007-04-08 10:52:28 +00:00
Denis Vlasenko ca3484103e busybox.net: micro fix 2007-04-07 10:49:02 +00:00
Denis Vlasenko 1ae63fc1bc busybox.net: update "screenshot" 2007-04-07 10:46:33 +00:00
Denis Vlasenko 9c146a91d3 getopt: use getopt32 for option parsing - inspired by patch by
Mats Erik Andersson <mats.andersson64@comhem.se>
function                                             old     new   delta
getopt_main                                          809     810      +1
static.BUFFER                                          4       -      -4
shell                                                  8       4      -4
quote                                                  4       -      -4
quiet_output                                           4       -      -4
quiet_errors                                           4       -      -4
long_options_nr                                        4       -      -4
long_options_length                                    4       -      -4
long_options                                         388     384      -4
alternative                                            4       -      -4
shortopts                                             15       -     -15
normalize                                            243     220     -23
.rodata                                           131832  131800     -32
add_longopt                                          200       -    -200
------------------------------------------------------------------------------
(add/remove: 0/9 grow/shrink: 1/4 up/down: 1/-306)           Total: -305 bytes
2007-04-07 10:25:04 +00:00
Denis Vlasenko fdf63a30fe docs: "how to add a patch" 2007-04-07 09:35:56 +00:00
Denis Vlasenko 540a2a1f3b libiproute: audit callgraph, shortcut error paths into die() functions.
Kill a few statics, made other globals smaller:
oneline is smallint, _SL_ is char

function                                             old     new   delta
print_tunnel                                         693     731     +38
print_route                                         1775    1777      +2
print_addrinfo                                      1495    1497      +2
ipaddr_list_or_flush                                2826    2828      +2
oneline                                                4       1      -3
_SL_                                                   4       1      -3
ipaddr_modify                                       1476    1472      -4
parse_address                                        124     119      -5
ip_parse_common_args                                 429     423      -6
on_off                                                53      46      -7
do_del_ioctl                                         113     106      -7
do_add_ioctl                                         120     113      -7
do_show                                              864     856      -8
iprule_list                                          157     148      -9
do_iptunnel                                          310     299     -11
do_add                                               143     126     -17
get_ctl_fd                                            95      76     -19
set_address                                          108      84     -24
ip_main                                              351     323     -28
static.ifr                                            32       -     -32
parse_args                                          1992    1949     -43
iproute_list_or_flush                               1673    1582     -91
do_iplink                                           1583    1485     -98
filter                                               280       -    -280
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 4/18 up/down: 44/-702)         Total: -658 bytes
2007-04-07 01:14:45 +00:00
Denis Vlasenko fbd2918f5c udhcp: MAC_BCAST_ADDR and blank_chaddr are in fact constant, move to rodata.
a few global variables reduced to smallints
function                                             old     new   delta
add_lease                                             75     227    +152
static.blank_chaddr                                    -      16     +16
MAC_BCAST_ADDR                                         -       6      +6
sockfd                                                 4       8      +4
udhcp_run_script                                    1153    1155      +2
state                                                  8       5      -3
listen_mode                                            4       1      -3
perform_release                                      152     148      -4
fd                                                     8       4      -4
blank_chaddr                                          16       -     -16
udhcpc_main                                         2518    2497     -21
.rodata                                           131864  131832     -32
oldest_expired_lease                                  61       -     -61
clear_lease                                          127       -    -127
------------------------------------------------------------------------------
(add/remove: 2/3 grow/shrink: 3/6 up/down: 180/-271)          Total: -91 bytes
2007-04-07 01:05:47 +00:00
Denis Vlasenko bb5b01c7c7 comm: eliminate statics 2007-04-07 00:45:27 +00:00
Denis Vlasenko 04c99ebb4f random small shrinkage and elimination of statics 2007-04-07 00:44:31 +00:00
Denis Vlasenko 19507f0869 nc: code shrinkage, bugfixes. -50 bytes code size 2007-04-06 10:41:05 +00:00
Denis Vlasenko 5a30d59c3d svn add match_fstype.c :( 2007-04-05 22:19:43 +00:00
Denis Vlasenko bf295dd5b6 [u]mount: extend -t option (Roy Marples <uberlord@gentoo.org>) 2007-04-05 21:57:47 +00:00
Denis Vlasenko df5bbb938a diff: fix segfault on empty dirs (Peter Korsgaard <peter.korsgaard@barco.com>) 2007-04-05 21:29:42 +00:00
Denis Vlasenko 1bb552b1d9 libbb: add xunlink()
patch: do not try to delete same file twice
2007-04-05 21:25:15 +00:00
Mike Frysinger 9020d850bf less intrusive export of FLTFLAGS 2007-04-05 21:14:29 +00:00
Mike Frysinger c7b10dc037 set default FLTFLAGS for a fatty stack 2007-04-05 21:10:59 +00:00
Denis Vlasenko 2f7b923f5c find: improve usage text (Natanael Copa <natanael.copa@gmail.com>) 2007-04-05 21:01:06 +00:00
Denis Vlasenko 5f42d26865 nc: missed exit() in signal handler 2007-04-05 20:57:10 +00:00
Denis Vlasenko 29fe7265b8 nc: port nc 1.10 to busybox 2007-04-05 20:26:28 +00:00
Bernhard Reutner-Fischer 00c2c4868a - clean up addgroup, fix adding users to existing groups and make it optional (Tito) 2007-04-05 13:16:39 +00:00
Bernhard Reutner-Fischer 45aebfd32d - bail out if either file does not exist
Avoids filling my scrollback-buffer with superfluous information ;)
2007-04-05 12:27:12 +00:00
Bernhard Reutner-Fischer 2e75dcc80d - add -s|--spider which only checks if the file exists but does not download it's content.
Closes #1291
2007-04-05 10:31:47 +00:00
Bernhard Reutner-Fischer 6d79dd66cb - size and prune were mixed up 2007-04-05 09:40:12 +00:00
Bernhard Reutner-Fischer bdd253e450 - fix segfault in reset_ino_dev_hashtable() when *hashtable was null.
Seen in the testsuite for du -l .../testsuite on exit with CLEAN_UP enabled.
2007-04-05 09:21:24 +00:00
Denis Vlasenko 7d6c9296e7 find: missed 'ststic' on const data 2007-04-05 00:35:43 +00:00
Denis Vlasenko 56fce00fc7 find: un-DESKTOPize (Kai Schwenzfeier <niteblade@gmx.net>)
find: -group, -depth (Natanael Copa <natanael.copa@gmail.com>)
find: make constant array static, declare PARM_xx constants with enum
2007-04-04 23:41:35 +00:00
Bernhard Reutner-Fischer febe3c4211 - sed -e "s/char[[:space:]]*\*[[:space:]]*argv\[\]/char **argv/g" 2007-04-04 20:52:03 +00:00
Bernhard Reutner-Fischer d9c2d5fe4f - minor shrinkage
text    data     bss     dec     hex filename
   1431       0       4    1435     59b tail.o.orig
   1396       0       0    1396     574 tail.o
2007-04-04 20:29:15 +00:00
Bernhard Reutner-Fischer 10aed96f14 - remove debugging output. sorry.. 2007-04-04 17:58:39 +00:00
Bernhard Reutner-Fischer 24efe4f15f - note cosmetic glitch in tail 2007-04-04 17:57:55 +00:00
Denis Vlasenko 1ca332b367 reword comment 2007-04-04 17:49:47 +00:00
Bernhard Reutner-Fischer 2a47dea263 - remove bss users. Shrinkage while at it. See XXX for further, pre-existing bugs
text    data     bss     dec     hex filename
   1969       0      32    2001     7d1 dd.o.oorig
   1941       0       0    1941     795 dd.o
2007-04-04 14:01:23 +00:00
Bernhard Reutner-Fischer 3a60244ae9 - remove some bss users.
text    data     bss     dec     hex filename
   6220       8      14    6242    1862 stty.o.oorig
   6219       8       0    6227    1853 stty.o
2007-04-04 13:59:49 +00:00
Bernhard Reutner-Fischer 0e6ab01c5a - remove superfluous bss user (flags) and manually unswitch some areas:
text    data     bss     dec     hex filename
   4517       0      34    4551    11c7 stat.o.oorig
   4300       0      30    4330    10ea stat.o
2007-04-04 13:58:33 +00:00
Denis Vlasenko 794687947f Add/improve comment, shorten some usage texts. No code changes. 2007-04-04 11:02:55 +00:00
Denis Vlasenko 64a15124e7 ipsvd: use IP:PORT syntax for environment vars. Pros:
1. it's saner (matches internal libc sockaddr abstraction).
2. it's smaller.
Cons: not compatible with smarden's ipsvd.
Fix IPv6 define typos.
Stop interpreting options in prog's args.
Code size -162 bytes.
2007-04-04 10:16:15 +00:00
Denis Vlasenko 02fd66885c ipsvd: make udpsvd work similar to tcpsvd (multiple parallel
children for several streams of udp packets tested to work)
code size: -509 bytes
2007-04-03 23:23:10 +00:00
Denis Vlasenko b933ac1e25 ipsvd: fixes and improvements after testing 2007-04-03 12:09:46 +00:00
Denis Vlasenko 992e05b6f0 udpsvd: more work on it. works in limited testing. 2007-04-03 01:13:04 +00:00
Bernhard Reutner-Fischer cea0a8bccb - use bb_error_msg 2007-04-02 17:01:22 +00:00
Bernhard Reutner-Fischer 8025afad8a - use xregcomp. Untested. vda, isn't there a regfree missing here?
text    data     bss     dec     hex filename
   2522       0       0    2522     9da expr.o.r18305
   2478       0       0    2478     9ae expr.o
2007-04-02 16:54:41 +00:00
Bernhard Reutner-Fischer 3c5929a53b - remove some unneeded forward declarations. No obj-code changes. 2007-04-02 16:41:24 +00:00
Bernhard Reutner-Fischer adb01b1583 - remove args from bss, minor misc shrinkage while at it.
text    data     bss     dec     hex filename
   2577       0       4    2581     a15 expr.o
   2522       0       0    2522     9da expr.o
2007-04-02 16:38:13 +00:00
Denis Vlasenko 729bd9e0b0 test: comment out unused code
udpsvd: fake it compile
tcpsvd: more optimal memorizing of IP's for -C
2007-04-02 12:37:28 +00:00
Denis Vlasenko b05a939bcc udpsvd: forgotten 'svn add' 2007-04-02 06:17:45 +00:00
Denis Vlasenko 60fadaca28 udpsvd: next part of ipsvd applets (not working yet) 2007-04-01 19:10:36 +00:00
Denis Vlasenko 57a426b15b tcpsvd: fix line buffering, add firewall query code 2007-04-01 10:59:33 +00:00
Denis Vlasenko ba2fb719b9 Copyright, help text, whitespace cleanups 2007-04-01 09:39:03 +00:00
Denis Vlasenko 2856dab477 tcpsvd: new applet
It's a GPL-ed 'clone' of Dan Bernstein's tcpserver.
Author: Gerrit Pape <pape@smarden.org>
http://smarden.sunsite.dk/ipsvd/
size tcpsvd.o
   text    data     bss     dec     hex filename
   2571       4      16    2591     a1f tcpsvd.o
2007-04-01 01:18:20 +00:00
Denis Vlasenko f443bffd3c lash: make -c work; crush buffer overrun and free of non-malloced ptr
(from Mats Erik Andersson <mats.andersson64@comhem.se>)
2007-03-31 11:08:50 +00:00
Denis Vlasenko 6fa8b8e17f lash: style cleanup 2007-03-31 11:07:30 +00:00
Denis Vlasenko 9eb51ad6b9 website: link to post-1.5.0 fixes, fix dangling link 2007-03-31 10:32:27 +00:00
Denis Vlasenko ae47cd1da7 hdparm: fix multisector mode setting
(from Toni Mirabete <amirabete@catix.cat>)
2007-03-31 10:30:02 +00:00
Denis Vlasenko 4caa09a782 uniq: getopt32-ization. -38 bytes. 2007-03-31 10:19:11 +00:00
Denis Vlasenko 666c40c9fc unzip: fix xstrndup bug (xstrndup(s,n) can allocate less than n bytes!) 2007-03-31 10:17:24 +00:00
Bernhard Reutner-Fischer 7b881c7168 - fix compilation if FEATURE_TR_CLASSES is off. Sorry for that.. 2007-03-30 18:26:46 +00:00
Bernhard Reutner-Fischer cc890264d9 - debloat test. untested.
text    data     bss     dec     hex filename
   3154       0     172    3326     cfe test.o.oorig
   2683       0     172    2855     b27 test.o

This applet should be rewritten not to use such odd lexer semantics.
It duplicates code from all over the place (see XXX).
brrr
2007-03-30 18:23:36 +00:00
Bernhard Reutner-Fischer eceecea568 - fix bug where we did not reject invalid classes like '[[:alpha'
- debloat while at it:
   text    data     bss     dec     hex filename
   1554       0      19    1573     625 tr.o.oorig
   1357       0      16    1373     55d tr.o
2007-03-30 14:43:27 +00:00
Mike Frysinger 52a9db6bb8 introduce the concept of LDLIBS for additional libraries so that when we do the final link, the objects/libraries are in the correct order 2007-03-30 05:44:15 +00:00
Denis Vlasenko 2e723237c9 traceroute: move data off bss. small code optimizations.
function                                             old     new   delta
traceroute_main                                     4358    4397     +39
verbose                                               13       9      -4
useicmp                                                4       -      -4
nflag                                                  4       -      -4
split_suffices                                        40      24     -16
route                                                 16       -     -16
dumpleases_main                                      392     357     -35
gwlist                                                36       -     -36
whereto                                              128       -    -128
wherefrom                                            128       -    -128
packet                                               512       -    -512
------------------------------------------------------------------------------
(add/remove: 0/7 grow/shrink: 1/3 up/down: 39/-883)          Total: -844 bytes
2007-03-29 21:55:22 +00:00
Denis Vlasenko 53f83d68fb 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" <Kim.Heino@bluegiga.com>)
2007-03-29 19:42:19 +00:00
Denis Vlasenko 5e43d8591b dumpleases: getopt32()-ization
(from Mats Erik Andersson <mats.andersson64@comhem.se>)
2007-03-29 19:29:32 +00:00
Bernhard Reutner-Fischer a87ed2c716 - use index_in_str_array also for find_main
text    data     bss     dec     hex filename
   2605       1      12    2618     a3a find.o.r18274
   2602       1      12    2615     a37 find.o.r18275
2007-03-29 13:56:49 +00:00
Bernhard Reutner-Fischer 307d27df4f - remove bloated switch statement.
text    data     bss     dec     hex filename
   2706       1      12    2719     a9f find.o.r18273
   2605       1      12    2618     a3a find.o.r18274
2007-03-29 13:56:02 +00:00
Bernhard Reutner-Fischer 557b458767 - implement a TODO: Use index_in_str_array in parse_params
text    data     bss     dec     hex filename
   2771       1      12    2784     ae0 find.o.r18272
   2749       1      12    2762     aca find.o.-try-switch
   2706       1      12    2719     a9f find.o.r18273
2007-03-29 13:55:17 +00:00
Bernhard Reutner-Fischer 32773aca55 - Purely cosmetic type fiddling 2007-03-29 13:54:17 +00:00
Bernhard Reutner-Fischer 3e816c1252 - fold recurse, depthFirst and dereference params into one param flags.
Minor size improvement (-16b for size, -24b according to bloat-o-meter).
2007-03-29 10:30:50 +00:00
Bernhard Reutner-Fischer 3d43edb28c - update defconfig 2007-03-28 22:19:46 +00:00
Denis Vlasenko c7d4b98cbd run_parts: I was wrong, NULL termination is already done because
G is pre-initialized to 0.
2007-03-28 22:05:38 +00:00
Denis Vlasenko 45cd089df1 run_parts: NULL-terminate list of arguments; fix perror/error usage 2007-03-28 22:04:04 +00:00
Denis Vlasenko 450196c119 ps: work around libc bug: printf("%.*s\n", MAX_INT, buffer) 2007-03-28 21:57:12 +00:00
Bernhard Reutner-Fischer b7cffd4bed - rewrite run-parts
text    data     bss     dec     hex filename
   1029       0       0    1029     405 debianutils/run_parts.o-old
    478       0       0     478     1de debianutils/run_parts.o-new-bare
    600       0       0     600     258 debianutils/run_parts.o-new-full

bare, i.e. without long opts and fancy stuff
./scripts/bloat-o-meter bb_old busybox_unstripped   function                                             old     new   delta
act                                                    -     215    +215
run_parts_main                                       216     201     -15
valid_name                                            50       -     -50
runparts_long_options                                 64       -     -64
.rodata                                           124323  124163    -160
run_parts                                            513       -    -513
------------------------------------------------------------------------------
(add/remove: 1/3 grow/shrink: 0/2 up/down: 215/-802)         Total: -587 bytes
2007-03-28 20:35:13 +00:00
Bernhard Reutner-Fischer 0a537a0c57 - move additional fancy options not mandated by SUSv3 into a FANCY option 2007-03-28 16:48:40 +00:00
Bernhard Reutner-Fischer 0864f4d14f - fix formatting of help text 2007-03-28 16:46:03 +00:00
Bernhard Reutner-Fischer 58a275b303 - reinstate dmalloc and efence support 2007-03-28 15:00:27 +00:00
Denis Vlasenko 0eec4abb13 hdparm: flag variables can easily be smaller than long
function                                             old     new   delta
process_dev                                         5247    5325     +78
bb_ioctl_on_off                                       72      78      +6
unregister_hwif                                        4       1      -3
...
perform_reset                                          4       1      -3
parse_xfermode                                       111     108      -3
noisy_piomode                                          4       1      -3
...
do_flush                                               4       1      -3
do_ctimings                                            4       1      -3
static.parm                                            4       -      -4
static.multcount                                       4       -      -4
parse_opts                                            54      48      -6
hdparm_main                                         1435    1383     -52
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 2/61 up/down: 84/-243)         Total: -159 bytes
2007-03-28 01:00:45 +00:00
Denis Vlasenko 7c282a2078 hdparm: remove stray static (-200 bytes bss) 2007-03-28 00:14:54 +00:00
Denis Vlasenko f1ba749509 hdparm: whitespace style fixes 2007-03-28 00:14:01 +00:00
Denis Vlasenko 6a5598c2bc pidfile creation mode set to 0666 (umask affects it as usual) 2007-03-27 22:05:34 +00:00
Denis Vlasenko ebf48bb80c forgotten svn add... 2007-03-27 22:02:06 +00:00
Denis Vlasenko 10457b90db make pidfile writing configurable.
[ui]toa_to_buf: change API. No users yet.
2007-03-27 22:01:31 +00:00
Denis Vlasenko f4d40c87d3 remove_file: cosmetic code improvement, a few bytes saved 2007-03-26 23:14:38 +00:00
Denis Vlasenko 3983bd5593 diff: fix SEGV (NULL deref) in diff -N 2007-03-26 22:58:21 +00:00
Denis Vlasenko 17a1526f9e sed: a communal variable managed to slip past 'size'
('size' happily displays 0 bytes in data and bss,
but in reality sed.o used 180 bytes of it). Oh well.
function                                             old     new   delta
pipe_putc                                             67      76      +9
sed_main                                             627     633      +6
get_next_line                                        161     166      +5
bbg                                                  180       -    -180
(add/remove: 0/1 grow/shrink: 3/0 up/down: 20/-180)          Total: -160 bytes

sed: also make sed -i failure message less cryptic
2007-03-26 20:48:46 +00:00
Denis Vlasenko 91dd275f05 split: let me join bikeshed painting frenzy :)
this one should be able to handle huge files.
   text    data     bss     dec     hex filename
    664       4       0     668     29c busybox.t0/coreutils/split.o
    628       0       0     628     274 busybox.t1/coreutils/split.o
split_main                                           488     525     +37
suffix_len                                             4       -      -4
next_file                                             77       -     -77
(add/remove: 0/2 grow/shrink: 1/0 up/down: 37/-81)            Total: -44 bytes
2007-03-26 20:15:40 +00:00
Bernhard Reutner-Fischer 576de34d1c - check the suffix proper plus misc touch up 2007-03-26 18:19:29 +00:00
Denis Vlasenko afa7023b46 zcip: make it work on NOMMU (+ improve NOMMU support machinery)
fsck: fix bad English in a comment
2007-03-26 17:25:33 +00:00
Bernhard Reutner-Fischer 4e1361a481 - add usage for split 2007-03-26 14:38:03 +00:00
Bernhard Reutner-Fischer b813eaff23 - implement suffices as required by SUSv3
- fix glitch in next_file (suffices were exhaused too early).
2007-03-26 14:28:12 +00:00
Denis Vlasenko 53091ecd20 Attempt to get more applets compile for NOMMU.
TODO_config_nommu documents what I managed to compile so far
(yay! msh works! cool). inetd, telnetd, httpd still do not compile. TODO
Also make fork(), daemon() produce warnings on compile stage
(in addition to erros on link stage).
2007-03-26 13:35:09 +00:00
Denis Vlasenko ec1a4b5a52 pidfile.c: not used anymore
BTW, previous change removed pidfile locking, -700 code (static compile)
2007-03-26 13:24:24 +00:00
Denis Vlasenko af1c84360f Move udhcp to new NOMMU helpers.
Fix server part to compile under NOMMU.
Client is not compilable yet.
On MMU everything compiles (and maybe even works :)
2007-03-26 13:22:35 +00:00
Denis Vlasenko 5a142025d3 move everything to new NOMMU helpers, except udhcp 2007-03-26 13:20:54 +00:00
Denis Vlasenko bb7fcb4229 libbb: rework NOMMU helper API so that it makes more sense
and easier to use. Doesn't compile - need two more commits.
2007-03-26 13:20:04 +00:00
Denis Vlasenko f62c6fa1ca nmeter: should die if stdout doesn't like him anymore 2007-03-26 13:16:22 +00:00
Bernhard Reutner-Fischer cd43dfdeec - shrink a tiny bit (-8b) 2007-03-26 10:46:31 +00:00
Denis Vlasenko cad04ef4f3 add NOMMU fixme's; move move_fd from runit_lib to libbb; nuke fd_copy 2007-03-25 23:21:05 +00:00
Bernhard Reutner-Fischer 10f8f5f443 - rough prototype for split(1). TODO: Still needs some love since it's way too big..
text	   data	    bss	    dec	    hex	filename
    602	      4	      0	    606	    25e	coreutils/split.o
2007-03-25 21:50:18 +00:00
Denis Vlasenko 55f30b05ac inetd,ed,msh: data/bss reduction (in mss, more than 9k of it) 2007-03-24 22:42:29 +00:00
Denis Vlasenko c0415a9833 login: nuke nonblock() - we have it in libbb; -400 bytes bss. 2007-03-24 17:04:07 +00:00
Denis Vlasenko 8a503be840 #ifdef out re_execed on MMU machines 2007-03-24 16:13:33 +00:00
Denis Vlasenko 7695328575 adduser: don't bomb out if shadow password file doesn't exist
(from Tito <farmatito@tiscali.it>)
2007-03-24 16:06:46 +00:00
Denis Vlasenko 219d14d514 random style fixes (extra spaces deleted) 2007-03-24 15:40:16 +00:00
Denis Vlasenko 644849a3aa SELinux: load_policy applet - this time with svn add 2007-03-24 15:38:49 +00:00
Denis Vlasenko 1fc6e56684 SELinux: load_policy applet 2007-03-24 15:37:57 +00:00
Denis Vlasenko 5b27fbe990 dc: use common_bufsiz1 for evaluation stack
msh: fix "underscore bug" (a_b=1111 didn't work)
dnsd: openlog(), so that applet's name is logged
2007-03-24 14:06:51 +00:00
Denis Vlasenko b5b45a91f0 dnsd: last commit had a typo :( 2007-03-24 13:09:07 +00:00
Denis Vlasenko d3bac03988 dnsd: fix several buglets, make smaller 2007-03-24 12:13:04 +00:00
Denis Vlasenko 9067f13be0 NOMMU re-exec trick shuld not depend on existence of "don't daemonize"
option for every affected applet (and dnsd, for example, don't have one).
Thus rework re-exec support to not require it. Code got smaller too.
2007-03-24 12:11:17 +00:00
Denis Vlasenko 1b6fa4c57c applets.c, xfunc.c: style cleanup 2007-03-24 12:08:36 +00:00
Denis Vlasenko ce074df814 inetd: indent labels uniformly 2007-03-24 12:07:31 +00:00
Denis Vlasenko 7d10823f6a Announce 1.5.0 and move svn to 1.6.0.svn 2007-03-22 23:31:29 +00:00
Denis Vlasenko 4b38e29764 This revision is busybox 1.5.0 2007-03-22 22:27:40 +00:00
Denis Vlasenko 58875aefe4 assorted fixes uncovered by randomconfig runs 2007-03-22 22:22:10 +00:00
Denis Vlasenko d0587ed966 interface: revert part of commit 18120 (eth aliases work again) 2007-03-22 19:35:51 +00:00
Denis Vlasenko cbcff2936e gzip: fix -d option handling 2007-03-22 18:56:23 +00:00
Denis Vlasenko 1787e22465 ifconfig: support (by ignoring it) "inet" before IP address or hostname 2007-03-22 18:56:00 +00:00
Denis Vlasenko 2a51af2579 vi: fix signed char-induced potential bugs 2007-03-21 22:31:24 +00:00
Denis Vlasenko 9a1fa8cf07 cmp: support 3rd and 4th arguments if DESKTOP=y (needed for gcc build) 2007-03-21 22:30:14 +00:00
Denis Vlasenko 7c139b4778 ash: fix signal handling 2007-03-21 20:17:27 +00:00
Denis Vlasenko b8e72fdde1 add info about gcc's sadistic alignment - and how to disable it 2007-03-21 10:07:01 +00:00
Denis Vlasenko afa37cf508 vi: remove Byte typedef and massive amount of casts.
also optimize many strlen() calls.
if (strlen(buf) <= 0) goto vc1 - ??!!
2007-03-21 00:05:35 +00:00
Denis Vlasenko f9234135f8 vi: support $EXINIT and -c 2007-03-21 00:03:42 +00:00
Denis Vlasenko 4f93cde77f syslogd: fix it for small BUFSIZ case 2007-03-20 20:03:03 +00:00
Denis Vlasenko f363065021 small doc update 2007-03-20 15:53:11 +00:00
Denis Vlasenko c86e052b81 fix accumulated whitespace and indentation damage 2007-03-20 11:30:28 +00:00
Denis Vlasenko e84aeb5bcb update docs 2007-03-20 11:08:39 +00:00
Denis Vlasenko 88a2aa98e0 dpkg: free_package(NULL) is ok, so don't test for NULL, just free. 2007-03-19 21:48:56 +00:00
Denis Vlasenko 97fd6d81b4 ls: fix segfault-if-standalone-shell, add big fat comment. 2007-03-19 20:59:20 +00:00
Bernhard Reutner-Fischer 6111a8f2e7 - don't automatically select run-parts but point out that this is a system-utility in the strict sense. 2007-03-19 20:28:03 +00:00
Bernhard Reutner-Fischer 16deb86746 - very minor size tweak.
TODO: mv to globals, config-out non-busybox dhcp client stuff, reduce string bloat, etc
   text    data     bss     dec     hex filename
   7543       0      28    7571    1d93 networking/ifupdown.o.orig
   7515       0      28    7543    1d77 networking/ifupdown.o
2007-03-19 19:54:56 +00:00
Denis Vlasenko 3d101dd467 expand documentation 2007-03-19 16:04:11 +00:00
Bernhard Reutner-Fischer be862096c0 - be gentle to the intel compiler and make sure we have __u64 which is needed for linux/loop.h 2007-03-19 15:15:06 +00:00
Denis Vlasenko 54e3d1f00d telnet: finish style cleanup bits 2007-03-19 14:52:26 +00:00
Denis Vlasenko f24cdf1554 telnet: someone tried to do data optimization before me. Complete it.
text    data     bss     dec     hex filename
   2558       0     404    2962     b92 busybox.t2/networking/telnet.o
   2542       0       0    2542     9ee busybox.t3/networking/telnet.o
2007-03-19 14:47:09 +00:00
Denis Vlasenko dfce08f281 fdisk: bb_common_bufsiz1 is too small for globals on 64-bit CPU 2007-03-19 14:45:10 +00:00
Denis Vlasenko bd852076b9 fdisk: get rid of _() macro.
Shorten some messages. Stop using stderr - anyone who tries
to use fdisk no-interactively is "strange" anyway.
Improve storage handling in bsd module.
   text    data     bss     dec     hex filename
 728112    1488   33788  763388   ba5fc busybox.t0/busybox
 727248    1488   33372  762108   ba0fc busybox.t1/busybox
2007-03-19 14:43:38 +00:00
Bernhard Reutner-Fischer de8a6a01d8 Kim B. Heino writes:
When installing a new package with dpkg dependencies are checked 
correctly. But when I try to update an existing package, the 
dependencies are checked against the old package, not against new 
package. Thus the new package can break dependencies.
2007-03-19 13:44:18 +00:00
Denis Vlasenko 41e1dc3f8b make clean deletes .kernelrelease now
trylink deleted empty linker stderr on success
2007-03-18 21:45:21 +00:00
Denis Vlasenko 4b4b619c9c include <stddef.h> so that ptrdiff_t is again available 2007-03-18 20:33:26 +00:00
Denis Vlasenko 1c86a29aea Announce 1.4.2 2007-03-18 18:21:44 +00:00
Denis Vlasenko 83bb98f759 mkfs_minix: remove older, less efficient bss reduction trick 2007-03-18 14:43:21 +00:00
Denis Vlasenko 8e1a0cc4c9 fdisk: move 2k ptes[] array into bb_common_bufsiz1 2007-03-18 14:42:45 +00:00
Denis Vlasenko 6b343ddbc8 fix inadvertently leaked PWD_BUFFER_SIZE 2007-03-18 00:57:15 +00:00
Denis Vlasenko 081ef799fa random fixes to help text 2007-03-17 16:38:21 +00:00
Mike Frysinger 7a96504d30 dont use obsolete function index() as pointed out by src.obsolete.funcs 2007-03-17 06:29:05 +00:00
Mike Frysinger 75acbe322c punt useless header as pointed out by src.obsolete.headers 2007-03-17 06:27:38 +00:00
Mike Frysinger 757ed50841 fix typo as pointed out by src.obsolete.funcs 2007-03-17 06:26:51 +00:00
Denis Vlasenko 4b0bb9e0fd sed: fix very obscure case of escaped newline in sed command
(needed for uclibc build, btw). Add testcase for it.
2007-03-16 23:36:58 +00:00
Bernhard Reutner-Fischer 486e7ca6b7 - touchup wording a bit 2007-03-16 11:14:38 +00:00
Denis Vlasenko 84a9b8750e build system: produce link map. Rather useful when you
are wondering why your busybox is much bigger that you hoped for.
2007-03-15 23:44:10 +00:00
Denis Vlasenko 3ce293b585 gunzip: s/unsigned char extra_short/unsigned extra_short/
we can unzip openssh-4.3p2.tar.gz now :)
2007-03-15 23:30:18 +00:00
Denis Vlasenko 4efeaee387 mkfs_minix: stop using lots of bss/data.
data -3500 bytes, code -300 bytes
keep_data_small: expand/fix
2007-03-15 19:52:42 +00:00
Denis Vlasenko 5e892bae51 syslogd: reduce data/bss usage. Code size is practically the same. 2007-03-15 19:50:46 +00:00
Denis Vlasenko bff32ce4d5 gzip: Improve ptr_to_globals trick, allowing gcc
to optimize better. -480 bytes.
2007-03-15 19:48:35 +00:00
Denis Vlasenko 1cc70225e7 networking/interface.c: was doing really strange caching of fd's
open for getting ifconfig data - ??! Simplified all that. -200 bytes.
2007-03-15 19:46:43 +00:00
Denis Vlasenko 54d14ca1a2 copy_file: comment out one condition which is always false.
Add comment explaining POSIX rules for cp - and why
these rules are dangerous. Provide conditionally compiled code
for both POSIX and safe behaviors, select safe for now.
Code shrunk by ~80 bytes.
2007-03-15 13:33:37 +00:00
Denis Vlasenko 24af7201e9 fix TODO: getopt32 should reset optind to 1 itself 2007-03-15 13:28:46 +00:00
Denis Vlasenko 972288e62f modify ptr_to_globals trick so that we do not violate
type safety (well, sort of ;))
2007-03-15 00:57:01 +00:00
Denis Vlasenko dd2b2f75ae adjtimex: fix argument types (most importantly, allow negative ones) 2007-03-14 23:00:26 +00:00
Denis Vlasenko 5659407595 swapon: reinstate hole check but reduce it to warning
inode_hash: remove unused variable
2007-03-14 22:55:39 +00:00
Denis Vlasenko 7f2527e5a7 arp, networking/interface.c: eliminate statics
and unneeded on-stack buffers, disable (comment out)
some apparently unused (and buggy) code paths. -700 bytes.
2007-03-14 22:11:20 +00:00
Denis Vlasenko 650a0459b8 get_header_ar: reformatted code, no real changes 2007-03-14 22:08:53 +00:00
Denis Vlasenko 16c7fb7fc5 chown, env: stop using statics 2007-03-14 22:08:04 +00:00
Denis Vlasenko e1e93c1e1c missed hunk of "stop using big static buffer for inode hash" 2007-03-14 22:06:57 +00:00
Denis Vlasenko 6ef06eeed4 stop using big static buffer for inode hash 2007-03-14 22:06:01 +00:00
Denis Vlasenko 75ab6af71e stop using (yet another) static buffer 2007-03-14 21:56:51 +00:00
Denis Vlasenko cfa2b3a209 watchdog: don't use static variable 2007-03-14 21:55:41 +00:00
Denis Vlasenko 1ce190b7c1 udhcp: use fdprintf for pidfile creation (smaller code) 2007-03-14 21:54:42 +00:00
Denis Vlasenko 9616aff095 cosmetic documentation change 2007-03-14 11:50:34 +00:00
Bernhard Reutner-Fischer 26a8016da6 - change option -c to -Z to match newer upstream SElinux conventions 2007-03-14 08:52:28 +00:00
Denis Vlasenko fe42d17318 gzip: bbunzip integration fixes 2007-03-14 00:08:28 +00:00
Denis Vlasenko 75605788ff gzip: use common bbunzip infrastructure - ~700 bytes code less 2007-03-14 00:07:51 +00:00
Denis Vlasenko 07766bb0e7 gzip: reduce global data footprint, part 3 2007-03-14 00:06:51 +00:00
Denis Vlasenko da799e8227 gzip: reduce global data footprint, part 2 2007-03-14 00:06:29 +00:00
Denis Vlasenko e930fe1441 gzip: reduce global data footprint, part 1 2007-03-14 00:06:10 +00:00
Denis Vlasenko fad03bc3bb fsck_minix: stop using large buffers in bss 2007-03-13 22:31:28 +00:00
Denis Vlasenko 93ebd4f58d ash: popstackmark is reported trying to pop until NULL
is seen (which isn't possible), prevent this.
2007-03-13 20:55:36 +00:00
Denis Vlasenko 5df955fce2 Do not fail password check if shadow password does not exist -
fall back to ordinary one

Reduced usage of functions returning datain static buffers.
(mostly passwd/group/shadow related):

function                                             old     new   delta
correct_password                                     143     193     +50
sulogin_main                                         490     533     +43
adduser_main                                         732     774     +42
passwd_main                                         1875    1915     +40
addgroup_main                                        330     365     +35
bb_internal_getspnam                                  38       -     -38
bb_internal_fgetpwent                                 38       -     -38
bb_internal_fgetgrent                                 38       -     -38
static.resultbuf                                     168      88     -80
static.buffer                                       1872    1104    -768
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 5/2 up/down: 210/-962)         Total: -752 bytes
2007-03-13 13:01:14 +00:00
Denis Vlasenko c9c893d4f5 resize: make it usable in in backticks; have a timeout (if display
doesn't respond to 'get cursor pos' ESC sequence...)
2007-03-12 23:41:07 +00:00
Denis Vlasenko 8a164052bf add missing copyright statements and doc for sv 2007-03-12 23:34:52 +00:00
Denis Vlasenko d55a36255d sv: make code trivially smaller 2007-03-12 23:14:42 +00:00
Denis Vlasenko b5c33b10b9 chcon: remove redundant ifs: if(p) free(p) 2007-03-12 19:49:07 +00:00
Denis Vlasenko 39c651e909 introduce and use setfscreatecon_or_die
(patch by Yuichi Nakamura <ynakam@hitachisoft.jp>)
runcon: *yet another* fix for vda's brainfart :(
2007-03-12 18:22:55 +00:00
Denis Vlasenko b3f09f4a50 swapon: random shrinkage 2007-03-12 18:16:24 +00:00
Denis Vlasenko 214aec46bd bbunzip: remove extra formatting directives in comments 2007-03-12 11:31:17 +00:00
Denis Vlasenko 955bccc94f chcon: exclude constraints for impossible option if long opts are off 2007-03-12 10:41:23 +00:00
Denis Vlasenko 1203c9bf2f next portion of selinux updates: chcon, runcon. From
Yuichi Nakamura <himainu-ynakam@miomio.jp>  
KaiGai Kohei <busybox@kaigai.gr.jp>
2007-03-11 22:16:02 +00:00
Denis Vlasenko baca175912 kill superfluous returns at the end of void functions 2007-03-11 13:43:10 +00:00
Denis Vlasenko ecea8f201e update defconfig 2007-03-11 12:29:25 +00:00
Denis Vlasenko a4688bf55d fix buglets found by randomconfig run 2007-03-11 10:56:37 +00:00
Denis Vlasenko be644a81e9 awk: support multiple -v options 2007-03-10 17:22:14 +00:00
Denis Vlasenko 49622d7846 selinux support by Yuichi Nakamura <ynakam@hitachisoft.jp> (HitachiSoft) 2007-03-10 16:58:49 +00:00
Denis Vlasenko 4eb8b936cb more: do not mess with "/dev/console" (!);
fill whole 1st screen (was "screen sans one line");
    fall back to cat if redirected or no ctty
less: fall back to cat if no ctty (was exiting)
resize: cosmetics
2007-03-10 16:32:14 +00:00
Denis Vlasenko 2b52b2797b ifupdown: do not complain if !/var/run/ifstate 2007-03-09 22:48:08 +00:00
Denis Vlasenko 3aba666514 runsv: random code savings, ~300 bytes 2007-03-09 22:46:06 +00:00
Denis Vlasenko bebbd8c9ba bbunzip: size optimization: ~90 bytes 2007-03-09 20:49:55 +00:00
Bernhard Reutner-Fischer f25d57e0b4 - update 2007-03-09 16:56:57 +00:00
Bernhard Reutner-Fischer 71bc71a7dc - add chrt applet.
text    data     bss     dec     hex filename
    769       0       0     769     301 miscutils/chrt.o
and could use some further shrinkage
2007-03-09 16:56:38 +00:00
Denis Vlasenko 339f5eb2e0 printf: allow hex/oct numbers; move functions around
so that we have no forward declarations
2007-03-09 16:43:01 +00:00
Bernhard Reutner-Fischer 48e71c188f - move bbconfig into alphabetical order 2007-03-09 14:27:50 +00:00
Denis Vlasenko 02f0c4c2bf diff: failed to confirm "static bug" in gcc - reinstating statics.
microscopic code improvements.
2007-03-09 10:08:53 +00:00
Denis Vlasenko f5a157615d less: handle yet another Home/End key sequence; expand a comment 2007-03-09 08:55:23 +00:00
Bernhard Reutner-Fischer e11b4a4705 - add selinux applets to the IMA workaround 2007-03-09 08:46:31 +00:00
Bernhard Reutner-Fischer 12eda0ab97 This small patch fixes a bug when exclusive options were given
to matchpathcon it should exit. (KaiGai Kohei)
2007-03-09 08:44:30 +00:00
Mike Frysinger 67a32adbca add STANDALONE support 2007-03-09 08:25:24 +00:00
Denis Vlasenko a1c631278b less: make '/' (regex search) scan input if no matches are found
in input taken so far.
2007-03-08 18:12:01 +00:00
Denis Vlasenko 18d6fc1a50 less: yet another attempt to make search better 2007-03-08 17:52:36 +00:00
Denis Vlasenko 5c1de36702 less: fix 'n'ext match: sometimes was going to 999999th line 2007-03-08 16:44:32 +00:00
Denis Vlasenko 8a91081d9d chown: fix comment, fix verbose message 2007-03-08 16:14:46 +00:00
Denis Vlasenko cd27c42552 chown: support -H -L -P if ENABLE_DESKTOP
chmod: cosmetic fixes
expr: smallish help for dumb compilers
2007-03-08 13:37:43 +00:00
Denis Vlasenko 6c939e0cb4 bbunzip: fix comments to match reality 2007-03-07 23:22:47 +00:00
Denis Vlasenko 36b7e28fa0 missed end-of-line 2007-03-07 23:08:26 +00:00
Denis Vlasenko 673d4bbab6 hwclock: support /dev/rtc0 etc 2007-03-07 23:02:50 +00:00
Denis Vlasenko 7fb8a00341 fix umount usage message 2007-03-07 22:49:53 +00:00
Denis Vlasenko 0085f231b2 diff: make -U0 work 2007-03-07 22:45:42 +00:00
Denis Vlasenko 80281fefc0 httpd: make httpd usable for NOMMU CPUs 2007-03-07 22:16:38 +00:00
Denis Vlasenko ab9eef21a5 bunzip2/gunzip/uncompress/unlzma: merge into common code -
fix few corner cases, reduce size by 450 bytes. Update testsuite.
2007-03-07 22:02:23 +00:00
Denis Vlasenko 8e858e2700 clean up accumulated whitespace damage 2007-03-07 09:35:43 +00:00
Denis Vlasenko 41cca2b4f5 who: stop using static buffer, small size optimizations 2007-03-07 00:07:42 +00:00
Denis Vlasenko c115fdbc80 ifupdown: code to deconstruct the state_list gracefully
(patch by Gabriel L. Somlo <somlo@cmu.edu>)
2007-03-06 22:53:10 +00:00
Denis Vlasenko 9431e564aa ash: "here document" testcases 2007-03-05 21:08:29 +00:00
Denis Vlasenko 140644dc1c add ash testcases 2007-03-05 20:46:46 +00:00
Denis Vlasenko ccd412da09 decouple INIT and SYSLOGD (patch by Eric Spakman E.Spakman@inter.nl.net) 2007-03-05 19:55:30 +00:00
Denis Vlasenko 1ccd96fd1f httpd: run interpreter for configured file extensions in any dir,
not only in /cgi-bin/
2007-03-05 19:24:33 +00:00
Denis Vlasenko d238a477b7 init: fix handling of stdio file descriptors 2007-03-05 19:22:04 +00:00
Denis Vlasenko ec77ba128a httpd: fix breakage (introduced by me) 2007-03-05 16:56:25 +00:00
Denis Vlasenko 1c660b4bd2 small ash testsuite, adapted from bash
(only a small part of it, actually)
2007-03-05 00:27:50 +00:00
Denis Vlasenko 3af3e5b4b0 ash: cosmetic improvements in error messages 2007-03-05 00:24:52 +00:00
Denis Vlasenko 940494f813 remove f words 2007-03-04 18:09:50 +00:00
Denis Vlasenko 29e31ddd81 ash: do not use "safe applets" in non-standalone shell 2007-03-03 23:12:17 +00:00
Denis Vlasenko dcbd51dd28 tar: handle tarfiles with (broken) checksums a-la Sun. 2007-03-03 20:06:59 +00:00
Denis Vlasenko 19c238bc90 ping: don't measure times if ping payload is less than 8 bytes;
commonalize some ping code.
2007-03-03 00:36:35 +00:00
Denis Vlasenko 2110aa9ece ls: w/o -l follow symlinks to dirs for commandline args 2007-02-28 23:14:06 +00:00
Denis Vlasenko 4c7e5b6c76 I *always* forget svn add :( 2007-02-27 22:39:19 +00:00
Denis Vlasenko 5066473d41 udhcp: optionally support RFC3397 (by Gabriel L. Somlo <somlo@cmu.edu>) 2007-02-27 21:15:08 +00:00
Denis Vlasenko 966bb43766 init: de-indent a block of code 2007-02-27 19:20:33 +00:00
Denis Vlasenko b716754199 init: trivial compile fix 2007-02-27 19:20:00 +00:00
Denis Vlasenko cce38586ae start_stop_daemon: add -chuid support 2007-02-26 22:47:42 +00:00
Denis Vlasenko f8ea0f3a66 grep: "implement" -a and -I by ignoring them 2007-02-25 02:38:54 +00:00
Denis Vlasenko 385304d449 grep: implement -w 2007-02-25 02:38:20 +00:00
Denis Vlasenko 4222ae440a ash: replace xstrdup (shell shall not die)
grep: fix mis-indented block
2007-02-25 02:37:49 +00:00
Denis Vlasenko 018e085d44 stop using bash'isms ('function')
runtest: do not depend on busybox.links
2007-02-25 00:40:37 +00:00
Denis Vlasenko 629563b5d7 awk: fix memory leak (can affect large file processing) 2007-02-24 17:05:52 +00:00
Denis Vlasenko 5276402f2c ash: fix compile problems 2007-02-24 13:42:56 +00:00
Denis Vlasenko f98dc4db7a ash: cleanup part 2.8 2007-02-23 21:11:02 +00:00
Denis Vlasenko 0dec6de38b ash: cleanup part 2.7 2007-02-23 21:10:47 +00:00
Denis Vlasenko cc5715184b ash: cleanup part 2.6 2007-02-23 21:10:35 +00:00
Denis Vlasenko 2de3d9fbee ash: cleanup part 2.5 2007-02-23 21:10:23 +00:00
Denis Vlasenko a89150733a ash: cleanup part 2.4 2007-02-23 21:10:06 +00:00
Denis Vlasenko 99eb8500c9 ash: cleanup part 2.3 2007-02-23 21:09:49 +00:00
Denis Vlasenko fc06f2968b ash: cleanup part 2.2 2007-02-23 21:09:35 +00:00
Denis Vlasenko 5651bfc204 ash: starting second round of cleanups. #1 2007-02-23 21:08:58 +00:00
Denis Vlasenko bc54cffc83 ash: cleanup part 9 2007-02-23 01:05:52 +00:00
Denis Vlasenko 4d2183bee1 ash: cleanup part 8 2007-02-23 01:05:38 +00:00
Denis Vlasenko 4fe15f3d9e ash: cleanup part 7 2007-02-23 01:05:26 +00:00
Denis Vlasenko a6704933dd ash: cleanup part 6 2007-02-23 01:05:15 +00:00
Denis Vlasenko 5c67e3ed90 ash: cleanup part 5 2007-02-23 01:05:03 +00:00
Denis Vlasenko fe1f00a7a7 ash: cleanup part 4 2007-02-23 01:04:50 +00:00
Denis Vlasenko 9650f36210 ash: cleanup part 3 2007-02-23 01:04:37 +00:00
Denis Vlasenko aa74445514 ash: cleanup part 2 2007-02-23 01:04:22 +00:00
Denis Vlasenko 0c032a49b9 ash: cleanup part 1 2007-02-23 01:03:40 +00:00
Denis Vlasenko 7a2ca5e111 init: stop doing silly things with the console (-400 bytes)
init_shared.[ch]: unused, thus deleted
2007-02-21 00:15:20 +00:00
Denis Vlasenko a624c11d5e ash: move ash_main() and helpers to end of ash.c, more fuctions renamed,
superfluous casts from memory allocators removed
2007-02-19 22:45:43 +00:00
Denis Vlasenko 2da584fc4e ash: more renaming and style fixes 2007-02-19 22:44:05 +00:00
Denis Vlasenko b012b10dbd ash: rearrange code to reduce forward references, rename some functions 2007-02-19 22:43:01 +00:00
Denis Vlasenko e5570da2cf ash: tiny style fixes 2007-02-19 22:41:55 +00:00
Denis Vlasenko 5cedb75aa7 ash: de-obfuscate code, add 'static' keyword, etc. 2007-02-18 19:56:41 +00:00
Denis Vlasenko 3bf0020a5f hdparm: style fixes, no code changes 2007-02-18 13:36:04 +00:00
Denis Vlasenko 131ae177a7 ash: convert #ifdef CONFIG_ to #if ENABLE_ 2007-02-18 13:00:19 +00:00
Denis Vlasenko a0f82e928a ash: fix indentation and style. no code changes 2007-02-18 12:35:30 +00:00
Denis Vlasenko d0762e3d52 runsv: add missing {} 2007-02-18 11:07:43 +00:00
Denis Vlasenko 54cf511ce1 sort: fix multiple -k (was ignoring all except last) 2007-02-17 18:11:45 +00:00
Denis Vlasenko ec27feb045 init: code readability enhancements; very small code changes 2007-02-17 15:52:02 +00:00
Denis Vlasenko c84520d73d klogd: code de-obfuscation with small code size reduction 2007-02-17 14:12:10 +00:00
Bernhard Reutner-Fischer d818dcc72a - whitespace cleanup and add a possible shrinkage suggestion 2007-02-16 17:17:07 +00:00
Denis Vlasenko 7fd00cbff7 dpkg: fix segfault on "dpkg -i" 2007-02-15 21:19:50 +00:00
Denis Vlasenko 4998c81891 syslogd: MARK code is buggy. Disabling it altogether on anti-bloat grounds 2007-02-14 20:51:46 +00:00
Denis Vlasenko 9ab2658836 zcip: revert my bogus change 2007-02-14 20:50:22 +00:00
Denis Vlasenko b30418ac19 less: support xterm's home/end; improve forward search 2007-02-14 20:49:14 +00:00
Mike Frysinger ae30210d90 create a document for mdev so people dont have to rtfs 2007-02-14 13:20:29 +00:00
Denis Vlasenko b5368bf437 httpd: a little bit more correct handling of CGI "HTTP/xxx" output 2007-02-13 23:42:54 +00:00
Denis Vlasenko e54b472ffc make tar restore mode again 2007-02-12 22:06:56 +00:00
Bernhard Reutner-Fischer 9a1c71a0f2 - check if the compiler supports -fwhole-program -- 4.0 does not 2007-02-12 12:57:38 +00:00
Denis Vlasenko a3055846a4 httpd: fix for POSTDATA handling bugs:
erroneous close(0)
full_read -> safe_read (with explanation)
2007-02-11 19:51:06 +00:00
Denis Vlasenko 6089c2c31e diff: fix access past end of array 2007-02-11 19:07:03 +00:00
Denis Vlasenko 6ca0444420 syslogd: fix "readpath bug" by using readlink instead
libbb: rename xgetcwd and xreadlink
2007-02-11 16:19:28 +00:00
Denis Vlasenko 136f42f503 Add CGI docs 2007-02-11 14:52:07 +00:00
Denis Vlasenko ad67a3925c remove unused #include,, improve code readability 2007-02-09 18:26:52 +00:00
Denis Vlasenko c8e9993514 ping: reuse another bit of common code. -60 bytes 2007-02-09 18:14:42 +00:00
Denis Vlasenko 9ca26d38c5 ping: support -I addr in family neutral manner; reuse a bit of common code 2007-02-09 17:32:16 +00:00
Denis Vlasenko d244c5eaf8 msh: fix my buglet 2007-02-09 17:30:14 +00:00
Denis Vlasenko b477e18c1e tftp: fix my bug 2007-02-08 20:41:41 +00:00
Mike Frysinger 0aa6ba5d44 make sure ps/top output what they claim: vsz, not rss ... down the line we should make the output controllable either at runtime or buildtime as both statistics are quite useful 2007-02-08 08:21:58 +00:00
Mike Frysinger 4423e5beef /etc/modules.conf is a 2.6.x file while /etc/modules.conf and /etc/conf.modules are 2.4.x and older files 2007-02-08 07:03:44 +00:00
Mike Frysinger c5d9e8ff3d touchup style; no functional changes 2007-02-08 06:30:58 +00:00
Denis Vlasenko 0850cdabde tftp: fix IPv6 fallout 2007-02-07 23:20:32 +00:00
Denis Vlasenko 8c6c6e955b selinux fixes by KaiGai Kohei <kaigai@kaigai.gr.jp> 2007-02-07 22:08:42 +00:00
Denis Vlasenko 710694f0e5 fix #ifdef ENABLE_xxx -> #if 2007-02-07 20:27:03 +00:00
Denis Vlasenko d4eda22d0c fix warning coming from printing size_t with %u 2007-02-06 21:52:05 +00:00
Denis Vlasenko d46d3c292e new applets: selinux utils by KaiGai Kohei <kaigai@kaigai.gr.jp> 2007-02-06 19:28:50 +00:00
Denis Vlasenko b292264bfd find: fix -not support 2007-02-06 17:38:29 +00:00
Denis Vlasenko 1d76f439da EXEC_PREFER_APPLETS support by Gabriel L. Somlo <somlo@cmu.edu> 2007-02-06 01:20:12 +00:00
Denis Vlasenko cc24419e98 minix utils: de-inline bit ops (saves ~130 bytes) 2007-02-06 00:37:40 +00:00
Denis Vlasenko dc485c9da6 minix utils: make a message easier to understand; small tweaks 2007-02-06 00:36:53 +00:00
Denis Vlasenko f885c543da correct "pivot_root: pivot_root: <msg>" 2007-02-06 00:35:36 +00:00
Denis Vlasenko 8c0164c373 fix tar t segfault (closes 1183) 2007-02-04 21:30:35 +00:00
Bernhard Reutner-Fischer d909d23451 - indent 2007-02-04 20:32:38 +00:00
Bernhard Reutner-Fischer 7154b99c89 - improve wording 2007-02-04 17:24:53 +00:00
Bernhard Reutner-Fischer 01986e9c6f - remove duplicate menu entry 2007-02-04 17:21:55 +00:00
Denis Vlasenko cf787cf3a5 find: support for ! 2007-02-04 17:11:25 +00:00
Bernhard Reutner-Fischer 10b7996c1b - strip 12 bytes off by using a smaller type for need_print.
- add TODO to switch this applet to index_in_str_array()
2007-02-04 16:09:04 +00:00
Bernhard Reutner-Fischer cbd6e65744 - fix buglet introduced in r17351 in find_param(). Closes #1193 2007-02-04 11:13:57 +00:00
Denis Vlasenko e991303406 udhcp: use improved gethostbyname replacement from IPv6 code 2007-02-04 02:41:57 +00:00
Denis Vlasenko 1094452423 ifconfig: use IPv6 infrastructure 2007-02-04 02:40:27 +00:00
Denis Vlasenko 5870ad9672 mount: (try to) support cifs with IPv6 2007-02-04 02:39:55 +00:00
Denis Vlasenko 42823d597a add x to IPv6 functions which can die 2007-02-04 02:39:08 +00:00
Denis Vlasenko 45854b5e3f mkconfigs: remove echo "..." contortion 2007-02-04 02:38:21 +00:00
Denis Vlasenko 9f85de1821 BB_EXECLP should call execlp, not execvp 2007-02-04 00:09:18 +00:00
Denis Vlasenko e8ce0626d9 s/PREFIX/CONFIG_PREFIX/ 2007-02-03 17:29:14 +00:00
Denis Vlasenko 06af216528 suppress warnings about easch <applet>_main() having
no preceding prototype
2007-02-03 17:28:39 +00:00
Denis Vlasenko c7ba8b9d6c do not put all <applet>_main() declarations
in busybox.h - this produces false dependencies
2007-02-03 17:27:14 +00:00
Bernhard Reutner-Fischer 6a1829d90c - include busybox.h before looking at an eventual #if ENABLE_DESKTOP 2007-02-03 12:52:25 +00:00
Denis Vlasenko a5c5ae03eb add TODO 2007-02-03 12:50:41 +00:00
Denis Vlasenko 37c8f36357 usage_compressed: be more permissive in which od flavors we support 2007-02-03 12:45:43 +00:00
Denis Vlasenko 4c97863109 assorted fixes for bugs found with randomconfig 2007-02-03 03:31:13 +00:00
Denis Vlasenko e968fcd562 lineedit: add missing #if/#endif
init: fix warnings
2007-02-03 02:42:47 +00:00
Denis Vlasenko 4921b54f37 Add BB_EXEC[LV]P() which encapsulate FEATURE_EXEC_PREFER_APPLETS
(patch from Gabriel L. Somlo <somlo@cmu.edu>)
2007-02-03 02:17:41 +00:00
Denis Vlasenko 0aa8490693 sigset_t blocked_sigset is too big for static (128 bytes) 2007-02-03 01:47:56 +00:00
Denis Vlasenko 64392905ef svlogd: fix performance problems: excessive write,
gettimeofday calls. rt_sigprocmask were dealt with
in previous commit
2007-02-03 00:53:43 +00:00
Denis Vlasenko 4f8d27f29a svlogd: do not set O_NONBLOCK on stdin permanently - that can
affect other processes!
2007-02-03 00:52:17 +00:00
Bernhard Reutner-Fischer 493691a4f5 - minor tweak 2007-02-02 16:11:24 +00:00
Bernhard Reutner-Fischer 7a7e54a190 - update helptext 2007-02-02 16:06:02 +00:00
Denis Vlasenko e129f43c83 add a comment so that people won't get confused 2007-02-02 01:57:24 +00:00
Denis Vlasenko 7fca91a3de sv: fix incorrect option parsing and reduce size 2007-02-02 01:19:09 +00:00
Denis Vlasenko 8bb21af72c httpd: directory indexer example doesn't need piping thru dd anymore 2007-02-02 01:18:37 +00:00
Denis Vlasenko a100707c04 find -user support by Natanael Copa <natanael.copa@gmail.com> 2007-02-02 01:17:52 +00:00
Denis Vlasenko 731d357295 trivial warning fix 2007-02-02 01:16:33 +00:00
Denis Vlasenko c4d606e367 udhcpd: allow "domain" to be a list of DNS servers, not just one 2007-02-02 01:16:08 +00:00
Denis Vlasenko de55b5d014 correct wget's comment 2007-02-01 01:53:25 +00:00
Denis Vlasenko 4bb31899e5 add -Wwrite-strings to Makefile 2007-02-01 01:51:36 +00:00
Denis Vlasenko 1e3b068689 msh: cleaning up for -Wwrite-strings part #4 2007-02-01 01:43:54 +00:00
Denis Vlasenko 6b50f73171 msh: cleaning up for -Wwrite-strings part #3 2007-02-01 01:43:39 +00:00
Denis Vlasenko 489f93ebae msh: cleaning up for -Wwrite-strings part #2 2007-02-01 01:43:16 +00:00
Denis Vlasenko 00ccf95bc8 msh: cleaning up for -Wwrite-strings 2007-02-01 01:39:24 +00:00
Denis Vlasenko 71d8abf30c lash: -Wwrite-strings fixes 2007-01-30 22:44:07 +00:00
Denis Vlasenko bb81c5831a hush: style fixes 2007-01-30 22:32:09 +00:00
Denis Vlasenko c72c1ed932 hush: now it's -Wwrite-strings clean 2007-01-30 22:31:26 +00:00
Denis Vlasenko 0c886c65de hush: style fixes 2007-01-30 22:30:09 +00:00
Denis Vlasenko 15d78fb724 hust: -Wwrite-strings fixes 2007-01-30 22:28:21 +00:00
Denis Vlasenko 34c4e5f0b3 silly space saving in sed 2007-01-30 22:25:16 +00:00
Denis Vlasenko 54767db8c7 micro optimization 2007-01-30 01:11:36 +00:00
Denis Vlasenko 27a131e08e preparatory patch for -Wwrite-strings #8 (missed part) 2007-01-30 00:44:41 +00:00
Bernhard Reutner-Fischer eb10e17b7b - improve spelling 2007-01-29 23:56:13 +00:00
Denis Vlasenko 9356b5022c preparatory patch for -Wwrite-strings #7: sed
remaining: shell (rather scary mess in msh.c)
2007-01-29 23:44:38 +00:00
Denis Vlasenko 322661d025 preparatory patch for -Wwrite-strings #6 2007-01-29 23:43:52 +00:00
Denis Vlasenko 89ef65f024 preparatory patch for -Wwrite-strings #5 2007-01-29 23:43:18 +00:00
Denis Vlasenko ab2aea4447 preparatory patch for -Wwrite-strings #4 2007-01-29 22:51:58 +00:00
Denis Vlasenko 06c0a71d23 preparatory patch for -Wwrite-strings #3 2007-01-29 22:51:44 +00:00
Denis Vlasenko b6aae0f381 preparatory patch for -Wwrite-strings #2 2007-01-29 22:51:25 +00:00
Denis Vlasenko a41fdf331a preparatory patch for -Wwrite-strings #1 2007-01-29 22:51:00 +00:00
Denis Vlasenko e935602ff5 taskset: fix incorrect rage spec and allow 0xXXX input
ping: shave off 60 bytes
2007-01-29 18:03:54 +00:00
Denis Vlasenko 86811803e3 add to testsuite and fix yet another sed corner case 2007-01-29 17:10:19 +00:00
Denis Vlasenko c562bb7487 disable -Wold-style-definition for gcc 3.x 2007-01-29 17:08:51 +00:00
Denis Vlasenko fe7a9f1277 sed: fix 2 bugs (one testsuite entry + one newly found)
but more importantly make code more understandable
2007-01-29 14:31:47 +00:00
Denis Vlasenko 826c85f382 fix all known regressions with sed and also make it simpler 2007-01-28 23:26:15 +00:00
Denis Vlasenko dccb1a5343 wc can emit unpredictable amount of whitespace 2007-01-28 16:59:30 +00:00
Denis Vlasenko afe488d4bc work around gcc bug 2007-01-28 16:07:45 +00:00
Denis Vlasenko 9d938732d0 fix which-uses-default-path 2007-01-28 15:31:19 +00:00
Denis Vlasenko 4e1715f4b9 correct bad English 2007-01-28 14:51:32 +00:00
Bernhard Reutner-Fischer 2806b2368c - reinstate static for the command string arrray to be gentle to gcc-3.x 2007-01-28 11:14:26 +00:00
Bernhard Reutner-Fischer 8ca35d2d65 - document the multicast argument for ip link 2007-01-28 00:39:30 +00:00
Bernhard Reutner-Fischer 4d9a358ec1 - use uint32_t as suggested by vda.
- minor size- and readability tweaks while at it:
   text	   data	    bss	    dec	    hex	filename
   2631	      0	      0	   2631	    a47	networking/libiproute/iprule.o.orig
   2596	      0	      0	   2596	    a24	networking/libiproute/iprule.o
2007-01-28 00:20:46 +00:00
Denis Vlasenko 6912ea1467 ether-wake: remove #warning 2007-01-27 23:18:58 +00:00
Denis Vlasenko eeafc1a057 svlogd: batch writes if !timestamp 2007-01-27 23:15:50 +00:00
Denis Vlasenko ca549c5e69 svlogd: remove unused buffering, stop doing tons of memcpy 2007-01-27 22:24:59 +00:00
Denis Vlasenko bde74b617f runit/* cleanup part 3 (just deleting unused code) 2007-01-27 22:22:53 +00:00
Denis Vlasenko e2473f8c23 runit/* cleanup part 2 2007-01-27 22:22:17 +00:00
Denis Vlasenko 8c78395120 runit cleanup part 1 2007-01-27 22:21:52 +00:00
Denis Vlasenko e06bed30cf use bb_sanitize_stdio() where appropriate 2007-01-27 22:21:12 +00:00
Bernhard Reutner-Fischer cd75a96f0f - sum -r TODO should not print the filename as oposed to -s
Unfortunately, without rewriting sum, this bugfix adds 19 (!) bytes.
2007-01-27 22:11:28 +00:00
Bernhard Reutner-Fischer 14813c5943 - add a very few simple test for sum.
The very first is currently broken
2007-01-27 22:07:54 +00:00
Bernhard Reutner-Fischer aae82e0d8b - the testharness needs busybox.links. Now the new foobar.tests work again 2007-01-27 22:04:58 +00:00
Denis Vlasenko 9dca07d949 make it possible to build bbox without warnings again. 2007-01-27 14:03:15 +00:00
Denis Vlasenko 434ad5456b fix warning in find.c 2007-01-27 13:45:17 +00:00
Denis Vlasenko e0eebc1ef3 Make -Werror configurable 2007-01-27 13:44:53 +00:00
Denis Vlasenko fd94efa41f fix numbering in switch(): we don't have "del" anymore,
substring match on "delete" handles it ok. But we (I?)
forgot to renumber case labels...
2007-01-27 13:13:45 +00:00
Denis Vlasenko 5ff8f3d7fd add link to post 1.4.1 patches 2007-01-26 23:35:12 +00:00
Denis Vlasenko 98c0bba09d fix bin2hex bug. lowercase = uppercase | 0x20, not | 0x10! 2007-01-26 23:31:05 +00:00
Denis Vlasenko fc7f92253a find: fix -mtime, -mmin, -perm (+ add symbolic perm handling)
chmod: better name for a variable
2007-01-26 23:00:05 +00:00
Denis Vlasenko 8b942c6639 fix "expr has no effect" warning 2007-01-26 22:55:12 +00:00
Denis Vlasenko 86724af484 bb_parse_mode: do not do umask() needlessly. 2007-01-26 22:54:01 +00:00
Bernhard Reutner-Fischer f98d637ba4 - readahead depends on LFS 2007-01-26 09:03:23 +00:00
Mike Frysinger 5b6195c9bc respect CFLAGS/CPPFLAGS in env 2007-01-26 07:14:01 +00:00
Denis Vlasenko bc5262d3dd fix option -F mishandling 2007-01-26 07:02:56 +00:00
Denis Vlasenko a1042e94f1 fix non-ipv6 compile 2007-01-26 07:01:10 +00:00
Denis Vlasenko 30abe97940 announce 1.4.1 2007-01-25 21:10:43 +00:00
Denis Vlasenko 90ec4dc0c7 arping: stop using last gethostbyname2 in the tree
hostname: small optimization
2007-01-25 19:44:38 +00:00
Denis Vlasenko aeb4bdd582 accidentally applied wrong (old) patch, fixing up... 2007-01-25 00:00:02 +00:00
Denis Vlasenko 581930cc0d opt_complementary doesn't like numeric opts :( 2007-01-24 23:55:34 +00:00
Denis Vlasenko b9a279ba94 Unify ping and ping6. ping has -4 and -6 which force
name resolution into IP or IPv6 only, otherwise
we take address family returned by host2sockaddr()
in lsa->sa.sa_family. IOW: "ping ::1" with do IPv6 ping,
"ping 127.0.0.1" will do IPv4 ping.
ping6 is aliased to "ping -6".
2007-01-24 23:53:22 +00:00
Denis Vlasenko 677cb5eea5 hostname declaration was misplaced 2007-01-24 22:12:35 +00:00
Denis Vlasenko 218f2f4882 accumulated post-1.4.0 fixes 2007-01-24 22:02:01 +00:00
Bernhard Reutner-Fischer 84d2d493b4 - remove nested function. Saves ~30 bytes. 2007-01-24 21:38:10 +00:00
Bernhard Reutner-Fischer 7b1c5aacb0 - TODO: merge 'struct suffix_mult $several_suffixes[] into a struct suffix_mult
for several in head tail od_bloaty hexdump svlogd
2007-01-24 21:13:16 +00:00
Mike Frysinger 0e282c9aed combine depends lines 2007-01-24 14:50:27 +00:00
Mike Frysinger 11353ae0ab as Peter Kjellerstedt points out, bool/prompt/depend need to be split up in order to achieve the desired behavior (default to Y without a prompt); revert previous to commits to this file 2007-01-24 14:34:35 +00:00
Mike Frysinger a01579d4eb change "bool ... if OPT" to more common "depend ... OPT" 2007-01-24 12:16:08 +00:00
Mike Frysinger 6cda89700e combine bool;prompt to just bool 2007-01-24 09:32:42 +00:00
Mike Frysinger 841ef1308b combine bool;prompt to just bool 2007-01-24 09:32:19 +00:00
Mike Frysinger 08e7097340 "depends ..." -> "depends on ..." 2007-01-24 09:14:09 +00:00
Mike Frysinger 71a6a4e723 correct file format errors 2007-01-24 08:24:43 +00:00
Bernhard Reutner-Fischer 1c747b32c7 - add hostcc-option checker 2007-01-23 11:44:14 +00:00
Bernhard Reutner-Fischer 82f8788acc - call cc-option to check if the compiler supports the flags we asked to use 2007-01-23 11:39:13 +00:00
Bernhard Reutner-Fischer b5bb40f088 - add an unsupported makefile for IMA compiles
Nice for catching eventual breakage early on..
2007-01-23 01:29:04 +00:00
Bernhard Reutner-Fischer 425997223c - rtnl_rttable_a2n wants an unsigned int32 2007-01-23 01:27:17 +00:00
Denis Vlasenko 52848eecca add link to fixes-1.4.0 2007-01-22 23:39:08 +00:00
Denis Vlasenko 769d1e05e6 fix warning from needlessly-global functions 2007-01-22 23:04:27 +00:00
Denis Vlasenko d77f7c3136 remove empty source files 2007-01-22 22:47:07 +00:00
Denis Vlasenko 5de9e9ce0b clean up commented out old code 2007-01-22 22:46:04 +00:00
Denis Vlasenko 9adc6ced4f ping6: stop using xgethostbyname2, remove it from libbb. 2007-01-22 22:45:27 +00:00
Denis Vlasenko 448f0241e0 nslookup: full circle. Here we started IPv6 work. Use "new API"
and thus save a few bytes.
2007-01-22 22:43:05 +00:00
Bernhard Reutner-Fischer fdcd7c4237 - add more strict prototype checking to catch wrong and broken code (like nested functions) 2007-01-22 17:50:21 +00:00
Bernhard Reutner-Fischer 835f575b61 - the archivers expect mode to be a mode_t, so do not trip signed/unsigned conversion purposefully 2007-01-22 17:48:08 +00:00
Bernhard Reutner-Fischer 620e57b421 - forgot to include ip_common.h 2007-01-22 17:42:37 +00:00
Bernhard Reutner-Fischer d0f33b3ce8 - not sure if we want a timestamp there, so put one in 2007-01-22 17:12:56 +00:00
Bernhard Reutner-Fischer bb8c7c041c - sed -i -e "/\$Id:/d;" 2007-01-22 17:04:53 +00:00
Denis Vlasenko 703e20235a cleanups: unnecessary casts, unified const_1, eliminate cross-.c file
prototypes (heresy!), add spaces in places like "flags&NETSTAT_CONNECTED",
removed unused #defines, #ifdef -> #if, use uint32_t for ipv4 addrs.
2007-01-22 14:12:08 +00:00
Denis Vlasenko 6cd2d2bcba dnsd: getfileentry was leaking memory
mount: improve readability
2007-01-22 14:06:03 +00:00
Denis Vlasenko 35d4da0fb5 exterminate u_intXXX.
fix ping6 buglet (memset is too short), minor sync between ping and ping6
2007-01-22 14:04:27 +00:00
Denis Vlasenko 85629f08bc comment out unused old networking API parts
sockaddr2dotted: return IPV6 addrs in [addr]:port form (was addr:port)
2007-01-22 09:36:41 +00:00
Denis Vlasenko 3c99a59915 remove obsolete FEATURE_WGET_IP6_LITERAL 2007-01-22 09:14:02 +00:00
Denis Vlasenko d8760a705c defconfig: refresh 2007-01-22 09:12:15 +00:00
Denis Vlasenko 95fef7071e move shell/cmdedit.c -> libbb/lineedit.c 2007-01-22 09:03:42 +00:00
Denis Vlasenko 38f6319421 cmdedit is not a 'command' editing anymore, it's just editing (generic),
so rename stuff accordingly.
2007-01-22 09:03:07 +00:00
Denis Vlasenko 253ce00296 cmdedit: fix breakage 2007-01-22 08:34:44 +00:00
Denis Vlasenko b01b4e2a1f cmdedit.h: remove 2007-01-22 08:17:14 +00:00
Denis Vlasenko 6258fd3454 cmdedit: stop playing dirty games with atexit 2007-01-22 07:30:26 +00:00
Denis Vlasenko 8e1c71529c Convert cmdedit into more generic line input facility
(make history and completion optional at runtime).
Use it for fdisk, as an example.
Some unrelated fixes in fdisk are also here.
2007-01-22 07:21:38 +00:00
Denis Vlasenko 00cdbd8fc2 Introduce FEATURE_EDITING_FANCY_KEYS, so that user can disable
less-known keys (e.g. Ctrl-B/E/F)
2007-01-21 19:21:21 +00:00
Denis Vlasenko 5592fac308 cmdedit: more optimizations 2007-01-21 19:19:46 +00:00
Denis Vlasenko 47bdb3ac48 cmdedit: small optimizations 2007-01-21 19:18:59 +00:00
Denis Vlasenko 82b39e83ab sanitize cmdedit a bit (group functions by task etc) 2007-01-21 19:18:19 +00:00
Bernhard Reutner-Fischer 7b1f23610f - use makedev to get device number, else it gives wrong major/minor numbers to devices files on systems which use big device numbers.
Closes #919
2007-01-21 11:20:01 +00:00
Denis Vlasenko 2f0c0d0b88 Introduce FEATURE_EXEC_PREFER_APPLETS = "re-execute our own
executable if we asked to exec someting with argv[0] == known_applet"
Use it in init. Also respect PATH in init, remove explicit "/sbin" etc
from exec. Patch by Gabriel L. Somlo <somlo@cmu.edu>
2007-01-21 00:41:04 +00:00
Bernhard Reutner-Fischer b3f3c23f78 - point to correct version. Thanks to Yann E. MORIN. 2007-01-20 21:46:20 +00:00
Bernhard Reutner-Fischer 12f96c1cec - make tty's pre SUSv3 option handling dependant on INCLUDE_SUSv2 2007-01-20 21:34:24 +00:00
Bernhard Reutner-Fischer af45760cca - get_terminal_width_height does not and should never write to fd. Cosmetic Precaution 2007-01-20 21:33:50 +00:00
Bernhard Reutner-Fischer d19f4aaa21 - small size tweak 2007-01-20 21:32:38 +00:00
Bernhard Reutner-Fischer 1118a1de46 - make pre SUSv3 option handling dependant on INCLUDE_SUSv2 2007-01-20 21:32:20 +00:00
Bernhard Reutner-Fischer 8b1ae45037 - small size tweak 2007-01-20 21:31:21 +00:00
Bernhard Reutner-Fischer b31c252860 - reuse retval for the option handling.
- TODO add tee, readahead and splice support to uClibc and use it in busybox!
2007-01-20 21:30:49 +00:00
Bernhard Reutner-Fischer 088a212bf5 - small size tweaks 2007-01-20 21:29:50 +00:00
Bernhard Reutner-Fischer ca5b35299e - make read_stduu() and read_base64() void, small size tweaks 2007-01-20 21:29:32 +00:00
Bernhard Reutner-Fischer d58c19479d - small size tweak 2007-01-20 21:28:36 +00:00
Bernhard Reutner-Fischer a8e2e1872a - add C99 bool type for setups that support it. 2007-01-20 21:27:18 +00:00
Denis Vlasenko 312735878b Announce 1.3.2 and 1.4.0 on busybox.net 2007-01-20 20:38:57 +00:00
Denis Vlasenko 12a3917e45 head is 1.5.0.svn now 2007-01-20 20:02:29 +00:00
635 changed files with 51276 additions and 36949 deletions

No files matched your search

+75 -45
View File
@@ -101,8 +101,7 @@ config FEATURE_INSTALLER
help
Enable 'busybox --install [-s]' support. This will allow you to use
busybox at runtime to create hard links or symlinks for all the
applets that are compiled into busybox. This feature requires the
/proc filesystem.
applets that are compiled into busybox.
config LOCALE_SUPPORT
bool "Enable locale support (system needs locale for this to work)"
@@ -141,6 +140,13 @@ config FEATURE_CLEAN_UP
Don't enable this unless you have a really good reason to clean
things up manually.
config FEATURE_PIDFILE
bool "Support writing pidfiles"
default n
help
This option makes some applets (e.g. crond, syslogd, inetd) write
a pidfile in /var/run. Some applications rely on them.
config FEATURE_SUID
bool "Support for SUID/SGID handling"
default n
@@ -156,13 +162,6 @@ config FEATURE_SUID
are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs,
and vlock.
config FEATURE_SYSLOG
bool "Support for syslog"
default n
help
This option is auto-selected when you select any applet which may
send its output to syslog. You do not need to select it manually.
config FEATURE_SUID_CONFIG
bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
default n if FEATURE_SUID
@@ -203,14 +202,6 @@ config FEATURE_SUID_CONFIG_QUIET
/etc/busybox.conf should be readable by the user needing the SUID, check
this option to avoid users to be notified about missing permissions.
config FEATURE_HAVE_RPC
bool "RPC support"
default y
help
Select this if you have rpc support.
This automatically turns off all configuration options that rely
on RPC.
config SELINUX
bool "Support NSA Security Enhanced Linux"
default n
@@ -231,6 +222,20 @@ config SELINUX
Most people will leave this set to 'N'.
config FEATURE_PREFER_APPLETS
bool "exec prefers applets"
default n
help
This is an experimental option which directs applets about to
call 'exec' to try and find an applicable busybox applet before
searching the PATH. This is typically done by exec'ing
/proc/self/exe.
This may affect shell, find -exec, xargs and similar applets.
They will use applets even if /bin/<applet> -> busybox link
is missing (or is not a link to busybox). However, this causes
problems in chroot jails without mounted /proc and with ps/top
(command name can be shown as 'exe' for applets started this way).
config BUSYBOX_EXEC_PATH
string "Path to BusyBox executable"
default "/proc/self/exe"
@@ -241,6 +246,22 @@ config BUSYBOX_EXEC_PATH
executable. If you haven't got /proc, set this to wherever you
want to run BusyBox from.
# These are auto-selected by other options
config FEATURE_SYSLOG
bool "Support for logging to syslog"
default n
help
This option is auto-selected when you select any applet which may
send its output to syslog. You do not need to select it manually.
config FEATURE_HAVE_RPC
bool "RPC support"
default n
help
This is automatically selected if any of enabled applets need it.
You do not need to select it manually.
endmenu
menu 'Build Options'
@@ -344,21 +365,29 @@ config DEBUG
Most people should answer N.
config DEBUG_PESSIMIZE
bool "Disable compiler optimizations."
config WERROR
bool "Abort compilation on any warning"
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.
Selecting this will add -Werror to gcc command line.
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
depends on DEBUG
help
Using an additional debugging library will make BusyBox become
considerable larger and will cause it to run more slowly. You
@@ -418,31 +447,30 @@ config INSTALL_NO_USR
that you really want this behaviour.
choice
prompt "Applets links"
default INSTALL_APPLET_SYMLINKS
help
Choose how you install applets links.
prompt "Applets links"
default INSTALL_APPLET_SYMLINKS
help
Choose how you install applets links.
config INSTALL_APPLET_SYMLINKS
bool "as soft-links"
help
Install applets as soft-links to the busybox binary. This needs some
free inodes on the filesystem, but might help with filesystem
generators that can't cope with hard-links.
bool "as soft-links"
help
Install applets as soft-links to the busybox binary. This needs some
free inodes on the filesystem, but might help with filesystem
generators that can't cope with hard-links.
config INSTALL_APPLET_HARDLINKS
bool "as hard-links"
help
Install applets as hard-links to the busybox binary. This might count
on a filesystem with few inodes.
bool "as hard-links"
help
Install applets as hard-links to the busybox binary. This might count
on a filesystem with few inodes.
config INSTALL_APPLET_DONT
bool
prompt "not installed"
depends on FEATURE_INSTALLER || FEATURE_SH_STANDALONE_SHELL
help
Do not install applet links. Useful when using the -install feature
or a standalone shell for rescue pruposes.
bool "not installed"
depends on FEATURE_INSTALLER || FEATURE_SH_STANDALONE || FEATURE_PREFER_APPLETS
help
Do not install applet links. Useful when using the -install feature
or a standalone shell for rescue purposes.
endchoice
@@ -477,3 +505,5 @@ source procps/Config.in
source shell/Config.in
source sysklogd/Config.in
source runit/Config.in
source selinux/Config.in
source ipsvd/Config.in
+2 -2
View File
@@ -5,7 +5,7 @@ The BusyBox build process is similar to the Linux kernel build:
make menuconfig # This creates a file called ".config"
make # This creates the "busybox" executable
make install # or make PREFIX=/path/from/root install
make install # or make CONFIG_PREFIX=/path/from/root install
The full list of configuration and install options is available by typing:
@@ -114,7 +114,7 @@ configuration step, as in:
make O=/some/empty/directory allyesconfig
cd /some/empty/directory
make
make PREFIX=. install
make CONFIG_PREFIX=. install
More Information:
=================
+26 -14
View File
@@ -1,5 +1,5 @@
VERSION = 1
PATCHLEVEL = 4
PATCHLEVEL = 7
SUBLEVEL = 2
EXTRAVERSION =
NAME = Unnamed
@@ -183,11 +183,6 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi)
HOSTCC = gcc
HOSTCXX = g++
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
HOSTCXXFLAGS = -O2
# Decide whether to build built-in, modular, or both.
# Normally, just do built-in.
@@ -262,9 +257,16 @@ export quiet Q KBUILD_VERBOSE
# Look for make include files relative to root of kernel src
MAKEFLAGS += --include-dir=$(srctree)
HOSTCC = gcc
HOSTCXX = g++
HOSTCFLAGS :=
HOSTCXXFLAGS :=
# We need some generic definitions
include $(srctree)/scripts/Kbuild.include
HOSTCFLAGS += $(call hostcc-option,-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer,)
HOSTCXXFLAGS += -O2
# For maximum performance (+ possibly random breakage, uncomment
# the following)
@@ -299,9 +301,11 @@ AFLAGS_KERNEL =
# Use LINUXINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
CFLAGS :=
CPPFLAGS :=
AFLAGS :=
CFLAGS := $(CFLAGS)
CPPFLAGS := $(CPPFLAGS)
AFLAGS := $(AFLAGS)
LDFLAGS := $(LDFLAGS)
LDLIBS :=
# Read KERNELRELEASE from .kernelrelease (if it exists)
KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null)
@@ -315,6 +319,7 @@ export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \
export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
export FLTFLAGS
# When compiling out-of-tree modules, put MODVERDIR in the module
# tree rather than in the kernel tree. The kernel tree might
@@ -432,6 +437,7 @@ libs-y := \
editors/ \
findutils/ \
init/ \
ipsvd/ \
libbb/ \
libpwdgrp/ \
loginutils/ \
@@ -442,6 +448,7 @@ libs-y := \
networking/udhcp/ \
procps/ \
runit/ \
selinux/ \
shell/ \
sysklogd/ \
util-linux/ \
@@ -480,7 +487,7 @@ endif
# The all: target is the default when no target is given on the
# command line.
# This allow a user to issue only 'make' to build a kernel including modules
# Defaults busybox but it is usually overriden in the arch makefile
# Defaults busybox but it is usually overridden in the arch makefile
all: busybox
-include $(srctree)/arch/$(ARCH)/Makefile
@@ -562,9 +569,10 @@ busybox-all := $(core-y) $(libs-y)
# May be overridden by arch/$(ARCH)/Makefile
quiet_cmd_busybox__ ?= LINK $@
cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) $(LDFLAGS) \
-o $@ \
-o $@ -Wl,-Map -Wl,$@.map \
-Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
-Wl,--start-group $(busybox-all) -Wl,--end-group
-Wl,--start-group $(busybox-all) -Wl,--end-group \
$(LDLIBS)
# Generate System.map
quiet_cmd_sysmap = SYSMAP
@@ -671,8 +679,12 @@ busybox_unstripped: $(busybox-all) FORCE
$(Q)rm -f .old_version
busybox: busybox_unstripped
ifeq ($(SKIP_STRIP),y)
$(Q)cp $< $@
else
$(Q)$(STRIP) -s --remove-section=.note --remove-section=.comment \
busybox_unstripped -o $@
endif
# The actual objects are generated when descending,
# make sure no implicit rule kicks in
@@ -748,7 +760,7 @@ PHONY += prepare-all
# 2) Create the include2 directory, used for the second asm symlink
prepare3: .kernelrelease
ifneq ($(KBUILD_SRC),)
@echo ' Using $(srctree) as source for kernel'
@echo ' Using $(srctree) as source for busybox'
$(Q)if [ -f $(srctree)/.config ]; then \
echo " $(srctree) is not clean, please run 'make mrproper'";\
echo " in the '$(srctree)' directory.";\
@@ -905,7 +917,7 @@ endif # CONFIG_MODULES
# Directories & files removed with 'make clean'
CLEAN_DIRS += $(MODVERDIR)
CLEAN_FILES += busybox* System.map \
CLEAN_FILES += busybox* System.map .kernelrelease \
.tmp_kallsyms* .tmp_version .tmp_busybox* .tmp_System.map
# Directories & files removed with 'make mrproper'
+8 -4
View File
@@ -2,9 +2,6 @@
# Build system
# ==========================================================================
%.bflt: %_unstripped
$(CROSS_COMPILE)elf2flt $(ELF2FLTFLAGS) $< -o $@
busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h $(srctree)/include/applets.h
$(Q)-$(SHELL) $^ >$@
@@ -70,6 +67,7 @@ sizes: busybox_unstripped
.PHONY: bloatcheck
bloatcheck: busybox_old busybox_unstripped
@$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped
@$(CROSS_COMPILE)size busybox_old busybox_unstripped
.PHONY: baseline
baseline: busybox_unstripped
@@ -79,9 +77,13 @@ baseline: busybox_unstripped
objsizes: busybox_unstripped
$(srctree)/scripts/objsizes
.PHONY: stksizes
stksizes: busybox_unstripped
$(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH)
.PHONY: bigdata
bigdata: busybox_unstripped
nm --size-sort busybox_unstripped | grep -vi ' [tr] ' | tail -20
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [tr] '
# Documentation Targets
.PHONY: doc
@@ -143,3 +145,5 @@ SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS))
.PHONY: html
html: $(syn)
synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
-include $(srctree)/Makefile.local
+69 -7
View File
@@ -3,11 +3,12 @@
# ==========================================================================
BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
SKIP_STRIP = n
# -std=gnu99 needed for [U]LLONG_MAX on some systems
CPPFLAGS += $(call cc-option,-std=gnu99,)
CPPFLAGS += \
-std=gnu99 \
-Iinclude -Ilibbb \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
-include include/autoconf.h \
@@ -15,17 +16,78 @@ CPPFLAGS += \
$(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
CFLAGS += \
-Wall -Wstrict-prototypes -Wshadow -Werror -Wundef \
-funsigned-char -fno-builtin-strlen -finline-limit=0 -static-libgcc \
-Os -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
-fomit-frame-pointer -ffunction-sections -fdata-sections
# flag checks are grouped together to speed the checks up a bit..
CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,)
CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
# If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
# (or anything else for that matter) make sure that it is still possible
# to build bbox without warnings. Current offender: find.c:alloc_action().
# Looks more like gcc bug: gcc will warn on it with or without prototype.
# But still, warning-free compile is a must, or else we will drown
# in warnings pretty soon.
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,)
# -fno-guess-branch-probability: prohibit pseudo-random guessing
# of branch probabilities (hopefully makes bloatcheck more stable):
CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
# FIXME: These warnings are at least partially to be concerned about and should
# be fixed..
#CFLAGS+=$(call cc-option,-Wconversion,)
ifeq ($(CONFIG_DEBUG),y)
CFLAGS += -g
CFLAGS += $(call cc-option,-g)
endif
ifeq ($(CONFIG_STATIC),y)
LDFLAGS += -static
endif
BBOX_LIB_LIST = m crypt
ifeq ($(CONFIG_PAM),y)
BBOX_LIB_LIST += pam pam_misc
endif
ifeq ($(CONFIG_SELINUX),y)
BBOX_LIB_LIST += selinux sepol
endif
ifeq ($(CONFIG_EFENCE),y)
BBOX_LIB_LIST += efence
endif
ifeq ($(CONFIG_DMALLOC),y)
BBOX_LIB_LIST += dmalloc
endif
# For scripts/trylink
export BBOX_LIB_LIST
#LDFLAGS += -nostdlib
LDFLAGS_ELF2FLT = -Wl,-elf2flt
ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
SKIP_STRIP = y
endif
# Busybox is a stack-fatty so make sure we increase default size
# TODO: use "make stksizes" to find & fix big stack users
# (we stole scripts/checkstack.pl from the kernel... thanks guys!)
FLTFLAGS += -s 20000
+3 -1
View File
@@ -27,7 +27,7 @@ help:
@echo ' make SED="$(objtree)/sed"'
@echo
@echo 'Installation:'
@echo ' install - install busybox into $(PREFIX)'
@echo ' install - install busybox into $(CONFIG_PREFIX)'
@echo ' uninstall'
@echo
@echo 'Development:'
@@ -39,4 +39,6 @@ help:
@echo ' release - create a distribution tarball'
@echo ' sizes - show size of all enabled busybox symbols'
@echo ' objsizes - show size of each .o object built'
@echo ' bigdata - show data objects, biggest first'
@echo ' stksizes - show stack users, biggest first'
@echo
+4 -4
View File
@@ -50,10 +50,10 @@ Using busybox:
The build automatically generates a file "busybox.links", which is used by
'make install' to create symlinks to the BusyBox binary for all compiled in
commands. This uses the PREFIX environment variable to specify where to
install, and installs hardlinks or symlinks depending on the configuration
preferences. (You can also manually run the install script at
"applets/install.sh").
commands. This uses the CONFIG_PREFIX environment variable to specify
where to install, and installs hardlinks or symlinks depending
on the configuration preferences. (You can also manually run
the install script at "applets/install.sh").
----------------
+16 -9
View File
@@ -36,12 +36,7 @@ Rob Landley <rob@landley.net>:
modutils. The orig depmod is rather pointless to have to add to a firmware image
in when we already have a insmod/rmmod and friends.
Unify base64 handling.
There's base64 encoding and decoding going on in:
networking/wget.c:base64enc()
coreutils/uudecode.c:read_base64()
coreutils/uuencode.c:tbl_base64[]
networking/httpd.c:decodeBase64()
And probably elsewhere. That needs to be unified into libbb functions.
[done]
Do a SUSv3 audit
Look at the full Single Unix Specification version 3 (available online at
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
@@ -130,7 +125,6 @@ Bernhard Fischer <busybox@busybox.net> suggests to look at these:
make bb_common_bufsiz1 configurable, size wise.
make pipesize configurable, size wise.
Use bb_common_bufsiz1 throughout applets!
Add chrt applet. Please CC Bernhard if you suggest a patch.
As yet unclaimed:
@@ -154,6 +148,10 @@ patch
And while we're at it, a new patch filename quoting format is apparently
coming soon: http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
---
ps / top
Add support for both RSS and VSIZE rather than just one or the other.
Or make it a build option.
---
man
It would be nice to have a man command. Not one that handles troff or
anything, just one that can handle preformatted ascii man pages, possibly
@@ -164,11 +162,20 @@ man
---
ar
Write support?
----
---
stty / catv
stty's visible() function and catv's guts are identical. Merge them into
an appropriate libbb function.
----
---
struct suffix_mult
Several duplicate users of: grep -r "1024\*1024" * -B2 -A1
Merge to a single size_suffixes[] in libbb.
Users: head tail od_bloaty hexdump and (partially as it wouldn't hurt) svlogd
---
tail
./busybox tail -f foo.c~ TODO
should not print fmt=header_fmt for subsequent date >> TODO; i.e. only
fmt+ if another (not the current) file did change
Architectural issues:
+710
View File
@@ -0,0 +1,710 @@
# This .config compiles for NOMMU.
# TODO:
# Pick disabled applet, enable & try to make it compile & work on NOMMU
#
# Automatically generated make config: don't edit
# Busybox version: 1.6.0.svn
# Wed Apr 11 01:29:04 2007
#
CONFIG_HAVE_DOT_CONFIG=y
#
# Busybox Settings
#
#
# General Configuration
#
# CONFIG_NITPICK is not set
# CONFIG_DESKTOP is not set
# CONFIG_FEATURE_BUFFERS_USE_MALLOC is not set
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
CONFIG_SHOW_USAGE=y
CONFIG_FEATURE_VERBOSE_USAGE=y
CONFIG_FEATURE_COMPRESS_USAGE=y
CONFIG_FEATURE_INSTALLER=y
# CONFIG_LOCALE_SUPPORT is not set
CONFIG_GETOPT_LONG=y
CONFIG_FEATURE_DEVPTS=y
# CONFIG_FEATURE_CLEAN_UP is not set
CONFIG_FEATURE_PIDFILE=y
CONFIG_FEATURE_SUID=y
CONFIG_FEATURE_SYSLOG=y
# CONFIG_FEATURE_SUID_CONFIG is not set
# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
# CONFIG_FEATURE_HAVE_RPC is not set
# CONFIG_SELINUX is not set
CONFIG_FEATURE_PREFER_APPLETS=y
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
#
# Build Options
#
# CONFIG_STATIC is not set
# CONFIG_BUILD_LIBBUSYBOX is not set
# CONFIG_FEATURE_FULL_LIBBUSYBOX is not set
# CONFIG_FEATURE_SHARED_BUSYBOX is not set
CONFIG_LFS=y
# CONFIG_BUILD_AT_ONCE is not set
#
# Debugging Options
#
# CONFIG_DEBUG is not set
CONFIG_WERROR=y
CONFIG_NO_DEBUG_LIB=y
# CONFIG_DMALLOC is not set
# CONFIG_EFENCE is not set
CONFIG_INCLUDE_SUSv2=y
#
# Installation Options
#
# CONFIG_INSTALL_NO_USR is not set
CONFIG_INSTALL_APPLET_SYMLINKS=y
# CONFIG_INSTALL_APPLET_HARDLINKS is not set
# CONFIG_INSTALL_APPLET_DONT is not set
CONFIG_PREFIX="./_install"
#
# Busybox Library Tuning
#
CONFIG_PASSWORD_MINLEN=6
CONFIG_MD5_SIZE_VS_SPEED=2
CONFIG_FEATURE_EDITING=y
# CONFIG_FEATURE_EDITING_FANCY_KEYS is not set
# CONFIG_FEATURE_EDITING_VI is not set
CONFIG_FEATURE_EDITING_HISTORY=15
# CONFIG_FEATURE_EDITING_SAVEHISTORY is not set
# CONFIG_FEATURE_TAB_COMPLETION is not set
# CONFIG_FEATURE_USERNAME_COMPLETION is not set
# CONFIG_FEATURE_EDITING_FANCY_PROMPT is not set
#
# Applets
#
#
# Archival Utilities
#
CONFIG_AR=y
CONFIG_FEATURE_AR_LONG_FILENAMES=y
CONFIG_BUNZIP2=y
CONFIG_CPIO=y
# CONFIG_DPKG is not set
# CONFIG_DPKG_DEB is not set
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
CONFIG_GUNZIP=y
CONFIG_FEATURE_GUNZIP_UNCOMPRESS=y
CONFIG_GZIP=y
CONFIG_RPM2CPIO=y
# CONFIG_RPM is not set
CONFIG_TAR=y
CONFIG_FEATURE_TAR_CREATE=y
# CONFIG_FEATURE_TAR_BZIP2 is not set
# CONFIG_FEATURE_TAR_LZMA is not set
CONFIG_FEATURE_TAR_FROM=y
# CONFIG_FEATURE_TAR_GZIP is not set
# CONFIG_FEATURE_TAR_COMPRESS is not set
CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y
CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
CONFIG_FEATURE_TAR_LONG_OPTIONS=y
CONFIG_UNCOMPRESS=y
CONFIG_UNLZMA=y
CONFIG_FEATURE_LZMA_FAST=y
CONFIG_UNZIP=y
#
# Common options for cpio and tar
#
CONFIG_FEATURE_UNARCHIVE_TAPE=y
# CONFIG_FEATURE_DEB_TAR_GZ is not set
# CONFIG_FEATURE_DEB_TAR_BZ2 is not set
# CONFIG_FEATURE_DEB_TAR_LZMA is not set
#
# Coreutils
#
CONFIG_BASENAME=y
CONFIG_CAL=y
CONFIG_CAT=y
CONFIG_CATV=y
CONFIG_CHGRP=y
CONFIG_CHMOD=y
CONFIG_CHOWN=y
CONFIG_CHROOT=y
CONFIG_CKSUM=y
CONFIG_CMP=y
CONFIG_COMM=y
CONFIG_CP=y
CONFIG_CUT=y
CONFIG_DATE=y
CONFIG_FEATURE_DATE_ISOFMT=y
CONFIG_DD=y
CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
CONFIG_FEATURE_DD_IBS_OBS=y
CONFIG_DF=y
CONFIG_DIFF=y
CONFIG_FEATURE_DIFF_BINARY=y
CONFIG_FEATURE_DIFF_DIR=y
CONFIG_FEATURE_DIFF_MINIMAL=y
CONFIG_DIRNAME=y
CONFIG_DOS2UNIX=y
CONFIG_UNIX2DOS=y
CONFIG_DU=y
CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K=y
CONFIG_ECHO=y
CONFIG_FEATURE_FANCY_ECHO=y
CONFIG_ENV=y
CONFIG_FEATURE_ENV_LONG_OPTIONS=y
CONFIG_EXPR=y
CONFIG_EXPR_MATH_SUPPORT_64=y
CONFIG_FALSE=y
CONFIG_FOLD=y
CONFIG_HEAD=y
CONFIG_FEATURE_FANCY_HEAD=y
CONFIG_HOSTID=y
CONFIG_ID=y
CONFIG_INSTALL=y
CONFIG_FEATURE_INSTALL_LONG_OPTIONS=y
CONFIG_LENGTH=y
CONFIG_LN=y
CONFIG_LOGNAME=y
CONFIG_LS=y
CONFIG_FEATURE_LS_FILETYPES=y
CONFIG_FEATURE_LS_FOLLOWLINKS=y
CONFIG_FEATURE_LS_RECURSIVE=y
CONFIG_FEATURE_LS_SORTFILES=y
CONFIG_FEATURE_LS_TIMESTAMPS=y
CONFIG_FEATURE_LS_USERNAME=y
CONFIG_FEATURE_LS_COLOR=y
CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y
CONFIG_MD5SUM=y
CONFIG_MKDIR=y
CONFIG_FEATURE_MKDIR_LONG_OPTIONS=y
CONFIG_MKFIFO=y
CONFIG_MKNOD=y
CONFIG_MV=y
CONFIG_FEATURE_MV_LONG_OPTIONS=y
CONFIG_NICE=y
CONFIG_NOHUP=y
CONFIG_OD=y
CONFIG_PRINTENV=y
CONFIG_PRINTF=y
CONFIG_PWD=y
CONFIG_REALPATH=y
CONFIG_RM=y
CONFIG_RMDIR=y
CONFIG_SEQ=y
CONFIG_SHA1SUM=y
CONFIG_SLEEP=y
CONFIG_FEATURE_FANCY_SLEEP=y
CONFIG_SORT=y
CONFIG_FEATURE_SORT_BIG=y
CONFIG_SPLIT=y
CONFIG_FEATURE_SPLIT_FANCY=y
CONFIG_STAT=y
CONFIG_FEATURE_STAT_FORMAT=y
CONFIG_STTY=y
CONFIG_SUM=y
CONFIG_SYNC=y
CONFIG_TAIL=y
CONFIG_FEATURE_FANCY_TAIL=y
CONFIG_TEE=y
CONFIG_FEATURE_TEE_USE_BLOCK_IO=y
CONFIG_TEST=y
CONFIG_FEATURE_TEST_64=y
CONFIG_TOUCH=y
CONFIG_TR=y
CONFIG_FEATURE_TR_CLASSES=y
CONFIG_FEATURE_TR_EQUIV=y
CONFIG_TRUE=y
CONFIG_TTY=y
CONFIG_UNAME=y
CONFIG_UNIQ=y
CONFIG_USLEEP=y
CONFIG_UUDECODE=y
CONFIG_UUENCODE=y
CONFIG_WATCH=y
CONFIG_WC=y
CONFIG_FEATURE_WC_LARGE=y
CONFIG_WHO=y
CONFIG_WHOAMI=y
CONFIG_YES=y
#
# Common options for cp and mv
#
CONFIG_FEATURE_PRESERVE_HARDLINKS=y
#
# Common options for ls, more and telnet
#
CONFIG_FEATURE_AUTOWIDTH=y
#
# Common options for df, du, ls
#
CONFIG_FEATURE_HUMAN_READABLE=y
#
# Common options for md5sum, sha1sum
#
CONFIG_FEATURE_MD5_SHA1_SUM_CHECK=y
#
# Console Utilities
#
CONFIG_CHVT=y
CONFIG_CLEAR=y
CONFIG_DEALLOCVT=y
CONFIG_DUMPKMAP=y
CONFIG_LOADFONT=y
CONFIG_LOADKMAP=y
CONFIG_OPENVT=y
CONFIG_RESET=y
CONFIG_RESIZE=y
CONFIG_FEATURE_RESIZE_PRINT=y
CONFIG_SETCONSOLE=y
CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS=y
CONFIG_SETKEYCODES=y
CONFIG_SETLOGCONS=y
#
# Debian Utilities
#
CONFIG_MKTEMP=y
CONFIG_PIPE_PROGRESS=y
CONFIG_READLINK=y
CONFIG_FEATURE_READLINK_FOLLOW=y
CONFIG_RUN_PARTS=y
CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS=y
CONFIG_FEATURE_RUN_PARTS_FANCY=y
# CONFIG_START_STOP_DAEMON is not set
# CONFIG_FEATURE_START_STOP_DAEMON_FANCY is not set
# CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS is not set
CONFIG_WHICH=y
#
# Editors
#
CONFIG_AWK=y
CONFIG_FEATURE_AWK_MATH=y
CONFIG_ED=y
CONFIG_PATCH=y
CONFIG_SED=y
CONFIG_VI=y
CONFIG_FEATURE_VI_COLON=y
CONFIG_FEATURE_VI_YANKMARK=y
CONFIG_FEATURE_VI_SEARCH=y
CONFIG_FEATURE_VI_USE_SIGNALS=y
CONFIG_FEATURE_VI_DOT_CMD=y
CONFIG_FEATURE_VI_READONLY=y
CONFIG_FEATURE_VI_SETOPTS=y
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_FEATURE_ALLOW_EXEC=y
#
# Finding Utilities
#
CONFIG_FIND=y
CONFIG_FEATURE_FIND_PRINT0=y
CONFIG_FEATURE_FIND_MTIME=y
CONFIG_FEATURE_FIND_MMIN=y
CONFIG_FEATURE_FIND_PERM=y
CONFIG_FEATURE_FIND_TYPE=y
CONFIG_FEATURE_FIND_XDEV=y
CONFIG_FEATURE_FIND_NEWER=y
CONFIG_FEATURE_FIND_INUM=y
CONFIG_FEATURE_FIND_EXEC=y
CONFIG_FEATURE_FIND_USER=y
CONFIG_FEATURE_FIND_GROUP=y
CONFIG_FEATURE_FIND_NOT=y
CONFIG_FEATURE_FIND_DEPTH=y
CONFIG_FEATURE_FIND_PAREN=y
CONFIG_FEATURE_FIND_SIZE=y
CONFIG_FEATURE_FIND_PRUNE=y
CONFIG_GREP=y
CONFIG_FEATURE_GREP_EGREP_ALIAS=y
CONFIG_FEATURE_GREP_FGREP_ALIAS=y
CONFIG_FEATURE_GREP_CONTEXT=y
CONFIG_XARGS=y
CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION=y
CONFIG_FEATURE_XARGS_SUPPORT_QUOTES=y
CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT=y
CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
#
# Init Utilities
#
# CONFIG_INIT is not set
# CONFIG_DEBUG_INIT is not set
# CONFIG_FEATURE_USE_INITTAB is not set
# CONFIG_FEATURE_INIT_SCTTY is not set
# CONFIG_FEATURE_INIT_SYSLOG is not set
# CONFIG_FEATURE_EXTRA_QUIET is not set
# CONFIG_FEATURE_INIT_COREDUMPS is not set
# CONFIG_FEATURE_INITRD is not set
CONFIG_HALT=y
CONFIG_MESG=y
#
# Login/Password Management Utilities
#
CONFIG_FEATURE_SHADOWPASSWDS=y
CONFIG_USE_BB_SHADOW=y
CONFIG_USE_BB_PWD_GRP=y
CONFIG_ADDGROUP=y
CONFIG_FEATURE_ADDUSER_TO_GROUP=y
CONFIG_DELGROUP=y
CONFIG_ADDUSER=y
CONFIG_DELUSER=y
CONFIG_GETTY=y
CONFIG_FEATURE_UTMP=y
CONFIG_FEATURE_WTMP=y
CONFIG_LOGIN=y
CONFIG_LOGIN_SCRIPTS=y
CONFIG_FEATURE_SECURETTY=y
CONFIG_PASSWD=y
CONFIG_FEATURE_PASSWD_WEAK_CHECK=y
CONFIG_SU=y
CONFIG_FEATURE_SU_SYSLOG=y
CONFIG_FEATURE_SU_CHECKS_SHELLS=y
CONFIG_SULOGIN=y
CONFIG_VLOCK=y
#
# Linux Ext2 FS Progs
#
CONFIG_CHATTR=y
CONFIG_FSCK=y
CONFIG_LSATTR=y
#
# Linux Module Utilities
#
CONFIG_INSMOD=y
CONFIG_FEATURE_INSMOD_VERSION_CHECKING=y
CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS=y
CONFIG_FEATURE_INSMOD_LOADINKMEM=y
CONFIG_FEATURE_INSMOD_LOAD_MAP=y
CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL=y
CONFIG_RMMOD=y
CONFIG_LSMOD=y
CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y
CONFIG_MODPROBE=y
CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS=y
CONFIG_FEATURE_MODPROBE_FANCY_ALIAS=y
#
# Options common to multiple modutils
#
CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
CONFIG_FEATURE_2_4_MODULES=y
CONFIG_FEATURE_2_6_MODULES=y
# CONFIG_FEATURE_QUERY_MODULE_INTERFACE is not set
#
# Linux System Utilities
#
CONFIG_DMESG=y
CONFIG_FEATURE_DMESG_PRETTY=y
CONFIG_FBSET=y
CONFIG_FEATURE_FBSET_FANCY=y
CONFIG_FEATURE_FBSET_READMODE=y
CONFIG_FDFLUSH=y
CONFIG_FDFORMAT=y
CONFIG_FDISK=y
CONFIG_FDISK_SUPPORT_LARGE_DISKS=y
CONFIG_FEATURE_FDISK_WRITABLE=y
CONFIG_FEATURE_AIX_LABEL=y
CONFIG_FEATURE_SGI_LABEL=y
CONFIG_FEATURE_SUN_LABEL=y
CONFIG_FEATURE_OSF_LABEL=y
CONFIG_FEATURE_FDISK_ADVANCED=y
CONFIG_FREERAMDISK=y
CONFIG_FSCK_MINIX=y
CONFIG_MKFS_MINIX=y
#
# Minix filesystem support
#
CONFIG_FEATURE_MINIX2=y
CONFIG_GETOPT=y
CONFIG_HEXDUMP=y
CONFIG_HWCLOCK=y
CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS=y
CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS=y
CONFIG_IPCRM=y
CONFIG_IPCS=y
CONFIG_LOSETUP=y
CONFIG_MDEV=y
CONFIG_FEATURE_MDEV_CONF=y
CONFIG_FEATURE_MDEV_EXEC=y
CONFIG_MKSWAP=y
CONFIG_FEATURE_MKSWAP_V0=y
CONFIG_MORE=y
CONFIG_FEATURE_USE_TERMIOS=y
CONFIG_MOUNT=y
# CONFIG_FEATURE_MOUNT_NFS is not set
CONFIG_FEATURE_MOUNT_CIFS=y
CONFIG_FEATURE_MOUNT_FLAGS=y
CONFIG_FEATURE_MOUNT_FSTAB=y
CONFIG_PIVOT_ROOT=y
CONFIG_RDATE=y
CONFIG_READPROFILE=y
CONFIG_SETARCH=y
CONFIG_SWAPONOFF=y
CONFIG_SWITCH_ROOT=y
CONFIG_UMOUNT=y
CONFIG_FEATURE_UMOUNT_ALL=y
#
# Common options for mount/umount
#
CONFIG_FEATURE_MOUNT_LOOP=y
# CONFIG_FEATURE_MTAB_SUPPORT is not set
#
# Miscellaneous Utilities
#
CONFIG_ADJTIMEX=y
# CONFIG_BBCONFIG is not set
CONFIG_CHRT=y
# CONFIG_CROND is not set
# CONFIG_DEBUG_CROND_OPTION is not set
# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set
# CONFIG_CRONTAB is not set
CONFIG_DC=y
# CONFIG_DEVFSD is not set
# CONFIG_DEVFSD_MODLOAD is not set
# CONFIG_DEVFSD_FG_NP is not set
# CONFIG_DEVFSD_VERBOSE is not set
# CONFIG_FEATURE_DEVFS is not set
CONFIG_EJECT=y
CONFIG_LAST=y
CONFIG_LESS=y
CONFIG_FEATURE_LESS_MAXLINES=9999999
CONFIG_FEATURE_LESS_BRACKETS=y
CONFIG_FEATURE_LESS_FLAGS=y
CONFIG_FEATURE_LESS_FLAGCS=y
CONFIG_FEATURE_LESS_MARKS=y
CONFIG_FEATURE_LESS_REGEXP=y
CONFIG_HDPARM=y
CONFIG_FEATURE_HDPARM_GET_IDENTITY=y
CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF=y
CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF=y
CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET=y
CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF=y
CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA=y
CONFIG_MAKEDEVS=y
# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
CONFIG_FEATURE_MAKEDEVS_TABLE=y
CONFIG_MOUNTPOINT=y
CONFIG_MT=y
CONFIG_NMETER=y
CONFIG_RAIDAUTORUN=y
CONFIG_READAHEAD=y
CONFIG_RUNLEVEL=y
CONFIG_RX=y
CONFIG_STRINGS=y
CONFIG_SETSID=y
# CONFIG_TASKSET is not set
# CONFIG_FEATURE_TASKSET_FANCY is not set
CONFIG_TIME=y
CONFIG_WATCHDOG=y
#
# Networking Utilities
#
CONFIG_FEATURE_IPV6=y
# CONFIG_VERBOSE_RESOLUTION_ERRORS is not set
CONFIG_ARP=y
CONFIG_ARPING=y
CONFIG_DNSD=y
CONFIG_ETHER_WAKE=y
CONFIG_FAKEIDENTD=y
CONFIG_FTPGET=y
CONFIG_FTPPUT=y
CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y
CONFIG_HOSTNAME=y
# CONFIG_HTTPD is not set
# CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP is not set
# CONFIG_FEATURE_HTTPD_SETUID is not set
# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set
# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES is not set
# CONFIG_FEATURE_HTTPD_CGI is not set
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set
# CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set
# CONFIG_FEATURE_HTTPD_ENCODE_URL_STR is not set
CONFIG_IFCONFIG=y
CONFIG_FEATURE_IFCONFIG_STATUS=y
CONFIG_FEATURE_IFCONFIG_SLIP=y
CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y
CONFIG_FEATURE_IFCONFIG_HW=y
CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
# CONFIG_IFUPDOWN is not set
# CONFIG_FEATURE_IFUPDOWN_IP is not set
# CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN is not set
# CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN is not set
# CONFIG_FEATURE_IFUPDOWN_IPV4 is not set
# CONFIG_FEATURE_IFUPDOWN_IPV6 is not set
# CONFIG_FEATURE_IFUPDOWN_IPX is not set
# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
# CONFIG_INETD is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set
# CONFIG_FEATURE_INETD_RPC is not set
CONFIG_IP=y
CONFIG_FEATURE_IP_ADDRESS=y
CONFIG_FEATURE_IP_LINK=y
CONFIG_FEATURE_IP_ROUTE=y
CONFIG_FEATURE_IP_TUNNEL=y
CONFIG_FEATURE_IP_RULE=y
CONFIG_FEATURE_IP_SHORT_FORMS=y
CONFIG_IPADDR=y
CONFIG_IPLINK=y
CONFIG_IPROUTE=y
CONFIG_IPTUNNEL=y
CONFIG_IPRULE=y
CONFIG_IPCALC=y
CONFIG_FEATURE_IPCALC_FANCY=y
CONFIG_FEATURE_IPCALC_LONG_OPTIONS=y
CONFIG_NAMEIF=y
CONFIG_NC=y
CONFIG_NC_SERVER=y
CONFIG_NC_EXTRA=y
CONFIG_NETSTAT=y
CONFIG_NSLOOKUP=y
CONFIG_PING=y
CONFIG_PING6=y
CONFIG_FEATURE_FANCY_PING=y
CONFIG_ROUTE=y
CONFIG_TELNET=y
CONFIG_FEATURE_TELNET_TTYPE=y
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
# CONFIG_TELNETD is not set
# CONFIG_FEATURE_TELNETD_STANDALONE is not set
CONFIG_TFTP=y
CONFIG_FEATURE_TFTP_GET=y
CONFIG_FEATURE_TFTP_PUT=y
CONFIG_FEATURE_TFTP_BLOCKSIZE=y
# CONFIG_DEBUG_TFTP is not set
CONFIG_TRACEROUTE=y
# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
CONFIG_APP_UDHCPD=y
CONFIG_APP_DHCPRELAY=y
CONFIG_APP_DUMPLEASES=y
# CONFIG_APP_UDHCPC is not set
# CONFIG_FEATURE_UDHCP_DEBUG is not set
CONFIG_FEATURE_RFC3397=y
CONFIG_VCONFIG=y
CONFIG_WGET=y
CONFIG_FEATURE_WGET_STATUSBAR=y
CONFIG_FEATURE_WGET_AUTHENTICATION=y
CONFIG_FEATURE_WGET_LONG_OPTIONS=y
CONFIG_ZCIP=y
#
# Process Utilities
#
CONFIG_FREE=y
CONFIG_FUSER=y
CONFIG_KILL=y
CONFIG_KILLALL=y
CONFIG_KILLALL5=y
CONFIG_PIDOF=y
CONFIG_FEATURE_PIDOF_SINGLE=y
CONFIG_FEATURE_PIDOF_OMIT=y
CONFIG_PS=y
CONFIG_FEATURE_PS_WIDE=y
CONFIG_RENICE=y
CONFIG_BB_SYSCTL=y
CONFIG_TOP=y
CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y
CONFIG_UPTIME=y
#
# Shells
#
# CONFIG_FEATURE_SH_IS_ASH is not set
# CONFIG_FEATURE_SH_IS_HUSH is not set
# CONFIG_FEATURE_SH_IS_LASH is not set
# CONFIG_FEATURE_SH_IS_MSH is not set
CONFIG_FEATURE_SH_IS_NONE=y
# CONFIG_ASH is not set
# CONFIG_ASH_JOB_CONTROL is not set
# CONFIG_ASH_READ_NCHARS is not set
# CONFIG_ASH_READ_TIMEOUT is not set
# CONFIG_ASH_ALIAS is not set
# CONFIG_ASH_MATH_SUPPORT is not set
# CONFIG_ASH_MATH_SUPPORT_64 is not set
# CONFIG_ASH_GETOPTS is not set
# CONFIG_ASH_BUILTIN_ECHO is not set
# CONFIG_ASH_BUILTIN_TEST is not set
# CONFIG_ASH_CMDCMD is not set
# CONFIG_ASH_MAIL is not set
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
# CONFIG_ASH_RANDOM_SUPPORT is not set
# CONFIG_ASH_EXPAND_PRMT is not set
# CONFIG_HUSH is not set
# CONFIG_LASH is not set
CONFIG_MSH=y
#
# Bourne Shell Options
#
CONFIG_FEATURE_SH_EXTRA_QUIET=y
CONFIG_FEATURE_SH_STANDALONE=y
#
# System Logging Utilities
#
CONFIG_SYSLOGD=y
CONFIG_FEATURE_ROTATE_LOGFILE=y
CONFIG_FEATURE_REMOTE_LOG=y
CONFIG_FEATURE_IPC_SYSLOG=y
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=16
CONFIG_LOGREAD=y
CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING=y
CONFIG_KLOGD=y
CONFIG_LOGGER=y
#
# Runit Utilities
#
# CONFIG_RUNSV is not set
# CONFIG_RUNSVDIR is not set
CONFIG_SV=y
# CONFIG_SVLOGD is not set
CONFIG_CHPST=y
CONFIG_SETUIDGID=y
CONFIG_ENVUIDGID=y
CONFIG_ENVDIR=y
CONFIG_SOFTLIMIT=y
# CONFIG_CHCON is not set
# CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set
# CONFIG_GETENFORCE is not set
# CONFIG_GETSEBOOL is not set
# CONFIG_LOAD_POLICY is not set
# CONFIG_MATCHPATHCON is not set
# CONFIG_RUNCON is not set
# CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set
# CONFIG_SELINUXENABLED is not set
# CONFIG_SETENFORCE is not set
#
# ipsvd utilities
#
# CONFIG_TCPSVD is not set
# CONFIG_UDPSVD is not set
+12 -9
View File
@@ -5,18 +5,21 @@
# Licensed under the GPL v2, see the file LICENSE in this tarball.
obj-y:=
obj-y += applets.o
obj-y += busybox.o
# Generated file needs additional love
applets/applets.o: include/usage_compressed.h
obj-y += applets.o
hostprogs-y:=
hostprogs-y += usage
always := $(hostprogs-y)
HOSTCFLAGS_usage.o = -I$(srctree)/include
always:= $(hostprogs-y)
# Generated files need additional love
quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
cmd_gen_usage_compressed = $(srctree)/applets/usage_compressed include/usage_compressed.h applets
include/usage_compressed.h: $(srctree)/include/usage.h applets/usage
HOSTCFLAGS_usage.o = -I$(srctree)/include
applets/applets.o: include/usage_compressed.h
applets/usage: .config $(srctree)/applets/usage_compressed
include/usage_compressed.h: applets/usage $(srctree)/applets/usage_compressed
$(call cmd,gen_usage_compressed)
+361 -184
View File
@@ -12,8 +12,8 @@
* Licensed under GPLv2 or later, see file License in this tarball for details.
*/
#include "busybox.h"
#include <assert.h>
#include "busybox.h"
/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
@@ -23,10 +23,18 @@
#warning Note that glibc is unsuitable for static linking anyway.
#warning If you still want to do it, remove -Wl,--gc-sections
#warning from top-level Makefile and remove this warning.
#error Aborting compilation.
#endif
/* Declare <applet>_main() */
#define PROTOTYPES
#include "applets.h"
#undef PROTOTYPES
#if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE
static const char usage_messages[] =
/* Define usage_messages[] */
static const char usage_messages[] ALIGN1 = ""
#define MAKE_USAGE
#include "usage.h"
#include "applets.h"
@@ -34,38 +42,35 @@ static const char usage_messages[] =
#undef MAKE_USAGE
#else
#define usage_messages 0
#endif /* ENABLE_SHOW_USAGE */
#endif /* SHOW_USAGE */
#undef APPLET
#undef APPLET_NOUSAGE
#undef PROTOTYPES
/* Define struct bb_applet applets[] */
#include "applets.h"
/* The -1 arises because of the {0,NULL,0,-1} entry. */
static struct BB_applet *applet_using;
#if ENABLE_FEATURE_SH_STANDALONE
const unsigned short NUM_APPLETS = ARRAY_SIZE(applets);
#endif
const struct bb_applet *current_applet;
const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
#if !BB_MMU
bool re_execed;
#endif
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
const unsigned short NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
USE_FEATURE_SUID(static uid_t ruid;) /* real uid */
#if ENABLE_FEATURE_SUID_CONFIG
#ifdef CONFIG_FEATURE_SUID_CONFIG
#include <ctype.h>
#define CONFIG_FILE "/etc/busybox.conf"
/* applets [] is const, so we have to define this "override" structure */
static struct BB_suid_config
{
struct BB_applet *m_applet;
/* applets[] is const, so we have to define this "override" structure */
static struct BB_suid_config {
const struct bb_applet *m_applet;
uid_t m_uid;
gid_t m_gid;
mode_t m_mode;
struct BB_suid_config *m_next;
} *suid_config;
static int suid_cfg_readable;
static bool suid_cfg_readable;
/* check if u is member of group g */
static int ingroup(uid_t u, gid_t g)
@@ -98,53 +103,55 @@ static char *get_trimmed_slice(char *s, char *e)
break;
}
}
e[1] = 0;
e[1] = '\0';
/* Next, advance past all leading space and return a ptr to the
* first non-space char; possibly the terminating nul. */
return skip_whitespace(s);
}
#define parse_error(x) { err=x; goto pe_label; }
/* Don't depend on the tools to combine strings. */
static const char config_file[] = CONFIG_FILE;
/* There are 4 chars + 1 nul for each of user/group/other. */
static const char mode_chars[] = "Ssx-\0Ssx-\0Ttx-";
static const char config_file[] ALIGN1 = "/etc/busybox.conf";
/* We don't supply a value for the nul, so an index adjustment is
* necessary below. Also, we use unsigned short here to save some
* space even though these are really mode_t values. */
static const unsigned short mode_mask[] = {
/* SST sst xxx --- */
static const unsigned short mode_mask[] ALIGN2 = {
/* SST sst xxx --- */
S_ISUID, S_ISUID|S_IXUSR, S_IXUSR, 0, /* user */
S_ISGID, S_ISGID|S_IXGRP, S_IXGRP, 0, /* group */
0, S_IXOTH, S_IXOTH, 0 /* other */
};
#define parse_error(x) do { errmsg = x; goto pe_label; } while (0)
static void parse_config_file(void)
{
struct BB_suid_config *sct_head;
struct BB_suid_config *sct;
struct BB_applet *applet;
const struct bb_applet *applet;
FILE *f;
char *err;
const char *errmsg;
char *s;
char *e;
int i, lc, section;
int i;
unsigned lc;
smallint section;
char buffer[256];
struct stat st;
assert(!suid_config); /* Should be set to NULL by bss init. */
assert(!suid_config); /* Should be set to NULL by bss init. */
if ((stat(config_file, &st) != 0) /* No config file? */
|| !S_ISREG(st.st_mode) /* Not a regular file? */
|| (st.st_uid != 0) /* Not owned by root? */
|| (st.st_mode & (S_IWGRP | S_IWOTH)) /* Writable by non-root? */
|| !(f = fopen(config_file, "r")) /* Cannot open? */
) {
ruid = getuid();
if (ruid == 0) /* run by root - don't need to even read config file */
return;
if ((stat(config_file, &st) != 0) /* No config file? */
|| !S_ISREG(st.st_mode) /* Not a regular file? */
|| (st.st_uid != 0) /* Not owned by root? */
|| (st.st_mode & (S_IWGRP | S_IWOTH)) /* Writable by non-root? */
|| !(f = fopen(config_file, "r")) /* Cannot open? */
) {
return;
}
@@ -152,7 +159,7 @@ static void parse_config_file(void)
sct_head = NULL;
section = lc = 0;
do {
while (1) {
s = buffer;
if (!fgets(s, sizeof(buffer), f)) { /* Are we done? */
@@ -180,7 +187,8 @@ static void parse_config_file(void)
/* Trim leading and trailing whitespace, ignoring comments, and
* check if the resulting string is empty. */
if (!*(s = get_trimmed_slice(s, strchrnul(s, '#')))) {
s = get_trimmed_slice(s, strchrnul(s, '#'));
if (!*s) {
continue;
}
@@ -190,10 +198,11 @@ static void parse_config_file(void)
/* Unlike the old code, we ignore leading and trailing
* whitespace for the section name. We also require that
* there are no stray characters after the closing bracket. */
if (!(e = strchr(s, ']')) /* Missing right bracket? */
|| e[1] /* Trailing characters? */
|| !*(s = get_trimmed_slice(s+1, e)) /* Missing name? */
) {
e = strchr(s, ']');
if (!e /* Missing right bracket? */
|| e[1] /* Trailing characters? */
|| !*(s = get_trimmed_slice(s+1, e)) /* Missing name? */
) {
parse_error("section header");
}
/* Right now we only have one section so just check it.
@@ -219,7 +228,8 @@ static void parse_config_file(void)
* where both key and value could contain inner whitespace. */
/* First get the key (an applet name in our case). */
if (!!(e = strchr(s, '='))) {
e = strchr(s, '=');
if (e) {
s = get_trimmed_slice(s, e);
}
if (!e || !*s) { /* Missing '=' or empty key. */
@@ -228,9 +238,10 @@ static void parse_config_file(void)
/* Ok, we have an applet name. Process the rhs if this
* applet is currently built in and ignore it otherwise.
* Note: This can hide config file bugs which only pop
* Note: this can hide config file bugs which only pop
* up when the busybox configuration is changed. */
if ((applet = find_applet_by_name(s))) {
applet = find_applet_by_name(s);
if (applet) {
/* Note: We currently don't check for duplicates!
* The last config line for each applet will be the
* one used since we insert at the head of the list.
@@ -245,9 +256,13 @@ static void parse_config_file(void)
e = skip_whitespace(e+1);
for (i=0 ; i < 3 ; i++) {
for (i = 0; i < 3; i++) {
/* There are 4 chars + 1 nul for each of user/group/other. */
static const char mode_chars[] ALIGN1 = "Ssx-\0" "Ssx-\0" "Ttx-";
const char *q;
if (!*(q = strchrnul(mode_chars + 5*i, *e++))) {
q = strchrnul(mode_chars + 5*i, *e++);
if (!*q) {
parse_error("mode");
}
/* Adjust by -i to account for nul. */
@@ -258,35 +273,32 @@ static void parse_config_file(void)
s = skip_whitespace(e);
/* Note: We require whitespace between the mode and the
/* Note: we require whitespace between the mode and the
* user/group info. */
if ((s == e) || !(e = strchr(s, '.'))) {
parse_error("<uid>.<gid>");
}
*e++ = 0;
*e++ = '\0';
/* We can't use get_ug_id here since it would exit()
* if a uid or gid was not found. Oh well... */
{
char *e2;
sct->m_uid = strtoul(s, &e2, 10);
if (*e2 || (s == e2)) {
struct passwd *pwd = getpwnam(s);
if (!pwd) {
parse_error("user");
}
sct->m_uid = pwd->pw_uid;
sct->m_uid = bb_strtoul(s, NULL, 10);
if (errno) {
struct passwd *pwd = getpwnam(s);
if (!pwd) {
parse_error("user");
}
sct->m_uid = pwd->pw_uid;
}
sct->m_gid = strtoul(e, &e2, 10);
if (*e2 || (e == e2)) {
struct group *grp;
if (!(grp = getgrnam(e))) {
parse_error("group");
}
sct->m_gid = grp->gr_gid;
sct->m_gid = bb_strtoul(e, NULL, 10);
if (errno) {
struct group *grp;
grp = getgrnam(e);
if (!grp) {
parse_error("group");
}
sct->m_gid = grp->gr_gid;
}
}
continue;
@@ -303,11 +315,11 @@ static void parse_config_file(void)
parse_error("keyword outside section");
}
} while (1);
} /* while (1) */
pe_label:
fprintf(stderr, "Parse error in %s, line %d: %s\n",
config_file, lc, err);
config_file, lc, errmsg);
fclose(f);
/* Release any allocated memory before returning. */
@@ -316,176 +328,341 @@ static void parse_config_file(void)
free(sct_head);
sct_head = sct;
}
return;
}
#else
#define parse_config_file() ((void)0)
#endif /* CONFIG_FEATURE_SUID_CONFIG */
#ifdef CONFIG_FEATURE_SUID
static void check_suid(struct BB_applet *applet)
static inline void parse_config_file(void)
{
uid_t ruid = getuid(); /* real [ug]id */
uid_t rgid = getgid();
USE_FEATURE_SUID(ruid = getuid();)
}
#endif /* FEATURE_SUID_CONFIG */
#ifdef CONFIG_FEATURE_SUID_CONFIG
#if ENABLE_FEATURE_SUID
static void check_suid(const struct bb_applet *applet)
{
gid_t rgid; /* real gid */
if (ruid == 0) /* set by parse_config_file() */
return; /* run by root - no need to check more */
rgid = getgid();
#if ENABLE_FEATURE_SUID_CONFIG
if (suid_cfg_readable) {
uid_t uid;
struct BB_suid_config *sct;
mode_t m;
for (sct = suid_config; sct; sct = sct->m_next) {
if (sct->m_applet == applet)
break;
}
if (sct) {
mode_t m = sct->m_mode;
if (sct->m_uid == ruid)
/* same uid */
m >>= 6;
else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid))
/* same group / in group */
m >>= 3;
if (!(m & S_IXOTH)) /* is x bit not set ? */
bb_error_msg_and_die("you have no permission to run this applet!");
if (sct->m_gid != 0) {
/* _both_ have to be set for sgid */
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
xsetgid(sct->m_gid);
} else xsetgid(rgid); /* no sgid -> drop */
}
if (sct->m_uid != 0) {
if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid);
else xsetuid(ruid); /* no suid -> drop */
}
} else {
/* default: drop all privileges */
xsetgid(rgid);
xsetuid(ruid);
goto found;
}
/* default: drop all privileges */
xsetgid(rgid);
xsetuid(ruid);
return;
} else {
#ifndef CONFIG_FEATURE_SUID_CONFIG_QUIET
static int onetime = 0;
found:
m = sct->m_mode;
if (sct->m_uid == ruid)
/* same uid */
m >>= 6;
else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid))
/* same group / in group */
m >>= 3;
if (!(m & S_IXOTH)) /* is x bit not set ? */
bb_error_msg_and_die("you have no permission to run this applet!");
/* _both_ sgid and group_exec have to be set for setegid */
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
rgid = sct->m_gid;
/* else (no setegid) we will set egid = rgid */
/* We set effective AND saved ids. If saved-id is not set
* like we do below, seteiud(0) can still later succeed! */
if (setresgid(-1, rgid, rgid))
bb_perror_msg_and_die("setresgid");
/* do we have to set effective uid? */
uid = ruid;
if (sct->m_mode & S_ISUID)
uid = sct->m_uid;
/* else (no seteuid) we will set euid = ruid */
if (setresuid(-1, uid, uid))
bb_perror_msg_and_die("setresuid");
return;
}
#if !ENABLE_FEATURE_SUID_CONFIG_QUIET
{
static bool onetime = 0;
if (!onetime) {
onetime = 1;
fprintf(stderr, "Using fallback suid method\n");
}
#endif
}
#endif
#endif
if (applet->need_suid == _BB_SUID_ALWAYS) {
if (geteuid()) bb_error_msg_and_die("applet requires root privileges!");
/* Real uid is not 0. If euid isn't 0 too, suid bit
* is most probably not set on our executable */
if (geteuid())
bb_error_msg_and_die("applet requires root privileges!");
} else if (applet->need_suid == _BB_SUID_NEVER) {
xsetgid(rgid); /* drop all privileges */
xsetgid(rgid); /* drop all privileges */
xsetuid(ruid);
}
}
#else
#define check_suid(x)
#endif /* CONFIG_FEATURE_SUID */
#define check_suid(x) ((void)0)
#endif /* FEATURE_SUID */
#ifdef CONFIG_FEATURE_COMPRESS_USAGE
#if ENABLE_FEATURE_COMPRESS_USAGE
#include "usage_compressed.h"
#include "unarchive.h"
static const char *unpack_usage_messages(void)
{
int input[2], output[2], pid;
char *buf;
char *outbuf = NULL;
bunzip_data *bd;
int i;
if(pipe(input) < 0 || pipe(output) < 0)
exit(1);
pid = fork();
switch (pid) {
case -1: /* error */
exit(1);
case 0: /* child */
close(input[1]);
close(output[0]);
uncompressStream(input[0], output[1]);
exit(0);
i = start_bunzip(&bd,
/* src_fd: */ -1,
/* inbuf: */ packed_usage,
/* len: */ sizeof(packed_usage));
/* read_bunzip can longjmp to start_bunzip, and ultimately
* end up here with i != 0 on read data errors! Not trivial */
if (!i) {
/* Cannot use xmalloc: will leak bd in NOFORK case! */
outbuf = malloc_or_warn(SIZEOF_usage_messages);
if (outbuf)
read_bunzip(bd, outbuf, SIZEOF_usage_messages);
}
/* parent */
close(input[0]);
close(output[1]);
pid = fork();
switch (pid) {
case -1: /* error */
exit(1);
case 0: /* child */
full_write(input[1], packed_usage, sizeof(packed_usage));
exit(0);
}
/* parent */
close(input[1]);
buf = xmalloc(SIZEOF_usage_messages);
full_read(output[0], buf, SIZEOF_usage_messages);
return buf;
dealloc_bunzip(bd);
return outbuf;
}
#define dealloc_usage_messages(s) free(s)
#else
#define unpack_usage_messages() usage_messages
#endif /* ENABLE_FEATURE_COMPRESS_USAGE */
#define dealloc_usage_messages(s) ((void)(s))
#endif /* FEATURE_COMPRESS_USAGE */
void bb_show_usage(void)
{
if (ENABLE_SHOW_USAGE) {
const char *format_string;
const char *usage_string = unpack_usage_messages();
const char *p;
const char *usage_string = p = unpack_usage_messages();
int i;
for (i = applet_using - applets; i > 0;)
if (!*usage_string++) --i;
i = current_applet - applets;
while (i) {
while (*p++) continue;
i--;
}
format_string = "%s\n\nUsage: %s %s\n\n";
if (*usage_string == '\b')
format_string = "%s\n\nNo help available.\n\n";
fprintf(stderr, format_string, bb_msg_full_version,
applet_using->name, usage_string);
fprintf(stderr, "%s multi-call binary\n", bb_banner);
format_string = "\nUsage: %s %s\n\n";
if (*p == '\b')
format_string = "\nNo help available.\n\n";
fprintf(stderr, format_string, applet_name, p);
dealloc_usage_messages((char*)usage_string);
}
exit(xfunc_error_retval);
xfunc_die();
}
static int applet_name_compare(const void *name, const void *vapplet)
{
const struct BB_applet *applet = vapplet;
const struct bb_applet *applet = vapplet;
return strcmp(name, applet->name);
}
struct BB_applet *find_applet_by_name(const char *name)
const struct bb_applet *find_applet_by_name(const char *name)
{
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
/* Do a binary search to find the applet entry given the name. */
return bsearch(name, applets, ARRAY_SIZE(applets)-1, sizeof(applets[0]),
applet_name_compare);
}
void run_applet_by_name(const char *name, int argc, char **argv)
{
if (ENABLE_FEATURE_SUID_CONFIG)
parse_config_file();
if (!strncmp(name, "busybox", 7))
exit(busybox_main(argc, argv));
/* Do a binary search to find the applet entry given the name. */
applet_using = find_applet_by_name(name);
if (applet_using) {
applet_name = applet_using->name;
if (argc == 2 && !strcmp(argv[1], "--help"))
bb_show_usage();
if (ENABLE_FEATURE_SUID)
check_suid(applet_using);
exit(applet_using->main(argc, argv));
#if ENABLE_FEATURE_INSTALLER
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links)
{
/* directory table
* this should be consistent w/ the enum,
* busybox.h::bb_install_loc_t, or else... */
static const char usr_bin [] ALIGN1 = "/usr/bin";
static const char usr_sbin[] ALIGN1 = "/usr/sbin";
static const char *const install_dir[] = {
&usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
&usr_bin [4], /* "/bin" */
&usr_sbin[4], /* "/sbin" */
usr_bin,
usr_sbin
};
int (*lf)(const char *, const char *) = link;
char *fpc;
int i;
int rc;
if (use_symbolic_links)
lf = symlink;
for (i = 0; applets[i].name != NULL; i++) {
fpc = concat_path_file(
install_dir[applets[i].install_loc],
applets[i].name);
rc = lf(busybox, fpc);
if (rc != 0 && errno != EEXIST) {
bb_perror_msg("%s", fpc);
}
free(fpc);
}
}
#else
#define install_links(x,y) ((void)0)
#endif /* FEATURE_INSTALLER */
/* If we were called as "busybox..." */
static int busybox_main(char **argv)
{
if (!argv[1]) {
/* Called without arguments */
const struct bb_applet *a;
int col, output_width;
help:
output_width = 80;
if (ENABLE_FEATURE_AUTOWIDTH) {
/* Obtain the terminal width */
get_terminal_width_height(0, &output_width, NULL);
}
/* leading tab and room to wrap */
output_width -= sizeof("start-stop-daemon, ") + 8;
printf("%s multi-call binary\n", bb_banner); /* reuse const string... */
printf("Copyright (C) 1998-2006  Erik Andersen, Rob Landley, and others.\n"
"Licensed under GPLv2.  See source distribution for full notice.\n"
"\n"
"Usage: busybox [function] [arguments]...\n"
" or: [function] [arguments]...\n"
"\n"
"\tBusyBox is a multi-call binary that combines many common Unix\n"
"\tutilities into a single executable. Most people will create a\n"
"\tlink to busybox for each function they wish to use and BusyBox\n"
"\twill act like whatever it was invoked as!\n"
"\nCurrently defined functions:\n");
col = 0;
a = applets;
while (a->name) {
if (col > output_width) {
puts(",");
col = 0;
}
col += printf("%s%s", (col ? ", " : "\t"), a->name);
a++;
}
puts("\n");
return 0;
}
if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
const char *busybox;
busybox = xmalloc_readlink(bb_busybox_exec_path);
if (!busybox)
busybox = bb_busybox_exec_path;
/* -s makes symlinks */
install_links(busybox, argv[2] && strcmp(argv[2], "-s") == 0);
return 0;
}
if (strcmp(argv[1], "--help") == 0) {
/* "busybox --help [<applet>]" */
if (!argv[2])
goto help;
/* convert to "<applet> --help" */
argv[0] = argv[2];
argv[2] = NULL;
} else {
/* "busybox <applet> arg1 arg2 ..." */
argv++;
}
/* we want "<argv[0]>: applet not found", not "busybox: ..." */
applet_name = argv[0];
run_applet_and_exit(argv[0], argv);
bb_error_msg_and_die("applet not found");
}
void run_current_applet_and_exit(char **argv)
{
int argc = 1;
while (argv[argc])
argc++;
/* Reinit some shared global data */
optind = 1;
xfunc_error_retval = EXIT_FAILURE;
applet_name = current_applet->name;
if (argc == 2 && !strcmp(argv[1], "--help"))
bb_show_usage();
if (ENABLE_FEATURE_SUID)
check_suid(current_applet);
exit(current_applet->main(argc, argv));
}
void run_applet_and_exit(const char *name, char **argv)
{
current_applet = find_applet_by_name(name);
if (current_applet)
run_current_applet_and_exit(argv);
if (!strncmp(name, "busybox", 7))
exit(busybox_main(argv));
}
#ifdef __GLIBC__
/* Make it reside in R/W memory: */
int *const bb_errno __attribute__ ((section (".data")));
#endif
int main(int argc, char **argv)
{
#ifdef __GLIBC__
(*(int **)&bb_errno) = __errno_location();
#endif
#if !BB_MMU
/* NOMMU re-exec trick sets high-order bit in first byte of name */
if (argv[0][0] & 0x80) {
re_execed = 1;
argv[0][0] &= 0x7f;
}
#endif
applet_name = argv[0];
if (applet_name[0] == '-')
applet_name++;
applet_name = bb_basename(applet_name);
parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */
/* Set locale for everybody except 'init' */
if (ENABLE_LOCALE_SUPPORT && getpid() != 1)
setlocale(LC_ALL, "");
run_applet_and_exit(applet_name, argv);
bb_error_msg_and_die("applet not found");
}
-146
View File
@@ -1,146 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* BusyBox' main applet dispatcher.
*
* Licensed under GPLv2, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
#ifdef CONFIG_FEATURE_INSTALLER
/*
* directory table
* this should be consistent w/ the enum, busybox.h::Location,
* or else...
*/
static const char usr_bin [] = "/usr/bin";
static const char usr_sbin[] = "/usr/sbin";
static const char* const install_dir[] = {
&usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
&usr_bin [4], /* "/bin" */
&usr_sbin[4], /* "/sbin" */
usr_bin,
usr_sbin
};
/* abstract link() */
typedef int (*link_func)(const char *, const char *);
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links)
{
link_func lf = link;
char *fpc;
int i;
int rc;
if (use_symbolic_links)
lf = symlink;
for (i = 0; applets[i].name != NULL; i++) {
fpc = concat_path_file(
install_dir[applets[i].location],
applets[i].name);
rc = lf(busybox, fpc);
if (rc != 0 && errno != EEXIST) {
bb_perror_msg("%s", fpc);
}
free(fpc);
}
}
#else
#define install_links(x,y)
#endif /* CONFIG_FEATURE_INSTALLER */
int main(int argc, char **argv)
{
const char *s;
applet_name = argv[0];
if (*applet_name == '-')
applet_name++;
while ((s = strchr(applet_name, '/')))
applet_name = s + 1;
/* Set locale for everybody except 'init' */
if (ENABLE_LOCALE_SUPPORT && getpid() != 1)
setlocale(LC_ALL, "");
run_applet_by_name(applet_name, argc, argv);
bb_error_msg_and_die("applet not found");
}
int busybox_main(int argc, char **argv)
{
/*
* This style of argument parsing doesn't scale well
* in the event that busybox starts wanting more --options.
* If someone has a cleaner approach, by all means implement it.
*/
if (ENABLE_FEATURE_INSTALLER && argc > 1 && !strcmp(argv[1], "--install")) {
int use_symbolic_links = 0;
char *busybox;
/* to use symlinks, or not to use symlinks... */
if (argc > 2)
if (strcmp(argv[2], "-s") == 0)
use_symbolic_links = 1;
/* link */
// XXX: FIXME: this is broken. Why not just use argv[0] ?
busybox = xreadlink("/proc/self/exe");
if (!busybox)
return 1;
install_links(busybox, use_symbolic_links);
if (ENABLE_FEATURE_CLEAN_UP)
free(busybox);
return 0;
}
/* Deal with --help. (Also print help when called with no arguments) */
if (argc == 1 || !strcmp(argv[1], "--help") ) {
if (argc > 2) {
applet_name = argv[2];
run_applet_by_name(applet_name, 2, argv);
} else {
const struct BB_applet *a;
int col, output_width;
output_width = 80 - sizeof("start-stop-daemon, ") - 8;
if (ENABLE_FEATURE_AUTOWIDTH) {
/* Obtain the terminal width. */
get_terminal_width_height(0, &output_width, NULL);
/* leading tab and room to wrap */
output_width -= sizeof("start-stop-daemon, ") + 8;
}
printf("%s\n"
"Copyright (C) 1998-2006  Erik Andersen, Rob Landley, and others.\n"
"Licensed under GPLv2.  See source distribution for full notice.\n\n"
"Usage: busybox [function] [arguments]...\n"
" or: [function] [arguments]...\n\n"
"\tBusyBox is a multi-call binary that combines many common Unix\n"
"\tutilities into a single executable. Most people will create a\n"
"\tlink to busybox for each function they wish to use and BusyBox\n"
"\twill act like whatever it was invoked as!\n"
"\nCurrently defined functions:\n", bb_msg_full_version);
col = 0;
for (a = applets; a->name;) {
col += printf("%s%s", (col ? ", " : "\t"), a->name);
a++;
if (col > output_width && a->name) {
puts(",");
col = 0;
}
}
puts("\n");
return 0;
}
} else run_applet_by_name(argv[1], argc - 1, argv + 1);
bb_error_msg_and_die("applet not found");
}
+2 -3
View File
@@ -9,12 +9,11 @@ const char *applet_name;
#include <stdio.h>
#include <stdlib.h>
//Ok to remove? #include "bb_config.h"
#include "usage.h"
int main(int argc, char *argv[])
int main(int argc, char **argv)
{
applet_name=argv[0];
applet_name = argv[0];
return APPLET_main(argc,argv);
}
+2 -2
View File
@@ -43,7 +43,7 @@ if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then
inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'`
sub_shell_it=`
cd "$prefix"
for d in usr/sbin usr/bin sbin bin ; do
for d in usr/sbin usr/bin sbin bin; do
pd=$PWD
if [ -d "$d" ]; then
cd $d
@@ -58,7 +58,7 @@ rm -f $prefix/bin/busybox || exit 1
mkdir -p $prefix/bin || exit 1
install -m 755 busybox $prefix/bin/busybox || exit 1
for i in $h ; do
for i in $h; do
appdir=`dirname $i`
mkdir -p $prefix/$appdir || exit 1
if [ "$2" = "--hardlinks" ]; then
+2 -1
View File
@@ -1,8 +1,9 @@
/* vi: set sw=4 ts=4: */
#include <unistd.h>
/* Just #include "autoconf.h" doesn't work for builds in separate
* object directory */
#include "../include/autoconf.h"
#include "../include/busybox.h"
static const char usage_messages[] = ""
#define MAKE_USAGE
+2 -2
View File
@@ -12,8 +12,8 @@ sz=`"$loc/usage" | wc -c` || exit 1
exec >"$target"
echo 'static const char packed_usage[] = '
echo 'static const char packed_usage[] ALIGN1 = '
"$loc/usage" | bzip2 -1 | od -v -t x1 \
| $SED -e 's/^[^ ]*//' -e 's/ \(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/'
| $SED -e 's/^[^ ]*//' -e 's/ *\(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/'
echo ';'
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
+3 -1
View File
@@ -2,4 +2,6 @@
# Build system
# ==========================================================================
CFLAGS += -march=i386 -mpreferred-stack-boundary=2
# -mpreferred-stack-boundary=2 is essential in preventing gcc 4.2.x
# from aligning stack to 16 bytes. (Which is gcc's way of supporting SSE).
CFLAGS += $(call cc-option,-march=i386 -mpreferred-stack-boundary=2,)
+16
View File
@@ -133,6 +133,13 @@ config RPM
help
Mini RPM applet - queries and extracts RPM packages.
config FEATURE_RPM_BZ2
bool "Enable handling of rpms with bzip2-compressed data inside"
default n
depends on RPM
help
Enable handling of rpms with bzip2-compressed data inside.
config TAR
bool "tar"
default n
@@ -198,6 +205,15 @@ config FEATURE_TAR_OLDGNU_COMPATIBILITY
the old GNU format; help to kill this old format by
repacking your ancient archives with the new format.
config FEATURE_TAR_OLDSUN_COMPATIBILITY
bool "Enable untarring of tarballs with checksums produced by buggy Sun tar"
default N
depends on TAR
help
This option is required to unpack archives created by some old
version of Sun's tar (it was calculating checksum using signed arithmetic).
It is said to be fixed in newer Sun tar, but "old" tarballs still exist.
config FEATURE_TAR_GNU_EXTENSIONS
bool "Enable support for some GNU tar extensions"
default y
+5 -5
View File
@@ -8,15 +8,15 @@ libs-y += libunarchive/
lib-y:=
lib-$(CONFIG_AR) += ar.o
lib-$(CONFIG_BUNZIP2) += bunzip2.o
lib-$(CONFIG_UNLZMA) += unlzma.o
lib-$(CONFIG_BUNZIP2) += bbunzip.o
lib-$(CONFIG_UNLZMA) += bbunzip.o
lib-$(CONFIG_CPIO) += cpio.o
lib-$(CONFIG_DPKG) += dpkg.o
lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o
lib-$(CONFIG_GUNZIP) += gunzip.o
lib-$(CONFIG_GZIP) += gzip.o
lib-$(CONFIG_GUNZIP) += bbunzip.o
lib-$(CONFIG_GZIP) += gzip.o bbunzip.o
lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o
lib-$(CONFIG_RPM) += rpm.o
lib-$(CONFIG_TAR) += tar.o
lib-$(CONFIG_UNCOMPRESS) += uncompress.o
lib-$(CONFIG_UNCOMPRESS) += bbunzip.o
lib-$(CONFIG_UNZIP) += unzip.o
+9 -6
View File
@@ -14,7 +14,7 @@
* http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
*/
#include "busybox.h"
#include "libbb.h"
#include "unarchive.h"
static void header_verbose_list_ar(const file_header_t *file_header)
@@ -38,19 +38,21 @@ static void header_verbose_list_ar(const file_header_t *file_header)
#define AR_OPT_CREATE 0x20
#define AR_OPT_INSERT 0x40
int ar_main(int argc, char **argv);
int ar_main(int argc, char **argv)
{
static const char msg_unsupported_err[] ALIGN1 =
"archive %s is not supported";
archive_handle_t *archive_handle;
unsigned opt;
static const char msg_unsupported_err[] =
"Archive %s not supported. Install binutils 'ar'.";
char magic[8];
archive_handle = init_handle();
/* Prepend '-' to the first argument if required */
opt_complementary = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
opt = getopt32(argc, argv, "ptxovcr");
opt_complementary = "--:p:t:x:-1:p--tx:t--px:x--pt";
opt = getopt32(argv, "ptxovcr");
if (opt & AR_CTX_PRINT) {
archive_handle->action_data = data_extract_to_stdout;
@@ -87,7 +89,8 @@ int ar_main(int argc, char **argv)
}
archive_handle->offset += 7;
while (get_header_ar(archive_handle) == EXIT_SUCCESS) /* repeat */;
while (get_header_ar(archive_handle) == EXIT_SUCCESS)
continue;
return EXIT_SUCCESS;
}
+349
View File
@@ -0,0 +1,349 @@
/* vi: set sw=4 ts=4: */
/*
* Common code for gunzip-like applets
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
enum {
OPT_STDOUT = 0x1,
OPT_FORCE = 0x2,
/* gunzip only: */
OPT_VERBOSE = 0x4,
OPT_DECOMPRESS = 0x8,
OPT_TEST = 0x10,
};
static
int open_to_or_warn(int to_fd, const char *filename, int flags, int mode)
{
int fd = open3_or_warn(filename, flags, mode);
if (fd < 0) {
return 1;
}
xmove_fd(fd, to_fd);
return 0;
}
int bbunpack(char **argv,
char* (*make_new_name)(char *filename),
USE_DESKTOP(long long) int (*unpacker)(void)
)
{
struct stat stat_buf;
USE_DESKTOP(long long) int status;
char *filename, *new_name;
smallint exitcode = 0;
do {
/* NB: new_name is *maybe* malloc'ed! */
new_name = NULL;
filename = *argv; /* can be NULL - 'streaming' bunzip2 */
if (filename && LONE_DASH(filename))
filename = NULL;
/* Open src */
if (filename) {
if (stat(filename, &stat_buf) != 0) {
bb_perror_msg("%s", filename);
err:
exitcode = 1;
goto free_name;
}
if (open_to_or_warn(STDIN_FILENO, filename, O_RDONLY, 0))
goto err;
}
/* Special cases: test, stdout */
if (option_mask32 & (OPT_STDOUT|OPT_TEST)) {
if (option_mask32 & OPT_TEST)
if (open_to_or_warn(STDOUT_FILENO, bb_dev_null, O_WRONLY, 0))
goto err;
filename = NULL;
}
/* Open dst if we are going to unpack to file */
if (filename) {
new_name = make_new_name(filename);
if (!new_name) {
bb_error_msg("%s: unknown suffix - ignored", filename);
goto err;
}
/* O_EXCL: "real" bunzip2 doesn't overwrite files */
/* GNU gunzip goes not bail out, but goes to next file */
if (open_to_or_warn(STDOUT_FILENO, new_name, O_WRONLY | O_CREAT | O_EXCL,
stat_buf.st_mode))
goto err;
}
/* Check that the input is sane */
if (isatty(STDIN_FILENO) && (option_mask32 & OPT_FORCE) == 0) {
bb_error_msg_and_die("compressed data not read from terminal, "
"use -f to force it");
}
status = unpacker();
if (status < 0)
exitcode = 1;
if (filename) {
char *del = new_name;
if (status >= 0) {
/* TODO: restore user/group/times here? */
/* Delete _compressed_ file */
del = filename;
/* restore extension (unless tgz -> tar case) */
if (new_name == filename)
filename[strlen(filename)] = '.';
}
xunlink(del);
#if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */
/* Extreme bloat for gunzip compat */
if (ENABLE_DESKTOP && (option_mask32 & OPT_VERBOSE) && status >= 0) {
fprintf(stderr, "%s: %u%% - replaced with %s\n",
filename, (unsigned)(stat_buf.st_size*100 / (status+1)), new_name);
}
#endif
free_name:
if (new_name != filename)
free(new_name);
}
} while (*argv && *++argv);
return exitcode;
}
#if ENABLE_BUNZIP2 || ENABLE_UNLZMA || ENABLE_UNCOMPRESS
static
char* make_new_name_generic(char *filename, const char *expected_ext)
{
char *extension = strrchr(filename, '.');
if (!extension || strcmp(extension + 1, expected_ext) != 0) {
/* Mimic GNU gunzip - "real" bunzip2 tries to */
/* unpack file anyway, to file.out */
return NULL;
}
*extension = '\0';
return filename;
}
#endif
/*
* Modified for busybox by Glenn McGrath <bug1@iinet.net.au>
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#if ENABLE_BUNZIP2
static
char* make_new_name_bunzip2(char *filename)
{
return make_new_name_generic(filename, "bz2");
}
static
USE_DESKTOP(long long) int unpack_bunzip2(void)
{
return unpack_bz2_stream(STDIN_FILENO, STDOUT_FILENO);
}
int bunzip2_main(int argc, char **argv);
int bunzip2_main(int argc, char **argv)
{
getopt32(argv, "cf");
argv += optind;
if (applet_name[2] == 'c')
option_mask32 |= OPT_STDOUT;
return bbunpack(argv, make_new_name_bunzip2, unpack_bunzip2);
}
#endif
/*
* Gzip implementation for busybox
*
* Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly.
*
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
* based on gzip sources
*
* Adjusted further by Erik Andersen <andersen@codepoet.org> to support files as
* well as stdin/stdout, and to generally behave itself wrt command line
* handling.
*
* General cleanup to better adhere to the style guide and make use of standard
* busybox functions by Glenn McGrath <bug1@iinet.net.au>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
* Copyright (C) 1992-1993 Jean-loup Gailly
* The unzip code was written and put in the public domain by Mark Adler.
* Portions of the lzw code are derived from the public domain 'compress'
* written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies,
* Ken Turkowski, Dave Mack and Peter Jannesen.
*
* See the license_msg below and the file COPYING for the software license.
* See the file algorithm.doc for the compression algorithms and file formats.
*/
#if ENABLE_GUNZIP
static
char* make_new_name_gunzip(char *filename)
{
char *extension = strrchr(filename, '.');
if (!extension)
return NULL;
extension++;
if (strcmp(extension, "tgz" + 1) == 0
#if ENABLE_FEATURE_GUNZIP_UNCOMPRESS
|| strcmp(extension, "Z") == 0
#endif
) {
extension[-1] = '\0';
} else if (strcmp(extension, "tgz") == 0) {
filename = xstrdup(filename);
extension = strrchr(filename, '.');
extension[2] = 'a';
extension[3] = 'r';
} else {
return NULL;
}
return filename;
}
static
USE_DESKTOP(long long) int unpack_gunzip(void)
{
USE_DESKTOP(long long) int status = -1;
/* do the decompression, and cleanup */
if (xread_char(STDIN_FILENO) == 0x1f) {
unsigned char magic2;
magic2 = xread_char(STDIN_FILENO);
if (ENABLE_FEATURE_GUNZIP_UNCOMPRESS && magic2 == 0x9d) {
status = uncompress(STDIN_FILENO, STDOUT_FILENO);
} else if (magic2 == 0x8b) {
check_header_gzip_or_die(STDIN_FILENO);
status = unpack_gz_stream(STDIN_FILENO, STDOUT_FILENO);
} else {
goto bad_magic;
}
if (status < 0) {
bb_error_msg("error inflating");
}
} else {
bad_magic:
bb_error_msg("invalid magic");
/* status is still == -1 */
}
return status;
}
int gunzip_main(int argc, char **argv);
int gunzip_main(int argc, char **argv)
{
getopt32(argv, "cfvdt");
argv += optind;
/* if called as zcat */
if (applet_name[1] == 'c')
option_mask32 |= OPT_STDOUT;
return bbunpack(argv, make_new_name_gunzip, unpack_gunzip);
}
#endif
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
*
* Based on bunzip.c from busybox
*
* Licensed under GPL v2, see file LICENSE in this tarball for details.
*/
#if ENABLE_UNLZMA
static
char* make_new_name_unlzma(char *filename)
{
return make_new_name_generic(filename, "lzma");
}
static
USE_DESKTOP(long long) int unpack_unlzma(void)
{
return unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO);
}
int unlzma_main(int argc, char **argv);
int unlzma_main(int argc, char **argv)
{
getopt32(argv, "cf");
argv += optind;
/* lzmacat? */
if (applet_name[4] == 'c')
option_mask32 |= OPT_STDOUT;
return bbunpack(argv, make_new_name_unlzma, unpack_unlzma);
}
#endif
/*
* Uncompress applet for busybox (c) 2002 Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#if ENABLE_UNCOMPRESS
static
char* make_new_name_uncompress(char *filename)
{
return make_new_name_generic(filename, "Z");
}
static
USE_DESKTOP(long long) int unpack_uncompress(void)
{
USE_DESKTOP(long long) int status = -1;
if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) {
bb_error_msg("invalid magic");
} else {
status = uncompress(STDIN_FILENO, STDOUT_FILENO);
}
return status;
}
int uncompress_main(int argc, char **argv);
int uncompress_main(int argc, char **argv)
{
getopt32(argv, "cf");
argv += optind;
return bbunpack(argv, make_new_name_uncompress, unpack_uncompress);
}
#endif
-66
View File
@@ -1,66 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Modified for busybox by Glenn McGrath <bug1@iinet.net.au>
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "unarchive.h"
#define BUNZIP2_OPT_STDOUT 1
#define BUNZIP2_OPT_FORCE 2
int bunzip2_main(int argc, char **argv)
{
USE_DESKTOP(long long) int status;
char *filename;
unsigned opt;
int src_fd, dst_fd;
opt = getopt32(argc, argv, "cf");
/* Set input filename and number */
filename = argv[optind];
if (filename && NOT_LONE_DASH(filename)) {
/* Open input file */
src_fd = xopen(filename, O_RDONLY);
} else {
src_fd = STDIN_FILENO;
filename = 0;
}
/* if called as bzcat force the stdout flag */
if ((opt & BUNZIP2_OPT_STDOUT) || applet_name[2] == 'c')
filename = 0;
/* Check that the input is sane. */
if (isatty(src_fd) && (opt & BUNZIP2_OPT_FORCE) == 0) {
bb_error_msg_and_die("compressed data not read from terminal, "
"use -f to force it");
}
if (filename) {
struct stat stat_buf;
/* extension = filename+strlen(filename)-4 is buggy:
* strlen may be less than 4 */
char *extension = strrchr(filename, '.');
if (!extension || strcmp(extension, ".bz2") != 0) {
bb_error_msg_and_die("invalid extension");
}
xstat(filename, &stat_buf);
*extension = '\0';
dst_fd = xopen3(filename, O_WRONLY | O_CREAT | O_TRUNC,
stat_buf.st_mode);
} else dst_fd = STDOUT_FILENO;
status = uncompressStream(src_fd, dst_fd);
if (filename) {
if (status >= 0) filename[strlen(filename)] = '.';
if (unlink(filename) < 0) {
bb_error_msg_and_die("cannot remove %s", filename);
}
}
return status;
}
+10 -13
View File
@@ -11,21 +11,18 @@
* Only supports new ASCII and CRC formats
*
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h"
#include "busybox.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
#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
int cpio_main(int argc, char **argv);
int cpio_main(int argc, char **argv)
{
archive_handle_t *archive_handle;
@@ -38,7 +35,7 @@ int cpio_main(int argc, char **argv)
archive_handle->seek = seek_by_read;
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
opt = getopt32(argc, argv, "ituvF:dm", &cpio_filename);
opt = getopt32(argv, "ituvF:dm", &cpio_filename);
/* One of either extract or test options must be given */
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
+111 -121
View File
@@ -24,7 +24,7 @@
*
*/
#include "busybox.h"
#include "libbb.h"
#include "unarchive.h"
/* note: if you vary hash_prime sizes be aware,
@@ -53,16 +53,16 @@
* and available file */
#define PACKAGE_HASH_PRIME 10007
typedef struct edge_s {
unsigned operator:3;
unsigned operator:4; /* was:3 */
unsigned type:4;
unsigned name:14;
unsigned version:14;
unsigned name:16; /* was:14 */
unsigned version:16; /* was:14 */
} edge_t;
typedef struct common_node_s {
unsigned name:14;
unsigned version:14;
unsigned num_of_edges:14;
unsigned name:16; /* was:14 */
unsigned version:16; /* was:14 */
unsigned num_of_edges:16; /* was:14 */
edge_t **edge;
} common_node_t;
@@ -71,8 +71,8 @@ typedef struct common_node_s {
* likely to be installed at any one time, so there is a bit of leeway here */
#define STATUS_HASH_PRIME 8191
typedef struct status_node_s {
unsigned package:14; /* has to fit PACKAGE_HASH_PRIME */
unsigned status:14; /* has to fit STATUS_HASH_PRIME */
unsigned package:16; /* was:14 */ /* has to fit PACKAGE_HASH_PRIME */
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 */
@@ -107,13 +107,13 @@ enum operator_e {
typedef struct deb_file_s {
char *control_file;
char *filename;
unsigned package:14;
unsigned package:16; /* was:14 */
} deb_file_t;
static void make_hash(const char *key, unsigned *start, unsigned *decrement, const int hash_prime)
{
unsigned long int hash_num = key[0];
unsigned long hash_num = key[0];
int len = strlen(key);
int i;
@@ -352,7 +352,8 @@ static int search_package_hashtable(const unsigned name, const unsigned version,
* FIXME: I don't think this is very efficient, but I thought I'd keep
* it simple for now until it proves to be a problem.
*/
static int search_for_provides(int needle, int start_at) {
static int search_for_provides(int needle, int start_at)
{
int i, j;
common_node_t *p;
for (i = start_at + 1; i < PACKAGE_HASH_PRIME; i++) {
@@ -412,7 +413,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
or_edge = xmalloc(sizeof(edge_t));
or_edge->type = edge_type + 1;
or_edge->name = search_name_hashtable(field);
or_edge->version = 0; // tracks the number of altenatives
or_edge->version = 0; // tracks the number of alternatives
add_edge_to_node(parent_node, or_edge);
}
@@ -431,7 +432,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
edge->version = search_name_hashtable("ANY");
} else {
/* Skip leading ' ' or '(' */
version += strspn(field2, " (");
version += strspn(version, " (");
/* Calculate length of any operator characters */
offset_ch = strspn(version, "<=>");
/* Determine operator */
@@ -472,9 +473,13 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
or_edge->version++;
add_edge_to_node(parent_node, edge);
} while ((field2 = strtok_r(NULL, "|", &line_ptr2)) != NULL);
field2 = strtok_r(NULL, "|", &line_ptr2);
} while (field2 != NULL);
free(line2);
} while ((field = strtok_r(NULL, ",", &line_ptr1)) != NULL);
field = strtok_r(NULL, ",", &line_ptr1);
} while (field != NULL);
free(line);
}
@@ -577,10 +582,10 @@ static int read_package_field(const char *package_buffer, char **field_name, cha
static unsigned fill_package_struct(char *control_buffer)
{
static const char *const field_names[] = { "Package", "Version",
"Pre-Depends", "Depends","Replaces", "Provides",
"Conflicts", "Suggests", "Recommends", "Enhances", 0
};
static const char field_names[] ALIGN1 =
"Package\0""Version\0"
"Pre-Depends\0""Depends\0""Replaces\0""Provides\0"
"Conflicts\0""Suggests\0""Recommends\0""Enhances\0";
common_node_t *new_node = xzalloc(sizeof(common_node_t));
char *field_name;
@@ -597,10 +602,10 @@ static unsigned fill_package_struct(char *control_buffer)
&field_name, &field_value);
if (field_name == NULL) {
goto fill_package_struct_cleanup; /* Oh no, the dreaded goto statement ! */
goto fill_package_struct_cleanup; /* Oh no, the dreaded goto statement! */
}
field_num = index_in_str_array(field_names, field_name);
field_num = index_in_strings(field_names, field_name);
switch (field_num) {
case 0: /* Package */
new_node->name = search_name_hashtable(field_value);
@@ -643,11 +648,8 @@ static unsigned fill_package_struct(char *control_buffer)
return -1;
}
num = search_package_hashtable(new_node->name, new_node->version, VER_EQUAL);
if (package_hashtable[num] == NULL) {
package_hashtable[num] = new_node;
} else {
free_package(new_node);
}
free_package(package_hashtable[num]);
package_hashtable[num] = new_node;
return num;
}
@@ -706,13 +708,13 @@ static void set_status(const unsigned status_node_num, const char *new_value, co
new_status = xasprintf("%s %s %s", name_hashtable[want], name_hashtable[flag], name_hashtable[status]);
status_hashtable[status_node_num]->status = search_name_hashtable(new_status);
free(new_status);
return;
}
static const char *describe_status(int status_num) {
int status_want, status_state ;
static const char *describe_status(int status_num)
{
int status_want, status_state;
if (status_hashtable[status_num] == NULL || status_hashtable[status_num]->status == 0)
return "is not installed or flagged to be installed\n";
return "is not installed or flagged to be installed";
status_want = get_status(status_num, 1);
status_state = get_status(status_num, 3);
@@ -725,7 +727,7 @@ static const char *describe_status(int status_num) {
if (status_want == search_name_hashtable("purge"))
return "is marked to be purged";
}
if (status_want == search_name_hashtable("unknown"))
if (status_want == search_name_hashtable("unknown"))
return "is in an indeterminate state";
if (status_want == search_name_hashtable("install"))
return "is marked to be installed";
@@ -763,7 +765,6 @@ static void index_status_file(const char *filename)
free(control_buffer);
}
fclose(status_file);
return;
}
static void write_buffer_no_status(FILE *new_status_file, const char *control_buffer)
@@ -780,7 +781,6 @@ static void write_buffer_no_status(FILE *new_status_file, const char *control_bu
fprintf(new_status_file, "%s: %s\n", name, value);
}
}
return;
}
/* This could do with a cleanup */
@@ -799,7 +799,8 @@ static void write_status_file(deb_file_t **deb_file)
/* Update previously known packages */
while ((control_buffer = xmalloc_fgets_str(old_status_file, "\n\n")) != NULL) {
if ((tmp_string = strstr(control_buffer, "Package:")) == NULL) {
tmp_string = strstr(control_buffer, "Package:");
if (tmp_string == NULL) {
continue;
}
@@ -824,8 +825,9 @@ static void write_status_file(deb_file_t **deb_file)
if (strcmp(status_from_file, status_from_hashtable) != 0) {
/* New status isnt exactly the same as old status */
const int state_status = get_status(status_num, 3);
if ((strcmp("installed", name_hashtable[state_status]) == 0) ||
(strcmp("unpacked", name_hashtable[state_status]) == 0)) {
if ((strcmp("installed", name_hashtable[state_status]) == 0)
|| (strcmp("unpacked", name_hashtable[state_status]) == 0)
) {
/* We need to add the control file from the package */
i = 0;
while (deb_file[i] != NULL) {
@@ -890,7 +892,7 @@ static void write_status_file(deb_file_t **deb_file)
}
}
/* If the package from the status file wasnt handle above, do it now*/
if (! write_flag) {
if (!write_flag) {
fprintf(new_status_file, "%s\n\n", control_buffer);
}
@@ -1071,12 +1073,14 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
const edge_t *package_edge = package_node->edge[j];
unsigned package_num;
if (package_edge->type == EDGE_OR_PRE_DEPENDS ||
package_edge->type == EDGE_OR_DEPENDS) { /* start an EDGE_OR_ list */
if (package_edge->type == EDGE_OR_PRE_DEPENDS
|| package_edge->type == EDGE_OR_DEPENDS
) { /* start an EDGE_OR_ list */
number_of_alternatives = package_edge->version;
root_of_alternatives = package_edge;
continue;
} else if (number_of_alternatives == 0) { /* not in the middle of an EDGE_OR_ list */
}
if (number_of_alternatives == 0) { /* not in the middle of an EDGE_OR_ list */
number_of_alternatives = 1;
root_of_alternatives = NULL;
}
@@ -1126,14 +1130,14 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
name_hashtable[package_node->name],
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
name_hashtable[root_of_alternatives->name]);
else
bb_error_msg_and_die(
"package %s %sdepends on %s, which %s\n",
name_hashtable[package_node->name],
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
name_hashtable[package_edge->name],
describe_status(status_num));
} else if (result == 0 && number_of_alternatives) {
bb_error_msg_and_die(
"package %s %sdepends on %s, which %s\n",
name_hashtable[package_node->name],
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
name_hashtable[package_edge->name],
describe_status(status_num));
}
if (result == 0 && number_of_alternatives) {
/* we've found a package which
* satisfies the dependency,
* so skip over the rest of
@@ -1171,49 +1175,42 @@ static char **create_list(const char *filename)
if (count == 0) {
return NULL;
} else {
file_list[count] = NULL;
return file_list;
}
file_list[count] = NULL;
return file_list;
}
/* maybe i should try and hook this into remove_file.c somehow */
static int remove_file_array(char **remove_names, char **exclude_names)
{
struct stat path_stat;
int match_flag;
int remove_flag = FALSE;
int i,j;
int remove_flag = 1; /* not removed anything yet */
int i, j;
if (remove_names == NULL) {
return FALSE;
return 0;
}
for (i = 0; remove_names[i] != NULL; i++) {
match_flag = FALSE;
if (exclude_names != NULL) {
for (j = 0; exclude_names[j] != 0; j++) {
for (j = 0; exclude_names[j] != NULL; j++) {
if (strcmp(remove_names[i], exclude_names[j]) == 0) {
match_flag = TRUE;
break;
goto skip;
}
}
}
if (!match_flag) {
if (lstat(remove_names[i], &path_stat) < 0) {
continue;
}
if (S_ISDIR(path_stat.st_mode)) {
if (rmdir(remove_names[i]) != -1) {
remove_flag = TRUE;
}
} else {
if (unlink(remove_names[i]) != -1) {
remove_flag = TRUE;
}
}
/* TODO: why we are checking lstat? we can just try rm/rmdir */
if (lstat(remove_names[i], &path_stat) < 0) {
continue;
}
if (S_ISDIR(path_stat.st_mode)) {
remove_flag &= rmdir(remove_names[i]); /* 0 if no error */
} else {
remove_flag &= unlink(remove_names[i]); /* 0 if no error */
}
skip:
continue;
}
return remove_flag;
return (remove_flag == 0);
}
static int run_package_script(const char *package_name, const char *script_type)
@@ -1230,8 +1227,11 @@ static int run_package_script(const char *package_name, const char *script_type)
return result;
}
static const char *all_control_files[] = {"preinst", "postinst", "prerm", "postrm",
"list", "md5sums", "shlibs", "conffiles", "config", "templates", NULL };
static const char *const all_control_files[] = {
"preinst", "postinst", "prerm", "postrm",
"list", "md5sums", "shlibs", "conffiles",
"config", "templates", NULL
};
static char **all_control_list(const char *package_name)
{
@@ -1250,7 +1250,6 @@ static char **all_control_list(const char *package_name)
static void free_array(char **array)
{
if (array) {
unsigned i = 0;
while (array[i]) {
@@ -1273,8 +1272,7 @@ static void list_packages(void)
puts("+++-==============-==============");
/* go through status hash, dereference package hash and finally strings */
for (i=0; i<STATUS_HASH_PRIME+1; i++) {
for (i = 0; i < STATUS_HASH_PRIME+1; i++) {
if (status_hashtable[i]) {
const char *stat_str; /* status string */
const char *name_str; /* package name */
@@ -1291,7 +1289,7 @@ static void list_packages(void)
s1 = stat_str[0] == 'i' ? 'i' : 'r';
/* get abbreviation for status field 2 */
for (j=0, spccnt=0; stat_str[j] && spccnt<2; j++) {
for (j = 0, spccnt = 0; stat_str[j] && spccnt < 2; j++) {
if (stat_str[j] == ' ') spccnt++;
}
s2 = stat_str[j];
@@ -1299,7 +1297,7 @@ static void list_packages(void)
/* print out the line formatted like Debian dpkg */
printf("%c%c %-14s %s\n", s1, s2, name_str, vers_str);
}
}
}
}
static void remove_package(const unsigned package_num, int noisy)
@@ -1312,14 +1310,12 @@ static void remove_package(const unsigned package_num, int noisy)
char **exclude_files;
char list_name[package_name_length + 25];
char conffile_name[package_name_length + 30];
int return_value;
if (noisy)
printf("Removing %s (%s)...\n", package_name, package_version);
/* run prerm script */
return_value = run_package_script(package_name, "prerm");
if (return_value == -1) {
if (run_package_script(package_name, "prerm") != 0) {
bb_error_msg_and_die("script failed, prerm failure");
}
@@ -1387,8 +1383,8 @@ static void purge_package(const unsigned package_num)
free(exclude_files);
/* run postrm script */
if (run_package_script(package_name, "postrm") == -1) {
bb_error_msg_and_die("postrm fialure.. set status to what?");
if (run_package_script(package_name, "postrm") != 0) {
bb_error_msg_and_die("postrm failure.. set status to what?");
}
/* Change package status */
@@ -1416,17 +1412,15 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
tar_handle->src_fd = ar_handle->src_fd;
/* We don't care about data.tar.* or debian-binary, just control.tar.* */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_handle->accept), "control.tar.gz");
#if ENABLE_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_handle->accept), (char*)"control.tar.gz");
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_handle->accept), "control.tar.bz2");
#if ENABLE_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_handle->accept), (char*)"control.tar.bz2");
#endif
/* Assign the tar handle as a subarchive of the ar handle */
ar_handle->sub_archive = tar_handle;
return;
}
static void init_archive_deb_data(archive_handle_t *ar_handle)
@@ -1438,17 +1432,15 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
tar_handle->src_fd = ar_handle->src_fd;
/* We don't care about control.tar.* or debian-binary, just data.tar.* */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_handle->accept), "data.tar.gz");
#if ENABLE_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_handle->accept), (char*)"data.tar.gz");
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_handle->accept), "data.tar.bz2");
#if ENABLE_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_handle->accept), (char*)"data.tar.bz2");
#endif
/* Assign the tar handle as a subarchive of the ar handle */
ar_handle->sub_archive = tar_handle;
return;
}
static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, llist_t *myaccept)
@@ -1472,7 +1464,6 @@ static void data_extract_all_prefix(archive_handle_t *archive_handle)
archive_handle->file_header->name = xasprintf("%s%s", archive_handle->buffer, name_ptr);
data_extract_all(archive_handle);
}
return;
}
static void unpack_package(deb_file_t *deb_file)
@@ -1525,7 +1516,7 @@ static void unpack_package(deb_file_t *deb_file)
archive_handle = init_archive_deb_ar(deb_file->filename);
init_archive_deb_data(archive_handle);
archive_handle->sub_archive->action_data = data_extract_all_prefix;
archive_handle->sub_archive->buffer = "/";
archive_handle->sub_archive->buffer = (char*)"/"; /* huh? */
archive_handle->sub_archive->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
unpack_ar_archive(archive_handle);
@@ -1559,13 +1550,14 @@ static void configure_package(deb_file_t *deb_file)
/* Run the postinst script */
if (run_package_script(package_name, "postinst") != 0) {
/* TODO: handle failure gracefully */
bb_error_msg_and_die("postrm failure.. set status to what?");
bb_error_msg_and_die("postinst failure.. set status to what?");
}
/* Change status to reflect success */
set_status(status_num, "install", 1);
set_status(status_num, "installed", 3);
}
int dpkg_main(int argc, char **argv);
int dpkg_main(int argc, char **argv)
{
deb_file_t **deb_file = NULL;
@@ -1585,21 +1577,19 @@ int dpkg_main(int argc, char **argv)
OPT_purge = 0x10,
OPT_remove = 0x20,
OPT_unpack = 0x40,
REQ_package_name = 0x8000,
REQ_filename = 0x4000,
};
opt = getopt32(argc, argv, "CF:ilPru", &str_f);
if (opt & OPT_configure) opt |= REQ_package_name; // -C
opt = getopt32(argv, "CF:ilPru", &str_f);
//if (opt & OPT_configure) ... // -C
if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg)
if (strcmp(str_f, "depends"))
opt &= ~OPT_force_ignore_depends;
}
if (opt & OPT_install) opt |= REQ_filename; // -i
//if (opt & OPT_install) ... // -i
//if (opt & OPT_list_installed) ... // -l
if (opt & OPT_purge) opt |= REQ_package_name; // -P
if (opt & OPT_remove) opt |= REQ_package_name; // -r
if (opt & OPT_unpack) opt |= REQ_filename; // -u (--unpack in official dpkg)
//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 */
@@ -1622,14 +1612,15 @@ int dpkg_main(int argc, char **argv)
/* Read arguments and store relevant info in structs */
while (*argv) {
/* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */
deb_file = xrealloc(deb_file, sizeof(deb_file_t *) * (deb_count + 2));
deb_file[deb_count] = xzalloc(sizeof(deb_file_t));
if (opt & REQ_filename) {
deb_file = xrealloc(deb_file, sizeof(deb_file[0]) * (deb_count + 2));
deb_file[deb_count] = xzalloc(sizeof(deb_file[0][0]));
if (opt & (OPT_install | OPT_unpack)) {
/* -i/-u: require filename */
archive_handle_t *archive_handle;
llist_t *control_list = NULL;
/* Extract the control file */
llist_add_to(&control_list, "./control");
llist_add_to(&control_list, (char*)"./control");
archive_handle = init_archive_deb_ar(argv[0]);
init_archive_deb_control(archive_handle);
deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list);
@@ -1647,7 +1638,7 @@ int dpkg_main(int argc, char **argv)
deb_file[deb_count]->package = (unsigned) package_num;
/* Add the package to the status hashtable */
if (opt & (OPT_unpack|OPT_install)) {
if (opt & (OPT_unpack | OPT_install)) {
/* Try and find a currently installed version of this package */
status_num = search_status_hashtable(name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]);
/* If no previous entry was found initialise a new entry */
@@ -1665,8 +1656,8 @@ int dpkg_main(int argc, char **argv)
set_status(status_num, "reinstreq", 2);
}
}
}
else if (opt & REQ_package_name) {
} else if (opt & (OPT_configure | OPT_purge | OPT_remove)) {
/* -C/-p/-r: require package name */
deb_file[deb_count]->package = search_package_hashtable(
search_name_hashtable(argv[0]),
search_name_hashtable("ANY"), VER_ANY);
@@ -1685,8 +1676,7 @@ int dpkg_main(int argc, char **argv)
bb_error_msg_and_die("%s is already removed", name_hashtable[package_hashtable[package_num]->name]);
}
set_status(status_num, "deinstall", 1);
}
else if (opt & OPT_purge) {
} else if (opt & OPT_purge) {
/* if package status is "conf-files" then its ok */
if (strcmp(name_hashtable[state_status], "not-installed") == 0) {
bb_error_msg_and_die("%s is already purged", name_hashtable[package_hashtable[package_num]->name]);
@@ -1697,6 +1687,8 @@ int dpkg_main(int argc, char **argv)
deb_count++;
argv++;
}
if (!deb_count)
bb_error_msg_and_die("no package files specified");
deb_file[deb_count] = NULL;
/* Check that the deb file arguments are installable */
@@ -1748,9 +1740,7 @@ int dpkg_main(int argc, char **argv)
}
for (i = 0; i < PACKAGE_HASH_PRIME; i++) {
if (package_hashtable[i] != NULL) {
free_package(package_hashtable[i]);
}
free_package(package_hashtable[i]);
}
for (i = 0; i < STATUS_HASH_PRIME; i++) {
+11 -10
View File
@@ -4,7 +4,7 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "libbb.h"
#include "unarchive.h"
#define DPKG_DEB_OPT_CONTENTS 1
@@ -13,13 +13,14 @@
#define DPKG_DEB_OPT_EXTRACT 8
#define DPKG_DEB_OPT_EXTRACT_VERBOSE 16
int dpkg_deb_main(int argc, char **argv);
int dpkg_deb_main(int argc, char **argv)
{
archive_handle_t *ar_archive;
archive_handle_t *tar_archive;
llist_t *control_tar_llist = NULL;
unsigned opt;
char *extract_dir = NULL;
const char *extract_dir = NULL;
short argcount = 1;
/* Setup the tar archive handle */
@@ -30,18 +31,18 @@ int dpkg_deb_main(int argc, char **argv)
ar_archive->sub_archive = tar_archive;
ar_archive->filter = filter_accept_list_reassign;
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_archive->accept), "data.tar.gz");
llist_add_to(&control_tar_llist, "control.tar.gz");
#if ENABLE_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_archive->accept), (char*)"data.tar.gz");
llist_add_to(&control_tar_llist, (char*)"control.tar.gz");
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_archive->accept), "data.tar.bz2");
llist_add_to(&control_tar_llist, "control.tar.bz2");
#if ENABLE_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2");
llist_add_to(&control_tar_llist, (char*)"control.tar.bz2");
#endif
opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
opt = getopt32(argc, argv, "cefXx");
opt = getopt32(argv, "cefXx");
if (opt & DPKG_DEB_OPT_CONTENTS) {
tar_archive->action_header = header_verbose_list;
@@ -60,7 +61,7 @@ int dpkg_deb_main(int argc, char **argv)
* it should accept a second argument which specifies a
* specific field to print */
ar_archive->accept = control_tar_llist;
llist_add_to(&(tar_archive->accept), "./control");
llist_add_to(&(tar_archive->accept), (char*)"./control");
tar_archive->filter = filter_accept_list;
tar_archive->action_data = data_extract_to_stdout;
}
-162
View File
@@ -1,162 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Gzip implementation for busybox
*
* Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly.
*
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
* based on gzip sources
*
* Adjusted further by Erik Andersen <andersen@codepoet.org> to support files as
* well as stdin/stdout, and to generally behave itself wrt command line
* handling.
*
* General cleanup to better adhere to the style guide and make use of standard
* busybox functions by Glenn McGrath <bug1@iinet.net.au>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
* Copyright (C) 1992-1993 Jean-loup Gailly
* The unzip code was written and put in the public domain by Mark Adler.
* Portions of the lzw code are derived from the public domain 'compress'
* written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies,
* Ken Turkowski, Dave Mack and Peter Jannesen.
*
* See the license_msg below and the file COPYING for the software license.
* See the file algorithm.doc for the compression algorithms and file formats.
*/
#include "busybox.h"
#include "unarchive.h"
#define GUNZIP_OPT_STDOUT 1
#define GUNZIP_OPT_FORCE 2
#define GUNZIP_OPT_TEST 4
#define GUNZIP_OPT_DECOMPRESS 8
#define GUNZIP_OPT_VERBOSE 0x10
int gunzip_main(int argc, char **argv)
{
USE_DESKTOP(long long) int status;
int exitcode = 0;
unsigned opt;
opt = getopt32(argc, argv, "cftdv");
/* if called as zcat */
if (strcmp(applet_name, "zcat") == 0) {
opt |= GUNZIP_OPT_STDOUT;
}
do {
struct stat stat_buf;
char *old_path = argv[optind];
char *delete_path = NULL;
char *new_path = NULL;
int src_fd;
int dst_fd;
optind++;
if (old_path == NULL || LONE_DASH(old_path)) {
src_fd = STDIN_FILENO;
opt |= GUNZIP_OPT_STDOUT;
USE_DESKTOP(opt &= ~GUNZIP_OPT_VERBOSE;)
optind = argc; /* we don't handle "gunzip - a.gz b.gz" */
} else {
src_fd = xopen(old_path, O_RDONLY);
/* Get the time stamp on the input file. */
fstat(src_fd, &stat_buf);
}
/* Check that the input is sane. */
if (isatty(src_fd) && !(opt & GUNZIP_OPT_FORCE)) {
bb_error_msg_and_die
("compressed data not read from terminal, use -f to force it");
}
/* Set output filename and number */
if (opt & GUNZIP_OPT_TEST) {
dst_fd = xopen(bb_dev_null, O_WRONLY); /* why does test use filenum 2 ? */
} else if (opt & GUNZIP_OPT_STDOUT) {
dst_fd = STDOUT_FILENO;
} else {
char *extension;
new_path = xstrdup(old_path);
extension = strrchr(new_path, '.');
#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
if (extension && (strcmp(extension, ".Z") == 0)) {
*extension = '\0';
} else
#endif
if (extension && (strcmp(extension, ".gz") == 0)) {
*extension = '\0';
} else if (extension && (strcmp(extension, ".tgz") == 0)) {
extension[2] = 'a';
extension[3] = 'r';
} else {
// FIXME: should we die or just skip to next?
bb_error_msg_and_die("invalid extension");
}
/* Open output file (with correct permissions) */
dst_fd = xopen3(new_path, O_WRONLY | O_CREAT | O_TRUNC,
stat_buf.st_mode);
/* If unzip succeeds remove the old file */
delete_path = old_path;
}
status = -1;
/* do the decompression, and cleanup */
if (xread_char(src_fd) == 0x1f) {
unsigned char magic2;
magic2 = xread_char(src_fd);
if (ENABLE_FEATURE_GUNZIP_UNCOMPRESS && magic2 == 0x9d) {
status = uncompress(src_fd, dst_fd);
} else if (magic2 == 0x8b) {
check_header_gzip(src_fd); // FIXME: xfunc? _or_die?
status = inflate_gunzip(src_fd, dst_fd);
} else {
bb_error_msg("invalid magic");
exitcode = 1;
}
if (status < 0) {
bb_error_msg("error inflating");
exitcode = 1;
}
else if (ENABLE_DESKTOP && (opt & GUNZIP_OPT_VERBOSE)) {
fprintf(stderr, "%s: %u%% - replaced with %s\n",
old_path, (unsigned)(stat_buf.st_size*100 / (status+1)), new_path);
}
} else {
bb_error_msg("invalid magic");
exitcode = 1;
}
if (status < 0 && new_path) {
/* Unzip failed, remove new path instead of old path */
delete_path = new_path;
}
if (dst_fd != STDOUT_FILENO) {
close(dst_fd);
}
if (src_fd != STDIN_FILENO) {
close(src_fd);
}
/* delete_path will be NULL if in test mode or from stdin */
if (delete_path && (unlink(delete_path) == -1)) {
bb_error_msg("cannot remove %s", delete_path);
exitcode = 1;
}
free(new_path);
} while (optind < argc);
return exitcode;
}
+440 -579
View File
File diff suppressed because it is too large. Load diff
+31 -22
View File
@@ -26,7 +26,6 @@ lib-y:= \
\
data_align.o \
find_list_entry.o \
open_transformer.o \
init_handle.o
GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o
@@ -36,24 +35,34 @@ DPKG_FILES:= \
get_header_tar.o \
filter_accept_list_reassign.o
lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
lib-$(CONFIG_CPIO) += get_header_cpio.o
lib-$(CONFIG_DPKG) += $(DPKG_FILES)
lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
lib-$(CONFIG_TAR) += get_header_tar.o
lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
lib-$(CONFIG_RPM) += open_transformer.o
lib-$(CONFIG_FEATURE_TAR_BZIP2) += open_transformer.o
lib-$(CONFIG_FEATURE_TAR_LZMA) += open_transformer.o
lib-$(CONFIG_FEATURE_TAR_GZIP) += open_transformer.o
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += open_transformer.o
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += open_transformer.o
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += open_transformer.o
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += open_transformer.o
lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
lib-$(CONFIG_CPIO) += get_header_cpio.o
lib-$(CONFIG_DPKG) += $(DPKG_FILES)
lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
lib-$(CONFIG_FEATURE_RPM_BZ2) += decompress_bunzip2.o
lib-$(CONFIG_TAR) += get_header_tar.o
lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
@@ -3,8 +3,8 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "unarchive.h"
#include "libbb.h"
#include "unarchive.h"
ssize_t archive_xread_all_eof(archive_handle_t *archive_handle,
unsigned char *buf, size_t count)
+5 -8
View File
@@ -2,12 +2,11 @@
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h" /* for external decl of check_header_gzip */
void check_header_gzip(int src_fd)
#include "libbb.h"
#include "unarchive.h" /* for external decl of check_header_gzip_or_die */
void check_header_gzip_or_die(int src_fd)
{
union {
unsigned char raw[8];
@@ -30,7 +29,7 @@ void check_header_gzip(int src_fd)
if (header.formatted.flags & 0x04) {
/* bit 2 set: extra field present */
unsigned char extra_short;
unsigned extra_short;
extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8);
while (extra_short > 0) {
@@ -57,6 +56,4 @@ void check_header_gzip(int src_fd)
xread_char(src_fd);
xread_char(src_fd);
}
return;
}
+1 -6
View File
@@ -3,10 +3,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
//#include <sys/types.h>
#include "libbb.h"
#include "unarchive.h"
@@ -17,6 +14,4 @@ void data_align(archive_handle_t *archive_handle, const unsigned short boundary)
archive_handle->seek(archive_handle, skip_amount);
archive_handle->offset += skip_amount;
return;
}
+27 -15
View File
@@ -25,7 +25,8 @@ void data_extract_all(archive_handle_t *archive_handle)
&& (unlink(file_header->name) == -1)
&& (errno != ENOENT)
) {
bb_perror_msg_and_die("cannot remove old file");
bb_perror_msg_and_die("cannot remove old file %s",
file_header->name);
}
}
else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) {
@@ -52,13 +53,16 @@ void data_extract_all(archive_handle_t *archive_handle)
/* Handle hard links separately
* We identified hard links as regular files of size 0 with a symlink */
if (S_ISREG(file_header->mode) && (file_header->link_name)
if (S_ISREG(file_header->mode) && (file_header->link_target)
&& (file_header->size == 0)
) {
/* hard link */
res = link(file_header->link_name, file_header->name);
res = link(file_header->link_target, file_header->name);
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
bb_perror_msg("cannot create hard link");
bb_perror_msg("cannot create %slink "
"from %s to %s", "hard",
file_header->name,
file_header->link_target);
}
} else {
/* Create the filesystem entry */
@@ -73,22 +77,22 @@ void data_extract_all(archive_handle_t *archive_handle)
}
case S_IFDIR:
res = mkdir(file_header->name, file_header->mode);
if ((errno != EISDIR) && (res == -1)
if ((res == -1) && (errno != EISDIR)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("extract_archive: %s", file_header->name);
bb_perror_msg("cannot make dir %s", file_header->name);
}
break;
case S_IFLNK:
/* Symlink */
res = symlink(file_header->link_name, file_header->name);
res = symlink(file_header->link_target, file_header->name);
if ((res == -1)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("cannot create symlink "
"from %s to '%s'",
bb_perror_msg("cannot create %slink "
"from %s to %s", "sym",
file_header->name,
file_header->link_name);
file_header->link_target);
}
break;
case S_IFSOCK:
@@ -110,10 +114,18 @@ void data_extract_all(archive_handle_t *archive_handle)
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) {
lchown(file_header->name, file_header->uid, file_header->gid);
}
if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) {
struct utimbuf t;
t.actime = t.modtime = file_header->mtime;
utime(file_header->name, &t);
if ((file_header->mode & S_IFMT) != S_IFLNK) {
/* uclibc has no lchmod, glibc is even stranger -
* it has lchmod which seems to do nothing!
* so we use chmod... */
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_PERM)) {
chmod(file_header->name, file_header->mode);
}
/* same for utime */
if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) {
struct utimbuf t;
t.actime = t.modtime = file_header->mtime;
utime(file_header->name, &t);
}
}
}
@@ -3,6 +3,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
void data_extract_to_stdout(archive_handle_t *archive_handle)
+1 -5
View File
@@ -3,12 +3,8 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include "unarchive.h"
#include "libbb.h"
#include "unarchive.h"
void data_skip(archive_handle_t *archive_handle)
{
+245 -213
View File
@@ -55,81 +55,80 @@
/* This is what we know about each Huffman coding group */
struct group_data {
/* We have an extra slot at the end of limit[] for a sentinal value. */
int limit[MAX_HUFCODE_BITS+1],base[MAX_HUFCODE_BITS],permute[MAX_SYMBOLS];
int limit[MAX_HUFCODE_BITS+1], base[MAX_HUFCODE_BITS], permute[MAX_SYMBOLS];
int minLen, maxLen;
};
/* Structure holding all the housekeeping data, including IO buffers and
memory that persists between calls to bunzip */
typedef struct {
struct bunzip_data {
/* State for interrupting output loop */
int writeCopies,writePos,writeRunCountdown,writeCount,writeCurrent;
int writeCopies, writePos, writeRunCountdown, writeCount, writeCurrent;
/* I/O tracking data (file handles, buffers, positions, etc.) */
int in_fd,out_fd,inbufCount,inbufPos /*,outbufPos*/;
int in_fd, out_fd, inbufCount, inbufPos /*, outbufPos*/;
unsigned char *inbuf /*,*outbuf*/;
unsigned int inbufBitCount, inbufBits;
unsigned inbufBitCount, inbufBits;
/* The CRC values stored in the block header and calculated from the data */
uint32_t headerCRC, totalCRC, writeCRC;
uint32_t *crc32Table;
/* Intermediate buffer and its size (in bytes) */
unsigned int *dbuf, dbufSize;
/* These things are a bit too big to go on the stack */
unsigned char selectors[32768]; /* nSelectors=15 bits */
struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */
unsigned *dbuf, dbufSize;
/* For I/O error handling */
jmp_buf jmpbuf;
} bunzip_data;
/* Big things go last (register-relative addressing can be larger for big offsets */
uint32_t crc32Table[256];
unsigned char selectors[32768]; /* nSelectors=15 bits */
struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */
};
/* typedef struct bunzip_data bunzip_data; -- done in .h file */
/* Return the next nnn bits of input. All reads from the compressed input
are done through this function. All reads are big endian */
static unsigned int get_bits(bunzip_data *bd, char bits_wanted)
static unsigned get_bits(bunzip_data *bd, char bits_wanted)
{
unsigned int bits=0;
unsigned bits = 0;
/* If we need to get more data from the byte buffer, do so. (Loop getting
one byte at a time to enforce endianness and avoid unaligned access.) */
while (bd->inbufBitCount<bits_wanted) {
while (bd->inbufBitCount < bits_wanted) {
/* If we need to read more data from file into byte buffer, do so */
if(bd->inbufPos==bd->inbufCount) {
if((bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE)) <= 0)
longjmp(bd->jmpbuf,RETVAL_UNEXPECTED_INPUT_EOF);
bd->inbufPos=0;
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);
if (bd->inbufCount <= 0)
longjmp(bd->jmpbuf, RETVAL_UNEXPECTED_INPUT_EOF);
bd->inbufPos = 0;
}
/* 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;
bits<<=bits_wanted;
bd->inbufBitCount=0;
if (bd->inbufBitCount >= 24) {
bits = bd->inbufBits & ((1 << bd->inbufBitCount) - 1);
bits_wanted -= bd->inbufBitCount;
bits <<= bits_wanted;
bd->inbufBitCount = 0;
}
/* Grab next 8 bits of input from buffer. */
bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++];
bd->inbufBitCount+=8;
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);
bd->inbufBitCount -= bits_wanted;
bits |= (bd->inbufBits >> bd->inbufBitCount) & ((1 << bits_wanted) - 1);
return bits;
}
@@ -139,26 +138,26 @@ static unsigned int get_bits(bunzip_data *bd, char bits_wanted)
static int get_next_block(bunzip_data *bd)
{
struct group_data *hufGroup;
int dbufCount,nextSym,dbufSize,groupCount,*base,*limit,selector,
i,j,k,t,runPos,symCount,symTotal,nSelectors,byteCount[256];
int dbufCount, nextSym, dbufSize, groupCount, *base, *limit, selector,
i, j, k, t, runPos, symCount, symTotal, nSelectors, byteCount[256];
unsigned char uc, symToByte[256], mtfSymbol[256], *selectors;
unsigned int *dbuf,origPtr;
unsigned *dbuf, origPtr;
dbuf=bd->dbuf;
dbufSize=bd->dbufSize;
selectors=bd->selectors;
dbuf = bd->dbuf;
dbufSize = bd->dbufSize;
selectors = bd->selectors;
/* Reset longjmp I/O error handling */
i=setjmp(bd->jmpbuf);
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);
i = get_bits(bd, 24);
j = get_bits(bd, 24);
bd->headerCRC = get_bits(bd, 32);
if ((i == 0x177245) && (j == 0x385090)) return RETVAL_LAST_BLOCK;
if ((i != 0x314159) || (j != 0x265359)) return RETVAL_NOT_BZIP_DATA;
@@ -166,8 +165,9 @@ static int get_next_block(bunzip_data *bd)
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;
if ((origPtr=get_bits(bd,24)) > dbufSize) return RETVAL_DATA_ERROR;
if (get_bits(bd, 1)) return RETVAL_OBSOLETE_INPUT;
origPtr = get_bits(bd, 24);
if (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
@@ -175,48 +175,52 @@ static int get_next_block(bunzip_data *bd)
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++) {
if(t&(1<<(15-i))) {
k=get_bits(bd,16);
for (j=0;j<16;j++)
if(k&(1<<(15-j))) symToByte[symTotal++]=(16*i)+j;
t = get_bits(bd, 16);
symTotal = 0;
for (i = 0; i < 16; i++) {
if (t & (1 << (15-i))) {
k = get_bits(bd, 16);
for (j = 0; j < 16; j++)
if (k & (1 << (15-j)))
symToByte[symTotal++] = (16*i) + j;
}
}
/* 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;
groupCount = get_bits(bd, 3);
if (groupCount < 2 || groupCount > MAX_GROUPS)
return RETVAL_DATA_ERROR;
/* nSelectors: Every GROUP_SIZE many symbols we select a new Huffman coding
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.) */
if(!(nSelectors=get_bits(bd, 15))) return RETVAL_DATA_ERROR;
for (i=0; i<groupCount; i++) mtfSymbol[i] = i;
for (i=0; i<nSelectors; i++) {
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;
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;
mtfSymbol[0] = selectors[i] = uc;
}
/* 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];
int minLen, maxLen, pp;
symCount = symTotal + 2;
for (j = 0; j < groupCount; j++) {
unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1];
int minLen, maxLen, pp;
/* Read Huffman code lengths for each symbol. They're stored in
a way similar to mtf; record a starting value for the first symbol,
@@ -225,17 +229,17 @@ static int get_next_block(bunzip_data *bd)
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;
t = get_bits(bd, 5) - 1;
for (i = 0; i < symCount; i++) {
for (;;) {
if (((unsigned)t) > (MAX_HUFCODE_BITS-1))
if ((unsigned)t > (MAX_HUFCODE_BITS-1))
return RETVAL_DATA_ERROR;
/* 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);
k = get_bits(bd, 2);
if (k < 2) {
bd->inbufBitCount++;
break;
@@ -243,20 +247,20 @@ 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);
t += (((k+1) & 2) - 1);
}
/* Correct for the initial -1, to get the final symbol length */
length[i]=t+1;
length[i] = t + 1;
}
/* Find largest and smallest lengths in this group */
minLen=maxLen=length[0];
minLen = maxLen = length[0];
for (i = 1; i < symCount; i++) {
if(length[i] > maxLen) maxLen = length[i];
else if(length[i] < minLen) minLen = length[i];
if (length[i] > maxLen) maxLen = length[i];
else if (length[i] < minLen) minLen = length[i];
}
/* Calculate permute[], base[], and limit[] tables from length[].
@@ -270,7 +274,7 @@ static int get_next_block(bunzip_data *bd)
* length: each code with a value>limit[length] needs another bit.
*/
hufGroup=bd->groups+j;
hufGroup = bd->groups + j;
hufGroup->minLen = minLen;
hufGroup->maxLen = maxLen;
@@ -278,30 +282,31 @@ static int get_next_block(bunzip_data *bd)
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;
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;
for (t=0;t<symCount;t++)
if(length[t]==i) hufGroup->permute[pp++] = t;
pp = 0;
for (i = minLen; i <= maxLen; i++) {
temp[i] = limit[i] = 0;
for (t = 0; t < symCount; t++)
if (length[t] == i)
hufGroup->permute[pp++] = t;
}
/* Count symbols coded for at each bit length */
for (i=0;i<symCount;i++) temp[length[i]]++;
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];
pp = t = 0;
for (i = minLen; i < maxLen; i++) {
pp += temp[i];
/* We read the largest possible symbol size and then unget bits
after determining how many we need, and those extra bits could
@@ -310,13 +315,14 @@ static int get_next_block(bunzip_data *bd)
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;
base[i+1]=pp-(t+=temp[i]);
limit[i] = (pp << (maxLen - i)) - 1;
pp <<= 1;
t += temp[i];
base[i+1] = pp - t;
}
limit[maxLen+1] = INT_MAX; /* Sentinal value for reading next sym. */
limit[maxLen]=pp+temp[maxLen]-1;
base[minLen]=0;
limit[maxLen] = pp + temp[maxLen] - 1;
base[minLen] = 0;
}
/* We've finished reading and digesting the block header. Now read this
@@ -325,24 +331,24 @@ static int get_next_block(bunzip_data *bd)
/* Initialize symbol occurrence counters and symbol Move To Front table */
for (i=0;i<256;i++) {
for (i = 0; i < 256; i++) {
byteCount[i] = 0;
mtfSymbol[i]=(unsigned char)i;
mtfSymbol[i] = (unsigned char)i;
}
/* Loop through compressed symbols. */
runPos=dbufCount=selector=0;
runPos = dbufCount = selector = 0;
for (;;) {
/* fetch next Huffman coding group from list. */
symCount=GROUP_SIZE-1;
if(selector>=nSelectors) return RETVAL_DATA_ERROR;
hufGroup=bd->groups+selectors[selector++];
base=hufGroup->base-1;
limit=hufGroup->limit-1;
continue_this_group:
symCount = GROUP_SIZE - 1;
if (selector >= nSelectors) return RETVAL_DATA_ERROR;
hufGroup = bd->groups + selectors[selector++];
base = hufGroup->base - 1;
limit = hufGroup->limit - 1;
continue_this_group:
/* Read next Huffman-coded symbol. */
@@ -353,33 +359,34 @@ continue_this_group:
valid compressed file. As a further optimization, we do the read
inline (falling back to a call to get_bits if the buffer runs
dry). The following (up to got_huff_bits:) is equivalent to
j=get_bits(bd,hufGroup->maxLen);
j = get_bits(bd, hufGroup->maxLen);
*/
while (bd->inbufBitCount<hufGroup->maxLen) {
if(bd->inbufPos==bd->inbufCount) {
j = get_bits(bd,hufGroup->maxLen);
while (bd->inbufBitCount < hufGroup->maxLen) {
if (bd->inbufPos == bd->inbufCount) {
j = get_bits(bd, hufGroup->maxLen);
goto got_huff_bits;
}
bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++];
bd->inbufBitCount+=8;
bd->inbufBits = (bd->inbufBits << 8) | bd->inbuf[bd->inbufPos++];
bd->inbufBitCount += 8;
};
bd->inbufBitCount-=hufGroup->maxLen;
j = (bd->inbufBits>>bd->inbufBitCount)&((1<<hufGroup->maxLen)-1);
bd->inbufBitCount -= hufGroup->maxLen;
j = (bd->inbufBits >> bd->inbufBitCount) & ((1 << hufGroup->maxLen) - 1);
got_huff_bits:
got_huff_bits:
/* Figure how how many bits are in next symbol and unget extras */
i=hufGroup->minLen;
while (j>limit[i]) ++i;
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)
|| (((unsigned)(j=(j>>(hufGroup->maxLen-i))-base[i]))
>= MAX_SYMBOLS))
if (i > hufGroup->maxLen)
return RETVAL_DATA_ERROR;
j = (j >> (hufGroup->maxLen - i)) - base[i];
if ((unsigned)j >= MAX_SYMBOLS)
return RETVAL_DATA_ERROR;
nextSym = hufGroup->permute[j];
@@ -388,11 +395,11 @@ got_huff_bits:
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 ((unsigned)nextSym <= SYMBOL_RUNB) { /* RUNA or RUNB */
/* If this is the start of a new run, zero out counter */
if(!runPos) {
if (!runPos) {
runPos = 1;
t = 0;
}
@@ -406,7 +413,7 @@ got_huff_bits:
context). Thus space is saved. */
t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
if(runPos < dbufSize) runPos <<= 1;
if (runPos < dbufSize) runPos <<= 1;
goto end_of_huffman_loop;
}
@@ -415,18 +422,18 @@ got_huff_bits:
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;
if (runPos) {
runPos = 0;
if (dbufCount + t >= dbufSize) return RETVAL_DATA_ERROR;
uc = symToByte[mtfSymbol[0]];
byteCount[uc] += t;
while (t--) dbuf[dbufCount++]=uc;
while (t--) dbuf[dbufCount++] = uc;
}
/* Is this the terminating symbol? */
if(nextSym>symTotal) break;
if (nextSym > symTotal) break;
/* At this point, nextSym indicates a new literal character. Subtract
one to get the position in the MTF array at which this literal is
@@ -436,7 +443,7 @@ got_huff_bits:
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;
if (dbufCount >= dbufSize) return RETVAL_DATA_ERROR;
i = nextSym - 1;
uc = mtfSymbol[i];
@@ -449,22 +456,22 @@ got_huff_bits:
mtfSymbol[i] = mtfSymbol[i-1];
} while (--i);
mtfSymbol[0] = uc;
uc=symToByte[uc];
uc = symToByte[uc];
/* We have our literal byte. Save it into dbuf. */
byteCount[uc]++;
dbuf[dbufCount++] = (unsigned int)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;
end_of_huffman_loop:
if (symCount--) goto continue_this_group;
}
/* At this point, we've read all the Huffman-coded symbols (and repeated
runs) for this block from the input stream, and decoded them into the
runs) for this block from the input stream, and decoded them into the
intermediate buffer. There are dbufCount many decoded bytes in dbuf[].
Now undo the Burrows-Wheeler transform on dbuf.
See http://dogma.net/markn/articles/bwt/bwt.htm
@@ -472,17 +479,17 @@ end_of_huffman_loop:
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
j=0;
for (i=0;i<256;i++) {
k=j+byteCount[i];
j = 0;
for (i = 0; i < 256; i++) {
k = j + byteCount[i];
byteCount[i] = j;
j=k;
j = k;
}
/* Figure out what order dbuf would be in if we sorted it. */
for (i=0;i<dbufCount;i++) {
uc=(unsigned char)(dbuf[i] & 0xff);
for (i = 0; i < dbufCount; i++) {
uc = (unsigned char)(dbuf[i] & 0xff);
dbuf[byteCount[uc]] |= (i << 8);
byteCount[uc]++;
}
@@ -491,14 +498,14 @@ end_of_huffman_loop:
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;
bd->writePos=dbuf[origPtr];
bd->writeCurrent=(unsigned char)(bd->writePos&0xff);
bd->writePos>>=8;
bd->writeRunCountdown=5;
if (dbufCount) {
if (origPtr >= dbufCount) return RETVAL_DATA_ERROR;
bd->writePos = dbuf[origPtr];
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
bd->writePos >>= 8;
bd->writeRunCountdown = 5;
}
bd->writeCount=dbufCount;
bd->writeCount = dbufCount;
return RETVAL_OK;
}
@@ -510,18 +517,18 @@ end_of_huffman_loop:
are ignored, data is written to out_fd and return is RETVAL_OK or error.
*/
static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
int read_bunzip(bunzip_data *bd, char *outbuf, int len)
{
const unsigned int *dbuf;
int pos,current,previous,gotcount;
const unsigned *dbuf;
int pos, current, previous, gotcount;
/* If last read was short due to end of file, return last block now */
if(bd->writeCount<0) return bd->writeCount;
if (bd->writeCount < 0) return bd->writeCount;
gotcount = 0;
dbuf=bd->dbuf;
pos=bd->writePos;
current=bd->writeCurrent;
dbuf = bd->dbuf;
pos = bd->writePos;
current = bd->writeCurrent;
/* 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
@@ -539,9 +546,9 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
/* If the output buffer is full, snapshot state and return */
if(gotcount >= len) {
bd->writePos=pos;
bd->writeCurrent=current;
if (gotcount >= len) {
bd->writePos =pos;
bd->writeCurrent = current;
bd->writeCopies++;
return len;
}
@@ -549,8 +556,8 @@ static 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->writeCRC = (bd->writeCRC << 8)
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
/* Loop now if we're outputting multiple copies of this byte */
@@ -558,31 +565,32 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
--bd->writeCopies;
continue;
}
decode_next_byte:
decode_next_byte:
if (!bd->writeCount--) break;
/* Follow sequence vector to undo Burrows-Wheeler transform */
previous=current;
pos=dbuf[pos];
current=pos&0xff;
pos>>=8;
previous = current;
pos = dbuf[pos];
current = pos & 0xff;
pos >>= 8;
/* After 3 consecutive copies of the same byte, the 4th is a repeat
count. We count down from 4 instead
* of counting up because testing for non-zero is faster */
if(--bd->writeRunCountdown) {
if(current!=previous) bd->writeRunCountdown=4;
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;
bd->writeCopies = current;
current = previous;
bd->writeRunCountdown = 5;
/* Sometimes there are just 3 bytes (run length 0) */
if(!bd->writeCopies) goto decode_next_byte;
if (!bd->writeCopies) goto decode_next_byte;
/* Subtract the 1 copy we'd output anyway to get extras */
@@ -592,13 +600,13 @@ decode_next_byte:
/* Decompression of this block completed successfully */
bd->writeCRC=~bd->writeCRC;
bd->totalCRC=((bd->totalCRC<<1) | (bd->totalCRC>>31)) ^ bd->writeCRC;
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;
if (bd->writeCRC != bd->headerCRC) {
bd->totalCRC = bd->headerCRC+1;
return RETVAL_LAST_BLOCK;
}
}
@@ -606,86 +614,107 @@ decode_next_byte:
/* 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;
return (previous!=RETVAL_LAST_BLOCK) ? previous : gotcount;
previous = get_next_block(bd);
if (previous) {
bd->writeCount = previous;
return (previous != RETVAL_LAST_BLOCK) ? previous : gotcount;
}
bd->writeCRC=~0;
pos=bd->writePos;
current=bd->writeCurrent;
bd->writeCRC = ~0;
pos = bd->writePos;
current = bd->writeCurrent;
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. */
static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf,
/* 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)
{
bunzip_data *bd;
unsigned int i;
const unsigned int BZh0=(((unsigned int)'B')<<24)+(((unsigned int)'Z')<<16)
+(((unsigned int)'h')<<8)+(unsigned int)'0';
unsigned i;
enum {
BZh0 = ('B' << 24) + ('Z' << 16) + ('h' << 8) + '0'
};
/* Figure out how much data to allocate */
i=sizeof(bunzip_data);
if(in_fd!=-1) i+=IOBUF_SIZE;
i = sizeof(bunzip_data);
if (in_fd != -1) i += IOBUF_SIZE;
/* Allocate bunzip_data. Most fields initialize to zero. */
bd=*bdp=xzalloc(i);
bd = *bdp = xzalloc(i);
/* Setup input buffer */
if(-1==(bd->in_fd=in_fd)) {
bd->inbuf=inbuf;
bd->inbufCount=len;
} else bd->inbuf=(unsigned char *)(bd+1);
bd->in_fd = in_fd;
if (-1 == in_fd) {
/* in this case, bd->inbuf is read-only */
bd->inbuf = (void*)inbuf; /* cast away const-ness */
bd->inbufCount = len;
} else
bd->inbuf = (unsigned char *)(bd + 1);
/* Init the CRC32 table (big endian) */
bd->crc32Table = crc32_filltable(1);
crc32_filltable(bd->crc32Table, 1);
/* Setup for I/O error handling via longjmp */
i=setjmp(bd->jmpbuf);
if(i) return i;
i = setjmp(bd->jmpbuf);
if (i) return i;
/* Ensure that file starts with "BZh['1'-'9']." */
i = get_bits(bd,32);
if (((unsigned int)(i-BZh0-1)) >= 9) return RETVAL_NOT_BZIP_DATA;
i = get_bits(bd, 32);
if ((unsigned)(i - BZh0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA;
/* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
uncompressed data. Allocate intermediate buffer for block. */
bd->dbufSize=100000*(i-BZh0);
bd->dbufSize = 100000 * (i - BZh0);
bd->dbuf=xmalloc(bd->dbufSize * sizeof(int));
/* Cannot use xmalloc - may leak bd in NOFORK case! */
bd->dbuf = malloc_or_warn(bd->dbufSize * sizeof(int));
if (!bd->dbuf) {
free(bd);
xfunc_die();
}
return RETVAL_OK;
}
/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip data,
not end of file.) */
void dealloc_bunzip(bunzip_data *bd)
{
free(bd->dbuf);
free(bd);
}
/* Decompress src_fd to dst_fd. Stops at end of bzip data, not end of file. */
USE_DESKTOP(long long) int
uncompressStream(int src_fd, int dst_fd)
unpack_bz2_stream(int src_fd, int dst_fd)
{
USE_DESKTOP(long long total_written = 0;)
char *outbuf;
bunzip_data *bd;
int i;
outbuf=xmalloc(IOBUF_SIZE);
i=start_bunzip(&bd,src_fd,0,0);
if(!i) {
outbuf = xmalloc(IOBUF_SIZE);
i = start_bunzip(&bd, src_fd, NULL, 0);
if (!i) {
for (;;) {
if((i=read_bunzip(bd,outbuf,IOBUF_SIZE)) <= 0) break;
if(i!=write(dst_fd,outbuf,i)) {
i=RETVAL_UNEXPECTED_OUTPUT_EOF;
i = read_bunzip(bd, outbuf, IOBUF_SIZE);
if (i <= 0) break;
if (i != safe_write(dst_fd, outbuf, i)) {
i = RETVAL_UNEXPECTED_OUTPUT_EOF;
break;
}
USE_DESKTOP(total_written += i;)
@@ -694,19 +723,18 @@ uncompressStream(int src_fd, int dst_fd)
/* Check CRC and release memory */
if(i==RETVAL_LAST_BLOCK) {
if (bd->headerCRC!=bd->totalCRC) {
if (i == RETVAL_LAST_BLOCK) {
if (bd->headerCRC != bd->totalCRC) {
bb_error_msg("data integrity error when decompressing");
} else {
i=RETVAL_OK;
i = RETVAL_OK;
}
} else if (i==RETVAL_UNEXPECTED_OUTPUT_EOF) {
} else if (i == RETVAL_UNEXPECTED_OUTPUT_EOF) {
bb_error_msg("compressed file ends unexpectedly");
} else {
bb_error_msg("decompression failed");
}
free(bd->dbuf);
free(bd);
dealloc_bunzip(bd);
free(outbuf);
return i ? i : USE_DESKTOP(total_written) + 0;
@@ -714,18 +742,22 @@ uncompressStream(int src_fd, int dst_fd)
#ifdef TESTING
static char * const bunzip_errors[]={NULL,"Bad file checksum","Not bzip data",
"Unexpected input EOF","Unexpected output EOF","Data error",
"Out of memory","Obsolete (pre 0.9.5) bzip format not supported."};
static char *const bunzip_errors[] = {
NULL, "Bad file checksum", "Not bzip data",
"Unexpected input EOF", "Unexpected output EOF", "Data error",
"Out of memory", "Obsolete (pre 0.9.5) bzip format not supported"
};
/* Dumb little test thing, decompress stdin to stdout */
int main(int argc, char *argv[])
int main(int argc, char **argv)
{
int i=uncompressStream(0,1);
int i = unpack_bz2_stream(0, 1);
char c;
if(i<0) fprintf(stderr,"%s\n", bunzip_errors[-i]);
else if(read(0,&c,1)) fprintf(stderr,"Trailing garbage ignored\n");
if (i < 0)
fprintf(stderr,"%s\n", bunzip_errors[-i]);
else if (read(0, &c, 1))
fprintf(stderr,"Trailing garbage ignored\n");
return -i;
}
#endif
+54 -57
View File
@@ -7,7 +7,6 @@
* (see disclaimer below)
*/
/* (N)compress42.c - File compression ala IEEE Computer, Mar 1992.
*
* Authors:
@@ -26,9 +25,6 @@
* [... History snipped ...]
*
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
/* Default input buffer size */
#define IBUFSIZ 2048
@@ -37,72 +33,67 @@
#define OBUFSIZ 2048
/* Defines for third byte of header */
#define MAGIC_1 (char_type)'\037' /* First byte of compressed file */
#define MAGIC_2 (char_type)'\235' /* Second byte of compressed file */
#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */
/* Masks 0x20 and 0x40 are free. */
/* I think 0x20 should mean that there is */
/* a fourth header byte (for expansion). */
#define BLOCK_MODE 0x80 /* Block compresssion if table is full and */
/* compression rate is dropping flush tables */
/* the next two codes should not be changed lightly, as they must not */
/* lie within the contiguous general code space. */
#define FIRST 257 /* first free entry */
#define CLEAR 256 /* table clear output code */
#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */
/* Masks 0x20 and 0x40 are free. */
/* I think 0x20 should mean that there is */
/* a fourth header byte (for expansion). */
#define BLOCK_MODE 0x80 /* Block compression if table is full and */
/* compression rate is dropping flush tables */
/* the next two codes should not be changed lightly, as they must not */
/* lie within the contiguous general code space. */
#define FIRST 257 /* first free entry */
#define CLEAR 256 /* table clear output code */
#define INIT_BITS 9 /* initial number of bits/code */
#define INIT_BITS 9 /* initial number of bits/code */
/* machine variants which require cc -Dmachine: pdp11, z8000, DOS */
#define FAST
#define HBITS 17 /* 50% occupancy */
#define HSIZE (1<<HBITS)
#define HMASK (HSIZE-1)
#define HPRIME 9941
#define BITS 16
#undef MAXSEG_64K
#define MAXCODE(n) (1L << (n))
#define htabof(i) htab[i]
#define codetabof(i) codetab[i]
#define tab_prefixof(i) codetabof(i)
#define tab_suffixof(i) ((unsigned char *)(htab))[i]
#define de_stack ((unsigned char *)&(htab[HSIZE-1]))
#define clear_htab() memset(htab, -1, HSIZE)
#define clear_tab_prefixof() memset(codetab, 0, 256);
#define HBITS 17 /* 50% occupancy */
#define HSIZE (1<<HBITS)
#define HMASK (HSIZE-1) /* unused */
#define HPRIME 9941 /* unused */
#define BITS 16
#define BITS_STR "16"
#undef MAXSEG_64K /* unused */
#define MAXCODE(n) (1L << (n))
#define htabof(i) htab[i]
#define codetabof(i) codetab[i]
#define tab_prefixof(i) codetabof(i)
#define tab_suffixof(i) ((unsigned char *)(htab))[i]
#define de_stack ((unsigned char *)&(htab[HSIZE-1]))
#define clear_tab_prefixof() memset(codetab, 0, 256)
/*
* Decompress stdin to stdout. This routine adapts to the codes in the
* file building the "string" table on-the-fly; requiring no table to
* be stored in the compressed file. The tables used herein are shared
* with those of the compress() routine. See the definitions above.
* be stored in the compressed file.
*/
USE_DESKTOP(long long) int
uncompress(int fd_in, int fd_out)
{
USE_DESKTOP(long long total_written = 0;)
USE_DESKTOP(long long) int retval = -1;
unsigned char *stackp;
long int code;
long code;
int finchar;
long int oldcode;
long int incode;
long oldcode;
long incode;
int inbits;
int posbits;
int outpos;
int insize;
int bitmask;
long int free_ent;
long int maxcode;
long int maxmaxcode;
long free_ent;
long maxcode;
long maxmaxcode;
int n_bits;
int rsize = 0;
RESERVE_CONFIG_UBUFFER(inbuf, IBUFSIZ + 64);
RESERVE_CONFIG_UBUFFER(outbuf, OBUFSIZ + 2048);
unsigned char htab[HSIZE];
unsigned short codetab[HSIZE];
unsigned char *inbuf; /* were eating insane amounts of stack - */
unsigned char *outbuf; /* bad for some embedded targets */
unsigned char *htab;
unsigned short *codetab;
/* Hmm, these were statics - why?! */
/* user settable max # bits/code */
@@ -110,8 +101,10 @@ uncompress(int fd_in, int fd_out)
/* block compress mode -C compatible with 2.0 */
int block_mode; /* = BLOCK_MODE; */
memset(inbuf, 0, IBUFSIZ + 64);
memset(outbuf, 0, OBUFSIZ + 2048);
inbuf = xzalloc(IBUFSIZ + 64);
outbuf = xzalloc(OBUFSIZ + 2048);
htab = xzalloc(HSIZE); /* wsn't zeroed out before, maybe can xmalloc? */
codetab = xzalloc(HSIZE * sizeof(codetab[0]));
insize = 0;
@@ -119,7 +112,7 @@ uncompress(int fd_in, int fd_out)
* to do some cleanup (e.g. delete incomplete unpacked file etc) */
if (full_read(fd_in, inbuf, 1) != 1) {
bb_error_msg("short read");
return -1;
goto err;
}
maxbits = inbuf[0] & BIT_MASK;
@@ -128,8 +121,8 @@ uncompress(int fd_in, int fd_out)
if (maxbits > BITS) {
bb_error_msg("compressed with %d bits, can only handle "
"%d bits", maxbits, BITS);
return -1;
BITS_STR" bits", maxbits);
goto err;
}
n_bits = INIT_BITS;
@@ -143,7 +136,7 @@ uncompress(int fd_in, int fd_out)
free_ent = ((block_mode) ? FIRST : 256);
/* As above, initialize the first 256 entries in the table. */
clear_tab_prefixof();
/*clear_tab_prefixof(); - done by xzalloc */
for (code = 255; code >= 0; --code) {
tab_suffixof(code) = (unsigned char) code;
@@ -235,7 +228,7 @@ uncompress(int fd_in, int fd_out)
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
(posbits & 07));
bb_error_msg("uncompress: corrupt input");
return -1;
goto err;
}
*--stackp = (unsigned char) finchar;
@@ -243,7 +236,7 @@ uncompress(int fd_in, int fd_out)
}
/* Generate output characters in reverse order */
while ((long int) code >= (long int) 256) {
while ((long) code >= (long) 256) {
*--stackp = tab_suffixof(code);
code = tab_prefixof(code);
}
@@ -302,7 +295,11 @@ uncompress(int fd_in, int fd_out)
USE_DESKTOP(total_written += outpos;)
}
RELEASE_CONFIG_BUFFER(inbuf);
RELEASE_CONFIG_BUFFER(outbuf);
return USE_DESKTOP(total_written) + 0;
retval = USE_DESKTOP(total_written) + 0;
err:
free(inbuf);
free(outbuf);
free(htab);
free(codetab);
return retval;
}
+11 -9
View File
@@ -12,8 +12,8 @@
#include "libbb.h"
#include "unarchive.h"
#ifdef CONFIG_FEATURE_LZMA_FAST
# define speed_inline ATTRIBUTE_ALWAYS_INLINE
#if ENABLE_FEATURE_LZMA_FAST
# define speed_inline ALWAYS_INLINE
#else
# define speed_inline
#endif
@@ -78,7 +78,7 @@ static rc_t* rc_init(int fd) /*, int buffer_size) */
}
/* Called once */
static ATTRIBUTE_ALWAYS_INLINE void rc_free(rc_t * rc)
static ALWAYS_INLINE void rc_free(rc_t * rc)
{
if (ENABLE_FEATURE_CLEAN_UP)
free(rc);
@@ -92,16 +92,18 @@ static void rc_do_normalize(rc_t * rc)
rc->range <<= 8;
rc->code = (rc->code << 8) | *rc->ptr++;
}
static ATTRIBUTE_ALWAYS_INLINE void rc_normalize(rc_t * rc)
static ALWAYS_INLINE void rc_normalize(rc_t * rc)
{
if (rc->range < (1 << RC_TOP_BITS)) {
rc_do_normalize(rc);
}
}
/* Called 9 times */
/* rc_is_bit_0 is called 9 times */
/* Why rc_is_bit_0_helper exists?
* Because we want to always expose (rc->code < rc->bound) to optimizer
* Because we want to always expose (rc->code < rc->bound) to optimizer.
* Thus rc_is_bit_0 is always inlined, and rc_is_bit_0_helper is inlined
* only if we compile for speed.
*/
static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
{
@@ -109,7 +111,7 @@ static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
return rc->bound;
}
static ATTRIBUTE_ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
static ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
{
uint32_t t = rc_is_bit_0_helper(rc, p);
return rc->code < t;
@@ -143,7 +145,7 @@ static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
}
/* Called once */
static ATTRIBUTE_ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
static ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
{
rc_normalize(rc);
rc->range >>= 1;
@@ -228,7 +230,7 @@ enum {
USE_DESKTOP(long long) int
unlzma(int src_fd, int dst_fd)
unpack_lzma_stream(int src_fd, int dst_fd)
{
USE_DESKTOP(long long total_written = 0;)
lzma_header_t header;
+11 -9
View File
@@ -182,39 +182,39 @@ static state_t* alloc_state(void)
#endif
static const unsigned short mask_bits[] = {
static const unsigned short mask_bits[] ALIGN2 = {
0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};
/* Copy lengths for literal codes 257..285 */
static const unsigned short cplens[] = {
static const unsigned short cplens[] ALIGN2 = {
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59,
67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
};
/* note: see note #13 above about the 258 in this list. */
/* Extra bits for literal codes 257..285 */
static const unsigned char cplext[] = {
static const unsigned char cplext[] ALIGN1 = {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5,
5, 5, 5, 0, 99, 99
}; /* 99 == invalid */
/* Copy offsets for distance codes 0..29 */
static const unsigned short cpdist[] = {
static const unsigned short cpdist[] ALIGN2 = {
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513,
769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577
};
/* Extra bits for distance codes */
static const unsigned char cpdext[] = {
static const unsigned char cpdext[] ALIGN1 = {
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
11, 11, 12, 12, 13, 13
};
/* Tables for deflate from PKZIP's appnote.txt. */
/* Order of the bit length code lengths */
static const unsigned char border[] = {
static const unsigned char border[] ALIGN1 = {
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
};
@@ -455,6 +455,8 @@ static int huft_build(unsigned *b, const unsigned n,
* bl, bd: number of bits decoded by tl[] and td[]
*/
/* called once from inflate_block */
/* map formerly local static variables to globals */
#define ml inflate_codes_ml
#define md inflate_codes_md
#define bb inflate_codes_bb
@@ -979,7 +981,7 @@ static int inflate_get_next_window(STATE_PARAM_ONLY)
}
/* Called from inflate_gunzip() and inflate_unzip() */
/* Called from unpack_gz_stream() and inflate_unzip() */
/* NB: bytebuffer is allocated here but freeing it is left to the caller! */
static USE_DESKTOP(long long) int
inflate_unzip_internal(STATE_PARAM int in, int out)
@@ -998,7 +1000,7 @@ inflate_unzip_internal(STATE_PARAM int in, int out)
gunzip_bb = 0;
/* Create the crc table */
gunzip_crc_table = crc32_filltable(0);
gunzip_crc_table = crc32_filltable(NULL, 0);
gunzip_crc = ~0;
/* Allocate space for buffer */
@@ -1054,7 +1056,7 @@ inflate_unzip(inflate_unzip_result *res, unsigned bufsize, int in, int out)
USE_DESKTOP(long long) int
inflate_gunzip(int in, int out)
unpack_gz_stream(int in, int out)
{
uint32_t stored_crc = 0;
unsigned count;
+1 -1
View File
@@ -5,7 +5,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
/* Accept any non-null name, its not really a filter at all */
+1 -1
View File
@@ -5,7 +5,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
/*
@@ -23,13 +23,13 @@ char filter_accept_list_reassign(archive_handle_t *archive_handle)
name_ptr = strrchr(archive_handle->file_header->name, '.');
/* Modify the subarchive handler based on the extension */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
#if ENABLE_FEATURE_DEB_TAR_GZ
if (strcmp(name_ptr, ".gz") == 0) {
archive_handle->action_data_subarchive = get_header_tar_gz;
return EXIT_SUCCESS;
}
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
#if ENABLE_FEATURE_DEB_TAR_BZ2
if (strcmp(name_ptr, ".bz2") == 0) {
archive_handle->action_data_subarchive = get_header_tar_bz2;
return EXIT_SUCCESS;
@@ -5,7 +5,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
/*
+1 -1
View File
@@ -6,7 +6,7 @@
*/
#include <fnmatch.h>
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
/* Find a string in a shell pattern list */
+16 -12
View File
@@ -23,9 +23,9 @@ char get_header_ar(archive_handle_t *archive_handle)
char magic[2];
} formatted;
} ar;
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
#if ENABLE_FEATURE_AR_LONG_FILENAMES
static char *ar_long_names;
static unsigned int ar_long_name_size;
static unsigned ar_long_name_size;
#endif
/* dont use xread as we want to handle the error ourself */
@@ -66,7 +66,9 @@ char get_header_ar(archive_handle_t *archive_handle)
/* long filenames have '/' as the first character */
if (ar.formatted.name[0] == '/') {
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
#if ENABLE_FEATURE_AR_LONG_FILENAMES
unsigned long_offset;
if (ar.formatted.name[1] == '/') {
/* If the second char is a '/' then this entries data section
* stores long filename for multiple entries, they are stored
@@ -78,20 +80,22 @@ char get_header_ar(archive_handle_t *archive_handle)
/* This ar entries data section only contained filenames for other records
* they are stored in the static ar_long_names for future reference */
return get_header_ar(archive_handle); /* Return next header */
} else if (ar.formatted.name[1] == ' ') {
}
if (ar.formatted.name[1] == ' ') {
/* This is the index of symbols in the file for compilers */
data_skip(archive_handle);
archive_handle->offset += typed->size;
return get_header_ar(archive_handle); /* Return next header */
} else {
/* The number after the '/' indicates the offset in the ar data section
(saved in variable long_name) that conatains the real filename */
const unsigned int long_offset = atoi(&ar.formatted.name[1]);
if (long_offset >= ar_long_name_size) {
bb_error_msg_and_die("can't resolve long filename");
}
typed->name = xstrdup(ar_long_names + long_offset);
}
/* The number after the '/' indicates the offset in the ar data section
* (saved in variable long_name) that conatains the real filename */
long_offset = atoi(&ar.formatted.name[1]);
if (long_offset >= ar_long_name_size) {
bb_error_msg_and_die("can't resolve long filename");
}
typed->name = xstrdup(ar_long_names + long_offset);
#else
bb_error_msg_and_die("long filenames not supported");
#endif
+8 -7
View File
@@ -16,8 +16,9 @@ typedef struct hardlinks_s {
char get_header_cpio(archive_handle_t *archive_handle)
{
static hardlinks_t *saved_hardlinks = NULL;
static unsigned short pending_hardlinks = 0;
static unsigned pending_hardlinks = 0;
static int inode;
file_header_t *file_header = archive_handle->file_header;
char cpio_header[110];
int namesize;
@@ -30,7 +31,7 @@ char get_header_cpio(archive_handle_t *archive_handle)
tmp = saved_hardlinks;
oldtmp = NULL;
file_header->link_name = file_header->name;
file_header->link_target = file_header->name;
file_header->size = 0;
while (tmp) {
@@ -56,7 +57,7 @@ char get_header_cpio(archive_handle_t *archive_handle)
saved_hardlinks = tmp;
}
file_header->name = file_header->link_name;
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?");
@@ -122,12 +123,12 @@ char get_header_cpio(archive_handle_t *archive_handle)
}
if (S_ISLNK(file_header->mode)) {
file_header->link_name = xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, file_header->link_name, file_header->size);
file_header->link_target = xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, file_header->link_target, file_header->size);
archive_handle->offset += file_header->size;
file_header->size = 0; /* Stop possible seeks in future */
} else {
file_header->link_name = NULL;
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 */
@@ -154,7 +155,7 @@ char get_header_cpio(archive_handle_t *archive_handle)
archive_handle->offset += file_header->size;
free(file_header->link_name);
free(file_header->link_target);
return EXIT_SUCCESS;
}
+43 -17
View File
@@ -36,7 +36,7 @@ static unsigned long long getOctal(char *str, int len)
*/
str[len] = '\0';
v = strtoull(str, &str, 8);
if (*str)
if (*str && (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY || *str != ' '))
bb_error_msg_and_die("corrupted octal value in tar header");
return v;
}
@@ -45,7 +45,7 @@ static unsigned long long getOctal(char *str, int len)
void BUG_tar_header_size(void);
char get_header_tar(archive_handle_t *archive_handle)
{
static int end;
static smallint end;
file_header_t *file_header = archive_handle->file_header;
struct {
@@ -69,7 +69,10 @@ char get_header_tar(archive_handle_t *archive_handle)
char padding[12]; /* 500-512 */
} tar;
char *cp;
int sum, i;
int i, sum_u, sum;
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
int sum_s;
#endif
int parse_names;
if (sizeof(tar) != 512)
@@ -110,18 +113,41 @@ char get_header_tar(archive_handle_t *archive_handle)
#endif
bb_error_msg_and_die("invalid tar magic");
}
/* Do checksum on headers */
sum = ' ' * sizeof(tar.chksum);
for (i = 0; i < 148 ; i++) {
sum += ((char*)&tar)[i];
/* Do checksum on headers.
* POSIX says that checksum is done on unsigned bytes, but
* Sun and HP-UX gets it wrong... more details in
* GNU tar source. */
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
sum_s = ' ' * sizeof(tar.chksum);
#endif
sum_u = ' ' * sizeof(tar.chksum);
for (i = 0; i < 148; i++) {
sum_u += ((unsigned char*)&tar)[i];
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
sum_s += ((signed char*)&tar)[i];
#endif
}
for (i = 156; i < 512 ; i++) {
sum += ((char*)&tar)[i];
for (i = 156; i < 512; i++) {
sum_u += ((unsigned char*)&tar)[i];
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
sum_s += ((signed char*)&tar)[i];
#endif
}
/* This field does not need special treatment (getOctal) */
if (sum != xstrtoul(tar.chksum, 8)) {
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
sum = strtoul(tar.chksum, &cp, 8);
if ((*cp && *cp != ' ')
|| (sum_u != sum USE_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum))
) {
bb_error_msg_and_die("invalid tar header checksum");
}
#else
/* This field does not need special treatment (getOctal) */
sum = xstrtoul(tar.chksum, 8);
if (sum_u != sum USE_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum)) {
bb_error_msg_and_die("invalid tar header checksum");
}
#endif
/* 0 is reserved for high perf file, treat as normal file */
if (!tar.typeflag) tar.typeflag = '0';
@@ -134,13 +160,13 @@ char get_header_tar(archive_handle_t *archive_handle)
unsigned major = GET_OCTAL(tar.devmajor);
file_header->device = makedev(major, minor);
}
file_header->link_name = NULL;
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_name = xstrdup(tar.linkname);
/* FIXME: what if we have non-link object with link_name? */
/* Will link_name be free()ed? */
file_header->link_target = xstrdup(tar.linkname);
/* FIXME: what if we have non-link object with link_target? */
/* Will link_target be free()ed? */
}
file_header->mtime = GET_OCTAL(tar.mtime);
file_header->size = GET_OCTAL(tar.size);
@@ -241,7 +267,7 @@ char get_header_tar(archive_handle_t *archive_handle)
longname = NULL;
}
if (linkname) {
file_header->link_name = linkname;
file_header->link_target = linkname;
linkname = NULL;
}
#endif
@@ -270,7 +296,7 @@ char get_header_tar(archive_handle_t *archive_handle)
}
archive_handle->offset += file_header->size;
free(file_header->link_name);
free(file_header->link_target);
/* Do not free(file_header->name)! */
return EXIT_SUCCESS;
+1 -1
View File
@@ -11,7 +11,7 @@ char get_header_tar_bz2(archive_handle_t *archive_handle)
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompressStream);
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2", "bunzip2", "-cf", "-", NULL);
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
+9 -4
View File
@@ -3,26 +3,31 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
char get_header_tar_gz(archive_handle_t *archive_handle)
{
#if BB_MMU
unsigned char magic[2];
#endif
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
/* Check gzip magic only if open_transformer will invoke unpack_gz_stream (MMU case).
* Otherwise, it will invoke an external helper "gunzip -cf" (NOMMU case) which will
* need the header. */
#if BB_MMU
xread(archive_handle->src_fd, &magic, 2);
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
bb_error_msg_and_die("invalid gzip magic");
}
check_header_gzip(archive_handle->src_fd);
check_header_gzip_or_die(archive_handle->src_fd);
#endif
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip", "gunzip", "-cf", "-", NULL);
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
+2 -1
View File
@@ -6,6 +6,7 @@
* Licensed under GPL v2, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
char get_header_tar_lzma(archive_handle_t * archive_handle)
@@ -13,7 +14,7 @@ char get_header_tar_lzma(archive_handle_t * archive_handle)
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unlzma);
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma", "unlzma", "-cf", "-", NULL);
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
+1 -1
View File
@@ -2,7 +2,7 @@
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include "libbb.h"
#include "unarchive.h"
void header_list(const file_header_t *file_header)
+1 -1
View File
@@ -2,7 +2,7 @@
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include "libbb.h"
#include "unarchive.h"
void header_skip(const file_header_t *file_header ATTRIBUTE_UNUSED)
+2 -2
View File
@@ -23,8 +23,8 @@ void header_verbose_list(const file_header_t *file_header)
mtime->tm_sec,
file_header->name);
if (file_header->link_name) {
printf(" -> %s", file_header->link_name);
if (file_header->link_target) {
printf(" -> %s", file_header->link_target);
}
/* putchar isnt used anywhere else i dont think */
puts("");
+27 -12
View File
@@ -3,37 +3,52 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h"
/* transformer(), more than meets the eye */
/*
* On MMU machine, the transform_prog and ... are stripped
* by a macro in include/unarchive.h. On NOMMU, transformer is stripped.
*/
int open_transformer(int src_fd,
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd))
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd),
const char *transform_prog, ...)
{
int fd_pipe[2];
int pid;
if (pipe(fd_pipe) != 0) {
bb_perror_msg_and_die("can't create pipe");
}
xpipe(fd_pipe);
#if BB_MMU
pid = fork();
if (pid == -1) {
#else
pid = vfork();
#endif
if (pid == -1)
bb_perror_msg_and_die("fork failed");
}
if (pid == 0) {
#if !BB_MMU
va_list ap;
#endif
/* child process */
close(fd_pipe[0]); /* We don't wan't to read from the parent */
// FIXME: error check?
#if BB_MMU
transformer(src_fd, fd_pipe[1]);
close(fd_pipe[1]); /* Send EOF */
close(src_fd);
if (ENABLE_FEATURE_CLEAN_UP) {
close(fd_pipe[1]); /* Send EOF */
close(src_fd);
}
exit(0);
#else
xmove_fd(src_fd, 0);
xmove_fd(fd_pipe[1], 1);
va_start(ap, transform_prog);
BB_EXECVP(transform_prog, ap);
bb_perror_and_die("exec failed");
#endif
/* notreached */
}
+1 -6
View File
@@ -3,18 +3,13 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <sys/types.h>
#include <errno.h>
#include <unistd.h>
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount)
{
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
#ifdef CONFIG_FEATURE_UNARCHIVE_TAPE
#if ENABLE_FEATURE_UNARCHIVE_TAPE
if (errno == ESPIPE) {
seek_by_read(archive_handle, amount);
} else
+1 -3
View File
@@ -3,10 +3,8 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include "unarchive.h"
#include "libbb.h"
#include "unarchive.h"
/* If we are reading through a pipe(), or from stdin then we can't lseek,
* we must read and discard the data to skip over it.
+2 -4
View File
@@ -2,11 +2,9 @@
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include "unarchive.h"
#include "libbb.h"
#include "unarchive.h"
void unpack_ar_archive(archive_handle_t *ar_archive)
{
+41 -8
View File
@@ -7,7 +7,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "libbb.h"
#include "unarchive.h"
#define RPM_HEADER_MAGIC "\216\255\350"
@@ -80,6 +80,7 @@ static void fileaction_dobackup(char *filename, int fileref);
static void fileaction_setowngrp(char *filename, int fileref);
static void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref));
int rpm_main(int argc, char **argv);
int rpm_main(int argc, char **argv)
{
int opt = 0, func = 0, rpm_fd, offset;
@@ -184,11 +185,19 @@ int rpm_main(int argc, char **argv)
return 0;
}
static void extract_cpio_gz(int fd) {
static void extract_cpio_gz(int fd)
{
archive_handle_t *archive_handle;
unsigned char magic[2];
#if BB_MMU
USE_DESKTOP(long long) int (*xformer)(int src_fd, int dst_fd);
enum { xformer_prog = 0 };
#else
enum { xformer = 0 };
const char *xformer_prog;
#endif
/* Initialise */
/* Initialize */
archive_handle = init_handle();
archive_handle->seek = seek_by_read;
//archive_handle->action_header = header_list;
@@ -199,16 +208,40 @@ static void extract_cpio_gz(int fd) {
archive_handle->offset = 0;
xread(archive_handle->src_fd, &magic, 2);
#if BB_MMU
xformer = unpack_gz_stream;
#else
xformer_prog = "gunzip";
#endif
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
bb_error_msg_and_die("invalid gzip magic");
if (ENABLE_FEATURE_RPM_BZ2
&& (magic[0] == 0x42) && (magic[1] == 0x5a)) {
#if BB_MMU
xformer = unpack_bz2_stream;
#else
xformer_prog = "bunzip2";
#endif
/* We can do better, need modifying unpack_bz2_stream to not require
* first 2 bytes. Not very hard to do... I mean, TODO :) */
xlseek(archive_handle->src_fd, -2, SEEK_CUR);
} else
bb_error_msg_and_die("no gzip"
USE_FEATURE_RPM_BZ2("/bzip")
" magic");
} else {
check_header_gzip_or_die(archive_handle->src_fd);
#if !BB_MMU
/* NOMMU version of open_transformer execs an external unzipper that should
* have the file position at the start of the file */
xlseek(archive_handle->src_fd, 0, SEEK_SET);
#endif
}
check_header_gzip(archive_handle->src_fd);
xchdir("/"); /* Install RPM's to root */
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
xchdir("/"); /* Install RPM's to root */
archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog, xformer_prog, "-cf", "-", NULL);
archive_handle->offset = 0;
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
/* loop */;
continue;
}
+4 -3
View File
@@ -6,7 +6,7 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "libbb.h"
#include "unarchive.h"
#define RPM_MAGIC "\355\253\356\333"
@@ -49,6 +49,7 @@ static void skip_header(int rpm_fd)
}
/* No getopt required */
int rpm2cpio_main(int argc, char **argv);
int rpm2cpio_main(int argc, char **argv)
{
struct rpm_lead lead;
@@ -78,8 +79,8 @@ int rpm2cpio_main(int argc, char **argv)
bb_error_msg_and_die("invalid gzip magic");
}
check_header_gzip(rpm_fd);
if (inflate_gunzip(rpm_fd, STDOUT_FILENO) < 0) {
check_header_gzip_or_die(rpm_fd);
if (unpack_gz_stream(rpm_fd, STDOUT_FILENO) < 0) {
bb_error_msg("error inflating");
}
+51 -48
View File
@@ -25,9 +25,11 @@
#include <fnmatch.h>
#include <getopt.h>
#include "busybox.h"
#include "libbb.h"
#include "unarchive.h"
#define block_buf bb_common_bufsiz1
#if ENABLE_FEATURE_TAR_CREATE
/* Tar file constants */
@@ -134,7 +136,6 @@ static void freeHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr)
}
*hlInfoHeadPtr = NULL;
}
return;
}
/* Might be faster (and bigger) if the dev/ino were stored in numeric order;) */
@@ -173,6 +174,9 @@ static void putOctal(char *cp, int len, off_t value)
static void chksum_and_xwrite(int fd, struct TarHeader* hp)
{
/* POSIX says that checksum is done on unsigned bytes
* (Sun and HP-UX gets it wrong... more details in
* GNU tar source) */
const unsigned char *cp;
int chksum, size;
@@ -273,8 +277,8 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
tbInfo->hlInfo->name, 0);
#endif
} else if (S_ISLNK(statbuf->st_mode)) {
char *lpath = xreadlink(fileName);
if (!lpath) /* Already printed err msg inside xreadlink() */
char *lpath = xmalloc_readlink_or_warn(fileName);
if (!lpath)
return FALSE;
header.typeflag = SYMTYPE;
strncpy(header.linkname, lpath, sizeof(header.linkname));
@@ -413,11 +417,11 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
header_name = fileName;
while (header_name[0] == '/') {
static int alreadyWarned = FALSE;
static smallint warned;
if (alreadyWarned == FALSE) {
if (!warned) {
bb_error_msg("removing leading '/' from member names");
alreadyWarned = TRUE;
warned = 1;
}
header_name++;
}
@@ -438,9 +442,8 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
/* Is this a regular file? */
if (tbInfo->hlInfo == NULL && S_ISREG(statbuf->st_mode)) {
/* open the file we want to archive, and make sure all is well */
inputFileFd = open(fileName, O_RDONLY);
inputFileFd = open_or_warn(fileName, O_RDONLY);
if (inputFileFd < 0) {
bb_perror_msg("%s: cannot open", fileName);
return FALSE;
}
}
@@ -453,7 +456,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
/* If it was a regular file, write out the body */
if (inputFileFd >= 0) {
size_t readSize;
/* Wwrite the file to the archive. */
/* Write the file to the archive. */
/* We record size into header first, */
/* and then write out file. If file shrinks in between, */
/* tar will be corrupted. So we don't allow for that. */
@@ -474,8 +477,8 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
/* Pad the file up to the tar block size */
/* (a few tricks here in the name of code size) */
readSize = (-(int)statbuf->st_size) & (TAR_BLOCK_SIZE-1);
memset(bb_common_bufsiz1, 0, readSize);
xwrite(tbInfo->tarFd, bb_common_bufsiz1, readSize);
memset(block_buf, 0, readSize);
xwrite(tbInfo->tarFd, block_buf, readSize);
}
return TRUE;
@@ -504,10 +507,10 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
int gzipDataPipe[2] = { -1, -1 };
int gzipStatusPipe[2] = { -1, -1 };
volatile int vfork_exec_errno = 0;
char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0)
bb_perror_msg_and_die("pipe");
xpipe(gzipDataPipe);
xpipe(gzipStatusPipe);
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
@@ -529,7 +532,7 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
close(gzipStatusPipe[0]);
fcntl(gzipStatusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows success */
execlp(zip_exec, zip_exec, "-f", NULL);
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
vfork_exec_errno = errno;
close(gzipStatusPipe[1]);
@@ -560,16 +563,17 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
/* Read the directory/files and iterate over them one at a time */
while (include) {
if (!recursive_action(include->data, TRUE, dereferenceFlag,
FALSE, writeFileToTarball, writeFileToTarball, &tbInfo, 0))
if (!recursive_action(include->data, ACTION_RECURSE |
(dereferenceFlag ? ACTION_FOLLOWLINKS : 0),
writeFileToTarball, writeFileToTarball, &tbInfo, 0))
{
errorFlag = TRUE;
}
include = include->link;
}
/* Write two empty blocks to the end of the archive */
memset(bb_common_bufsiz1, 0, 2*TAR_BLOCK_SIZE);
xwrite(tbInfo.tarFd, bb_common_bufsiz1, 2*TAR_BLOCK_SIZE);
memset(block_buf, 0, 2*TAR_BLOCK_SIZE);
xwrite(tbInfo.tarFd, block_buf, 2*TAR_BLOCK_SIZE);
/* To be pedantically correct, we would check if the tarball
* is smaller than 20 tar blocks, and pad it if it was smaller,
@@ -644,7 +648,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
bb_error_msg_and_die("invalid magic");
}
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress);
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress, "uncompress", "uncompress", "-cf", "-", NULL);
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
/* nothing */;
@@ -674,7 +678,7 @@ static void handle_SIGCHLD(int status)
/* child exited with 0 */
return;
/* Cannot happen?
if(!WIFSIGNALED(status) && !WIFEXITED(status)) return; */
if (!WIFSIGNALED(status) && !WIFEXITED(status)) return; */
child_error = 1;
}
#endif
@@ -711,47 +715,47 @@ enum {
OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions
};
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
static const struct option tar_long_options[] = {
{ "list", 0, NULL, 't' },
{ "extract", 0, NULL, 'x' },
{ "directory", 1, NULL, 'C' },
{ "file", 1, NULL, 'f' },
{ "to-stdout", 0, NULL, 'O' },
{ "same-permissions", 0, NULL, 'p' },
{ "verbose", 0, NULL, 'v' },
{ "keep-old", 0, NULL, 'k' },
static const char tar_longopts[] ALIGN1 =
"list\0" No_argument "t"
"extract\0" No_argument "x"
"directory\0" Required_argument "C"
"file\0" Required_argument "f"
"to-stdout\0" No_argument "O"
"same-permissions\0" No_argument "p"
"verbose\0" No_argument "v"
"keep-old\0" No_argument "k"
# if ENABLE_FEATURE_TAR_CREATE
{ "create", 0, NULL, 'c' },
{ "dereference", 0, NULL, 'h' },
"create\0" No_argument "c"
"dereference\0" No_argument "h"
# endif
# if ENABLE_FEATURE_TAR_BZIP2
{ "bzip2", 0, NULL, 'j' },
"bzip2\0" No_argument "j"
# endif
# if ENABLE_FEATURE_TAR_LZMA
{ "lzma", 0, NULL, 'a' },
"lzma\0" No_argument "a"
# endif
# if ENABLE_FEATURE_TAR_FROM
{ "files-from", 1, NULL, 'T' },
{ "exclude-from", 1, NULL, 'X' },
"files-from\0" Required_argument "T"
"exclude-from\0" Required_argument "X"
# endif
# if ENABLE_FEATURE_TAR_GZIP
{ "gzip", 0, NULL, 'z' },
"gzip\0" No_argument "z"
# endif
# if ENABLE_FEATURE_TAR_COMPRESS
{ "compress", 0, NULL, 'Z' },
"compress\0" No_argument "Z"
# endif
{ "no-same-owner", 0, NULL, 0xfd },
{ "no-same-permissions",0, NULL, 0xfe },
"no-same-owner\0" No_argument "\xfd"
"no-same-permissions\0" No_argument "\xfe"
/* --exclude takes next bit position in option mask, */
/* therefore we have to either put it _after_ --no-same-perm */
/* or add OPT[BIT]_EXCLUDE before OPT[BIT]_NOPRESERVE_OWN */
# if ENABLE_FEATURE_TAR_FROM
{ "exclude", 1, NULL, 0xff },
"exclude\0" Required_argument "\xff"
# endif
{ 0, 0, 0, 0 }
};
;
#endif
int tar_main(int argc, char **argv);
int tar_main(int argc, char **argv)
{
char (*get_header_ptr)(archive_handle_t *) = get_header_tar;
@@ -782,9 +786,9 @@ int tar_main(int argc, char **argv)
USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
applet_long_options = tar_long_options;
applet_long_options = tar_longopts;
#endif
opt = getopt32(argc, argv,
opt = getopt32(argv,
"txC:f:Opvk"
USE_FEATURE_TAR_CREATE( "ch" )
USE_FEATURE_TAR_BZIP2( "j" )
@@ -860,10 +864,9 @@ int tar_main(int argc, char **argv)
char *cp = last_char_is(argv[optind], '/');
if (cp > argv[optind])
*cp = '\0';
llist_add_to(&tar_handle->accept, argv[optind]);
llist_add_to_end(&tar_handle->accept, argv[optind]);
optind++;
}
tar_handle->accept = rev_llist(tar_handle->accept);
if (tar_handle->accept || tar_handle->reject)
tar_handle->filter = filter_accept_reject_list;
-94
View File
@@ -1,94 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Uncompress applet for busybox (c) 2002 Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "unarchive.h"
#define GUNZIP_TO_STDOUT 1
#define GUNZIP_FORCE 2
int uncompress_main(int argc, char **argv)
{
int status = EXIT_SUCCESS;
unsigned long flags;
flags = getopt32(argc, argv, "cf");
while (optind < argc) {
char *compressed_file = argv[optind++];
char *delete_path = NULL;
char *uncompressed_file = NULL;
int src_fd;
int dst_fd;
if (LONE_DASH(compressed_file)) {
src_fd = STDIN_FILENO;
flags |= GUNZIP_TO_STDOUT;
} else {
src_fd = xopen(compressed_file, O_RDONLY);
}
/* Check that the input is sane. */
if (isatty(src_fd) && ((flags & GUNZIP_FORCE) == 0)) {
bb_error_msg_and_die
("compressed data not read from terminal. Use -f to force it.");
}
/* Set output filename and number */
if (flags & GUNZIP_TO_STDOUT) {
dst_fd = STDOUT_FILENO;
} else {
struct stat stat_buf;
char *extension;
uncompressed_file = xstrdup(compressed_file);
extension = strrchr(uncompressed_file, '.');
if (!extension || (strcmp(extension, ".Z") != 0)) {
bb_error_msg_and_die("invalid extension");
}
*extension = '\0';
/* Open output file */
xstat(compressed_file, &stat_buf);
dst_fd = xopen3(uncompressed_file,
O_WRONLY | O_CREAT | O_TRUNC,
stat_buf.st_mode);
/* If unzip succeeds remove the old file */
delete_path = compressed_file;
}
/* do the decompression, and cleanup */
if ((xread_char(src_fd) != 0x1f) || (xread_char(src_fd) != 0x9d)) {
bb_error_msg_and_die("invalid magic");
}
status = uncompress(src_fd, dst_fd);
if ((status != EXIT_SUCCESS) && (uncompressed_file)) {
/* Unzip failed, remove the uncomressed file instead of compressed file */
delete_path = uncompressed_file;
}
if (dst_fd != STDOUT_FILENO) {
close(dst_fd);
}
if (src_fd != STDIN_FILENO) {
close(src_fd);
}
/* delete_path will be NULL if in test mode or from stdin */
if (delete_path && (unlink(delete_path) == -1)) {
bb_error_msg_and_die("cannot remove %s", delete_path);
}
free(uncompressed_file);
}
return status;
}
-64
View File
@@ -1,64 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
*
* Based on bunzip.c from busybox
*
* Licensed under GPL v2, see file LICENSE in this tarball for details.
*/
/* Why our g[un]zip/bunzip2 are so ugly compared to this beauty? */
#include "busybox.h"
#include "unarchive.h"
#define UNLZMA_OPT_STDOUT 1
int unlzma_main(int argc, char **argv)
{
USE_DESKTOP(long long) int status;
char *filename;
unsigned opt;
int src_fd, dst_fd;
opt = getopt32(argc, argv, "c");
/* Set input filename and number */
filename = argv[optind];
if (filename && NOT_LONE_DASH(filename)) {
/* Open input file */
src_fd = xopen(filename, O_RDONLY);
} else {
src_fd = STDIN_FILENO;
filename = 0;
}
/* if called as lzmacat force the stdout flag */
if ((opt & UNLZMA_OPT_STDOUT) || applet_name[4] == 'c')
filename = 0;
if (filename) {
struct stat stat_buf;
/* bug: char *extension = filename + strlen(filename) - 5; */
char *extension = strrchr(filename, '.');
if (!extension || strcmp(extension, ".lzma") != 0) {
bb_error_msg_and_die("invalid extension");
}
xstat(filename, &stat_buf);
*extension = '\0';
dst_fd = xopen3(filename, O_WRONLY | O_CREAT | O_TRUNC,
stat_buf.st_mode);
} else
dst_fd = STDOUT_FILENO;
status = unlzma(src_fd, dst_fd);
if (filename) {
if (status >= 0) /* if success delete src, else delete dst */
filename[strlen(filename)] = '.';
if (unlink(filename) < 0) {
bb_error_msg_and_die("cannot remove %s", filename);
}
}
return (status < 0);
}
+5 -3
View File
@@ -24,7 +24,7 @@
* - central directory
*/
#include "busybox.h"
#include "libbb.h"
#include "unarchive.h"
#define ZIP_FILEHEADER_MAGIC SWAP_LE32(0x04034b50)
@@ -93,6 +93,7 @@ static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
return 0;
}
int unzip_main(int argc, char **argv);
int unzip_main(int argc, char **argv)
{
zip_header_t zip_header;
@@ -133,7 +134,8 @@ int unzip_main(int argc, char **argv)
break;
case 1 : /* The zip file */
src_fn = xstrndup(optarg, strlen(optarg)+4);
src_fn = xmalloc(strlen(optarg)+4);
strcpy(src_fn, optarg);
opt_range++;
break;
@@ -194,7 +196,7 @@ int unzip_main(int argc, char **argv)
src_fd = open(src_fn, O_RDONLY);
}
if (src_fd == -1) {
src_fn[orig_src_fn_len] = 0;
src_fn[orig_src_fn_len] = '\0';
bb_error_msg_and_die("cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
}
}
+1 -1
View File
@@ -85,7 +85,7 @@ config SETCONSOLE
config FEATURE_SETCONSOLE_LONG_OPTIONS
bool "Enable long options"
default n
depends on SET_CONSOLE && GETOPT_LONG
depends on SETCONSOLE && GETOPT_LONG
help
Support long options for the setconsole applet.
+6 -6
View File
@@ -7,7 +7,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "libbb.h"
/* From <linux/vt.h> */
enum {
@@ -15,6 +15,7 @@ enum {
VT_WAITACTIVE = 0x5607 /* wait for vt active */
};
int chvt_main(int argc, char **argv);
int chvt_main(int argc, char **argv)
{
int fd, num;
@@ -24,10 +25,9 @@ int chvt_main(int argc, char **argv)
}
fd = get_console_fd();
num = xatoul_range(argv[1], 1, 63);
if ((-1 == ioctl(fd, VT_ACTIVATE, num))
|| (-1 == ioctl(fd, VT_WAITACTIVE, num))) {
bb_perror_msg_and_die("ioctl");
}
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);
return EXIT_SUCCESS;
}
+2 -4
View File
@@ -10,11 +10,9 @@
/* no options, no getopt */
#include <stdio.h>
#include <stdlib.h>
#include "busybox.h"
#include "libbb.h"
int clear_main(int argc, char **argv);
int clear_main(int argc, char **argv)
{
return printf("\033[H\033[J") != 6;
+6 -6
View File
@@ -10,19 +10,20 @@
/* no options, no getopt */
#include "busybox.h"
#include "libbb.h"
/* From <linux/vt.h> */
enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
int deallocvt_main(int argc, char *argv[])
int deallocvt_main(int argc, char **argv);
int deallocvt_main(int argc, char **argv)
{
/* num = 0 deallocate all unused consoles */
int num = 0;
switch (argc) {
case 2:
num = xatoul_range(argv[1], 1, 63);
num = xatou_range(argv[1], 1, 63);
/* Fallthrough */
case 1:
break;
@@ -30,8 +31,7 @@ int deallocvt_main(int argc, char *argv[])
bb_show_usage();
}
if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
bb_perror_msg_and_die("VT_DISALLOCATE");
}
/* double cast suppresses "cast to ptr from int of different size */
xioctl(get_console_fd(), VT_DISALLOCATE, (void *)(ptrdiff_t)num);
return EXIT_SUCCESS;
}
+9 -8
View File
@@ -8,7 +8,7 @@
*
*/
#include "busybox.h"
#include "libbb.h"
/* From <linux/kd.h> */
struct kbentry {
@@ -22,18 +22,19 @@ struct kbentry {
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
int dumpkmap_main(int argc, char **argv);
int dumpkmap_main(int argc, char **argv)
{
struct kbentry ke;
int i, j, fd;
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
char flags[MAX_NR_KEYMAPS];
if (argc >= 2 && *argv[1] == '-')
if (argc >= 2 && argv[1][0] == '-')
bb_show_usage();
fd = xopen(CURRENT_VC, O_RDWR);
write(1, magic, 7);
write(1, "bkeymap", 7);
/* Here we want to set everything to 0 except for indexes:
* [0-2] [4-6] [8-10] [12] */
@@ -49,12 +50,12 @@ int dumpkmap_main(int argc, char **argv)
for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j;
ke.kb_table = i;
if (ioctl(fd, KDGKBENT, &ke) < 0) {
bb_perror_msg("ioctl failed with %s, %s, %p",
if (!ioctl_or_perror(fd, KDGKBENT, &ke,
"ioctl failed with %s, %s, %p",
(char *)&ke.kb_index,
(char *)&ke.kb_table,
&ke.kb_value);
} else {
&ke.kb_value)
) {
write(1, (void*)&ke.kb_value, 2);
}
}
+41 -53
View File
@@ -7,7 +7,7 @@
* Loads the console font, and possibly the corresponding screen map(s).
* (Adapted for busybox by Matej Vela.)
*/
#include "busybox.h"
#include "libbb.h"
#include <sys/kd.h>
enum {
@@ -21,42 +21,27 @@ enum {
};
struct psf_header {
unsigned char magic1, magic2; /* Magic number */
unsigned char mode; /* PSF font mode */
unsigned char charsize; /* Character size */
unsigned char magic1, magic2; /* Magic number */
unsigned char mode; /* PSF font mode */
unsigned char charsize; /* Character size */
};
#define PSF_MAGIC_OK(x) ((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2)
static void loadnewfont(int fd);
int loadfont_main(int argc, char **argv)
{
int fd;
if (argc != 1)
bb_show_usage();
fd = xopen(CURRENT_VC, O_RDWR);
loadnewfont(fd);
return EXIT_SUCCESS;
}
static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
{
char buf[16384];
char *buf;
int i;
memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32)
bb_error_msg_and_die("bad character size %d", unit);
buf = xzalloc(16 * 1024);
/*memset(buf, 0, 16 * 1024);*/
for (i = 0; i < fontsize; i++)
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
#if defined( PIO_FONTX ) && !defined( __sparc__ )
#if defined(PIO_FONTX) && !defined(__sparc__)
{
struct consolefontdesc cfd;
@@ -64,13 +49,13 @@ static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
cfd.charheight = unit;
cfd.chardata = buf;
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
return; /* success */
bb_perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
if (!ioctl_or_perror(fd, PIO_FONTX, &cfd, "PIO_FONTX ioctl failed (will try PIO_FONT)"))
goto ret; /* success */
}
#endif
if (ioctl(fd, PIO_FONT, buf))
bb_perror_msg_and_die("PIO_FONT ioctl error");
xioctl(fd, PIO_FONT, buf);
ret:
free(buf);
}
static void
@@ -105,49 +90,38 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
advice.advised_hashsize = 0;
advice.advised_hashstep = 0;
advice.advised_hashlevel = 0;
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) {
bb_error_msg("it seems this kernel is older than 1.1.92");
bb_error_msg_and_die("no Unicode mapping table loaded");
} else
#endif
bb_perror_msg_and_die("PIO_UNIMAPCLR");
}
xioctl(fd, PIO_UNIMAPCLR, &advice);
ud.entry_ct = ct;
ud.entries = up;
if (ioctl(fd, PIO_UNIMAP, &ud)) {
bb_perror_msg_and_die("PIO_UNIMAP");
}
xioctl(fd, PIO_UNIMAP, &ud);
}
static void loadnewfont(int fd)
{
enum { INBUF_SIZE = 32*1024 + 1 };
int unit;
unsigned char inbuf[32768]; /* primitive */
unsigned int inputlth, offset;
unsigned inputlth, offset;
/* Was on stack, but 32k is a bit too much: */
unsigned char *inbuf = xmalloc(INBUF_SIZE);
/*
* We used to look at the length of the input file
* with stat(); now that we accept compressed files,
* just read the entire file.
*/
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
if (ferror(stdin))
inputlth = full_read(STDIN_FILENO, inbuf, INBUF_SIZE);
if (inputlth < 0)
bb_perror_msg_and_die("error reading input font");
/* use malloc/realloc in case of giant files;
maybe these do not occur: 16kB for the font,
and 16kB for the map leaves 32 unicode values
for each font position */
if (!feof(stdin))
bb_perror_msg_and_die("font too large");
if (inputlth >= INBUF_SIZE)
bb_error_msg_and_die("font too large");
/* test for psf first */
{
struct psf_header psfhdr;
int fontsize;
int hastable;
unsigned int head0, head;
unsigned head0, head;
if (inputlth < sizeof(struct psf_header))
goto no_psf;
@@ -160,7 +134,7 @@ static void loadnewfont(int fd)
if (psfhdr.mode > PSF_MAXMODE)
bb_error_msg_and_die("unsupported psf file mode");
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ )
#if !defined(PIO_FONTX) || defined(__sparc__)
if (fontsize != 256)
bb_error_msg_and_die("only fontsize 256 supported");
#endif
@@ -176,8 +150,8 @@ static void loadnewfont(int fd)
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
return;
}
no_psf:
no_psf:
/* file with three code pages? */
if (inputlth == 9780) {
offset = 40;
@@ -191,3 +165,17 @@ static void loadnewfont(int fd)
}
do_loadfont(fd, inbuf + offset, unit, 256);
}
int loadfont_main(int argc, char **argv);
int loadfont_main(int argc, char **argv)
{
int fd;
if (argc != 1)
bb_show_usage();
fd = xopen(CURRENT_VC, O_RDWR);
loadnewfont(fd);
return EXIT_SUCCESS;
}
+2 -1
View File
@@ -8,7 +8,7 @@
*
*/
#include "busybox.h"
#include "libbb.h"
#define BINARY_KEYMAP_MAGIC "bkeymap"
@@ -25,6 +25,7 @@ struct kbentry {
#define NR_KEYS 128
#define MAX_NR_KEYMAPS 256
int loadkmap_main(int argc, char **argv);
int loadkmap_main(int argc, char **argv)
{
struct kbentry ke;
+13 -20
View File
@@ -10,33 +10,26 @@
/* getopt not needed */
#include "busybox.h"
#include "libbb.h"
int openvt_main(int argc, char **argv);
int openvt_main(int argc, char **argv)
{
int fd;
char vtname[sizeof(VC_FORMAT) + 2];
if (argc < 3) {
if (argc < 3)
bb_show_usage();
}
/* check for illegal vt number: < 1 or > 63 */
sprintf(vtname, VC_FORMAT, (int)xatoul_range(argv[1], 1, 63));
sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63));
if (fork() == 0) {
/* child */
/* leave current vt (controlling tty) */
setsid();
/* and grab new one */
fd = xopen(vtname, O_RDWR);
/* Reassign stdin, stdout and sterr */
dup2(fd, STDIN_FILENO);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
while (fd > 2) close(fd--);
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
/* grab new one */
close(0);
xopen(vtname, O_RDWR);
dup2(0, STDOUT_FILENO);
dup2(0, STDERR_FILENO);
execvp(argv[2], &argv[2]);
_exit(1);
}
return EXIT_SUCCESS;
BB_EXECVP(argv[2], &argv[2]);
_exit(1);
}
+2 -4
View File
@@ -10,11 +10,9 @@
/* no options, no getopt */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "busybox.h"
#include "libbb.h"
int reset_main(int argc, char **argv);
int reset_main(int argc, char **argv)
{
if (isatty(1)) {
+42 -11
View File
@@ -7,32 +7,63 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* no options, no getopt */
#include "busybox.h"
#include "libbb.h"
#define ESC "\033"
#define old_termios (*(struct termios*)&bb_common_bufsiz1)
static void
onintr(int sig ATTRIBUTE_UNUSED)
{
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
exit(1);
}
int resize_main(int argc, char **argv);
int resize_main(int argc, char **argv)
{
struct termios old, new;
struct winsize w = {0,0,0,0};
struct termios new;
struct winsize w = { 0,0,0,0 };
int ret;
tcgetattr(STDOUT_FILENO, &old); /* fiddle echo */
new = old;
/* We use _stderr_ in order to make resize usable
* in shell backticks (those redirect stdout away from tty).
* NB: other versions of resize open "/dev/tty"
* and operate on it - should we do the same?
*/
tcgetattr(STDERR_FILENO, &old_termios); /* fiddle echo */
new = old_termios;
new.c_cflag |= (CLOCAL | CREAD);
new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
tcsetattr(STDOUT_FILENO, TCSANOW, &new);
signal(SIGINT, onintr);
signal(SIGQUIT, onintr);
signal(SIGTERM, onintr);
signal(SIGALRM, onintr);
tcsetattr(STDERR_FILENO, TCSANOW, &new);
/* save_cursor_pos 7
* scroll_whole_screen [r
* put_cursor_waaaay_off [$x;$yH
* get_cursor_pos [6n
* restore_cursor_pos 8
*/
printf("\0337\033[r\033[999;999H\033[6n");
scanf("\033[%hu;%huR", &w.ws_row, &w.ws_col);
ret = ioctl(STDOUT_FILENO, TIOCSWINSZ, &w);
printf("\0338");
tcsetattr(STDOUT_FILENO, TCSANOW, &old);
fprintf(stderr, ESC"7" ESC"[r" ESC"[999;999H" ESC"[6n");
alarm(3); /* Just in case terminal won't answer */
scanf(ESC"[%hu;%huR", &w.ws_row, &w.ws_col);
fprintf(stderr, ESC"8");
/* BTW, other versions of resize recalculate w.ws_xpixel, ws.ws_ypixel
* by calculating character cell HxW from old values
* (gotten via TIOCGWINSZ) and recomputing *pixel values */
ret = ioctl(STDERR_FILENO, TIOCSWINSZ, &w);
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
if (ENABLE_FEATURE_RESIZE_PRINT)
printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n",
w.ws_col, w.ws_row);
return ret;
}
+10 -11
View File
@@ -7,26 +7,27 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include <getopt.h>
#include "libbb.h"
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
static const struct option setconsole_long_options[] = {
{ "reset", 0, NULL, 'r' },
{ 0, 0, 0, 0 }
};
static const char setconsole_longopts[] ALIGN1 =
"reset\0" No_argument "r"
;
#endif
#define OPT_SETCONS_RESET 1
int setconsole_main(int argc, char **argv);
int setconsole_main(int argc, char **argv)
{
unsigned long flags;
const char *device = CURRENT_TTY;
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
applet_long_options = setconsole_long_options;
applet_long_options = setconsole_longopts;
#endif
flags = getopt32(argc, argv, "r");
flags = getopt32(argv, "r");
if (argc - optind > 1)
bb_show_usage();
@@ -37,11 +38,9 @@ int setconsole_main(int argc, char **argv)
device = argv[optind];
} else {
if (flags & OPT_SETCONS_RESET)
device = CONSOLE_DEV;
device = DEV_CONSOLE;
}
if (-1 == ioctl(xopen(device, O_RDONLY), TIOCCONS)) {
bb_perror_msg_and_die("TIOCCONS");
}
xioctl(xopen(device, O_RDONLY), TIOCCONS, NULL);
return EXIT_SUCCESS;
}
+7 -11
View File
@@ -9,12 +9,8 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include "busybox.h"
//#include <sys/ioctl.h>
#include "libbb.h"
/* From <linux/kd.h> */
struct kbkeycode {
@@ -24,8 +20,8 @@ enum {
KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
};
extern int
setkeycodes_main(int argc, char** argv)
int setkeycodes_main(int argc, char** argv);
int setkeycodes_main(int argc, char** argv)
{
int fd, sc;
struct kbkeycode a;
@@ -43,9 +39,9 @@ setkeycodes_main(int argc, char** argv)
a.scancode -= 0xe000;
a.scancode += 128;
}
if (ioctl(fd, KDSETKEYCODE, &a)) {
bb_perror_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
}
ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
"failed to set SCANCODE %x to KEYCODE %d",
sc, a.keycode);
argc -= 2;
argv += 2;
}
+4 -4
View File
@@ -9,9 +9,10 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "libbb.h"
extern int setlogcons_main(int argc, char **argv)
int setlogcons_main(int argc, char **argv);
int setlogcons_main(int argc, char **argv)
{
struct {
char fn;
@@ -24,8 +25,7 @@ extern int setlogcons_main(int argc, char **argv)
if (argc == 2)
arg.subarg = xatoul_range(argv[1], 0, 63);
if (ioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg))
bb_perror_msg_and_die("TIOCLINUX");
xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
return 0;
}
+55 -47
View File
@@ -65,13 +65,6 @@ config CKSUM
help
cksum is used to calculate the CRC32 checksum of a file.
config CMP
bool "cmp"
default n
help
cmp is used to compare two files and returns the result
to standard output.
config COMM
bool "comm"
default n
@@ -142,38 +135,6 @@ config DF
df reports the amount of disk space used and available
on filesystems.
config DIFF
bool "diff"
default n
help
diff compares two files or directories and outputs the
differences between them in a form that can be given to
the patch command.
config FEATURE_DIFF_BINARY
bool "Enable checks for binary files"
default y
depends on DIFF
help
This option enables support for checking for binary files
before a comparison is carried out.
config FEATURE_DIFF_DIR
bool "Enable directory support"
default y
depends on DIFF
help
This option enables support for directory and subdirectory
comparison.
config FEATURE_DIFF_MINIMAL
bool "Enable -d option to find smaller sets of changes"
default n
depends on DIFF
help
Enabling this option allows the use of -d to make diff
try hard to find the smallest possible set of changes.
config DIRNAME
bool "dirname"
default n
@@ -239,6 +200,19 @@ config FEATURE_ENV_LONG_OPTIONS
help
Support long options for the env applet.
config EXPAND
bool "expand"
default n
help
By default, convert all tabs to spaces.
config FEATURE_EXPAND_LONG_OPTIONS
bool "Enable long options"
default n
depends on EXPAND && GETOPT_LONG
help
Support long options for the expand applet.
config EXPR
bool "expr"
default n
@@ -474,6 +448,20 @@ config PWD
help
pwd is used to print the current directory.
config READLINK
bool "readlink"
default n
help
This program reads a symbolic link and returns the name
of the file it points to
config FEATURE_READLINK_FOLLOW
bool "Enable canonicalization by following all symlinks (-f)"
default n
depends on READLINK
help
Enable the readlink option (-f).
config REALPATH
bool "realpath"
default n
@@ -536,6 +524,21 @@ config FEATURE_SORT_BIG
The SuSv3 sort standard is available at:
http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
config SPLIT
bool "split"
default n
help
split a file into pieces.
config FEATURE_SPLIT_FANCY
bool "fancy extensions"
default n
depends on SPLIT
help
Add support for features not required by SUSv3.
Supports additional suffixes 'b' for 512 bytes,
'g' for 1GiB for the -b option.
config STAT
bool "stat"
default n
@@ -665,6 +668,19 @@ config UNAME
help
uname is used to print system information.
config UNEXPAND
bool "unexpand"
default n
help
By default, convert only leading sequences of blanks to tabs.
config FEATURE_UNEXPAND_LONG_OPTIONS
bool "Enable long options"
default n
depends on UNEXPAND && GETOPT_LONG
help
Support long options for the unexpand applet.
config UNIQ
bool "uniq"
default n
@@ -689,14 +705,6 @@ config UUENCODE
help
uuencode is used to uuencode a file.
config WATCH
bool "watch"
default n
select DATE
help
watch is used to execute a program periodically, showing
output to the screen.
config WC
bool "wc"
default n
+6 -4
View File
@@ -10,21 +10,20 @@ lib-y:=
lib-$(CONFIG_BASENAME) += basename.o
lib-$(CONFIG_CAL) += cal.o
lib-$(CONFIG_CAT) += cat.o
lib-$(CONFIG_LESS) += cat.o # less uses it if stdout isn't a tty
lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
lib-$(CONFIG_LESS) += cat.o # less too
lib-$(CONFIG_CATV) += catv.o
lib-$(CONFIG_CHGRP) += chgrp.o chown.o
lib-$(CONFIG_CHMOD) += chmod.o
lib-$(CONFIG_CHOWN) += chown.o
lib-$(CONFIG_CHROOT) += chroot.o
lib-$(CONFIG_CKSUM) += cksum.o
lib-$(CONFIG_CMP) += cmp.o
lib-$(CONFIG_COMM) += comm.o
lib-$(CONFIG_CP) += cp.o
lib-$(CONFIG_CUT) += cut.o
lib-$(CONFIG_DATE) += date.o
lib-$(CONFIG_DD) += dd.o
lib-$(CONFIG_DF) += df.o
lib-$(CONFIG_DIFF) += diff.o
lib-$(CONFIG_DIRNAME) += dirname.o
lib-$(CONFIG_DOS2UNIX) += dos2unix.o
lib-$(CONFIG_DU) += du.o
@@ -32,6 +31,7 @@ lib-$(CONFIG_ECHO) += echo.o
lib-$(CONFIG_ASH) += echo.o # used by ash
lib-$(CONFIG_ENV) += env.o
lib-$(CONFIG_EXPR) += expr.o
lib-$(CONFIG_EXPAND) += expand.o
lib-$(CONFIG_FALSE) += false.o
lib-$(CONFIG_FOLD) += fold.o
lib-$(CONFIG_HEAD) += head.o
@@ -53,12 +53,14 @@ lib-$(CONFIG_OD) += od.o
lib-$(CONFIG_PRINTENV) += printenv.o
lib-$(CONFIG_PRINTF) += printf.o
lib-$(CONFIG_PWD) += pwd.o
lib-$(CONFIG_READLINK) += readlink.o
lib-$(CONFIG_REALPATH) += realpath.o
lib-$(CONFIG_RM) += rm.o
lib-$(CONFIG_RMDIR) += rmdir.o
lib-$(CONFIG_SEQ) += seq.o
lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
lib-$(CONFIG_SLEEP) += sleep.o
lib-$(CONFIG_SPLIT) += split.o
lib-$(CONFIG_SORT) += sort.o
lib-$(CONFIG_STAT) += stat.o
lib-$(CONFIG_STTY) += stty.o
@@ -73,11 +75,11 @@ lib-$(CONFIG_TR) += tr.o
lib-$(CONFIG_TRUE) += true.o
lib-$(CONFIG_TTY) += tty.o
lib-$(CONFIG_UNAME) += uname.o
lib-$(CONFIG_UNEXPAND) += expand.o
lib-$(CONFIG_UNIQ) += uniq.o
lib-$(CONFIG_USLEEP) += usleep.o
lib-$(CONFIG_UUDECODE) += uudecode.o
lib-$(CONFIG_UUENCODE) += uuencode.o
lib-$(CONFIG_WATCH) += watch.o
lib-$(CONFIG_WC) += wc.o
lib-$(CONFIG_WHO) += who.o
lib-$(CONFIG_WHOAMI) += whoami.o
+5 -5
View File
@@ -20,11 +20,11 @@
* 3) Save some space by using strcmp(). Calling strncmp() here was silly.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "busybox.h"
#include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
int basename_main(int argc, char **argv);
int basename_main(int argc, char **argv)
{
size_t m, n;
@@ -46,5 +46,5 @@ int basename_main(int argc, char **argv)
puts(s);
fflush_stdout_and_exit(EXIT_SUCCESS);
return fflush(stdout);
}
+53 -57
View File
@@ -17,7 +17,9 @@
* Major size reduction... over 50% (>1.5k) on i386.
*/
#include "busybox.h"
#include "libbb.h"
/* We often use "unsigned" intead of "int", it's easier to div on most CPUs */
#define THURSDAY 4 /* for reformation */
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
@@ -28,29 +30,25 @@
#define MAXDAYS 42 /* max slots in a month array */
#define SPACE -1 /* used in day array */
static const char days_in_month[] = {
static const unsigned char days_in_month[] ALIGN1 = {
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
static const char sep1752[] = {
static const unsigned char sep1752[] ALIGN1 = {
1, 2, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30
};
static int julian;
static unsigned julian;
/* leap year -- account for Gregorian reformation in 1752 */
#define leap_year(yr) \
((yr) <= 1752 ? !((yr) % 4) : \
(!((yr) % 4) && ((yr) % 100)) || !((yr) % 400))
static int is_leap_year(int year)
static int leap_year(unsigned yr)
{
return leap_year(year);
if (yr <= 1752)
return !(yr % 4);
return (!(yr % 4) && (yr % 100)) || !(yr % 400);
}
#undef leap_year
#define leap_year(yr) is_leap_year(yr)
/* number of centuries since 1700, not inclusive */
#define centuries_since_1700(yr) \
@@ -64,12 +62,12 @@ static int is_leap_year(int year)
#define leap_years_since_year_1(yr) \
((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
static void center (char *, int, int);
static void day_array (int, int, int *);
static void trim_trailing_spaces_and_print (char *);
static void center(char *, unsigned, unsigned);
static void day_array(unsigned, unsigned, unsigned *);
static void trim_trailing_spaces_and_print(char *);
static void blank_string(char *buf, size_t buflen);
static char *build_row(char *p, int *dp);
static char *build_row(char *p, unsigned *dp);
#define DAY_LEN 3 /* 3 spaces per day */
#define J_DAY_LEN (DAY_LEN + 1)
@@ -77,25 +75,24 @@ static char *build_row(char *p, int *dp);
#define J_WEEK_LEN (WEEK_LEN + 7)
#define HEAD_SEP 2 /* spaces between day headings */
int cal_main(int argc, char **argv);
int cal_main(int argc, char **argv)
{
struct tm *local_time;
struct tm zero_tm;
time_t now;
int month, year, flags, i;
unsigned month, year, flags, i;
char *month_names[12];
char day_headings[28]; /* 28 for julian, 21 for nonjulian */
char buf[40];
flags = getopt32(argc, argv, "jy");
flags = getopt32(argv, "jy");
julian = flags & 1;
argv += optind;
month = 0;
argv += optind;
argc -= optind;
if ((argc -= optind) > 2) {
if (argc > 2) {
bb_show_usage();
}
@@ -108,12 +105,12 @@ int cal_main(int argc, char **argv)
}
} else {
if (argc == 2) {
month = xatoul_range(*argv++, 1, 12);
month = xatou_range(*argv++, 1, 12);
}
year = xatoul_range(*argv, 1, 9999);
year = xatou_range(*argv, 1, 9999);
}
blank_string(day_headings, sizeof(day_headings) - 7 + 7*julian);
blank_string(day_headings, sizeof(day_headings) - 7 + 7*julian);
i = 0;
do {
@@ -129,8 +126,8 @@ int cal_main(int argc, char **argv)
} while (++i < 12);
if (month) {
int row, len, days[MAXDAYS];
int *dp = days;
unsigned row, len, days[MAXDAYS];
unsigned *dp = days;
char lineout[30];
day_array(month, year, dp);
@@ -144,8 +141,8 @@ int cal_main(int argc, char **argv)
trim_trailing_spaces_and_print(lineout);
}
} else {
int row, which_cal, week_len, days[12][MAXDAYS];
int *dp;
unsigned row, which_cal, week_len, days[12][MAXDAYS];
unsigned *dp;
char lineout[80];
sprintf(lineout, "%d", year);
@@ -192,19 +189,21 @@ int cal_main(int argc, char **argv)
* out end to end. You would have 42 numbers or spaces. This routine
* builds that array for any month from Jan. 1 through Dec. 9999.
*/
static void day_array(int month, int year, int *days)
static void day_array(unsigned month, unsigned year, unsigned *days)
{
long temp;
int i;
int j_offset;
int day, dw, dm;
unsigned long temp;
unsigned i;
unsigned day, dw, dm;
memset(days, SPACE, MAXDAYS * sizeof(int));
if ((month == 9) && (year == 1752)) {
/* Assumes the Gregorian reformation eliminates
* 3 Sep. 1752 through 13 Sep. 1752.
*/
unsigned j_offset = julian * 244;
size_t oday = 0;
j_offset = julian * 244;
do {
days[oday+2] = sep1752[oday] + j_offset;
} while (++oday < sizeof(sep1752));
@@ -213,7 +212,7 @@ static void day_array(int month, int year, int *days)
}
/* day_in_year
* return the 1 based day number within the year
* return the 1 based day number within the year
*/
day = 1;
if ((month > 2) && leap_year(year)) {
@@ -226,17 +225,15 @@ static void day_array(int month, int year, int *days)
}
/* day_in_week
* return the 0 based day number for any date from 1 Jan. 1 to
* 31 Dec. 9999. Assumes the Gregorian reformation eliminates
* 3 Sep. 1752 through 13 Sep. 1752. Returns Thursday for all
* missing days.
* return the 0 based day number for any date from 1 Jan. 1 to
* 31 Dec. 9999. Assumes the Gregorian reformation eliminates
* 3 Sep. 1752 through 13 Sep. 1752. Returns Thursday for all
* missing days.
*/
dw = THURSDAY;
temp = (long)(year - 1) * 365 + leap_years_since_year_1(year - 1)
+ day;
temp = (long)(year - 1) * 365 + leap_years_since_year_1(year - 1) + day;
if (temp < FIRST_MISSING_DAY) {
dw = ((temp - 1 + SATURDAY) % 7);
} else if (temp >= (FIRST_MISSING_DAY + NUMBER_MISSING_DAYS)) {
} else {
dw = (((temp - 1 + SATURDAY) - NUMBER_MISSING_DAYS) % 7);
}
@@ -249,10 +246,9 @@ static void day_array(int month, int year, int *days)
++dm;
}
while (dm) {
do {
days[dw++] = day++;
--dm;
}
} while (--dm);
}
static void trim_trailing_spaces_and_print(char *s)
@@ -262,7 +258,7 @@ static void trim_trailing_spaces_and_print(char *s)
while (*p) {
++p;
}
while (p > s) {
while (p != s) {
--p;
if (!(isspace)(*p)) { /* We want the function... not the inline. */
p[1] = '\0';
@@ -273,9 +269,9 @@ static void trim_trailing_spaces_and_print(char *s)
puts(s);
}
static void center(char *str, int len, int separate)
static void center(char *str, unsigned len, unsigned separate)
{
int n = strlen(str);
unsigned n = strlen(str);
len -= n;
printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
}
@@ -286,15 +282,16 @@ static void blank_string(char *buf, size_t buflen)
buf[buflen-1] = '\0';
}
static char *build_row(char *p, int *dp)
static char *build_row(char *p, unsigned *dp)
{
int col, val, day;
unsigned col, val, day;
memset(p, ' ', (julian + DAY_LEN) * 7);
col = 0;
do {
if ((day = *dp++) != SPACE) {
day = *dp++;
if (day != SPACE) {
if (julian) {
++p;
if (day >= 100) {
@@ -303,7 +300,8 @@ static char *build_row(char *p, int *dp)
day %= 100;
}
}
if ((val = day / 10) > 0) {
val = day / 10;
if (val > 0) {
*p = val + '0';
}
*++p = day % 10 + '0';
@@ -347,5 +345,3 @@ static char *build_row(char *p, int *dp)
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+19 -9
View File
@@ -10,21 +10,30 @@
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
#include "busybox.h"
#include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
int bb_cat(char **argv)
{
static char *const argv_dash[] = { "-", NULL };
FILE *f;
static const char *const argv_dash[] = { "-", NULL };
int fd;
int retval = EXIT_SUCCESS;
if (!*argv) argv = (char**) &argv_dash;
if (!*argv)
argv = (char**) &argv_dash;
do {
f = fopen_or_warn_stdin(*argv);
if (f) {
off_t r = bb_copyfd_eof(fileno(f), STDOUT_FILENO);
fclose_if_not_stdin(f);
fd = STDIN_FILENO;
if (!LONE_DASH(*argv))
fd = open_or_warn(*argv, O_RDONLY);
if (fd >= 0) {
/* This is not an xfunc - never exits */
off_t r = bb_copyfd_eof(fd, STDOUT_FILENO);
if (fd != STDIN_FILENO)
close(fd);
if (r >= 0)
continue;
}
@@ -34,9 +43,10 @@ int bb_cat(char **argv)
return retval;
}
int cat_main(int argc, char **argv);
int cat_main(int argc, char **argv)
{
getopt32(argc, argv, "u");
getopt32(argv, "u");
argv += optind;
return bb_cat(argv);
}
+23 -13
View File
@@ -10,44 +10,54 @@
/* See "Cat -v considered harmful" at
* http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz */
#include "busybox.h"
#include "libbb.h"
int catv_main(int argc, char **argv);
int catv_main(int argc, char **argv)
{
int retval = EXIT_SUCCESS, fd;
int retval = EXIT_SUCCESS;
int fd;
unsigned flags;
flags = getopt32(argc, argv, "etv");
flags = getopt32(argv, "etv");
#define CATV_OPT_e (1<<0)
#define CATV_OPT_t (1<<1)
#define CATV_OPT_v (1<<2)
flags ^= CATV_OPT_v;
argv += optind;
/* Read from stdin if there's nothing else to do. */
fd = 0;
if (!argv[0]) {
argv--;
goto jump_in;
}
do {
/* Read from stdin if there's nothing else to do. */
fd = 0;
if (*argv && 0 > (fd = xopen(*argv, O_RDONLY)))
fd = open_or_warn(*argv, O_RDONLY);
if (fd < 0) {
retval = EXIT_FAILURE;
else for (;;) {
continue;
}
jump_in:
for (;;) {
int i, res;
res = read(fd, bb_common_bufsiz1, sizeof(bb_common_bufsiz1));
#define read_buf bb_common_bufsiz1
res = read(fd, read_buf, COMMON_BUFSIZE);
if (res < 0)
retval = EXIT_FAILURE;
if (res < 1)
break;
for (i = 0; i < res; i++) {
char c = bb_common_bufsiz1[i];
unsigned char c = read_buf[i];
if (c > 126 && (flags & CATV_OPT_v)) {
if (c == 127) {
printf("^?");
continue;
} else {
printf("M-");
c -= 128;
}
printf("M-");
c -= 128;
}
if (c < 32) {
if (c == 10) {
+5 -4
View File
@@ -7,15 +7,16 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* BB_AUDIT SUSv3 defects - unsupported options -H, -L, and -P. */
/* BB_AUDIT SUSv3 defects - none? */
/* BB_AUDIT GNU defects - unsupported long options. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */
#include "busybox.h"
#include "libbb.h"
/* FIXME - move to .h */
extern int chown_main(int argc, char **argv);
/* This is a NOEXEC applet. Be very careful! */
int chgrp_main(int argc, char **argv);
int chgrp_main(int argc, char **argv)
{
/* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */
+16 -13
View File
@@ -14,7 +14,10 @@
/* BB_AUDIT GNU defects - unsupported long options. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chmod.html */
#include "busybox.h"
#include "libbb.h"
/* This is a NOEXEC applet. Be very careful! */
#define OPT_RECURSE (option_mask32 & 1)
#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 2) SKIP_DESKTOP(0))
@@ -31,7 +34,7 @@
* symbolic links encountered during recursive directory traversals.
*/
static int fileAction(const char *fileName, struct stat *statbuf, void* junk, int depth)
static int fileAction(const char *fileName, struct stat *statbuf, void* param, int depth)
{
mode_t newmode;
@@ -46,8 +49,8 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk, in
}
newmode = statbuf->st_mode;
if (!bb_parse_mode((char *)junk, &newmode))
bb_error_msg_and_die("invalid mode: %s", (char *)junk);
if (!bb_parse_mode((char *)param, &newmode))
bb_error_msg_and_die("invalid mode: %s", (char *)param);
if (chmod(fileName, newmode) == 0) {
if (OPT_VERBOSE
@@ -64,6 +67,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk, in
return FALSE;
}
int chmod_main(int argc, char **argv);
int chmod_main(int argc, char **argv)
{
int retval = EXIT_SUCCESS;
@@ -89,7 +93,7 @@ int chmod_main(int argc, char **argv)
/* Parse options */
opt_complementary = "-2";
getopt32(argc, argv, ("-"OPT_STR) + 1); /* Reuse string */
getopt32(argv, ("-"OPT_STR) + 1); /* Reuse string */
argv += optind;
/* Restore option-like mode if needed */
@@ -100,8 +104,6 @@ int chmod_main(int argc, char **argv)
do {
if (!recursive_action(*argv,
OPT_RECURSE, // recurse
FALSE, // follow links: coreutils doesn't
FALSE, // depth first
fileAction, // file action
fileAction, // dir action
smode, // user data
@@ -117,10 +119,12 @@ int chmod_main(int argc, char **argv)
/*
Security: chmod is too important and too subtle.
This is a test script (busybox chmod versus coreutils).
Run it in empty dir. Probably requires bash.
Run it in empty directory.
#!/bin/sh
function create() {
t1="/tmp/busybox chmod"
t2="/usr/bin/chmod"
create() {
rm -rf $1; mkdir $1
(
cd $1 || exit 1
@@ -133,17 +137,16 @@ function create() {
ln -s ../up dir/up
)
}
function tst() {
tst() {
(cd test1; $t1 $1)
(cd test2; $t2 $1)
(cd test1; ls -lR) >out1
(cd test2; ls -lR) >out2
echo "chmod $1" >out.diff
if ! diff -u out1 out2 >>out.diff; then exit 1; fi
mv out.diff out1.diff
rm out.diff
}
t1="/tmp/busybox chmod"
t2="/usr/bin/chmod"
echo "If script produced 'out.diff' file, then at least one testcase failed"
create test1; create test2
tst "a+w file"
tst "a-w dir"
+122 -54
View File
@@ -7,44 +7,52 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* BB_AUDIT SUSv3 defects - unsupported options -H, -L, and -P. */
/* BB_AUDIT SUSv3 defects - none? */
/* BB_AUDIT GNU defects - unsupported long options. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */
#include "busybox.h"
#include "libbb.h"
/* This is a NOEXEC applet. Be very careful! */
#define OPT_STR ("Rh" USE_DESKTOP("vcfLHP"))
#define BIT_RECURSE 1
#define OPT_RECURSE (option_mask32 & 1)
#define OPT_NODEREF (option_mask32 & 2)
#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 0x04) SKIP_DESKTOP(0))
#define OPT_CHANGED (USE_DESKTOP(option_mask32 & 0x08) SKIP_DESKTOP(0))
#define OPT_QUIET (USE_DESKTOP(option_mask32 & 0x10) SKIP_DESKTOP(0))
/* POSIX options
* -L traverse every symbolic link to a directory encountered
* -H if a command line argument is a symbolic link to a directory, traverse it
* -P do not traverse any symbolic links (default)
* We do not conform to the following:
* "Specifying more than one of -H, -L, and -P is not an error.
* The last option specified shall determine the behavior of the utility." */
/* -L */
#define BIT_TRAVERSE 0x20
#define OPT_TRAVERSE (USE_DESKTOP(option_mask32 & BIT_TRAVERSE) SKIP_DESKTOP(0))
/* -H or -L */
#define BIT_TRAVERSE_TOP (0x20|0x40)
#define OPT_TRAVERSE_TOP (USE_DESKTOP(option_mask32 & BIT_TRAVERSE_TOP) SKIP_DESKTOP(0))
typedef int (*chown_fptr)(const char *, uid_t, gid_t);
static struct bb_uidgid_t ugid = { -1, -1 };
static int (*chown_func)(const char *, uid_t, gid_t) = chown;
#define OPT_RECURSE (option_mask32 & 1)
#define OPT_NODEREF (option_mask32 & 2)
#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 4) SKIP_DESKTOP(0))
#define OPT_CHANGED (USE_DESKTOP(option_mask32 & 8) SKIP_DESKTOP(0))
#define OPT_QUIET (USE_DESKTOP(option_mask32 & 0x10) SKIP_DESKTOP(0))
#define OPT_STR ("Rh" USE_DESKTOP("vcf"))
/* TODO:
* -H if a command line argument is a symbolic link to a directory, traverse it
* -L traverse every symbolic link to a directory encountered
* -P do not traverse any symbolic links (default)
*/
static int fileAction(const char *fileName, struct stat *statbuf,
void ATTRIBUTE_UNUSED *junk, int depth)
void *cf, int depth)
{
// TODO: -H/-L/-P
// if (depth ... && S_ISLNK(statbuf->st_mode)) ....
uid_t u = (ugid.uid == (uid_t)-1) ? statbuf->st_uid : ugid.uid;
gid_t g = (ugid.gid == (gid_t)-1) ? statbuf->st_gid : ugid.gid;
if (!chown_func(fileName,
(ugid.uid == (uid_t)-1) ? statbuf->st_uid : ugid.uid,
(ugid.gid == (gid_t)-1) ? statbuf->st_gid : ugid.gid)
) {
if (!((chown_fptr)cf)(fileName, u, g)) {
if (OPT_VERBOSE
|| (OPT_CHANGED && (statbuf->st_uid != ugid.uid || statbuf->st_gid != ugid.gid))
|| (OPT_CHANGED && (statbuf->st_uid != u || statbuf->st_gid != g))
) {
printf("changed ownership of '%s' to %u:%u\n",
fileName, ugid.uid, ugid.gid);
fileName, (unsigned)u, (unsigned)g);
}
return TRUE;
}
@@ -53,47 +61,45 @@ static int fileAction(const char *fileName, struct stat *statbuf,
return FALSE;
}
int chown_main(int argc, char **argv);
int chown_main(int argc, char **argv)
{
char *groupName;
int retval = EXIT_SUCCESS;
int flags;
chown_fptr chown_func;
opt_complementary = "-2";
getopt32(argc, argv, OPT_STR);
getopt32(argv, OPT_STR);
argv += optind;
if (OPT_NODEREF) chown_func = lchown;
/* First, check if there is a group name here */
groupName = strchr(*argv, '.'); /* deprecated? */
if (!groupName)
groupName = strchr(*argv, ':');
else
*groupName = ':'; /* replace '.' with ':' */
/* First, try parsing "user[:[group]]" */
if (!groupName) { /* "user" */
ugid.uid = get_ug_id(*argv, xuname2uid);
} else if (groupName == *argv) { /* ":group" */
ugid.gid = get_ug_id(groupName + 1, xgroup2gid);
} else {
if (!groupName[1]) /* "user:" */
*groupName = '\0';
if (!get_uidgid(&ugid, *argv, 1))
bb_error_msg_and_die("unknown user/group %s", *argv);
/* This matches coreutils behavior (almost - see below) */
chown_func = chown;
if (OPT_NODEREF
/* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */
USE_DESKTOP( || (option_mask32 & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
) {
chown_func = lchown;
}
flags = ACTION_DEPTHFIRST; /* match coreutils order */
if (OPT_RECURSE)
flags |= ACTION_RECURSE;
if (OPT_TRAVERSE_TOP)
flags |= ACTION_FOLLOWLINKS_L0; /* -H/-L: follow links on depth 0 */
if (OPT_TRAVERSE)
flags |= ACTION_FOLLOWLINKS; /* follow links if -L */
parse_chown_usergroup_or_die(&ugid, argv[0]);
/* Ok, ready to do the deed now */
argv++;
do {
if (!recursive_action(*argv,
OPT_RECURSE, // recurse
FALSE, // follow links: TODO: -H/-L/-P
FALSE, // depth first
fileAction, // file action
fileAction, // dir action
NULL, // user data
0) // depth
flags, /* flags */
fileAction, /* file action */
fileAction, /* dir action */
chown_func, /* user data */
0) /* depth */
) {
retval = EXIT_FAILURE;
}
@@ -101,3 +107,65 @@ int chown_main(int argc, char **argv)
return retval;
}
/*
Testcase. Run in empty directory.
#!/bin/sh
t1="/tmp/busybox chown"
t2="/usr/bin/chown"
create() {
rm -rf $1; mkdir $1
(
cd $1 || exit 1
mkdir dir dir2
>up
>file
>dir/file
>dir2/file
ln -s dir linkdir
ln -s file linkfile
ln -s ../up dir/linkup
ln -s ../dir2 dir/linkupdir2
)
chown -R 0:0 $1
}
tst() {
create test1
create test2
echo "[$1]" >>test1.out
echo "[$1]" >>test2.out
(cd test1; $t1 $1) >>test1.out 2>&1
(cd test2; $t2 $1) >>test2.out 2>&1
(cd test1; ls -lnR) >out1
(cd test2; ls -lnR) >out2
echo "chown $1" >out.diff
if ! diff -u out1 out2 >>out.diff; then exit 1; fi
rm out.diff
}
tst_for_each() {
tst "$1 1:1 file"
tst "$1 1:1 dir"
tst "$1 1:1 linkdir"
tst "$1 1:1 linkfile"
}
echo "If script produced 'out.diff' file, then at least one testcase failed"
>test1.out
>test2.out
# These match coreutils 6.8:
tst_for_each "-v"
tst_for_each "-vR"
tst_for_each "-vRP"
tst_for_each "-vRL"
tst_for_each "-vRH"
tst_for_each "-vh"
tst_for_each "-vhR"
tst_for_each "-vhRP"
tst_for_each "-vhRL"
tst_for_each "-vhRH"
# Fix `name' in coreutils output
sed 's/`/'"'"'/g' -i test2.out
# Compare us with coreutils output
diff -u test1.out test2.out
*/
+6 -4
View File
@@ -9,8 +9,9 @@
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
#include "busybox.h"
#include "libbb.h"
int chroot_main(int argc, char **argv);
int chroot_main(int argc, char **argv)
{
if (argc < 2) {
@@ -26,12 +27,13 @@ int chroot_main(int argc, char **argv)
++argv;
if (argc == 2) {
argv -= 2;
if (!(*argv = getenv("SHELL"))) {
*argv = (char *) DEFAULT_SHELL;
argv[0] = getenv("SHELL");
if (!argv[0]) {
argv[0] = (char *) DEFAULT_SHELL;
}
argv[1] = (char *) "-i";
}
execvp(*argv, argv);
BB_EXECVP(*argv, argv);
bb_perror_msg_and_die("cannot execute %s", *argv);
}
+6 -5
View File
@@ -6,12 +6,12 @@
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */
#include "busybox.h"
#include "libbb.h"
int cksum_main(int argc, char **argv);
int cksum_main(int argc, char **argv)
{
uint32_t *crc32_table = crc32_filltable(1);
uint32_t *crc32_table = crc32_filltable(NULL, 1);
FILE *fp;
uint32_t crc;
@@ -27,8 +27,9 @@ int cksum_main(int argc, char **argv)
crc = 0;
length = 0;
while ((bytes_read = fread(bb_common_bufsiz1, 1, BUFSIZ, fp)) > 0) {
cp = bb_common_bufsiz1;
#define read_buf bb_common_bufsiz1
while ((bytes_read = fread(read_buf, 1, BUFSIZ, fp)) > 0) {
cp = read_buf;
length += bytes_read;
while (bytes_read--)
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ (*cp++)) & 0xffL];
+31 -44
View File
@@ -7,43 +7,36 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "libbb.h"
#define COMM_OPT_1 0x01
#define COMM_OPT_2 0x02
#define COMM_OPT_3 0x04
/* These three variables control behaviour if non-zero */
static int only_file_1;
static int only_file_2;
static int both;
#define COMM_OPT_1 (1 << 0)
#define COMM_OPT_2 (1 << 1)
#define COMM_OPT_3 (1 << 2)
/* writeline outputs the input given, appropriately aligned according to class */
static void writeline(char *line, int class)
static void writeline(char *line, int class, int flags)
{
if (class == 0) {
if (!only_file_1)
if (flags & COMM_OPT_1)
return;
} else if (class == 1) {
if (!only_file_2)
if (flags & COMM_OPT_2)
return;
if (only_file_1)
if (!(flags & COMM_OPT_1))
putchar('\t');
}
else /*if (class == 2)*/ {
if (!both)
} else /*if (class == 2)*/ {
if (flags & COMM_OPT_3)
return;
if (only_file_1)
if (!(flags & COMM_OPT_1))
putchar('\t');
if (only_file_2)
if (!(flags & COMM_OPT_2))
putchar('\t');
}
fputs(line, stdout);
}
/* This is the real core of the program - lines are compared here */
static void cmp_files(char **infiles)
int comm_main(int argc, char **argv);
int comm_main(int argc, char **argv)
{
#define LINE_LEN 100
#define BB_EOF_0 0x1
@@ -51,12 +44,19 @@ static void cmp_files(char **infiles)
char thisline[2][LINE_LEN];
FILE *streams[2];
int i;
unsigned flags;
opt_complementary = "=2";
flags = getopt32(argv, "123");
argv += optind;
for (i = 0; i < 2; ++i) {
streams[i] = ((infiles[i][0] == '=' && infiles[i][1]) ? stdin : xfopen(infiles[i], "r"));
streams[i] = (argv[i][0] == '-' && !argv[i][1]) ? stdin : xfopen(argv[i], "r");
fgets(thisline[i], LINE_LEN, streams[i]);
}
/* This is the real core of the program - lines are compared here */
while (*thisline[0] || *thisline[1]) {
int order = 0;
@@ -78,11 +78,11 @@ static void cmp_files(char **infiles)
}
if (order == 0 && !i)
writeline(thisline[1], 2);
writeline(thisline[1], 2, flags);
else if (order > 0 && !(i & BB_EOF_1))
writeline(thisline[1], 1);
writeline(thisline[1], 1, flags);
else if (order < 0 && !(i & BB_EOF_0))
writeline(thisline[0], 0);
writeline(thisline[0], 0, flags);
if (i & BB_EOF_0 & BB_EOF_1) {
break;
@@ -91,7 +91,7 @@ static void cmp_files(char **infiles)
i = (i & BB_EOF_0 ? 1 : 0);
while (!feof(streams[i])) {
if ((order < 0 && i) || (order > 0 && !i))
writeline(thisline[i], i);
writeline(thisline[i], i, flags);
fgets(thisline[i], LINE_LEN, streams[i]);
}
break;
@@ -104,23 +104,10 @@ static void cmp_files(char **infiles)
}
}
fclose(streams[0]);
fclose(streams[1]);
}
if (ENABLE_FEATURE_CLEAN_UP) {
fclose(streams[0]);
fclose(streams[1]);
}
int comm_main(int argc, char **argv)
{
unsigned long flags;
flags = getopt32(argc, argv, "123");
if (optind + 2 != argc)
bb_show_usage();
only_file_1 = !(flags & COMM_OPT_1);
only_file_2 = !(flags & COMM_OPT_2);
both = !(flags & COMM_OPT_3);
cmp_files(argv + optind);
exit(EXIT_SUCCESS);
return EXIT_SUCCESS;
}
+14 -3
View File
@@ -3,6 +3,7 @@
* Mini cp implementation for busybox
*
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
* SELinux support by Yuichi Nakamura <ynakam@hitachisoft.jp>
*
* Licensed under GPL v2 or later, see file LICENSE in this tarball for details.
*/
@@ -14,9 +15,13 @@
* Size reduction.
*/
#include "busybox.h"
#include "libbb.h"
#include "libcoreutils/coreutils.h"
/* This is a NOEXEC applet. Be very careful! */
int cp_main(int argc, char **argv);
int cp_main(int argc, char **argv)
{
struct stat source_stat;
@@ -39,8 +44,8 @@ int cp_main(int argc, char **argv)
// -P and -d are the same (-P is POSIX, -d is GNU)
// -r and -R are the same
// -a = -pdR
opt_complementary = "?:l--s:s--l:Pd:rR:apdR";
flags = getopt32(argc, argv, FILEUTILS_CP_OPTSTR "arPHL");
opt_complementary = "l--s:s--l:Pd:rR:apdR";
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPHL");
/* 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
@@ -49,6 +54,12 @@ int cp_main(int argc, char **argv)
if (flags & OPT_H) ... // deref command-line params only
*/
#if ENABLE_SELINUX
if (flags & FILEUTILS_PRESERVE_SECURITY_CONTEXT) {
selinux_or_die();
}
#endif
flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */
if (optind + 2 > argc) {
+8 -6
View File
@@ -9,10 +9,13 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "libbb.h"
/* This is a NOEXEC applet. Be very careful! */
/* option vars */
static const char optstring[] = "b:c:f:d:sn";
static const char optstring[] ALIGN1 = "b:c:f:d:sn";
#define CUT_OPT_BYTE_FLGS (1<<0)
#define CUT_OPT_CHAR_FLGS (1<<1)
#define CUT_OPT_FIELDS_FLGS (1<<2)
@@ -160,20 +163,19 @@ static void cut_file(FILE * file)
}
}
static const char _op_on_field[] = " only when operating on fields";
static const char _op_on_field[] ALIGN1 = " only when operating on fields";
int cut_main(int argc, char **argv);
int cut_main(int argc, char **argv)
{
char *sopt, *ltok;
opt_complementary = "b--bcf:c--bcf:f--bcf";
getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, &ltok);
getopt32(argv, optstring, &sopt, &sopt, &sopt, &ltok);
// argc -= optind;
argv += optind;
if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
bb_error_msg_and_die("expected a list of bytes, characters, or fields");
if (option_mask32 & BB_GETOPT_ERROR)
bb_error_msg_and_die("only one type of list may be specified");
if (option_mask32 & CUT_OPT_DELIM_FLGS) {
if (strlen(ltok) > 1) {
+20 -23
View File
@@ -10,7 +10,7 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include "libbb.h"
/* This 'date' command supports only 2 time setting formats,
all the GNU strftime stuff (its in libc, lets use it),
@@ -32,18 +32,13 @@
#define DATE_OPT_TIMESPEC 0x20
#define DATE_OPT_HINT 0x40
static void xputenv(char *s)
{
if (putenv(s) != 0)
bb_error_msg_and_die(bb_msg_memory_exhausted);
}
static void maybe_set_utc(int opt)
{
if (opt & DATE_OPT_UTC)
xputenv("TZ=UTC0");
putenv((char*)"TZ=UTC0");
}
int date_main(int argc, char **argv);
int date_main(int argc, char **argv)
{
time_t tm;
@@ -56,9 +51,9 @@ int date_main(int argc, char **argv)
char *isofmt_arg;
char *hintfmt_arg;
opt_complementary = "?:d--s:s--d"
opt_complementary = "d--s:s--d"
USE_FEATURE_DATE_ISOFMT(":R--I:I--R");
opt = getopt32(argc, argv, "Rs:ud: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));
@@ -68,15 +63,16 @@ int date_main(int argc, char **argv)
if (!isofmt_arg) {
ifmt = 0; /* default is date */
} else {
const char * const isoformats[] =
{"date", "hours", "minutes", "seconds"};
static const char *const isoformats[] = {
"date", "hours", "minutes", "seconds"
};
for (ifmt = 0; ifmt < 4; ifmt++)
if (!strcmp(isofmt_arg, isoformats[ifmt])) {
break;
}
if (ifmt == 4) /* parse error */
bb_show_usage();
if (!strcmp(isofmt_arg, isoformats[ifmt]))
goto found;
/* parse error */
bb_show_usage();
found: ;
}
}
@@ -206,7 +202,7 @@ int date_main(int argc, char **argv)
date_fmt[i++] = '%';
date_fmt[i++] = 'S';
}
format_utc:
format_utc:
date_fmt[i++] = '%';
date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
}
@@ -218,23 +214,24 @@ format_utc:
i = 22;
goto format_utc;
} else /* default case */
date_fmt = "%a %b %e %H:%M:%S %Z %Y";
date_fmt = (char*)"%a %b %e %H:%M:%S %Z %Y";
}
#define date_buf bb_common_bufsiz1
if (*date_fmt == '\0') {
/* With no format string, just print a blank line */
*bb_common_bufsiz1 = 0;
date_buf[0] = '\0';
} else {
/* Handle special conversions */
if (strncmp(date_fmt, "%f", 2) == 0) {
date_fmt = "%Y.%m.%d-%H:%M:%S";
date_fmt = (char*)"%Y.%m.%d-%H:%M:%S";
}
/* Generate output string */
strftime(bb_common_bufsiz1, 200, date_fmt, &tm_time);
strftime(date_buf, sizeof(date_buf), date_fmt, &tm_time);
}
puts(bb_common_bufsiz1);
puts(date_buf);
return EXIT_SUCCESS;
}
+187 -101
View File
@@ -8,8 +8,11 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "busybox.h"
#include <signal.h> /* For FEATURE_DD_SIGNAL_HANDLING */
#include "libbb.h"
/* This is a NOEXEC applet. Be very careful! */
static const struct suffix_mult dd_suffixes[] = {
{ "c", 1 },
@@ -17,26 +20,33 @@ static const struct suffix_mult dd_suffixes[] = {
{ "b", 512 },
{ "kD", 1000 },
{ "k", 1024 },
{ "K", 1024 }, // compat with coreutils dd
{ "K", 1024 }, /* compat with coreutils dd */
{ "MD", 1000000 },
{ "M", 1048576 },
{ "GD", 1000000000 },
{ "G", 1073741824 },
{ NULL, 0 }
{ }
};
static off_t out_full, out_part, in_full, in_part;
struct globals {
off_t out_full, out_part, in_full, in_part;
};
#define G (*(struct globals*)&bb_common_bufsiz1)
/* We have to zero it out because of NOEXEC */
#define INIT_G() memset(&G, 0, sizeof(G))
static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal)
{
fprintf(stderr, "%"OFF_FMT"d+%"OFF_FMT"d records in\n"
"%"OFF_FMT"d+%"OFF_FMT"d records out\n",
in_full, in_part,
out_full, out_part);
/* Deliberately using %u, not %d */
fprintf(stderr, "%"OFF_FMT"u+%"OFF_FMT"u records in\n"
"%"OFF_FMT"u+%"OFF_FMT"u records out\n",
G.in_full, G.in_part,
G.out_full, G.out_part);
}
static ssize_t full_write_or_warn(int fd, const void *buf, size_t len,
const char* filename)
const char *const filename)
{
ssize_t n = full_write(fd, buf, len);
if (n < 0)
@@ -44,103 +54,193 @@ static ssize_t full_write_or_warn(int fd, const void *buf, size_t len,
return n;
}
static bool write_and_stats(int fd, const void *buf, size_t len, size_t obs,
const char *filename)
{
ssize_t n = full_write_or_warn(fd, buf, len, filename);
if (n < 0)
return 1;
if (n == obs)
G.out_full++;
else if (n) /* > 0 */
G.out_part++;
return 0;
}
#if ENABLE_LFS
#define XATOU_SFX xatoull_sfx
#else
#define XATOU_SFX xatoul_sfx
#endif
int dd_main(int argc, char **argv);
int dd_main(int argc, char **argv)
{
enum {
sync_flag = 1 << 0,
noerror = 1 << 1,
trunc_flag = 1 << 2,
twobufs_flag = 1 << 3,
FLAG_SYNC = 1 << 0,
FLAG_NOERROR = 1 << 1,
FLAG_NOTRUNC = 1 << 2,
FLAG_TWOBUFS = 1 << 3,
FLAG_COUNT = 1 << 4,
};
int flags = trunc_flag;
size_t oc = 0, ibs = 512, obs = 512;
static const char keywords[] ALIGN1 =
"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"
#endif
;
enum {
OP_bs = 1,
OP_count,
OP_seek,
OP_skip,
OP_if,
OP_of,
#if ENABLE_FEATURE_DD_IBS_OBS
OP_ibs,
OP_obs,
OP_conv,
OP_conv_notrunc,
OP_conv_sync,
OP_conv_noerror,
#endif
};
size_t ibs = 512, obs = 512;
ssize_t n, w;
off_t seek = 0, skip = 0, count = OFF_T_MAX;
int oflag, ifd, ofd;
const char *infile = NULL, *outfile = NULL;
char *ibuf, *obuf;
/* And these are all zeroed at once! */
struct {
int flags;
int ifd, ofd;
size_t oc;
off_t count;
off_t seek, skip;
const char *infile, *outfile;
#if ENABLE_FEATURE_DD_SIGNAL_HANDLING
struct sigaction sigact;
#endif
} Z;
#define flags (Z.flags )
#define ifd (Z.ifd )
#define ofd (Z.ofd )
#define oc (Z.oc )
#define count (Z.count )
#define seek (Z.seek )
#define skip (Z.skip )
#define infile (Z.infile )
#define outfile (Z.outfile)
#define sigact (Z.sigact )
if (ENABLE_FEATURE_DD_SIGNAL_HANDLING) {
struct sigaction sa;
memset(&Z, 0, sizeof(Z));
INIT_G();
memset(&sa, 0, sizeof(sa));
sa.sa_handler = dd_output_status;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGUSR1, &sa, 0);
}
#if ENABLE_FEATURE_DD_SIGNAL_HANDLING
sigact.sa_handler = dd_output_status;
sigact.sa_flags = SA_RESTART;
sigemptyset(&sigact.sa_mask);
sigaction(SIGUSR1, &sigact, NULL);
#endif
for (n = 1; n < argc; n++) {
smalluint key_len;
smalluint what;
char *key;
char *arg = argv[n];
/* Must fit into positive ssize_t */
if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("ibs=", arg, 4))
ibs = xatoul_range_sfx(arg+4, 0, ((size_t)-1L)/2, dd_suffixes);
else if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("obs=", arg, 4))
obs = xatoul_range_sfx(arg+4, 0, ((size_t)-1L)/2, dd_suffixes);
else if (!strncmp("bs=", arg, 3))
ibs = obs = xatoul_range_sfx(arg+3, 0, ((size_t)-1L)/2, dd_suffixes);
/* These can be large: */
else if (!strncmp("count=", arg, 6))
count = XATOU_SFX(arg+6, dd_suffixes);
else if (!strncmp("seek=", arg, 5))
seek = XATOU_SFX(arg+5, dd_suffixes);
else if (!strncmp("skip=", arg, 5))
skip = XATOU_SFX(arg+5, dd_suffixes);
else if (!strncmp("if=", arg, 3))
infile = arg+3;
else if (!strncmp("of=", arg, 3))
outfile = arg+3;
else if (ENABLE_FEATURE_DD_IBS_OBS && !strncmp("conv=", arg, 5)) {
arg += 5;
while (1) {
if (!strncmp("notrunc", arg, 7)) {
flags &= ~trunc_flag;
arg += 7;
} else if (!strncmp("sync", arg, 4)) {
flags |= sync_flag;
arg += 4;
} else if (!strncmp("noerror", arg, 7)) {
flags |= noerror;
arg += 7;
} else {
bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv");
}
if (arg[0] == '\0') break;
if (*arg++ != ',') bb_show_usage();
}
} else
//XXX:FIXME: we reject plain "dd --" This would cost ~20 bytes, so..
//if (*arg == '-' && *++arg == '-' && !*++arg) continue;
key = strstr(arg, "=");
if (key == 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)
bb_show_usage();
arg += key_len;
/* Must fit into positive ssize_t */
#if ENABLE_FEATURE_DD_IBS_OBS
if (what == OP_ibs) {
ibs = xatoul_range_sfx(arg, 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;
}
if (what == OP_conv) {
while (1) {
/* find ',', replace them with nil so we can use arg for
* index_in_strings() without copying.
* We rely on arg 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 */
break;
arg = key + 1; /* skip this keyword and ',' */
}
continue;
}
#endif
if (what == OP_bs) {
ibs = obs = xatoul_range_sfx(arg, 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;
}
if (what == OP_seek) {
seek = XATOU_SFX(arg, dd_suffixes);
continue;
}
if (what == OP_skip) {
skip = XATOU_SFX(arg, dd_suffixes);
continue;
}
if (what == OP_if) {
infile = arg;
continue;
}
if (what == OP_of)
outfile = arg;
}
//XXX:FIXME for huge ibs or obs, malloc'ing them isn't the brightest idea ever
ibuf = obuf = xmalloc(ibs);
if (ibs != obs) {
flags |= twobufs_flag;
flags |= FLAG_TWOBUFS;
obuf = xmalloc(obs);
}
if (infile != NULL)
ifd = xopen(infile, O_RDONLY);
else {
ifd = STDIN_FILENO;
/* ifd = STDIN_FILENO; - it's zero and it's already there */
infile = bb_msg_standard_input;
}
if (outfile != NULL) {
oflag = O_WRONLY | O_CREAT;
int oflag = O_WRONLY | O_CREAT;
if (!seek && (flags & trunc_flag))
if (!seek && !(flags & FLAG_NOTRUNC))
oflag |= O_TRUNC;
ofd = xopen(outfile, oflag);
if (seek && (flags & trunc_flag)) {
if (seek && !(flags & FLAG_NOTRUNC)) {
if (ftruncate(ofd, seek * obs) < 0) {
struct stat st;
@@ -153,50 +253,45 @@ int dd_main(int argc, char **argv)
ofd = STDOUT_FILENO;
outfile = bb_msg_standard_output;
}
if (skip) {
if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) {
while (skip-- > 0) {
n = safe_read(ifd, ibuf, ibs);
if (n < 0)
bb_perror_msg_and_die("%s", infile);
goto die_infile;
if (n == 0)
break;
}
}
}
if (seek) {
if (lseek(ofd, seek * obs, SEEK_CUR) < 0)
goto die_outfile;
}
while (in_full + in_part != count) {
if (flags & noerror) {
/* Pre-zero the buffer when doing the noerror thing */
memset(ibuf, '\0', ibs);
}
while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) {
if (flags & FLAG_NOERROR) /* Pre-zero the buffer if conv=noerror */
memset(ibuf, 0, ibs);
n = safe_read(ifd, ibuf, ibs);
if (n == 0)
break;
if (n < 0) {
if (flags & noerror) {
if (flags & FLAG_NOERROR) {
n = ibs;
bb_perror_msg("%s", infile);
} else
bb_perror_msg_and_die("%s", infile);
goto die_infile;
}
if ((size_t)n == ibs)
in_full++;
G.in_full++;
else {
in_part++;
if (flags & sync_flag) {
G.in_part++;
if (flags & FLAG_SYNC) {
memset(ibuf + n, '\0', ibs - n);
n = ibs;
}
}
if (flags & twobufs_flag) {
if (flags & FLAG_TWOBUFS) {
char *tmp = ibuf;
while (n) {
size_t d = obs - oc;
@@ -208,32 +303,23 @@ int dd_main(int argc, char **argv)
tmp += d;
oc += d;
if (oc == obs) {
w = full_write_or_warn(ofd, obuf, obs, outfile);
if (w < 0) goto out_status;
if (w == obs)
out_full++;
else if (w > 0)
out_part++;
if (write_and_stats(ofd, obuf, obs, obs, outfile))
goto out_status;
oc = 0;
}
}
} else {
w = full_write_or_warn(ofd, ibuf, n, outfile);
if (w < 0) goto out_status;
if (w == obs)
out_full++;
else if (w > 0)
out_part++;
}
} else if (write_and_stats(ofd, ibuf, n, obs, outfile))
goto out_status;
}
if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
w = full_write_or_warn(ofd, obuf, oc, outfile);
if (w < 0) goto out_status;
if (w > 0)
out_part++;
G.out_part++;
}
if (close(ifd) < 0) {
die_infile:
bb_perror_msg_and_die("%s", infile);
}
+31 -34
View File
@@ -18,39 +18,36 @@
* the command line. Properly round *-blocks, Used, and Available quantities.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <mntent.h>
#include <sys/vfs.h>
#include "busybox.h"
#include "libbb.h"
#ifndef CONFIG_FEATURE_HUMAN_READABLE
static long kscale(long b, long bs)
#if !ENABLE_FEATURE_HUMAN_READABLE
static unsigned long kscale(unsigned long b, unsigned long bs)
{
return ( b * (long long) bs + 1024/2 ) / 1024;
return (b * (unsigned long long) bs + 1024/2) / 1024;
}
#endif
int df_main(int argc, char **argv);
int df_main(int argc, char **argv)
{
long blocks_used;
long blocks_percent_used;
#ifdef CONFIG_FEATURE_HUMAN_READABLE
unsigned long df_disp_hr = 1024;
unsigned long blocks_used;
unsigned blocks_percent_used;
#if ENABLE_FEATURE_HUMAN_READABLE
unsigned df_disp_hr = 1024;
#endif
int status = EXIT_SUCCESS;
unsigned opt;
FILE *mount_table;
struct mntent *mount_entry;
struct statfs s;
static const char hdr_1k[] = "1k-blocks"; /* default display is kilobytes */
const char *disp_units_hdr = hdr_1k;
/* default display is kilobytes */
const char *disp_units_hdr = "1k-blocks";
#ifdef CONFIG_FEATURE_HUMAN_READABLE
#if ENABLE_FEATURE_HUMAN_READABLE
opt_complementary = "h-km:k-hm:m-hk";
opt = getopt32(argc, argv, "hmk");
opt = getopt32(argv, "hmk");
if (opt & 1) {
df_disp_hr = 0;
disp_units_hdr = " Size";
@@ -60,7 +57,7 @@ int df_main(int argc, char **argv)
disp_units_hdr = "1M-blocks";
}
#else
opt = getopt32(argc, argv, "k");
opt = getopt32(argv, "k");
#endif
printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
@@ -75,7 +72,7 @@ int df_main(int argc, char **argv)
}
}
do {
while (1) {
const char *device;
const char *mount_point;
@@ -111,7 +108,7 @@ int df_main(int argc, char **argv)
blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = 0;
if (blocks_used + s.f_bavail) {
blocks_percent_used = (((long long) blocks_used) * 100
blocks_percent_used = (blocks_used * 100ULL
+ (blocks_used + s.f_bavail)/2
) / (blocks_used + s.f_bavail);
}
@@ -127,28 +124,28 @@ int df_main(int argc, char **argv)
}
}
#ifdef CONFIG_FEATURE_HUMAN_READABLE
printf("%-20s %9s ", device,
if (printf("\n%-20s" + 1, device) > 20)
printf("\n%-20s", "");
#if ENABLE_FEATURE_HUMAN_READABLE
printf(" %9s ",
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
printf("%9s ",
make_human_readable_str( (s.f_blocks - s.f_bfree),
printf(" %9s " + 1,
make_human_readable_str((s.f_blocks - s.f_bfree),
s.f_bsize, df_disp_hr));
printf("%9s %3ld%% %s\n",
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
printf("%9s %3u%% %s\n",
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
kscale(s.f_blocks, s.f_bsize),
kscale(s.f_blocks-s.f_bfree, s.f_bsize),
kscale(s.f_bavail, s.f_bsize),
blocks_percent_used, mount_point);
printf(" %9lu %9lu %9lu %3u%% %s\n",
kscale(s.f_blocks, s.f_bsize),
kscale(s.f_blocks-s.f_bfree, s.f_bsize),
kscale(s.f_bavail, s.f_bsize),
blocks_percent_used, mount_point);
#endif
}
} while (1);
}
fflush_stdout_and_exit(status);
}
+5 -4
View File
@@ -10,10 +10,11 @@
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/dirname.html */
#include <stdio.h>
#include <stdlib.h>
#include "busybox.h"
#include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
int dirname_main(int argc, char **argv);
int dirname_main(int argc, char **argv)
{
if (argc != 2) {
@@ -22,5 +23,5 @@ int dirname_main(int argc, char **argv)
puts(dirname(argv[1]));
fflush_stdout_and_exit(EXIT_SUCCESS);
return fflush(stdout);
}
+34 -38
View File
@@ -12,51 +12,47 @@
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
#include "busybox.h"
#include "libbb.h"
enum ConvType {
enum {
CT_UNIX2DOS = 1,
CT_DOS2UNIX
} ConvType;
};
/* if fn is NULL then input is stdin and output is stdout */
static int convert(char *fn)
static int convert(char *fn, int conv_type)
{
FILE *in, *out;
int i;
#define name_buf bb_common_bufsiz1
in = stdin;
out = stdout;
if (fn != NULL) {
in = xfopen(fn, "rw");
/*
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.
0600 for glibc 2.0.7 and later.
*/
snprintf(bb_common_bufsiz1, sizeof(bb_common_bufsiz1), "%sXXXXXX", fn);
/*
sizeof bb_common_bufsiz1 is 4096, so it should be big enough to
hold the full path. However if the output is truncated the
subsequent call to mkstemp would fail.
*/
if ((i = mkstemp(&bb_common_bufsiz1[0])) == -1
|| chmod(bb_common_bufsiz1, 0600) == -1) {
snprintf(name_buf, sizeof(name_buf), "%sXXXXXX", fn);
i = mkstemp(&name_buf[0]);
if (i == -1 || chmod(name_buf, 0600) == -1) {
bb_perror_nomsg_and_die();
}
out = fdopen(i, "w+");
if (!out) {
close(i);
remove(bb_common_bufsiz1);
remove(name_buf);
return -2;
}
} else {
in = stdin;
out = stdout;
}
while ((i = fgetc(in)) != EOF) {
if (i == '\r')
continue;
if (i == '\n') {
if (ConvType == CT_UNIX2DOS)
if (conv_type == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
continue;
@@ -67,14 +63,14 @@ static int convert(char *fn)
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0) {
bb_perror_nomsg();
remove(bb_common_bufsiz1);
remove(name_buf);
return -2;
}
/* Assume they are both on the same filesystem (which
* should be true since we put them into the same directory
* so we _should_ be ok, but you never know... */
if (rename(bb_common_bufsiz1, fn) < 0) {
bb_perror_msg("cannot rename '%s' as '%s'", bb_common_bufsiz1, fn);
if (rename(name_buf, fn) < 0) {
bb_perror_msg("cannot rename '%s' as '%s'", name_buf, fn);
return -1;
}
}
@@ -82,34 +78,34 @@ static int convert(char *fn)
return 0;
}
int dos2unix_main(int argc, char *argv[])
int dos2unix_main(int argc, char **argv);
int dos2unix_main(int argc, char **argv)
{
int o;
int o, conv_type;
/* See if we are supposed to be doing dos2unix or unix2dos */
if (applet_name[0] == 'd') {
ConvType = CT_DOS2UNIX; /*2 */
conv_type = CT_DOS2UNIX; /* 2 */
} else {
ConvType = CT_UNIX2DOS; /*1 */
conv_type = CT_UNIX2DOS; /* 1 */
}
/* -u and -d are mutally exclusive */
opt_complementary = "?:u--d:d--u";
/* process parameters */
/* -u convert to unix */
/* -d convert to dos */
o = getopt32(argc, argv, "du");
/* -u convert to unix, -d convert to dos */
opt_complementary = "u--d:d--u"; /* mutually exclusive */
o = getopt32(argv, "du");
/* Do the conversion requested by an argument else do the default
* conversion depending on our name. */
if (o)
ConvType = o;
conv_type = o;
if (optind < argc) {
while (optind < argc)
if ((o = convert(argv[optind++])) < 0)
break;
} else
o = convert(NULL);
do {
/* might be convert(NULL) if there is no filename given */
o = convert(argv[optind], conv_type);
if (o < 0)
break;
optind++;
} while (optind < argc);
return o;
}
+10 -11
View File
@@ -23,7 +23,7 @@
* 4) Fixed busybox bug #1284 involving long overflow with human_readable.
*/
#include "busybox.h"
#include "libbb.h"
#if ENABLE_FEATURE_HUMAN_READABLE
# if ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
@@ -48,7 +48,7 @@ static int one_file_system;
static dev_t dir_dev;
static void print(long size, const char * const filename)
static void print(long size, const char *const filename)
{
/* TODO - May not want to defer error checking here. */
#if ENABLE_FEATURE_HUMAN_READABLE
@@ -64,7 +64,7 @@ static void print(long size, const char * const filename)
}
/* tiny recursive du */
static long du(const char * const filename)
static long du(const char *const filename)
{
struct stat statbuf;
long sum;
@@ -101,7 +101,7 @@ static long du(const char * const filename)
if (statbuf.st_nlink > count_hardlinks) {
/* Add files/directories with links only once */
if (is_in_ino_dev_hashtable(&statbuf, NULL)) {
if (is_in_ino_dev_hashtable(&statbuf)) {
return 0;
}
add_to_ino_dev_hashtable(&statbuf, NULL);
@@ -143,6 +143,7 @@ static long du(const char * const filename)
return sum;
}
int du_main(int argc, char **argv);
int du_main(int argc, char **argv)
{
long total;
@@ -169,7 +170,7 @@ int du_main(int argc, char **argv)
*/
#if ENABLE_FEATURE_HUMAN_READABLE
opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
opt = getopt32(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
if (opt & (1 << 9)) {
/* -h opt */
disp_hr = 0;
@@ -184,7 +185,7 @@ int du_main(int argc, char **argv)
}
#else
opt_complementary = "H-L:L-H:s-d:d-s";
opt = getopt32(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
opt = getopt32(argv, "aHkLsx" "d:" "lc", &smax_print_depth);
#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
if (opt & (1 << 2)) {
/* -k opt */
@@ -222,7 +223,7 @@ int du_main(int argc, char **argv)
/* go through remaining args (if any) */
argv += optind;
if (optind >= argc) {
*--argv = ".";
*--argv = (char*)".";
if (slink_depth == 1) {
slink_depth = 0;
}
@@ -234,10 +235,8 @@ int du_main(int argc, char **argv)
total += du(*argv);
slink_depth = slink_depth_save;
} while (*++argv);
#if ENABLE_FEATURE_CLEAN_UP
reset_ino_dev_hashtable();
#endif
if (ENABLE_FEATURE_CLEAN_UP)
reset_ino_dev_hashtable();
if (print_final_total) {
print(total, "total");
}
+51 -44
View File
@@ -20,102 +20,109 @@
* 1) In handling '\c' escape, the previous version only suppressed the
* trailing newline. SUSv3 specifies _no_ output after '\c'.
* 2) SUSv3 specifies that octal escapes are of the form \0{#{#{#}}}.
* The previous version version did not allow 4-digit octals.
* The previous version did not allow 4-digit octals.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "busybox.h"
#include "libbb.h"
int bb_echo(char **argv)
{
#ifndef CONFIG_FEATURE_FANCY_ECHO
#define eflag '\\'
++argv;
const char *arg;
#if !ENABLE_FEATURE_FANCY_ECHO
enum {
eflag = '\\',
nflag = 1, /* 1 -- print '\n' */
};
arg = *++argv;
if (!arg)
goto newline_ret;
#else
const char *p;
int nflag = 1;
int eflag = 0;
char nflag = 1;
char eflag = 0;
while (1) {
arg = *++argv;
if (!arg)
goto newline_ret;
if (*arg != '-')
break;
while (*++argv && (**argv == '-')) {
/* If it appears that we are handling options, then make sure
* that all of the options specified are actually valid.
* Otherwise, the string should just be echoed.
*/
if (!*(p = *argv + 1)) { /* A single '-', so echo it. */
p = arg + 1;
if (!*p) /* A single '-', so echo it. */
goto just_echo;
}
do {
if (strrchr("neE", *p) == 0) {
if (!strrchr("neE", *p))
goto just_echo;
}
} while (*++p);
/* All of the options in this arg are valid, so handle them. */
p = *argv + 1;
p = arg + 1;
do {
if (*p == 'n') {
if (*p == 'n')
nflag = 0;
} else if (*p == 'e') {
if (*p == 'e')
eflag = '\\';
} else {
eflag = 0;
}
} while (*++p);
}
just_echo:
just_echo:
#endif
while (*argv) {
while (1) {
/* arg is already == *argv and isn't NULL */
int c;
while ((c = *(*argv)++)) {
if (!eflag) {
/* optimization for very common case */
fputs(arg, stdout);
} else while ((c = *arg++)) {
if (c == eflag) { /* Check for escape seq. */
if (**argv == 'c') {
if (*arg == 'c') {
/* '\c' means cancel newline and
* ignore all subsequent chars. */
return 0;
goto ret;
}
#ifndef CONFIG_FEATURE_FANCY_ECHO
#if !ENABLE_FEATURE_FANCY_ECHO
/* SUSv3 specifies that octal escapes must begin with '0'. */
if (((unsigned int)(**argv - '1')) >= 7)
if ( (((unsigned char)*arg) - '1') >= 7)
#endif
{
/* Since SUSv3 mandates a first digit of 0, 4-digit octals
* of the form \0### are accepted. */
if ((**argv == '0') && (((unsigned int)(argv[0][1] - '0')) < 8)) {
(*argv)++;
if (*arg == '0' && ((unsigned char)(arg[1]) - '0') < 8) {
arg++;
}
/* bb_process_escape_sequence can handle nul correctly */
c = bb_process_escape_sequence((const char **) argv);
c = bb_process_escape_sequence(&arg);
}
}
putchar(c);
}
if (*++argv) {
putchar(' ');
}
arg = *++argv;
if (!arg)
break;
putchar(' ');
}
#ifdef CONFIG_FEATURE_FANCY_ECHO
newline_ret:
if (nflag) {
putchar('\n');
}
#else
putchar('\n');
#endif
return 0;
ret:
return fflush(stdout);
}
/* This is a NOFORK applet. Be very careful! */
int echo_main(int argc, char** argv);
int echo_main(int argc, char** argv)
{
(void)bb_echo(argv);
fflush_stdout_and_exit(EXIT_SUCCESS);
return bb_echo(argv);
}
/*-
+16 -18
View File
@@ -29,43 +29,41 @@
* - use xfunc_error_retval
*/
#include "busybox.h"
#include <errno.h>
#include <getopt.h> /* struct option */
extern char **environ;
#include "libbb.h"
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
static const struct option env_long_options[] = {
{ "ignore-environment", 0, NULL, 'i' },
{ "unset", 1, NULL, 'u' },
{ 0, 0, 0, 0 }
};
static const char env_longopts[] ALIGN1 =
"ignore-environment\0" No_argument "i"
"unset\0" Required_argument "u"
;
#endif
int env_main(int argc, char** argv);
int env_main(int argc, char** argv)
{
static char *cleanenv[1] = { NULL };
/* cleanenv was static - why? */
char *cleanenv[1];
char **ep;
unsigned opt;
llist_t *unset_env = NULL;
extern char **environ;
opt_complementary = "u::";
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
applet_long_options = env_long_options;
applet_long_options = env_longopts;
#endif
opt = getopt32(argc, argv, "+iu:", &unset_env);
opt = getopt32(argv, "+iu:", &unset_env);
argv += optind;
if (*argv && LONE_DASH(argv[0])) {
opt |= 1;
++argv;
}
if (opt & 1)
if (opt & 1) {
cleanenv[0] = NULL;
environ = cleanenv;
else if (opt & 2) {
} else {
while (unset_env) {
unsetenv(unset_env->data);
unset_env = unset_env->link;
@@ -80,7 +78,7 @@ int env_main(int argc, char** argv)
}
if (*argv) {
execvp(*argv, argv);
BB_EXECVP(*argv, argv);
/* SUSv3-mandated exit codes. */
xfunc_error_retval = (errno == ENOENT) ? 127 : 126;
bb_perror_msg_and_die("%s", *argv);
+209
View File
@@ -0,0 +1,209 @@
/* expand - convert tabs to spaces
* unexpand - convert spaces to tabs
*
* Copyright (C) 89, 91, 1995-2006 Free Software Foundation, Inc.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* David MacKenzie <djm@gnu.ai.mit.edu>
*
* Options for expand:
* -t num --tabs=NUM Convert tabs to num spaces (default 8 spaces).
* -i --initial Only convert initial tabs on each line to spaces.
*
* Options for unexpand:
* -a --all Convert all blanks, instead of just initial blanks.
* -f --first-only Convert only leading sequences of blanks (default).
* -t num --tabs=NUM Have tabs num characters apart instead of 8.
*
* Busybox version (C) 2007 by Tito Ragusa <farmatito@tiscali.it>
*
* Caveat: this versions of expand and unexpand don't accept tab lists.
*/
#include "libbb.h"
enum {
OPT_INITIAL = 1 << 0,
OPT_TABS = 1 << 1,
OPT_ALL = 1 << 2,
};
static void xputchar(char c)
{
if (putchar(c) < 0)
bb_error_msg_and_die(bb_msg_write_error);
}
#if ENABLE_EXPAND
static void expand(FILE *file, unsigned tab_size, unsigned opt)
{
char *line;
char *ptr;
int convert;
int pos;
/* Increment tab_size by 1 locally.*/
tab_size++;
while ((line = xmalloc_fgets(file)) != NULL) {
convert = 1;
pos = 0;
ptr = line;
while (*line) {
pos++;
if (*line == '\t' && convert) {
for (; pos < tab_size; pos++) {
xputchar(' ');
}
} else {
if ((opt & OPT_INITIAL) && !isblank(*line)) {
convert = 0;
}
xputchar(*line);
}
if (pos == tab_size) {
pos = 0;
}
line++;
}
free(ptr);
}
}
#endif
#if ENABLE_UNEXPAND
static void unexpand(FILE *file, unsigned int tab_size, unsigned opt)
{
char *line;
char *ptr;
int convert;
int pos;
int i = 0;
int column = 0;
while ((line = xmalloc_fgets(file)) != NULL) {
convert = 1;
pos = 0;
ptr = line;
while (*line) {
while ((*line == ' ' || *line == '\t') && convert) {
pos += (*line == ' ') ? 1 : tab_size;
line++;
column++;
if ((opt & OPT_ALL) && column == tab_size) {
column = 0;
goto put_tab;
}
}
if (pos) {
i = pos / tab_size;
if (i) {
for (; i > 0; i--) {
put_tab:
xputchar('\t');
}
} else {
for (i = pos % tab_size; i > 0; i--) {
xputchar(' ');
}
}
pos = 0;
} else {
if (opt & OPT_INITIAL) {
convert = 0;
}
if (opt & OPT_ALL) {
column++;
}
xputchar(*line);
line++;
}
}
free(ptr);
}
}
#endif
int expand_main(int argc, char **argv);
int expand_main(int argc, char **argv)
{
/* Default 8 spaces for 1 tab */
const char *opt_t = "8";
FILE *file;
unsigned tab_size;
unsigned opt;
int exit_status = EXIT_SUCCESS;
#if ENABLE_FEATURE_EXPAND_LONG_OPTIONS
static const char expand_longopts[] ALIGN1 =
/* name, has_arg, val */
"initial\0" No_argument "i"
"tabs\0" Required_argument "t"
;
#endif
#if ENABLE_FEATURE_UNEXPAND_LONG_OPTIONS
static const char unexpand_longopts[] ALIGN1 =
/* name, has_arg, val */
"first-only\0" No_argument "i"
"tabs\0" Required_argument "t"
"all\0" No_argument "a"
;
#endif
if (ENABLE_EXPAND && (!ENABLE_UNEXPAND || applet_name[0] == 'e')) {
USE_FEATURE_EXPAND_LONG_OPTIONS(applet_long_options = expand_longopts);
opt = getopt32(argv, "it:", &opt_t);
} else if (ENABLE_UNEXPAND) {
USE_FEATURE_UNEXPAND_LONG_OPTIONS(applet_long_options = unexpand_longopts);
/* -t NUM sets also -a */
opt_complementary = "ta";
opt = getopt32(argv, "ft:a", &opt_t);
/* -f --first-only is the default */
if (!(opt & OPT_ALL)) opt |= OPT_INITIAL;
}
tab_size = xatou_range(opt_t, 1, UINT_MAX);
argv += optind;
/* If no args are given, read from stdin */
if (!*argv) {
*--argv = (char*)bb_msg_standard_input;
goto use_stdin;
}
do {
if (NOT_LONE_CHAR(*argv, '-')) {
file = fopen_or_warn(*argv, "r");
if (!file) {
exit_status = EXIT_FAILURE;
continue;
}
} else {
use_stdin:
file = stdin;
}
if (ENABLE_EXPAND && (!ENABLE_UNEXPAND || applet_name[0] == 'e'))
USE_EXPAND(expand(file, tab_size, opt));
else if (ENABLE_UNEXPAND)
USE_UNEXPAND(unexpand(file, tab_size, opt));
/* Check and close the file */
/* We do want all of them to execute, thus | instead of || */
if (ferror(file) | fclose_if_not_stdin(file)) {
bb_perror_msg("%s", *argv);
exit_status = EXIT_FAILURE;
}
/* If stdin also clear EOF */
if (file == stdin)
clearerr(file);
} while (*++argv);
/* Now close stdin also */
/* (if we didn't read from it, it's a no-op) */
if (fclose(stdin))
bb_perror_msg_and_die(bb_msg_standard_input);
fflush_stdout_and_exit(exit_status);
}
+82 -80
View File
@@ -25,7 +25,7 @@
/* no getopt needed */
#include "busybox.h"
#include "libbb.h"
#include "xregex.h"
/* The kinds of value we can have. */
@@ -62,39 +62,14 @@ struct valinfo {
typedef struct valinfo VALUE;
/* The arguments given to the program, minus the program name. */
static char **args;
struct globals {
char **args;
};
#define G (*(struct globals*)&bb_common_bufsiz1)
static VALUE *docolon(VALUE * sv, VALUE * pv);
/* forward declarations */
static VALUE *eval(void);
static VALUE *int_value(arith_t i);
static VALUE *str_value(char *s);
static int nextarg(char *str);
static int null(VALUE * v);
static int toarith(VALUE * v);
static void freev(VALUE * v);
static void tostring(VALUE * v);
int expr_main(int argc, char **argv)
{
VALUE *v;
if (argc == 1) {
bb_error_msg_and_die("too few arguments");
}
args = argv + 1;
v = eval();
if (*args)
bb_error_msg_and_die("syntax error");
if (v->type == integer)
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
else
puts(v->u.s);
fflush_stdout_and_exit(null(v));
}
/* Return a VALUE for I. */
@@ -110,7 +85,7 @@ static VALUE *int_value(arith_t i)
/* Return a VALUE for S. */
static VALUE *str_value(char *s)
static VALUE *str_value(const char *s)
{
VALUE *v;
@@ -135,8 +110,8 @@ static int null(VALUE * v)
{
if (v->type == integer)
return v->u.i == 0;
else /* string: */
return v->u.s[0] == '\0' || LONE_CHAR(v->u.s, '0');
/* string: */
return v->u.s[0] == '\0' || LONE_CHAR(v->u.s, '0');
}
/* Coerce V to a string value (can't fail). */
@@ -151,7 +126,7 @@ static void tostring(VALUE * v)
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
static int toarith(VALUE * v)
static bool toarith(VALUE * v)
{
if (v->type == string) {
arith_t i;
@@ -172,11 +147,11 @@ static int toarith(VALUE * v)
/* Return nonzero if the next token matches STR exactly.
STR must not be NULL. */
static int nextarg(char *str)
static bool nextarg(const char *str)
{
if (*args == NULL)
if (*G.args == NULL)
return 0;
return strcmp(*args, str) == 0;
return strcmp(*G.args, str) == 0;
}
/* The comparison operator handling functions. */
@@ -193,16 +168,16 @@ static int cmp_common(VALUE * l, VALUE * r, int op)
cmpval = l->u.i - r->u.i;
if (op == '<')
return cmpval < 0;
else if (op == ('L' + 'E'))
if (op == ('L' + 'E'))
return cmpval <= 0;
else if (op == '=')
if (op == '=')
return cmpval == 0;
else if (op == '!')
if (op == '!')
return cmpval != 0;
else if (op == '>')
if (op == '>')
return cmpval > 0;
else /* >= */
return cmpval >= 0;
/* >= */
return cmpval >= 0;
}
/* The arithmetic operator handling functions. */
@@ -244,15 +219,14 @@ static VALUE *docolon(VALUE * sv, VALUE * pv)
tostring(pv);
if (pv->u.s[0] == '^') {
fprintf(stderr, "\
bb_error_msg("\
warning: unportable BRE: `%s': using `^' as the first character\n\
of a basic regular expression is not portable; it is being ignored", pv->u.s);
}
memset(&re_buffer, 0, sizeof(re_buffer));
memset(re_regs, 0, sizeof(*re_regs));
if (regcomp(&re_buffer, pv->u.s, 0) != 0)
bb_error_msg_and_die("invalid regular expression");
xregcomp(&re_buffer, pv->u.s, 0);
/* expr uses an anchored pattern match, so check that there was a
* match and that the match starts at offset 0. */
@@ -271,6 +245,7 @@ of a basic regular expression is not portable; it is being ignored", pv->u.s);
else
v = int_value(0);
}
//FIXME: sounds like here is a bit missing: regfree(&re_buffer);
return v;
}
@@ -280,53 +255,59 @@ static VALUE *eval7(void)
{
VALUE *v;
if (!*args)
if (!*G.args)
bb_error_msg_and_die("syntax error");
if (nextarg("(")) {
args++;
G.args++;
v = eval();
if (!nextarg(")"))
bb_error_msg_and_die("syntax error");
args++;
G.args++;
return v;
}
if (nextarg(")"))
bb_error_msg_and_die("syntax error");
return str_value(*args++);
return str_value(*G.args++);
}
/* Handle match, substr, index, length, and quote keywords. */
static VALUE *eval6(void)
{
VALUE *l, *r, *v, *i1, *i2;
static const char keywords[] ALIGN1 =
"quote\0""length\0""match\0""index\0""substr\0";
if (nextarg("quote")) {
args++;
if (!*args)
VALUE *r, *i1, *i2;
VALUE *l = l; /* silence gcc */
VALUE *v = v; /* silence gcc */
int key = *G.args ? index_in_strings(keywords, *G.args) + 1 : 0;
if (key == 0) /* not a keyword */
return eval7();
G.args++; /* We have a valid token, so get the next argument. */
if (key == 1) { /* quote */
if (!*G.args)
bb_error_msg_and_die("syntax error");
return str_value(*args++);
} else if (nextarg("length")) {
args++;
return str_value(*G.args++);
}
if (key == 2) { /* length */
r = eval6();
tostring(r);
v = int_value(strlen(r->u.s));
freev(r);
return v;
} else if (nextarg("match")) {
args++;
} else
l = eval6();
if (key == 3) { /* match */
r = eval6();
v = docolon(l, r);
freev(l);
freev(r);
return v;
} else if (nextarg("index")) {
args++;
l = eval6();
}
if (key == 4) { /* index */
r = eval6();
tostring(l);
tostring(r);
@@ -335,16 +316,14 @@ static VALUE *eval6(void)
v->u.i = 0;
freev(l);
freev(r);
return v;
} else if (nextarg("substr")) {
args++;
l = eval6();
}
if (key == 5) { /* substr */
i1 = eval6();
i2 = eval6();
tostring(l);
if (!toarith(i1) || !toarith(i2)
|| i1->u.i > (arith_t) strlen(l->u.s)
|| i1->u.i <= 0 || i2->u.i <= 0)
|| i1->u.i > (arith_t) strlen(l->u.s)
|| i1->u.i <= 0 || i2->u.i <= 0)
v = str_value("");
else {
v = xmalloc(sizeof(VALUE));
@@ -354,9 +333,9 @@ static VALUE *eval6(void)
freev(l);
freev(i1);
freev(i2);
return v;
} else
return eval7();
}
return v;
}
/* Handle : operator (pattern matching).
@@ -368,7 +347,7 @@ static VALUE *eval5(void)
l = eval6();
while (nextarg(":")) {
args++;
G.args++;
r = eval6();
v = docolon(l, r);
freev(l);
@@ -396,7 +375,7 @@ static VALUE *eval4(void)
op = '%';
else
return l;
args++;
G.args++;
r = eval5();
val = arithmetic_common(l, r, op);
freev(l);
@@ -421,7 +400,7 @@ static VALUE *eval3(void)
op = '-';
else
return l;
args++;
G.args++;
r = eval4();
val = arithmetic_common(l, r, op);
freev(l);
@@ -454,7 +433,7 @@ static VALUE *eval2(void)
op = '>';
else
return l;
args++;
G.args++;
r = eval3();
toarith(l);
toarith(r);
@@ -473,7 +452,7 @@ static VALUE *eval1(void)
l = eval2();
while (nextarg("&")) {
args++;
G.args++;
r = eval2();
if (null(l) || null(r)) {
freev(l);
@@ -493,7 +472,7 @@ static VALUE *eval(void)
l = eval1();
while (nextarg("|")) {
args++;
G.args++;
r = eval1();
if (null(l)) {
freev(l);
@@ -503,3 +482,26 @@ static VALUE *eval(void)
}
return l;
}
int expr_main(int argc, char **argv);
int expr_main(int argc, char **argv)
{
VALUE *v;
if (argc == 1) {
bb_error_msg_and_die("too few arguments");
}
G.args = argv + 1;
v = eval();
if (*G.args)
bb_error_msg_and_die("syntax error");
if (v->type == integer)
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
else
puts(v->u.s);
fflush_stdout_and_exit(null(v));
}
+4 -2
View File
@@ -10,9 +10,11 @@
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/false.html */
#include <stdlib.h>
#include "busybox.h"
#include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
int false_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv);
int false_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv)
{
return EXIT_FAILURE;
Loaded 100 of 635 files, more files were not shown because too many files have changed in this diff. Show more