Compare commits

...
2460 Commits
Author SHA1 Message Date
Denis Vlasenko de15bb931a apply single post-1.7.4 patch; bump version to 1.7.5 2008-03-21 08:44:32 +00:00
Denis Vlasenko cf24d29529 Apply post-1.7.3 fix to inetd 2007-11-24 04:41:20 +00:00
Denis Vlasenko fa3f806cd0 apply accumulated post 1.7.2 patches; bump version to 1.7.3 2007-11-03 23:17:40 +00:00
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
Denis Vlasenko 8942c12782 releasing busybox 1.4.0 2007-01-20 19:57:57 +00:00
Denis Vlasenko 316355524f fixing bugs revealed by randomconfig runs 2007-01-20 16:54:19 +00:00
Denis Vlasenko 91f20ab510 fixes for amd64 compilation 2007-01-20 01:47:44 +00:00
Denis Vlasenko e055443412 ls: stop doing time() for each file in "ls -l"
ls: use fully-buffered stdout (can it be problematic
on VERY slow/hanging NFS mounts?)
2007-01-19 22:03:06 +00:00
Denis Vlasenko 4ebaf10742 strdup -> xstrdup
sed: de-obfuscate piece of code
2007-01-19 21:33:19 +00:00
Denis Vlasenko 2405ad659e ls: use get_cached_username/groupname 2007-01-19 21:24:17 +00:00
Denis Vlasenko 9af7c9d6b6 openvt,getty,vfork_daemon_rexec,mount: tighten up fd cleanup code
(will close all fd's > 2 on daemonization now)
getty: fix "getty -" support, and also do not try to chown/chmod "-"
telnetd: fix "lost ctty" bug
Yet another attempt on saner function names:
bb_sanitize_server_stdio(0/1) -> bb_sanitize_stdio() + bb_daemonize();
2007-01-19 21:19:35 +00:00
Denis Vlasenko f8c11aa65d fsck: dead code removal; also disable progress indicator code
(doesn't look good to me)
2007-01-19 02:04:09 +00:00
Denis Vlasenko e18a293a52 fsck: stop using strtok 2007-01-19 02:03:14 +00:00
Denis Vlasenko 1abf91aa25 fsck: move functions around so that related ones are nearby
no actual code changes
2007-01-19 02:02:33 +00:00
Denis Vlasenko a0e701d137 fsck: small optimization 2007-01-19 02:01:19 +00:00
Denis Vlasenko 74c9d2365a fix potentially misaligned 32-bit accesses 2007-01-18 15:42:00 +00:00
Bernhard Reutner-Fischer c966ba46a9 - move the smallint that is platform dependant to it's proper place 2007-01-18 10:32:09 +00:00
Peter Kjellerstedt f8384fa50c Use char for smallint on CRIS as well. 2007-01-18 10:26:07 +00:00
Bernhard Reutner-Fischer 1a250d9f32 - reinstate paranoia check in wrapf(). 2007-01-18 08:41:22 +00:00
Denis Vlasenko 7f0d7ae4f5 fix subtle bug inherited from dash 2007-01-18 01:12:57 +00:00
Denis Vlasenko 41aaefce71 stop using global variable needlessly 2007-01-18 00:53:35 +00:00
Denis Vlasenko cbbc043d1b smallint can be a char for amd64 too 2007-01-18 00:16:06 +00:00
Denis Vlasenko ef44d9d9f2 sed,get_line_from_file: improve comments 2007-01-17 23:16:16 +00:00
Bernhard Reutner-Fischer ae114c235e - stty's visible() function and catv's guts are identical. Merge them into
an appropriate libbb function.
2007-01-17 19:51:00 +00:00
Bernhard Reutner-Fischer 79cc55975f - remove superfluous define that expanded to "!strcmp"
- remove some dead code
2007-01-17 19:46:46 +00:00
Bernhard Reutner-Fischer 8eb0549e5d - reuse return code of vsnprintf to avoid pulling in strlen 2007-01-17 19:46:33 +00:00
Bernhard Reutner-Fischer 94feb1c807 - merge display_changed() and display_all()
This one is a bit risky but did work for me in cursory testing..
2007-01-17 19:46:12 +00:00
Bernhard Reutner-Fischer d4a745c3d4 - peruse get_terminal_width_height and remove legacy code for ancient
slowaris versions.
2007-01-17 19:45:36 +00:00
Bernhard Reutner-Fischer a6e31ad834 - rewrite find_param to use index_in_str_array 2007-01-17 19:45:14 +00:00
Bernhard Reutner-Fischer 4950f010f3 - manually inline tty_value_to_baud and remove string_to_baud_or_die
(cleanup)
2007-01-17 19:44:59 +00:00
Bernhard Reutner-Fischer 21fc740023 - constify some read-only members and remove superfluous casts
(cleanup)
2007-01-17 19:44:24 +00:00
Bernhard Reutner-Fischer 4fa566d4ad - reuse option_mask32 for state-handling in main
- improve check for errors from fcntl
2007-01-17 19:42:30 +00:00
Bernhard Reutner-Fischer 9e8df9354a - replace some occurances of "kernel" with busybox 2007-01-17 19:36:01 +00:00
Denis Vlasenko b64eed6030 httpd: use fd#1 in inetd mode
inetd: micro style fix
2007-01-14 17:06:11 +00:00
Denis Vlasenko d1a6e8d320 inetd: preparatory patch, no code changes 2007-01-14 14:46:18 +00:00
Denis Vlasenko d97c9244b1 Rename bb_sanitize_stdio -> bb_sanitize_server_stdio
(name is still bad - it doesn't hint that function
may do daemonization trick for you if asked to).
Small fixes to fakeidentd.
2007-01-14 13:12:06 +00:00
Denis Vlasenko b8b81a6f8f small size optimization 2007-01-14 12:47:27 +00:00
Denis Vlasenko 844ff096ec isrv.h: add copyright info 2007-01-14 12:34:48 +00:00
Denis Vlasenko fdf7aec532 I forgot "svn add" AGAIN! :( 2007-01-14 12:32:30 +00:00
Denis Vlasenko c14c95ec89 fakeidentd: avoid extra fcntl calls 2007-01-14 12:31:26 +00:00
Denis Vlasenko 19250813a8 fakeidentd: fix daemon mode (was thinking that it is in
inetd-wait mode and dying after timeout). Minor fixes,
comments are improved in places.
2007-01-14 12:07:25 +00:00
Denis Vlasenko ffcef2d1f7 inetd: open log after daemonization 2007-01-14 02:03:28 +00:00
Denis Vlasenko 7a431b3715 By popular request reinstate fakeidentd's standalone mode.
Since this is also needed for other applets like telnetd,
introduce generic driver for such things.
It even supports inetd-wait ('linger') mode, when inetd
hands out listen socket to child and waits to it to die,
instead of handing out accepted socket and continuing
listening itself (nowait mode).
Code growth ~200 bytes.
NB: our inetd doesn't support wait mode yet (or mabe it is buggy).
2007-01-14 01:29:06 +00:00
Denis Vlasenko 150f402b36 whitespace fixes (leading spaces to tab) 2007-01-13 21:06:21 +00:00
Denis Vlasenko 2418288cac small fixes to ipv6 infrastructure 2007-01-13 21:05:38 +00:00
Denis Vlasenko 3a34d0c08a random small size optimizations 2007-01-12 22:10:34 +00:00
Denis Vlasenko 21b080daa8 stty: fix bug reported by Paul Albrecht <albrecht@rdi1.com> -
stty -echo didn't work. Introduced by me :(
2007-01-12 21:03:07 +00:00
Denis Vlasenko f8abc100cc stty: rearrange functions, avoiding the need in forward declarations.
No other code chages.
2007-01-12 21:02:04 +00:00
Denis Vlasenko 4df8135cf6 undo RESERVE_CONFIG_BUFFER change. aldot, small on-stack char[N] objects
are perfectly okay, don't convert them to RESERVE_CONFIG_BUFFERs.
2007-01-12 21:01:05 +00:00
Denis Vlasenko 5d68724d5b next part of ipv6-ization. mostly netcat. 2007-01-12 20:59:31 +00:00
Denis Vlasenko 2c91652bbc next part of ipv6-ization. dnsd code is "interesting"... 2007-01-12 14:57:37 +00:00
Denis Vlasenko 6536a9b583 next part of ipv6-ization is here: wget & httpd 2007-01-12 10:35:23 +00:00
Denis Vlasenko f8138d1f91 fakeinetd: attempted ipv6-ization (and it's done)
but entire applet can be orders of magnitude smaller
if written as an inetd service.
So did that (#ifdef'ed out entire old version).
inetd version is less than 10% of old one!
function                                             old     new   delta
packed_usage                                       22083   22105     +22
nobodystr                                              4       -      -4
bind_ip_address                                        4       -      -4
ident_substr                                          20       -     -20
chmatch                                               22       -     -22
movefd                                                25       -     -25
skipchars                                             49       -     -49
handlexitsigs                                         51       -     -51
replyError                                            70       -     -70
.rodata                                           158120  158024     -96
deleteConn                                           102       -    -102
G                                                    524     388    -136
conns                                                560       -    -560
fakeidentd_main                                     1457     143   -1314
------------------------------------------------------------------------------
(add/remove: 0/10 grow/shrink: 1/3 up/down: 22/-2453)       Total: -2431 bytes
2007-01-11 23:26:13 +00:00
Denis Vlasenko 4fa5e8b455 fix my own breakage 2007-01-11 22:39:25 +00:00
Denis Vlasenko f7996f3b70 Trailing whitespace removal over entire tree 2007-01-11 17:20:00 +00:00
Denis Vlasenko 3821fb13ea fix verbose output; remove commented-out includes. 2007-01-11 16:51:21 +00:00
Denis Vlasenko 8e9ccba371 ipv6-ization efforts continue. Few bugs are found,
unknown number likely introduced...
2007-01-11 16:50:23 +00:00
Denis Vlasenko 085231fbba code shrinkage by Bernhard Fischer <rep.nop@aon.at> 2007-01-10 22:35:54 +00:00
Denis Vlasenko 1a8bf7f5d3 missed a few #undefs (no real impact I think) 2007-01-10 20:57:03 +00:00
Denis Vlasenko 7573541f74 fix bug 1146 (gunzip breakage introduced by me --vda) 2007-01-10 20:50:04 +00:00
Denis Vlasenko bbe514683a a bit more IPv6-ization work
syslogd: converted to use it (in -R host:port)
2007-01-10 20:19:56 +00:00
Denis Vlasenko 9de420c27c Improve generic ipv4+ipv6 support in libbb.
Convert telnet to it. Now this works:
telnetd -b [::1]:1234 - bind to IPv6 non-standard port
telnet [::1]:1234 - connect to IPv6 non-standard port
telnet ::1 1234 - same
This does not require ANY ipv6-specific code in applets
(no struct sockaddr_in6. In fact, no sockaddr_in, too).
2007-01-10 09:28:01 +00:00
Denis Vlasenko 62a6983a81 execute "safe applets" exev if not standalone shell
(patch by "Eric Spakman" <E.Spakman@inter.nl.net>)
2007-01-10 00:24:50 +00:00
Denis Vlasenko 886bb0df66 Fix typo in usage text by shortening it 2007-01-09 23:48:46 +00:00
Denis Vlasenko 1c962f23e0 Yet another small size reduction by Bernhard Fischer <rep.nop@aon.at> 2007-01-09 23:44:57 +00:00
Denis Vlasenko 59f2c34037 small size reduction by Bernhard Fischer <rep.nop@aon.at> 2007-01-09 23:43:28 +00:00
Denis Vlasenko bae7948a5a small size reduction by Bernhard Fischer <rep.nop@aon.at> 2007-01-09 23:42:43 +00:00
Denis Vlasenko db1edde6d8 compilation fix by Bernhard Fischer <rep.nop@aon.at> 2007-01-09 23:39:48 +00:00
Bernhard Reutner-Fischer d1e54e4f56 - missing hunk to go with r17206 2007-01-09 17:41:54 +00:00
Bernhard Reutner-Fischer 0f48663f83 - shrink by 26 bytes or so 2007-01-09 17:37:32 +00:00
Bernhard Reutner-Fischer e86bd6cde5 - vapier wants LD to point to CC, revert my previous change 2007-01-09 17:36:26 +00:00
Bernhard Reutner-Fischer 8fc4011992 - shrink klogd a tiny bit.
Compile tested only, would have sent it to the list for review but they don't show up in the ML archives :-/
   text    data     bss     dec     hex filename
    533       0       0     533     215 sysklogd/klogd.o.orig
    530       0       0     530     212 sysklogd/klogd.o
2007-01-09 15:46:36 +00:00
Bernhard Reutner-Fischer f07fe62d89 vda, we once had a get_chomped_line_from_file or the like. Where is that nowadays? FIXME: use it here instead of the fgets()
- shrink by ~9%: use common_buf, reuse are_you_root, adopt to global option_mask32
2007-01-09 10:06:19 +00:00
Denis Vlasenko 44c2eb23dd ping6: fix sequence numbers (missed ntoh) and ttl display.
(apparently some, eh, clever libc guy decided that
*CHANGING* IPV6_HOPLIMIT value in libc header is a nifty idea...)
2007-01-08 23:55:33 +00:00
Bernhard Reutner-Fischer d6c23aeefb - guess we need dl too 2007-01-08 16:38:33 +00:00
Bernhard Reutner-Fischer c1feac6e9f - set LD to ld
- simplify the cmd_busybox__ a bit and pass the LDFLAGS via -Wl down to CC
2007-01-08 16:29:15 +00:00
Denis Vlasenko 681f183b94 Previous "fix" wasn't good enough.
Now *this* is the correct fix (I think).
2007-01-07 22:23:38 +00:00
Denis Vlasenko 91c06e0a3c arp: small fixes for user-supplied device name case 2007-01-07 22:20:33 +00:00
Bernhard Reutner-Fischer 42646c5585 - style fixes and shrink by another 4 bytes while at it. 2007-01-07 22:12:35 +00:00
Denis Vlasenko 6998142998 httpd: stop adding our own "Content-type:" to CGI output 2007-01-07 21:25:12 +00:00
Denis Vlasenko db6a5c3f9e gzip cleanup part #13 - the last for today I think 2007-01-07 19:45:51 +00:00
Denis Vlasenko 3ae6f34135 gzip cleanup part #12 2007-01-07 19:44:57 +00:00
Denis Vlasenko 2f6df7fa0a gzip cleanup part #11 2007-01-07 19:44:35 +00:00
Denis Vlasenko 56c83eaaf5 gzip cleanup part #10 2007-01-07 19:40:50 +00:00
Denis Vlasenko 89af56b3e5 gzip cleanup part #9 2007-01-07 19:40:34 +00:00
Denis Vlasenko 52933d47bd gzip cleanup part #8 2007-01-07 19:40:13 +00:00
Denis Vlasenko ef87d46b8c gzip cleanup part #7 2007-01-07 19:39:54 +00:00
Denis Vlasenko 1a03c21adf gzip cleanup part #6 2007-01-07 19:39:34 +00:00
Denis Vlasenko da31fbc1b1 gzip cleanup part #5 2007-01-07 19:39:02 +00:00
Denis Vlasenko f824136f6b gzip cleanup part #4 2007-01-07 19:38:42 +00:00
Denis Vlasenko ed0f6db35e gzip cleanup part #3 2007-01-07 19:38:26 +00:00
Denis Vlasenko 30551fd6da gzip cleanup part #2 2007-01-07 19:38:06 +00:00
Denis Vlasenko ad403413c7 a ton of gzip changes, split up in compiled and
run-tested pieces. Code was rather messy.
It's not a bug fix, more like code cleanup.

This is the first part.
2007-01-07 19:37:42 +00:00
Denis Vlasenko 88e2b1cb62 I *always* forgotting svn add 2007-01-07 19:35:11 +00:00
Bernhard Reutner-Fischer 7ae93f0fe7 - FIXME: someone broke diff -r
- minor shrinkage i had lying around
   text	   data	    bss	    dec	    hex	filename
   7002	      8	     88	   7098	   1bba	diff.o.orig
   6936	      8	     81	   7025	   1b71	diff.o
2007-01-07 15:56:09 +00:00
Bernhard Reutner-Fischer 5568b722d4 - a few minor tweaks 2007-01-07 15:53:18 +00:00
Bernhard Reutner-Fischer 70722ec4ce - pull taskset.tests from the busybox_scratch branch 2007-01-07 15:19:34 +00:00
Bernhard Reutner-Fischer f0b71c19ae - add arp to defconfig 2007-01-07 12:18:59 +00:00
Denis Vlasenko fa85b86f38 add arp applet - thanks to
"Eric Spakman" <E.Spakman@inter.nl.net>
2007-01-07 01:24:12 +00:00
Denis Vlasenko b05955e0a5 work around gcc's false warning 2007-01-07 00:24:49 +00:00
Denis Vlasenko 8336f080cb diff: small optimizations; do not try to diff non-seekable stream
(currently we don't support that)
sort: fixes. testsuites fixed:
sort with non-default leading delim 1
sort with non-default leading delim 2
sort key doesn't strip leading blanks, disables fallback global sort
2007-01-07 00:21:41 +00:00
Denis Vlasenko 8a820b2732 syslogs: a bit better wording in explanation how buffering
is allocated
2007-01-06 22:08:53 +00:00
Bernhard Reutner-Fischer ea9e35f5dd - minor shrinkage: -25 bytes or so. 2007-01-06 21:47:09 +00:00
Denis Vlasenko 3697a829de "kernel" => "busybox" 2007-01-06 10:31:45 +00:00
Denis Vlasenko da98165ad6 kill unused variable 2007-01-06 01:27:24 +00:00
Denis Vlasenko c7a4aa5c99 move [g]zip decompressor state into malloc'ed buffer. size:
text    data     bss     dec     hex
5256       0     108    5364    14f4 - old
4915       0       0    4915    1333 - new
2007-01-06 00:03:11 +00:00
Denis Vlasenko d1a19affeb split inflate_xx_setup() subroutines from inflate_xx() 2007-01-05 23:58:45 +00:00
Denis Vlasenko cd42cb8df0 do not expose internal state of [g]zip unpacker.
fix memory leak in inflate_gunzip.
2007-01-05 23:56:53 +00:00
Denis Vlasenko 447b543eaf Stopped doing assignments inside expressions.
Who wrote this gem, I wonder?

n -= (e = (e = gunzip_wsize - ((d &= gunzip_wsize - 1) > w ? d : w)) > n ? n : e);
2007-01-05 19:49:02 +00:00
Denis Vlasenko cc33ef12d2 decompress_unzip: preparatory patch 2007-01-05 19:46:04 +00:00
Denis Vlasenko 3376298b59 Stop tracking buffer size - it is a constant.
Stop ignoring write errors.
Fix bugs in this line:
rc->buffer_size = read(rc->fd, RC_BUFFER, rc->buffer_size);
(a) should use safe_read()
(b) just ONE short read (e.g. 4 bytes) will make ALL future reads short!
2007-01-05 14:04:47 +00:00
Denis Vlasenko 98b8e9487d simplify access to buffer, making code a bit smaller 2007-01-05 13:59:05 +00:00
Bernhard Reutner-Fischer 89d49a4236 - remove duplicate includes 2007-01-04 22:13:25 +00:00
Denis Vlasenko a0e2a0a192 syslogd: start using bb_common_bufsiz1 instead of stack/malloc
logger: optimize, also use bb_common_bufsiz1 (~40 bytes)
tested to eat arbitrarily-sized input at high speed - ok
2007-01-04 21:22:11 +00:00
Denis Vlasenko b893497151 syslogd: stop doing open/fstat/lseek/close on _every_ write
(still doing it if more than a second passed in between).
Costs ~40 bytes.
2007-01-04 18:02:32 +00:00
Denis Vlasenko a9b60e93ee new libbb func: xmalloc_realpath (+ use it where makes sense)
syslogd, logread: add debugging code (disabled)
syslogs: drastically smaller bss; fix "-C n" behaviour
2007-01-04 17:59:59 +00:00
Denis Vlasenko ceab8700df syslogd: almost rewritten. Had several obvious bugs... 2007-01-04 17:57:54 +00:00
Bernhard Reutner-Fischer bfe1950c63 - spelling fix 2007-01-04 15:44:49 +00:00
Denis Vlasenko e428e9d43b klogd: small optimizations
(btw, I looked into syslogd... that's frightening!)
2007-01-04 03:07:57 +00:00
Denis Vlasenko b8429fb1f4 fix allnoconfig build. the most useful fix of the month. ;)
[spotted by Bernhard Fischer <rep.nop@aon.at>]
2007-01-03 23:23:58 +00:00
Denis Vlasenko a773af3b1d httpd: read cgi output with full_read, not safe_read
(avoids mangling of HTTP headers)
2007-01-03 23:02:18 +00:00
Denis Vlasenko a8951cbc34 wget: always print port# in 'Host' header (smaller code) 2007-01-03 22:29:01 +00:00
Denis Vlasenko 919c10dd88 ping[6]: don't do htons(a++), it can be a macro 2007-01-03 22:14:18 +00:00
Denis Vlasenko b36b370fbe wget: print port# in 'Host' header, if different from 80 2007-01-03 22:09:26 +00:00
Denis Vlasenko 562dc249e0 ftpgetput: fix PASV mode, fix xatou0induced breakage,
improve error message, guard against garbage from remote server
being printed. ~20 bytes code growth
2007-01-03 21:55:50 +00:00
Denis Vlasenko 6eebed561a chown: fix handling of "user.group" notation 2007-01-03 20:07:06 +00:00
Denis Vlasenko c9d34da375 find: fix misplaced #else (fix by Harald Kuthe <trhoudini@hotmail.com>) 2007-01-03 03:15:58 +00:00
Denis Vlasenko d54708399d fdisk: remove 8k buffer from bss - OSF labels
are not THAT common anyway
2007-01-03 02:58:54 +00:00
Denis Vlasenko 9b1381fd2f convert calloc to xzalloc
fix sleep-on-die option
2007-01-03 02:56:00 +00:00
Denis Vlasenko bb3d0fab3b extern variable declaration in a .c file is heresy - fixing it 2007-01-03 01:57:25 +00:00
Denis Vlasenko 75fa4eb155 fsck_minix: tiny optimization 2007-01-03 01:36:42 +00:00
Denis Vlasenko 87033fb5fa forgot to svn add util-linux/minix.h :( 2007-01-03 00:47:47 +00:00
Denis Vlasenko 73464ce53d fbset: move variable from data to bss
fsck_minix: fix fallout
2007-01-03 00:45:05 +00:00
Denis Vlasenko aa95959cb8 factor out minix structures/constants into minix.h
fsck_minix: optimizations
2007-01-03 00:43:19 +00:00
Denis Vlasenko 6dd392a252 fsck_minix: optimizations. ~130 bytes 2007-01-03 00:41:53 +00:00
Denis Vlasenko 24cfe8fe0c introduce small[u]int
fsck_minix: use it for flag variables. 140 bytes saved
2007-01-03 00:39:15 +00:00
Denis Vlasenko 2a85676fa5 silly style fixes 2007-01-02 16:45:05 +00:00
Denis Vlasenko ace35eeb88 Remove networking/libiproute/linux/pkt_sched.h
(and networking/libiproute/linux/ since it become empty).
Style fixes.
2007-01-02 16:32:16 +00:00
Mike Frysinger a71199e0f0 str2u() is only used when FEATURE_SORT_BIG is enabled 2007-01-02 05:43:30 +00:00
Mike Frysinger e5c095345e convert usage compressed command into the new cmd style 2007-01-02 05:42:35 +00:00
Denis Vlasenko e1d3e034a9 awk: style fixes 2007-01-01 23:53:52 +00:00
Denis Vlasenko 6dc6ebbf44 awk: undo locale setting for numbers - or else parsing
can act quite mysteriously
date: add if(ENABLE_LOCALE_SUPPORT)
2007-01-01 23:53:12 +00:00
Denis Vlasenko f782f52c8c awk: style cleanup. A lot of rw data moved to ro
(still has quite a lot of statics etc...).
getopt32-ification.
2007-01-01 23:51:30 +00:00
Denis Vlasenko b2abef3e54 stty: fix width of a field for ppc32
sort: fix -u to match coreutils 6.3
msh: compile fix (my fault)
2007-01-01 18:18:04 +00:00
Denis Vlasenko e27f15615f msh: double "static char line[LINELIM]" etc deleted.
massive amounts of assignments-in-ifs deleted
(some of which were VERY nasty)
2007-01-01 06:00:38 +00:00
Denis Vlasenko d1a302b52f rt_names: stop allocating 5k in rwdata
objsizes: don't show build machinery's object modules
2006-12-31 20:40:20 +00:00
Denis Vlasenko 50ddabc859 less: fix <tab><backspace> buglet 2006-12-31 19:36:01 +00:00
Denis Vlasenko 95b307103a less: interpret backspace.
less is officially declared PAGER-capable! ;)
(this includes viewing of manpages)
2006-12-31 19:23:31 +00:00
Denis Vlasenko c519320000 iproute: remove double get_hz optimization 2006-12-31 19:07:23 +00:00
Denis Vlasenko 13463af29f remove commented out #includes etc
move get_hz to the only caller
2006-12-31 18:58:32 +00:00
Denis Vlasenko 98ee06d3d4 stop using __u32 etc. uint32_t is there for a reason 2006-12-31 18:57:37 +00:00
Denis Vlasenko 806116b234 fixes from Yann E. MORIN <yann.morin.1998@anciens.enib.fr> 2006-12-31 12:14:16 +00:00
Mike Frysinger d514ba226b convert include/autoconf.h split and include/bbconfigopts.h commands into the new cmd style 2006-12-31 11:46:19 +00:00
Mike Frysinger 5dd76862ef Yann E. MORIN. writes: i pity the fool who doesnt use the z length modifier with size_t types 2006-12-31 11:34:17 +00:00
Denis Vlasenko 4a64c33443 about.html: update maintainer name
libbb/Kbuild: less needs xregcomp.o
2006-12-30 22:03:02 +00:00
Denis Vlasenko cb04ff5c68 fixdep.c: avoit doing memcmp in most cases
uidgid_get.c: add forgotten copyright notice
pwd/grp/shadow: avoid collisions with libc names
2006-12-30 21:11:57 +00:00
Denis Vlasenko 80602a98bc saw commit of vapier@busybox.net (thanks!),
decided to stop doing FOUR memcmp's per each input character.
I should have fixed this much earlier...
2006-12-30 19:52:28 +00:00
Mike Frysinger 1b3e8179a2 kill off AUTOCONF_INCLUDED (again) since it tends to get into cat fights with the kernel headers 2006-12-30 19:46:38 +00:00
Mike Frysinger 68ffb9a85d make sure AUTOCONF_TIMESTAMP is filled up properly ... if user has a timezone of Factory for example, strftime() will overflow the string and leave us without a trailing "\n and all hell breaks loose when we compile 2006-12-30 19:43:35 +00:00
Mike Frysinger 40ae9b5617 prevent buffer underflows with empty lines 2006-12-30 19:30:20 +00:00
Mike Frysinger c255f8b492 prevent accessing memory that we dont own 2006-12-30 19:21:48 +00:00
Denis Vlasenko 6a5dc5d75a next bunch of fixes for bugs found by randconfig 2006-12-30 18:42:29 +00:00
Denis Vlasenko 3bba545a54 done a dozen of randconfig test. guess what? ALL failed...
these are resulting fixes
2006-12-30 17:57:03 +00:00
Denis Vlasenko b5a122b6f9 fix for uclibc-without-shadow.h compilation 2006-12-30 14:46:51 +00:00
Mike Frysinger d9e4ddc38b we need to use the compiler driver to invoke LD as LDFLAGS is in the form the compiler driver understands, not the form the linker itself understands, so trying to invoke ld directly and passing it LDFLAGS while invoking the compiler driver in other places and passing it LDFLAGS does not work 2006-12-29 23:27:22 +00:00
Denis Vlasenko c1a339983f Add link to post-1.3.1 patches to website 2006-12-28 21:44:43 +00:00
Mike Frysinger 57ec574af7 * precision requires the argument be an integer, not size_t 2006-12-28 21:41:09 +00:00
Denis Vlasenko 7fa0fcafca fix build without shadow support 2006-12-28 21:33:30 +00:00
Denis Vlasenko 9a44c4f91c bb_xget[pw/gr]nam were horribly misnamed - fixed.
uidgid_get -> get_uidgid, add additional param
(numeric_ok). Make chown use it.
chown: fix "chown user: ...."
install: fix incorrect use of bb_xget[pw/gr]nam
2006-12-28 05:44:47 +00:00
Denis Vlasenko ba092336f0 news.html: Fix bad English 2006-12-27 09:47:53 +00:00
Denis Vlasenko 9cd7a249f1 fix typo 2006-12-27 07:57:29 +00:00
Denis Vlasenko f959bee0f4 Announce 1.3.1 2006-12-27 05:06:27 +00:00
Denis Vlasenko 8f27c34c28 ash: is_safe_applet mustn't affect disabled applets 2006-12-26 21:31:11 +00:00
Denis Vlasenko 666da5e2c6 merge post-1.3.0 fixes 2006-12-26 18:17:42 +00:00
Denis Vlasenko 270c17c0e6 properly export externs thru *.h files 2006-12-26 17:40:33 +00:00
Denis Vlasenko 3ef70d43ad adduser: trivial code movement 2006-12-26 17:37:38 +00:00
Denis Vlasenko bf0a201008 style fixes
last xcalloc replaced by xzalloc
2006-12-26 10:42:51 +00:00
Denis Vlasenko 5dd7ef0f37 chattr: bugfixes and size reduction 2006-12-26 03:36:28 +00:00
Denis Vlasenko 407b8c0b70 trivial size reduction 2006-12-26 03:02:25 +00:00
Denis Vlasenko 0de9375ee6 leftover of e2fsck surgery 2006-12-26 02:51:29 +00:00
Denis Vlasenko c4f623ef2a put small subset of e2fsprogs back in the tree:
lsattr, chattr, fsck. Old e2fsprogs tree is in
e2fsprogs/old_e2fsprogs/*.
2006-12-26 01:30:59 +00:00
Denis Vlasenko 64c5402584 remove e2fsprogs. Nobody volunteered to clean up that mess 2006-12-26 01:25:48 +00:00
Denis Vlasenko d63c3a032a Fix irregular capitalization in usage texts 2006-12-25 15:10:32 +00:00
Denis Vlasenko b6488c1780 trim help texts a bit more 2006-12-25 14:25:14 +00:00
Denis Vlasenko 5a4f0994b0 less: fix regexp search '/' on large files 2006-12-25 01:23:02 +00:00
Denis Vlasenko 7a50a64986 more usage message cleanups 2006-12-24 17:40:16 +00:00
Denis Vlasenko 765996aaea Cleanup usage messages (-200 bytes).
Remove busybox_main from applet table since
it is called via separate check
2006-12-24 16:59:27 +00:00
Denis Vlasenko 0ee3999d13 random tiny size savings 2006-12-24 15:23:28 +00:00
Denis Vlasenko 7cea262273 small stupid changes. no code changes 2006-12-24 07:30:09 +00:00
Denis Vlasenko a5b3e76c38 missing piece of prev commit: ndelay_off 2006-12-24 07:15:50 +00:00
Denis Vlasenko f4dff77355 less: implement waiting for input using select(). Rather tricky business.
But we do not read entire input anymore up-front.
2006-12-24 07:14:17 +00:00
Denis Vlasenko 9ac9e55e3c sum: 40% size reduction (-300 bytes)
find: one_char -> LONE_CHAR
2006-12-23 15:58:11 +00:00
Denis Vlasenko e13a537795 su: fix typo: "argv -= optind" should be += 2006-12-23 02:59:06 +00:00
Denis Vlasenko 1dc1b37b33 use xbind, xconnect where appropriate.
small edits to arping
2006-12-23 02:48:44 +00:00
Denis Vlasenko 7e46cf748e #define FEATURE_GETUSERNAME_AND_HOMEDIR should be always #defined 2006-12-23 01:21:55 +00:00
Denis Vlasenko 2a813e20e2 fix recognitions of -SIGname signals
(fix by Jacques LUDER <jacques.luder@thalesgroup.com>)
2006-12-23 01:06:21 +00:00
Denis Vlasenko 8f6c79240d find: fix spurious -exec error messages
(bug reported by Bernhard Fischer <rep.nop@aon.at>)
2006-12-23 00:49:10 +00:00
Denis Vlasenko 4cccc03768 remove useless casts (type*) xzalloc(...) 2006-12-22 18:37:07 +00:00
Denis Vlasenko a6df5907d2 dpkg: getopt32-ification etc, -100 bytes 2006-12-22 18:32:40 +00:00
Denis Vlasenko e31f721e14 tail: -50 text bytes 2006-12-22 16:06:16 +00:00
Denis Vlasenko f4c52b32db rpm: reformat. was really hard to read 2006-12-22 15:03:50 +00:00
Denis Vlasenko 0849207ce0 convert "negaite" config option into reversed (INCLUDE_SUSv2) 2006-12-22 13:56:36 +00:00
Denis Vlasenko c5cb38f4d9 time: -200 bytes of text 2006-12-22 13:43:19 +00:00
Denis Vlasenko f93ab47c45 time: fix option parsing bug, size optimizations 2006-12-22 12:36:13 +00:00
Denis Vlasenko 1d14e6f48c Always use /usr/share/udhcpc/default.script ([/usr] was depending on CONFIG_xx) 2006-12-22 11:47:19 +00:00
Denis Vlasenko afc9ff99fd removal of commented-out cruft 2006-12-22 00:45:27 +00:00
Denis Vlasenko 714701c890 tar et al: die if bb_copyfd_size copies less than asked for.
(we have bb_copyfd_exact_size now for that kind of usage)
2006-12-22 00:21:07 +00:00
Denis Vlasenko 0a8a774179 cmdedit: reformat code a bit, no algorithm changes 2006-12-21 22:27:10 +00:00
Denis Vlasenko d56b47f9a6 fix type character mixup in command completion 2006-12-21 22:24:46 +00:00
Denis Vlasenko f1282a8792 less: a few fixes for cases where we overflow status line 2006-12-21 17:03:20 +00:00
Denis Vlasenko f65d1338dc less: restore TAB display (was showing as inverse I after prev changes :) 2006-12-21 15:23:45 +00:00
Denis Vlasenko d51d14e36f less: "(null)" is a bit strange. "standard input" is better :) 2006-12-21 13:57:37 +00:00
Denis Vlasenko e147a72173 less: how many different kinds of status line we need, three?!
small fixes. [prev commit also added control char filtering
on input (e.g. regexp input, filename input for 'E' etc)]
2006-12-21 13:26:54 +00:00
Denis Vlasenko e865e81d34 less: stop dying on bad regexps, quietly pipe data w/o
user interaction if stdout is not a tty.
size optimizations
2006-12-21 13:24:58 +00:00
Denis Vlasenko bf66fbc8e2 introduce LONE_CHAR (optimized strcmp with one-char string) 2006-12-21 13:23:14 +00:00
Denis Vlasenko 6910741067 tail: fix tail +N 2006-12-21 00:43:06 +00:00
Denis Vlasenko 3f3190e34c less: total cleanup and bugfix.
Doesn't die horribly on binary files anymore.
In fact, they _100%_ work now. Control chars
are in reverse video, including DEL and that idiocy of VT-10x,
Meta-ESC [inventor of which should be prohibited from reproducing].
Regex search is fixed also. When you specify search ('/' key),
control chars turn into dots (unhighlighted),
and found occurrences highlighted instead. This is reversible.
Memory management fixed (was leaky as hell) and optimized.
Linewrapping fixed and thoroughly tested.
Max buffer size made configurable.
~ 600 bytes saved.
2006-12-21 00:22:03 +00:00
Denis Vlasenko 9a7cef930f less: somewhat buggy applet, but nice. Muchly reduced
xstrdup'ing and memory consumption. Made linewrap saner.
regex matching code was awful - still buggy, but not as
leaky as before. Made buffer size configurable. Killed
several static and on-stack buffers. Hopefully eliminated
staircase effect on Ctrl-C (unable to reproduce).
2006-12-20 02:46:48 +00:00
Denis Vlasenko b95636c52f remove casts from xmalloc() 2006-12-19 23:36:04 +00:00
Denis Vlasenko 2375d75f32 ifupdown: do not print and/or execute empty commands (""). 2006-12-19 23:15:46 +00:00
Denis Vlasenko 8cd1a288fa ifupdown: parse() returning NULL and returning "" is not the same,
it turned out! wow... okay, fixing my buglet...
2006-12-19 23:01:33 +00:00
Denis Vlasenko 28703015ab u_short, ulong exterminated
fdiskXXX: add a bit of sanity (not enough by far)
2006-12-19 20:32:02 +00:00
Denis Vlasenko f58906b646 cmdedit: fix my bug, improve code a bit 2006-12-19 19:30:37 +00:00
Bernhard Reutner-Fischer 28fbd69bf8 - use xlisten/xsocket some more. Saves .25 kB 2006-12-19 16:31:09 +00:00
Bernhard Reutner-Fischer 359d7ca0e7 - rename SU_SYSLOG to FEATURE_SU_SYSLOG 2006-12-19 08:55:38 +00:00
Denis Vlasenko 7f1dc21a5d cmdedit: use qsort for sorting command completion results; style fixes 2006-12-19 01:10:25 +00:00
Denis Vlasenko 8eb3b391ad passwd: add option to check passwords for weakness 2006-12-19 00:33:53 +00:00
Denis Vlasenko 249fabf1a3 Add option to disable command execution from vi & awk 2006-12-19 00:29:22 +00:00
Denis Vlasenko 15b213ef5a su: make /etc/shells check configurable
ash: missing ';'
2006-12-19 00:20:20 +00:00
Denis Vlasenko 908d6b7054 mount: add getmntent_r stub for dietlibc 2006-12-18 23:07:42 +00:00
Denis Vlasenko 7cfecc4b36 xfuncs.c: dietlibc actually HAS fdprintf!
platform.h: define strchrnul for dietlibc
ash: stop using few non-standard functions
2006-12-18 22:32:45 +00:00
Denis Vlasenko c8e6e35ba4 nc: add missing cast
xfuncs: add dprintf for dietlibc
2006-12-18 22:10:24 +00:00
Denis Vlasenko 83e5d6f772 A bunch of defined(__GLIBC__) added. static-linking warning expanded 2006-12-18 21:49:06 +00:00
Denis Vlasenko f42ff90453 du: dietlibc compat fix, style fixes. Thanks to sampo@symlabs.com. 2006-12-18 21:22:16 +00:00
Denis Vlasenko fcfe834d50 ifupdown: strlen(NULL) is a no-no, fixed. Also few micro-optimizations 2006-12-18 21:02:00 +00:00
Denis Vlasenko 6dca70a049 ps: fix buglet, add microoptimization 2006-12-18 14:20:01 +00:00
Denis Vlasenko db50647d1f httpd: we don't have FEATURE_HTTPD_WITHOUT_INETD anymore,
remove it from Config.in
2006-12-17 20:18:05 +00:00
Denis Vlasenko b8c77b5b25 start_stop_daemon: make code a bit more readable 2006-12-17 19:43:10 +00:00
Denis Vlasenko 0f5905e617 od: remove bug-for-bug compat (because the bug was fixed in coreuitls) 2006-12-17 19:21:13 +00:00
Denis Vlasenko c88894602d tar: report error if child dies while writing out the end of tarball
(e.g. out of disk space).
2006-12-17 19:08:20 +00:00
Denis Vlasenko b131b271a0 start_stop_daemon: fix bug where any program name was "matching"
processes for which readlink(/proc/N/exe) fails
2006-12-17 17:30:01 +00:00
Denis Vlasenko 7cdc54ff59 fix/shorten some usage strings 2006-12-17 17:27:56 +00:00
Denis Vlasenko 10f7dd1ea1 tftp: corrupted input packets were killing retransmits - fixed 2006-12-17 01:14:08 +00:00
Denis Vlasenko 0a10da29a7 diff: comment - explain what happens when hunk fails to apply 2006-12-17 00:49:56 +00:00
Denis Vlasenko f7583d89b0 patch: fix double-free (bug 1120) 2006-12-17 00:33:29 +00:00
Denis Vlasenko 9f739445cd inline strcmp(s, "-") [actually macro-ize it for now - gcc is too stupid] 2006-12-16 23:49:13 +00:00
Denis Vlasenko a597aaddfa s/extern inline/static ATTRIBUTE_ALWAYS_INLINE/g
xstrtou: disallow leading '+'
2006-12-16 23:48:13 +00:00
Denis Vlasenko 3469c185e5 wget: smallish optimization 2006-12-16 22:19:47 +00:00
Denis Vlasenko 6a1d661036 diff: fix -q exit code
last_char_is: sacrifice 9 bytes but avoid double-scan
2006-12-16 22:18:44 +00:00
Denis Vlasenko 79e77cdbed site: add link to directory with patches 2006-12-15 22:10:07 +00:00
Denis Vlasenko cda6c636ca re-applying first post-1.3.x change
version change to 1.4.0.svn
2006-12-15 00:59:35 +00:00
Denis Vlasenko 44b2ea786e back out last change - need to make busybox-1_3-stable branch first 2006-12-15 00:02:30 +00:00
Bernhard Reutner-Fischer 728534b3cb - table support for ip route 2006-12-14 15:41:29 +00:00
Bernhard Reutner-Fischer 56b956952e - minor shrinkage 2006-12-14 11:27:58 +00:00
Denis Vlasenko f7b0d4a3e5 Update busybox.net webpage with 1.3.0 announcement 2006-12-14 00:22:51 +00:00
Denis Vlasenko a883fa4cee exterminate last bzero's
version bump to 1.3.0
2006-12-13 23:52:32 +00:00
Bernhard Reutner-Fischer 9729e65706 - honor CONFIG_DEBUG 2006-12-13 17:44:24 +00:00
Bernhard Reutner-Fischer 5b6f776fe9 - remove warning about unused depth parameter in add_to_dirlist()
- make one variable static and add comment about why the other variables there are not static.
2006-12-13 16:50:15 +00:00
Denis Vlasenko 35a4bbe74f date: -R shouldn't use locale 2006-12-13 00:35:21 +00:00
Denis Vlasenko 5e2db5e8ee build system: small fix for "release" target to work 2006-12-12 23:46:31 +00:00
Denis Vlasenko 5fa7148761 build system: add "release" target
find: support -size N (needed for above)
2006-12-12 22:31:15 +00:00
Denis Vlasenko 16c2c700fd passwd: fix indentation 2006-12-12 18:11:58 +00:00
Denis Vlasenko db2b52425d passwd: added comment 2006-12-12 17:14:56 +00:00
Denis Vlasenko 900406c359 passwd: shrink by ~10 bytes, use PRNG instead of usleep. 2006-12-12 14:38:03 +00:00
Bernhard Reutner-Fischer 6f0540e7ec - remove functions marked as LEGACY in SUSv3 and use their modern counterparts. 2006-12-12 11:50:44 +00:00
Bernhard Reutner-Fischer 32f3ebf08f - add an anchor to let me point people to FAQ.html#standalone_shell
easily.
2006-12-10 13:40:16 +00:00
Denis Vlasenko 2ea630f9a5 bb_makedev: fix for glibc 2.3.2
sed: fix C++ style declaration
2006-12-10 02:52:19 +00:00
Denis Vlasenko 2f8f71b20d sed: style fixes 2006-12-10 02:09:12 +00:00
Denis Vlasenko b15b7f7a4a more: fix for case when _FILE_OFFSET_BITS is not #defined.
samll size improvement.
2006-12-10 01:57:29 +00:00
Bernhard Reutner-Fischer 57d83ff5f9 - Proposed fix to make aliases work (with uClibc-current).
See comment in the patch about the change introduced in r16342.
2006-12-07 12:25:17 +00:00
Bernhard Reutner-Fischer 1819eee436 - Improve wording in error message. 2006-12-07 12:18:36 +00:00
Bernhard Reutner-Fischer 95da177b09 - s/:\t\t/\t/ for two helptexts. 2006-12-07 12:16:17 +00:00
Bernhard Reutner-Fischer b7c50c9896 - remove a warning that was not ment to be checked in. 2006-12-06 23:14:31 +00:00
Bernhard Reutner-Fischer feea1b972c - better distinction between CFLAGS and CPPFLAGS. 2006-12-06 21:51:59 +00:00
Bernhard Reutner-Fischer bc95f57932 - adjust to kernel's build infrastructure. 2006-12-06 15:29:00 +00:00
Bernhard Reutner-Fischer 882e60c442 - shrink less.
01a: svn version
01b: merge past_eof and inp_stdin into flags.
01c: merge match_backwards into flags.
01d: add handling of <HOME> and <END> keys, remove set_tty_raw, use fflush_stdout_and_exit
01e: rewrite special-key handling to be smaller.
01f: changing the format saves 4 bytes (alot of places would benefit from this)
   text    data     bss     dec     hex filename
   9034       8     648    9690    25da less.o.01a
   9023       8     640    9671    25c7 less.o.01b
   9027       8     636    9671    25c7 less.o.01c
   9068       8     636    9712    25f0 less.o.01d
   8990       8     636    9634    25a2 less.o.01e
   8986       8     636    9630    259e less.o.01f
2006-12-04 16:04:50 +00:00
Bernhard Reutner-Fischer bbda98f14c - cosmetic change to avoid warnings about eventual padding/packing. 2006-12-04 15:58:27 +00:00
Bernhard Reutner-Fischer bb59f02218 - make sure we pickup the correct defines. Guards against 2.6.19 kernel-headers. 2006-12-04 15:57:17 +00:00
Bernhard Reutner-Fischer 91d4a2dac3 - commentary typo 2006-12-02 20:47:36 +00:00
Denis Vlasenko 1375bc7b67 sed: fix handling of files not ending in '\n' 2006-12-02 20:12:12 +00:00
Denis Vlasenko 8b22b07bc5 sed: improve handling of NULs 2006-12-02 17:58:10 +00:00
Denis Vlasenko becd8c538c passwd: made smaller by ~130 bytes. size can go negative
if current trend will continue ;)
2006-12-01 21:34:20 +00:00
Bernhard Reutner-Fischer 732268fe69 - provide central knob to turn off RPC related options. 2006-12-01 16:56:12 +00:00
Denis Vlasenko 4c87d4f242 passwd: micro-optimization 2006-11-30 23:13:59 +00:00
Denis Vlasenko eb98be02ac "kernel config" -> "busybox config"
suggested by Roberto A. Foglietta <roberto.foglietta@gmail.com>
2006-11-30 22:40:32 +00:00
Denis Vlasenko 93f6aa6bca "make bigdata" biggest offender dealt with:
xmalloc 16Kb buffer instead of keeping it in bss
2006-11-30 21:11:01 +00:00
Denis Vlasenko 610c4aa197 ed: convert style to bbox's. No code changes. 2006-11-30 20:57:50 +00:00
Denis Vlasenko 002526481e passwd: small size optimization. salt generation improved
(really generated different salts even if called back-to-back).
2006-11-30 20:41:28 +00:00
Denis Vlasenko ab24e18c7a passwd: rework:
* do not make backup copy by copying (just retain old file)
* correctly fall back to /etc/passwd if user is not in shadow
* fix bug with overlong passwd entries
* be permissive on some kinds of failures
* reduce stack usage
* code size: -500 bytes
2006-11-30 16:41:15 +00:00
Bernhard Reutner-Fischer b8bb27c7ea - save 4 bytes
text    data     bss     dec     hex filename
    764       0      80     844     34c vlock.o.oorig
    760       0      80     840     348 vlock.o
2006-11-30 14:53:51 +00:00
Denis Vlasenko 28bb84bd4e Well, I am not 100.00% usre that uint16 will suffice there.
We don't lose anything by using 'unsigned' instead.
2006-11-29 23:15:04 +00:00
Denis Vlasenko 016a82e279 another -90 bytes. That #define is **evil** 2006-11-29 22:47:42 +00:00
Denis Vlasenko 66b86c6902 mkfs.minix: more cleanups, -~300 bytes of code.
Added debugging support.
2006-11-29 22:33:47 +00:00
Denis Vlasenko c6ce8733dd cut 0.5k off mkfs.minix
assorted strtoul fixes (that's what brought me into minix)...
2006-11-29 18:15:52 +00:00
Denis Vlasenko a35c9e91ba httpd: fix decode of '/' when called via -d 2006-11-29 15:58:50 +00:00
Denis Vlasenko 2425bdce34 od: fix buglet in --traditional, microoptimization,
document coreutils bug
bloat-o-meter: account for objects in rodata too
2006-11-29 14:32:01 +00:00
Denis Vlasenko 834410a5a5 getopt32-ification of fdisk 2006-11-29 12:00:28 +00:00
Denis Vlasenko c61852a02b fix support for globally disabling --long-options.
(disabling them saves ~4K on fully configured bbox)
2006-11-29 11:09:43 +00:00
Denis Vlasenko 601ae1378b od: sometime ago I landed BIG od implementation
from coreutils. My fault. This commit contains
cleanups and size reductions.
2006-11-28 23:37:46 +00:00
Denis Vlasenko df38188367 fix bug in new str -> num convertors 2006-11-28 10:54:16 +00:00
Denis Vlasenko 7df69b887a usage: fix few help texts, fix breakage: '\<tab>'
sequence utterly confused cpp :)
2006-11-28 00:46:49 +00:00
Denis Vlasenko c2f5b02293 udhcpc: fix my breakage 2006-11-28 00:21:46 +00:00
Denis Vlasenko 1fffe38e01 fix udhcpc help message, take steps to make usage.h less messy 2006-11-28 00:06:39 +00:00
Denis Vlasenko 229b3d2072 do not overflow ifr_name. maybe it was safe in some places,
but not everywhere. err to the safe side.
2006-11-27 23:44:57 +00:00
Denis Vlasenko e2d3ded354 udhcpc: convert to getopt32 2006-11-27 23:43:28 +00:00
Denis Vlasenko 30d7a346e6 tar: fix misplaced --exclude long option definition 2006-11-27 20:24:40 +00:00
Denis Vlasenko 5e90e10647 Closing bug 1040:
The "quiet" option is quietly (hah) ignored. It should be passed through
to the mount() syscall in the comma separated list of options.
I found the problem with the vfat/msdos filesystems, which uses
a quiet option to override some complaints and errors.
2006-11-27 19:50:16 +00:00
Denis Vlasenko f1a6c6b362 erase_mtab: do not limit ourself to 40 mtab entries 2006-11-27 17:29:09 +00:00
Denis Vlasenko 097c324f59 fix remaining survivors of the return(a) cleanup 2006-11-27 16:59:15 +00:00
Denis Vlasenko d9e15f2068 style cleanup: return(a) -> return a, part 2 2006-11-27 16:49:55 +00:00
Denis Vlasenko 079f8afa0a style cleanup: return(a) -> return a, part 1 2006-11-27 16:49:31 +00:00
Denis Vlasenko 10d0d4eec7 byteswap ops had extra mask ops - removed 2006-11-27 16:48:17 +00:00
Denis Vlasenko 3ece72dc3f svn add bb_strtonum.c :( 2006-11-27 15:12:16 +00:00
Denis Vlasenko 459903bd4e Provide our own isdigit macro. saves more than 400 bytes. 2006-11-27 14:44:18 +00:00
Denis Vlasenko d686a045c8 safe_strtoXX interface proved to be a bit unconvenient.
Remove it, introduce saner bb_strtoXX.
Saved ~350 bytes.
2006-11-27 14:43:21 +00:00
Bernhard Reutner-Fischer 8a0a83d503 - minor shrinkage
text    data     bss     dec     hex filename
    773       0      80     853     355 vlock.o.orig
    766       0      80     846     34e vlock.o
2006-11-27 13:58:18 +00:00
Denis Vlasenko 2813ce2aad ifconfig: do not try to continue on errors. not much sence in doing that
IMHO, but requires extra code.
2006-11-27 10:03:21 +00:00
Denis Vlasenko a7b2c41e03 deluser: the same code, but a bit less obfuscated. 2006-11-27 01:04:23 +00:00
Denis Vlasenko c9bb67787a deluser: size reduction by 60 bytes.
patch from Tito <farmatito@tiscali.it>
2006-11-27 00:54:59 +00:00
Denis Vlasenko bf11e8942d added gcc flag which is needed for ULLONG_MAX to appear
on Tito's box
2006-11-26 22:17:46 +00:00
Denis Vlasenko e5667c1cfe Closing bug 730. libbb run_parts is using scandir (a GNUism),
and it is used only by run_parts applet, so move it there.
Also saved ~30 bytes (prolly gcc autoinlining...).
2006-11-26 20:13:39 +00:00
Denis Vlasenko ec0c920a78 added small doc about tar 'pax header' format 2006-11-26 17:07:38 +00:00
Denis Vlasenko 664733f1a3 sort: two small optimizations 2006-11-26 15:48:54 +00:00
Denis Vlasenko 0d42ddff70 sort: reformat entire file wrt style.
fix single obvious bug: right hand was 0 here:
 flags & (FLAG_b&FLAG_d&FLAG_f&FLAG_i&FLAG_bb)
fixed to use |
2006-11-26 15:48:03 +00:00
Denis Vlasenko cf749bc10c small fixes:
fix xstrdup to not grossly overallocate memory
use xopen instean of xopen3 in several places
etc.
2006-11-26 15:45:17 +00:00
Denis Vlasenko c1660fea6d tar: refuse to untar files with "/../" components 2006-11-26 15:42:03 +00:00
Denis Vlasenko b596335868 tar: correctly skip (and warn about) pax headers.
plug memory leak. save 50 bytes.
Wooohooo! we finally can unpack kernel tarballs!
2006-11-26 01:46:59 +00:00
Denis Vlasenko 7725d0ff5c tar: add support for FEATURE_TAR_GNU_EXTENSIONS so than we can save
long names now. We were able to read such tars, but not create.
+275 bytes. Without FEATURE_TAR_GNU_EXTENSIONS: -25 bytes.

We still cannot unpack Linux kernels, but not for long ;)
2006-11-25 23:56:50 +00:00
Denis Vlasenko 2d27e4ccbb tee: fix bug: argv[-1] is a no-no!
bb_full_fd_action: optimize
die_if_ferror: "<applet>: filename" isn't a good err msg, add "..I/O error"
2006-11-25 23:50:28 +00:00
Denis Vlasenko 87cd4a87e3 tar: small fix and small optimization 2006-11-25 23:47:32 +00:00
Denis Vlasenko 43bddf31e9 small improvements in str -> num convertors 2006-11-25 14:49:04 +00:00
Denis Vlasenko f2408e6c3f tar: abort if tarring up file larger that 64Gb
(otherwise we will produce garbled tarfile)
2006-11-25 14:48:09 +00:00
Denis Vlasenko 5dd27b1ee0 dd: support >2gb values for seek, skip, count 2006-11-25 14:46:21 +00:00
Denis Vlasenko ed836cdc30 regularize str -> num convertors 2006-11-25 14:44:13 +00:00
Denis Vlasenko 809a6e3104 small optimization 2006-11-24 22:42:44 +00:00
Denis Vlasenko 3feb2fc535 tar: fix multiple -t and/or -v options handling.
do not process list of files to tar up in reverse order.
2006-11-24 21:55:55 +00:00
Denis Vlasenko d031ffa623 tar: sanitize option handling 2006-11-24 21:54:44 +00:00
Denis Vlasenko b833ca9d2d tar: buglet fix 2006-11-24 18:53:13 +00:00
Denis Vlasenko d6772501db tar: fix and sanitize handling of long filenames/linknames
(GNU extensions 'K' and 'L').
We correctly handle them when untarring now, but unfortunately
we still don't use them when tarring! That stupid 100 char limit
is still there!
The biggest problem is that we don't support 'pax' tar format.
Linux kernel tarballs are in this format... shame
2006-11-24 17:21:44 +00:00
Denis Vlasenko d398ecab9d hunt down improper include <>, make mkswap output 4Gb+ friendly 2006-11-24 15:38:03 +00:00
Denis Vlasenko 8023d7df78 svn add makedev.c. Forgot as usual... :( 2006-11-24 15:06:28 +00:00
Denis Vlasenko b8a8e601df tar: small fixes:
* size-optimize mapping code
* kill double close
2006-11-24 14:59:45 +00:00
Denis Vlasenko c50f370f98 tar: cache [ug]id->username/groupname mappings. Cuts down amount
of open/read/close of /etc/passwd and /etc/group
dramatically (we were rereading those for each untarred file!!!)
2006-11-24 14:57:31 +00:00
Denis Vlasenko 4fbb584a0e tar: cry murder and bail out if file shrinks under us while we tar it up 2006-11-24 14:55:23 +00:00
Denis Vlasenko 0b35470d9b glibc makedev() is a large inline. Save 700+ bytes by wrapping it
into a function.
2006-11-24 14:54:27 +00:00
Denis Vlasenko cf30cc82a3 header_verbose_list: stop truncating file size in listing 2006-11-24 14:53:18 +00:00
Denis Vlasenko 376ce1e775 tar:
* unpack: handle tar header fields which are not NUL terminated
* pack: handle 4+GB files correctly
* pack: refuse to store 101+ softlinks (was truncating link
  target name)
* pack: mask mode with 07777
2006-11-24 14:51:01 +00:00
Denis Vlasenko 14621929a1 md5sum: make -c grok formats like "68b329da9893e34099c7d8ad5cb9c940 *foo".
Also eradicate 95 bytes of bloat.
2006-11-23 15:59:12 +00:00
Denis Vlasenko a741b778fe ifupdown:
ifconfig said to set iface up before it processes hw %hwaddress%,
which then of course fails. Thus we run two separate ifconfig
2006-11-23 15:08:37 +00:00
Denis Vlasenko 93ad1c2385 ifupdown: save some 100+ bytes of code in addstr() 2006-11-23 15:07:38 +00:00
Denis Vlasenko 4e4662cc73 wget: -O - still outputs progressbar (to stderr)
Noticed dead code. -100 bytes.
2006-11-23 13:10:23 +00:00
Denis Vlasenko c90c3f30a8 add "wpad" DHCP option. Spotted some optimization opportunities: -80 bytes 2006-11-23 12:57:49 +00:00
Denis Vlasenko 48237b0c88 introduce setsockopt_reuseaddr(int fd), setsockopt_broadcast(int fd),
use them where appropriate. 200 bytes saved
2006-11-22 23:22:06 +00:00
Bernhard Reutner-Fischer b40bdb383a - add FIXME to brokenness in the installer.. 2006-11-22 18:40:06 +00:00
Bernhard Reutner-Fischer 7627cc1454 - fix typo 2006-11-22 18:21:08 +00:00
Denis Vlasenko 81e264d4af fix double merge 2006-11-22 17:42:06 +00:00
Bernhard Reutner-Fischer be2f9f7fe0 - update TODOs 2006-11-22 16:48:29 +00:00
Bernhard Reutner-Fischer 32eddffa30 - revert r15563 (pull current version of taskset off the busybox_scratch branch) 2006-11-22 16:39:48 +00:00
Denis Vlasenko c8717cd857 telnetd: move generic stuff into libbb. It will make it easy
to make other server applets IPv6-aware too.
2006-11-22 16:10:39 +00:00
Denis Vlasenko 0801ef28ca telnetd: if FEATURE_IPV6 is on, telnet will NOT work on IPv4
which is kind of stupid
2006-11-22 15:57:52 +00:00
Denis Vlasenko 75f8d080a2 telnetd: we were having telnetd with is ONLY inetd or ONLY standalone.
What if I need to have both?? This patch introduces
CONFIG_FEATURE_TELNETD_STANDALONE: y - both, n - only inetd.
2006-11-22 15:54:52 +00:00
Bernhard Reutner-Fischer d6bbf99a8b - reinstate "make checkhelp" 2006-11-22 09:39:48 +00:00
Denis Vlasenko aad4999eea #if HAVE_AFINET6 -> #ifdef HAVE_AFINET6 2006-11-22 02:12:07 +00:00
Denis Vlasenko 428f7ae6e2 httpd: comment on QUERY_STRING 2006-11-21 21:35:14 +00:00
Denis Vlasenko 8b45837b4c httpd: add link to docs 2006-11-21 21:23:21 +00:00
Denis Vlasenko 5e618ff439 xgethostbyname: more readable 2006-11-21 20:35:22 +00:00
Denis Vlasenko 7ca3921e5e bb_INET_default[] is really just a const "default",
nothing INET-specific
2006-11-21 20:34:21 +00:00
Denis Vlasenko 5096246ffb ifconfig: looks like char host[128] is not really needed. 2006-11-21 20:32:38 +00:00
Denis Vlasenko f8c8bb1160 wget: yet another contortion for proftpd's PASV response. 2006-11-21 19:10:26 +00:00
Bernhard Reutner-Fischer 921f5df25f - add 'ip rule' support. First take..
text    data     bss     dec     hex filename
   2999       0       0    2999     bb7 networking/libiproute/iprule.o
2006-11-21 15:36:08 +00:00
Denis Vlasenko 04b30ba3b8 ifconfig: preparatory patch, no code changes 2006-11-21 14:26:37 +00:00
Denis Vlasenko 3aa2d51cd6 insmod: set STRVERSIONLEN = 64, convert #ifdef CONFIG to #if ENABLE,
stop using CONFIG_ prefix for non-config-system variables
2006-11-21 14:12:53 +00:00
Denis Vlasenko 9229794ab3 insmod_ng_main: -80 bytes. Stopp mmapping, use xmalloc_open_read_close(). 2006-11-21 11:58:14 +00:00
Bernhard Reutner-Fischer a8381948da - style fixes 2006-11-21 11:23:11 +00:00
Denis Vlasenko 1288722f3e wget: add TODO 2006-11-21 11:15:58 +00:00
Denis Vlasenko 40f62a8c3d wget: fix ftp PASV mode ("numeric" check was too strict) 2006-11-21 11:04:31 +00:00
Bernhard Reutner-Fischer 3e7ef7ead4 - update defconfig 2006-11-21 10:53:05 +00:00
Denis Vlasenko 9cade08917 wget: reduce likelihood of ETA overflow (especially with !LFS) 2006-11-21 10:43:02 +00:00
Denis Vlasenko 04291bc5ae httpd: slight reduction of #ifdef forest
few other applets: #ifdef CONFIG_ -> #if ENABLE_
traceroute: fix exposed bugs
defconfig: update
2006-11-21 10:15:25 +00:00
Denis Vlasenko 3eb91c2e35 cpio: (allegedly) fix bug 0001095:
"cpio hardlink support and possible memory leak fix"
2006-11-21 00:55:46 +00:00
Denis Vlasenko 5d148e2646 httpd: fix cgi-bin/index.cgi support, add example of it,
stat: fix end-of-line if format is specified (wasn't printing it),
      fix %z (time) format to match coreutils 6.3
2006-11-21 00:12:09 +00:00
Denis Vlasenko fcdb00f735 httpd: LC_TIME locale _must_ be POSIX to httpd! We speak over the net! 2006-11-21 00:09:37 +00:00
Denis Vlasenko 6c85ddc850 httpd: add support for directory indexer (cgi-bin/index.cgi) 2006-11-21 00:08:39 +00:00
Denis Vlasenko a3ee69fa6c httpd: get rid of big, useless blocks (deindent,
bring code under 80 columns)
2006-11-21 00:07:31 +00:00
Denis Vlasenko 0bb993f39b httpd: More robust Content-length: parsing,
code reorganization (less indented)
2006-11-21 00:06:28 +00:00
Denis Vlasenko 736230e209 dhcprelay: new applet 2006-11-20 19:40:36 +00:00
Denis Vlasenko c9cdeaa3fe add compile-time check for correct DHCP packet size 2006-11-20 01:13:09 +00:00
Denis Vlasenko 4a5cf16a36 login: use %s - we know that string is not too long there
ping[6]: use getopt32: smaller (-50 bytes) and handles -c6 correctly
(was requiring '-c 6' with mandatory space)
2006-11-20 00:48:22 +00:00
Denis Vlasenko 6a353c8158 mount: if FILE* is NULL, it's not wise to use it. 2006-11-19 17:34:57 +00:00
Denis Vlasenko 83edaf3fd6 svlogd: log full lines to stderr too, and also stop using stdio for that 2006-11-19 17:33:54 +00:00
Denis Vlasenko 22dcd04f8f mkdir: style fix 2006-11-19 13:53:50 +00:00
Denis Vlasenko 89f0b3486d rodata cleanup. "unable to" == "cannot". -300 bytes 2006-11-18 22:04:09 +00:00
Denis Vlasenko 61126ab30a small fixes: using fd-based io instead of FILE*-based,
missed O_TRUNC, etc
2006-11-18 22:03:26 +00:00
Denis Vlasenko 5a3395bc01 udhcp: fix indentation and style.
Eliminate (group) a lot of smallish *.h files
Remove lots of unneeded #includes
2006-11-18 19:51:32 +00:00
Denis Vlasenko abfc4cf6d8 Add names of people historically linked to bbox project 2006-11-18 16:30:04 +00:00
Denis Vlasenko f7eaccde13 nc: fix --help text 2006-11-18 02:17:37 +00:00
Denis Vlasenko a7189f01a4 add -Wundef, fix uncovered bugs 2006-11-17 20:29:00 +00:00
Denis Vlasenko 04c6386c45 forgot about avn add... :( 2006-11-17 18:58:49 +00:00
Denis Vlasenko 8a00f44bf4 runit: add runsv, runsvdir and sv. Oh yes.
It even seems to work. +11K. :(
2006-11-17 18:58:16 +00:00
Denis Vlasenko a5342b4541 httpd: make Bernhard happier 2006-11-17 18:26:57 +00:00
Bernhard Reutner-Fischer 8bfd215fb2 - Set INSTALL_OPTS according to the config. 2006-11-17 13:54:29 +00:00
Bernhard Reutner-Fischer 193bcf381e - fix generation of the busybox.links install script inputfile 2006-11-17 13:17:04 +00:00
Bernhard Reutner-Fischer 68532b3578 - typo fix 2006-11-17 12:47:50 +00:00
Bernhard Reutner-Fischer e766715032 - end may be used uninitialized.
- TODO: should eventually use skip_whitespace there
2006-11-17 11:28:00 +00:00
Denis Vlasenko b3a071543d httpd: reduce ifdef forest. comment out redundant PATH setting 2006-11-16 18:04:43 +00:00
Denis Vlasenko d4f3d1a4bd httpd:
fix union aliasing bug
symptom: wget of non-existent file gets redirected to /text/html/something
on second and subsequend wget attempts
fix double-free bug
symptom: glibc caught double-free (we didn't NULL config->xxx ptrs after free)
2006-11-16 16:20:12 +00:00
Denis Vlasenko 0871bc89fb httpd: add -i (inetd) and -f (foreground) otions.
-i makes possible to run httpd in both inetd and standalone mode
without recompile (or need to have two different binaries)
2006-11-16 16:17:02 +00:00
Denis Vlasenko e867b7ce86 httpd: stop being silly with setenv 2006-11-16 16:12:09 +00:00
Denis Vlasenko 83ea643d8d svlogd: new applet. +9k. Still too big, but it was 12k yesterday. 2006-11-16 02:27:24 +00:00
Mike Frysinger 3672fe9e91 remove duplicate flag decls 2006-11-15 21:52:10 +00:00
Denis Vlasenko 1119972f91 umount: umount -a shouldn't stop on first failure 2006-11-12 17:23:45 +00:00
Denis Vlasenko 6c5e5a0e85 httpd: cosmetic fixes (the bug which was being hunted down
turned out to be nonexistent :)
2006-11-10 23:28:57 +00:00
Denis Vlasenko 067e3f031a wget: fix error message.
Bad:
wget http://127.0.0.1:81/fgdg/Makefile
Connecting to 127.0.0.1[127.0.0.1]:81
: HTTP/1.0 404 Not Foundror 404 Not Found
Good:
wget http://127.0.0.1:81/fgdg/Makefile
Connecting to 127.0.0.1[127.0.0.1]:81
get: server returned error: HTTP/1.0 404 Not Found

nslookup: fix my mistake
applets: make Bernhard Fischer <rep.nop@aon.at> happy :)
2006-11-10 23:25:53 +00:00
Denis Vlasenko 07159f0f0e add && !defined(__UCLIBC__) to static link warning check 2006-11-09 00:00:12 +00:00
Denis Vlasenko 8528151658 small ipv6 doc changes; nslookup a tiny bit smaller 2006-11-07 19:05:43 +00:00
Denis Vlasenko 6476cc1089 getty: remove ancient termio support (was using termois anyway) 2006-11-07 01:52:10 +00:00
Denis Vlasenko 9f60929cc4 httpd: sendCgi() forked child needs to close opened
server socket and accepted socket
2006-11-05 19:47:33 +00:00
Denis Vlasenko 5af906e7c8 rename: compare_string_array -> index_in_str_array
introduce index_in_substr_array and use it in
iproute2
2006-11-05 18:05:09 +00:00
Denis Vlasenko 402151671b ps: add documentation on POSIX ps 2006-11-05 00:47:38 +00:00
Denis Vlasenko 77a1a53a98 usage.h: stop using ancient USAGE_xxx (we have USE_xx now) 2006-11-05 00:46:35 +00:00
Denis Vlasenko 9494919ea5 ps: implement POSIX-like options, most notably -o
(activated by CONFIG_DESKTOP)
2006-11-05 00:45:47 +00:00
Denis Vlasenko aae0311356 smart_ulltoa5: make available in libbb 2006-11-05 00:44:39 +00:00
Denis Vlasenko 459e4d6cf7 replace /proc scanning code by more versatile one.
Use it where appropriate.
Stop scanning /etc/passwd *for every process*!!! (uid->username)
top: reduce memory usage - we won't save unneeded fields
from /proc info anymore. Downside: ~+250 bytes of code
2006-11-05 00:43:51 +00:00
Denis Vlasenko fa07680091 top: improve CPU% calculation
style fixes
2006-11-05 00:38:51 +00:00
Denis Vlasenko 9d4533ede1 Fix kbuild bugs noticed by Bernhard Fischer <rep.nop@aon.at> 2006-11-02 22:09:37 +00:00
Denis Vlasenko dd539f7687 Unneeded code removed, usused field "unsigned pscpu" removed 2006-11-01 20:20:37 +00:00
Denis Vlasenko 9225854144 mostly style fixes 2006-11-01 10:25:35 +00:00
Denis Vlasenko 048c93cc55 pidof: reduce #ifdef forest 2006-11-01 09:17:47 +00:00
Denis Vlasenko 35fb512728 PID should be stored in pid_t, not int or long.
find_pid_by_name() was returning 0 or -1 in last array element,
but -1 was never checked. We can use just 0 intead.
2006-11-01 09:16:49 +00:00
Denis Vlasenko d3ada32285 ps: reduce #ifdef forest 2006-11-01 09:14:52 +00:00
Denis Vlasenko 966ec7c067 #if CONFIG_xxx -> #if ENABLE_xxx 2006-11-01 09:13:26 +00:00
Denis Vlasenko 31c65f2456 find: -type T was actually meaning ! -type T!
With this fix, "make mrproper" works correctly
2006-10-31 23:39:37 +00:00
Denis Vlasenko 14aa9f7415 build system: Makefiles are in source dir, add $(srctree) 2006-10-31 23:03:09 +00:00
Denis Vlasenko b141b9b512 reads: fix bug 1078 2006-10-31 22:46:08 +00:00
Denis Vlasenko 4126b1f5c6 add usefun info on SIGINT handling peculiarities 2006-10-31 18:41:29 +00:00
Denis Vlasenko 8c76487f06 login: add big fat comment about SIGINT - prevent
adding/deleting that code again and again
2006-10-31 18:30:56 +00:00
Denis Vlasenko 6ae8079e2d login: re-enable Ctrl-^C before execing shell. 2006-10-31 17:34:44 +00:00
Denis Vlasenko 3b8ff68ec8 dd: fix bugs: always assumed conv=sync, died on write errors
w/o perror and statictics. Several small improvements
2006-10-31 15:55:56 +00:00
Denis Vlasenko 5f18e7ca33 find: implement -prune. "make clean" now works! :) 2006-10-31 03:21:02 +00:00
Denis Vlasenko a3b4fed8b3 find: fix implicit -print (sometime differed from standard) 2006-10-31 03:20:13 +00:00
Denis Vlasenko 6191a7a007 find: implement ( ) 2006-10-30 02:10:47 +00:00
Denis Vlasenko afea46b4e4 "#warning: http://...." doesn't work (gcc thinks that it's a comment!) 2006-10-29 19:37:13 +00:00
Denis Vlasenko 41be5b863d website: fix link 2006-10-29 19:34:49 +00:00
Denis Vlasenko 8d463072df website: announce 1.2.2.1 2006-10-29 19:30:55 +00:00
Denis Vlasenko 5d499e1600 find: a lot more compliant to 'standard' find
(we were not respecting order of actions!).
Add -o and -a handling.
2006-10-29 19:07:01 +00:00
Denis Vlasenko e2fb719ba3 find: small improvement 2006-10-29 19:03:56 +00:00
Denis Vlasenko df0553bbd2 find: fix -exec to work like stock find does. 2006-10-29 00:21:47 +00:00
Denis Vlasenko 656f746e74 ls: silly comment fixes 2006-10-28 13:02:55 +00:00
Denis Vlasenko 8c0c119130 chmod: typo in comments 2006-10-28 12:42:40 +00:00
Denis Vlasenko 94cf69fe3e ls: cleanup part 2. ifdef forest is much less scary now :) 2006-10-28 12:37:51 +00:00
Denis Vlasenko 5c7596058d ls: cleanup part 1 2006-10-28 12:37:16 +00:00
Denis Vlasenko 8c35d65c43 recursive_action: add depth param
chmod: match coreutils versus following links
2006-10-27 23:42:25 +00:00
Denis Vlasenko e80e2a3660 chgrp: just call chown! :) 2006-10-27 23:28:38 +00:00
Denis Vlasenko 3b8fc1c582 recursive_action: preparatory changes. will introduce "int level". 2006-10-27 17:59:14 +00:00
Denis Vlasenko 51b4c92f80 chown: add -vcf support if CONFIG_DESKTOP
chmod: stop following symlinks
2006-10-27 16:07:20 +00:00
Denis Vlasenko fefb279ace chmod: support -vcf if CONFIG_DESKTOP 2006-10-27 15:13:54 +00:00
Denis Vlasenko cf70433173 modprobe: reformat to match bbox style 2006-10-27 15:12:50 +00:00
Denis Vlasenko 82f9e28513 OFF_T_FMT -> OFF_FMT 2006-10-27 13:00:07 +00:00
Denis Vlasenko 25d8062128 top: batch mode should output all processes 2006-10-27 09:34:22 +00:00
Denis Vlasenko b54b208d90 Fix largefile breakage; advance version to 1.2.2 2006-10-27 09:05:40 +00:00
Denis Vlasenko dca0b707c0 reshuffle libbb.h contents so that order of decls makes sense
Found bad typo in largefile support :)
2006-10-27 09:05:02 +00:00
Denis Vlasenko 621204bbf6 get_terminal_width_height: do not pass insanely large values 2006-10-27 09:03:24 +00:00
Denis Vlasenko d3d004dd35 last nail into error_msg() (de)capitalization 2006-10-27 09:02:31 +00:00
Denis Vlasenko 1340ca8c87 As usual, I forgot "svn del"... 2006-10-27 07:17:36 +00:00
Denis Vlasenko 2fe7b73d99 ...and yet another small fix. Ouch... 2006-10-26 23:39:04 +00:00
Denis Vlasenko 1de0830e62 Fix minor breakage in previous commit 2006-10-26 23:32:43 +00:00
Denis Vlasenko ddec5af6b0 rename functions to more understandable names 2006-10-26 23:25:17 +00:00
Denis Vlasenko f0ed376eda remove bb_printf and the like 2006-10-26 23:21:47 +00:00
Denis Vlasenko 670a6626ca add ipv6 developer doc 2006-10-26 17:21:13 +00:00
Denis Vlasenko ebe578ab2f nslookup: make it more IPv6 friendly 2006-10-26 17:17:59 +00:00
Denis Vlasenko 68f2187265 mount: use switch (compare_string_array(..))
where appropriate, saves >100 bytes.
2006-10-26 01:47:34 +00:00
Denis Vlasenko 1457915afc xconnect is non-conforming to "xfunc like libc" rule. Fixing 2006-10-26 01:09:46 +00:00
Denis Vlasenko 940b2e4b73 ip: "ip addr del" and "ip addr delete" both should work 2006-10-26 00:38:22 +00:00
Denis Vlasenko c6f188def8 silly size savings and capitalization fixes 2006-10-26 00:37:00 +00:00
Bernhard Reutner-Fischer e63a0dee9e - revert r16191; re-add resize() applet.
text	   data	    bss	    dec	    hex	filename
    288	      0	      0	    288	    120	console-tools/_resize.o.gcc-2.95
    258	      0	      0	    258	    102	console-tools/_resize.o.gcc-3.3
    252	      0	      0	    252	     fc	console-tools/_resize.o.gcc-3.4
2006-10-25 15:07:56 +00:00
Denis Vlasenko 8077850330 sed: mostly style fixes, very small changes in actual code 2006-10-25 12:46:46 +00:00
Denis Vlasenko d18a3a20db use skip_whitespace where appropriate 2006-10-25 12:46:03 +00:00
Denis Vlasenko c8400a2162 wget: wget $'-\207' ... should not be allowed to work. ever. :)
So fix wget & getopt32. Also fix multiple --header options
order: add and use rev_llist.
2006-10-25 00:33:44 +00:00
Rob Landley 44c7917cab Put up BusyBox 1.2.2 and get out of Denis' way. Also minor tweak to
autodocifier.pl so USAGE_ macros that haven't been converted to USE_ yet 
get correctly stripped out when generating BusyBox.html.
2006-10-24 21:46:19 +00:00
Bernhard Reutner-Fischer d35d540217 - add nmeter and raidautorun to defconfig. 2006-10-24 20:07:29 +00:00
Bernhard Reutner-Fischer a481d87ff7 - we take exactly one argument. 2006-10-24 20:06:55 +00:00
Denis Vlasenko 7534e0834f wget: -100 bytes, reduce stack usage, remove --header length limit 2006-10-23 23:21:58 +00:00
Denis Vlasenko 703aa13ff5 watch: fix warning
getty: fix breakage; fix excessive stack usage
2006-10-23 22:43:02 +00:00
Denis Vlasenko 4e70bf4359 getty: conditionally disable handling of all-caps terminals. 2006-10-23 10:17:34 +00:00
Denis Vlasenko 50e77e1cc1 getty: cleanup part 2 2006-10-23 02:11:22 +00:00
Denis Vlasenko dce3fde414 getty: cleanup part 1 2006-10-23 02:10:45 +00:00
Denis Vlasenko 7c4503d223 __GLIBC__ -> defined(__GLIBC__) 2006-10-23 00:42:24 +00:00
Denis Vlasenko 2295b49169 grep: "grep -h pattern file1 file2" ignored -h
(precluded kernel's "make modules")
2006-10-22 11:42:51 +00:00
Denis Vlasenko 9b44db5d9d cp: update help text 2006-10-22 10:05:01 +00:00
Denis Vlasenko f24e1f40e0 cp: add support for -s, -l. Fix free(nonmalloc) bug.
Add doc on POSIX's rules on -i and -f (insane!).
ln: make "ln dangling_symlink new_link" work.
2006-10-21 23:40:20 +00:00
Denis Vlasenko 8d73c35916 watch: execute command thru shell, not fork/exec. Other fixes 2006-10-20 23:48:30 +00:00
Denis Vlasenko 9bff26cccb chpst: add overlooked copyright statement 2006-10-20 19:40:44 +00:00
Denis Vlasenko c108ed5497 raidautorun: new applet, by:
Thomas Jarosch (email?) and
Bernhard Fischer <rep.nop@aon.at>
2006-10-20 19:39:48 +00:00
Denis Vlasenko 456fa6c0b1 readlink: do not emit errors if file doesnt not exist / not a link
getopt32: add =N support
2006-10-20 18:36:55 +00:00
Denis Vlasenko df51892690 Added compile-time warning for STATIC+GLIBC build 2006-10-20 13:42:57 +00:00
Denis Vlasenko e1a0d486e4 message string changes, mostly for consistency, also -32 bytes in .rodata 2006-10-20 13:28:22 +00:00
Bernhard Reutner-Fischer dd2982882b - remove duplicate flags (-funsigned-char -fno-builtin-strlen) 2006-10-20 12:21:17 +00:00
Denis Vlasenko b79b87a30f build system: (try to) get rid of bb_config.h hack 2006-10-19 22:17:44 +00:00
Denis Vlasenko 9fa9950784 build system: check for ENABLE_, USE_ and SKIP_ (not only for CONFIG_) 2006-10-19 22:14:58 +00:00
Denis Vlasenko b560577cb2 move usage_compressed.h generation into applets/ 2006-10-19 22:12:47 +00:00
Denis Vlasenko 52b5eba715 applets/applets.o must be rebuilt if usage.h is modified. 2006-10-19 22:11:06 +00:00
Denis Vlasenko fdc101782a scripts/usage.c: de-uglify #includes 2006-10-19 22:10:07 +00:00
Eric Andersen 534d88e34e console-tools/resize.c is apparently leftover from a reverted patch.
Since it is a 0 length file, it gets nuked by 'make distclean' so
I suppose might as well kill it off properly.
2006-10-19 22:02:29 +00:00
Denis Vlasenko 13c5a6832f mount: support user mounts if CONFIG_DESKTOP 2006-10-16 22:39:51 +00:00
Denis Vlasenko f46be09106 mdev: reduce excessive indentation 2006-10-16 19:39:37 +00:00
Denis Vlasenko 4e33e07f60 strip -> $(STRIP); fix "unused variable" warning
(patch by Diekema, Jon (AGRE) <Jon.Diekema@smiths-aerospace.com>)
2006-10-16 18:24:57 +00:00
Denis Vlasenko 5f03158f66 ash: fix segfault in ash.
patch by walter harms <wharms@bfs.de>
2006-10-16 01:33:16 +00:00
Denis Vlasenko d0e70af9d1 nc: fix 2 my own buglets, and few someone else's too. 2006-10-16 01:10:28 +00:00
Denis Vlasenko bf39216cc4 grep: -r didn't close files, producing "Too many open files" 2006-10-15 18:38:01 +00:00
Denis Vlasenko c6ec8c9680 telnetd: check ptsname() for NULL 2006-10-15 18:22:05 +00:00
Denis Vlasenko 023b57d935 wget: xatoi's were oversealous ("200 OK" isn't a number) 2006-10-15 17:05:55 +00:00
Denis Vlasenko efeed5ed28 fdisk: compilation fix 2006-10-14 16:16:03 +00:00
Denis Vlasenko 3544ae6004 grep: fix combination of -r and -h 2006-10-14 14:51:59 +00:00
Denis Vlasenko 3a6755f56f grep: add support for -r 2006-10-14 14:24:30 +00:00
Denis Vlasenko c345d8e945 sulogin: add support for $SUSHELL & $sushell 2006-10-14 11:47:02 +00:00
Denis Vlasenko 997aa1179e modprobe: fix for 2.4 kernels - by
Yann E. MORIN <yann.morin.1998@anciens.enib.fr>
2006-10-14 11:12:20 +00:00
Denis Vlasenko ea62077b85 add open_read_close() and similar stuff 2006-10-14 02:23:43 +00:00
Denis Vlasenko 88ca067690 xread/write can use full_read/write (smaller code) 2006-10-12 22:44:13 +00:00
Denis Vlasenko 2d5ca60bfb bb_get_[chomped]line_from_file wasn't descriptive enough.
Renaming...
2006-10-12 22:43:20 +00:00
Denis Vlasenko 372686bde7 cut, mount: small improvements 2006-10-12 22:42:33 +00:00
Denis Vlasenko 9c267b851e style fixes 2006-10-12 20:06:18 +00:00
Denis Vlasenko 98ae2160b6 fdisk: separate sun/aix/etc code into #included files 2006-10-12 19:30:44 +00:00
Denis Vlasenko a6dbb08a48 small style fixes 2006-10-12 19:29:44 +00:00
Denis Vlasenko 12f5676cce execable: no need to check getenv for NULL, it works anyway. 2006-10-12 06:15:13 +00:00
Denis Vlasenko 5cb46485dd execable.c: forgot to do "svn add" again... 2006-10-12 06:12:11 +00:00
Denis Vlasenko f6f43df60b ifupdown: stop emitting annoying/misleading error messages.
Patch by Gabriel Somlo <somlo at cmu.edu>
2006-10-11 22:16:56 +00:00
Denis Vlasenko 8de82bf84f hush.c: stop using __FILE__ (bad in out-of-tree builds) 2006-10-11 21:38:33 +00:00
Denis Vlasenko 665b02cb60 build system: fix build in separate obj tree 2006-10-11 21:24:42 +00:00
Denis Vlasenko 1db39b2f51 nmeter: new applet. ~4k
Fix build proble on x86_64
2006-10-11 20:59:02 +00:00
Denis Vlasenko 1114de7219 od: provide full-blown od from coreutils if CONFIG_DESKTOP 2006-10-10 23:26:05 +00:00
Denis Vlasenko cba9ef5523 fixes from Vladimir Dronnikov <dronnikov@gmail.ru> 2006-10-10 21:00:47 +00:00
Bernhard Reutner-Fischer 1ac42bf66e - add option -t
mkinitrd and mkinitramfs both require -t.
2006-10-10 15:28:41 +00:00
Denis Vlasenko da8f43fd34 build system: fix for non-i386 builds 2006-10-09 19:47:38 +00:00
Denis Vlasenko ca3c981c07 start_stop_daemon: add -N <nice> compat
[re]nice: add support for -nNNN w/o spaces, -NNN (nice only),
          simplified code
2006-10-08 23:36:17 +00:00
Denis Vlasenko 7039a66b58 correct largefile support, add comments about it. 2006-10-08 17:54:47 +00:00
Denis Vlasenko 1385899416 attempt to regularize atoi mess. 2006-10-08 12:49:22 +00:00
Denis Vlasenko 5625415085 dd: make it recognize not only 'k' but 'K' too;
make it (partially) CONFIG_LFS-aware
2006-10-07 16:24:46 +00:00
Denis Vlasenko 890ac9deb2 awk: && -> & in "n->info && OPCLSMASK" - fixes bug 1067 2006-10-07 15:16:19 +00:00
Denis Vlasenko f7a57848c2 eject: remove unmounting. It is buggy for many non-trivial
mounts, and can be done as shell script.
2006-10-07 15:00:29 +00:00
Denis Vlasenko 96e9d3c968 wget: don't be careless with xstrdup'ing 2006-10-07 14:28:55 +00:00
Denis Vlasenko a655152b00 wget: fix download of URLs like:
http://busybox.net?var=a/b
http://busybox.net?login=john@doe
http://busybox.net#test/test
2006-10-07 14:28:28 +00:00
Denis Vlasenko bede7d0ebe build system: do not generate include/linux 2006-10-06 16:14:12 +00:00
Denis Vlasenko 4fa499a17b build system: remove loeftover (two empty dirs) 2006-10-06 13:51:04 +00:00
Denis Vlasenko c12f53090b dnsd fix; option_mask32 added. dnsd needs more love. 2006-10-06 09:49:47 +00:00
Denis Vlasenko 4e6ceb4455 chpst: fix vda's silly mistakes
Patch by Vladimir Dronnikov <dronnikov@gmail.ru>
2006-10-06 08:54:49 +00:00
Denis Vlasenko 000b9ba91f eject: -T fix 2006-10-05 23:12:49 +00:00
Denis Vlasenko de59c0f58f httpd: add -u user[:grp] support 2006-10-05 22:50:22 +00:00
Denis Vlasenko 01c27fc5ac which: -84 bytes 2006-10-05 21:10:53 +00:00
Denis Vlasenko a3310527db make defconfig now works 2006-10-05 18:26:35 +00:00
Denis Vlasenko 8bf7bb8541 yet another fixlet: make clean/distclean/mrproper 2006-10-05 17:42:55 +00:00
Denis Vlasenko 1868409c86 fixing build system overhaul fallout... 2006-10-05 17:11:08 +00:00
Denis Vlasenko 5d2f1736d9 build system: small optimization 2006-10-05 10:26:05 +00:00
Denis Vlasenko 7d219aab70 build system overhaul 2006-10-05 10:17:08 +00:00
Denis Vlasenko 8f8f268cfd bb_applet_name -> applet_name 2006-10-03 21:00:43 +00:00
Denis Vlasenko 67b23e6043 getopt_ulflags -> getopt32.
It is impossible to formulate sane ABI based on
size of ulong because it can be 32-bit or 64-bit.
Basically it means that you cannot portably use
more that 32 option chars in one call anyway...
Make it explicit.
2006-10-03 21:00:06 +00:00
Denis Vlasenko 40920825d5 rename bb_default_error_retval -> xfunc_error_retval 2006-10-03 20:28:06 +00:00
Denis Vlasenko b6332248ca fdformat: remove redundant check 2006-10-03 19:57:50 +00:00
Denis Vlasenko 9275814a9e lots of silly indent fixes 2006-10-03 19:56:34 +00:00
Denis Vlasenko cf94446af7 random style fixes 2006-10-03 19:02:20 +00:00
Denis Vlasenko 6edaddec02 traceroute: fix compilation if netinet/protocols.h is missing 2006-10-03 18:19:02 +00:00
Denis Vlasenko f0a97fb43a Yeah, yeah... I forgot about 'svn add'... fixing that 2006-10-03 17:52:24 +00:00
Denis Vlasenko fe54458e46 runit/chpst: "change process state" utility
It's "nice" on steroids - can set uid/gid, mem/cpu limits etc. +3.5k
2006-10-03 15:57:40 +00:00
Denis Vlasenko 7c1ed2e922 traceroute: do not look up icmp protocol# in /etc, it is well-known :) 2006-10-03 10:47:35 +00:00
Denis Vlasenko 1c3577f91d ifupdown: Debian users contributed improvement to it 2006-10-02 20:57:10 +00:00
Denis Vlasenko 2e864cd219 eject: -T (implements single button open/close) 2006-10-02 20:49:25 +00:00
Denis Vlasenko 546cd1881a mount: accept and ignore -s (sloppy) option.
needed for compatibility with Linux automounter.
2006-10-02 18:52:49 +00:00
Denis Vlasenko e2016e145b sed: -e options were handled in reverse order. fix that. 2006-10-01 21:37:40 +00:00
Denis Vlasenko b97c9842a5 sed: unbreak multiple -e, -f option handling (my fault) 2006-10-01 21:05:12 +00:00
Denis Vlasenko bb119d059a gzip: add a bit of comment. The code itself
is too bloated to work on it...
2006-10-01 16:44:04 +00:00
Denis Vlasenko 97a8dd3857 g[un]zip: add support for -v (verbose).
Add CONFIG_DESKTOP, almost all bloat from this change
is hidden under that.
2006-10-01 15:55:11 +00:00
Denis Vlasenko f8aa109a9f wget: make progress bar and ETA work correctly with -c 2006-10-01 10:58:54 +00:00
Denis Vlasenko aecabffb8b dpkg: fix use-after-free (bug 939) 2006-09-30 21:05:25 +00:00
Denis Vlasenko 55a994055f lsmod: repair indentation
httpd: ifdef CONFIG -> if ENABLE (shorted, catched typos)
2006-09-30 20:41:44 +00:00
Denis Vlasenko 3038ac9c19 vconfig: fix bug 701 (I be damned if I understand it) 2006-09-30 19:37:25 +00:00
Denis Vlasenko 02be0f5350 syslogd: do not retry udp sends (can stall syslogd for extended periods
of time), resolve remote logging host before daemonization
2006-09-30 19:21:24 +00:00
Denis Vlasenko 14c1940255 syslogd: getopt_ulflags'ification (save ~50 bytes) 2006-09-30 19:20:00 +00:00
Denis Vlasenko 1decd0e529 syslogd: add option to suppress logging of messages lower than level N (-n N) 2006-09-30 19:17:40 +00:00
Denis Vlasenko 39d551fd15 fbset: store short string in the structure itself instead of the pointer
(small size saving)
2006-09-30 16:28:30 +00:00
Denis Vlasenko 274b8c0639 fbset: add support for -a (bug 1017) 2006-09-30 16:22:59 +00:00
Denis Vlasenko 7e3eb5171b no-op (just for svn commit run. 2.6.18 oopses on that, need to reproduce) 2006-09-30 08:32:41 +00:00
Denis Vlasenko 7935a5a992 libiproute/ll_map.c: fix bug 279
("On-demand net module loading fails with CONFIG_FEATURE_IFUPDOWN_IP")
2006-09-30 00:18:16 +00:00
Denis Vlasenko 70210168fc wc: optionally support very large files in wc 2006-09-29 23:41:59 +00:00
Denis Vlasenko 3ed001ff26 wc: reduce source cruft, make it so that "wc -c" (one option, no filenames)
will not print leading blanks.
2006-09-29 23:41:04 +00:00
Rob Landley 530c3ef818 Mention the new gpl@busybox.net address. 2006-09-29 22:43:12 +00:00
Denis Vlasenko 0b193a7871 losetup: use /dev/loopN or /dev/loop/N according to CONFIG_FEATURE_DEVFS=n/y 2006-09-29 21:47:11 +00:00
Denis Vlasenko a959588b80 Yet another silly little byte saving. couldn't -> cannot 2006-09-29 21:30:43 +00:00
Denis Vlasenko 6c30db8bd3 grep: add help text; fix style 2006-09-29 21:04:12 +00:00
Denis Vlasenko 51937534fb grep: implement -o option. Patch by Jac Goudsmit. 2006-09-29 20:58:53 +00:00
Denis Vlasenko 266bc17690 top: add support for -b, -n <iterations> 2006-09-29 17:16:39 +00:00
Denis Vlasenko b1726785f9 mount: fix bug 946 (mount -f should update mtab) 2006-09-29 14:43:20 +00:00
Denis Vlasenko f0d6cc8ca9 getopt_ulflags: fix indentation in comment (needs to be 8 _spaces_
in order to look correct to both 4 tab and 8 tab population).
Add comment about :: (which indicates optional argument).
2006-09-29 13:56:58 +00:00
Denis Vlasenko b02ef82c99 getopt_ulflags: formatting fixes 2006-09-29 08:23:42 +00:00
Denis Vlasenko 6248a734e2 xargs: simplify option parsing 2006-09-29 08:20:30 +00:00
Denis Vlasenko 981b24db5e rt_names.c: move few strings into rodata 2006-09-28 22:36:23 +00:00
Denis Vlasenko 5492884311 dpkg: style fixes; short -> int (generated code is smaller) 2006-09-28 22:35:42 +00:00
Denis Vlasenko 57308afb5b dpkg: reduce bss usage by ~130 kbytes (yes, kilobytes!)
at the cost of ~100 bytes of text.
Improves friendliness to nommu systems.
(Dunno whether nommu people ever use dpkg, though...)
2006-09-28 22:34:46 +00:00
Denis Vlasenko 06b543b217 ifupdown: make dhcp start/stop scripts user configurable
in /etc/network/interfaces. Patch author is Gabriel L. Somlo <somlo@cmu.edu>
2006-09-28 22:31:51 +00:00
Denis Vlasenko 524176680d Tried to find sha1_crypt - nope... ok, save few bytes in md5_sha1_sum.c
(time to sleep, 02:28 in the morning)...
2006-09-28 00:29:00 +00:00
Denis Vlasenko de9ec92958 usage.h: fix compile-time bugs exposed by previous change 2006-09-27 23:31:59 +00:00
Denis Vlasenko ce97960a6e usage.h: remove ugly tricks. We have USE_FEATURE_xxx now.
Few bugs are now exposed...
2006-09-27 23:31:08 +00:00
Denis Vlasenko c16bd212e3 silly switch style fix 2006-09-27 19:51:06 +00:00
Denis Vlasenko 94d5d82bd8 crontab: we indent using tabs 2006-09-27 19:48:56 +00:00
Denis Vlasenko 956a569360 losetup: with no arguments lists all /dev/loopN. Corrected help text.
(patch by Vladimir Dronnikov <dronnikov@gmail.ru>)
2006-09-27 14:51:27 +00:00
Denis Vlasenko 0bb628f4f3 kill: implement killall5. OpenWRT folks will be happy.
However their code was unusably different from sysvinit original.
Run tested.
2006-09-27 14:25:33 +00:00
Denis Vlasenko a77947f5bb kill: fix bugs (kill -l output was horrible), fix style, constify data 2006-09-27 14:19:16 +00:00
Denis Vlasenko be905d550c process utilities related style cleanup 2006-09-27 14:17:31 +00:00
Denis Vlasenko 2f4399c6cc ifupdown: fix for standalone shell; removed hardcoded PATH 2006-09-27 14:14:51 +00:00
Denis Vlasenko 0534125ccc ifupdown: style cleanup, no code changes 2006-09-26 20:35:30 +00:00
Denis Vlasenko e175ff252f several fixes from openWRT project 2006-09-26 17:41:00 +00:00
Denis Vlasenko 22f6dcb47c login: fix getopt_ulflags fallout (wasn't taking username supplied by getty) 2006-09-26 16:31:01 +00:00
Denis Vlasenko 8b8c75e6ab httpd: sanitize indentation 2006-09-26 10:07:41 +00:00
Denis Vlasenko a552eeb498 wget: add (configurable) large file support. Run tested. 2006-09-26 09:22:12 +00:00
Eric Andersen 3312c989e6 fix 'grep -C' which requires an argument 2006-09-25 22:18:56 +00:00
Denis Vlasenko d9867320b4 vlock: make message shorter 2006-09-24 02:10:03 +00:00
Denis Vlasenko da3cec9c85 mount: fix breakage from recent changes (spurious -ro mounts) 2006-09-24 01:01:01 +00:00
Rob Landley 29d94b907f Another attempt at untangling the logic so the compiler can follow it and not
generate pointless warnings.
2006-09-23 19:56:21 +00:00
Denis Vlasenko a94554d010 wget: fix bug where wget creates null file if there is no remote one.
add O_LARGEFILE support (not run tested :).
2006-09-23 17:49:09 +00:00
Denis Vlasenko 01a74f9649 applets.c: fix indentation 2006-09-23 16:34:39 +00:00
Denis Vlasenko c290563319 remove unneeded #includes, fix indentation 2006-09-23 16:01:09 +00:00
Denis Vlasenko c1876d7364 inetd: deindent main loop, other readability enhancements 2006-09-23 15:58:01 +00:00
Denis Vlasenko 4c196a80fc hexdump: fixlet for my breakage 2006-09-23 15:53:01 +00:00
Denis Vlasenko ec17d437ab inetd: reformat with tabs for indentation 2006-09-23 15:18:38 +00:00
Denis Vlasenko 2dbeaa95ca hexdump: deindent, almost fits into 80 columns now 2006-09-23 13:31:46 +00:00
Denis Vlasenko a36a676923 correct_password: undo whitespace damage.
vlock + correct_password: fix incorrect line breaks in messages.
2006-09-23 13:11:49 +00:00
Denis Vlasenko 7f1f5b001f ifupdown: getopt_ulflags'ification. 2006-09-23 12:49:01 +00:00
Denis Vlasenko a65a17700a arping: fix bug (getopt_ulflags and optarg don't mix),
remove unreachable error path.
2006-09-23 12:46:30 +00:00
Denis Vlasenko fe76cd5a5c insmod: getopt_ulflags'isation 2006-09-23 12:32:58 +00:00
Denis Vlasenko d78b433414 passwd: getopt_ulflags'isation 2006-09-23 12:30:03 +00:00
Denis Vlasenko 6429aabbf1 bb_askpass: shorten static password buffer. 256 is way too large.
simplify code a bit.
2006-09-23 12:22:11 +00:00
Rob Landley b97f07f5a1 Follow-up to 16172: this also doesn't produce a warning for me on gcc 4.1,
without having to feed the compiler nonsense.
2006-09-22 19:11:59 +00:00
Rob Landley 0372197385 "I'll think about it" != "apply it now". It means I need to think about it. 2006-09-22 18:47:45 +00:00
Denis Vlasenko 754a88f7aa netstat: getopt_ulflags'isation 2006-09-22 16:02:40 +00:00
Denis Vlasenko 01e88f0339 gzip: getopt_ulflags'isation 2006-09-22 15:13:38 +00:00
Denis Vlasenko 27ee7ba95e losetup: getopt_ulflags'ification + small fix for perror_nomsg 2006-09-22 14:53:41 +00:00
Denis Vlasenko 099efbf99e awk: getopt_ulflags'isation 2006-09-22 09:02:30 +00:00
Denis Vlasenko 750fc6d7bb sed: getopt_ulflags'isation 2006-09-22 08:56:03 +00:00
Denis Vlasenko 8514fc5681 hostname: getopt_ulflags'isation 2006-09-22 08:53:14 +00:00
Denis Vlasenko 0e87d347e8 telnetd: getopt_ulflags'isation 2006-09-22 08:50:29 +00:00
Denis Vlasenko 109d21fe74 adjtimex: getopt_ulflags'isation 2006-09-22 08:47:54 +00:00
Denis Vlasenko cb1ba86507 logger: getopt_ulflags'isation 2006-09-22 08:44:58 +00:00
Denis Vlasenko f47ff100cc getopt: fix whitespace damage 2006-09-22 08:42:06 +00:00
Denis Vlasenko cad36681d2 readprofile: getopt_ulflags'isation 2006-09-22 08:39:49 +00:00
Denis Vlasenko 7869c018b5 ipcs: fix my recent breakage 2006-09-22 08:30:52 +00:00
Bernhard Reutner-Fischer ae843e9cc8 - add new applet resize.
text    data     bss     dec     hex filename
    185       0       0     185      b9 console-tools/resize.o
    255       0       0     255      ff console-tools/resize.o.print
2006-09-22 08:18:41 +00:00
Rob Landley e9a7a6212b Change license statements (and clean up headers) on some of the files that
Erik or I are primary copyright holders on.
2006-09-22 02:52:41 +00:00
Bernhard Reutner-Fischer 05592ac00c - update and expand TODO a little bit 2006-09-21 22:58:38 +00:00
Bernhard Reutner-Fischer 3503ff72c6 - pull r15578 from busybox_scratch branch:
- fix bug where it would behave wrong if ./nohup.out was not writable.
  - debloat and make it readable while at it.
$ size coreutils/nohup.o*
   text    data     bss     dec     hex filename
    362       0       0     362     16a coreutils/nohup.o.trunk
    344       0       0     344     158 coreutils/nohup.o
$ make bloatcheck
function                                             old     new   delta
nohup_main                                           324     310     -14
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-14)             Total: -14 bytes
2006-09-21 22:10:24 +00:00
Bernhard Reutner-Fischer 42f67026a1 - silence gcc warning about a funcptr possibly being used uninitialized.
This is a perfect example on where we should NOT care if the functor is not
  initialized since the result will not be what the user may expect.
  Safe bet would be to init to NULL, but let's try normal uu for good measure.
- fix commentary typo while at it.
2006-09-21 20:40:56 +00:00
Denis Vlasenko ce32f65a1b mount: nfs mount should enable bb_error-to-syslog support 2006-09-21 12:30:16 +00:00
Bernhard Reutner-Fischer a528643330 - gcc-2.95 doesn't support -static-libgcc
- remove Winline
2006-09-21 11:54:51 +00:00
Denis Vlasenko 116080a13a mount: make Rob happy by reinstating #defines 2006-09-21 11:13:08 +00:00
Rob Landley fbdf121b7d Teach get_terminal_width_height to fall back to $LINES and $COLUMNS when
used via things like a serial console.
2006-09-20 22:06:01 +00:00
Rob Landley 4ef6f647a3 The version checked into the tree is a snapshot of an unifinished applet, and
you just made lots of ">>>>>>> mine" lines show up in my working copy of this.

Please don't do that again.
2006-09-20 21:57:36 +00:00
Rob Landley eb84a42fdd The Software Freedom Law Center wants us to add a copyright notice to the
generated binaries, to make copyright enforcement easier.  Our liason with
them (Bradley Kuhn) suggested the following text:

> Copyright (C) YEAR-2006  Erik Andersen, Rob Landley, and others.
> Licensed under GPLv2.  See source distribution for full notice.

And the busybox help message seems the least offensive place to put it.  (At
some point in the future, I need to strip 128 bytes from the binary to feel
good about this, though. :)

Minor header file cleanup while I was there, since libbb.h already #includes
most of that stuff...
2006-09-20 21:41:13 +00:00
Rob Landley 94b383d419 License clarification. 2006-09-20 20:01:29 +00:00
Bernhard Reutner-Fischer d1f939eaf3 - fix documentation for the command-line options of ipcs. Closes #1036 2006-09-20 15:56:53 +00:00
Bernhard Reutner-Fischer a6585774f9 - fix embarrassing typo of mine. Closes bug #1038 2006-09-20 15:29:13 +00:00
Denis Vlasenko 3ccc100670 ipcs: fix output (misaligned columns) 2006-09-19 17:43:56 +00:00
Denis Vlasenko c7b9bad519 ipcs: getopt_ulflag'ification, -170 bytes 2006-09-19 17:40:31 +00:00
Denis Vlasenko 79deb66c35 stty: fix few bugs found in testing 2006-09-19 15:12:12 +00:00
Denis Vlasenko 2969c772c2 getty: oops... removing duplicate #include <syslog.h> 2006-09-19 14:47:54 +00:00
Denis Vlasenko debaf2fe02 stty: reorder code, reducing need in forward declarations.
added few missed bits of error checking for parameters.
2006-09-19 14:31:44 +00:00
Denis Vlasenko 20b253d2d8 stty: convert "enum mode_type" into unnamed enum
(reduces code obfuscation); deindent set_mode;
add _or_die suffixes to few functions
2006-09-19 14:24:23 +00:00
Denis Vlasenko 8971cdaeca stty: reduce #ifdef forest 2006-09-19 14:20:22 +00:00
Denis Vlasenko e40c04b826 stty: simplify linewrapping code a bit 2006-09-19 14:19:42 +00:00
Denis Vlasenko 9efb070dcb stty: style fixes 2006-09-19 14:17:10 +00:00
Denis Vlasenko 7eab79acc5 stty: fix a longstanding FIXME (was able to die half-way setting term params) 2006-09-19 14:16:28 +00:00
Denis Vlasenko 85f9e32f7f mount: fstabname needs to be const char* 2006-09-19 14:14:12 +00:00
Denis Vlasenko 23514fe251 mount: fix warning (printf field width of * wants int, not size_t) 2006-09-19 14:07:52 +00:00
Denis Vlasenko f70265290c getty: #include <syslog.h> 2006-09-19 13:50:55 +00:00
Denis Vlasenko 0b5fd45ef7 change char *string = "foo" -> char string[] = "foo"
function                                             old     new   delta
xsetenv                                               45      44      -1
iproute_list_or_flush                               1834    1833      -1
ipaddr_modify                                       1915    1914      -1
ipaddr_list_or_flush                                1861    1860      -1
invarg                                                39      38      -1
do_set                                              1259    1258      -1
bb_verror_msg                                        268     267      -1
create_icmp_socket                                   142     140      -2
create_icmp6_socket                                  142     140      -2
bb_full_fd_action                                    324     322      -2
bb_path_mtab_file                                     10       -     -10
.rodata                                           214796  214720     -76
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/11 up/down: 0/-99)            Total: -99 bytes
2006-09-19 09:55:09 +00:00
Denis Vlasenko 9213a9e0f2 whitespace cleanup 2006-09-17 16:28:10 +00:00
Denis Vlasenko a6127aacef mount: style fixlet 2006-09-17 15:51:52 +00:00
Denis Vlasenko 6231e870ec style fixes 2006-09-17 15:45:48 +00:00
Denis Vlasenko 029c469934 mount: revert mount --bind to using "bind" as fstype. 2006-09-17 15:39:22 +00:00
Denis Vlasenko a52145a927 mount: mount_it_now() - char *dir is not really needed. 2006-09-17 15:09:48 +00:00
Denis Vlasenko c889d2b786 mount: fix "duplicate mount options in mtab" bug 2006-09-17 15:08:12 +00:00
Denis Vlasenko c0975199be mount: nfs_strerror's static buffer was bigger than needed. 2006-09-17 15:06:34 +00:00
Denis Vlasenko 9c99b62b9e mount: getopt_ulflag'ification 2006-09-17 15:05:31 +00:00
Denis Vlasenko 13b4924ce0 mount: style fixes 2006-09-17 15:04:35 +00:00
Denis Vlasenko 3bc59aa2a4 mount: fix bugs: free(mp->mnt_fsname) of non-malloced ptr;
check for "more than 2 arguments" was actually checking for -2.
2006-09-17 15:04:01 +00:00
Denis Vlasenko fc56dd2e21 mount: use bb_simplify_path as appropriate 2006-09-17 15:01:53 +00:00
Denis Vlasenko 8d474b5009 mount: style fixes 2006-09-17 15:00:58 +00:00
Denis Vlasenko 66fabdb631 login: apply fixes + getopt_ulflag'ification by Bernhard 2006-09-17 14:45:09 +00:00
Bernhard Reutner-Fischer 4d0f54af94 - Steven Scholz pointed out that ssd's make-pid doesn't take an argument. 2006-09-15 19:25:18 +00:00
Denis Vlasenko 30a64cdc95 mount: reorder things, fix NFS-less mount. 2006-09-15 15:12:00 +00:00
Rob Landley 215c61d3c2 Unbreak allbareconfig. 2006-09-15 04:10:05 +00:00
Rob Landley f5fc1384e9 So, in the cornucopia of superfulous warning directives I didn't add to the
tree, we have the warning about failed inlines (which with our inline
limit set to zero means any usage of the "inline" keyword at all).  Note
that setting the inline limit to zero, and using -Werror, both predated
adding the warning about inlines to the tree.  So whatever checkin added
that did nothing but break the tree.  But oh well.

The second category of superfluous warnings is warning about functions with
no previous declaration.  Apparently, if you add ALWAYS_INLINE to an empty
function definition, it considers the sucker undeclared as far as the
warning is concerned.  (I.E. it's a buggy warning.  I try not to ask the
compiler to generate warnings it can't competently generate.)

This is why I removed "inline" (unbreak allbareconfig), and couldn't replace it
with "ALWAYS_INLINE" (still broke allbareconfig).
2006-09-15 04:08:25 +00:00
Rob Landley 69115c656d Unbreak allbareconfig.
We've had -Werror in the tree for quite a while, so adding #warning
somewhat counterproductve way to make comments on the code that belong on the
mailing list anyway.
2006-09-15 04:01:03 +00:00
Rob Landley da9d1d079e Strangely, using // in the comments I added was not a persistent accident. 2006-09-14 19:52:07 +00:00
Denis Vlasenko 7ccf5cc064 login: eliminate forward decls and #ifdefs 2006-09-14 17:03:18 +00:00
Denis Vlasenko af9854b81a umount: do not try to close FILE* which is NULL. 2006-09-14 16:40:46 +00:00
Denis Vlasenko be507170eb mount: -o remount should not add lines to /etc/mtab 2006-09-14 16:09:27 +00:00
Denis Vlasenko 25098f7fd5 mount: move code from nfsmount.c into mount.c 2006-09-14 15:46:33 +00:00
Bernhard Reutner-Fischer 6eb2f8edce - make sure that the 'build' dir exists even if we are about to build just one applet. 2006-09-14 15:07:48 +00:00
Bernhard Reutner-Fischer 1d6fb6d448 - do away with silly comment and do the Right Thing wrt building the archives.
You have to provide the absolute path to the objdir/target.ext you want to build, as can be seen in the respective makefiles..
2006-09-14 15:04:31 +00:00
Denis Vlasenko 727ef94447 mount: fix mtab support (but it is still rather buggy) 2006-09-14 13:19:19 +00:00
Rob Landley 85c6de71bf svn 15355 replaced "BusyBox is licensed under the GNU General Public Public
License" with "BusyBox is licensed under the GNU General Public
License version 2 or later... (This is the same license the Linux kernel
is under...)"  Except that the Linux kernel isn't under GPLv2 or later,
it's just under GPLv2.

Now they match again.
2006-09-14 05:59:32 +00:00
Rob Landley cc9962d7fb More code from kernel developers, and therefore licensed under GPLv2 only.
Clarify the license boilerplate.

On an unrelated note, this could use busyboxification.  check_mount() looks
reusable and ask() is generic...
2006-09-14 05:27:28 +00:00
Rob Landley 73810e8d42 Add Larry Doolittle's ntpclient, plus some formatting tweaks. 2006-09-13 19:54:36 +00:00
Bernhard Reutner-Fischer 7fee0c4357 - fix copy'n paste errors that got introduced when switching to the shorter boilerplate.
No object code changes.
2006-09-13 16:39:19 +00:00
Bernhard Reutner-Fischer 92582f2e11 - r16075 broke for de-selected FEATURE_UTMP; Partial fix that wants some more cleanup (see FIXME in the patch). 2006-09-13 15:42:47 +00:00
Rob Landley 577905f1e4 Revert duplicate patch.
I don't know why patch decided to apply this even though it was already in
the tree.  I thought the other hunks failed because they were totally
unrelated leakage from Bernhard's tree (which they are; was the a reason
for bundling them in with this fix?  Do they have something to do with
the GCC 2.95 fix?  I suspect they prevent me from backporting this
patch to 1.2.2 because the header consolidation into libbb.h hadn't
been done yet, and no I'm not fixing it up: if that's the case then
this patch won't be in 1.2.2 due to extraneous changes bundled with it that
prevent a clean backport without rolling a new patch).
2006-09-12 22:42:03 +00:00
Rob Landley 20cc6d567f Remove pointless "const". Bloatcheck says 0 bytes difference. 2006-09-12 21:42:17 +00:00
Rob Landley 1b2b5cfba8 Fix from Bernhard for somebody trying to limp along with gcc 2.95.4. 2006-09-12 20:29:22 +00:00
Rob Landley 16bbb20089 Random cleanup hanging around my tree. 2006-09-12 20:28:34 +00:00
Bernhard Reutner-Fischer b5f50ea344 - small trivia to be gentle to gcc-2.95.x which had no va_copy but only __va_copy. 2006-09-12 13:27:55 +00:00
Bernhard Reutner-Fischer 428a5cd0d3 - fix warning about discarding qualifiers in initialization 2006-09-12 13:25:16 +00:00
Denis Vlasenko 00d7d6cef6 nfsmount: sanitize it. It had a rather peculiar idea of implementing "bg"
option - it was going to return a special flag back to caller and
expecting caller to call it again with special parameter! Also
caller was charged with calling mount() syscall...

mount: mtab support was non-functional. Enabling it revealed serious bug
which is not fixed yet.
2006-09-11 17:42:44 +00:00
Bernhard Reutner-Fischer 64d7e93081 - convert a few xopen3(,,0) into xopen(,). Also peruse the fact that xopen defaults to 0777 on it's own, so we don't need to xopen3(,,0777).
Saves a few bytes:
$ size busybox.old busybox                                text    data     bss     dec     hex filename
 839676    8780  243592 1092048  10a9d0 busybox.old
 839660    8780  243592 1092032  10a9c0 busybox
$ make CC=gcc-4.2-HEAD bloatcheck
function                                             old     new   delta
static.vconfig_main                                  281     279      -2
static.rx_main                                      1076    1074      -2
static.mt_main                                       294     292      -2
static.gzip_main                                     753     751      -2
static.mkfs_minix_main                              4034    4030      -4
static.unzip_main                                   1771    1766      -5
static.crontab_main                                 1513    1507      -6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/7 up/down: 0/-23)             Total: -23 bytes
2006-09-11 16:01:40 +00:00
Bernhard Reutner-Fischer 57b56674a3 - merge xstat.c into xfuncs.c 2006-09-11 09:18:09 +00:00
Bernhard Reutner-Fischer dea6e3d3cf - Tito pointed out that Rob forgot to add e2fsprogs/blkid/list.c 2006-09-11 09:16:12 +00:00
Rob Landley 49ea46667f Build fixes for gcc 4.0 with -Werror, from Tito. 2006-09-11 01:34:21 +00:00
Rob Landley 69674941dd Error reporting fix for sulogin, plus remove help entries for options we never
implemented.  (Plus a bit more of bbsh leaking in from my tree, but it
shouldn't hurt anything and I'm lazy...)
2006-09-11 00:34:01 +00:00
Denis Vlasenko 3077294615 nfsmount: remove some really old code (for kernels 1.x!) + small cleanups. 2006-09-10 18:48:16 +00:00
Denis Vlasenko d2b13eab98 nfsmount: delete nfsmount.h 2006-09-10 18:40:18 +00:00
Denis Vlasenko 39e93cc951 nfsmount: nfsmount.h merged into nfsmount.c 2006-09-10 18:38:17 +00:00
Denis Vlasenko 2244a21a8e nfsmount: style fix 2006-09-10 18:28:23 +00:00
Denis Vlasenko 5983914c1b ipcs: silly trick with strings. saves ~200 bytes. 2006-09-10 18:26:51 +00:00
Rob Landley 1bfca7bac7 Cleanup headers and replace the zero padding with an even smaller version.
One of the pads turned out to be unnecessary: sizeof(struct TarHeader) is
TAR_BLOCK_SIZE, the padding's in the struct.  The others could be done inline
with bb_common_bufsiz1.

This is a cleanup I did to Denis' patch long ago, but got sidetracked by
what turned into svn 15660.
2006-09-10 03:20:37 +00:00
Denis Vlasenko 9852d5a1e6 sulogin: minor cleanup. 2006-09-09 14:00:58 +00:00
Denis Vlasenko 8fafacd7ec setkeycodes: something horrible happened here
to indentation... fixed now
2006-09-09 13:23:04 +00:00
Denis Vlasenko 42dfcd2612 top: fixed wrong comment, made error message more clear 2006-09-09 12:55:02 +00:00
Denis Vlasenko 0c45bb23d2 tar: fix "xopen with O_CREAT" warning, improve zero padding write
(was doing zillions of 1-byte write syscalls)
2006-09-09 12:49:03 +00:00
Denis Vlasenko d5d614c5f4 xopen3(O_RDONLY) -> xopen(O_RDONLY). 2006-09-09 12:25:20 +00:00
Denis Vlasenko 9cac521f07 using [xa]sprintf for string concatenation is neat and saves
~100 bytes according to bloatcheck. Also this fixes bug in rpm
2006-09-09 12:24:19 +00:00
Denis Vlasenko 3526a1320a wget: wrap one atrociously long line (around 200 chars long!). 2006-09-09 12:20:57 +00:00
Denis Vlasenko d797fcd726 udhcp: FEATURE_UDHCP_SYSLOG should be selected only if
udhcp[cd] really are going to use it.
2006-09-09 12:18:46 +00:00
Denis Vlasenko 2f50aa42c5 login: use some ideas from util-linux's login.
O_NONBLOCKing output on login timeout.
fchmod instead of chmod (latter is racy).
is_my_tty() is not needed anymore after race is fixed
(is_my_tty() was racy too anyway...).
2006-09-08 17:56:52 +00:00
Denis Vlasenko bd8f43dbab few random readability enhansements. No code changes 2006-09-08 17:31:55 +00:00
Denis Vlasenko 9a9edf200b login: make it saner and smaller by ~0.5k. 2006-09-08 17:29:53 +00:00
Denis Vlasenko 6bbd174593 login: small fixes like \n removal, bb_error_msg'ification, etc. 2006-09-08 17:26:20 +00:00
Denis Vlasenko 942e4291fe login: previous commit comment was wrong :)
That commit added login script support.
Now _this commit_ is a style fix. Sorry....
2006-09-08 17:25:04 +00:00
Denis Vlasenko 2e502914b0 login: style fixes 2006-09-08 17:22:45 +00:00
Rob Landley dd93abeaff Shrinkage/cleanup from Tito. 2006-09-08 17:22:05 +00:00
Rob Landley ef08184d9e Fix warnings. 2006-09-08 17:21:19 +00:00
Rob Landley 3476ad651d Second drop. More infrastructure in place, especially for parsing pipelines.
The minimal version got a couple hundred bytes bigger, partly because it's
broken into more functions but mostly because it now dynamically reallocates
and frees everything with no hard-coded limits.  (I thought about making
that optional, but there's a limit to what I can debug and maintain.  It
should still be reasonably NOMMU friendly, the allocations are small and
short lived, and shouldn't contribute noticeably to long-term memory
fragmentation.)
2006-09-08 16:59:08 +00:00
Rob Landley c27f4f5445 A quick cleanup pass of some low-hanging mess. 2006-09-08 00:41:48 +00:00
Rob Landley d35c0efddb Bugfix for: echo '123456789' | sed 's/./|&/5' 2006-09-08 00:01:02 +00:00
Denis Vlasenko 239369b368 Fix (hopefully) bug 976. Need more thorough audit.
Restore erroneously removed FEATURE_UDHCP_SYSLOG.
2006-09-07 17:05:44 +00:00
Denis Vlasenko a9801658ee getty, sulogin: convert to using bb_msg for syslog output 2006-09-07 16:20:03 +00:00
Denis Vlasenko b750dec40a fix if (ENABLE_FEATURE_SYSLOG & (...)) - should be && 2006-09-07 16:03:45 +00:00
Denis Vlasenko 049d6b8c08 Add CONFIG_FEATURE_SYSLOG which controls whether
bb_xx_msg will ever try to send output to syslog.
Add "select CONFIG_FEATURE_SYSLOG" to relevant applets.
This allows to omit syslog code if we do not have
any syslog-capable applets in the build.
2006-09-07 06:02:39 +00:00
Denis Vlasenko b7d8dd9ab1 CONFIG_FEATURE_COMPRESS_USAGE was impossible to turn on
if !CONFIG_NITPICK
2006-09-07 05:43:38 +00:00
Denis Vlasenko 3da6aa878a adding files missed in prev updates (forgot about svn add) 2006-09-07 05:09:22 +00:00
Rob Landley f522d1231c Denis Vlasenko has started to put stuff on his BusyBox home page, so index it. 2006-09-06 22:56:38 +00:00
Denis Vlasenko 6d655be5df removed a lot of trailing \n in bb_msg() calls. It is added
automatically by function itself.
2006-09-06 19:02:46 +00:00
Denis Vlasenko 3538b9a882 Implement optional syslog logging using ordinary
bb_xx_msg calls, and convert networking/* to it.
The rest of bbox will be converted gradually.
2006-09-06 18:36:50 +00:00
Bernhard Reutner-Fischer 5d725462d4 - strip 399424 off the bss by making decompress_uncompress buffers config buffers.
Compile tested (too lazy to look for a small .Z on the net).
$ size busybox.old busybox
   text    data     bss     dec     hex filename
 859555   10232  645732 1515519  171fff busybox.old
 859683   10232  246308 1116223  11083f busybox
$ make bloatcheck
function                                             old     new   delta
uncompress                                          1036    1160    +124
inbuf                                               2116       4   -2112
outbuf                                              4100       4   -4096
htab                                              131072       - -131072
codetab                                           262144       - -262144
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/2 up/down: 124/-399424)   Total: -399300 bytes
2006-09-06 15:28:32 +00:00
Bernhard Reutner-Fischer e614eaf40d - mdev and grep use xregcomp. Closes bug #1021 2006-09-06 13:24:39 +00:00
Rob Landley 4cb035dd23 Vladimir Dronnikov (ybrnj80 at yandex dot ru) pointed out that my cleanup of
his code introduced a bug (an extra backslash in the CIFS mount string).
2006-09-05 14:00:21 +00:00
Rob Landley 02496aa69e The bb_ prefixes were removed from xasprintf() and xopen() a month ago (in
svn 15767).
2006-09-05 13:48:21 +00:00
Denis Vlasenko 797b4d210d run_shell.c: style fix 2006-09-05 09:45:30 +00:00
Denis Vlasenko d25a2645f5 xfunc: fix: && -> &. Also nuked two double semicolons... 2006-09-05 09:36:19 +00:00
Rob Landley 02add9e53a Might as well commit this to have the history. It's not linked in to the
applet list yet (and won't be until it can replace lash, I'm not having five
shells in menuconfig at once), but you can build it with scripts/individual
and mostly this is checked in so I can bloatcheck future versions against it
easily....

This is about as small as a shell can get and still be a shell.
2006-09-05 03:22:19 +00:00
Rob Landley 4d609cb5a3 Thinko. 2006-09-04 19:43:26 +00:00
Rob Landley 8cedabaee0 Patch from Natanael Copa to make start-stop-daemon just use readlink and
strcmp to check if a program is already running.
2006-09-04 18:59:39 +00:00
Denis Vlasenko adff40e80d sulogin: fix bug: -tNNN didn't work 2006-09-03 17:11:34 +00:00
Denis Vlasenko 1da6a21666 dpkg: fix buffer overflow (bug 983) 2006-09-03 16:33:58 +00:00
Denis Vlasenko 21afc7dc29 uuencode: common implementation for wget and uuencode (closing bug 694) 2006-09-03 15:49:40 +00:00
Denis Vlasenko 22dca23d52 archival: added O_TRUNC so that when we overwrite files on unpack,
we truncate them. Also spotted & fixed hard to trigger bug
          with extension handling.
2006-09-03 14:23:29 +00:00
Denis Vlasenko 314908da9e tar: revert older fix (non-portable), added new one.
testsuite tar-extracts-all-subdirs now passes.
2006-09-03 14:04:33 +00:00
Denis Vlasenko 65113e8d97 zcip: bb_error_msg had stray newlines; small optimization in opt parsing 2006-09-03 12:31:59 +00:00
Denis Vlasenko af906a3b6c zcip: minor fixes 2006-09-03 12:29:53 +00:00
Denis Vlasenko a9abecd85e zcip: fix stdout/err versus syslog output.
Incomplete: xfunc() would not respect this. TODO.
2006-09-03 12:28:32 +00:00
Denis Vlasenko 65dbd8752b zcip: getopt -> bb_getopt_ulflags 2006-09-03 12:27:25 +00:00
Denis Vlasenko 60e3dd6016 zcip: convert lots of zero-initialized locals
in zcip_main() to statics in bss.
2006-09-03 12:26:06 +00:00
Denis Vlasenko 035aae5841 zcip: use xfunc() where appropriate 2006-09-03 12:23:56 +00:00
Denis Vlasenko 27af5a0dd3 replacing func() with xfunc() where appropriate 2006-09-03 12:21:59 +00:00
Denis Vlasenko 87d80dcc3e zcip: apply patch from
http://bugs.busybox.net/view.php?id=1005
      zcip does not claim another IP after defending
2006-09-03 12:20:36 +00:00
Denis Vlasenko 06ab5fb6b9 tar: tar xf foo.tar dir/dir did not extract all subdirs.
Added testsuite entry for this
2006-09-02 18:40:10 +00:00
Denis Vlasenko bcf4908e71 ping: bind -> xbind 2006-09-02 17:53:16 +00:00
Denis Vlasenko e0b7f71d26 ping(6): use htons instead of SWAP_BE. 2006-09-02 16:57:59 +00:00
Denis Vlasenko 2cbe6e6eb2 ping: implement -I option 2006-09-02 16:17:30 +00:00
Denis Vlasenko db7f2e5881 ping6: resolve interface name to number early.
gcc is more efficient at truncating int to int16
via cast, use that instead of &.
2006-09-02 16:16:23 +00:00
Denis Vlasenko cb6874cc66 Sync ping and ping6 a bit, fix style and indentation. 2006-09-02 16:13:36 +00:00
Denis Vlasenko d53dd3e627 Fix endianness issue in ping6 2006-09-02 16:11:44 +00:00
Bernhard Reutner-Fischer bfbc4ebf40 - patch from Csaba Henk to make the "User-Agent" header field configurable. 2006-09-02 15:30:26 +00:00
Rob Landley 686298d6fb Walter Harms contributed a section on scripting languages. (I trimmed it
a bit.)
2006-09-01 17:38:23 +00:00
Rob Landley 89d9d4d5f7 Vladimir Dronnikov also submitted a CIFS support patch to mount, which I
heavily reworked here and probably broke.  Tomorrow I need to set up a
copy of samba to test against.  (This compiles, I make no promises beyond that.)
2006-09-01 08:10:44 +00:00
Rob Landley f5bbc692a0 Bernhard Fischer complained about moving --sort-common. 2006-08-30 16:50:00 +00:00
Rob Landley 1fdd83f897 There's some strange bug in glibc that triggers if you combine the
--gc-sections linker flag with static linking.  If this happens, then
the "stdout" variable (used by printf() and such) will only work if stdout
is _not_ redirected.  I.E "./busybox" prints stuff, but "./busybox | cat"
does not produce any output.  (But even when redirected, "write(1,"blah",4);"
continues to work just fine.)

This is clearly a glibc bug, but to avoid triggering it I've moved the
--gc-sections flag so it only gets added when we're not statically linking.
If somebody would like to go poke Ulrich Drepper, you can trivially reproduce
this with a "hello world" program, ala:

  gcc -static -Wl,--gc-sections hello.c &&  (./a.out | cat)
2006-08-29 21:46:10 +00:00
Bernhard Reutner-Fischer 31e2c00ec3 - set version back to 1.2.0 like it was before. Add at least -svn to the Extraversion to be able to distinguish it from the now old 1.2.0 release 2006-08-29 20:21:33 +00:00
Rob Landley 88621d7398 Svn 16007 broke the build under gcc 4.0.3. This fixes up some of the damage
(the e2fsprogs directory is too twisty and evil to easily fix, but I plan
to rewrite it anyway so I'll just bump that up in priority a bit).
2006-08-29 19:41:06 +00:00
Bernhard Reutner-Fischer 8c1eda528a - it's a mistake to remove lib-specific prefixes from libraries; still the removal should be complete. 2006-08-28 23:39:36 +00:00
Bernhard Reutner-Fischer 73561cc75a - pull from busybox_scratch: r15829:15850
Various fixes, cleanups and shrinkage:
saves 952 Bytes:
   text    data     bss     dec     hex filename
1087742   15853  790632 1894227  1ce753 ../busybox/busybox.old
1086790   15853  790632 1893275  1ce39b busybox
via:
# scripts/bloat-o-meter ../busybox/busybox_unstripped.old busybox_unstripped 
function                                             old     new   delta
ipcrm_main                                           756     822     +66
getval                                                 -      61     +61
maybe_set_utc                                          -      40     +40
udhcpc_main                                         2896    2912     +16
md5_hash_block                                       428     437      +9
opt                                                    8      16      +8
qgravechar                                           106     110      +4
make_bitmap                                          292     295      +3
inflate_unzip                                       2056    2059      +3
add_partition                                       1412    1414      +2
__parsespent                                         156     158      +2
qrealloc                                              41      42      +1
format                                                 -       1      +1
catv_main                                            313     314      +1
watch_main                                           293     292      -1
varunset                                              81      80      -1
part                                                   1       -      -1
check_if_skip                                        837     836      -1
start_stop_daemon_main                               840     837      -3
create_lost_and_found                                175     172      -3
supress_non_delimited_lines                            4       -      -4
static.l                                               4       -      -4
static.c                                               5       1      -4
bsd_sum_file                                         237     233      -4
eval2                                                338     332      -6
arithmetic_common                                    166     158      -8
cmpfunc                                               22       5     -17
cksum_main                                           294     275     -19
cmp_main                                             465     439     -26
dd_main                                             1535    1508     -27
rmmod_main                                           376     333     -43
cut_file                                             727     644     -83
ipcs_main                                           3809    3721     -88
cut_main                                             722     614    -108
date_main                                           1443    1263    -180
remove_ids                                           222       -    -222
------------------------------------------------------------------------------
(add/remove: 3/4 grow/shrink: 11/18 up/down: 217/-853)       Total: -636 bytes
2006-08-28 23:31:54 +00:00
Mike Frysinger 6ce8dae1d5 need libsepol in addtion to libselinux 2006-08-28 23:24:38 +00:00
Bernhard Reutner-Fischer 99b706858b - do maintainers duty by bumping version to 1.3.0-pre0;
pullup r15828 from busybox_scratch
2006-08-28 21:21:25 +00:00
Rob Landley 8479063667 Bugfix from Jason Schoon: send the right signal with -s. 2006-08-28 20:30:27 +00:00
Rob Landley 028ba280be More allbareconfig fixes. 2006-08-28 20:16:42 +00:00
Rob Landley b8cea6dcb3 Jordan Crouse submitted a patch to only include xregcomp.c when we actually
use it, thus fixing building against uClibc with regex support disabled.
2006-08-28 20:04:46 +00:00
Rob Landley abfe107f78 No real need for my_query_module() and this eliminates some type-punned
pointer warning on certain gcc versions (and saves 38 bytes).
2006-08-28 19:40:08 +00:00
Bernhard Reutner-Fischer 82ac9ecfe5 - pgf(?) found and fixed that missing dependency (usage: .config, IIRC), so remove the now unneeded NOTPARALLEL clause 2006-08-28 13:29:41 +00:00
Rob Landley 099ed50f91 Unbreak allbareconfig a bit. (The telnetd.c fix is a perfect example of why
applets which are a forest of #ifdefs are unmaintainable.)
2006-08-28 09:41:49 +00:00
Rob Landley f78ab5396d Antti Seppala (with dots over the last two a's) wants our getty to initialize
the terminal the way mingetty does instead of the way agetty does.  It's
a bit ugly for somebody else to be writing to a console sitting at a
login: prompt, but it's uglier when newline doesn't work as expected if
they do.
2006-08-24 20:00:44 +00:00
Rob Landley 4b5827a69b Patch from Yann Morin so modprobe won't return failure if the module gets
loaded while it's running (ala multi-device hotplug).
2006-08-22 23:50:11 +00:00
Rob Landley ecb29573e9 "Jordan Crouse" <jordan.crouse@amd.com> says:
The following patch makes coreutils/test.c act fail gracefully if getgroups() 
returns a -1.  This fixes a problem on the One Laptop Per Child ROM image
whereby we were getting odd Memory exhausted messages for '[' and 'test'.

Found by Mitch Bradley <wmb@firmworks.com>
(Tweaked by Rob: no need to initialize a static to NULL, or realloc something
that's only allocated when it's NULL.)
2006-08-22 23:40:28 +00:00
Rob Landley 98a915713d Michael Opdenacker spotted that makefile should use () instead of {}. 2006-08-21 17:42:03 +00:00
Rob Landley 1ffe1ede54 Oops, Michael pointed out that my cleanup left some dead code in there. 2006-08-21 16:03:38 +00:00
Rob Landley 43ee36c6da Yann E. Morin spotted a broken check_ld macro. 2006-08-20 23:13:33 +00:00
Rob Landley 0e4690d4ef Michael Opdenacker contributed a readahead applet. 2006-08-20 22:12:18 +00:00
Bernhard Reutner-Fischer 289e86a0a5 - typo s/ENABLE_WGET_LONG_OPTIONS/ENABLE_FEATURE_WGET_LONG_OPTIONS/g 2006-08-20 20:01:24 +00:00
Bernhard Reutner-Fischer d591a360d3 - merge -r15463:15564 from busybox_scratch branch through these changesets:
------------------------------------------------------------------------
r15465 | aldot | 2006-06-21 20:48:06 +0200 (Wed, 21 Jun 2006) | 3 lines

- use CONFIG_BUSYBOX_EXEC_PATH as before it one was broken by a recent revert.
- use xchdir() since all is invain if it fails there anyways, supposedly

------------------------------------------------------------------------
r15466 | aldot | 2006-06-21 20:55:16 +0200 (Wed, 21 Jun 2006) | 2 lines

- adjust docs to take CONFIG_BUSYBOX_EXEC_PATH into account.

------------------------------------------------------------------------
r15467 | aldot | 2006-06-21 21:31:24 +0200 (Wed, 21 Jun 2006) | 18 lines

- partial fallout of my TREE_USED touchup against gcc-4.2: rip unused vars, save
s 144 bytes
   text    data     bss     dec     hex filename
 862434   10156  645924 1518514  172bb2 busybox.old
 862322   10156  645892 1518370  172b22 busybox
function                                             old     new   delta
z_len                                                  4       -      -4
textend                                                4       -      -4
part_nb                                                4       -      -4
insize                                                 4       -      -4
ifile_size                                             4       -      -4
do_link                                                4       -      -4
new_text                                              70      60     -10
ipaddr_list_link                                      33      23     -10
gzip_main                                            898     822     -76
------------------------------------------------------------------------------
(add/remove: 0/6 grow/shrink: 0/3 up/down: 0/-120)           Total: -120 bytes


------------------------------------------------------------------------
r15468 | aldot | 2006-06-21 21:43:05 +0200 (Wed, 21 Jun 2006) | 19 lines

- remove useless global exports
function                                             old     new   delta
rpm_main                                             940    1601    +661
rpm_getstring                                        107     112      +5
rpm_getint                                           148     153      +5
loop_through_files                                   103     106      +3
fileaction_dobackup                                  115     113      -2
fileaction_list                                        5       -      -5
rpm_getcount                                          42       -     -42
extract_cpio_gz                                      161       -    -161
rpm_gettags                                          504       -    -504
------------------------------------------------------------------------------
(add/remove: 0/4 grow/shrink: 4/1 up/down: 674/-714)          Total: -40 bytes

   text    data     bss     dec     hex filename
 862322   10156  645892 1518370  172b22 busybox.old
 862290   10156  645892 1518338  172b02 busybox


------------------------------------------------------------------------
r15555 | aldot | 2006-06-30 14:10:11 +0200 (Fri, 30 Jun 2006) | 22 lines

- shrink syslog a little bit, move a big buffer (for 'line') off the bss, fold s
emaphore stuff into single caller manually.
  stats:
function                                             old     new   delta
logMessage                                           395     427     +32
message                                             1245    1257     +12
opts                                                   -       4      +4
small                                                  1       -      -1
local_logging                                          4       -      -4
doRemoteLog                                            4       -      -4
circular_logging                                       4       -      -4
syslogd_main                                        1299    1285     -14
static.res                                            36      16     -20
.rodata                                           186650  186586     -64
static.line                                         1025       -   -1025
------------------------------------------------------------------------------
(add/remove: 1/5 grow/shrink: 2/3 up/down: 48/-1136)        Total: -1088 bytes
cow@s37:~/src/busybox_scratch$ size sysklogd/syslogd.o{.orig,}
   text    data     bss     dec     hex filename
   3723     348    5242    9313    2461 sysklogd/syslogd.o.orig
   3697     348    4188    8233    2029 sysklogd/syslogd.o

==============================================================================
Overall bloatcheck for the changeset mentioned above:
function                                             old     new   delta
rpm_main                                             953    1608    +655
logMessage                                           395     427     +32
message                                             1245    1257     +12
opts                                                   -       4      +4
rpm_getstring                                        107     110      +3
rpm_getint                                           148     151      +3
loop_through_files                                   103     104      +1
small                                                  1       -      -1
fileaction_dobackup                                  115     113      -2
z_len                                                  4       -      -4
textend                                                4       -      -4
part_nb                                                4       -      -4
local_logging                                          4       -      -4
insize                                                 4       -      -4
ifile_size                                             4       -      -4
do_link                                                4       -      -4
doRemoteLog                                            4       -      -4
circular_logging                                       4       -      -4
fileaction_list                                        5       -      -5
new_text                                              70      60     -10
ipaddr_list_link                                      33      23     -10
clear_bufs                                            31      21     -10
syslogd_main                                        1287    1273     -14
builtin_help                                         190     176     -14
static.res                                            36      16     -20
builtin_source                                       229     199     -30
rpm_getcount                                          42       -     -42
gzip_main                                            842     786     -56
.rodata                                           227176  227112     -64
lash_main                                            609     527     -82
busy_loop                                           3883    3739    -144
extract_cpio_gz                                      155       -    -155
rpm_gettags                                          501       -    -501
static.line                                         1025       -   -1025
------------------------------------------------------------------------------
(add/remove: 1/15 grow/shrink: 6/12 up/down: 710/-2221)     Total: -1511 bytes
2006-08-20 17:35:13 +00:00
Bernhard Reutner-Fischer 13068a4fdb - typo: s/optarg/nprobes_str; fixes segfault as reported by Raphael HUCK 2006-08-18 18:29:40 +00:00
Bernhard Reutner-Fischer 71193a853d - remove CRIS specific CFLAG from generic flags-checking. 2006-08-18 17:44:52 +00:00
Bernhard Reutner-Fischer 5bd2a4b6ce - remove last reminiscents of IN_BUSYBOX 2006-08-18 17:22:23 +00:00
Rob Landley 4470b74e29 The kernel can't handle umount /dev/hdc, we have to do it through mtab,
except that we still have to work when there is no mtab.

Oh, and while we're at it, take advantage of the fact that modern processors
avoid branches via conditional assignment where possible.  ("x = a ? b : c;"
turns into "x = c; if (a) x = b;" because that way there's no branch to
potentially mispredict and thus never a bubble in the pipeline.  The if(a)
turns into an assembly test followed by a conditional assignment (rather
than a conditional jump).)  So since the compiler is going to do that _anyway_,
we might as well take advantage of it to produce a slightly smaller binary.

So there.
2006-08-17 19:07:20 +00:00
Rob Landley eb28ce4644 Timo Scheffler pointed out that OpenWRT isn't listed. 2006-08-17 04:45:24 +00:00
Rob Landley fac4ebea3d Add link to BusyBox Weekly News. (Yeah, another timesink.) 2006-08-16 22:25:43 +00:00
Rob Landley 95718b3091 New entry about backporting fixes. 2006-08-16 22:13:56 +00:00
Rob Landley b90a371a4c Update the tinyutils page to mention microperl, LUA, buildroot,
gentoo embedded...
2006-08-16 21:10:27 +00:00
Rob Landley 4640b05afd Bernhard Fischer pointed out some leftover debris needing cleanup. 2006-08-15 21:37:55 +00:00
Rob Landley a299efb7b0 Make a warning go away when standalone shell is disabled. 2006-08-10 21:46:43 +00:00
Rob Landley 10b36f94bb Patch from Chris Steel to fix mdev deleting device nodes. 2006-08-10 01:09:37 +00:00
Rob Landley b988462d3e Ok, features.h already defines _OPEN_SOURCE (and complains if it's already
defined), yet it's not doing it for scripts/individual for some reason.
(I hate fighting with header files.)
2006-08-10 01:08:41 +00:00
Rob Landley 519d7df930 Another whack at scripts/individual. Now builds 212 applets. 2006-08-09 20:56:23 +00:00
Rob Landley e55a73c7a8 Update usage to talk about the new shared subtree stuff in mount. 2006-08-09 20:55:35 +00:00
Rob Landley 3ba7bd143e Vladimir Dronnikov convinced me to twiddle the semantics of the new shared
subtree stuff to look more like http://lwn.net/Articles/159077/ thinks
they should.
2006-08-09 19:51:13 +00:00
Rob Landley 721b46e0e6 Fix a typo (|| instead of |) and remove two comments about a problem fixed
in the previous patch.
2006-08-08 12:54:02 +00:00
Rob Landley e3781b7312 Add shared subtree support, suggested by Vladimir Dronnikov. Also break out a
few new (unfinished) config options, which I intend to make hidden (but
enabled) when CONFIG_NITPICK is disabled.  Getting the .config infrastructure
to do that is non-obvious, it seems...
2006-08-08 01:39:49 +00:00
Rob Landley 47b16a6fe9 Using lstat() instead of stat() means that attempting to loopback mount
a symlink doesn't work.
2006-08-08 00:47:17 +00:00
Rob Landley 7250915d78 Make a warning go away on 64-bit systems. 2006-08-06 20:41:11 +00:00
Rob Landley 236c6755d2 Teach md5sum and sha1sum to work the way other applets do so I don't have to
teach scripts/individual new tricks.  And while I'm at it, teach
scripts/individual other new tricks.  Now builds 198 applets, some of which
I should teach it to hardlink together because they're really the same app...
2006-08-06 02:13:36 +00:00
Rob Landley affb7a61a6 scripts/individual now builds 171 applets. Some of them may even work. :) 2006-08-05 00:41:39 +00:00
Rob Landley 59fe8b9089 There are a number of reasons for reinventing printf(). Writing status to
stdout is not one of them.
2006-08-04 22:02:55 +00:00
Rob Landley f4e50b0bcd We haven't got a CONFIG_APT_GET. 2006-08-04 21:12:14 +00:00
Rob Landley cb376eebf0 Digging up my old "make standalone" stuff from a year ago:
http://busybox.net/lists/busybox/2005-September/015766.html

I renamed it "individual" to not confuse it with the standalone shell.  (Which
it isn't compatible with for obvious reasons.)  Configure busybox (I did
make defconfig), then run scripts/individual and it'll build an individual
version of each applet in the "build" subdirectory.

Currently it builds 146 and fails to build 104 applets out of "make defconfig".
I haven't taught it about multi-file applets yet (like tar), or the ones where
two applets get built from the same source (for example, zcat is a trivial
variant of gunzip so there is no zcat.c).  But here's a start.
2006-08-04 21:05:33 +00:00
Rob Landley e6a3fef08c Add busybox_old to distclean. 2006-08-04 20:39:56 +00:00
Rob Landley 23b61be0df Add comments to all the functions in this file documenting what they're for. 2006-08-04 20:20:03 +00:00
Rob Landley 74bb70cf54 Ok, that's not a typo, that's just me not thinking. 2006-08-04 20:19:01 +00:00
Rob Landley 3629d95a24 Typo. 2006-08-04 20:15:18 +00:00
Rob Landley 27d07c9ce2 Now that we have xopen3(), it's just plain unclean to have xopen() with
O_CREAT.  Two users are still doing it (and thus getting permissions 777),
I'm not sure what permissions they should be using but here they are
changed to xopen3().  This costs us a dozen or so bytes, but removing the
777 from xopen() should get some of that back.
2006-08-04 19:16:31 +00:00
Rob Landley daf58ef61a Use xopen3() instead of an after-the-fact chown. 2006-08-04 17:26:58 +00:00
Rob Landley 2c55fcac08 Thinko spotted by Vladimir Dronnikov. 2006-08-04 05:24:58 +00:00
Rob Landley 6ced427a6d Try to make a "type-punned pointer" warning go away for somebody on the
buildroot list.
2006-08-03 20:39:59 +00:00
Rob Landley 403777ffae Patch from tito to improve options parsing. 2006-08-03 20:22:37 +00:00
Rob Landley 081e38483e Remove xcalloc() and convert its callers to xzalloc(). About half of them
were using "1" as one of the arguments anyway, and as for the rest a multiply
and a push isn't noticeably bigger than pushing two arguments on the stack.
2006-08-03 20:07:35 +00:00
Rob Landley 86b4d64aa3 These should have been part of 15767 too. 2006-08-03 17:58:17 +00:00
Rob Landley 7478804b78 Fix umount so loop device disassociation hopefully doesn't screw up errno on
a failed mount.  And while I'm at it, legacy mdev removal was only being done
in the _failure_ case?  That can't be right.  Plus minor header cleanups
and an option parsing tweak.
2006-08-03 17:54:45 +00:00
Rob Landley 280a264fb8 Attempt to fixup httpd.c to match svn 15767. 2006-08-03 17:49:15 +00:00
Rob Landley d921b2ecc0 Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only
had one user), clean up lots of #includes...  General cleanup pass.  What I've
been doing for the last couple days.

And it conflicts!  I've removed httpd.c from this checkin due to somebody else
touching that file.  It builds for me.  I have to catch a bus.  (Now you know
why I'm looking forward to Mercurial.)
2006-08-03 15:41:12 +00:00
"Robert P. J. Day" 6dce0b6fa7 Remove apparent typo in "bool" line. 2006-08-03 11:28:36 +00:00
"Robert P. J. Day" 581d4f36b3 Move declaration to be compatible with older gcc's. 2006-08-03 10:50:39 +00:00
Rob Landley cae61e7ca4 Make a gcc 4.1 warning go away. 2006-08-01 00:30:26 +00:00
Rob Landley 2aced7ea04 Announce 1.2.1 2006-07-31 23:56:26 +00:00
Rob Landley 533320c659 1) ifeq is make syntax, #ifeq is a make comment.
2) The check_cc macros should probably all have the same number of arguments.
3) Move the -Werror into the gcc 4.0 on i386 test, because gcc 4.1 is broken
and produces warnings for things that provably aren't incorrect.

In other news it would be nice if our check_ld macro actually did something,
and why does or makefile do all the check_cc calls, then call itself as if
it's building out of tree, then do all the check_cc calls again?
2006-07-31 22:56:17 +00:00
Rob Landley 565bc33332 Remove code that can't be reached. 2006-07-31 22:50:12 +00:00
Rob Landley c052576821 Tito said that strings is a complete rewrite. 2006-07-31 16:37:57 +00:00
Rob Landley 91dc086d63 Switch off CONFIG_NITPICK in defconfig. (Kind of the point of CONFIG_NITPICK.) 2006-07-30 18:56:29 +00:00
Rob Landley 446129adae Add back in non-ifdef version of FEATURE_PRETTY_PRINT, and get the attribution
right this time.
2006-07-27 16:40:55 +00:00
Rob Landley 52c7d7ebf3 And now, with a for loop, so it can handle the nested USE() case. 2006-07-27 15:12:21 +00:00
Rob Landley fc367f9824 There's no excuse for adding new #ifdefs to the code like that. None at all. 2006-07-27 15:02:58 +00:00
Rob Landley 277eb6bb44 I touched perl. I feel dirty.
Make autodocifier suck less.  It still doesn't handle nested USE( USE() ) case
(the inner USE() winds up in the output), but making it recursive involves
getting perl to accept a "for" loop and it's telling me that "break" is an
unrecognized bareword and I hate perl.  This is at least an improvement.
2006-07-27 14:59:36 +00:00
Mike Frysinger eac0c06938 allow people to display dmesg output without syslog levels 2006-07-27 11:18:36 +00:00
Mike Frysinger 0b7dfb5ae7 eat gremlins 2006-07-27 03:42:30 +00:00
Mike Frysinger a7881119cc de-cuddle if( to if ( 2006-07-27 03:00:49 +00:00
Rob Landley 4795e4e011 Rich Filker spotted that sed -e 's/xxx/[/' didn't work right. Did a smaller
fix than his, and shrank the code a bit on top of that so the net size is
smaller, and added a test to the test suite for this case.  Plus I cleaned up
the #includes and removed unnecessary "const"s while I was there.
2006-07-26 17:25:08 +00:00
Rob Landley 7cc6b69bb0 Patch from Shaun Jackman, set optind by hand if we don't call getopt. 2006-07-26 16:10:39 +00:00
Rob Landley e1a0f5372f Unbreak allbareconfig. (Todo item: rewrite dependency checker. Yeah, I
already have that one, but it moves up the list...)
2006-07-26 15:38:46 +00:00
Rob Landley 5ebeb3ec56 Somebody on the buildroot list hit:
insmod.c:515:10: extra tokens at end of #ident directive
2006-07-25 20:37:45 +00:00
Mike Frysinger 91a339002a get rid of udhcp submenu 2006-07-24 07:35:52 +00:00
Mike Frysinger 8840759c61 move lchown/chown define out of specific files and into platform.h where it belongs 2006-07-20 19:31:07 +00:00
"Robert P. J. Day" eea561871b "formated" -> "formatted" throughout the code base. 2006-07-20 19:02:24 +00:00
Rob Landley bf30c69a38 Patch from Yann Morin to fix bug 941, underscores in module aliases. 2006-07-20 17:36:18 +00:00
Rob Landley f86a5ba510 Remove unnecessary consts. 2006-07-19 21:45:30 +00:00
Rob Landley 53702e53ba Replace the previous checkin with the correct fix. 2006-07-19 21:43:53 +00:00
Rob Landley 3b0cfb40a5 Patch from Yann Morin to look for modules.conf in the right place on 2.6.
Fixes http://bugs.busybox.net/view.php?id=942
2006-07-19 21:33:42 +00:00
"Robert P. J. Day" 3e4da920bd For now, get around the error that "child" might be uninitialized. 2006-07-18 12:05:43 +00:00
"Robert P. J. Day" fc2aea1a76 Rearrange order of type qualifiers. 2006-07-18 11:33:44 +00:00
Rob Landley f0623a2c98 Patch from Thaddeus Ternes, adding chuid to start-stop-daemon. 2006-07-17 00:35:07 +00:00
Rob Landley 62103757ef Bugfix from Tito to make sure /etc/group gets updated. 2006-07-16 18:58:18 +00:00
Rob Landley d893b120ba New mkswap. Small and simple. Might even work. :) 2006-07-16 08:17:03 +00:00
Rob Landley 534374755d Cleaup read() and write() variants, plus a couple of new functions like
xlseek and fdlength() for the new mkswap.
2006-07-16 08:14:35 +00:00
Rob Landley afb94ecf2b Convert setuid/setgid users to xsetuid/xsetgid. 2006-07-16 08:06:34 +00:00
Rob Landley 25c194fd19 Add -Werror. 2006-07-16 08:03:29 +00:00
Rob Landley df822f2606 We need xsetuid() and xsetgid() because per-user process resource limits can
prevent a process from switching to a user that has too many processes, and
when that happens WE'RE STILL ROOT.  See http://lwn.net/Articles/190331/
2006-07-15 23:00:46 +00:00
Rob Landley 1870737480 Comment tweak from tito. 2006-07-15 19:46:46 +00:00
Mike Frysinger 83169c607b Tito writes: If the gecos field of an user is empty, obscure reports a false "similar to gecos" error. 2006-07-15 03:59:00 +00:00
Rob Landley 91ed1a4a41 Patch from Suresh Rajashekara moving comments and #includes and such around. 2006-07-14 17:59:36 +00:00
Eric Andersen a4622324dd mention osuosl 2006-07-13 00:52:29 +00:00
Rob Landley 3a9cceb092 Add the two busybox developers' home pages that have busybox related stuff
on them.
2006-07-13 00:10:33 +00:00
Rob Landley 1f9145c5c3 More minor tweaks. 2006-07-12 21:31:16 +00:00
Mike Frysinger 58dda84ecc decuddle () from for/if/while 2006-07-12 20:04:00 +00:00
Rob Landley c9c1a41c58 A couple things that got tangled up in my tree, easier to check in both than
untangle them:

Rewrite u_signal_names() into get_signum() and get_signame(), plus trim the
signal list to that required by posix (they can specify the numbers for
the rest if they really need them).  (This is preparatory cleanup for adding
a timeout applet like Roberto Foglietta wants.)

Export the itoa (added due to Denis Vlasenko, although it's not quite his
preferred implementation) from xfuncs.c so it's actually used, and remove
several other redundant implementations of itoa and utoa() in the tree.
2006-07-12 19:17:55 +00:00
"Robert P. J. Day" 801ab14013 Add one-line GPL boilerplate to numerous (but not all yet) source files. 2006-07-12 07:56:04 +00:00
Rob Landley ab7d9be17c Patch from Tito to remove pwd_to_spwd (which we don't actually need), with
some #ifdef removal from me.
2006-07-11 16:19:17 +00:00
"Robert P. J. Day" 2819f757ca Add one-line GPL boilerplate to these source files. 2006-07-11 11:32:31 +00:00
Rob Landley 22d3958d76 Denis Vlasenko spotted the lack of bounds checking in my first attempt at
itoa/utoa.
2006-07-11 00:44:36 +00:00
Rob Landley 1cca9484db Upgrade netcat a lot. Make -e able to take the rest of the command line as
what to exec.  Add -f mode and a brief explanation of how to use it to replace
minicom.  Add -l -l mode so you can turn any command into a server.  And group
all of netcat's command line options under two CONFIG entries, so if you
disable both it doesn't use getopt at all.
2006-07-10 19:45:20 +00:00
"Robert P. J. Day" 5d8843e451 Replace current verbose GPL stuff in libbb/*.c with one-line GPL boilerplate. 2006-07-10 11:41:19 +00:00
Rob Landley 5b88a38157 Add itoa and utoa to see what Denis Vlasenko thinks. 2006-07-10 07:41:34 +00:00
Rob Landley 3bfcf3cccc Patch from Tito to make syslog configurable and remove #ifdefs. Further
cleanups by me.
2006-07-10 03:05:46 +00:00
Rob Landley cba1b96735 Patch from Shaun Jackman to set environment variable RUNLEVEL equal to
init's argv[1], so if you append "single" to your kernel command line and
the kernel doesn't parse it, RUNLELEL=single.

Plus a few unrelated header cleanups while I was in the area...
2006-07-09 17:28:17 +00:00
Rob Landley acf448d4f6 Bugfix from Shaun Jackman (check that argv[optind] isn't null before
dereferencing it) plus a bunch of tweaks from me.
2006-07-09 17:03:07 +00:00
Rob Landley 1df45cf8e7 Point at fixes.patch for 1.2.1. 2006-07-08 18:11:00 +00:00
Rob Landley ff6e21c2ce Fix tar so it can extract git-generated tarballs, based on a suggestion
from Erik Frederiksen.
2006-07-06 20:30:19 +00:00
Rob Landley 9ebd1bd468 Attempt to address Shaun Jackman's problem adding "busybox: busybox.bflt" to
.config.mak.
2006-07-06 20:02:47 +00:00
Paul Fox e3324502a5 fix dependencies so that compressed usage gets rebuilt if
a) include/usage.h is changed, and 
    b) after "make clean".
2006-07-06 20:00:43 +00:00
Rob Landley 4ae905a31c Minor build tweaks that save 1100 bytes building busybox on Ubuntu 6.06. 2006-07-06 17:22:54 +00:00
Rob Landley aa516a61b9 Fix three embarassing thinkos in the new dmesg.c:
1) the c argument shouldn't have had a : after that, dunno how that got there.
2) the xgetlarg for level was using size
3) because xgetlarg's error message _SUCKS_ (it does a show_usage() rather than giving any specific info about the range that was violated) I dropped the range down to 2 bytes.  (Which works fine, I dunno why we were nit-picking about that...)
2006-07-06 16:41:56 +00:00
Rob Landley f296f0b77d Bug fix from Vladimir Oleynic via Paul Fox for:
echo "+bond0" > /sys/class/net/bonding_masters
while true; do
  echo hello
done
2006-07-06 01:09:21 +00:00
Mike Frysinger 434ccd9739 fixes from ldoolitt@recycle.lbl.gov to use proper tab escaping and fix a typo 2006-07-05 22:19:21 +00:00
"Robert P. J. Day" cf5b80ba32 This file doesn't appear to be used anywhere. 2006-07-05 12:47:26 +00:00
Bernhard Reutner-Fischer 273430aa8d - Pull r15593:
Rename to CROSS_COMPILE and move its configuration to .config.mak. (Shaun Jackman)
2006-07-04 08:26:55 +00:00
"Robert P. J. Day" c773ac8a79 Delete unused version.c file and corresponding function prototypes
from blkid.h.  If this file needs to be resurrected, it can be
based on ext2fs/version.c.
2006-07-03 18:11:39 +00:00
Mike Frysinger 259472e741 remove duplicate CONFIG_TASKSET option 2006-07-03 05:22:36 +00:00
Mike Frysinger 441bfbf143 make the -0 xargs option a little more clear 2006-07-03 05:19:44 +00:00
"Robert P. J. Day" 4eddb42bbc Remove the silly redundancy from that header file include. 2006-07-03 00:46:47 +00:00
"Robert P. J. Day" c9f423a93d Correct the comment to match the code. 2006-07-02 19:52:52 +00:00
"Robert P. J. Day" 63fc1a9e08 Standardize on the vi editing directives being on the first line. 2006-07-02 19:47:05 +00:00
"Robert P. J. Day" 087b9d640e Allow a user-configurable minimum password length. 2006-07-02 18:35:39 +00:00
Bernhard Reutner-Fischer e02706fe45 - note that get_hz potentially needs cleanup. 2006-07-02 10:33:10 +00:00
Rob Landley 7a8e491dff Patch from Shaun Jackman moving the var=value logic to here it can do some good. 2006-07-01 17:19:02 +00:00
"Robert P. J. Day" 7ccb65f3a4 Yet more "#if 0" content removed. 2006-07-01 15:09:17 +00:00
"Robert P. J. Day" d35ef0f666 More removal of "#if 0" content. 2006-07-01 14:59:54 +00:00
"Robert P. J. Day" edd9ca5743 More removal of "#if 0" content. 2006-07-01 14:52:12 +00:00
"Robert P. J. Day" 53f21e34a7 Remove "#if 0" content. 2006-07-01 14:34:33 +00:00
"Robert P. J. Day" 177c9f3128 Get rid of all "#if 0" content. 2006-07-01 14:30:28 +00:00
"Robert P. J. Day" 68229837ff Remove all usage of the "register" storage class specifier. 2006-07-01 13:08:46 +00:00
"Robert P. J. Day" f350160963 Remove "#if 1" directives. 2006-07-01 12:19:39 +00:00
Rob Landley 01772aea33 Annoint 1.2.0. 2006-06-30 22:40:13 +00:00
Rob Landley 12d9419273 Revert taskset for 1.2.0. It emits a warning, breaks building under RH9,
and nobody seemed interested in fixing it despite repeated complaints.
I'll worry about it in the 1.3 timeframe...
2006-06-30 22:20:43 +00:00
Ned Ludd 5df6d9f777 - Give Rob Landley things TODO like depmod 2006-06-30 21:48:38 +00:00
Rob Landley a526c30cc5 Make another warning go away. 2006-06-30 20:30:10 +00:00
Rob Landley ab58d5cf8a Make warnings go away. 2006-06-30 19:04:09 +00:00
Rob Landley 9c0e4f03d9 More random todo items... 2006-06-30 16:38:09 +00:00
Rob Landley 8bbdb8732f This kind of paranoia is a debug option at best. 2006-06-30 16:36:56 +00:00
Rob Landley cd545287c5 Fix bug 744 by moving the flushing logic into the exhausted read buffer test.
(Also some other minor cleanups while I was there, shouldn't affect the
resulting binary.)
2006-06-30 16:35:40 +00:00
Rob Landley 00c051e42d Bug http://bugs.busybox.net/view.php?id=723 - initialize tv1 the first time
through the loop.
2006-06-30 14:05:19 +00:00
Mike Frysinger c340ea191a fix from Kolbjørn Barmen for building for m68k targets 2006-06-30 02:53:56 +00:00
Rob Landley 7077ea30f5 Some old kernel headers don't #include BLKSSZGET in sys/mount.h. 2006-06-29 19:00:12 +00:00
Rob Landley c5e4ab7fe6 Minor update on init not working. 2006-06-29 04:59:11 +00:00
Rob Landley a6e6037219 Fix bug http://bugs.busybox.net/view.php?id=874 where hexdump -C got its
spacing wrong.
2006-06-28 14:36:50 +00:00
Rob Landley db1ab1aeb3 Top was catching sigterm (and fumbling sigint) so it could reset the terminal
type on the way out, but the signal handler didn't exit.  Plus it did
unnecessary things with sigaction.  This code is overgrown and needs a serious
weed-whacking...
2006-06-28 14:11:25 +00:00
Rob Landley ea7c18514b Fix http://bugs.busybox.net/view.php?id=826 in which "(echo; echo) | sed x"
crashes because the empty state of the hold space is NULL but the empty
state of the pattern space is "".
2006-06-28 13:50:59 +00:00
Mike Frysinger cc826d74e4 cleanup patch usage 2006-06-28 00:22:32 +00:00
Rob Landley 1979d3ccbc More website cleanup. 2006-06-27 22:33:22 +00:00
Rob Landley d879ffb79e Move 2005 and earlier to oldnews. 2006-06-27 21:29:56 +00:00
Rob Landley ed9aec908b Redo the license section completely, and update the header to group the tabs. 2006-06-27 20:47:08 +00:00
Rob Landley cddba6c61f Move documentation links into the index so they're more visible. 2006-06-27 18:59:57 +00:00
Rob Landley af12cb39d1 Patch from Geoff Baker to fix bug http://bugs.busybox.net/view.php?id=905 by
changing wget's ftp code not to chdir but to use the complete path each time.
2006-06-27 18:41:03 +00:00
Rob Landley 22f383e695 Fix http://bugs.busybox.net/view.php?id=906 which could cause failures in top. 2006-06-27 18:14:12 +00:00
"Robert P. J. Day" 21302c2b78 Properly print the output for a sit (IPv6-in-IPv4) interface. 2006-06-26 22:03:43 +00:00
"Robert P. J. Day" 4137dd783b Aesthetic fix to use newer structure initialization format. 2006-06-26 21:54:57 +00:00
Mike Frysinger cd68a2e1a8 fix watchdog on no-mmu systems by adding -F option for rexec 2006-06-26 21:31:17 +00:00
Mike Frysinger 42705abc28 dont setpgrp() for now as it breaks system() and that is more important than ctrl+c handling of background processes 2006-06-26 20:42:36 +00:00
Rob Landley ef10d52745 Upgrade mdev to allow commands to be run on create/delete.
Both Jason Schoon and Giuseppe Ciotta deserve credit for this, I used elements
of both.  It's been upgraded so that you can specify that a given command
should run at create, at delete, or at both using different special characters
(@, $, and * respectively).  It uses the system() method of running command
lines which means you can use environment variables on the command line (it
sets $MDEV to the name of the current device being created/deleted, which is
useful if you matched it via regex), and the documentation warns that you need
a /bin/sh to make that work, so you probably want to pick a default shell.
2006-06-26 14:11:33 +00:00
Rob Landley cf7577d417 Missed one. Based on suggestions from Erik Hovland. 2006-06-25 22:59:31 +00:00
Rob Landley 11c7a7bed6 Various cleanups I made while going through Erik Hovland's patch submissions,
some of which are even from him. :)
2006-06-25 22:39:24 +00:00
Bernhard Reutner-Fischer f087798e8b - convert old-style parameter declarations (K&R) to modern style. 2006-06-25 22:08:53 +00:00
Rob Landley a892bf8284 Whitespace. (Vim's auto-indent is kind of annoying at times, like "daytime"
and "nighttime"...)
2006-06-25 15:37:28 +00:00
Rob Landley 934da82913 Fix a possible race condition if two processes try to claim the same loop
device at the same time.  We should only CLR_FD if the set status fails,
not if the SET_FD fails.
2006-06-25 15:29:12 +00:00
Rob Landley 768945b762 A few patches from Erik Hovland, turning strncpy() into safe_strncpy() and
removing some unnecessary code.
2006-06-25 00:34:52 +00:00
Rob Landley 641c3537c0 Add a test from Glenn. 2006-06-24 22:55:13 +00:00
Rob Landley e1ee482684 Document mount's new error return conventions. 2006-06-24 22:39:19 +00:00
Rob Landley c983274565 The logic to make cp -d or -P treat things like regular files should only
trigger for symlinks, not for device nodes.  This should fix "cp -a /dev ."
to work as expected (when run by root, anyway).

While I was there, cleanup headers and make an #ifdef go away...
2006-06-24 21:27:36 +00:00
Rob Landley 5d9c42aadc Slowly pulling more common headers into libbb.h. Andre pointed out that
older uClibc didn't include sys/socket.h from netinet/in.h, so add an
explicit #include for that too...
2006-06-24 17:55:02 +00:00
Rob Landley 53433b3ca1 Clean up. 2006-06-22 22:28:29 +00:00
Rob Landley 1fa4a9448b Patch from Shaun Jackman to replace CFLAGS_EXTRA with .config.mak 2006-06-22 22:05:00 +00:00
Rob Landley 67d4943393 CONFIG_DHCP -> CONFIG_APP_DHCP. 2006-06-22 18:48:34 +00:00
Mike Frysinger 135cee3741 Jean Wolter writes: modprobe checks, whether a module is already loaded. The function used for this currently always returns 0. 2006-06-21 23:03:37 +00:00
Bernhard Reutner-Fischer 35492137f8 - add note about strict ordering 2006-06-21 18:19:53 +00:00
Mike Frysinger c2ad4f5d27 Jean Wolter writes: ash uses bsearch to search in the list of built-in commands, therefore the list of built-in commands has to be ordered. Revision 15077 introduced the source built-in and destroyed this order. And now ash doesn't find the shift command anymore. 2006-06-21 18:04:49 +00:00
Rob Landley 0cc2c2c289 Patch from Paul Fox to improve mount's error handling behavior, which I beat
on a bit.
2006-06-21 03:53:33 +00:00
Rob Landley dbfb5a3cb7 Andre (armcc2200@yahoo) patched a bug where successful mounts could sometimes
produce an error, due to a missing rc assignment.
2006-06-21 02:39:57 +00:00
Rob Landley 399d45f1c6 Aurelien Jacobs pointed out inline functions that could be removed. Doing so
shrank the code a bit.
2006-06-21 01:49:17 +00:00
Rob Landley e5e1a10cd3 Remove pointless "inline" wrapper around get_terminal_width_height(). 2006-06-21 01:15:36 +00:00
Rob Landley 2d6af16035 Zubicaray reported a bug in vi that causes it to eat 100% cpu when you close
an xterm it's running in.  The vi signal behavior would catch and restarts lots
of signals, like SIGHUP, that should just kill the thing.  (Leftover behavior
from when it would segfault all the time.)  Filtered out the more obviously
bad ones.  If it segfaults, we should find and fix the problem.
2006-06-21 00:52:31 +00:00
Mike Frysinger b049c0ec19 only enable count_bit functions when actually needed to fix warning reported by Bernhard Fischer 2006-06-20 23:03:27 +00:00
Rob Landley b13fee4cbb Since rangecoder is just a bunch of C functions, move it into the one user
(decompress_unlzma.c).  Also a slight #include cleanup, and I've been meaning
to put #include <unistd.h> into libbb.h since it's so darn common...
2006-06-20 22:38:00 +00:00
Rob Landley 5483de1cb7 Cleanup patch from Shaun Jackman converting %m to perror. 2006-06-20 21:35:26 +00:00
Rob Landley 9fe801e0d2 Patch by Robert P. Day to remove obsolete alias code that the 2.4 and 2.6
Linux kernels don't do anymore.
2006-06-20 21:13:29 +00:00
Mike Frysinger 14ff19b28a assign default debug level to the MSHDEBUG define 2006-06-20 20:37:01 +00:00
Rob Landley 2b8a05a775 I broke allbareconfig with half-finished cleanups I'd forgotten weren't done.
Got both to a decent stopping point.  (There's a lot more cleanup to do on ls.c
but now is not the time...)
2006-06-20 17:43:01 +00:00
Rob Landley 8437ede6c2 The type changed too. 2006-06-20 16:43:05 +00:00
Peter Kjellerstedt 5ab8f7de4f Use the new names for tty_baud_to_value() and tty_value_to_baud() again. 2006-06-20 16:35:37 +00:00
Rob Landley 57c1f73dd5 Revert the last two patches to go back to a state before this file was
controversial.
2006-06-20 16:17:24 +00:00
Rob Landley 2818b292fb Patch by Robert P. Day to make structs use c99 initializers. 2006-06-20 15:52:52 +00:00
Rob Landley 2a613d7360 Patch from Robert P. J. Day cleaning up some unnecessary preprocessor
directives.
2006-06-20 14:57:00 +00:00
Rob Landley 352e117c6b Amrein-Marie Christophe pointed out that Mandrake changed its name. 2006-06-20 14:09:20 +00:00
Rob Landley 7a260f01ce Make some 64 bit warnings go away on x86-64. 2006-06-19 03:20:03 +00:00
Rob Landley 290fcb4213 Undo all of the ugliness and some of the bloat from 15412. 2006-06-18 23:59:03 +00:00
Rob Landley ea224be6aa skip_whitespace() shouldn't claim its return value is const, it doesn't know
that and callers wind up typecasting it back.
2006-06-18 20:20:07 +00:00
Rob Landley 14d7065ef1 Make this slightly more readable, and expose the hypocrasy of a comment that
says "our implementation makes it impossible to use blocksizes smaller than
22 octets" right above a check for blocksize < 8.
2006-06-18 15:23:13 +00:00
Mike Frysinger b000586d02 danf writes: stty doesn't support baud rates > 460800 bps, the attached patch adds support for all baud rates supported by Linux 2.6.16 on x86. 2006-06-17 22:41:28 +00:00
Rob Landley fe3d844bb1 Make it so Erik has to forward me less email. 2006-06-16 22:29:03 +00:00
Bernhard Reutner-Fischer fa61ca7591 - add cross-reference generation target.
Experimental.
2006-06-16 17:19:39 +00:00
Bernhard Reutner-Fischer 6d82f94681 - do away with the fwd-decls of functions. Should not contain any code changes
AFAICT.
2006-06-16 16:37:07 +00:00
Rob Landley d9a761d9c3 Revert svn 15333. If you vfork, you must either exec or exit. (The parent is
blocked until you do so.)
2006-06-16 16:35:53 +00:00
Rob Landley 1449a2014a This directory was fallout from the great feature freeze of 2003, which led
up to the 1.00 release.  I just moved what was left of it to
http://busybox.net/~landley/pending because it does _not_ belong in the
tree anymore.
2006-06-16 15:08:59 +00:00
Bernhard Reutner-Fischer 747041955e - hide CONFIG_GETOPT_LONG for the 1.2.0 release. Turned on per default.
I will revisit this and make sure that run-parts and ifupdown are fixed; hdparm needs treatment too..
2006-06-16 14:03:23 +00:00
Bernhard Reutner-Fischer f5efa7bfeb - add patch to provide a target 'html' to build a cross-reference of the source 2006-06-16 12:45:29 +00:00
Bernhard Reutner-Fischer fd4b61d5f3 - add needed includes and include busybox.h needed for the ATTRIBUTE define. 2006-06-16 12:28:39 +00:00
Rob Landley bc8c50351f Remove warnings caused by #include <sys/mount.h> in platform.h. Apparently
we redefine a lot of stuff from standard header files...
2006-06-16 04:25:19 +00:00
Rob Landley 9947a244d4 Patch from Rich Felker:
- duplicated format bit 14 forced LIST_EXEC always-on
- -p option was behaving just like -F (SUSv3 says -p only shows / for
  dirs, not other special symbols)
- tests for LIST_EXEC in color functions were nonsense (constant
  tests). i assume they were supposed to be (all_fmt & LIST_EXEC)
  however having coloring of executable files depend on -F seems
  undesirable.
2006-06-15 22:11:10 +00:00
Bernhard Reutner-Fischer 1761b9dabe - use shorter boilerplate, more accurate header guard
- don't use multi-line string literals
2006-06-15 21:56:28 +00:00
Bernhard Reutner-Fischer 7011dd0e06 - drats. 2006-06-15 21:39:34 +00:00
Bernhard Reutner-Fischer 42f091a761 - let the scripts be prerequisites of the files the generate
- make sure that bbconfig isn't too stupid
2006-06-15 21:35:35 +00:00
Rob Landley 39218932b1 Fix bug found by Joey Hess and forwarded by Bastian Bunk. Add Joey Hess's
test case to the testsuite, plus another one that would have been broken by
the first attempt at a fix.
2006-06-15 20:50:38 +00:00
Rob Landley cd82c3c041 Don't do workarounds for broken shells. Busybox is about to grow a shell that
we can run our own testsuite under, and I want it to handle the full range of
strange and peverted behavior you can find in real world shell scripts.
In the meantime, I'll just say #!/bin/bash in places that may care.
2006-06-15 20:07:57 +00:00
Rob Landley 04b7ef967b Jens Michaelsen pointed out that Linksys' firmware download side moved. 2006-06-15 17:34:57 +00:00
Rob Landley 148734df99 We came up with our own names for ATTRIBUTE_*, so why check if they're already
#defined?  Also remove a check for a gcc version older than RH9 (if non-linux
needs that #define they can put it in their section.)
2006-06-15 16:00:42 +00:00
Rob Landley 22d26fc6ae Patch from Yann Morin to put BLKGETSIZE64 in platform.h had rather a lot of
fallout due to the #include <sys/mount.h>.  Removed that #include from various
applets and fixed up those that were unhappy when that #include was made
because they'd block copied stuff out of it.  (Sigh.)
2006-06-15 15:49:36 +00:00
Rob Landley d6e5083d16 Help text update for libbb, talking about make standalone. 2006-06-15 15:04:53 +00:00
Bernhard Reutner-Fischer e2c7d34051 - there is no "CONFIG_STANDALONE" in the repository. Also iff there was a
CONFIG_STANDALONE, we'd need to toggle this on per default.
2006-06-14 17:33:57 +00:00
Bernhard Reutner-Fischer 597e70e9e4 - rename CONFIG_FEATURE_TFTP_DEBUG to CONFIG_DEBUG_TFTP 2006-06-14 17:32:11 +00:00
Bernhard Reutner-Fischer 32bf1f9d42 - rename CONFIG_FEATURE_TFTP_DEBUG to CONFIG_DEBUG_TFTP so it's off in defconfig
- expand the cmd_get/cmd_put macros
- Jason Schoon writes: unlink only if non-stdio
2006-06-14 17:29:10 +00:00
Bernhard Reutner-Fischer f1bd42a305 - correct typo 2006-06-14 16:51:50 +00:00
Bernhard Reutner-Fischer df798b7f58 - minor size tweak
text    data     bss     dec     hex filename
    613       0       0     613     265 loginutils/su.o.orig
    605       0       0     605     25d loginutils/su.o
2006-06-14 16:36:45 +00:00
Bernhard Reutner-Fischer 66e3a222cd - minor shrinkage 2006-06-14 16:17:50 +00:00
Rob Landley d760560c52 Attempt at fixing bug 836, vaguely based on patch from somebody named
clausmuus, forwarded to me by Yann E. Morin.
2006-06-14 01:51:16 +00:00
Rob Landley a34b48abe5 Upgrade the standalone shell code to use CONFIG_BUSYBOX_EXEC_PATH. 2006-06-14 01:27:01 +00:00
Rob Landley c7ddefc062 Attempt at fixing bug 815 by upgrading bb_spawn() so that builtins are at
the start of the path.  (This should be under the same config option as
the standalone shell, but right now that's buried in the shell menu.)

Also add the ability to specify CONFIG_BUSYBOX_EXEC_PATH with /proc/self/exe
as an overrideable default.
2006-06-14 01:24:33 +00:00
Rob Landley 575c8bacda Don't break allbareconfig. 2006-06-13 21:30:09 +00:00
Rob Landley 68286770b6 Patch from Shaun Jackman to detect "name=value" variable assignments. Random
cleanup at the end by me to make some unrelated #ifdefs go away...
2006-06-13 19:01:30 +00:00
Rob Landley f946379599 Make lash smaller. (Use llist_t for file closing, and different allocation
functions.)
2006-06-13 18:50:20 +00:00
Rob Landley 7c7b0d7437 Rewrite of dmesg, smaller and simpler. 2006-06-13 18:31:04 +00:00
Rob Landley 18958e9309 Random cleanup of platform.h. 2006-06-13 18:28:33 +00:00
Rob Landley 0960ca7383 Work around a persistent uClibc bug, since 0.9.29 still hasn't shipped.
Poked to do this by Jason Schoon.
2006-06-13 18:27:16 +00:00
Rob Landley 19a3940f15 Patch from Denis Vlasenko:
* Rename a var: statbytes -> transferred
* cursize == transferred, always. Nuke cursize.
* Make progressmeter() a nop if !CONFIG_FEATURE_WGET_STATUSBAR
  (reduces #ifdef forest)
* double elapsed -> int elapsed
* Do not sprintf to buf first and then write(STDERR) it,
  just fprintf directly to stderr
* Progress bar printing code made smaller
* Style fixes
2006-06-13 17:10:26 +00:00
Rob Landley 76ef08c5e3 Whitespace cleanup from Denis Vlasenko. 2006-06-13 16:44:26 +00:00
Rob Landley 7900b7b9b9 Use -ffunction-sections -fdata-sections --gc-sections if the compiler supports
it.  If nothing else, this gives us better granularity in bloatcheck.
2006-06-13 16:17:16 +00:00
Rob Landley c4b673994e Use xstat() instead of if(stat()) die() 2006-06-13 16:09:16 +00:00
Rob Landley fd8409f8c5 Patch from Denis Vlasenko, tweak error messages. 2006-06-13 15:31:39 +00:00
Rob Landley 9a1a9de49f Minor size shrinkage. 2006-06-13 15:12:14 +00:00
Rob Landley 9a202c9daa Patch from Denis Vlasenko: unlzma was make files with mode 777. Tweak
everything to do stat() and use xopen3().
2006-06-13 14:54:42 +00:00
Rob Landley 1dea55d577 Fix from Paul Fox to make compressed help text notice config changes. 2006-06-13 14:37:14 +00:00
Bernhard Reutner-Fischer 7b8ff22685 - make VERBOSE= and V= work equally; use BUILD_VERBOSE internally.
- move the link flags to cmd_link* so they are printed when requesting verbose output
2006-06-13 14:20:17 +00:00
Bernhard Reutner-Fischer 2f6a317944 - fix stupid typo from last checkin 2006-06-12 14:34:01 +00:00
Bernhard Reutner-Fischer f81ac42689 - remove superfluous CONFIG_BEGIN and CONFIG_END 2006-06-11 18:04:23 +00:00
Bernhard Reutner-Fischer a926f8e50a - add fancy mode to start-stop-daemon to support --oknodo and --verbose 2006-06-11 17:24:01 +00:00
Bernhard Reutner-Fischer 081b1ac6b4 - invert logic for nocheck_targets to exclude the empty default target. 2006-06-11 16:41:10 +00:00
Bernhard Reutner-Fischer e5de38497a - don't check for toolchain-setting for make targets that don't need them
- we already depend on sed, so do away with tr. Avoids pulling in yet another
  dependency.
2006-06-10 14:58:33 +00:00
Bernhard Reutner-Fischer 62f9856f54 - revert incorrect select change 2006-06-10 14:32:56 +00:00
Bernhard Reutner-Fischer b25f98a417 - fix two segfaults (reported by Horst Kronstorfer)
- remove dangling file if get fails (spotted and fixed by Jason Schoon)
- shrink it (Bernhard Fischer)
Thanks, all!
   text	   data	    bss	    dec	    hex	filename
   2684	      0	      0	   2684	    a7c	networking/tftp.o.orig
   2748	      0	      0	   2748	    abc	networking/tftp.o.allfixed
   2666	      0	      0	   2666	    a6a	networking/tftp.o.+shrink
2006-06-10 14:15:03 +00:00
Bernhard Reutner-Fischer 3b1936dcf9 - use bb_xbind
Thanks Erik Hovland
2006-06-10 11:39:09 +00:00
Bernhard Reutner-Fischer 44e216f264 - use bb_xchdir instead of ignoring eventual errors of chdir
Thanks to Erik Hovland
2006-06-10 11:29:44 +00:00
Bernhard Reutner-Fischer 2d1a6e7c1f - fix bug #887, in bb_get_chomped_line_from_file(), the last char was removed
unconditionally, even if it was not a newline.
  This was apparently broken by r14254
- whitespace while at it.
2006-06-10 11:04:43 +00:00
Paul Fox 6ba8bbe88a add ordering warning on enum Location 2006-06-09 12:25:10 +00:00
Bernhard Reutner-Fischer 1e23b6fdb5 - make sure that we see string_insert only if we need it. 2006-06-09 07:12:27 +00:00
Paul Fox 7ba12c6957 remove leading "Enable" from the config option text. not only is it
redundant, but it made the menuconfig shortcut mechanism mostly
useless, since so many of the entries started with 'E'.
2006-06-08 21:48:47 +00:00
Paul Fox 6ab037872f made "test" an ash built-in.
moved the contents of libbb/bb_echo.c back into coreutils/echo.c,
which is a more reasonable place for them than libbb.  this
forces anyone who wants echo and test to be builtin to ash to
also have them available as applets.  their cost is very small,
and the number of people who wouldn't want them as applets is
also very small.

added warning about shell builtins vs. CONFIG_FEATURE_SH_STANDALONE_SHELL,
which conflicts with their use.

thanks to nathanael copa for debugging help.

some string size optimization in test.c may have been lost with
this commit, but this is a good new baseline.
2006-06-08 21:37:26 +00:00
Rob Landley 176f2df69b Patch from Erik Hovland, via Tito. 2006-06-08 14:19:48 +00:00
Rob Landley 9c6f9552ec Some day, maybe gcc will be able to optimize out static functions that are
never used so we don't have to #ifdef them.  Wouldn't that be nice?
2006-06-08 14:11:36 +00:00
Mike Frysinger 2e7dfc179c need prototype for new vfork_daemon() 2006-06-07 21:58:57 +00:00
Mike Frysinger 9be7435203 initial support for no-mmu systems 2006-06-07 21:48:43 +00:00
Mike Frysinger 6fb5847faf sometimes daemonizing and vfork()/exit() is ok 2006-06-07 21:48:30 +00:00
Mike Frysinger ca70774293 bb_xdaemon() isnt available on no-mmu systems 2006-06-07 21:47:34 +00:00
Mike Frysinger 373af43bb0 comment all fields 2006-06-07 21:37:59 +00:00
Mike Frysinger 2fc534f3f1 hint at where the Magic comes from 2006-06-07 21:37:49 +00:00
Bernhard Reutner-Fischer f915a77386 - do away with the comment that noted that the current implementation
unly supports linux.
2006-06-07 21:26:09 +00:00
Rob Landley 6d8ce170b0 Fix from Tito to read from stdin only when it's not a tty. 2006-06-07 21:22:42 +00:00
Bernhard Reutner-Fischer 5929edc1fa - spelling 2006-06-07 20:30:01 +00:00
Mike Frysinger 301ad67912 add reference to proc(5) 2006-06-07 20:24:34 +00:00
Bernhard Reutner-Fischer 19008b8373 - reuse strings and messages. Saves about 600B 2006-06-07 20:17:41 +00:00
Rob Landley 4c5ad2fc90 Consolidate devfs garbage and mark it as obsolete. 2006-06-07 20:11:53 +00:00
Mike Frysinger 830d258dee use bb_xbind/bb_xlisten 2006-06-07 20:06:24 +00:00
Mike Frysinger 828d6bb3bc whitespace 2006-06-07 20:04:13 +00:00
Mike Frysinger 62a2c15376 whitespace 2006-06-07 20:03:13 +00:00
Mike Frysinger e3fdf2431a add a --noclobber flag 2006-06-07 18:12:27 +00:00
Mike Frysinger 81514ecca3 add support for cleaning out previous busybox install 2006-06-07 18:08:25 +00:00
Mike Frysinger 74b29a107f dont install emtpy libdirs 2006-06-07 17:27:46 +00:00
Mike Frysinger 55b12105b5 dont mix tabs and spaces, kthx 2006-06-07 17:24:29 +00:00
Mike Frysinger bc6584977a remove cvs $Id tag 2006-06-07 16:31:05 +00:00
Bernhard Reutner-Fischer 16d3e4e0af - add applet taskset to set/retrieve the CPU affinity of a process
text    data     bss     dec     hex filename
    584       0       0     584     248 taskset.o.gcc-2.95
    509       0       0     509     1fd taskset.o.gcc-3.3
    505       0       0     505     1f9 taskset.o.gcc-3.4
    506       0       0     506     1fa taskset.o.gcc-4.0
    498       0       0     498     1f2 taskset.o.gcc-4.1
    495       0       0     495     1ef taskset.o.gcc-4.2-HEAD
2006-06-07 15:44:59 +00:00
Mike Frysinger ea93f8a397 Tito writes: this patch fixes two potential bugs with the -i -I flags that could be reset during option parsing 2006-06-07 14:25:22 +00:00
Bernhard Reutner-Fischer e0387a6ee8 - fix the build if we have ftpput without ftpget (speeling reeoe)
Thanks to Stephane Billiart
2006-06-07 13:31:59 +00:00
Rob Landley 0753f4a15e Callers to identify() converted the endianness of the buffer. So did
identify().  This meant big endian systems had a NUXI problem.  Removed
the redundant conversion from the callers, and made some in-passing cleanups
while I was there.
2006-06-07 00:27:25 +00:00
Rob Landley eb29d6ce6a Remove a config entry that leaked in from my tree before I decided to
implement cat -v as a separate applet.
2006-06-06 22:59:37 +00:00
Rob Landley c44ab02f15 Whack the one last warning in make allbareconfig... 2006-06-06 19:50:16 +00:00
Mike Frysinger 280dae74b0 import support for microblaze relocations from uClinux-dist 2006-06-06 06:30:32 +00:00
Mike Frysinger 2a13175440 make the default prompt suck less when using fancy prompts 2006-06-06 06:26:12 +00:00
Mike Frysinger 75c6b7962d fix from uClinux-dist for proper exit status if reading /proc/modules failed 2006-06-06 06:19:19 +00:00
Mike Frysinger b306cb767f merge blackfin/microblaze from uClinux-dist 2006-06-06 06:15:52 +00:00
Mike Frysinger 8e640a1043 use vfork() instead of vork() since the only thing we do is execve() an app after fork (allows time to work on no-mmu) 2006-06-06 06:08:34 +00:00
Mike Frysinger b16b5bb08f only check __GNU_LIBRARY__ if it is actually defined 2006-06-06 06:00:20 +00:00
Rob Landley 362dc2bf33 Header cleanup on two more networking files (move libbb.h to the top and
remove #includes that libbb.h already does), plus a minor cleanup of
libbb.h to move #includes towards the top of the file where we can see 'em.
2006-06-05 17:35:24 +00:00
Rob Landley 12d87550a3 Confirming it's not needed. 2006-06-05 17:32:44 +00:00
Bernhard Reutner-Fischer bc291dc731 - add note about need to unify the 4 itoa() implementations. 2006-06-05 16:00:12 +00:00
Bernhard Reutner-Fischer 1e34731a6a - add testcase for grep bug (http://busybox.net/bugs/view.php?id=887)
The patch for bug #887 seems to work for me..
2006-06-04 18:40:48 +00:00
Bernhard Reutner-Fischer 213cc00445 - add note about ingroup and is_a_group_member 2006-06-04 17:58:19 +00:00
Bernhard Reutner-Fischer 863073da08 - add note about removing superfluous fmt specifiers 2006-06-04 16:05:02 +00:00
Bernhard Reutner-Fischer 395010b1f0 - note to cleanup fprintf(2,...) -> bb_error_msg(...) and
perror("bar") -> bb_perror_msg("bar");
2006-06-04 15:37:59 +00:00
Bernhard Reutner-Fischer 1b9d7c9aa9 - use bb_msg_{read,write}_error where appropriate.
text	   data	    bss	    dec	    hex	filename
 825015	   9100	 645216	1479331	 1692a3	busybox.old
 824919	   9100	 645216	1479235	 169243	busybox
2006-06-03 22:45:37 +00:00
Bernhard Reutner-Fischer a3d4bf38b0 - use bb functions instead of handrolling stuff.
- add XXX question about supposedly superfluous else clause
   text	   data	    bss	    dec	    hex	filename
   5918	      0	      0	   5918	   171e	editors/sed.o.orig
   5901	      0	      0	   5901	   170d	editors/sed.o
2006-06-03 21:40:11 +00:00
Rob Landley e84f4343b2 Remove #ifdeffed out code, both KEEP_UNUSED and #if 0. 2006-06-03 21:23:20 +00:00
Bernhard Reutner-Fischer 5084c78cbe - remove superfluous call of stack_machine(0) upon exit. 2006-06-03 21:19:09 +00:00
Bernhard Reutner-Fischer 5f6d67b7d6 - no need to have timer_duration in the data section.
- cleanup a little bit while at it.
2006-06-03 20:53:18 +00:00
Bernhard Reutner-Fischer b1312c9125 - use bb_msg_write_error in 3 places
- whitespace
2006-06-03 20:09:02 +00:00
Bernhard Reutner-Fischer c89982dcd7 - move #include busybox.h to the very top so we pull in the config
and eventual platform specific includes in early.
2006-06-03 19:49:21 +00:00
Bernhard Reutner-Fischer deda6a5c0d - move #include busybox.h to the very top so we pull in the config
and eventual platform specific includes in early.
- remove two supposedly superfluous newlines from ...error_msg() in modprobe
  and use shorter boilerplate while at it.
2006-06-03 19:35:15 +00:00
Bernhard Reutner-Fischer 2c351a8f98 - patch from Yann E. Morin: makes modprobe understand shell patterns
(especially '*') in module aliases, such as:
  "alias usb:v0582p0075d*dc*dsc*dp*ic*isc*ip* snd_usb_audio"

Fixes bug #889

 842162	  10244	 645924	1498330	 16dcda	busybox.old-4.1.20060603-1948
 842178	  10244	 645924	1498346	 16dcea	busybox.new-4.1.20060603-1948
2006-06-03 19:08:49 +00:00
Bernhard Reutner-Fischer 62558765b9 2006-06-02 Shaun Jackman <sjackman@gmail.com>
* shell/lash.c (pseudo_exec) [_NEWLIB_VERSION]: Remove the
	__getopt_initialized hackery.
2006-06-03 10:28:25 +00:00
Bernhard Reutner-Fischer 5c0ae06ef1 - No options should set the current system time.
Shaun Jackman writes:
A bug introduced in svn 11946 broke rdate. It no longer sets the
current system time when no options are specified. The options have
the opposite sense from what one might think, and, oddly enough, -ps
is intentionally a no-op.

Quoth rdate(8) from the BSD System Manager's Manual:

    -p      Do not set, just print the remote time
    -s      Do not print the time.
2006-06-03 10:24:20 +00:00
Rob Landley 9a990aaba8 Patch from Atsushi Nemoto:
This patch make depmod.pl more robust in cross environment.  If native
nm did not recognize target's object, you can override it with NM
environment variable.
2006-06-02 21:30:40 +00:00
Bernhard Reutner-Fischer e15d7573a1 - move #include busybox.h to the very top so we pull in the config
and eventual platform specific includes in early.
2006-06-02 20:56:16 +00:00
Rob Landley ecae66ac16 Header cleanup: don't #include headers that libbb.h already includes. 2006-06-02 20:53:38 +00:00
Rob Landley ff97ee9abd #ifdef reduction. 2006-06-02 19:03:01 +00:00
Bernhard Reutner-Fischer cf1f2ace39 - fix CONFIG_DEBUG_INIT compile failure 2006-06-02 10:43:17 +00:00
Mike Frysinger 3132e9d830 use xmalloc() 2006-06-02 06:30:30 +00:00
Paul Fox f0327f8e98 fix fdflish typo (reported by erik hovland) 2006-06-02 03:37:16 +00:00
Bernhard Reutner-Fischer b5353a20f3 - look at bb_applet_name. Should close bugs #892 and #893
also restructure code a bit so the fix only adds 1 byte..
2006-06-01 18:30:42 +00:00
Bernhard Reutner-Fischer d04e9b8130 - shrink logread a bit.
text    data     bss     dec     hex filename
    862      26     188    1076     434 logread.o.orig
    825      26     188    1039     40f logread.o
2006-06-01 14:36:14 +00:00
Paul Fox d112f8fa5e make halt and poweroff messages more accurate (i.e., claim "we're about to",
rather than "it's done", and combine with reboot handler to save space.
2006-06-01 13:17:49 +00:00
Rob Landley 8fc32d9326 Shaun Jackman pointed out that KERNEL_VERSION() is used without guards, so
defining it in a guard is silly.
2006-06-01 00:52:30 +00:00
Rob Landley 317a45cb62 The common case APPLET() macro only needs three arguments. 2006-06-01 00:51:38 +00:00
Rob Landley 9b1857f79f Bugfix from Shaun Jackman: don't attempt to write 64 bytes and then fail if
the write wasn't 192 bytes long.
2006-05-31 23:54:50 +00:00
Rob Landley d5b9b60fa5 Add CONFIG_NITPICK. (And tweak a couple other help entries while I'm there.)
Nothing's actually using it yet, but we need it.
2006-05-31 23:23:42 +00:00
Rob Landley 0620841758 Patch from Tito to remove long options from hdparm. 2006-05-31 22:52:57 +00:00
Rob Landley c8b360ebb7 Use BB endianness macro. 2006-05-31 22:24:33 +00:00
Rob Landley b623a542df Header file cleanup. platform.h apparently needs to be included early on so it
can figure out what header files to include, and override stuff that comes
later.  But applets shouldn't include platform.h directly, they should include
busybox.h or libbb.h.  Since busybox.h already includes libbb.h, move libbb.h
to the top of busybox.h and platform.h near the top of libbb.h (right after
bbconfig.h, which is something platform.h also needs access to).

While we're at it, move some stuff from busybox.h to libbb.h so we have one
big file to audit/clean up/try to make sense of instead of many.
2006-05-31 22:09:03 +00:00
Rob Landley 8abbee474c Add catv (separate applet instead of cat -v). Also cleanup cat.c comments,
the following of which (from cat.c) belongs in svn history instead of the
source code:

/* Mar 16, 2003      Manuel Novoa III   (mjn3@codepoet.org)
 *
 * This is a new implementation of 'cat' which aims to be SUSv3 compliant.
 *
 * Changes from the previous implementation include:
 * 1) Multiple '-' args are accepted as required by SUSv3.  The previous
 *    implementation would close stdin and segfault on a subsequent '-'.
 * 2) The '-u' options is required by SUSv3.  Note that the specified
 *    behavior for '-u' is done by default, so all we need do is accept
 *    the option.
 */
2006-05-31 19:36:04 +00:00
Bernhard Reutner-Fischer 9a5686b605 - fix IMA compile error i introduced when adding this untested snippet. 2006-05-31 18:57:56 +00:00
Bernhard Reutner-Fischer dac033e98c ha! a scratch-buffer! ;)
put the isdigit hack into it to help landley out..
2006-05-31 15:36:20 +00:00
Bernhard Reutner-Fischer f9437aaf5b - make getopt_ulflags aware of CONFIG_GETOPT_LONG 2006-05-31 14:12:51 +00:00
Bernhard Reutner-Fischer 8d3a6f7aaf - add CONFIG_FEATURE_WGET_LONG_OPTIONS 2006-05-31 14:11:38 +00:00
Bernhard Reutner-Fischer f3ac9ebc8e - convert xcalloc(1,x) to xzalloc 2006-05-31 13:31:16 +00:00
Bernhard Reutner-Fischer 595159f38c - shrink klogd a bit
text    data     bss     dec     hex filename
    569       0       0     569     239 sysklogd/klogd.o.orig
    537       0       0     537     219 sysklogd/klogd.o
2006-05-31 12:22:13 +00:00
Bernhard Reutner-Fischer c418d482ba - s/defined(__uClinux__)/BB_NOMMU/
This needs a second pass to:
+ add bb_daemon(unsigned char no_chdir, unsigned char no_close, const char*flag)
+ eventually globally export argc and argv, so we don't need to pass it to
  bb_daemon().
2006-05-31 10:19:51 +00:00
Bernhard Reutner-Fischer 507cd755a4 - conditionally define BB_NOMMU 2006-05-31 10:04:03 +00:00
Rob Landley 3252b625b7 Since we have less than 100k of usage.h data anyway, using bzip -9 is silly.
That says use 900k chunks when compressing, which needs about 4 megs of data
structures to undo the Burrows-Wheeler transform.  Switching it down to
bzip -1 (100k chunks) should have no impact on the compression (since it
still all fits in one chunk) but should reduce runtime decompression memory
requirements to something like 500k.  Still larger than gunzip, but not
egregiously so.
2006-05-30 19:19:45 +00:00
Rob Landley b2d42fa6d1 Test to see if I can rename a file without blanking its history... 2006-05-30 18:49:05 +00:00
Rob Landley 4b146e65ad Note about BB_NOMMU. 2006-05-30 18:31:37 +00:00
Bernhard Reutner-Fischer 7ae1553980 - consolidate "Sending SIG%s to all processes"; untested..
text    data     bss     dec     hex filename
   5379      32       8    5419    152b init/init.o.oorig
   5358      32       8    5398    1516 init/init.o
2006-05-30 18:17:21 +00:00
Bernhard Reutner-Fischer a8622e049d - this could use a brother which deals with glibc based systems.. 2006-05-30 15:49:10 +00:00
Bernhard Reutner-Fischer c58dbf28e0 - remove useless variable "status" from init_main.
http://www.opengroup.org/onlinepubs/009695399/functions/waitpid.html suggests
that we need not specify a status if we don't want, and we don't.
"If wait() or waitpid() return because the status of a child process is available, these functions shall return a value equal to the process ID of the child process. In this case, if the value of the argument stat_loc is not a null pointer, information shall be stored in the location pointed to by stat_loc.  "
   text    data     bss     dec     hex filename
   5391      32       8    5431    1537 init/init.o.06
   5379      32       8    5419    152b init/init.o
2006-05-30 12:16:54 +00:00
Bernhard Reutner-Fischer 3ab3080bc2 - use config_buffer for message()
- add second argument to waitfor(*action,pid); if action==NULL then use pid tor
  wait for. If an action was given, we wait for the action to finish just as
  before. In run() remove second and third occurance of the same functionality
  the waitfor() call now provides.
  Adjust the former only caller of waitfor accordingly.

PS: Not using waitfor but creating a second function used a few bytes more than
simply extending and reusing waitfor.
   text    data     bss     dec     hex filename
   5426      32       8    5466    155a init/init.o.orig
   5391      32       8    5431    1537 init/init.o
2006-05-30 12:10:29 +00:00
Rob Landley 752f0a6001 Put parentheses around some of the SWAP() macros, as pointed out by Peter
Kjellerstedt.
2006-05-30 06:28:03 +00:00
Rob Landley f14f7fc5ca Teach bloatometer about .rodata, and tweak the display into something that
has a better chance of getting merged.
2006-05-29 20:56:27 +00:00
Bernhard Reutner-Fischer 077368194c - cleanup conftest temporary files. 2006-05-29 20:01:52 +00:00
Bernhard Reutner-Fischer 35e1a077d6 - DEBUG_INIT -> config CONFIG_DEBUG_INIT 2006-05-29 13:08:35 +00:00
Bernhard Reutner-Fischer 76bb97c995 - landley, remove this? 2006-05-29 13:01:37 +00:00
Bernhard Reutner-Fischer 49e60b9788 - set_term() doesn't need an argument. (Like r15220 this is just compile-tested)
text    data     bss     dec     hex filename
   5432      32       8    5472    1560 init/init.o.r15220
   5426      32       8    5466    155a init/init.o
2006-05-29 12:57:52 +00:00
Bernhard Reutner-Fischer 0da069d382 - move common code into new open_new_terminal() function;
text    data     bss     dec     hex filename
 864434   10244  645892 1520570  1733ba busybox_old
 864386   10244  645892 1520522  17338a busybox_unstripped

add/remove: 1/0 grow/shrink: 0/2 up/down: 92/-143 (-51)
function                                     old     new   delta
open_new_terminal                              -      92     +92
exec_signal                                  345     276     -69
run                                         1527    1453     -74
Again, 48 != 51 so let's trust the former..
2006-05-29 12:54:16 +00:00
Bernhard Reutner-Fischer bbc225e13d - just whitespace 2006-05-29 12:12:45 +00:00
Bernhard Reutner-Fischer d2c306e862 - ls: remove unused variable
- dpkg.c, diff: use xstat
   text    data     bss     dec     hex filename
 848823    9100  645216 1503139  16efa3 busybox_old
 848679    9100  645216 1502995  16ef13 busybox_unstripped
bloatcheck is completely useless as it sees -79 for this, which is bogus.
2006-05-29 12:10:23 +00:00
Rob Landley 1ec5b29054 More size shrinkage. 2006-05-29 07:42:02 +00:00
Rob Landley a6e131dab3 Size reductions, mostly switching things to use libbb functions. 2006-05-29 06:43:55 +00:00
Rob Landley bba7f08d27 Add SWAP_LE?? and SWAP_BE?? macros, and make things use them. Converts values
to/from little endian or big endian, which is a NOP if that's what the current
platform already is.
2006-05-29 05:51:12 +00:00
Rob Landley 9755197448 This is not C++. 2006-05-29 05:21:29 +00:00
Rob Landley 0582ee0826 A few new todo items from email with Bernhard. 2006-05-29 05:06:06 +00:00
Rob Landley 15d20a03d6 Remove _() and N_() from platform.h. #define them as NOP macros in the two
files still using them.  I didn't remove them from e2fsck.c to avoid stomping
pending cleanup patches from Garrett, and I didn't bother to remove them from
fdisk.c because that entire file needs to be rewritten from scratch.
2006-05-29 05:00:44 +00:00
Rob Landley 8394729ddf Remove _(). 2006-05-29 04:49:55 +00:00
Rob Landley 4e3aff3425 Remove _(). 2006-05-29 04:37:28 +00:00
Rob Landley 267a0ed9e6 I changed last10 to last25, and just bumped it up to 50 so I renamed it
"recent.html".  There's a symlink from each of the old names for the moment,
I'll zap those eventually...
2006-05-28 02:10:21 +00:00
Rob Landley 81dab2cf83 Fix hdparm to use PRIu64 instead of typecasting to long long (which is 128 bits
on 64 bit platforms), and move #include <inttypes.h> to libbb.h.
2006-05-28 01:56:08 +00:00
Rob Landley 0fbe7ddbdd Put the ending quote on the help entry... 2006-05-28 01:40:26 +00:00
Rob Landley c44bc986b7 Fix some warnings in allbareconfig. 2006-05-28 01:19:06 +00:00
Rob Landley 3f78561d63 My first bout of untangling udhcp. Make lots of gratuitous #defines go
away, substitutie BB_VER for an external VERSION, use busybox CONFIG symbols
rather than checking for them then defining others, etc.  Lots more cleanup
to do...
2006-05-28 01:06:36 +00:00
Rob Landley 8fba99f35e Move portability stuff to platform.h, and clean up adjtimex.c a bit while
I'm in the area.
2006-05-27 22:08:01 +00:00
Rob Landley 299a6b4d7b Consolidate #include <sys/time.h> so libbb.h does it. 2006-05-27 21:42:58 +00:00
Rob Landley d244bc1a57 Update FAQ to mention make baseline when talking about make bloatcheck. 2006-05-27 21:30:34 +00:00
Rob Landley d9872aa0d7 Consolidate the .PHONY targets and add "make baseline" for bloatcheck. 2006-05-27 21:24:16 +00:00
Bernhard Reutner-Fischer 95a040fac8 - use the defines CURRENT_TTY and VC_1; also shrink xargs a tiny bit:
add/remove: 0/0 grow/shrink: 2/6 up/down: 5/-37 (-32)
function                                     old     new   delta
static.add_interface                         271     274      +3
static.glob3                                  36      38      +2
static.renice_main                           409     408      -1
static.readcmd                              1083    1081      -2
static.changepath                            176     174      -2
static.parse_opts                             56      51      -5
static.rx_main                              1095    1088      -7
static.xargs_main                            759     739     -20
----------------------------------------------------------------
Result                                                :-)    -32
2006-05-27 09:36:43 +00:00
Rob Landley 8bb50782a5 Change llist_add_* to take the address of the list rather than returning the new
head, and change all the callers.
2006-05-26 23:44:51 +00:00
Rob Landley 5edc10275e Slight sanity fix: data is void *, not char *. And it's called data
almost everywhere, so be consistent.
2006-05-26 23:00:10 +00:00
Bernhard Reutner-Fischer d765ee5d0f - provide fallback defines for non-linux 2006-05-26 20:34:02 +00:00
Bernhard Reutner-Fischer b21d23bd46 - provide fallback defines for non-linux 2006-05-26 20:33:12 +00:00
Bernhard Reutner-Fischer 01d23ade57 - add central knob to turn off getopt_long everywhere. EXPERIMENTAL!
Adds "Enable getopt long" under "General options", default y.
  Send patches to fix getopt_ulflags and run_parts.c if you turn this off..
  See http://busybox.net/lists/busybox/2006-May/021828.html for a start to run-parts
2006-05-26 20:19:22 +00:00
Bernhard Reutner-Fischer d29337580e - use strtol instead of strtoll if the latter does not exist
- add and use wrapper for attribute
- add and use replacement for vasprintf if it is unavailable
2006-05-26 19:58:58 +00:00
Bernhard Reutner-Fischer 781e42d66c - introduce and use bb_path_wtmp_file for portability (saves 11 Bytes).
- fix last.c to also look at the double-underscore UT_ defines.
2006-05-26 14:41:40 +00:00
Bernhard Reutner-Fischer b180e5a766 - use portability wrapper define bb_setpgrp. 2006-05-26 14:24:56 +00:00
Bernhard Reutner-Fischer 08421e1d0c - work around bug in gcc-3.4.x on ARM 2006-05-26 14:05:48 +00:00
Bernhard Reutner-Fischer 8379053b11 - move llist to top of file so we can potentially use it in all prototypes easily 2006-05-26 13:54:07 +00:00
Bernhard Reutner-Fischer 76b82cfd6f - make find_mount_point conditional on df and eject; Fixes `make hosttools´ on
hosts where mntent.h does not exist.
2006-05-26 13:38:43 +00:00
Bernhard Reutner-Fischer 4ed1f1d99d - add workaround for tar being broken since it uses a non-portable constant. 2006-05-26 13:34:25 +00:00
Bernhard Reutner-Fischer 7fca7e3378 - use the SED given by the user
- use the portable `` instead of $(). There is no bbsh, so this is needed.
2006-05-26 13:28:39 +00:00
Bernhard Reutner-Fischer e28d1d6fdc - add target hosttools (see make help)
- rename check_gcc to check_cc and pass the CC to use as arg#1; peruse check_cc for HOSTCFLAGS
- add and use check_strip
- add checks for {,no-}whole-archive and {start,end}-group LD flags
2006-05-26 13:22:57 +00:00
Bernhard Reutner-Fischer 6d0dbeb550 - use ATTRIBUTE_ALWAYS_INLINE if requested
- use shorter boilerplate while at it
2006-05-26 13:13:11 +00:00
Bernhard Reutner-Fischer e00fc16aaa - move libc checks from busybox.h to platform.h
- add ATTRIBUTE_ALWAYS_INLINE, endian handling for DEC UNIX, some more
  compiler dependent defines to platform.h
- add conditional bb_setpgrp define to platform.h
- remove superfluous specifying args from "#define fdprintf dprintf"
2006-05-26 13:10:10 +00:00
Bernhard Reutner-Fischer 7fd9983c56 - patch from Tito to pretty print the overall delta 2006-05-26 10:29:40 +00:00
Mike Frysinger 314c739b07 Yann E. MORIN. writes:
hdparm has a uint64_t passed to printf with a %llu format (which is ok, because
it's the same size), but without first being casted(?) to unsigned long long int.
Which is kinda funny because it's done OK on a few lines above...
2006-05-26 02:05:19 +00:00
Mike Frysinger 4f93a63467 errno and h_errno values are not the same #876 by rfelker 2006-05-26 01:56:42 +00:00
Mike Frysinger fa6c4844b2 fix spelling mistakes 2006-05-26 01:48:17 +00:00
Mike Frysinger 9c03cb920a check for queueing dependancy dependancies typos 2006-05-26 01:41:04 +00:00
Mike Frysinger 3354487393 queuing is spelled correctly 2006-05-26 01:38:19 +00:00
Rob Landley 399d2b5c24 Rich Felker suggested removing dprintf() from watch, and one thing led to
another... This adds bb_xspawn() support, which does vfork/exec.  (I don't
know why using a static instead of a local adds ~40 bytes, but using
the local doesn't work...)
2006-05-25 23:02:40 +00:00
Rob Landley 69d863b6c6 And fix the error I just introduced. :) 2006-05-25 21:13:30 +00:00
Rob Landley 5a2997de72 Remove pointless #define. 2006-05-25 21:12:40 +00:00
Rob Landley ade7f95bd1 Patch from Tito:
Remove -v verbose -V version -q quiet flags
Remove parse_opt_v2();
Rename parse_opt_v3() to parse_xfermode()
Remove if_strcat()
Rearrange code in  dump_identity() to reduce size
Modify some strings so that they could be optimized by the compiler
Minor code clean up
Remove unneeded #define <shm.h>

#if BB_BIG_ENDIAN && !defined(__USE_XOPEN)
# define __USE_XOPEN
#endif    
Must be before #include <unistd.h> and #include "busybox.h"
(noticed by Bernhard Fischer <rep.nop@aon.at>)

Remove duplicate code in do_time()
2006-05-25 18:53:06 +00:00
Rob Landley 6cd2250953 Remove a pointless #define. 2006-05-25 18:31:11 +00:00
Bernhard Reutner-Fischer 89a22ea5d9 make the testsuite a little less brittle:
- 'function fn_name\n{' breaks on older FreeBSD default shells, so use the more
  widely supported 'fn_name () {'. This needs more fixing..
- test for integers ought to use the proper operators
- test for strings ought to use quoting of the strings to be fair to strange
  implementations of test(1)
- make sure not to ignore return-codes != 0 from commands; Some shells exit
  immediately on this (much like explicitely requesting set -e in e.g. bash)

TODO:
*) Some older shells do not allow a space after the test-condition in an "if"
statement. This doesn't work:
if [ $status -ne 0 ] ; then
as opposed to this:
if [ $status -ne 0 ]; then
or this
if [ $status -ne 0 ]
then

*) strict spacing between commands. In some shells you have to say:
foo ; bar ; baz
The affected shells barf on stuff like ommitting the space, so this doesn't
work:
foo; bar   ;baz

*) $() vs. ``
The former isn't really portable as opposed to the latter.

*) fix frong assumption that the testsuite is run from the source-dir.
This is a complete misconception and renders the testsuite completely useless.


That said, i note that IMO a test-harness ought to do it's best to work in
a wide variety of environments, everything else defeats it's purpose.
2006-05-25 13:24:02 +00:00
Rob Landley 027ea1aeac Two more issues pointed out by Bernhard. 2006-05-24 17:58:00 +00:00
Rob Landley 5fc467e758 Yann Morin spotted some leftover flotsam from halfway through the recent
llist.c interface change that accidentally got checked in.  My bad.
2006-05-24 17:45:47 +00:00
Rob Landley fa6b5e62c2 It takes _talent_ to implement a version of nohup that does everything except
the actual blocking of HUP.
2006-05-23 00:28:06 +00:00
Bernhard Reutner-Fischer a81cec9192 - set x bit 2006-05-21 22:06:59 +00:00
Rob Landley 5cd1ccd995 Convert to a global struct, the way sed was. Now I have two, I can work out
the infrastructure to merge global structs into a union...
2006-05-21 18:33:27 +00:00
Rob Landley 9ffd42317b Minor cleanups: Convert a few calloc() calls to xzalloc, remove unnecessary
memset, collate variable declarations...
2006-05-21 18:30:35 +00:00
Rob Landley c020f5f518 New version of nohup that's much smaller, less paranoid, consistent,
vaguely portable, and licensed GPLv2 "or later".
2006-05-21 18:28:13 +00:00
Bernhard Reutner-Fischer 4148afe049 - fix wrong path to scripts/usage; It is in the builddir and not in the srcdir.
- flag .depend as .NOTPARALLEL to workaround bug in make-3.80 and make-3.81
Some more details on the second workaround (i.e. kludge):
make-3.80 silently fails, while make-3.81 is at least self-conscious enough to
admit:
include/usage_compressed.h: .config scripts/usage
#  Implicit rule search has not been done.
#  File does not exist.
#  File has not been updated.
#  Dependencies commands running (THIS IS A BUG).
#  commands to execute (from `/home/cow/src/bb2/Makefile', line 430):
        $(Q)$(SHELL) $(top_srcdir)/scripts/usage_compressed "$(top_builddir)/scripts" > $@

I'm giving up on trying to run the rest of the prerequisites of .depend in
parallel and just (try to) indicate that the prerequisites of .depend are
not to be run in parallel.

While this makes `make distclean defconfig;make -j´ work for me, it is not a
real -- longterm -- solution; FIXME
2006-05-21 15:05:49 +00:00
Bernhard Reutner-Fischer a1e130f122 - check for existing usage binary, so it get's more obvious that the toplevel
Makefile uses the wrong path to the binary (it's in top_builddir and not in top_srcdir)
2006-05-21 10:45:01 +00:00
Bernhard Reutner-Fischer 3c8c0690fd - there is no _usage.h anymore, so don't rm it in distclean. 2006-05-21 10:04:46 +00:00
Bernhard Reutner-Fischer 30ead9a9b9 - do not create usage_compressed.h if CONFIG_FEATURE_COMPRESS_USAGE is not set 2006-05-21 09:02:12 +00:00
Bernhard Reutner-Fischer 1a5eb46820 - there is no "sh". Use $(SHELL) 2006-05-21 08:25:45 +00:00
Bernhard Reutner-Fischer ef21629a6b - silence warning about no return in function returning non-void
- put CONFIG_DEBUG_CROND_OPTION into config
no changes in size when debugging is disabled.
2006-05-20 14:14:05 +00:00
Rob Landley 9b5a99ad21 Patch from Robert P. Day to remove #ifdefed out SLIP support code that we
have no CONFIG option to enable, and which existing SLIP users don't seem
to miss.
2006-05-19 22:54:42 +00:00
Rob Landley 206f75784b Remove unused function parameter, from Garrett. 2006-05-19 22:42:23 +00:00
Rob Landley 19d42df206 Add diffutils and dhcp to list of packages we provide replacements for. 2006-05-19 22:14:19 +00:00
Bernhard Reutner-Fischer 35017fb4fc - backout erroneously checked in snippet.. 2006-05-19 20:48:22 +00:00
Rob Landley df4cdaf341 First quick stab at organizing TODO under whose TODO item it is. 2006-05-19 20:47:55 +00:00
Rob Landley 80b8ff07ca A pending item in my tree I might as well check in: I plan to migrate calloc()
and bb_calloc() calls to bb_xzalloc() which allocates prezeroed memory but
only takes one argument (the size).
2006-05-19 20:36:49 +00:00
Bernhard Reutner-Fischer b1629b1b2a - remove emacs layout block as suggested by Robert P.J. Day
- use shorter boilerplate while at it
2006-05-19 19:29:19 +00:00
Bernhard Reutner-Fischer d8e87a09d1 - forgot to make busybox_unstripped depend on the applets in IMA mode. 2006-05-19 18:37:34 +00:00
Bernhard Reutner-Fischer c7801c4634 - use shorter boilerplate. 2006-05-19 18:35:03 +00:00
Bernhard Reutner-Fischer 351c832d75 - redirect stdout of scripts/config/conf to /nil for
allyesconfig, allnoconfig, defconfig, allbareconfig
- fix invalid call to "make"; use $(MAKE) instead.
2006-05-19 18:33:34 +00:00
Bernhard Reutner-Fischer a254065e63 - remove SIGIOT as suggested by landley. 2006-05-19 17:54:05 +00:00
Rob Landley 4ae2f511cf Patch from tito to replace shared memory usage with mlock(), slightly tweaked
by me.
2006-05-19 17:24:26 +00:00
Mike Frysinger cf89c37d08 fix indenting in help output for ifconfig 2006-05-19 16:14:31 +00:00
Bernhard Reutner-Fischer 14b1d2930a - typo s/allbaseconfig/allbareconfig/
I thought Robert Day pointed this out, but i cannot find the mail in the archives..
2006-05-19 14:02:51 +00:00
Bernhard Reutner-Fischer 0a8812bdc5 - replace _PATH_DEVNULL with bb_dev_null 2006-05-19 13:12:21 +00:00
Bernhard Reutner-Fischer 14aa06f29c - do not use non-standard u_int.
- do not use _PATH_DEVNULL gnuism but bb_dev_null.
Thanks to Rich Felker.
2006-05-19 13:02:27 +00:00
Bernhard Reutner-Fischer e2922e42a0 - make it C89 compatible; Declarations in the middle of a function is of course
fine in C99, but it really serves no purpose other than breaking compilation
  on C89 compilers.
  Thanks to Rich Felker for pointing this out.
2006-05-19 12:48:56 +00:00
Bernhard Reutner-Fischer 38583fd6f2 - use uint32_t instead of __u32
Thanks to Rich Felker for pointing this out.
2006-05-19 12:44:16 +00:00
Bernhard Reutner-Fischer 4009ed91f7 - Rich Felker writes:
SIGIOT is not defined in any standard i can find and it seems to be
useless (alias for SIGABRT) on linux. i put it in #ifdef but it's
probably best just to remove it and cut down the size a bit.
2006-05-19 12:41:13 +00:00
Bernhard Reutner-Fischer d9ed35c8b9 - remove superfluous legacy includes.
This applet should be converted to use llist; __NEED_DLLIST
2006-05-19 12:38:30 +00:00
Bernhard Reutner-Fischer a2a647dfc1 - include strings.h
Thanks to Rich Felker for pointing this out.
2006-05-19 12:30:00 +00:00
Bernhard Reutner-Fischer a85a63f6ee - fix invalid mode 2006-05-19 12:22:11 +00:00
Bernhard Reutner-Fischer e2e56c7c41 - single KERNEL_VERSION(a,b,c) macro in platform.h
- rename get_kernel_revision() to get_linux_version_code
from Robert P. J. Day
2006-05-19 11:54:02 +00:00
Bernhard Reutner-Fischer e3c150bc67 - cleanup memory if opening aliases failed and cleanup was requested. 2006-05-19 11:24:28 +00:00
Rob Landley 42c4259f68 Fluff out info on morris accounts. 2006-05-18 21:53:51 +00:00
Rob Landley 3afb070e6d Avoid a memory leak pointed out by Lucas C. Villa Real. 2006-05-18 20:41:43 +00:00
Rob Landley d2ccc2ba26 Typo fix. 2006-05-17 21:04:53 +00:00
Rob Landley 7723019c6b Patch from Bernhard Fischer to remove some useless bits. 2006-05-17 20:24:53 +00:00
Rob Landley c27c04c16e Announce 1.1.3. 2006-05-17 19:59:24 +00:00
Rob Landley 81369a8b2f Typo that hits big endian systems. 2006-05-17 19:47:58 +00:00
Rob Landley 5371a953ca The gnu extension to have realpath() malloc its buffer when handed a NULL
isn't implemented in uClibc, so we can't use it.
2006-05-17 04:09:14 +00:00
Rob Landley 2686d3bc38 Rob Sullivan cleaned up the longstanding patch from Hideki IWAMOTO to add
ibs and obs support to dd, and made it configurable.  I cleaned it up a bit
further and moved conv= into the same config option.
2006-05-16 16:52:12 +00:00
Rob Landley adde79883f Largeish cleanup patch from Tito, mostly if statement therapy. 2006-05-16 15:32:30 +00:00
Rob Landley 34b5319d86 Make md5 calculation always go through an the buffer so that A) we don't
handle packets out of sequence if some data goes through the buffer and
some doesn't, B) it works on systems that can't handle aligned access,
C) we just have one code path to worry about.

While we're at it, sizeof() and RESERVE_CONFIG_BUFFER() really don't combine
well, which is why md5sum has been reading and processing data 4 bytes at a
time.  I suspect that the existence of CONFIG_MD5_SIZE_VS_SPEED to do loop
unrolling and such in the algorithm was an attempt to work around that bug.
2006-05-16 02:38:26 +00:00
Rob Landley d272dc7cb3 Remove some out of date bits. 2006-05-15 21:02:36 +00:00
Rob Landley 282a26b8ba The one line fix to Bernhard Fischer's "profoundly". 2006-05-15 18:38:11 +00:00
Bernhard Reutner-Fischer 2f38f27b42 - patch from Robert P. J. Day to use filter instead of findstring. 2006-05-15 10:04:50 +00:00
Mike Frysinger d9b6b844e5 pull Rules.mak from top_srcdir as pointed out by Robert P. J. Day on the mailing list 2006-05-13 02:33:41 +00:00
Mike Frysinger 39440e520c pull Rules.mak from top_srcdir as pointed out by Robert P. J. Day on the mailing list 2006-05-13 02:33:09 +00:00
Mike Frysinger 2f4d91da75 fix whitespace 2006-05-13 02:27:52 +00:00
Rob Landley 47b1838957 Patch from Lucas C. Villa Real adding "source" as a synonym for the "." command. 2006-05-12 20:44:16 +00:00
Paul Fox d7384296f6 implement -print0 for find 2006-05-12 14:47:20 +00:00
Rob Landley f7897ec47b Autodetect parts of a multipart file, from Robert P. Day's suggestion. 2006-05-12 01:42:33 +00:00
Rob Landley 525d74badb Busybox is licensed under GPLv2 or later. Shipping another license with the
project would confuse the issue.

Some of these files are available elsewhere under other license terms,
but that's not directly relevant to busybox.
2006-05-11 21:19:22 +00:00
Rob Landley cc848ddbf8 Bug fix from Vladimir Oleynik, and suggestion I add my copyright notice
to the file.
2006-05-11 18:25:24 +00:00
Rob Landley 0690d1591f Tabs weren't lining up in the help text. 2006-05-11 17:33:10 +00:00
Rob Landley ac4c92da3b More about configuring busybox. 2006-05-11 17:21:13 +00:00
Rob Landley 9b70093714 Rename the devfs device names option so it doesn't bite people so often. 2006-05-11 16:39:52 +00:00
Rob Landley 2ad1e7ce44 Patch from Vladamir Oleynik, reducing memory consumption. 2006-05-11 15:23:23 +00:00
Rob Landley 983d751bc0 Remove reference to programming.html, update description of FAQ. 2006-05-11 15:02:32 +00:00
Rob Landley b73d2bf4bf Reorganize FAQ, update a few entries, and consolidate with programming.html. 2006-05-11 15:00:32 +00:00
Mike Frysinger 8d2cb8be3b back out default implicit %.o rule for now 2006-05-11 05:33:31 +00:00
Mike Frysinger d148a94a2a move the dir related rules to the end so the E2FSPROGS_AR rule is the default 2006-05-11 04:39:09 +00:00
Mike Frysinger be7c539b7a dont use tabs people 2006-05-11 04:37:25 +00:00
Mike Frysinger e135a5d746 fix no previous prototype warning 2006-05-11 02:36:51 +00:00
Mike Frysinger b5547fb0b3 fix no previous prototype warning 2006-05-11 02:35:55 +00:00
Mike Frysinger e92923862e typecast bbig to kill format warnings 2006-05-11 02:31:45 +00:00
Mike Frysinger 49f6afc0a0 rename 2006-05-11 02:10:13 +00:00
Mike Frysinger e3412d8331 remove files not related to busybox 2006-05-11 02:09:39 +00:00
Mike Frysinger 6143c0719b add implicit rule for %.a to help debugging in subdirs 2006-05-10 18:12:16 +00:00
Rob Landley 094b9f7e1d Shut up the warning "implicit declaration of strlen". 2006-05-10 17:41:21 +00:00
Mike Frysinger 06b00e8ba7 accept() takes a socklen_t, not an int 2006-05-10 17:18:11 +00:00
Mike Frysinger d2c8fd6360 fix whitespace in comment example 2006-05-10 17:17:09 +00:00
Mike Frysinger 772a3467ba some more useful debug info from Jason Holden 2006-05-10 17:14:32 +00:00
Mike Frysinger 673c9443ba add a default .o rule for easier debug 2006-05-10 17:12:12 +00:00
Bernhard Reutner-Fischer 72c4d64d20 - add helptext for --retries 2006-05-10 16:11:02 +00:00
Mike Frysinger 62ec21d0cf touchup whitespace/english a bit more 2006-05-10 15:59:07 +00:00
Mike Frysinger 731f81cbed whitespace between if and ( 2006-05-10 15:23:12 +00:00
Bernhard Reutner-Fischer eba32f429b - typo in error-message: s/algotithm/algorithm
- whitespace cleanup
2006-05-10 07:59:32 +00:00
Mike Frysinger 59e46117b1 clean more files 2006-05-10 05:19:27 +00:00
Rob Landley f893250a3b Replace isnan() and isinf() with inline tests so uClibc doesn't want us to
link sort against libm.  This adds 22 bytes for glibc but is a win for uClibc,
and since glibc is bigger than all of busybox it seems kind of silly to worry
about it.
2006-05-09 23:14:39 +00:00
Rob Landley c503df5bdd Split CONFIG_DEBUG from CONFIG_DEBUG_PESSIMIZE, and consolidate some Rules.mak
stuff along the way.
2006-05-09 22:08:56 +00:00
Bernhard Reutner-Fischer 2431830018 - fix bug in make help introduced by landley in r15022:
Development:
  bloatcheck             - show size difference between busybox_unstripped
  /bin/sh: -c: line 0: unexpected EOF while looking for matching `''
  /bin/sh: -c: line 1: syntax error: unexpected end of file
  make[1]: *** [help] Error 2
  make: *** [help] Error 2
2006-05-09 11:29:56 +00:00
Rob Landley e3f5a3fd82 Convert sed's static variables to a single global structure. 2006-05-09 03:53:55 +00:00
Rob Landley 0b65628395 Move sed over to the generic llist_t for append. Saves about 90 bytes. 2006-05-08 22:17:23 +00:00
Rob Landley 92d8b35594 Make bloatcheck work when building out of tree. 2006-05-08 20:48:12 +00:00
Bernhard Reutner-Fischer 45d545890f - fix build 2006-05-08 20:20:32 +00:00
Rob Landley a6b5b60942 Fiddling with llist to make memory management easier. Specifically, the
option to delete the contents of the list when we delete the list is a
good thing.
2006-05-08 19:03:07 +00:00
Rob Landley 712ba85b30 Tweak suggested by Matt Mackall when I submitted the bloat-o-meter changes
back to linux-kernel...
2006-05-08 18:30:33 +00:00
Rob Landley d61b8d8f9b The changes svn 14960 made to Rules.mak broke building out of tree
(with O=directory), and reverting them fixes building out of tree.  I'd be
happy to fix them up instead of reverting them if I had the foggiest idea
what they were trying to do, but I don't, and this at least gets building
out of tree working again...
2006-05-08 18:18:02 +00:00
Rob Landley 19802563ed The if() is cheaper than the extra function parameter. According to make
bloatcheck, this saves 112 bytes on x86...
2006-05-08 15:35:46 +00:00
Rob Landley 0ea0aefcb5 Remove a link that leaked in from the pending llist_t changes. 2006-05-08 15:08:25 +00:00
Mike Frysinger 1b4e1dae71 re-enable udhcp in a few more places 2006-05-08 03:24:36 +00:00
Mike Frysinger 7031f62d9b add back in udhcp support 2006-05-08 03:20:50 +00:00
Rob Landley 15fe2e11d7 Shrink the code about 50 bytes, allocate less run-time memory, and add a
comment that null terminating the string we sscanf() shouldn't be required
since the kernel adds \n to the end of it and sscanf will stop there.
2006-05-08 02:53:23 +00:00
Rob Landley 17507fa4c5 More busting on legacy mtab support in the help text. 2006-05-08 02:22:24 +00:00
Rob Landley 20deab0537 Cleanup patch from tito. 2006-05-07 23:34:15 +00:00
Rob Landley 63e4c637cb The udhcp was deleted from busybox in 14634. Bolting an external project to
the side of the tree doesn't _COUNT_, and I will not ship it.

Udhcp was deleted shortly after I posted my philosophy for what should and
shouldn't go into busybox:

http://www.busybox.net/lists/busybox/2006-March/019484.html

I complained about the change t the time.  I've complained repeatedly since.
But nobody felt like fixing it.  External dependencies are something to be
minimized.  I don't care about the ability for packages to build outside
busybox: something is either part of busybox, or it isn't.  If I convert any
part of the external udhcp repository to use libbb, I've broken the external
package.  Any random cleanups that touch that directory suddenly have to worry
about external dependencies that are NOT OUR PROBLEM.  Therefore, that
directory is not and cannot be part of busybox.  Wishful thinking isn't going
to change that.  I will not ship something I can't maintain.

I'll try to get a new dhcp client and server in before the ship window closes,
but I have a half-dozen other projects pending.  I'm sorry this happened, but
I'm not the one who removed it, and I'm not the one who ignored the project
maintainer's repeated complaints about the situation for the next month and a
half.
2006-05-07 23:19:20 +00:00
Rob Landley baa89b398d Patch to fix bug 868, and some related cleanup while I was in the area.
A tab is now taken as the end of filename if it's there, but if it isn't
(because the timestamp isn't there) we continue with the existing untruncated
line as the filename.
2006-05-07 21:10:06 +00:00
Rob Landley a336e7cc25 Script to easily get an assembly dump of a single function. 2006-05-07 20:58:55 +00:00
Rob Landley a389651115 Remove bb_strlen() in favor of -fno-builtin-strlen. Saves as many bytes
as the old optimization did (actually does slightly better under gcc 4.0), and
simplifies the code.
2006-05-07 20:20:34 +00:00
Rob Landley f8a8084267 Add "make bloatcheck" to run Matt Mackall's bloat-o-meter. Copy an old
busybox_unstripped to busybox_old, build a new version, and "make bloatcheck"
to see a detailed breakdown of the size difference.
2006-05-07 19:26:53 +00:00
Rob Landley 9fb272a222 Dennis Vlasenko pointed out that run_applet_by_name sets bb_applet_name already. 2006-05-07 01:44:23 +00:00
Mike Frysinger 89ede3f586 fix udhcp again 2006-05-06 05:30:46 +00:00
Mike Frysinger 96087332e7 make sure script is executable 2006-05-06 05:27:19 +00:00
Rob Landley 42bd987e22 Add an "optional" line for FEATURE_READLINK_FOLLOW. 2006-05-05 22:22:30 +00:00
Rob Landley c008c7440d New test from Natanael Copa. 2006-05-05 21:07:41 +00:00
Mike Frysinger 1781188a9d didnt mean to commit debug enable 2006-05-05 20:33:07 +00:00
Mike Frysinger 02d8fa48ad use %p when printing pointers, not %x 2006-05-05 20:32:31 +00:00
Mike Frysinger 4e512f1062 fix Bug 659 as reported by Robin Getz 2006-05-05 18:38:07 +00:00
Rob Landley 3958e0a151 Busybox's udhcp was deleted a while ago. Bolting an external project onto the
tree doesn't change that.
2006-05-05 18:20:42 +00:00
Rob Landley d8f6601502 Another patch from Garrett: remove bad block bitmap checking code. Everything
produced in the list ten years has some variant of internal error correction
(disks, cdrom, flash), so if it has user-visible bad blocks on it the
hardware has exhausted its remapping reserve and is dying, and you need to get
your data off pronto.  (The one exception I can think of is floppies, and I
don't care.)
2006-05-05 17:29:09 +00:00
Rob Landley 2c39eee805 Migrate endianness macros. 2006-05-05 16:54:40 +00:00
Rob Landley 39cf645ce0 Patch from Dennis Vlasenko resetting values that get reused. 2006-05-05 16:52:28 +00:00
Rob Landley 2381f702c9 Patch from Dennis Vlasenko simplifying the APPLET macros. 2006-05-05 15:55:06 +00:00
Rob Landley 49159c7f94 Patch from Jason Schoon to make mount -a not abort on the first failure. 2006-05-05 15:01:38 +00:00
Bernhard Reutner-Fischer 0e413e53e9 - ignore missing helptext for options which are not selectable. 2006-05-05 14:05:21 +00:00
Bernhard Reutner-Fischer 4f7953cc3c - add helptext for CONFIG_UNIX2DOS 2006-05-05 11:55:53 +00:00
Rob Landley 552b56dfd1 Not quite compiler independent, but we've never tried to be gcc independent
anyway.  This is at least less ugly than what was there before, and fixes
building all sources at once.
2006-05-04 21:22:27 +00:00
Rob Landley 3b89039c25 It was sitting there, in the patches directory, for years. It was delete it
or apply it.  It's small, simple, evil, part of SUSv3, and we can switch it
off.
2006-05-04 20:56:43 +00:00
Rob Landley 846fe0c045 There aren't any bzip2 based RPMs. If people want to experiment with new
packaging formats, there's ipkg and such...
2006-05-04 19:57:34 +00:00
Rob Landley b1c3fbc677 CONFIG->ENABLE migration. 2006-05-04 19:52:28 +00:00
Rob Landley 0c43046fde Fix allbareconfig. 2006-05-04 19:51:22 +00:00
Bernhard Reutner-Fischer 3916b2a560 - add script to check for missing help entries of config options
Currently we have these errors:

./modutils/Config.in: No helptext for 'CONFIG_FEATURE_QUERY_MODULE_INTERFACE'
./networking/Config.in: No helptext for 'CONFIG_IPADDR'
./networking/Config.in: No helptext for 'CONFIG_IPLINK'
./networking/Config.in: No helptext for 'CONFIG_IPROUTE'
./networking/Config.in: No helptext for 'CONFIG_IPTUNNEL'
./coreutils/Config.in: No helptext for 'CONFIG_UNIX2DOS'
2006-05-04 11:38:33 +00:00
Rob Landley 7c94bed234 Big dead code elimination pass from Garrett. 2006-05-03 21:58:45 +00:00
Rob Landley db2ab89b7c Build break fix from Bernhard fischer, fixing fallout from svn 14974. (My bad.) 2006-05-03 21:39:28 +00:00
Rob Landley f76cd964ec Whitespace and documentation cleanup from Dennis Vlasenko. 2006-05-03 21:23:15 +00:00
Rob Landley 425e7584a4 Patch from Rich Felker to make ls use libc's qsort. 2006-05-03 20:22:03 +00:00
Rob Landley 1801e9cde7 Rich Felker writes:
mistake in a macro caused statement before declaration.
2006-05-03 20:19:14 +00:00
Rob Landley 035ef5659e Patch from Garrett Kajmowicz to move a lot of #defines into the
header file.
2006-05-03 20:05:18 +00:00
Rob Landley 2584e9b39f Remove HDIO_GETGEO_BIG which is dead (removed from 2.6) and was pointless back
in 2.4 (it fetched the same hd_geometry struct only with uint cylinders instead
of ushort cylinders: nothing that big has ever accurately reported gemoetry,
it's all LBA.

Also stop declaring the hd_geometry struct static: it's two chars, a short, and
a long for a grand total of 8 bytes.  That can go on the stack.
2006-05-03 20:00:00 +00:00
Rob Landley 0f0b645f73 Use ATTRIBUTE_NORETURN as suggested by tito, plus a few in-passing cleanups. 2006-05-03 18:28:06 +00:00
Rob Landley c5598177bc Patch from Jason Schoon to add optional SIGUSR1 support to dd. 2006-05-02 22:44:04 +00:00
Rob Landley 67d5b8b5b1 Minor tweaks: remove traces of old $COMMAND environment variable. 2006-05-02 21:39:04 +00:00
Rob Landley 2631486f1b Patch from Shaun Jackman:
ls has an ugly bug. ls uses an array of pointers, the elements of
which are all in a linked list. To free the elements, instead of
freeing all the elements in the array, array[0..nelements], it frees
by iterating the linked list starting at array[0], which it assumes is
the head of the list. Unfortunately, ls also sorts the array! So,
array[0] is no longer the head, but somewhere in the middle of the
linked list. This patch fixes this bug, and also adds an
ENABLE_FEATURE_CLEAN_UP stanza.
2006-05-02 19:46:52 +00:00
Rob Landley 6389ff1115 Patch from tito removing obsolete code. 2006-05-01 19:28:53 +00:00
Rob Landley c488f87953 Notes on portability, and on when #include <linux/blah> is appropriate. 2006-05-01 05:26:01 +00:00
Rob Landley 73f54702bc Fixup a build break if ENABLE_SHOW_USAGE switched off. (Fallout from the
compressed usage messages patch).
2006-05-01 00:53:40 +00:00
Rob Landley 3ea66a805d Patches from Denis Vlasenko to rework "current_name" handling and remove
print_current_name().
2006-04-29 20:08:40 +00:00
Rob Landley 8a6254994c Patch from Denis Vlasenko:
* Do not initialize globals to 0, it is done automatically
* unsigned short -> uint16_t,  unsigned int -> uint32_t
  where appropriate (did it ever work on Alphas?)
* triple sync() is silly - removed
* check_zone_nr uses check_zone_nr2 now
* remove trailing periods from messages, uppercase first letter
2006-04-29 20:05:17 +00:00
Rob Landley 9950cab8e0 Patch from Denis Vlasenko:
ix bug (inode_map and zone_map are char* pointers,
sizeof() on them gives 4 or 8)
2006-04-29 20:03:54 +00:00
Rob Landley 5bc3f05a23 Remove some unused code pointed out by Tito, plus a slightly more graceful
way of handling endianness.
2006-04-29 19:11:24 +00:00
Rob Landley a3e4f38f7b Style fixes from Denis Vlasenko. 2006-04-29 16:06:31 +00:00
Rob Landley 5f8b5ecda2 Another patch from Denis Vlasenko:
Make hdparm smaller:
* Make bb_ioctl return the status
* Replace ioctl with bb_ioctl in a few places
* Add bb_ioctl_alt, use where appropriate (four places)
* unsigned char args1[4+512] = {WIN_IDENTIFY,0,0,1,};
  ate 0.5k of rodata, fix that
2006-04-29 16:03:40 +00:00
Rob Landley e5b281f89e From Dennis Vlasenko, Make hdparm smaller:
* Use combined no_scsi_no_xt()
 * Have common unsigned char args[4] = {WIN_SETFEATURES,0,0,0};
2006-04-29 15:49:18 +00:00
Rob Landley 2e2d752d49 Cleanup to hdparm by tito. 2006-04-29 15:23:33 +00:00
Mike Frysinger 2514042661 termios.h is already included so dont include sys/termios.h as well 2006-04-29 04:45:22 +00:00
Mike Frysinger 02fe81033f detect more obsolete headers 2006-04-29 04:44:08 +00:00
Mike Frysinger 59c6baedf7 just include fcntl.h not sys/fcntl.h 2006-04-29 04:43:50 +00:00
Mike Frysinger 706f8f6de5 just include fcntl.h not sys/fcntl.h 2006-04-29 04:43:31 +00:00
Mike Frysinger f054be12de Rob Sullivan writes: rewrite the regex handling to improve stability 2006-04-29 04:21:10 +00:00
Mike Frysinger 12ef09b818 compile.h is incorrect; create a new do_link.h and use that for bb_mkdep and usage 2006-04-29 04:19:10 +00:00
Mike Frysinger fe6bb3853c use pretty output for scripts/bb_mkdep and scripts/usage 2006-04-29 04:12:36 +00:00
Bernhard Reutner-Fischer 3737c03630 - rerun gcse pass after reload, enable whole-program iff we are not building
the lib (due to bug in gcc; see comment.)
I would have run the testsuite to check if everything is still behaving, but
unfortunately i cannot run the testsuite anymore: it just sits there and does
nothing even with a pristine checkout and an old gcc.
srcdir=/tmp/busybox/testsuite /tmp/busybox/testsuite/runtest 
PASS: Applet order
FAIL: Common typos
PASS: Obsolete function usage
PASS: Obsolete function usage
<spins, ^C>
make[1]: *** [check] Interrupt
make: *** [check] Interrupt

I've just corrected that wrong double-printing.

Anyway. with gcc-4.1-HEAD from earlier today, we now have for
defconfig+ COMPILE_AT_ONCE:


880 -rwxr-xr-x  1 433 433 893476 Apr 28 21:41 busybox.oorig-4.0
860 -rwxr-xr-x  1 433 433 874560 Apr 28 21:36 busybox.oorig
844 -rwxr-xr-x  1 433 433 858752 Apr 28 21:49 busybox

   text    data     bss     dec     hex filename
 879920   11568 1039148 1930636  1d758c busybox.oorig-4.0
 862802   10192 1038796 1911790  1d2bee busybox.oorig
 848066    9100 1037536 1894702  1ce92e busybox

values for 4.0.2 just added for reference..
2006-04-28 20:02:29 +00:00
Bernhard Reutner-Fischer 15545b1db9 - print "Obsolet headers" instead of "Obsolete function usage" when checking
for obsolet includes.
2006-04-28 19:53:48 +00:00
Rob Landley a2d9a1752c More usage.h cleanups, with collateral changes to httpd. Specifically,
most of our CONFIG entries switch stuff on instead of off when enabled, so fix
the gratuitously reversed INETD thing.
2006-04-28 19:38:04 +00:00
Rob Landley 0e6a3e14e4 Patch from tito to update output of hdparm. 2006-04-28 01:33:30 +00:00
Rob Landley 7e21d5f6b1 Patch from Dennis Vlasenko to add the option to compress help text. 2006-04-27 23:34:46 +00:00
Rob Landley d5b9428bb6 Re-wordwrap the new tests, and fix seq.c to pass them. 2006-04-27 22:36:32 +00:00
Bernhard Reutner-Fischer a345dc855f - add two regression tests for seq.
"seq two arguments equal, arbitrary negative step" fails but should pass..
2006-04-27 13:46:56 +00:00
Bernhard Reutner-Fischer fc477f4bc6 - add note about crond 2006-04-26 19:40:15 +00:00
Bernhard Reutner-Fischer 06a81d368e - patch from Denis Vlasenko to make sizes PHONY and to add objsizes which prints
the sizes of the individual object files.
2006-04-26 10:10:25 +00:00
Rob Landley 5fe8d5b9c5 Convert a chunk of usage.h to USE_ and SKIP_ (more to do there), and fix a
DEFALT typo in du while I was there.
2006-04-25 22:40:53 +00:00
Rob Landley 7818a422bc Portability tweak from Shaun Jackman, don't include asm/page.h directly. 2006-04-25 18:42:23 +00:00
Rob Landley 997650b972 From Denis Vlasenko:
* CPU% = process[i].ticks/sum(process[i].ticks) * busy_cpu_ticks/total_cpu_ticks
* got rid of empty line under "Load average" line
  and used last line - +2 visible processes
* do not do float conversion of loadavg, just read it as string from /proc
* fix display on small screens
* dropped unused .stime, .utime fields
* a few variables were renamed
* style fixes
2006-04-24 23:13:46 +00:00
Bernhard Reutner-Fischer 56fbd21fa7 - return ret so we return something meaningful. 2006-04-24 17:41:29 +00:00
Mike Frysinger 70cbb6e026 Jason Schoon writes: Attached is a patch to display the usage message if fuser is called with no arguments, rather than doing no work and failing silently. 2006-04-21 22:04:05 +00:00
Mike Frysinger 10f55b1dae Jason Schoon writes: This makes the case where LFS is not defined, but fdisk is configured with large disk support use the pretty build rules. 2006-04-21 21:59:22 +00:00
Mike Frysinger 586ea61284 2006-04-20 Shaun Jackman <sjackman@gmail.com>
* Makefile: Build a bFLT binary.
        * Rules.mak: Ditto.
2006-04-21 01:18:07 +00:00
Ned Ludd 791976490b - passwd doesnt use salt with md5 passwords; bug #604 thanks taviso 2006-04-21 00:40:35 +00:00
Mike Frysinger f162183527 kill signed warnings 2006-04-20 04:00:11 +00:00
Rob Landley 998dbee6d9 Patch from Jean Wolter:
it looks like the introduced support for character classes and
equivalence classes is not correct. The attached patch tries to fix
some symptoms and tries to make tr behave like gnu tr for the added
test cases. The patch

 - removes if clauses with side effects
 - fixes handling of buffer pointer (strcat added characters to the
   buffer without increasing the buffer pointer)
 - re-arranges character classes to match ASCII order

regards,
Jean
2006-04-19 22:22:06 +00:00
Rob Landley 5076eb4af9 svn 14824 broke -funsigned-char and possibly building out of tree, because
$(srcdir) can't bind early since it's set to a different value in each subdir.
If it binds early, it's blank, hence an empty -I which eats the next option
as a directory to look for #include files in.

So CFLAGS has to bind late, but the check_gcc stuff should only get run once.
I added a "make V=2" mode to show when check_gcc gets run, and turned WARNINGS
into a CFLAGS line since it was always getting added anyway.
2006-04-19 20:32:27 +00:00
Rob Landley 856489b63c New applet cksum, from Rob Sullivan. 2006-04-18 20:57:28 +00:00
Rob Landley bbd50b58ea Remove some #if 0 code. 2006-04-18 20:42:39 +00:00
Rob Landley e4386342b4 Simplify the GPL boilerplate. 2006-04-18 20:41:51 +00:00
Bernhard Reutner-Fischer 18260d5099 - typo: s/derefernce/dereference/g
Thanks to P.J. Day.
2006-04-18 14:17:49 +00:00
Bernhard Reutner-Fischer 0c013f5fc7 - commentary typo and superfluous whitespace removal in weird messages. 2006-04-18 12:46:56 +00:00
Bernhard Reutner-Fischer 38fc692e38 - improve wording in some help texts a little bit. 2006-04-18 11:21:07 +00:00
Bernhard Reutner-Fischer 074fe347b7 - add typo s/deamon/daemon/g 2006-04-18 11:15:19 +00:00
Bernhard Reutner-Fischer ea46f456d4 - patch from P.J. Day to rely on the automatic indenting provided by depends. 2006-04-18 11:11:40 +00:00
Bernhard Reutner-Fischer ba31d27249 - enable dumpleases applet again; bad rob 2006-04-18 10:04:08 +00:00
Bernhard Reutner-Fischer 9b68dbd878 - add grep for typo s/algorithic/algorithmic/g 2006-04-18 08:44:19 +00:00
Bernhard Reutner-Fischer 54f75ee300 - BusyBox is under GPL.
in http://www.busybox.net/lists/busybox/2006-April/020364.html Denis Vlasenko
  said when asked which license to use for these files:
  "Sure. LGPL or GPL is fine with me."
  Adjusting accordingly.
2006-04-18 08:24:13 +00:00
Bernhard Reutner-Fischer 2949577981 - simplify config options of the ip applet. 2006-04-18 08:11:37 +00:00
Rob Landley a2e98043d5 From Rob Sullivan: Fix a segfault with searching, plus some cleanups. 2006-04-18 01:53:41 +00:00
Rob Landley 29ba9796be Robert Eggers noticed that nfsmount would sometimes incorrectly return success. 2006-04-17 23:02:57 +00:00
Rob Landley 0edbad1a7c Glenn gave permission for GPLv2 "or later". 2006-04-17 22:49:30 +00:00
Rob Landley 026147a48f Patch from Tito to fix printing null and make output look like hdparm 6.3. 2006-04-17 22:29:13 +00:00
Rob Landley 8b1f11da52 Remove a superfluous quote and more non-generic standalone code. 2006-04-17 21:49:34 +00:00
Rob Landley 559f7d8e92 Elf dynamic linker stuff from Rich Felker. 2006-04-17 21:47:03 +00:00
Mike Frysinger 5c16988910 enable udhcp applets again; bad rob 2006-04-17 02:00:49 +00:00
Mike Frysinger 20c22e0883 just use the stack to kill memleak and return if user didnt give us anything to match 2006-04-16 21:41:00 +00:00
Mike Frysinger bf2d9905ca use xmalloc, dont hardcode length of string, and get rid of pointless call to memset 2006-04-16 21:30:47 +00:00
Mike Frysinger f8346038e9 kill off pointless malloc.h include 2006-04-16 21:17:00 +00:00
Mike Frysinger b66c931fad kill pointless memory.h includes 2006-04-16 21:15:42 +00:00
Mike Frysinger d017d73399 add a check for obsolete headers 2006-04-16 21:14:59 +00:00
Bernhard Reutner-Fischer af07a00082 - fix typo. Thanks to David Moberg for pointing this out. 2006-04-16 20:56:03 +00:00
Mike Frysinger 00d10a94f3 uncuddle if statements 2006-04-16 20:54:19 +00:00
Mike Frysinger f284c767e5 use more boiler plate GPL notices 2006-04-16 20:38:26 +00:00
Mike Frysinger 3a2b103eea uncuddle brackets 2006-04-16 20:34:26 +00:00
Mike Frysinger dbd8c3b295 add some tests for common typos and for obsolete functions 2006-04-16 06:09:46 +00:00
Mike Frysinger 1a54030445 use memmove() instead of bcopy() 2006-04-16 05:58:21 +00:00
Mike Frysinger 4b7b8a58a1 touchup comment 2006-04-16 05:55:15 +00:00
Mike Frysinger 0436b9f482 use strchr() not index() 2006-04-16 05:54:31 +00:00
Mike Frysinger 78bd504947 use memcmp() not bcmp() 2006-04-16 05:51:47 +00:00
Rob Landley b0a2d6c19d Remove code for protocols we don't properly support. (Most of this could
never be selected via menuconfig anyway.)  If somebody wants one of these
protocols, ask on the list for us to support it _properly_.
2006-04-14 20:07:33 +00:00
Rob Landley da0dcd1050 Patch from Robert P Day to remove standalone code from httpd. (Busybox has
its own make standalone planned as a general solution to this for all
applets.)
2006-04-14 19:46:19 +00:00
Rob Landley e66c7efc31 Busybox is under the GPL. 2006-04-14 19:25:01 +00:00
Rob Landley d086b504c3 Hard wiring configuration symbol values into the code defeats the purpose
of _having_ configuration symbol values.

Also, changing #ifdef CONFIG to #if ENABLE isn't nearly as useful as changing
them to if (ENABLE) or USE()/SKIP()...
2006-04-14 02:32:29 +00:00
Rob Landley 346d6d9af2 The link to Bernhard's subversion branch belongs in subversion.html (where
it already is).
2006-04-14 00:55:46 +00:00
Rob Landley 2ec922eed5 Patch from Robert P Day: let menuconfig indent stuff for us, we don't have
to do it in Config.in.
2006-04-13 23:22:16 +00:00
Bernhard Reutner-Fischer 6b4377f333 - remove unneeded include, use shorter boilerplate while at it and also
shrink filter_accept_reject_list() a tiny bit while at it.
   text    data     bss     dec     hex filename
     59       0       0      59      3b filter_accept_reject_list.o
     62       0       0      62      3e filter_accept_reject_list.o.orig
2006-04-13 13:32:16 +00:00
Bernhard Reutner-Fischer c2cb0f32b4 - patch from Denis Vlasenko to add and use bb_xopen3() 2006-04-13 12:45:04 +00:00
Bernhard Reutner-Fischer 4f3d2deaa4 - better wording.
Closes bug #656.
2006-04-12 19:14:35 +00:00
Bernhard Reutner-Fischer 34fc71f5a3 - note to think about eventually ditching vdprintf() 2006-04-12 18:50:19 +00:00
Bernhard Reutner-Fischer d9cf7ac781 - patch from Denis Vlasenko to add and use bb_xchdir() 2006-04-12 18:39:58 +00:00
Bernhard Reutner-Fischer 67f641e75b - patch from Denis Vlasenko to add bb_xbind() and bb_xlisten() 2006-04-12 18:24:37 +00:00
Bernhard Reutner-Fischer 2c99851181 - patch from Denis Vlasenko to add and use bb_xdaemon() 2006-04-12 18:09:26 +00:00
Bernhard Reutner-Fischer dac7ff15b7 - patch from Denis Vlasenko to add and use bb_xsocket() and to use
bb_xopen some more while at it.
  Also use shorter boilerplate while at it.
2006-04-12 17:55:51 +00:00
Bernhard Reutner-Fischer 79865bc507 - add verbatim cp of http://www.gnu.org/copyleft/lesser.txt 2006-04-12 17:46:18 +00:00
Bernhard Reutner-Fischer fc5f318896 - use C99 %j format to print intmax.
Closes bugs #802 and #743
2006-04-12 08:03:11 +00:00
Bernhard Reutner-Fischer cb44816ba3 - add and use bb_opendir(), bb_xopendir().
text    data     bss     dec     hex filename
 889445    9392 1035784 1934621  1d851d busybox.gcc-4.2.orig
 889297    9392 1035784 1934473  1d8489 busybox.gcc-4.2
 889009    9820 1037860 1936689  1d8d31 busybox.gcc-4.1.orig
 888817    9820 1037860 1936497  1d8c71 busybox.gcc-4.1
2006-04-12 07:35:12 +00:00
Bernhard Reutner-Fischer d0ea52ee04 - pin the CFLAGS to make sure that we don't have to re-evaluate the
check_gcc over and over again. Makes make -j work for me..
2006-04-11 20:48:24 +00:00
Bernhard Reutner-Fischer a23a6d7819 - include netinet/in.h for struct sockaddr_in.
Closes bug #735
2006-04-11 18:15:17 +00:00
Bernhard Reutner-Fischer e7f8a32929 - httpd in inetd mode: POST from IE (6) ends up in 'cannot display page'
Closes #827
2006-04-11 13:51:50 +00:00
Bernhard Reutner-Fischer cc295fb261 - comment out the check-referer lines. 2006-04-11 08:55:19 +00:00
Bernhard Reutner-Fischer e0e9886c19 - we seem to use h3, so make it consistent. 2006-04-11 08:49:01 +00:00
Bernhard Reutner-Fischer 91f604771b - update screenshot to reflect the busybox-1.1.2 stable release. 2006-04-11 08:42:58 +00:00
Bernhard Reutner-Fischer 9460f66e4e - tweak visibility of label expected_hwif_error as it's only needed for
CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF or CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF
2006-04-11 08:01:29 +00:00
Bernhard Reutner-Fischer 0b257d411d - remove implied closing paragraph
- add (improper but pretty) border='0'
2006-04-11 07:52:20 +00:00
Mike Frysinger f785255a44 Robert P. J. Day writes: even in the header file, make it clear that the routine depends on __uClinux__ 2006-04-11 04:04:40 +00:00
Bernhard Reutner-Fischer 776fe22756 - add note pointing to the stable branch, so users can pickup the current
stable version with fixes via svn.
2006-04-10 20:15:46 +00:00
Rob Landley bb5b2ffbc5 Announce 1.1.2. 2006-04-10 20:04:32 +00:00
Bernhard Reutner-Fischer 905a58a303 - poke bot 2006-04-10 19:47:46 +00:00
Bernhard Reutner-Fischer 8326d5e31b - add a colorful "valid HTML 4.01 Transitional" button to be able to check the referer easily.
Just rip it out if this is not considered generally useful.. TIA.
2006-04-10 19:40:51 +00:00
Bernhard Reutner-Fischer 3515f6e043 - make it resemble html. 2006-04-10 19:16:50 +00:00
Bernhard Reutner-Fischer fdf2b50316 - make it resemble english and fix typo s/interperet/interpret/g; 2006-04-10 18:40:27 +00:00
Rob Landley 81c40b39cb Patch from Tito to unify deluser and delgroup, and generally shrink code. 2006-04-10 18:03:17 +00:00
Bernhard Reutner-Fischer ca7166fe9d - put udhcp back in (Rob, you removed this in r14787 by accident..). 2006-04-10 18:02:12 +00:00
Rob Landley 4a8d9effca Notes about pic, static linking, and debugging dynamic linking. 2006-04-10 17:54:23 +00:00
Rob Landley 0ebecac02e Second verse, same as the first. 2006-04-10 17:34:12 +00:00
Rob Landley ea4c53ca43 Missing dependency spotted by Robert P Day. 2006-04-10 17:32:05 +00:00
Rob Landley 8ad70871b5 I forgot to re-enable shared library build after 1.1.1. (Undo svn 14590.) 2006-04-10 17:28:27 +00:00
Rob Landley c57ec37959 Patch from Rob Sullivan to consolidate crc32 table generation. 2006-04-10 17:07:15 +00:00
Rob Landley 998f449375 We use -funsigned-char now, so having a separate RESERVE_CONFIG_UBUFFER is
a bit silly.  Wean of that where it currently makes no difference...
2006-04-10 16:40:47 +00:00
Rob Landley 72615752db Modprobe update from Ignacio García Pérez, updating support for modprobe.conf. 2006-04-10 16:09:52 +00:00
Bernhard Reutner-Fischer 6554de06fe - fix typo introduced in the last commit. 2006-04-10 12:32:52 +00:00
Bernhard Reutner-Fischer a4acf669f4 - typo: s/biltin/builtin/g 2006-04-10 12:26:47 +00:00
Rob Landley 3e72c5931c Another size reduction patch from Garrett. 2006-04-06 22:49:04 +00:00
Bernhard Reutner-Fischer bc14214018 - patch from Rob Sullivan to add support for -L 2006-04-06 16:07:08 +00:00
Bernhard Reutner-Fischer 5fb0fecc1f - shrink it a little bit and make it buildable with gcc-2.95
text    data     bss     dec     hex filename
   7332       4      92    7428    1d04 diff.o-gcc-4.2-HEAD.orig
   7185       4      92    7281    1c71 diff.o-gcc-4.2-HEAD.new
   7336       4      92    7432    1d08 diff.o-gcc-4.1-HEAD.orig
   7148       4      92    7244    1c4c diff.o-gcc-4.1-HEAD.new
   7485       4      92    7581    1d9d diff.o-gcc-4.0.orig
   7318       4      92    7414    1cf6 diff.o-gcc-4.0.new
   7511       4      92    7607    1db7 diff.o-gcc-3.4.orig
   7252       4      92    7348    1cb4 diff.o-gcc-3.4.new
   8214       4      92    8310    2076 diff.o-gcc-3.3.orig
   7882       4      92    7978    1f2a diff.o-gcc-3.3.new
      -       -       -       -       - diff.o-gcc-2.95.orig
   8238       8      88    8334    208e diff.o-gcc-2.95.new
2006-04-06 11:28:19 +00:00
Bernhard Reutner-Fischer cc4003f778 - remove unused args.
text    data     bss     dec     hex filename
   7353       4      92    7449    1d19 coreutils/diff.o-gcc-4.2.oorig
   7332       4      92    7428    1d04 coreutils/diff.o
2006-04-06 08:23:11 +00:00
Bernhard Reutner-Fischer 693a93608a - move code around to avoid the need for the prototypes. 2006-04-06 08:15:24 +00:00
Bernhard Reutner-Fischer 8f7d389700 - new applet diff. Rob Sullivan writes:
Here's my attempt at a mini diff applet - it's adapted from the code at
http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/diff/, and only supports
unified diffs.

I've busyboxified everything to a reasonable degree, so I think the code is
suitable enough to be included, but there's still a fair bit of cleaning up
to be done.
2006-04-06 08:11:08 +00:00
Bernhard Reutner-Fischer e11a01cc34 - include inttypes.h as pointed out by Jason Schoon.
- use shorter boilerplate and switch to USE_FEATURE_STAT_FORMAT while at it.
2006-04-05 17:19:37 +00:00
Bernhard Reutner-Fischer 886f6afc8a - this applet should peruse USE_FEATURE_TFTP_... 2006-04-05 16:47:02 +00:00
Bernhard Reutner-Fischer 061fd0a353 - make sure that the label expected_hwif_error is visible even when
CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF isn't set.
2006-04-05 16:37:25 +00:00
Bernhard Reutner-Fischer fa939aae81 - include proper headers. 2006-04-05 16:21:37 +00:00
Bernhard Reutner-Fischer 465874f3a3 - use proper macros to print intmax_t.
PRIuMAX and PRIxMAX are defined in inttypes depending on the wordsize.
2006-04-05 14:57:59 +00:00
Paul Fox b7b24d61e0 adjust ifdefs for inclusion of string_insert() routine 2006-04-05 14:17:24 +00:00
Rob Landley 19af279d16 Kumar spotted another bug: if we autodetect nfs and they haven't specified the
fstype, it should be set to nfs.
2006-04-05 01:43:39 +00:00
Rob Landley e104d5fdcb Some tests were always true. We need comm.tests... 2006-04-04 19:26:37 +00:00
Rob Landley 9a2dd51237 Rewrite/shrink by tito. 2006-04-04 19:19:53 +00:00
Rob Landley ab8736064b You'd think there'd be a compiler warning for "pointless if", wouldn't you? 2006-04-04 16:56:04 +00:00
Rob Landley 3b84dfc2a8 Avoid spurious error message. (Technically applet order should be "SKIPPED"
when you move the testsuite directory outside of busybox and run it, but as
long as the test doesn't fail we're ok.)
2006-04-04 15:39:23 +00:00
Bernhard Reutner-Fischer dee811a53d - remove unused ext2fs_find_first_bit_set() and ext2fs_find_next_bit_set() 2006-04-04 12:17:24 +00:00
Bernhard Reutner-Fischer 89aaf4e249 - pull in prototype for e2fsck_main. 2006-04-04 12:10:28 +00:00
Bernhard Reutner-Fischer 2b398bec9c - make sure that we see all lib*/.c in IMA-mode even when not building the .so 2006-04-03 21:16:52 +00:00
Bernhard Reutner-Fischer 421d9e5941 - move buffer allocation schemes to libbb.h
- include the correct headers: applets need busybox.h while lib* need libbb.h
2006-04-03 16:39:31 +00:00
Bernhard Reutner-Fischer 101a470068 - make append_option and multiconvert static. 2006-04-03 15:46:14 +00:00
Bernhard Reutner-Fischer ebd1355828 - coalesce printf calls.
text    data     bss     dec     hex filename
   3474       4      96    3574     df6 networking/arping.o.orig
   3424       4      96    3524     dc4 networking/arping.o
2006-04-03 12:29:12 +00:00
Bernhard Reutner-Fischer a0f75e2bba - use bb_opt_complementally; Saves another 14 bytes. (thanks again, vodz) 2006-04-03 11:52:01 +00:00
Bernhard Reutner-Fischer a38330c366 - do away with useless fwd-decls, redundant bb_printf calls, silence warning
about comparing signed and unsigned and make stuff static.
   text    data     bss     dec     hex filename
   6944       0       0    6944    1b20 util-linux/ipcs.o.oorig
   6509       0       0    6509    196d util-linux/ipcs.o

TODO: bb_getopt_ulflags, and further simplifications
2006-04-03 11:25:48 +00:00
Bernhard Reutner-Fischer 6153629097 - set flags in a more reasonable manner. Thanks, vodz.
text    data     bss     dec     hex filename
   3520       4      96    3620     e24 networking/arping.o.oorig
   3488       4      96    3588     e04 networking/arping.o
2006-04-03 09:46:29 +00:00
Bernhard Reutner-Fischer cfb53dfd5e - include proper prototypes in libunarchive. 2006-04-02 21:50:01 +00:00
Bernhard Reutner-Fischer 7ab5f4d03d - janitorial: huft_build is never used outside of decompress_unzip.c and has no
prototype (which suggests that it's of no general use) so make it static for now.
2006-04-02 21:23:40 +00:00
Bernhard Reutner-Fischer 9a67ca309c - janitorial: include proper prototypes in libiproute. 2006-04-02 21:14:19 +00:00
Bernhard Reutner-Fischer 7f77810633 - switch Warning Of the Week to wrong or missing prototypes.
e.g. archival/uncompress.c wrongly includes libbb.h instead of busybox.h
  decompress_bunzip2.c,open_transformer.c don't include the proper "unarchive.h"
  etc, etc.
2006-04-02 20:41:55 +00:00
Bernhard Reutner-Fischer a1bccc0ba8 - typos: s/compatability/compatibility/g;s/compatable/compatible/g; 2006-04-02 20:17:55 +00:00
Bernhard Reutner-Fischer 9457e70357 - typo: s/compenent/component/g
add a bit of documentation.
2006-04-02 20:12:31 +00:00
Rob Landley a13cca9cf4 New version from Tito. 2006-04-02 18:57:20 +00:00
Mike Frysinger 819b56b64a work outside of the srctree 2006-04-01 20:38:22 +00:00
Rob Landley 03e78e75f3 The build broke for me on gcc 4.0.3 due to an #include having the wrong patch. 2006-04-01 17:36:31 +00:00
Rob Landley 20fef96dd8 Bug spotted by Kumar Gala. Hopefully this fixes it... 2006-04-01 17:32:52 +00:00
Rob Landley 07a637df47 Patch from KRONSTORFER Horst to Fix a size mismatch in ping, such as the 56/84
mismatch inthe following example:
  # ping -c 1 172.16.2.1
  PING 172.16.2.1 (172.16.2.1): 56 data bytes
  84 bytes from 172.16.2.1: icmp_seq=0 ttl=64 time=0.2 ms
2006-04-01 17:28:11 +00:00
Mike Frysinger b0c5445bf5 new test for source code sanity 2006-04-01 01:36:32 +00:00
Mike Frysinger 5dd1236f49 move source code tests out into a sep file rather than just disabling/breaking them 2006-04-01 01:36:13 +00:00
Mike Frysinger 81834531aa remove bogus " 2006-04-01 01:35:52 +00:00
Mike Frysinger 2cf38523a1 silence error if busybox.links doesnt exist and run tests that begin with "all_" 2006-04-01 01:35:33 +00:00
Rob Landley 43ac88849b Ext2fs cleanup from Garrett Kajmowicz. 2006-04-01 00:40:33 +00:00
Bernhard Reutner-Fischer 5cf905a871 - use RESERVE_CONFIG_BUFFER and a bit of whitespace-cleanup. defconfig:
text	   data	    bss	    dec	    hex	filename
   1307	      0	      0	   1307	    51b	util-linux/hwclock.o.oorig
   1255	      0	      0	   1255	    4e7	util-linux/hwclock.o
2006-03-31 22:36:15 +00:00
Bernhard Reutner-Fischer 81901a096c - add option to suppress the terse usage messages. Saves 6.8k for defconfig:
text	   data	    bss	    dec	    hex	filename
 861791	  11264	1039140	1912195	 1d2d83	busybox.have-terse-usage
 854799	  11264	1039140	1905203	 1d1233	busybox.no-terse
2006-03-31 18:43:55 +00:00
Bernhard Reutner-Fischer 2766eedde8 - use RESERVE_CONFIG_BUFFER. For defconfig this gives:
text	   data	    bss	    dec	    hex	filename
   3627	      4	    120	   3751	    ea7	networking/arping.o.oorig
   3548	      4	     96	   3648	    e40	networking/arping.o.r14710
   3520	      4	     96	   3620	    e24	networking/arping.o
2006-03-31 18:13:42 +00:00
Bernhard Reutner-Fischer e47c4cbd4d - update help text.
the interface argument is now a lowercase 'i' to match the big arping
  commandline-syntax.
2006-03-31 18:10:31 +00:00
Bernhard Reutner-Fischer 137669449a - shrink it a bit further.
text	   data	    bss	    dec	    hex	filename
   3627	      4	    120	   3751	    ea7	networking/arping.o.oorig
   3548	      4	     96	   3648	    e40	networking/arping.o
2006-03-31 18:02:46 +00:00
Rob Landley 8ea5205726 Shrink patch from Bernhard Fischer. 2006-03-30 21:50:57 +00:00
Bernhard Reutner-Fischer 1f6dc6d358 - rename clean_up in tune2fs and mke2fs to be prefixed with their applet names.
Purely cosmetic to ease readability.
2006-03-30 13:54:30 +00:00
Bernhard Reutner-Fischer 214744dba1 - fix paste'o which i overlooked when applying dalias' fmt stuff. 2006-03-30 13:38:19 +00:00
Rob Landley a8e2760924 Clarify. 2006-03-30 02:01:48 +00:00
Rob Landley daa4a6dcbd Update ipaddr help to match reality. 2006-03-30 01:59:30 +00:00
Paul Fox ef81ce620c fix from David Daney, on busybox mailing list:
> The problem is that if the zcip protocol times out at about the same 
 > time another ARP packet is being received, the newly calculated timeout 
 > may be set to wait forever.  This prevents the protocol from progressing 
 > through its various states.
 > 
 > The Fix is to set the timeout to zero if it used to be a positive 
 > number, but it has already expired.  This causes the next protocol state 
 > to be entered immediately instead of never.
 > 
 > If OK please commit.
 > 
 > Also note that if you may have to apply the patch on this page:
 > 
 > http://www.science.uva.nl/research/air/wiki/LinkLocalARPMeasurements
 > 
 > To the linux kernel to get proper zcip behavior.
 >
2006-03-29 23:01:33 +00:00
Bernhard Reutner-Fischer d409c3a2f7 - Rich Felker writes: fix invalid printf format strings
http://busybox.net/lists/busybox/2006-March/019568.html

   text	   data	    bss	    dec	    hex	filename
 900619	  10316	1038724	1949659	 1dbfdb	busybox.oorig
 900603	  10316	1038724	1949643	 1dbfcb	busybox
2006-03-29 22:34:47 +00:00
Bernhard Reutner-Fischer abaef6565e - warn a bit more verbosely about fmt stuff for non-release versions 2006-03-29 22:28:27 +00:00
Bernhard Reutner-Fischer 6018225238 - mark trunk as 1.2.0-pre0 2006-03-29 22:22:37 +00:00
965 changed files with 120995 additions and 96648 deletions

No files matched your search

+1 -1
View File
@@ -113,7 +113,7 @@ Manuel Novoa III <mjn3@codepoet.org>
Vladimir Oleynik <dzo@simtreas.ru>
cmdedit; bb_mkdep, xargs(current), httpd(current);
ports: ash, crond, fdisk (initial, unmaintained now), inetd, stty, traceroute,
ports: ash, crond, fdisk (initial, unmaintained now), inetd, stty, traceroute,
top;
locale, various fixes
and irreconcilable critic of everything not perfect.
+210 -113
View File
@@ -13,9 +13,34 @@ menu "Busybox Settings"
menu "General Configuration"
config NITPICK
bool "See lots more (probably unnecessary) configuration options."
default n
help
Some BusyBox applets have more configuration options than anyone
will ever care about. To avoid drowining people in complexity, most
of the applet features that can be set to a sane default value are
hidden, unless you hit the above switch.
This is better than to telling people to edit the busybox source
code, but not by much.
See http://en.wikipedia.org/wiki/Fibber_McGee_and_Molly#The_Closet
You have been warned.
config DESKTOP
bool "Enable options for full-blown desktop systems"
default n
help
Enable options and features which are not essential.
Select this only if you plan to use busybox on full-blown
desktop machine with common Linux distro, not on an embedded box.
choice
prompt "Buffer allocation policy"
default CONFIG_FEATURE_BUFFERS_USE_MALLOC
default FEATURE_BUFFERS_USE_MALLOC
depends on NITPICK
help
There are 3 ways BusyBox can handle buffer allocations:
- Use malloc. This costs code size for the call to xmalloc.
@@ -26,61 +51,86 @@ choice
behavior was the only one available for BusyBox versions 0.48 and
earlier.
config CONFIG_FEATURE_BUFFERS_USE_MALLOC
config FEATURE_BUFFERS_USE_MALLOC
bool "Allocate with Malloc"
config CONFIG_FEATURE_BUFFERS_GO_ON_STACK
config FEATURE_BUFFERS_GO_ON_STACK
bool "Allocate on the Stack"
config CONFIG_FEATURE_BUFFERS_GO_IN_BSS
config FEATURE_BUFFERS_GO_IN_BSS
bool "Allocate in the .bss section"
endchoice
config CONFIG_FEATURE_VERBOSE_USAGE
config SHOW_USAGE
bool "Show terse applet usage messages"
default y
help
All BusyBox applets will show help messages when invoked with
wrong arguments. You can turn off printing these terse usage
messages if you say no here.
This will save you up to 7k.
config FEATURE_VERBOSE_USAGE
bool "Show verbose applet usage messages"
default n
select SHOW_USAGE
help
All BusyBox applets will show more verbose help messages when
busybox is invoked with --help. This will add a lot of text to the
busybox binary. In the default configuration, this will add about
13k, but it can add much more depending on your configuration.
config CONFIG_FEATURE_INSTALLER
config FEATURE_COMPRESS_USAGE
bool "Store applet usage messages in compressed form"
default y
depends on SHOW_USAGE
help
Store usage messages in compressed form, uncompress them on-the-fly
when <applet> --help is called.
If you have a really tiny busybox with few applets enabled (and
bunzip2 isn't one of them), the overhead of the decompressor might
be noticeable. Also, if you run executables directly from ROM
and have very little memory, this might not be a win. Otherwise,
you probably want this.
config FEATURE_INSTALLER
bool "Support --install [-s] to install applet links at runtime"
default n
help
Enable 'busybox --install [-s]' support. This will allow you to use
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 CONFIG_LOCALE_SUPPORT
config LOCALE_SUPPORT
bool "Enable locale support (system needs locale for this to work)"
default n
help
Enable this if your system has locale support and you would like
busybox to support locale settings.
config CONFIG_FEATURE_DEVFS
bool "Support for devfs"
default n
config GETOPT_LONG
bool "Enable support for --long-options"
default y
help
Enable if you want BusyBox to work with devfs.
Enable this if you want busybox applets to use the gnu --long-option
style, in addition to single character -a -b -c style options.
config CONFIG_FEATURE_DEVPTS
config FEATURE_DEVPTS
bool "Use the devpts filesystem for Unix98 PTYs"
default y if CONFIG_FEATURE_DEVFS
default y
help
Enable if you want BusyBox to use Unix98 PTY support. If enabled,
busybox will use /dev/ptmx for the master side of the pseudoterminal
and /dev/pts/<number> for the slave side. Otherwise, BSD style
/dev/ttyp<number> will be used. To use this option, you should have
devpts or devfs mounted.
devpts mounted.
config CONFIG_FEATURE_CLEAN_UP
config FEATURE_CLEAN_UP
bool "Clean up all memory before exiting (usually not needed)"
default n
depends on NITPICK
help
As a size optimization, busybox normally exits without explicitly
freeing dynamically allocated memory or closing files. This saves
@@ -90,19 +140,36 @@ config CONFIG_FEATURE_CLEAN_UP
Don't enable this unless you have a really good reason to clean
things up manually.
config CONFIG_FEATURE_SUID
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
help
Support SUID and SGID binaries.
With this option you can install the busybox binary belonging
to root with the suid bit set, and it'll and it'll automatically drop
priviledges for applets that don't need root access.
config CONFIG_FEATURE_SUID_CONFIG
If you're really paranoid and don't want to do this, build two
busybox binaries with different applets in them (and the appropriate
symlinks pointing to each binary), and only set the suid bit on the
one that needs it. The applets currently marked to need the suid bit
are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs,
and vlock.
config FEATURE_SUID_CONFIG
bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
default n if CONFIG_FEATURE_SUID
depends on CONFIG_FEATURE_SUID
default n if FEATURE_SUID
depends on FEATURE_SUID
help
Allow the SUID / SGID state of an applet to be determined runtime by
checking /etc/busybox.conf. The format of this file is as follows:
Allow the SUID / SGID state of an applet to be determined at runtime
by checking /etc/busybox.conf. (This is sort of a poor man's sudo.)
The format of this file is as follows:
<applet> = [Ssx-][Ssx-][x-] (<username>|<uid>).(<groupname>|<gid>)
@@ -127,15 +194,15 @@ config CONFIG_FEATURE_SUID_CONFIG
Robert 'sandman' Griebl has more information here:
<url: http://www.softforge.de/bb/suid.html >.
config CONFIG_FEATURE_SUID_CONFIG_QUIET
config FEATURE_SUID_CONFIG_QUIET
bool "Suppress warning message if /etc/busybox.conf is not readable"
default n
depends on CONFIG_FEATURE_SUID_CONFIG
default y
depends on FEATURE_SUID_CONFIG
help
/etc/busybox.conf should be readable by the user needing the SUID, check
this option to avoid users to be notified about missing permissions.
config CONFIG_SELINUX
config SELINUX
bool "Support NSA Security Enhanced Linux"
default n
help
@@ -155,11 +222,51 @@ config 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"
help
When Busybox applets need to run other busybox applets, BusyBox
sometimes needs to exec() itself. When the /proc filesystem is
mounted, /proc/self/exe always points to the currently running
executable. If you haven't got /proc, set this to wherever you
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'
config CONFIG_STATIC
config STATIC
bool "Build BusyBox as a static binary (no shared libs)"
default n
help
@@ -173,25 +280,22 @@ config CONFIG_STATIC
Most people will leave this set to 'N'.
# The busybox shared library feature is there so make standalone can produce
# smaller applets. Since make standalone isn't in yet, there's nothing using
# this yet, and so it's disabled.
config CONFIG_DISABLE_SHARED
bool
default n
config CONFIG_BUILD_LIBBUSYBOX
config BUILD_LIBBUSYBOX
bool "Build shared libbusybox"
default n
depends on CONFIG_DISABLE_SHARED
help
Build a shared library libbusybox.so which contains all
libraries used inside busybox.
config CONFIG_FEATURE_FULL_LIBBUSYBOX
This is an experimental feature intended to support the upcoming
"make standalone" mode. Enabling it against the one big busybox
binary serves no purpose (and increases the size). You should
almost certainly say "no" to this right now.
config FEATURE_FULL_LIBBUSYBOX
bool "Feature-complete libbusybox"
default n if !CONFIG_FEATURE_SHARED_BUSYBOX
depends on CONFIG_BUILD_LIBBUSYBOX
default n if !FEATURE_SHARED_BUSYBOX
depends on BUILD_LIBBUSYBOX
help
Build a libbusybox with the complete feature-set, disregarding
the actually selected config.
@@ -207,15 +311,15 @@ config CONFIG_FEATURE_FULL_LIBBUSYBOX
Say 'N' if in doubt.
config CONFIG_FEATURE_SHARED_BUSYBOX
config FEATURE_SHARED_BUSYBOX
bool "Use shared libbusybox for busybox"
default y if CONFIG_BUILD_LIBBUSYBOX
depends on !CONFIG_STATIC && CONFIG_BUILD_LIBBUSYBOX
default y if BUILD_LIBBUSYBOX
depends on !STATIC && BUILD_LIBBUSYBOX
help
Use libbusybox.so also for busybox itself.
You need to have a working dynamic linker to use this variant.
config CONFIG_LFS
config LFS
bool "Build with Large File Support (for accessing files > 2 GB)"
default n
select FDISK_SUPPORT_LARGE_DISKS
@@ -227,34 +331,7 @@ config CONFIG_LFS
cp, mount, tar, and many others. If you want to access files larger
than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.
config USING_CROSS_COMPILER
bool "Do you want to build BusyBox with a Cross Compiler?"
default n
help
Do you want to build BusyBox with a Cross Compiler? If so,
then enable this option. Otherwise leave it set to 'N'.
config CROSS_COMPILER_PREFIX
string "Cross Compiler prefix"
default "/usr/i386-linux-uclibc/bin/i386-uclibc-"
depends on USING_CROSS_COMPILER
help
If you want to build BusyBox with a cross compiler, then you
will need to set this to the cross-compiler prefix. For example,
if my cross-compiler is /usr/i386-linux-uclibc/bin/i386-uclibc-gcc
then I would enter '/usr/i386-linux-uclibc/bin/i386-uclibc-' here,
which will ensure the correct compiler is used.
config EXTRA_CFLAGS_OPTIONS
string "Any extra CFLAGS options for the compiler?"
default ""
help
Do you want to pass any extra CFLAGS options to the compiler as
you build BusyBox? If so, this is the option for you... For example,
if you want to add some simple compiler switches (like -march=i686),
or check for warnings using -Werror, just those options here.
config CONFIG_BUILD_AT_ONCE
config BUILD_AT_ONCE
bool "Compile all sources at once"
default n
help
@@ -277,22 +354,40 @@ endmenu
menu 'Debugging Options'
config CONFIG_DEBUG
bool "Build BusyBox with Debugging symbols"
config DEBUG
bool "Build BusyBox with extra Debugging symbols"
default n
help
Say Y here if you wish to compile BusyBox with debugging symbols.
This will allow you to use a debugger to examine BusyBox internals
while applets are running. This increases the size of the binary
considerably and should only be used when doing development.
If you are doing development and want to debug BusyBox, answer Y.
Say Y here if you wish to examine BusyBox internals while applets are
running. This increases the size of the binary considerably, and
should only be used when doing development. If you are doing
development and want to debug BusyBox, answer Y.
Most people should answer N.
config WERROR
bool "Abort compilation on any warning"
default n
help
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 CONFIG_NO_DEBUG_LIB
depends on CONFIG_DEBUG
default NO_DEBUG_LIB
help
Using an additional debugging library will make BusyBox become
considerable larger and will cause it to run more slowly. You
@@ -320,31 +415,31 @@ choice
you are hunting a hard to find memory problem.
config CONFIG_NO_DEBUG_LIB
config NO_DEBUG_LIB
bool "None"
config CONFIG_DMALLOC
config DMALLOC
bool "Dmalloc"
config CONFIG_EFENCE
config EFENCE
bool "Electric-fence"
endchoice
config CONFIG_DEBUG_YANK_SUSv2
bool "Disable obsolete features removed before SUSv3?"
config INCLUDE_SUSv2
bool "Enable obsolete features removed before SUSv3?"
default y
help
This option will disable backwards compatability with SuSv2,
This option will enable backwards compatibility with SuSv2,
specifically, old-style numeric options ('command -1 <file>')
will not be supported in head, tail, and fold. (Note: should
yank from renice too.)
will be supported in head, tail, and fold. (Note: should
affect renice too.)
endmenu
menu 'Installation Options'
config CONFIG_INSTALL_NO_USR
config INSTALL_NO_USR
bool "Don't use /usr"
default n
help
@@ -352,31 +447,30 @@ config CONFIG_INSTALL_NO_USR
that you really want this behaviour.
choice
prompt "Applets links"
default CONFIG_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 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.
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.
config 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.
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.
config CONFIG_INSTALL_APPLET_DONT
bool
prompt "not installed"
depends on CONFIG_FEATURE_INSTALLER || CONFIG_FEATURE_SH_STANDALONE_SHELL
help
Do not install applets links. Usefull when using the -install feature
or a standalone shell for rescue pruposes.
config INSTALL_APPLET_DONT
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
@@ -410,3 +504,6 @@ source networking/Config.in
source procps/Config.in
source shell/Config.in
source sysklogd/Config.in
source runit/Config.in
source selinux/Config.in
source ipsvd/Config.in
+7 -5
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:
@@ -32,8 +32,10 @@ any built-in busybox applets directly, without looking for external
programs by that name. Supplying an empty command path (as above) means
the only commands busybox can find are the built-in ones.
(Note that the standalone shell currently requires /proc/self/exe to
launch new applets.)
Note that the standalone shell requires CONFIG_BUSYBOX_EXEC_PATH
to be set appropriately, depending on whether or not /proc/self/exe is
available or not. If you do not have /proc, then point that config option
to the location of your busybox binary, usually /bin/busybox.
Configuring Busybox:
====================
@@ -53,7 +55,7 @@ is run without an existing configuration, make defconfig will run first to
create a known starting point.
Other starting configurations (mostly used for testing purposes) include
"make allbaseconfig" (enables all applets but disables all optional features),
"make allbareconfig" (enables all applets but disables all optional features),
"make allyesconfig" (enables absolutely everything including debug features),
and "make randconfig" (produce a random configuration).
@@ -112,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:
=================
+8
View File
@@ -1,3 +1,11 @@
--- A note on GPL versions
BusyBox is distributed under version 2 of the General Public License (included
in its entirety, below). Version 2 is the only version of this license which
this version of BusyBox (or modified versions derived from this one) may be
distributed under.
------------------------------------------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
+1203 -368
View File
File diff suppressed because it is too large. Load diff
+149
View File
@@ -0,0 +1,149 @@
# ==========================================================================
# Build system
# ==========================================================================
busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h $(srctree)/include/applets.h
$(Q)-$(SHELL) $^ >$@
.PHONY: install
ifeq ($(CONFIG_INSTALL_APPLET_SYMLINKS),y)
INSTALL_OPTS:= --symlinks
endif
ifeq ($(CONFIG_INSTALL_APPLET_HARDLINKS),y)
INSTALL_OPTS:= --hardlinks
endif
install: $(srctree)/applets/install.sh busybox busybox.links
$(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
$(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
@echo
@echo
@echo --------------------------------------------------
@echo You will probably need to make your busybox binary
@echo setuid root to ensure all configured applets will
@echo work properly.
@echo --------------------------------------------------
@echo
endif
uninstall: busybox.links
rm -f $(CONFIG_PREFIX)/bin/busybox
for i in `cat busybox.links` ; do rm -f $(CONFIG_PREFIX)$$i; done
ifneq ($(strip $(DO_INSTALL_LIBS)),n)
for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
rm -f $(CONFIG_PREFIX)$$i; \
done
endif
check test: busybox busybox.links
bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \
$(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)
.PHONY: release
release: distclean
cd ..; \
rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
cp -a busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
-name .svn \
-print \
-exec rm -r -f {} \; ; \
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
-name .\#* \
-print \
-exec rm -f {} \; ; \
tar -czf busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION).tar.gz \
busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ ; }
.PHONY: checkhelp
checkhelp:
$(Q)$(srctree)/scripts/checkhelp.awk \
$(patsubst %,$(srctree)/%,$(wildcard $(patsubst %,%/Config.in,$(busybox-dirs) ./)))
.PHONY: sizes
sizes: busybox_unstripped
$(NM) --size-sort $(<)
.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
@mv busybox_unstripped busybox_old
.PHONY: objsizes
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
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [tr] '
# Documentation Targets
.PHONY: doc
doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
$(srctree)/include/usage.h \
$(srctree)/docs/busybox_footer.pod \
$(srctree)/docs/autodocifier.pl
$(disp_doc)
$(Q)-mkdir -p docs
$(Q)-( cat $(srctree)/docs/busybox_header.pod ; \
$(srctree)/docs/autodocifier.pl $(srctree)/include/usage.h ; \
cat $(srctree)/docs/busybox_footer.pod ; ) > docs/busybox.pod
docs/BusyBox.txt: docs/busybox.pod
$(disp_doc)
$(Q)-mkdir -p docs
$(Q)-pod2text $< > $@
docs/BusyBox.1: docs/busybox.pod
$(disp_doc)
$(Q)-mkdir -p docs
$(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
$< > $@
docs/BusyBox.html: docs/busybox.net/BusyBox.html
$(disp_doc)
$(Q)-mkdir -p docs
$(Q)-rm -f docs/BusyBox.html
$(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
docs/busybox.net/BusyBox.html: docs/busybox.pod
$(Q)-mkdir -p docs/busybox.net
$(Q)-pod2html --noindex $< > \
docs/busybox.net/BusyBox.html
$(Q)-rm -f pod2htm*
# documentation, cross-reference
# Modern distributions already ship synopsis packages (e.g. debian)
# If you have an old distribution go to http://synopsis.fresco.org/
syn_tgt = $(wildcard $(patsubst %,%/*.c,$(busybox-alldirs)))
syn = $(patsubst %.c, %.syn, $(syn_tgt))
comma:= ,
brace_open:= (
brace_close:= )
SYN_CPPFLAGS := $(strip $(CPPFLAGS) $(EXTRA_CPPFLAGS))
SYN_CPPFLAGS := $(subst $(brace_open),\$(brace_open),$(SYN_CPPFLAGS))
SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS))
#SYN_CPPFLAGS := $(subst ",\",$(SYN_CPPFLAGS))
#")
#SYN_CPPFLAGS := [$(patsubst %,'%'$(comma),$(SYN_CPPFLAGS))'']
%.syn: %.c
synopsis -p C -l Comments.SSDFilter,Comments.Previous -Wp,preprocess=True,cppflags="'$(SYN_CPPFLAGS)'" -o $@ $<
.PHONY: html
html: $(syn)
synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
-include $(srctree)/Makefile.local
+93
View File
@@ -0,0 +1,93 @@
# ==========================================================================
# Build system
# ==========================================================================
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 += \
-Iinclude -Ilibbb \
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
-include include/autoconf.h \
-D_GNU_SOURCE -DNDEBUG \
$(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
-D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
# flag checks are grouped together to speed the checks up a bit..
CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,)
CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
# If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
# (or anything else for that matter) make sure that it is still possible
# to build bbox without warnings. Current offender: find.c:alloc_action().
# Looks more like gcc bug: gcc will warn on it with or without prototype.
# But still, warning-free compile is a must, or else we will drown
# in warnings pretty soon.
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 += $(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
+44
View File
@@ -0,0 +1,44 @@
# ==========================================================================
# Build system
# ==========================================================================
help:
@echo 'Cleaning:'
@echo ' clean - delete temporary files created by build'
@echo ' distclean - delete all non-source files (including .config)'
@echo
@echo 'Build:'
@echo ' all - Executable and documentation'
@echo ' busybox - the swiss-army executable'
@echo ' doc - docs/BusyBox.{txt,html,1}'
@echo ' html - create html-based cross-reference'
@echo
@echo 'Configuration:'
@echo ' allnoconfig - disable all symbols in .config'
@echo ' allyesconfig - enable all symbols in .config (see defconfig)'
@echo ' allbareconfig - enable all applets without any sub-features'
@echo ' config - text based configurator (of last resort)'
@echo ' defconfig - set .config to largest generic configuration'
@echo ' menuconfig - interactive curses-based configurator'
@echo ' oldconfig - resolve any unresolved symbols in .config'
@echo ' hosttools - build sed for the host.'
@echo ' You can use these commands if the commands on the host'
@echo ' is unusable. Afterwards use it like:'
@echo ' make SED="$(objtree)/sed"'
@echo
@echo 'Installation:'
@echo ' install - install busybox into $(CONFIG_PREFIX)'
@echo ' uninstall'
@echo
@echo 'Development:'
@echo ' baseline - create busybox_old for bloatcheck.'
@echo ' bloatcheck - show size difference between old and new versions'
@echo ' check - run the test suite for all applets'
@echo ' checkhelp - check for missing help-entries in Config.in'
@echo ' randconfig - generate a random configuration'
@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
+12 -17
View File
@@ -5,12 +5,12 @@ What is busybox:
BusyBox combines tiny versions of many common UNIX utilities into a single
small executable. It provides minimalist replacements for most of the
utilities you usually find in bzip2, coreutils, e2fsprogs, file, findutils,
gawk, grep, inetutils, less, modutils, net-tools, procps, sed, shadow,
sysklogd, sysvinit, tar, util-linux, and vim. The utilities in BusyBox
often have fewer options than their full-featured cousins; however, the
options that are included provide the expected functionality and behave
very much like their larger counterparts.
utilities you usually find in bzip2, coreutils, dhcp, diffutils, e2fsprogs,
file, findutils, gawk, grep, inetutils, less, modutils, net-tools, procps,
sed, shadow, sysklogd, sysvinit, tar, util-linux, and vim. The utilities
in BusyBox often have fewer options than their full-featured cousins;
however, the options that are included provide the expected functionality
and behave very much like their larger counterparts.
BusyBox has been written with size-optimization and limited resources in
mind, both to produce small binaries and to reduce run-time memory usage.
@@ -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").
----------------
@@ -65,11 +65,6 @@ Downloading the current source code:
http://busybox.net/downloads/
You can browse the up to the minute source code and change history online.
The "stable" series is at:
http://www.busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_00_stable/busybox/
And the development series is at:
http://www.busybox.net/cgi-bin/viewcvs.cgi/trunk/busybox/
@@ -199,5 +194,5 @@ Supported hardware:
Please feed suggestions, bug reports, insults, and bribes back to the busybox
maintainer:
Erik Andersen
<andersen@codepoet.org>
Denis Vlasenko
<vda.linux@googlemail.com>
-304
View File
@@ -1,304 +0,0 @@
# Rules.make for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under GPLv2, see the file LICENSE in this tarball for details.
#
# Pull in the user's busybox configuration
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
-include $(top_builddir)/.config
endif
#--------------------------------------------------------
PROG := busybox
MAJOR_VERSION :=1
MINOR_VERSION :=1
SUBLEVEL_VERSION:=1
EXTRAVERSION :=
VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION)
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
#--------------------------------------------------------
# With a modern GNU make(1) (highly recommended, that's what all the
# developers use), all of the following configuration values can be
# overridden at the command line. For example:
# make CROSS=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
#--------------------------------------------------------
# If you are running a cross compiler, you will want to set 'CROSS'
# to something more interesting... Target architecture is determined
# by asking the CC compiler what arch it compiles things for, so unless
# your compiler is broken, you should not need to specify TARGET_ARCH
CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
CC = $(CROSS)gcc
AR = $(CROSS)ar
AS = $(CROSS)as
LD = $(CROSS)ld
NM = $(CROSS)nm
STRIP = $(CROSS)strip
CPP = $(CC) -E
SED ?= sed
# What OS are you compiling busybox for? This allows you to include
# OS specific things, syscall overrides, etc.
TARGET_OS=linux
# Select the compiler needed to build binaries for your development system
HOSTCC = gcc
HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
LC_ALL:= C
# If you want to add some simple compiler switches (like -march=i686),
# especially from the command line, use this instead of CFLAGS directly.
# For optimization overrides, it's better still to set OPTIMIZATION.
CFLAGS_EXTRA=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
# To compile vs some other alternative libc, you may need to use/adjust
# the following lines to meet your needs...
#
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
# using the compatible RPMs (compat-*) at http://www.redhat.com !
#LIBCDIR:=/usr/i386-glibc20-linux
#
# For other libraries, you are on your own. But these may (or may not) help...
#LDFLAGS+=-nostdlib
#LIBRARIES:=$(LIBCDIR)/lib/libc.a -lgcc
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR) -funsigned-char
#GCCINCDIR:=$(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
CFLAGS+=-I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir)
ARFLAGS=cru
# gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest
# get the CC MAJOR/MINOR version
CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1))
CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1))
#--------------------------------------------------------
export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
ifeq ($(strip $(TARGET_ARCH)),)
TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
-e 's/i.86/i386/' \
-e 's/sparc.*/sparc/' \
-e 's/arm.*/arm/g' \
-e 's/m68k.*/m68k/' \
-e 's/ppc/powerpc/g' \
-e 's/v850.*/v850/g' \
-e 's/sh[234]/sh/' \
-e 's/mips-.*/mips/' \
-e 's/mipsel-.*/mipsel/' \
-e 's/cris.*/cris/' \
)
endif
# A nifty macro to make testing gcc features easier
check_gcc=$(shell \
if [ "$(1)" != "" ]; then \
if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
then echo "$(1)"; else echo "$(2)"; fi \
fi)
# A not very robust macro to check for available ld flags
check_ld=$(shell \
if [ "x$(1)" != "x" ]; then \
$(LD) --help | grep -q "\$(1)" && echo "-Wl,$(1)" ; \
fi)
CFLAGS+=$(call check_gcc,-funsigned-char,)
CFLAGS+=$(call check_gcc,-mmax-stack-frame=256,)
#--------------------------------------------------------
# Arch specific compiler optimization stuff should go here.
# Unless you want to override the defaults, do not set anything
# for OPTIMIZATION...
# use '-Os' optimization if available, else use -O2
OPTIMIZATION:=$(call check_gcc,-Os,-O2)
ifeq ($(CONFIG_BUILD_AT_ONCE),y)
# gcc 2.95 exits with 0 for "unrecognized option"
ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0)
CFLAGS_COMBINE:=$(call check_gcc,--combine,)
endif
OPTIMIZATION+=$(call check_gcc,-funit-at-a-time,)
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795
#PROG_CFLAGS+=$(call check_gcc,-fwhole-program,)
endif # CONFIG_BUILD_AT_ONCE
LIB_LDFLAGS:=$(call check_ld,--enable-new-dtags,)
#LIB_LDFLAGS+=$(call check_ld,--reduce-memory-overheads,)
#LIB_LDFLAGS+=$(call check_ld,--as-needed,)
#LIB_LDFLAGS+=$(call check_ld,--warn-shared-textrel,)
# Some nice architecture specific optimizations
ifeq ($(strip $(TARGET_ARCH)),arm)
OPTIMIZATION+=-fstrict-aliasing
endif
ifeq ($(strip $(TARGET_ARCH)),i386)
OPTIMIZATION+=$(call check_gcc,-march=i386,)
# gcc-4.0 and older seem to benefit from these
#ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
OPTIMIZATION+=$(call check_gcc,-falign-functions=1 -falign-jumps=1 -falign-loops=1,\
-malign-functions=0 -malign-jumps=0 -malign-loops=0)
#endif # gcc-4.0 and older
# gcc-4.1 and beyond seem to benefit from these
ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
# turn off flags which hurt -Os
OPTIMIZATION+=$(call check_gcc,-fno-tree-loop-optimize,)
OPTIMIZATION+=$(call check_gcc,-fno-tree-dominator-opts,)
OPTIMIZATION+=$(call check_gcc,-fno-strength-reduce,)
OPTIMIZATION+=$(call check_gcc,-fno-branch-count-reg,)
endif # gcc-4.1 and beyond
endif
OPTIMIZATIONS:=$(OPTIMIZATION) $(call check_gcc,-fomit-frame-pointer,)
#
#--------------------------------------------------------
# If you're going to do a lot of builds with a non-vanilla configuration,
# it makes sense to adjust parameters above, so you can type "make"
# by itself, instead of following it by the same half-dozen overrides
# every time. The stuff below, on the other hand, is probably less
# prone to casual user adjustment.
#
ifeq ($(strip $(CONFIG_LFS)),y)
# For large file summit support
CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
endif
ifeq ($(strip $(CONFIG_DMALLOC)),y)
# For testing mem leaks with dmalloc
CFLAGS+=-DDMALLOC
LIBRARIES:=-ldmalloc
else
ifeq ($(strip $(CONFIG_EFENCE)),y)
LIBRARIES:=-lefence
endif
endif
ifeq ($(strip $(CONFIG_DEBUG)),y)
CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE
LDFLAGS += $(call check_ld,--warn-common,)
else
CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
LDFLAGS += $(call check_ld,--warn-common,)
LDFLAGS += $(call check_ld,--sort-common,)
endif
STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment
ifeq ($(strip $(CONFIG_STATIC)),y)
PROG_CFLAGS += $(call check_gcc,-static,)
endif
CFLAGS_SHARED += $(call check_gcc,-shared,)
LIB_CFLAGS+=$(CFLAGS_SHARED)
ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
CFLAGS_PIC:= $(call check_gcc,-fPIC,)
LIB_CFLAGS+=$(CFLAGS_PIC)
endif
ifeq ($(strip $(CONFIG_SELINUX)),y)
LIBRARIES += -lselinux
endif
ifeq ($(strip $(PREFIX)),)
PREFIX:=`pwd`/_install
endif
# Additional complications due to support for pristine source dir.
# Include files in the build directory should take precedence over
# the copy in top_srcdir, both during the compilation phase and the
# shell script that finds the list of object files.
# Work in progress by <ldoolitt@recycle.lbl.gov>.
OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
CFLAGS += $(CROSS_CFLAGS)
ifdef BB_INIT_SCRIPT
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
endif
# Put user-supplied flags at the end, where they
# have a chance of winning.
CFLAGS += $(CFLAGS_EXTRA)
#------------------------------------------------------------
# Installation options
ifeq ($(strip $(CONFIG_INSTALL_APPLET_HARDLINKS)),y)
INSTALL_OPTS=--hardlinks
endif
ifeq ($(strip $(CONFIG_INSTALL_APPLET_SYMLINKS)),y)
INSTALL_OPTS=--symlinks
endif
ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y)
INSTALL_OPTS=
endif
#------------------------------------------------------------
# Make the output nice and tight
MAKEFLAGS += --no-print-directory
export MAKE_IS_SILENT=n
ifneq ($(findstring s,$(MAKEFLAGS)),)
export MAKE_IS_SILENT=y
SECHO := @-false
DISP := sil
Q := @
else
ifneq ($(V)$(VERBOSE),)
SECHO := @-false
DISP := ver
Q :=
else
SECHO := @echo
DISP := pur
Q := @
endif
endif
show_objs = $(subst $(top_builddir)/,,$(subst ../,,$@))
pur_disp_compile.c = echo " "CC $(show_objs)
pur_disp_compile.h = echo " "HOSTCC $(show_objs)
pur_disp_strip = echo " "STRIP $(show_objs)
pur_disp_link = echo " "LINK $(show_objs)
pur_disp_ar = echo " "AR $(ARFLAGS) $(show_objs)
sil_disp_compile.c = true
sil_disp_compile.h = true
sil_disp_strip = true
sil_disp_link = true
sil_disp_ar = true
ver_disp_compile.c = echo $(cmd_compile.c)
ver_disp_compile.h = echo $(cmd_compile.h)
ver_disp_strip = echo $(cmd_strip)
ver_disp_link = echo $(cmd_link)
ver_disp_ar = echo $(cmd_ar)
disp_compile.c = $($(DISP)_disp_compile.c)
disp_compile.h = $($(DISP)_disp_compile.h)
disp_strip = $($(DISP)_disp_strip)
disp_link = $($(DISP)_disp_link)
disp_ar = $($(DISP)_disp_ar)
disp_gen = $(SECHO) " "GEN $@ ; true
disp_doc = $(SECHO) " "DOC $(subst docs/,,$@) ; true
cmd_compile.c = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
cmd_compile.h = $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $<
cmd_strip = $(STRIPCMD) $@
cmd_link = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS)
cmd_ar = $(AR) $(ARFLAGS) $@ $^
compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
compile.h = @$(disp_compile.h) ; $(cmd_compile.h)
do_strip = @$(disp_strip) ; $(cmd_strip)
do_link = @$(disp_link) ; $(cmd_link)
do_ar = @$(disp_ar) ; $(cmd_ar)
.PHONY: dummy
+168 -108
View File
@@ -1,37 +1,145 @@
Busybox TODO
Stuff that needs to be done. All of this is fair game for 1.2.
Stuff that needs to be done. This is organized by who plans to get around to
doing it eventually, but that doesn't mean they "own" the item. If you want to
do one of these bounce an email off the person it's listed under to see if they
have any suggestions how they plan to go about it, and to minimize conflicts
between your work and theirs. But otherwise, all of these are fair game.
Rob Landley <rob@landley.net>:
Add BB_NOMMU to platform.h and migrate __uClinux__ tests to that.
#if defined __UCLIBC__ && !defined __ARCH_USE_MMU__
Add a libbb/platform.c
Implement fdprintf() for platforms that haven't got one.
Implement bb_realpath() that can handle NULL on non-glibc.
Cleanup bb_asprintf()
Migrate calloc() and bb_calloc() occurrences to bb_xzalloc().
Remove obsolete _() wrapper crud for internationalization we don't do.
Figure out where we need utf8 support, and add it.
sh
The command shell situation is a big mess. We have three or four different
shells that don't really share any code, and the "standalone shell" doesn't
work all that well (especially not in a chroot environment), due to apps not
being reentrant. I'm writing a new shell (bbsh) to unify the various
shells and configurably add the minimal set of bash features people
actually use. The hardest part is it has to configure down as small as
lash while providing lash's features. The rest is easy in comparison.
bzip2
Compression-side support.
init
General cleanup (should use ENABLE_FEATURE_INIT_SYSLOG and ENABLE_FEATURE_INIT_DEBUG).
depmod
busybox lacks a way to update module deps when running from firmware without the
use of the depmod.pl (perl is to bloated for most embedded setups) and or orig
modutils. The orig depmod is rather pointless to have to add to a firmware image
in when we already have a insmod/rmmod and friends.
Unify base64 handling.
[done]
Do a SUSv3 audit
Look at the full Single Unix Specification version 3 (available online at
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
figure out which of our apps are compliant, and what we're missing that
we might actually care about.
Even better would be some kind of automated compliance test harness that
exercises each command line option and the various corner cases.
Internationalization
How much internationalization should we do?
The low hanging fruit is UTF-8 character set support. We should do this.
(Vodz pointed out the shell's cmdedit as needing work here. What else?)
We also have lots of hardwired english text messages. Consolidating this
into some kind of message table not only makes translation easier, but
also allows us to consolidate redundant (or close) strings.
We probably don't want to be bloated with locale support. (Not unless we
can cleanly export it from our underlying C library without having to
concern ourselves with it directly. Perhaps a few specific things like a
config option for "date" are low hanging fruit here?)
What level should things happen at? How much do we care about
internationalizing the text console when X11 and xterms are so much better
at it? (There's some infrastructure here we don't implement: The
"unicode_start" and "unicode_stop" shell scripts need "vt-is-UTF8" and a
--unicode option to loadkeys. That implies a real loadkeys/dumpkeys
implementation to replace loadkmap/dumpkmap. Plus messing with console font
loading. Is it worth it, or do we just say "use X"?)
Individual compilation of applets.
It would be nice if busybox had the option to compile to individual applets,
for people who want an alternate implementation less bloated than the gnu
utils (or simply with less political baggage), but without it being one big
executable.
Turning libbb into a real dll is another possibility, especially if libbb
could export some of the other library interfaces we've already more or less
got the code for (like zlib).
buildroot - Make a "dogfood" option
Busybox 1.1 will be capable of replacing most gnu packages for real world
use, such as developing software or in a live CD. It needs wider testing.
Busybox should now be able to replace bzip2, coreutils, e2fsprogs, file,
findutils, gawk, grep, inetutils, less, modutils, net-tools, patch, procps,
sed, shadow, sysklogd, sysvinit, tar, util-linux, and vim. The resulting
system should be self-hosting (I.E. able to rebuild itself from source
code). This means it would need (at least) binutils, gcc, and make, or
equivalents.
It would be a good "eating our own dogfood" test if buildroot had the option
of using a "make allyesconfig" busybox instead of the all of the above
packages. Anything that's wrong with the resulting system, we can fix. (It
would be nice to be able to upgrade busybox to be able to replace bash and
diffutils as well, but we're not there yet.)
One example of an existing system that does this already is Firmware Linux:
http://www.landley.net/code/firmware
initramfs
Busybox should have a sample initramfs build script. This depends on
bbsh, mdev, and switch_root.
mkdep
Write a mkdep that doesn't segfault if there's a directory it doesn't
have permission to read, isn't based on manually editing the output of
lexx and yacc, doesn't make such a mess under include/config, etc.
Group globals into unions of structures.
Go through and turn all the global and static variables into structures,
and have all those structures be in a big union shared between processes,
so busybox uses less bss. (This is a big win on nommu machines.) See
sed.c and mdev.c for examples.
Go through bugs.busybox.net and close out all of that somehow.
This one's open to everybody, but I'll wind up doing it...
Bernhard Fischer <busybox@busybox.net> suggests to look at these:
New debug options:
-Wlarger-than-127
Cleanup any big users
-Wunused-parameter
Facilitate applet PROTOTYPES to provide means for having applets that
do a) not take any arguments b) need only one of argc or argv c) need
both argc and argv. All of these three options should go for the most
feature complete denominator.
Collate BUFSIZ IOBUF_SIZE MY_BUF_SIZE PIPE_PROGRESS_SIZE BUFSIZE PIPESIZE
make bb_common_bufsiz1 configurable, size wise.
make pipesize configurable, size wise.
Use bb_common_bufsiz1 throughout applets!
As yet unclaimed:
build system
make -j is broken, -j1 is forced atm
Make sure that the flags get pinned in e.g. Rules.mak so when expanding them
later on you get the cached result without the need to re-evaluate them.
----
find
doesn't understand (), lots of susv3 stuff.
----
sh
The command shell situation is a big mess. We have three or four different
shells that don't really share any code, and the "standalone shell" doesn't
work all that well (especially not in a chroot environment), due to apps not
being reentrant. Unifying the various shells and figuring out a configurable
way of adding the minimal set of bash features a given script uses is a big
job, but it would be a big improvement.
Note: Rob Landley (rob@landley.net) is working on a new unified shell called
bbsh, but it's a low priority...
---
diff
We should have a diff -u command. We have patch, we should have diff
(we only need to support unified diffs though).
Also, make sure we handle empty files properly:
Make sure we handle empty files properly:
From the patch man page:
   you can remove a file by sending out a context diff that compares
   the file to be deleted with an empty file dated the Epoch.  The
   file will be removed unless patch is conforming to POSIX and the
   -E or --remove-empty-files option is not given.
you can remove a file by sending out a context diff that compares
the file to be deleted with an empty file dated the Epoch. The
file will be removed unless patch is conforming to POSIX and the
-E or --remove-empty-files option is not given.
---
patch
Should have simple fuzz factor support to apply patches at an offset which
@@ -40,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
@@ -48,17 +160,22 @@ man
(How doclifter might work into this is anybody's guess.)
---
bzip2
Compression-side support.
---
init
General cleanup.
---
ar
Write support?
---
mdev
Micro-udev.
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:
@@ -74,46 +191,6 @@ bb_close() with fsync()
You need to call fsync() if you care about errors that occur after write(),
but that can have a big performance impact. So make it a config option.
---
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.
---
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
figure out which of our apps are compliant, and what we're missing that
we might actually care about.
Even better would be some kind of automated compliance test harness that
exercises each command line option and the various corner cases.
---
Internationalization
How much internationalization should we do?
The low hanging fruit is UTF-8 character set support. We should do this.
(Vodz pointed out the shell's cmdedit as needing work here. What else?)
We also have lots of hardwired english text messages. Consolidating this
into some kind of message table not only makes translation easier, but
also allows us to consolidate redundant (or close) strings.
We probably don't want to be bloated with locale support. (Not unless we can
cleanly export it from our underlying C library without having to concern
ourselves with it directly. Perhaps a few specific things like a config
option for "date" are low hanging fruit here?)
What level should things happen at? How much do we care about
internationalizing the text console when X11 and xterms are so much better
at it? (There's some infrastructure here we don't implement: The
"unicode_start" and "unicode_stop" shell scripts need "vt-is-UTF8" and a
--unicode option to loadkeys. That implies a real loadkeys/dumpkeys
implementation to replace loadkmap/dumpkmap. Plus messing with console font
loading. Is it worth it, or do we just say "use X"?)
---
Unify archivers
Lots of archivers have the same general infrastructure. The directory
traversal code should be factored out, and the guts of each archiver could
@@ -129,45 +206,12 @@ Text buffer support.
a whole file into memory and act on it. There might be an opportunity
for shared code in there that could be moved into libbb...
---
Individual compilation of applets.
It would be nice if busybox had the option to compile to individual applets,
for people who want an alternate implementation less bloated than the gnu
utils (or simply with less political baggage), but without it being one big
executable.
Turning libbb into a real dll is another possibility, especially if libbb
could export some of the other library interfaces we've already more or less
got the code for (like zlib).
---
buildroot - Make a "dogfood" option
Busybox 1.1 will be capable of replacing most gnu packages for real world use,
such as developing software or in a live CD. It needs wider testing.
Busybox should now be able to replace bzip2, coreutils, e2fsprogs, file,
findutils, gawk, grep, inetutils, less, modutils, net-tools, patch, procps,
sed, shadow, sysklogd, sysvinit, tar, util-linux, and vim. The resulting
system should be self-hosting (I.E. able to rebuild itself from source code).
This means it would need (at least) binutils, gcc, and make, or equivalents.
It would be a good "eating our own dogfood" test if buildroot had the option
of using a "make allyesconfig" busybox instead of the all of the above
packages. Anything that's wrong with the resulting system, we can fix. (It
would be nice to be able to upgrade busybox to be able to replace bash and
diffutils as well, but we're not there yet.)
One example of an existing system that does this already is Firmware Linux:
http://www.landley.net/code/firmware
---
initramfs
Busybox should have a sample initramfs build script. This depends on
bbsh, mdev, and switch_root.
---
Memory Allocation
We have a CONFIG_BUFFER mechanism that lets us select whether to do memory
allocation on the stack or the heap. Unfortunately, we're not using it much.
We need to audit our memory allocations and turn a lot of malloc/free calls
into RESERVE_CONFIG_BUFFER/RELEASE_CONFIG_BUFFER.
For a start, see e.g. make CFLAGS_EXTRA=-Wlarger-than-64
For a start, see e.g. make EXTRA_CFLAGS=-Wlarger-than-64
And while we're at it, many of the CONFIG_FEATURE_CLEAN_UP #ifdefs will be
optimized out by the compiler in the stack allocation case (since there's no
@@ -227,7 +271,7 @@ FEATURE_CLEAN_UP
jumps out of the normal flow control and bypasses any cleanup code we
put at the end of our applets.
It's possible to add hooks to libbb functions like xmalloc() and bb_xopen()
It's possible to add hooks to libbb functions like xmalloc() and xopen()
to add their entries to a linked list, which could be traversed and
freed/closed automatically. (This would need to be able to free just the
entries after a checkpoint to be usable for a forkless standalone shell.
@@ -247,6 +291,21 @@ Minor stuff:
if(!ioctl (fd, WDIOC_GETTIMEOUT, &tmo)) timer_duration = 1 + (tmo / 2);
Unfortunately, that needs linux/watchdog.h and that contains unfiltered
kernel types on some distros, which breaks the build.
---
use bb_error_msg where appropriate: See
egrep "(printf.*\([[:space:]]*(stderr|2)|[^_]write.*\([[:space:]]*(stderr|2))"
---
use bb_perror_msg where appropriate: See
egrep "[^_]perror"
---
Remove superfluous fmt occurances: e.g.
fprintf(stderr, "%s: %s not found\n", "unalias", *argptr);
-> fprintf(stderr, "unalias: %s not found\n", *argptr);
---
possible code duplication ingroup() and is_a_group_member()
---
Move __get_hz() to a better place and (re)use it in route.c, ash.c, msh.c
---
Code cleanup:
@@ -257,4 +316,5 @@ bzero() -> memset()
---
sigblock(), siggetmask(), sigsetmask(), sigmask() -> sigprocmask et al
---
vdprintf() -> similar sized functionality
---
+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
+25
View File
@@ -0,0 +1,25 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
obj-y:=
obj-y += applets.o
hostprogs-y:=
hostprogs-y += usage
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
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)
-23
View File
@@ -1,23 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
ifndef top_srcdir
top_srcdir=..
endif
ifndef top_builddir
top_builddir=..
endif
srcdir=$(top_srcdir)/applets
APPLETS_DIR:=./
include $(top_builddir)/Rules.mak
include $(top_builddir)/.config
include $(srcdir)/Makefile.in
all: $(libraries-y)
-include $(top_builddir).depend
clean:
rm -f *.o *.a $(AR_TARGET)
-26
View File
@@ -1,26 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
APPLETS_AR:=applets.a
ifndef $(APPLETS_DIR)
APPLETS_DIR:=$(top_builddir)/applets/
endif
srcdir=$(top_srcdir)/applets
APPLET_SRC:= $(patsubst %,$(srcdir)/%,applets.c busybox.c version.c)
APPLET_OBJ:= $(patsubst $(srcdir)/%.c,$(APPLETS_DIR)%.o, $(APPLET_SRC))
APPLET_SRC-y+=$(APPLET_SRC)
APPLET_SRC-a+=$(APPLET_SRC)
libraries-y+=$(APPLETS_DIR)$(APPLETS_AR)
$(APPLETS_DIR)$(APPLETS_AR): $(APPLET_OBJ)
$(do_ar)
$(APPLET_OBJ): $(top_builddir)/.config
$(APPLET_OBJ): $(APPLETS_DIR)%.o: $(srcdir)/%.c
$(compile.c)
+419 -219
View File
@@ -6,93 +6,88 @@
* isn't something I'm going to worry about... If you wrote something
* here, please feel free to acknowledge your work.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
* Permission has been granted to redistribute this code under the GPL.
*
* Licensed under GPLv2 or later, see file License in this tarball for details.
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "busybox.h"
const char usage_messages[] =
/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
#warning Static linking against glibc produces buggy executables
#warning (glibc does not cope well with ld --gc-sections).
#warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
#warning Note that glibc is unsuitable for static linking anyway.
#warning If you still want to do it, remove -Wl,--gc-sections
#warning from top-level Makefile and remove this warning.
#error Aborting compilation.
#endif
/* Declare <applet>_main() */
#define PROTOTYPES
#include "applets.h"
#undef PROTOTYPES
#if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE
/* Define usage_messages[] */
static const char usage_messages[] ALIGN1 = ""
#define MAKE_USAGE
#include "usage.h"
#include "applets.h"
;
#undef MAKE_USAGE
#undef APPLET
#undef APPLET_NOUSAGE
#undef PROTOTYPES
#else
#define usage_messages 0
#endif /* SHOW_USAGE */
/* Define struct bb_applet applets[] */
#include "applets.h"
/* The -1 arises because of the {0,NULL,0,-1} entry. */
#if ENABLE_FEATURE_SH_STANDALONE
const unsigned short NUM_APPLETS = ARRAY_SIZE(applets);
#endif
const struct bb_applet *current_applet;
const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
#if !BB_MMU
bool re_execed;
#endif
static struct BB_applet *applet_using;
USE_FEATURE_SUID(static uid_t ruid;) /* real uid */
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
#if ENABLE_FEATURE_SUID_CONFIG
#ifdef CONFIG_FEATURE_SUID_CONFIG
#include <sys/stat.h>
#include <ctype.h>
#include "pwd_.h"
#include "grp_.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;
uid_t m_uid;
gid_t m_gid;
mode_t m_mode;
struct BB_suid_config *m_next;
/* 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)
static int ingroup(uid_t u, gid_t g)
{
struct group *grp = getgrgid (g);
struct group *grp = getgrgid(g);
if (grp) {
char **mem;
if (grp) {
char **mem;
for (mem = grp->gr_mem; *mem; mem++) {
struct passwd *pwd = getpwnam (*mem);
for (mem = grp->gr_mem; *mem; mem++) {
struct passwd *pwd = getpwnam(*mem);
if (pwd && (pwd->pw_uid == u))
return 1;
if (pwd && (pwd->pw_uid == u))
return 1;
}
}
}
return 0;
return 0;
}
/* This should probably be a libbb routine. In that case,
@@ -108,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 (char *) bb_skip_whitespace(s);
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")) /* Can not 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;
}
@@ -162,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? */
@@ -190,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;
}
@@ -200,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.
@@ -229,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. */
@@ -238,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.
@@ -253,11 +254,15 @@ static void parse_config_file(void)
/* Get the specified mode. */
e = (char *) bb_skip_whitespace(e+1);
e = skip_whitespace(e+1);
for (i = 0; i < 3; i++) {
/* There are 4 chars + 1 nul for each of user/group/other. */
static const char mode_chars[] ALIGN1 = "Ssx-\0" "Ssx-\0" "Ttx-";
for (i=0 ; i < 3 ; i++) {
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. */
@@ -266,37 +271,34 @@ static void parse_config_file(void)
/* Now get the the user/group info. */
s = (char *) bb_skip_whitespace(e);
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;
if (!(pwd = getpwnam(s))) {
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;
@@ -313,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. */
@@ -326,143 +328,341 @@ static void parse_config_file(void)
free(sct_head);
sct_head = sct;
}
return;
}
#else
#define parse_config_file()
#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 (suid_cfg_readable) {
struct BB_suid_config *sct;
for (sct = suid_config; sct; sct = sct->m_next) {
if (sct->m_applet == applet)
break;
}
if (sct) {
mode_t m = sct->m_mode;
#if ENABLE_FEATURE_SUID
static void check_suid(const struct bb_applet *applet)
{
gid_t rgid; /* real gid */
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 (ruid == 0) /* set by parse_config_file() */
return; /* run by root - no need to check more */
rgid = getgid();
if (!(m & S_IXOTH)) /* is x bit not set ? */
bb_error_msg_and_die ("You have no permission to run this applet!");
#if ENABLE_FEATURE_SUID_CONFIG
if (suid_cfg_readable) {
uid_t uid;
struct BB_suid_config *sct;
mode_t m;
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { /* *both* have to be set for sgid */
if (setegid (sct->m_gid))
bb_error_msg_and_die
("BusyBox binary has insufficient rights to set proper GID for applet!");
} else
setgid (rgid); /* no sgid -> drop */
if (sct->m_mode & S_ISUID) {
if (seteuid (sct->m_uid))
bb_error_msg_and_die
("BusyBox binary has insufficient rights to set proper UID for applet!");
} else
setuid (ruid); /* no suid -> drop */
} else {
for (sct = suid_config; sct; sct = sct->m_next) {
if (sct->m_applet == applet)
goto found;
}
/* default: drop all privileges */
setgid (rgid);
setuid (ruid);
}
return;
} else {
#ifndef CONFIG_FEATURE_SUID_CONFIG_QUIET
static int onetime = 0;
xsetgid(rgid);
xsetuid(ruid);
return;
found:
m = sct->m_mode;
if (sct->m_uid == ruid)
/* same uid */
m >>= 6;
else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid))
/* same group / in group */
m >>= 3;
if (!onetime) {
onetime = 1;
fprintf (stderr, "Using fallback suid method\n");
if (!(m & S_IXOTH)) /* is x bit not set ? */
bb_error_msg_and_die("you have no permission to run this applet!");
/* _both_ sgid and group_exec have to be set for setegid */
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
rgid = sct->m_gid;
/* else (no setegid) we will set egid = rgid */
/* We set effective AND saved ids. If saved-id is not set
* like we do below, seteiud(0) can still later succeed! */
if (setresgid(-1, rgid, rgid))
bb_perror_msg_and_die("setresgid");
/* do we have to set effective uid? */
uid = ruid;
if (sct->m_mode & S_ISUID)
uid = sct->m_uid;
/* else (no seteuid) we will set euid = ruid */
if (setresuid(-1, uid, uid))
bb_perror_msg_and_die("setresuid");
return;
}
#if !ENABLE_FEATURE_SUID_CONFIG_QUIET
{
static bool onetime = 0;
if (!onetime) {
onetime = 1;
fprintf(stderr, "Using fallback suid method\n");
}
}
#endif
}
#endif
if (applet->need_suid == _BB_SUID_ALWAYS) {
if (geteuid () != 0)
bb_error_msg_and_die ("This applet requires root privileges!");
} else if (applet->need_suid == _BB_SUID_NEVER) {
setgid (rgid); /* drop all privileges */
setuid (ruid);
}
if (applet->need_suid == _BB_SUID_ALWAYS) {
/* Real uid is not 0. If euid isn't 0 too, suid bit
* is most probably not set on our executable */
if (geteuid())
bb_error_msg_and_die("applet requires root privileges!");
} else if (applet->need_suid == _BB_SUID_NEVER) {
xsetgid(rgid); /* drop all privileges */
xsetuid(ruid);
}
}
#else
#define check_suid(x)
#endif /* CONFIG_FEATURE_SUID */
#define check_suid(x) ((void)0)
#endif /* FEATURE_SUID */
#if ENABLE_FEATURE_COMPRESS_USAGE
#include "usage_compressed.h"
#include "unarchive.h"
void bb_show_usage (void)
static const char *unpack_usage_messages(void)
{
const char *format_string;
const char *usage_string = usage_messages;
int i;
char *outbuf = NULL;
bunzip_data *bd;
int i;
for (i = applet_using - applets; i > 0;) {
if (!*usage_string++) {
--i;
i = start_bunzip(&bd,
/* src_fd: */ -1,
/* inbuf: */ packed_usage,
/* len: */ sizeof(packed_usage));
/* read_bunzip can longjmp to start_bunzip, and ultimately
* end up here with i != 0 on read data errors! Not trivial */
if (!i) {
/* Cannot use xmalloc: will leak bd in NOFORK case! */
outbuf = malloc_or_warn(SIZEOF_usage_messages);
if (outbuf)
read_bunzip(bd, outbuf, SIZEOF_usage_messages);
}
}
dealloc_bunzip(bd);
return outbuf;
}
#define dealloc_usage_messages(s) free(s)
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);
#else
exit (bb_default_error_retval);
#define unpack_usage_messages() usage_messages
#define dealloc_usage_messages(s) ((void)(s))
#endif /* FEATURE_COMPRESS_USAGE */
void bb_show_usage(void)
{
if (ENABLE_SHOW_USAGE) {
const char *format_string;
const char *p;
const char *usage_string = p = unpack_usage_messages();
int i;
i = current_applet - applets;
while (i) {
while (*p++) continue;
i--;
}
fprintf(stderr, "%s multi-call binary\n", bb_banner);
format_string = "\nUsage: %s %s\n\n";
if (*p == '\b')
format_string = "\nNo help available.\n\n";
fprintf(stderr, format_string, applet_name, p);
dealloc_usage_messages((char*)usage_string);
}
xfunc_die();
}
static int applet_name_compare (const void *x, const void *y)
{
const char *name = x;
const struct BB_applet *applet = y;
return strcmp (name, applet->name);
static int applet_name_compare(const void *name, const void *vapplet)
{
const struct bb_applet *applet = vapplet;
return strcmp(name, applet->name);
}
extern const size_t NUM_APPLETS;
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),
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)) 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) {
bb_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));
}
return bsearch(name, applets, ARRAY_SIZE(applets)-1, sizeof(applets[0]),
applet_name_compare);
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
#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");
}
-157
View File
@@ -1,157 +0,0 @@
/* vi: set sw=4 ts=4: */
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include "busybox.h"
#if ENABLE_LOCALE_SUPPORT
#include <locale.h>
#else
#define setlocale(x,y)
#endif
const char *bb_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_f)(const char *, const char *);
/* create (sym)links for each applet */
static void install_links(const char *busybox, int use_symbolic_links)
{
__link_f Link = link;
char *fpc;
int i;
int rc;
if (use_symbolic_links)
Link = symlink;
for (i = 0; applets[i].name != NULL; i++) {
fpc = concat_path_file(
install_dir[applets[i].location], applets[i].name);
rc = Link(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;
bb_applet_name=argv[0];
if (*bb_applet_name == '-') bb_applet_name++;
for (s = bb_applet_name; *s ;)
if (*(s++) == '/') bb_applet_name = s;
/* Set locale for everybody except `init' */
if(ENABLE_LOCALE_SUPPORT && getpid() != 1)
setlocale(LC_ALL, "");
run_applet_by_name(bb_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;
int rc = 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 */
busybox = xreadlink("/proc/self/exe");
if (busybox) {
install_links(busybox, use_symbolic_links);
free(busybox);
} else {
rc = 1;
}
return rc;
}
/* Deal with --help. (Also print help when called with no arguments) */
if (argc==1 || !strcmp(argv[1],"--help") ) {
if (argc>2) {
run_applet_by_name(bb_applet_name=argv[2], 2, argv);
} else {
const struct BB_applet *a;
int col, output_width;
if (ENABLE_FEATURE_AUTOWIDTH) {
/* Obtain the terminal width. */
get_terminal_width_height(0, &output_width, NULL);
/* leading tab and room to wrap */
output_width -= 20;
} else output_width = 60;
printf("%s\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);
if (col > output_width && a->name) {
printf(",\n");
col = 0;
}
}
printf("\n\n");
exit(0);
}
} else run_applet_by_name(bb_applet_name=argv[1], argc-1, argv+1);
bb_error_msg_and_die("applet not found");
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+1 -1
View File
@@ -10,7 +10,7 @@
export LC_ALL=POSIX
export LC_CTYPE=POSIX
CONFIG_H=${1:-include/bb_config.h}
CONFIG_H=${1:-include/autoconf.h}
APPLETS_H=${2:-include/applets.h}
$HOSTCC -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
awk '/^[ \t]*LINK/{
+26
View File
@@ -0,0 +1,26 @@
/* Minimal wrapper to build an individual busybox applet.
*
* Copyright 2005 Rob Landley <rob@landley.net
*
* Licensed under GPL version 2, see file LICENSE in this tarball for details
*/
const char *applet_name;
#include <stdio.h>
#include <stdlib.h>
#include "usage.h"
int main(int argc, char **argv)
{
applet_name = argv[0];
return APPLET_main(argc,argv);
}
void bb_show_usage(void)
{
printf(APPLET_full_usage "\n");
exit(1);
}
+41 -17
View File
@@ -5,18 +5,22 @@ export LC_CTYPE=POSIX
prefix=${1}
if [ -z "$prefix" ]; then
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]"
exit 1;
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]"
exit 1;
fi
h=`sort busybox.links | uniq`
cleanup="0"
noclobber="0"
case "$2" in
--hardlinks) linkopts="-f";;
--symlinks) linkopts="-fs";;
"") h="";;
*) echo "Unknown install option: $2"; exit 1;;
--hardlinks) linkopts="-f";;
--symlinks) linkopts="-fs";;
--cleanup) cleanup="1";;
--noclobber) noclobber="1";;
"") h="";;
*) echo "Unknown install option: $2"; exit 1;;
esac
if [ "$DO_INSTALL_LIBS" != "n" ]; then
if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
# get the target dir for the libs
# assume it starts with lib
libdir=$($CC -print-file-name=libc.so | \
@@ -34,37 +38,57 @@ if [ "$DO_INSTALL_LIBS" != "n" ]; then
fi
done
fi
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
pd=$PWD
if [ -d "$d" ]; then
cd $d
ls -iL . | grep "^ *$inode" | awk '{print $2}' | env -i xargs rm -f
fi
cd "$pd"
done
`
fi
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
bb_path="$prefix/bin/busybox"
bb_path="$prefix/bin/busybox"
else
case "$appdir" in
case "$appdir" in
/)
bb_path="bin/busybox"
bb_path="bin/busybox"
;;
/bin)
bb_path="busybox"
bb_path="busybox"
;;
/sbin)
bb_path="../bin/busybox"
bb_path="../bin/busybox"
;;
/usr/bin|/usr/sbin)
bb_path="../../bin/busybox"
bb_path="../../bin/busybox"
;;
*)
echo "Unknown installation directory: $appdir"
exit 1
;;
esac
esac
fi
if [ "$noclobber" = "0" ] || [ ! -e "$prefix$i" ]; then
echo " $prefix$i -> $bb_path"
ln $linkopts $bb_path $prefix$i || exit 1
else
echo " $prefix$i already exists"
fi
echo " $prefix$i -> $bb_path"
ln $linkopts $bb_path $prefix$i || exit 1
done
exit 0
+18
View File
@@ -0,0 +1,18 @@
/* 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"
static const char usage_messages[] = ""
#define MAKE_USAGE
#include "usage.h"
#include "applets.h"
;
int main(void)
{
write(1, usage_messages, sizeof(usage_messages));
return 0;
}
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
target="$1"
loc="$2"
test "$target" || exit 1
test "$loc" || loc=.
test -x "$loc/usage" || exit 1
test "$SED" || SED=sed
sz=`"$loc/usage" | wc -c` || exit 1
exec >"$target"
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"/'
echo ';'
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
-10
View File
@@ -1,10 +0,0 @@
#include "busybox.h"
#ifndef BB_EXTRA_VERSION
#define BANNER "BusyBox v" BB_VER " (" BB_BT ")"
#else
#define BANNER "BusyBox v" BB_VER " (" BB_EXTRA_VERSION ")"
#endif
const char BB_BANNER[]=BANNER;
const char * const bb_msg_full_version = BANNER " multi-call binary";
+7
View File
@@ -0,0 +1,7 @@
# ==========================================================================
# Build system
# ==========================================================================
# -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,)
+87 -71
View File
@@ -5,7 +5,7 @@
menu "Archival Utilities"
config CONFIG_AR
config AR
bool "ar"
default n
help
@@ -28,17 +28,17 @@ config CONFIG_AR
Unless you have a specific application which requires ar, you should
probably say N here.
config CONFIG_FEATURE_AR_LONG_FILENAMES
bool " Enable support for long filenames (not need for debs)"
config FEATURE_AR_LONG_FILENAMES
bool "Enable support for long filenames (not need for debs)"
default n
depends on CONFIG_AR
depends on AR
help
By default the ar format can only store the first 15 characters of the
filename, this option removes that limitation.
It supports the GNU ar long filename method which moves multiple long
filenames into a the data section of a new ar entry.
config CONFIG_BUNZIP2
config BUNZIP2
bool "bunzip2"
default n
help
@@ -54,7 +54,7 @@ config CONFIG_BUNZIP2
Unless you have a specific application which requires bunzip2, you
should probably say N here.
config CONFIG_CPIO
config CPIO
bool "cpio"
default n
help
@@ -68,7 +68,7 @@ config CONFIG_CPIO
Unless you have a specific application which requires cpio, you should
probably say N here.
config CONFIG_DPKG
config DPKG
bool "dpkg"
default n
help
@@ -77,7 +77,7 @@ config CONFIG_DPKG
This implementation of dpkg has a number of limitations, you should use the
official dpkg if possible.
config CONFIG_DPKG_DEB
config DPKG_DEB
bool "dpkg_deb"
default n
help
@@ -88,16 +88,16 @@ config CONFIG_DPKG_DEB
Unless you have a specific application which requires dpkg-deb, you should
probably say N here.
config CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
bool " extract only (-x)"
config FEATURE_DPKG_DEB_EXTRACT_ONLY
bool "extract only (-x)"
default n
depends on CONFIG_DPKG_DEB
depends on DPKG_DEB
help
This reduces dpkg-deb to the equivalent of "ar -p <deb> data.tar.gz | tar -zx".
However it saves space as none of the extra dpkg-deb, ar or tar options are
needed, they are linked to internally.
config CONFIG_GUNZIP
config GUNZIP
bool "gunzip"
default n
help
@@ -105,35 +105,42 @@ config CONFIG_GUNZIP
You can use the `-t' option to test the integrity of
an archive, without decompressing it.
config CONFIG_FEATURE_GUNZIP_UNCOMPRESS
bool " Uncompress support"
config FEATURE_GUNZIP_UNCOMPRESS
bool "Uncompress support"
default n
depends on CONFIG_GUNZIP
depends on GUNZIP
help
Enable if you want gunzip to have the ability to decompress
archives created by the program compress (not much
used anymore).
config CONFIG_GZIP
config GZIP
bool "gzip"
default n
help
gzip is used to compress files.
It's probably the most widely used UNIX compression program.
config CONFIG_RPM2CPIO
config RPM2CPIO
bool "rpm2cpio"
default n
help
Converts an RPM file into a CPIO archive.
config CONFIG_RPM
config RPM
bool "rpm"
default n
help
Mini RPM applet - queries and extracts
Mini RPM applet - queries and extracts RPM packages.
config CONFIG_TAR
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
help
@@ -141,86 +148,95 @@ config CONFIG_TAR
create compressed archives. It's probably the most widely used
UNIX archive program.
config CONFIG_FEATURE_TAR_CREATE
bool " Enable archive creation"
config FEATURE_TAR_CREATE
bool "Enable archive creation"
default y
depends on CONFIG_TAR
depends on TAR
help
If you enable this option you'll be able to create
tar archives using the `-c' option.
config CONFIG_FEATURE_TAR_BZIP2
bool " Enable -j option to handle .tar.bz2 files"
config FEATURE_TAR_BZIP2
bool "Enable -j option to handle .tar.bz2 files"
default n
depends on CONFIG_TAR
depends on TAR
help
If you enable this option you'll be able to extract
archives compressed with bzip2.
config CONFIG_FEATURE_TAR_LZMA
bool " Enable -a option to handle .tar.lzma files"
config FEATURE_TAR_LZMA
bool "Enable -a option to handle .tar.lzma files"
default n
depends on CONFIG_TAR
depends on TAR
help
If you enable this option you'll be able to extract
archives compressed with lzma.
config CONFIG_FEATURE_TAR_FROM
bool " Enable -X (exclude from) and -T (include from) options)"
config FEATURE_TAR_FROM
bool "Enable -X (exclude from) and -T (include from) options)"
default n
depends on CONFIG_TAR
depends on TAR
help
If you enable this option you'll be able to specify
a list of files to include or exclude from an archive.
config CONFIG_FEATURE_TAR_GZIP
bool " Enable -z option"
config FEATURE_TAR_GZIP
bool "Enable -z option"
default y
depends on CONFIG_TAR
depends on TAR
help
If you enable this option tar will be able to call gzip,
when creating or extracting tar gziped archives.
config CONFIG_FEATURE_TAR_COMPRESS
bool " Enable -Z option"
config FEATURE_TAR_COMPRESS
bool "Enable -Z option"
default n
depends on CONFIG_TAR
depends on TAR
help
If you enable this option tar will be able to call uncompress,
when extracting .tar.Z archives.
config CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
bool " Enable support for old tar header format"
config FEATURE_TAR_OLDGNU_COMPATIBILITY
bool "Enable support for old tar header format"
default N
depends on CONFIG_TAR
depends on TAR
help
This option is required to unpack archives created in
the old GNU format; help to kill this old format by
repacking your ancient archives with the new format.
config CONFIG_FEATURE_TAR_GNU_EXTENSIONS
bool " Enable support for some GNU tar extensions"
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
depends on CONFIG_TAR
depends on TAR
help
With this option busybox supports GNU long filenames and
linknames.
config CONFIG_FEATURE_TAR_LONG_OPTIONS
bool " Enable long options"
config FEATURE_TAR_LONG_OPTIONS
bool "Enable long options"
default n
depends on CONFIG_TAR
depends on TAR && GETOPT_LONG
help
Enable use of long options, increases size by about 400 Bytes
config CONFIG_UNCOMPRESS
config UNCOMPRESS
bool "uncompress"
default n
help
uncompress is used to decompress archives created by compress.
Not much used anymore, replaced by gzip/gunzip.
config CONFIG_UNLZMA
config UNLZMA
bool "unlzma"
default n
help
@@ -235,15 +251,15 @@ config CONFIG_UNLZMA
Unless you have a specific application which requires unlzma, you
should probably say N here.
config CONFIG_FEATURE_LZMA_FAST
bool " Optimze unlzma for speed"
config FEATURE_LZMA_FAST
bool "Optimze unlzma for speed"
default n
depends on CONFIG_UNLZMA
depends on UNLZMA
help
This option reduce decompression time by about 33% at the cost of
This option reduces decompression time by about 33% at the cost of
a 2K bigger binary.
config CONFIG_UNZIP
config UNZIP
bool "unzip"
default n
help
@@ -254,31 +270,31 @@ config CONFIG_UNZIP
directory of your choice.
comment "Common options for cpio and tar"
depends on CONFIG_CPIO || CONFIG_TAR
depends on CPIO || TAR
config CONFIG_FEATURE_UNARCHIVE_TAPE
bool " Enable tape drive support"
config FEATURE_UNARCHIVE_TAPE
bool "Enable tape drive support"
default n
depends on CONFIG_CPIO || CONFIG_TAR
depends on CPIO || TAR
help
I don't think this is needed anymore.
comment "Common options for dpkg and dpkg_deb"
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
depends on DPKG || DPKG_DEB
config CONFIG_FEATURE_DEB_TAR_GZ
bool " gzip debian packages (normal)"
default y if CONFIG_DPKG || CONFIG_DPKG_DEB
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
config FEATURE_DEB_TAR_GZ
bool "gzip debian packages (normal)"
default y if DPKG || DPKG_DEB
depends on DPKG || DPKG_DEB
help
This is the default compression method inside the debian ar file.
If you want compatibility with standard .deb's you should say yes here.
config CONFIG_FEATURE_DEB_TAR_BZ2
bool " bzip2 debian packages"
config FEATURE_DEB_TAR_BZ2
bool "bzip2 debian packages"
default n
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
depends on DPKG || DPKG_DEB
help
This allows dpkg and dpkg-deb to extract deb's that are compressed internally
with bzip2 instead of gzip.
@@ -286,15 +302,15 @@ config CONFIG_FEATURE_DEB_TAR_BZ2
You only want this if you are creating your own custom debian packages that
use an internal control.tar.bz2 or data.tar.bz2.
config CONFIG_FEATURE_DEB_TAR_LZMA
bool " lzma debian packages"
config FEATURE_DEB_TAR_LZMA
bool "lzma debian packages"
default n
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
depends on DPKG || DPKG_DEB
help
This allows dpkg and dpkg-deb to extract deb's that are compressed
internally with lzma instead of gzip.
internally with lzma instead of gzip.
You only want this if you are creating your own custom debian
packages that use an internal control.tar.lzma or data.tar.lzma.
packages that use an internal control.tar.lzma or data.tar.lzma.
endmenu
+22
View File
@@ -0,0 +1,22 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
libs-y += libunarchive/
lib-y:=
lib-$(CONFIG_AR) += ar.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) += 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) += bbunzip.o
lib-$(CONFIG_UNZIP) += unzip.o
-23
View File
@@ -1,23 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
ifndef top_srcdir
top_srcdir=..
endif
ifndef top_builddir
top_builddir=..
endif
ARCHIVAL_DIR:=./
srcdir=$(top_srcdir)/archival
include $(top_builddir)/Rules.mak
include $(top_builddir)/.config
include $(srcdir)/Makefile.in
all: $(libraries-y)
-include $(top_builddir)/.depend
clean:
rm -f *.o *.a $(AR_TARGET)
-42
View File
@@ -1,42 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
ARCHIVAL_AR:=archival.a
ifndef $(ARCHIVAL_DIR)
ARCHIVAL_DIR:=$(top_builddir)/archival/
endif
srcdir=$(top_srcdir)/archival
ARCHIVAL-y:=
ARCHIVAL-$(CONFIG_APT_GET) +=
ARCHIVAL-$(CONFIG_AR) += ar.o
ARCHIVAL-$(CONFIG_BUNZIP2) += bunzip2.o
ARCHIVAL-$(CONFIG_UNLZMA) += unlzma.o
ARCHIVAL-$(CONFIG_CPIO) += cpio.o
ARCHIVAL-$(CONFIG_DPKG) += dpkg.o
ARCHIVAL-$(CONFIG_DPKG_DEB) += dpkg_deb.o
ARCHIVAL-$(CONFIG_GUNZIP) += gunzip.o
ARCHIVAL-$(CONFIG_GZIP) += gzip.o
ARCHIVAL-$(CONFIG_RPM2CPIO) += rpm2cpio.o
ARCHIVAL-$(CONFIG_RPM) += rpm.o
ARCHIVAL-$(CONFIG_TAR) += tar.o
ARCHIVAL-$(CONFIG_UNCOMPRESS) += uncompress.o
ARCHIVAL-$(CONFIG_UNZIP) += unzip.o
ifneq ($(strip $(ARCHIVAL-y)),)
libraries-y+=$(ARCHIVAL_DIR)$(ARCHIVAL_AR)
endif
ARCHIVAL_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(ARCHIVAL-y))
ARCHIVAL_SRC-a:=$(wildcard $(srcdir)/*.c)
APPLET_SRC-y+=$(ARCHIVAL_SRC-y)
APPLET_SRC-a+=$(ARCHIVAL_SRC-a)
$(ARCHIVAL_DIR)$(ARCHIVAL_AR): $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
$(do_ar)
$(ARCHIVAL_DIR)%.o: $(srcdir)/%.c
$(compile.c)
+17 -33
View File
@@ -7,35 +7,15 @@
*
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* There is no single standard to adhere to so ar may not portable
* between different systems
* http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
*/
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <utime.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h"
#include "busybox.h"
static void header_verbose_list_ar(const file_header_t *file_header)
{
@@ -46,7 +26,8 @@ static void header_verbose_list_ar(const file_header_t *file_header)
mtime[16] = ' ';
memmove(&mtime[17], &mtime[20], 4);
mtime[21] = '\0';
printf("%s %d/%d%7d %s %s\n", &mode[1], file_header->uid, file_header->gid, (int) file_header->size, &mtime[4], file_header->name);
printf("%s %d/%d%7d %s %s\n", &mode[1], file_header->uid, file_header->gid,
(int) file_header->size, &mtime[4], file_header->name);
}
#define AR_CTX_PRINT 0x01
@@ -57,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 long opt;
static const char msg_unsupported_err[] =
"Archive %s not supported. Install binutils 'ar'.";
unsigned opt;
char magic[8];
archive_handle = init_handle();
/* Prepend '-' to the first argument if required */
bb_opt_complementally = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
opt = bb_getopt_ulflags(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;
@@ -93,20 +76,21 @@ int ar_main(int argc, char **argv)
bb_error_msg_and_die(msg_unsupported_err, "insertion");
}
archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
archive_handle->src_fd = xopen(argv[optind++], O_RDONLY);
while (optind < argc) {
archive_handle->filter = filter_accept_list;
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind++]);
llist_add_to(&(archive_handle->accept), argv[optind++]);
}
archive_xread_all(archive_handle, magic, 7);
xread(archive_handle->src_fd, magic, 7);
if (strncmp(magic, "!<arch>", 7) != 0) {
bb_error_msg_and_die("Invalid ar magic");
bb_error_msg_and_die("invalid ar magic");
}
archive_handle->offset += 7;
while (get_header_ar(archive_handle) == EXIT_SUCCESS);
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
-65
View File
@@ -1,65 +0,0 @@
/*
* Modified for busybox by Glenn McGrath <bug1@iinet.net.au>
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
*
* Licensed under GPL v2, see file LICENSE in this tarball for details.
*/
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
#include "unarchive.h"
#define BUNZIP2_OPT_STDOUT 1
#define BUNZIP2_OPT_FORCE 2
int bunzip2_main(int argc, char **argv)
{
char *filename;
unsigned long opt;
int status, src_fd, dst_fd;
opt = bb_getopt_ulflags(argc, argv, "cf");
/* Set input filename and number */
filename = argv[optind];
if ((filename) && (filename[0] != '-') && (filename[1] != '\0')) {
/* Open input file */
src_fd = bb_xopen(filename, O_RDONLY);
} else {
src_fd = STDIN_FILENO;
filename = 0;
}
/* if called as bzcat force the stdout flag */
if ((opt & BUNZIP2_OPT_STDOUT) || bb_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) {
char *extension=filename+strlen(filename)-4;
if (strcmp(extension, ".bz2") != 0) {
bb_error_msg_and_die("Invalid extension");
}
*extension=0;
dst_fd = bb_xopen(filename, O_WRONLY | O_CREAT);
} else dst_fd = STDOUT_FILENO;
status = uncompressStream(src_fd, dst_fd);
if(filename) {
if (!status) filename[strlen(filename)]='.';
if (unlink(filename) < 0) {
bb_error_msg_and_die("Couldn't remove %s", filename);
}
}
return status;
}
/* vi:set ts=4: */
+16 -31
View File
@@ -4,53 +4,38 @@
*
* Copyright (C) 2001 by Glenn McGrath
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* Limitations:
* Doesn't check CRC's
* Only supports new ASCII and CRC formats
*
*/
#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;
char *cpio_filename = NULL;
unsigned long opt;
unsigned opt;
/* Initialise */
archive_handle = init_handle();
archive_handle->src_fd = STDIN_FILENO;
archive_handle->seek = seek_by_char;
archive_handle->seek = seek_by_read;
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
opt = bb_getopt_ulflags(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) {
@@ -79,7 +64,7 @@ int cpio_main(int argc, char **argv)
}
}
if (cpio_filename) { /* CPIO_OPT_FILE */
archive_handle->src_fd = bb_xopen(cpio_filename, O_RDONLY);
archive_handle->src_fd = xopen(cpio_filename, O_RDONLY);
archive_handle->seek = seek_by_jump;
}
if (opt & CPIO_OPT_CREATE_LEADING_DIR) {
@@ -88,11 +73,11 @@ int cpio_main(int argc, char **argv)
while (optind < argc) {
archive_handle->filter = filter_accept_list;
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]);
llist_add_to(&(archive_handle->accept), argv[optind]);
optind++;
}
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
return(EXIT_SUCCESS);
return EXIT_SUCCESS;
}
+519 -600
View File
File diff suppressed because it is too large. Load diff
+21 -35
View File
@@ -1,26 +1,11 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* dpkg-deb packs, unpacks and provides information about Debian archives.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h"
#include "busybox.h"
#define DPKG_DEB_OPT_CONTENTS 1
#define DPKG_DEB_OPT_CONTROL 2
@@ -28,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 long opt;
char *extract_dir = NULL;
unsigned opt;
const char *extract_dir = NULL;
short argcount = 1;
/* Setup the tar archive handle */
@@ -45,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
ar_archive->accept = llist_add_to(NULL, "data.tar.gz");
control_tar_llist = llist_add_to(NULL, "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
ar_archive->accept = llist_add_to(ar_archive->accept, "data.tar.bz2");
control_tar_llist = 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
bb_opt_complementally = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
opt = bb_getopt_ulflags(argc, argv, "cefXx");
opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
opt = getopt32(argv, "cefXx");
if (opt & DPKG_DEB_OPT_CONTENTS) {
tar_archive->action_header = header_verbose_list;
@@ -75,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;
tar_archive->accept = llist_add_to(NULL, "./control");
llist_add_to(&(tar_archive->accept), (char*)"./control");
tar_archive->filter = filter_accept_list;
tar_archive->action_data = data_extract_to_stdout;
}
@@ -91,7 +77,7 @@ int dpkg_deb_main(int argc, char **argv)
bb_show_usage();
}
tar_archive->src_fd = ar_archive->src_fd = bb_xopen(argv[optind++], O_RDONLY);
tar_archive->src_fd = ar_archive->src_fd = xopen(argv[optind++], O_RDONLY);
/* Workout where to extract the files */
/* 2nd argument is a dir name */
@@ -99,13 +85,13 @@ int dpkg_deb_main(int argc, char **argv)
extract_dir = argv[optind];
}
if (extract_dir) {
mkdir(extract_dir, 0777);
chdir(extract_dir);
mkdir(extract_dir, 0777); /* bb_make_directory(extract_dir, 0777, 0) */
xchdir(extract_dir);
}
unpack_ar_archive(ar_archive);
/* Cleanup */
close (ar_archive->src_fd);
close(ar_archive->src_fd);
return(EXIT_SUCCESS);
return EXIT_SUCCESS;
}
-195
View File
@@ -1,195 +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>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* 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 0
static char *license_msg[] = {
" Copyright (C) 1992-1993 Jean-loup Gailly",
" This program is free software; you can redistribute it and/or modify",
" it under the terms of the GNU General Public License as published by",
" the Free Software Foundation; either version 2, or (at your option)",
" any later version.",
"",
" This program is distributed in the hope that it will be useful,",
" but WITHOUT ANY WARRANTY; without even the implied warranty of",
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
" GNU General Public License for more details.",
"",
" You should have received a copy of the GNU General Public License",
" along with this program; if not, write to the Free Software",
" Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.",
0
};
#endif
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#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
int gunzip_main(int argc, char **argv)
{
char status = EXIT_SUCCESS;
unsigned long opt;
opt = bb_getopt_ulflags(argc, argv, "cftd");
/* if called as zcat */
if (strcmp(bb_applet_name, "zcat") == 0) {
opt |= GUNZIP_OPT_STDOUT;
}
do {
struct stat stat_buf;
const char *old_path = argv[optind];
const char *delete_path = NULL;
char *new_path = NULL;
int src_fd;
int dst_fd;
optind++;
if (old_path == NULL || strcmp(old_path, "-") == 0) {
src_fd = STDIN_FILENO;
opt |= GUNZIP_OPT_STDOUT;
} else {
src_fd = bb_xopen(old_path, O_RDONLY);
/* Get the time stamp on the input file. */
xstat(old_path, &stat_buf);
}
/* Check that the input is sane. */
if (isatty(src_fd) && ((opt & GUNZIP_OPT_FORCE) == 0)) {
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 = bb_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 = bb_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 {
bb_error_msg_and_die("Invalid extension");
}
/* Open output file */
dst_fd = bb_xopen(new_path, O_WRONLY | O_CREAT);
/* Set permissions on the file */
chmod(new_path, stat_buf.st_mode);
/* If unzip succeeds remove the old file */
delete_path = old_path;
}
/* do the decompression, and cleanup */
if (bb_xread_char(src_fd) == 0x1f) {
unsigned char magic2;
magic2 = bb_xread_char(src_fd);
#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
if (magic2 == 0x9d) {
status = uncompress(src_fd, dst_fd);
} else
#endif
if (magic2 == 0x8b) {
check_header_gzip(src_fd);
status = inflate_gunzip(src_fd, dst_fd);
if (status != 0) {
bb_error_msg_and_die("Error inflating");
}
} else {
bb_error_msg_and_die("Invalid magic");
}
} else {
bb_error_msg_and_die("Invalid magic");
}
if ((status != EXIT_SUCCESS) && (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_and_die("Couldn't remove %s", delete_path);
}
free(new_path);
} while (optind < argc);
return status;
}
+1166 -1597
View File
File diff suppressed because it is too large. Load diff
+68
View File
@@ -0,0 +1,68 @@
# Makefile for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
lib-y:= \
\
data_skip.o \
data_extract_all.o \
data_extract_to_stdout.o \
data_extract_to_buffer.o \
\
filter_accept_all.o \
filter_accept_list.o \
filter_accept_reject_list.o \
\
header_skip.o \
header_list.o \
header_verbose_list.o \
\
archive_xread_all_eof.o \
\
seek_by_read.o \
seek_by_jump.o \
\
data_align.o \
find_list_entry.o \
init_handle.o
GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o
DPKG_FILES:= \
get_header_ar.o \
unpack_ar_archive.o \
get_header_tar.o \
filter_accept_list_reassign.o
lib-$(CONFIG_RPM) += open_transformer.o
lib-$(CONFIG_FEATURE_TAR_BZIP2) += open_transformer.o
lib-$(CONFIG_FEATURE_TAR_LZMA) += open_transformer.o
lib-$(CONFIG_FEATURE_TAR_GZIP) += open_transformer.o
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += open_transformer.o
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += open_transformer.o
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += open_transformer.o
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += open_transformer.o
lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
lib-$(CONFIG_CPIO) += get_header_cpio.o
lib-$(CONFIG_DPKG) += $(DPKG_FILES)
lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
lib-$(CONFIG_FEATURE_RPM_BZ2) += decompress_bunzip2.o
lib-$(CONFIG_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
-36
View File
@@ -1,36 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
ifndef top_srcdir
top_srcdir=../..
endif
ifndef top_builddir
top_builddir=../..
endif
srcdir=$(top_srcdir)/archival/libunarchive
LIBUNARCHIVE_DIR:=./
include $(top_builddir)/Rules.mak
include $(top_builddir)/.config
include $(srcdir)/Makefile.in
all: $(libraries-y)
-include $(top_builddir)/.depend
clean:
rm -f *.o *.a $(AR_TARGET)
-83
View File
@@ -1,83 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
LIBUNARCHIVE_AR:=libunarchive.a
ifndef $(LIBUNARCHIVE_DIR)
LIBUNARCHIVE_DIR:=$(top_builddir)/archival/libunarchive
endif
srcdir=$(top_srcdir)/archival/libunarchive
LIBUNARCHIVE-obj:=$(LIBUNARCHIVE_DIR)/$(LIBUNARCHIVE_AR)
libraries-y+=$(LIBUNARCHIVE-obj)
LIBUNARCHIVE-y:= \
\
data_skip.o \
data_extract_all.o \
data_extract_to_stdout.o \
data_extract_to_buffer.o \
\
filter_accept_all.o \
filter_accept_list.o \
filter_accept_reject_list.o \
\
header_skip.o \
header_list.o \
header_verbose_list.o \
\
archive_xread_all.o \
archive_xread_all_eof.o \
\
seek_by_char.o \
seek_by_jump.o \
\
data_align.o \
find_list_entry.o \
open_transformer.o \
init_handle.o
GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o
DPKG_FILES:= \
get_header_ar.o \
unpack_ar_archive.o \
get_header_tar.o \
filter_accept_list_reassign.o
LIBUNARCHIVE-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
LIBUNARCHIVE-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
LIBUNARCHIVE-$(CONFIG_UNLZMA) += decompress_unlzma.o
LIBUNARCHIVE-$(CONFIG_CPIO) += get_header_cpio.o
LIBUNARCHIVE-$(CONFIG_DPKG) += $(DPKG_FILES)
LIBUNARCHIVE-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
LIBUNARCHIVE-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
LIBUNARCHIVE-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
LIBUNARCHIVE-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
LIBUNARCHIVE-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
LIBUNARCHIVE-$(CONFIG_TAR) += get_header_tar.o
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
LIBUNARCHIVE-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
LIBUNARCHIVE-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
LIBUNARCHIVE-y:=$(sort $(LIBUNARCHIVE-y))
LIBUNARCHIVE_SRC-y:=$(patsubst %,$(srcdir)/%,$(subst .o,.c,$(LIBUNARCHIVE-y)))
LIBUNARCHIVE_SRC-a:=$(wildcard $(srcdir)/*.c)
LIBRARY_SRC-y+=$(LIBUNARCHIVE_SRC-y)
LIBRARY_SRC-a+=$(LIBUNARCHIVE_SRC-a)
$(LIBUNARCHIVE_DIR)/$(LIBUNARCHIVE_AR): $(patsubst %,$(LIBUNARCHIVE_DIR)/%,$(LIBUNARCHIVE-y))
$(do_ar)
$(LIBUNARCHIVE_DIR)/%.o: $(srcdir)/%.c
$(compile.c)
-32
View File
@@ -1,32 +0,0 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "unarchive.h"
#include "libbb.h"
void archive_xread_all(const archive_handle_t *archive_handle, void *buf, const size_t count)
{
ssize_t size;
size = bb_full_read(archive_handle->src_fd, buf, count);
if (size != count) {
bb_error_msg_and_die("Short read");
}
return;
}
+10 -22
View File
@@ -1,32 +1,20 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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)
ssize_t archive_xread_all_eof(archive_handle_t *archive_handle,
unsigned char *buf, size_t count)
{
ssize_t size;
size = bb_full_read(archive_handle->src_fd, buf, count);
if ((size != 0) && (size != count)) {
bb_perror_msg_and_die("Short read, read %ld of %ld", (long)size, (long)count);
size = full_read(archive_handle->src_fd, buf, count);
if (size != 0 && size != count) {
bb_error_msg_and_die("short read: %u of %u",
(unsigned)size, (unsigned)count);
}
return(size);
return size;
}
+24 -23
View File
@@ -1,9 +1,12 @@
#include <stdlib.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h" /* for external decl of check_header_gzip */
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
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];
@@ -13,46 +16,44 @@ void check_header_gzip(int src_fd)
unsigned int mtime;
unsigned char xtra_flags;
unsigned char os_flags;
} formated;
} formatted;
} header;
bb_xread_all(src_fd, header.raw, 8);
xread(src_fd, header.raw, 8);
/* Check the compression method */
if (header.formated.method != 8) {
bb_error_msg_and_die("Unknown compression method %d",
header.formated.method);
if (header.formatted.method != 8) {
bb_error_msg_and_die("unknown compression method %d",
header.formatted.method);
}
if (header.formated.flags & 0x04) {
if (header.formatted.flags & 0x04) {
/* bit 2 set: extra field present */
unsigned char extra_short;
unsigned extra_short;
extra_short = bb_xread_char(src_fd) + (bb_xread_char(src_fd) << 8);
extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8);
while (extra_short > 0) {
/* Ignore extra field */
bb_xread_char(src_fd);
xread_char(src_fd);
extra_short--;
}
}
/* Discard original name if any */
if (header.formated.flags & 0x08) {
if (header.formatted.flags & 0x08) {
/* bit 3 set: original file name present */
while(bb_xread_char(src_fd) != 0);
while (xread_char(src_fd) != 0);
}
/* Discard file comment if any */
if (header.formated.flags & 0x10) {
if (header.formatted.flags & 0x10) {
/* bit 4 set: file comment present */
while(bb_xread_char(src_fd) != 0);
while (xread_char(src_fd) != 0);
}
/* Read the header checksum */
if (header.formated.flags & 0x02) {
bb_xread_char(src_fd);
bb_xread_char(src_fd);
if (header.formatted.flags & 0x02) {
xread_char(src_fd);
xread_char(src_fd);
}
return;
}
+3 -19
View File
@@ -1,23 +1,9 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* 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"
@@ -28,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;
}
+78 -75
View File
@@ -1,29 +1,8 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <sys/types.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <utime.h>
#include <unistd.h>
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
@@ -34,16 +13,20 @@ void data_extract_all(archive_handle_t *archive_handle)
int res;
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
char *name = bb_xstrdup(file_header->name);
bb_make_directory (dirname(name), -1, FILEUTILS_RECUR);
char *name = xstrdup(file_header->name);
bb_make_directory(dirname(name), -1, FILEUTILS_RECUR);
free(name);
}
/* Check if the file already exists */
if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
/* Remove the existing entry if it exists */
if (((file_header->mode & S_IFMT) != S_IFDIR) && (unlink(file_header->name) == -1) && (errno != ENOENT)) {
bb_perror_msg_and_die("Couldnt remove old file");
if (((file_header->mode & S_IFMT) != S_IFDIR)
&& (unlink(file_header->name) == -1)
&& (errno != ENOENT)
) {
bb_perror_msg_and_die("cannot remove old file %s",
file_header->name);
}
}
else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) {
@@ -51,78 +34,98 @@ void data_extract_all(archive_handle_t *archive_handle)
struct stat statbuf;
if (lstat(file_header->name, &statbuf) == -1) {
if (errno != ENOENT) {
bb_perror_msg_and_die("Couldnt stat old file");
bb_perror_msg_and_die("cannot stat old file");
}
}
else if (statbuf.st_mtime <= file_header->mtime) {
if (!(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
bb_error_msg("%s not created: newer or same age file exists", file_header->name);
bb_error_msg("%s not created: newer or "
"same age file exists", file_header->name);
}
data_skip(archive_handle);
return;
}
else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) {
bb_perror_msg_and_die("Couldnt remove old file %s", file_header->name);
bb_perror_msg_and_die("cannot remove old file %s",
file_header->name);
}
}
/* 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) && (file_header->size == 0)) {
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("Couldnt 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 */
switch(file_header->mode & S_IFMT) {
case S_IFREG: {
/* Regular file */
dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL);
bb_copyfd_size(archive_handle->src_fd, dst_fd, file_header->size);
close(dst_fd);
break;
}
case S_IFDIR:
res = mkdir(file_header->name, file_header->mode);
if ((errno != EISDIR) && (res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
bb_perror_msg("extract_archive: %s", file_header->name);
}
break;
case S_IFLNK:
/* Symlink */
res = symlink(file_header->link_name, file_header->name);
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name);
}
break;
case S_IFSOCK:
case S_IFBLK:
case S_IFCHR:
case S_IFIFO:
res = mknod(file_header->name, file_header->mode, file_header->device);
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
bb_perror_msg("Cannot create node %s", file_header->name);
}
break;
default:
bb_error_msg_and_die("Unrecognised file type");
switch (file_header->mode & S_IFMT) {
case S_IFREG: {
/* Regular file */
dst_fd = xopen3(file_header->name, O_WRONLY | O_CREAT | O_EXCL,
file_header->mode);
bb_copyfd_exact_size(archive_handle->src_fd, dst_fd, file_header->size);
close(dst_fd);
break;
}
case S_IFDIR:
res = mkdir(file_header->name, file_header->mode);
if ((res == -1) && (errno != EISDIR)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("cannot make dir %s", file_header->name);
}
break;
case S_IFLNK:
/* Symlink */
res = symlink(file_header->link_target, file_header->name);
if ((res == -1)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("cannot create %slink "
"from %s to %s", "sym",
file_header->name,
file_header->link_target);
}
break;
case S_IFSOCK:
case S_IFBLK:
case S_IFCHR:
case S_IFIFO:
res = mknod(file_header->name, file_header->mode, file_header->device);
if ((res == -1)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("cannot create node %s", file_header->name);
}
break;
default:
bb_error_msg_and_die("unrecognized file type");
}
}
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) {
lchown(file_header->name, file_header->uid, file_header->gid);
}
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_PERM) &&
(file_header->mode & S_IFMT) != S_IFLNK)
{
chmod(file_header->name, file_header->mode);
}
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);
}
}
}
+6 -17
View File
@@ -1,17 +1,8 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* Copyright 2002 Glenn McGrath
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
@@ -19,10 +10,8 @@
void data_extract_to_buffer(archive_handle_t *archive_handle)
{
const unsigned int size = archive_handle->file_header->size;
unsigned int size = archive_handle->file_header->size;
archive_handle->buffer = xmalloc(size + 1);
archive_xread_all(archive_handle, archive_handle->buffer, size);
archive_handle->buffer[size] = '\0';
archive_handle->buffer = xzalloc(size + 1);
xread(archive_handle->src_fd, archive_handle->buffer, size);
}
+6 -15
View File
@@ -1,23 +1,14 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
#include <unistd.h>
void data_extract_to_stdout(archive_handle_t *archive_handle)
{
bb_copyfd_size(archive_handle->src_fd, STDOUT_FILENO, archive_handle->file_header->size);
bb_copyfd_exact_size(archive_handle->src_fd,
STDOUT_FILENO,
archive_handle->file_header->size);
}
+3 -18
View File
@@ -1,25 +1,10 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* 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)
{
+283 -260
View File
@@ -1,13 +1,12 @@
/* vi: set sw=4 ts=4: */
/* Small bzip2 deflate implementation, by Rob Landley (rob@landley.net).
/* Small bzip2 deflate implementation, by Rob Landley (rob@landley.net).
Based on bzip2 decompression code by Julian R Seward (jseward@acm.org),
which also acknowledges contributions by Mike Burrows, David Wheeler,
Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten,
Robert Sedgewick, and Jon L. Bentley.
Based on bzip2 decompression code by Julian R Seward (jseward@acm.org),
which also acknowledges contributions by Mike Burrows, David Wheeler,
Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten,
Robert Sedgewick, and Jon L. Bentley.
This code is licensed under the LGPLv2:
LGPL http://www.gnu.org/copyleft/lgpl.html
Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/*
@@ -24,119 +23,112 @@
I would ask that anyone benefiting from this work, especially those
using it in commercial products, consider making a donation to my local
non-profit hospice organization (www.hospiceacadiana.com) in the name of
the woman I loved, Toni W. Hagan, who passed away Feb. 12, 2003.
the woman I loved, Toni W. Hagan, who passed away Feb. 12, 2003.
Manuel
*/
#include <setjmp.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include "libbb.h"
#include "unarchive.h"
/* Constants for Huffman coding */
#define MAX_GROUPS 6
#define GROUP_SIZE 50 /* 64 would have been more efficient */
#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */
#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */
#define SYMBOL_RUNA 0
#define SYMBOL_RUNB 1
#define MAX_GROUPS 6
#define GROUP_SIZE 50 /* 64 would have been more efficient */
#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */
#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */
#define SYMBOL_RUNA 0
#define SYMBOL_RUNB 1
/* Status return values */
#define RETVAL_OK 0
#define RETVAL_LAST_BLOCK (-1)
#define RETVAL_NOT_BZIP_DATA (-2)
#define RETVAL_UNEXPECTED_INPUT_EOF (-3)
#define RETVAL_UNEXPECTED_OUTPUT_EOF (-4)
#define RETVAL_DATA_ERROR (-5)
#define RETVAL_OUT_OF_MEMORY (-6)
#define RETVAL_OBSOLETE_INPUT (-7)
#define RETVAL_OK 0
#define RETVAL_LAST_BLOCK (-1)
#define RETVAL_NOT_BZIP_DATA (-2)
#define RETVAL_UNEXPECTED_INPUT_EOF (-3)
#define RETVAL_UNEXPECTED_OUTPUT_EOF (-4)
#define RETVAL_DATA_ERROR (-5)
#define RETVAL_OUT_OF_MEMORY (-6)
#define RETVAL_OBSOLETE_INPUT (-7)
/* Other housekeeping constants */
#define IOBUF_SIZE 4096
#define IOBUF_SIZE 4096
/* 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 */
unsigned int crc32Table[256],headerCRC, totalCRC, writeCRC;
uint32_t headerCRC, totalCRC, writeCRC;
/* 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;
}
@@ -146,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);
if(i) return i;
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;
@@ -173,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
@@ -182,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;
for (;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
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,
@@ -232,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))
for (;;) {
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;
@@ -250,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];
for(i = 1; i < symCount; i++) {
if(length[i] > maxLen) maxLen = length[i];
else if(length[i] < minLen) minLen = length[i];
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];
}
/* Calculate permute[], base[], and limit[] tables from length[].
@@ -277,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;
@@ -285,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
@@ -317,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
@@ -332,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;
for(;;) {
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. */
@@ -360,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];
@@ -395,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;
}
@@ -413,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;
}
@@ -422,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
@@ -443,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];
@@ -456,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
@@ -479,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]++;
}
@@ -498,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;
}
@@ -517,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
@@ -542,13 +542,13 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
/* Loop outputting bytes */
for(;;) {
for (;;) {
/* 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;
}
@@ -556,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 */
@@ -565,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 */
@@ -599,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;
}
}
@@ -613,128 +614,150 @@ 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=0xffffffffUL;
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,j,c;
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=xmalloc(i);
memset(bd,0,sizeof(bunzip_data));
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) */
for(i=0;i<256;i++) {
c=i<<24;
for(j=8;j;j--)
c=c&0x80000000 ? (c<<1)^0x04c11db7 : (c<<1);
bd->crc32Table[i]=c;
}
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.) */
int uncompressStream(int src_fd, int dst_fd)
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
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);
if(!(i=start_bunzip(&bd,src_fd,0,0))) {
for(;;) {
if((i=read_bunzip(bd,outbuf,IOBUF_SIZE)) <= 0) break;
if(i!=write(dst_fd,outbuf,i)) {
i=RETVAL_UNEXPECTED_OUTPUT_EOF;
outbuf = xmalloc(IOBUF_SIZE);
i = start_bunzip(&bd, src_fd, NULL, 0);
if (!i) {
for (;;) {
i = read_bunzip(bd, outbuf, IOBUF_SIZE);
if (i <= 0) break;
if (i != safe_write(dst_fd, outbuf, i)) {
i = RETVAL_UNEXPECTED_OUTPUT_EOF;
break;
}
USE_DESKTOP(total_written += i;)
}
}
/* Check CRC and release memory */
if(i==RETVAL_LAST_BLOCK) {
if (bd->headerCRC!=bd->totalCRC) {
bb_error_msg("Data integrity error when decompressing.");
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) {
bb_error_msg("Compressed file ends unexpectedly");
} else if (i == RETVAL_UNEXPECTED_OUTPUT_EOF) {
bb_error_msg("compressed file ends unexpectedly");
} else {
bb_error_msg("Decompression failed");
bb_error_msg("decompression failed");
}
free(bd->dbuf);
free(bd);
dealloc_bunzip(bd);
free(outbuf);
return i;
return i ? i : USE_DESKTOP(total_written) + 0;
}
#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) 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
+101 -85
View File
@@ -1,3 +1,4 @@
/* vi: set sw=4 ts=4: */
#include "libbb.h"
/* uncompress for busybox -- (c) 2002 Robert Griebl
@@ -6,7 +7,6 @@
* (see disclaimer below)
*/
/* (N)compress42.c - File compression ala IEEE Computer, Mar 1992.
*
* Authors:
@@ -25,9 +25,6 @@
* [... History snipped ...]
*
*/
#include <stdio.h>
#include <string.h>
#include <unistd.h>
/* Default input buffer size */
#define IBUFSIZ 2048
@@ -36,99 +33,101 @@
#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))
/* Block compress mode -C compatible with 2.0 */
static int block_mode = BLOCK_MODE;
/* user settable max # bits/code */
static int maxbits = BITS;
/* Input buffer */
static unsigned char inbuf[IBUFSIZ + 64];
/* Output buffer */
static unsigned char outbuf[OBUFSIZ + 2048];
static long int htab[HSIZE];
static unsigned short codetab[HSIZE];
#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, sizeof(htab))
#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.
*/
int uncompress(int fd_in, int fd_out)
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;
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 */
int maxbits; /* = BITS; */
/* block compress mode -C compatible with 2.0 */
int block_mode; /* = BLOCK_MODE; */
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;
inbuf[0] = bb_xread_char(fd_in);
/* xread isn't good here, we have to return - caller may want
* to do some cleanup (e.g. delete incomplete unpacked file etc) */
if (full_read(fd_in, inbuf, 1) != 1) {
bb_error_msg("short read");
goto err;
}
maxbits = inbuf[0] & BIT_MASK;
block_mode = inbuf[0] & BLOCK_MODE;
maxmaxcode = MAXCODE(maxbits);
if (maxbits > BITS) {
bb_error_msg("compressed with %d bits, can only handle %d bits", maxbits,
BITS);
return -1;
bb_error_msg("compressed with %d bits, can only handle "
BITS_STR" bits", maxbits);
goto err;
}
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
bitmask = (1 << n_bits) - 1;
n_bits = INIT_BITS;
maxcode = MAXCODE(INIT_BITS) - 1;
bitmask = (1 << INIT_BITS) - 1;
oldcode = -1;
finchar = 0;
outpos = 0;
@@ -137,20 +136,21 @@ int 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;
}
do {
resetbuf:;
resetbuf:
{
int i;
int e;
int o;
e = insize - (o = (posbits >> 3));
o = posbits >> 3;
e = insize - o;
for (i = 0; i < e; ++i)
inbuf[i] = inbuf[i + o];
@@ -159,8 +159,9 @@ int uncompress(int fd_in, int fd_out)
posbits = 0;
}
if (insize < (int) sizeof(inbuf) - IBUFSIZ) {
if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) {
rsize = safe_read(fd_in, inbuf + insize, IBUFSIZ);
//error check??
insize += rsize;
}
@@ -185,16 +186,16 @@ int uncompress(int fd_in, int fd_out)
{
unsigned char *p = &inbuf[posbits >> 3];
code =
((((long) (p[0])) | ((long) (p[1]) << 8) |
((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
code = ((((long) (p[0])) | ((long) (p[1]) << 8) |
((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
}
posbits += n_bits;
if (oldcode == -1) {
outbuf[outpos++] = (unsigned char) (finchar =
(int) (oldcode = code));
oldcode = code;
finchar = (int) oldcode;
outbuf[outpos++] = (unsigned char) finchar;
continue;
}
@@ -205,8 +206,9 @@ int uncompress(int fd_in, int fd_out)
((posbits - 1) +
((n_bits << 3) -
(posbits - 1 + (n_bits << 3)) % (n_bits << 3)));
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
bitmask = (1 << n_bits) - 1;
n_bits = INIT_BITS;
maxcode = MAXCODE(INIT_BITS) - 1;
bitmask = (1 << INIT_BITS) - 1;
goto resetbuf;
}
@@ -226,7 +228,7 @@ int 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;
@@ -234,18 +236,20 @@ int 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);
}
*--stackp = (unsigned char) (finchar = tab_suffixof(code));
finchar = tab_suffixof(code);
*--stackp = (unsigned char) finchar;
/* And put them out in forward order */
{
int i;
if (outpos + (i = (de_stack - stackp)) >= OBUFSIZ) {
i = de_stack - stackp;
if (outpos + i >= OBUFSIZ) {
do {
if (i > OBUFSIZ - outpos) {
i = OBUFSIZ - outpos;
@@ -257,11 +261,14 @@ int uncompress(int fd_in, int fd_out)
}
if (outpos >= OBUFSIZ) {
write(fd_out, outbuf, outpos);
full_write(fd_out, outbuf, outpos);
//error check??
USE_DESKTOP(total_written += outpos;)
outpos = 0;
}
stackp += i;
} while ((i = (de_stack - stackp)) > 0);
i = de_stack - stackp;
} while (i > 0);
} else {
memcpy(outbuf + outpos, stackp, i);
outpos += i;
@@ -269,7 +276,8 @@ int uncompress(int fd_in, int fd_out)
}
/* Generate the new entry. */
if ((code = free_ent) < maxmaxcode) {
code = free_ent;
if (code < maxmaxcode) {
tab_prefixof(code) = (unsigned short) oldcode;
tab_suffixof(code) = (unsigned char) finchar;
free_ent = code + 1;
@@ -282,8 +290,16 @@ int uncompress(int fd_in, int fd_out)
} while (rsize > 0);
if (outpos > 0) {
write(fd_out, outbuf, outpos);
full_write(fd_out, outbuf, outpos);
//error check??
USE_DESKTOP(total_written += outpos;)
}
return 0;
retval = USE_DESKTOP(total_written) + 0;
err:
free(inbuf);
free(outbuf);
free(htab);
free(codetab);
return retval;
}
+256 -104
View File
@@ -1,3 +1,4 @@
/* vi: set sw=4 ts=4: */
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
@@ -5,29 +6,167 @@
* Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/)
* Copyright (C) 1999-2005 Igor Pavlov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <byteswap.h>
#include "libbb.h"
#include "unarchive.h"
#include "rangecoder.h"
#if ENABLE_FEATURE_LZMA_FAST
# define speed_inline ALWAYS_INLINE
#else
# define speed_inline
#endif
typedef struct {
int fd;
uint8_t *ptr;
/* Was keeping rc on stack in unlzma and separately allocating buffer,
* but with "buffer 'attached to' allocated rc" code is smaller: */
/* uint8_t *buffer; */
#define RC_BUFFER ((uint8_t*)(rc+1))
uint8_t *buffer_end;
/* Had provisions for variable buffer, but we don't need it here */
/* int buffer_size; */
#define RC_BUFFER_SIZE 0x10000
uint32_t code;
uint32_t range;
uint32_t bound;
} rc_t;
#define RC_TOP_BITS 24
#define RC_MOVE_BITS 5
#define RC_MODEL_TOTAL_BITS 11
/* Called twice: once at startup and once in rc_normalize() */
static void rc_read(rc_t * rc)
{
int buffer_size = safe_read(rc->fd, RC_BUFFER, RC_BUFFER_SIZE);
if (buffer_size <= 0)
bb_error_msg_and_die("unexpected EOF");
rc->ptr = RC_BUFFER;
rc->buffer_end = RC_BUFFER + buffer_size;
}
/* Called once */
static rc_t* rc_init(int fd) /*, int buffer_size) */
{
int i;
rc_t* rc;
rc = xmalloc(sizeof(rc_t) + RC_BUFFER_SIZE);
rc->fd = fd;
/* rc->buffer_size = buffer_size; */
rc->buffer_end = RC_BUFFER + RC_BUFFER_SIZE;
rc->ptr = rc->buffer_end;
rc->code = 0;
rc->range = 0xFFFFFFFF;
for (i = 0; i < 5; i++) {
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->code = (rc->code << 8) | *rc->ptr++;
}
return rc;
}
/* Called once */
static ALWAYS_INLINE void rc_free(rc_t * rc)
{
if (ENABLE_FEATURE_CLEAN_UP)
free(rc);
}
/* Called twice, but one callsite is in speed_inline'd rc_is_bit_0_helper() */
static void rc_do_normalize(rc_t * rc)
{
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->range <<= 8;
rc->code = (rc->code << 8) | *rc->ptr++;
}
static ALWAYS_INLINE void rc_normalize(rc_t * rc)
{
if (rc->range < (1 << RC_TOP_BITS)) {
rc_do_normalize(rc);
}
}
/* 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.
* 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)
{
rc_normalize(rc);
rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
return rc->bound;
}
static ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
{
uint32_t t = rc_is_bit_0_helper(rc, p);
return rc->code < t;
}
/* Called ~10 times, but very small, thus inlined */
static speed_inline void rc_update_bit_0(rc_t * rc, uint16_t * p)
{
rc->range = rc->bound;
*p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS;
}
static speed_inline void rc_update_bit_1(rc_t * rc, uint16_t * p)
{
rc->range -= rc->bound;
rc->code -= rc->bound;
*p -= *p >> RC_MOVE_BITS;
}
/* Called 4 times in unlzma loop */
static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
{
if (rc_is_bit_0(rc, p)) {
rc_update_bit_0(rc, p);
*symbol *= 2;
return 0;
} else {
rc_update_bit_1(rc, p);
*symbol = *symbol * 2 + 1;
return 1;
}
}
/* Called once */
static ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
{
rc_normalize(rc);
rc->range >>= 1;
if (rc->code >= rc->range) {
rc->code -= rc->range;
return 1;
}
return 0;
}
/* Called twice */
static speed_inline void
rc_bit_tree_decode(rc_t * rc, uint16_t * p, int num_levels, int *symbol)
{
int i = num_levels;
*symbol = 1;
while (i--)
rc_get_bit(rc, p + *symbol, symbol);
*symbol -= 1 << num_levels;
}
typedef struct {
@@ -37,57 +176,63 @@ typedef struct {
} __attribute__ ((packed)) lzma_header_t;
#define LZMA_BASE_SIZE 1846
#define LZMA_LIT_SIZE 768
/* #defines will force compiler to compute/optimize each one with each usage.
* Have heart and use enum instead. */
enum {
LZMA_BASE_SIZE = 1846,
LZMA_LIT_SIZE = 768,
#define LZMA_NUM_POS_BITS_MAX 4
LZMA_NUM_POS_BITS_MAX = 4,
#define LZMA_LEN_NUM_LOW_BITS 3
#define LZMA_LEN_NUM_MID_BITS 3
#define LZMA_LEN_NUM_HIGH_BITS 8
LZMA_LEN_NUM_LOW_BITS = 3,
LZMA_LEN_NUM_MID_BITS = 3,
LZMA_LEN_NUM_HIGH_BITS = 8,
#define LZMA_LEN_CHOICE 0
#define LZMA_LEN_CHOICE_2 (LZMA_LEN_CHOICE + 1)
#define LZMA_LEN_LOW (LZMA_LEN_CHOICE_2 + 1)
#define LZMA_LEN_MID (LZMA_LEN_LOW \
+ (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_LOW_BITS)))
#define LZMA_LEN_HIGH (LZMA_LEN_MID \
+(1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_MID_BITS)))
#define LZMA_NUM_LEN_PROBS (LZMA_LEN_HIGH + (1 << LZMA_LEN_NUM_HIGH_BITS))
LZMA_LEN_CHOICE = 0,
LZMA_LEN_CHOICE_2 = (LZMA_LEN_CHOICE + 1),
LZMA_LEN_LOW = (LZMA_LEN_CHOICE_2 + 1),
LZMA_LEN_MID = (LZMA_LEN_LOW \
+ (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_LOW_BITS))),
LZMA_LEN_HIGH = (LZMA_LEN_MID \
+ (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_MID_BITS))),
LZMA_NUM_LEN_PROBS = (LZMA_LEN_HIGH + (1 << LZMA_LEN_NUM_HIGH_BITS)),
#define LZMA_NUM_STATES 12
#define LZMA_NUM_LIT_STATES 7
LZMA_NUM_STATES = 12,
LZMA_NUM_LIT_STATES = 7,
#define LZMA_START_POS_MODEL_INDEX 4
#define LZMA_END_POS_MODEL_INDEX 14
#define LZMA_NUM_FULL_DISTANCES (1 << (LZMA_END_POS_MODEL_INDEX >> 1))
LZMA_START_POS_MODEL_INDEX = 4,
LZMA_END_POS_MODEL_INDEX = 14,
LZMA_NUM_FULL_DISTANCES = (1 << (LZMA_END_POS_MODEL_INDEX >> 1)),
#define LZMA_NUM_POS_SLOT_BITS 6
#define LZMA_NUM_LEN_TO_POS_STATES 4
LZMA_NUM_POS_SLOT_BITS = 6,
LZMA_NUM_LEN_TO_POS_STATES = 4,
#define LZMA_NUM_ALIGN_BITS 4
LZMA_NUM_ALIGN_BITS = 4,
#define LZMA_MATCH_MIN_LEN 2
LZMA_MATCH_MIN_LEN = 2,
#define LZMA_IS_MATCH 0
#define LZMA_IS_REP (LZMA_IS_MATCH + (LZMA_NUM_STATES <<LZMA_NUM_POS_BITS_MAX))
#define LZMA_IS_REP_G0 (LZMA_IS_REP + LZMA_NUM_STATES)
#define LZMA_IS_REP_G1 (LZMA_IS_REP_G0 + LZMA_NUM_STATES)
#define LZMA_IS_REP_G2 (LZMA_IS_REP_G1 + LZMA_NUM_STATES)
#define LZMA_IS_REP_0_LONG (LZMA_IS_REP_G2 + LZMA_NUM_STATES)
#define LZMA_POS_SLOT (LZMA_IS_REP_0_LONG \
+ (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX))
#define LZMA_SPEC_POS (LZMA_POS_SLOT \
+(LZMA_NUM_LEN_TO_POS_STATES << LZMA_NUM_POS_SLOT_BITS))
#define LZMA_ALIGN (LZMA_SPEC_POS \
+ LZMA_NUM_FULL_DISTANCES - LZMA_END_POS_MODEL_INDEX)
#define LZMA_LEN_CODER (LZMA_ALIGN + (1 << LZMA_NUM_ALIGN_BITS))
#define LZMA_REP_LEN_CODER (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS)
#define LZMA_LITERAL (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS)
LZMA_IS_MATCH = 0,
LZMA_IS_REP = (LZMA_IS_MATCH + (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX)),
LZMA_IS_REP_G0 = (LZMA_IS_REP + LZMA_NUM_STATES),
LZMA_IS_REP_G1 = (LZMA_IS_REP_G0 + LZMA_NUM_STATES),
LZMA_IS_REP_G2 = (LZMA_IS_REP_G1 + LZMA_NUM_STATES),
LZMA_IS_REP_0_LONG = (LZMA_IS_REP_G2 + LZMA_NUM_STATES),
LZMA_POS_SLOT = (LZMA_IS_REP_0_LONG \
+ (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX)),
LZMA_SPEC_POS = (LZMA_POS_SLOT \
+ (LZMA_NUM_LEN_TO_POS_STATES << LZMA_NUM_POS_SLOT_BITS)),
LZMA_ALIGN = (LZMA_SPEC_POS \
+ LZMA_NUM_FULL_DISTANCES - LZMA_END_POS_MODEL_INDEX),
LZMA_LEN_CODER = (LZMA_ALIGN + (1 << LZMA_NUM_ALIGN_BITS)),
LZMA_REP_LEN_CODER = (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS),
LZMA_LITERAL = (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS),
};
int unlzma(int src_fd, int dst_fd)
USE_DESKTOP(long long) int
unpack_lzma_stream(int src_fd, int dst_fd)
{
USE_DESKTOP(long long total_written = 0;)
lzma_header_t header;
int lc, pb, lp;
uint32_t pos_state_mask;
@@ -98,7 +243,7 @@ int unlzma(int src_fd, int dst_fd)
uint16_t *prob_lit;
int num_bits;
int num_probs;
rc_t rc;
rc_t *rc;
int i, mi;
uint8_t *buffer;
uint8_t previous_byte = 0;
@@ -107,8 +252,7 @@ int unlzma(int src_fd, int dst_fd)
int state = 0;
uint32_t rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
if (read(src_fd, &header, sizeof(header)) != sizeof(header))
bb_error_msg_and_die("can't read header");
xread(src_fd, &header, sizeof(header));
if (header.pos >= (9 * 5 * 5))
bb_error_msg_and_die("bad header");
@@ -119,10 +263,8 @@ int unlzma(int src_fd, int dst_fd)
pos_state_mask = (1 << pb) - 1;
literal_pos_mask = (1 << lp) - 1;
#if BB_BIG_ENDIAN
header.dict_size = bswap_32(header.dict_size);
header.dst_size = bswap_64(header.dst_size);
#endif
header.dict_size = SWAP_LE32(header.dict_size);
header.dst_size = SWAP_LE64(header.dst_size);
if (header.dict_size == 0)
header.dict_size = 1;
@@ -135,16 +277,16 @@ int unlzma(int src_fd, int dst_fd)
for (i = 0; i < num_probs; i++)
p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
rc_init(&rc, src_fd, 0x10000);
rc = rc_init(src_fd); /*, RC_BUFFER_SIZE); */
while (global_pos + buffer_pos < header.dst_size) {
int pos_state = (buffer_pos + global_pos) & pos_state_mask;
prob =
p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state;
if (rc_is_bit_0(&rc, prob)) {
if (rc_is_bit_0(rc, prob)) {
mi = 1;
rc_update_bit_0(&rc, prob);
rc_update_bit_0(rc, prob);
prob = (p + LZMA_LITERAL + (LZMA_LIT_SIZE
* ((((buffer_pos + global_pos) & literal_pos_mask) << lc)
+ (previous_byte >> (8 - lc)))));
@@ -162,7 +304,7 @@ int unlzma(int src_fd, int dst_fd)
match_byte <<= 1;
bit = match_byte & 0x100;
prob_lit = prob + 0x100 + bit + mi;
if (rc_get_bit(&rc, prob_lit, &mi)) {
if (rc_get_bit(rc, prob_lit, &mi)) {
if (!bit)
break;
} else {
@@ -173,7 +315,7 @@ int unlzma(int src_fd, int dst_fd)
}
while (mi < 0x100) {
prob_lit = prob + mi;
rc_get_bit(&rc, prob_lit, &mi);
rc_get_bit(rc, prob_lit, &mi);
}
previous_byte = (uint8_t) mi;
@@ -181,7 +323,9 @@ int unlzma(int src_fd, int dst_fd)
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
write(dst_fd, buffer, header.dict_size);
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
}
if (state < 4)
state = 0;
@@ -193,24 +337,24 @@ int unlzma(int src_fd, int dst_fd)
int offset;
uint16_t *prob_len;
rc_update_bit_1(&rc, prob);
rc_update_bit_1(rc, prob);
prob = p + LZMA_IS_REP + state;
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
if (rc_is_bit_0(rc, prob)) {
rc_update_bit_0(rc, prob);
rep3 = rep2;
rep2 = rep1;
rep1 = rep0;
state = state < LZMA_NUM_LIT_STATES ? 0 : 3;
prob = p + LZMA_LEN_CODER;
} else {
rc_update_bit_1(&rc, prob);
rc_update_bit_1(rc, prob);
prob = p + LZMA_IS_REP_G0 + state;
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
if (rc_is_bit_0(rc, prob)) {
rc_update_bit_0(rc, prob);
prob = (p + LZMA_IS_REP_0_LONG
+ (state << LZMA_NUM_POS_BITS_MAX) + pos_state);
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
if (rc_is_bit_0(rc, prob)) {
rc_update_bit_0(rc, prob);
state = state < LZMA_NUM_LIT_STATES ? 9 : 11;
pos = buffer_pos - rep0;
@@ -221,28 +365,30 @@ int unlzma(int src_fd, int dst_fd)
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
write(dst_fd, buffer, header.dict_size);
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
}
continue;
} else {
rc_update_bit_1(&rc, prob);
rc_update_bit_1(rc, prob);
}
} else {
uint32_t distance;
rc_update_bit_1(&rc, prob);
rc_update_bit_1(rc, prob);
prob = p + LZMA_IS_REP_G1 + state;
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
if (rc_is_bit_0(rc, prob)) {
rc_update_bit_0(rc, prob);
distance = rep1;
} else {
rc_update_bit_1(&rc, prob);
rc_update_bit_1(rc, prob);
prob = p + LZMA_IS_REP_G2 + state;
if (rc_is_bit_0(&rc, prob)) {
rc_update_bit_0(&rc, prob);
if (rc_is_bit_0(rc, prob)) {
rc_update_bit_0(rc, prob);
distance = rep2;
} else {
rc_update_bit_1(&rc, prob);
rc_update_bit_1(rc, prob);
distance = rep3;
rep3 = rep2;
}
@@ -256,30 +402,30 @@ int unlzma(int src_fd, int dst_fd)
}
prob_len = prob + LZMA_LEN_CHOICE;
if (rc_is_bit_0(&rc, prob_len)) {
rc_update_bit_0(&rc, prob_len);
if (rc_is_bit_0(rc, prob_len)) {
rc_update_bit_0(rc, prob_len);
prob_len = (prob + LZMA_LEN_LOW
+ (pos_state << LZMA_LEN_NUM_LOW_BITS));
offset = 0;
num_bits = LZMA_LEN_NUM_LOW_BITS;
} else {
rc_update_bit_1(&rc, prob_len);
rc_update_bit_1(rc, prob_len);
prob_len = prob + LZMA_LEN_CHOICE_2;
if (rc_is_bit_0(&rc, prob_len)) {
rc_update_bit_0(&rc, prob_len);
if (rc_is_bit_0(rc, prob_len)) {
rc_update_bit_0(rc, prob_len);
prob_len = (prob + LZMA_LEN_MID
+ (pos_state << LZMA_LEN_NUM_MID_BITS));
offset = 1 << LZMA_LEN_NUM_LOW_BITS;
num_bits = LZMA_LEN_NUM_MID_BITS;
} else {
rc_update_bit_1(&rc, prob_len);
rc_update_bit_1(rc, prob_len);
prob_len = prob + LZMA_LEN_HIGH;
offset = ((1 << LZMA_LEN_NUM_LOW_BITS)
+ (1 << LZMA_LEN_NUM_MID_BITS));
num_bits = LZMA_LEN_NUM_HIGH_BITS;
}
}
rc_bit_tree_decode(&rc, prob_len, num_bits, &len);
rc_bit_tree_decode(rc, prob_len, num_bits, &len);
len += offset;
if (state < 4) {
@@ -292,7 +438,7 @@ int unlzma(int src_fd, int dst_fd)
LZMA_NUM_LEN_TO_POS_STATES ? len :
LZMA_NUM_LEN_TO_POS_STATES - 1)
<< LZMA_NUM_POS_SLOT_BITS);
rc_bit_tree_decode(&rc, prob, LZMA_NUM_POS_SLOT_BITS,
rc_bit_tree_decode(rc, prob, LZMA_NUM_POS_SLOT_BITS,
&pos_slot);
if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
num_bits = (pos_slot >> 1) - 1;
@@ -303,7 +449,7 @@ int unlzma(int src_fd, int dst_fd)
} else {
num_bits -= LZMA_NUM_ALIGN_BITS;
while (num_bits--)
rep0 = (rep0 << 1) | rc_direct_bit(&rc);
rep0 = (rep0 << 1) | rc_direct_bit(rc);
prob = p + LZMA_ALIGN;
rep0 <<= LZMA_NUM_ALIGN_BITS;
num_bits = LZMA_NUM_ALIGN_BITS;
@@ -311,7 +457,7 @@ int unlzma(int src_fd, int dst_fd)
i = 1;
mi = 1;
while (num_bits--) {
if (rc_get_bit(&rc, prob + mi, &mi))
if (rc_get_bit(rc, prob + mi, &mi))
rep0 |= i;
i <<= 1;
}
@@ -332,16 +478,22 @@ int unlzma(int src_fd, int dst_fd)
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
write(dst_fd, buffer, header.dict_size);
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
}
len--;
} while (len != 0 && buffer_pos < header.dst_size);
}
}
write(dst_fd, buffer, buffer_pos);
rc_free(&rc);
return 0;
}
/* vi:set ts=4: */
if (full_write(dst_fd, buffer, buffer_pos) != buffer_pos) {
bad:
rc_free(rc);
return -1;
}
rc_free(rc);
USE_DESKTOP(total_written += buffer_pos;)
return USE_DESKTOP(total_written) + 0;
}
File diff suppressed because it is too large. Load diff
+7 -22
View File
@@ -1,32 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
* Copyright (C) 2002 by Glenn McGrath
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <fnmatch.h>
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
/* Accept any non-null name, its not really a filter at all */
char filter_accept_all(archive_handle_t *archive_handle)
{
if (archive_handle->file_header->name) {
return(EXIT_SUCCESS);
} else {
return(EXIT_FAILURE);
}
if (archive_handle->file_header->name)
return EXIT_SUCCESS;
return EXIT_FAILURE;
}
+7 -22
View File
@@ -1,24 +1,11 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
* Copyright (C) 2002 by Glenn McGrath
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <fnmatch.h>
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
/*
@@ -26,9 +13,7 @@
*/
char filter_accept_list(archive_handle_t *archive_handle)
{
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
return(EXIT_SUCCESS);
} else {
return(EXIT_FAILURE);
}
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name))
return EXIT_SUCCESS;
return EXIT_FAILURE;
}
@@ -1,32 +1,17 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h"
/*
* Reassign the subarchive metadata parser based on the filename extension
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
* Reassign the subarchive metadata parser based on the filename extension
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
*/
char filter_accept_list_reassign(archive_handle_t *archive_handle)
{
@@ -38,22 +23,22 @@ 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);
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);
return EXIT_SUCCESS;
}
#endif
if (ENABLE_FEATURE_DEB_TAR_LZMA && !strcmp(name_ptr, ".lzma")) {
archive_handle->action_data_subarchive = get_header_tar_lzma;
return(EXIT_SUCCESS);
return EXIT_SUCCESS;
}
}
return(EXIT_FAILURE);
return EXIT_FAILURE;
}
@@ -1,24 +1,11 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2002 by Glenn McGrath
* Copyright (C) 2002 by Glenn McGrath
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <fnmatch.h>
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
/*
@@ -27,19 +14,20 @@
char filter_accept_reject_list(archive_handle_t *archive_handle)
{
const char *key = archive_handle->file_header->name;
const llist_t *accept_entry = find_list_entry(archive_handle->accept, key);
const llist_t *reject_entry = find_list_entry(archive_handle->reject, key);
const llist_t *reject_entry = find_list_entry2(archive_handle->reject, key);
const llist_t *accept_entry;
/* If the key is in a reject list fail */
if (reject_entry) {
return(EXIT_FAILURE);
return EXIT_FAILURE;
}
accept_entry = find_list_entry2(archive_handle->accept, key);
/* Fail if an accept list was specified and the key wasnt in there */
if (archive_handle->accept && (accept_entry == NULL)) {
return(EXIT_FAILURE);
if ((accept_entry == NULL) && archive_handle->accept) {
return EXIT_FAILURE;
}
/* Accepted */
return(EXIT_SUCCESS);
return EXIT_SUCCESS;
}
+39 -15
View File
@@ -1,30 +1,54 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* Copyright (C) 2002 by Glenn McGrath
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <fnmatch.h>
#include <stdlib.h>
#include "libbb.h"
#include "unarchive.h"
/* Find a string in a shell pattern list */
const llist_t *find_list_entry(const llist_t *list, const char *filename)
{
while (list) {
if (fnmatch(list->data, filename, 0) == 0) {
return(list);
return list;
}
list = list->link;
}
return(NULL);
return NULL;
}
/* Same, but compares only path components present in pattern
* (extra trailing path components in filename are assumed to match)
*/
const llist_t *find_list_entry2(const llist_t *list, const char *filename)
{
char buf[PATH_MAX];
int pattern_slash_cnt;
const char *c;
char *d;
while (list) {
c = list->data;
pattern_slash_cnt = 0;
while (*c)
if (*c++ == '/') pattern_slash_cnt++;
c = filename;
d = buf;
/* paranoia is better that buffer overflows */
while (*c && d != buf + sizeof(buf)-1) {
if (*c == '/' && --pattern_slash_cnt < 0)
break;
*d++ = *c++;
}
*d = '\0';
if (fnmatch(list->data, buf, 0) == 0) {
return list;
}
list = list->link;
}
return NULL;
}
+50 -50
View File
@@ -1,28 +1,15 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
/* vi: set sw=4 ts=4: */
/* Copyright 2001 Glenn McGrath.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "unarchive.h"
#include "libbb.h"
#include "unarchive.h"
char get_header_ar(archive_handle_t *archive_handle)
{
int err;
file_header_t *typed = archive_handle->file_header;
union {
char raw[60];
@@ -34,17 +21,17 @@ char get_header_ar(archive_handle_t *archive_handle)
char mode[8];
char size[10];
char magic[2];
} formated;
} 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 bb_xread as we want to handle the error ourself */
/* dont use xread as we want to handle the error ourself */
if (read(archive_handle->src_fd, ar.raw, 60) != 60) {
/* End Of File */
return(EXIT_FAILURE);
return EXIT_FAILURE;
}
/* ar header starts on an even byte (2 byte aligned)
@@ -53,56 +40,68 @@ char get_header_ar(archive_handle_t *archive_handle)
if (ar.raw[0] == '\n') {
/* fix up the header, we started reading 1 byte too early */
memmove(ar.raw, &ar.raw[1], 59);
ar.raw[59] = bb_xread_char(archive_handle->src_fd);
ar.raw[59] = xread_char(archive_handle->src_fd);
archive_handle->offset++;
}
archive_handle->offset += 60;
/* align the headers based on the header magic */
if ((ar.formated.magic[0] != '`') || (ar.formated.magic[1] != '\n')) {
bb_error_msg_and_die("Invalid ar header");
}
if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n')
bb_error_msg_and_die("invalid ar header");
typed->mode = strtol(ar.formated.mode, NULL, 8);
typed->mtime = atoi(ar.formated.date);
typed->uid = atoi(ar.formated.uid);
typed->gid = atoi(ar.formated.gid);
typed->size = atoi(ar.formated.size);
/* FIXME: more thorough routine would be in order here */
/* (we have something like that in tar) */
/* but for now we are lax. This code works because */
/* on misformatted numbers bb_strtou returns all-ones */
typed->mode = err = bb_strtou(ar.formatted.mode, NULL, 8);
if (err == -1) bb_error_msg_and_die("invalid ar header");
typed->mtime = err = bb_strtou(ar.formatted.date, NULL, 10);
if (err == -1) bb_error_msg_and_die("invalid ar header");
typed->uid = err = bb_strtou(ar.formatted.uid, NULL, 10);
if (err == -1) bb_error_msg_and_die("invalid ar header");
typed->gid = err = bb_strtou(ar.formatted.gid, NULL, 10);
if (err == -1) bb_error_msg_and_die("invalid ar header");
typed->size = err = bb_strtou(ar.formatted.size, NULL, 10);
if (err == -1) bb_error_msg_and_die("invalid ar header");
/* long filenames have '/' as the first character */
if (ar.formated.name[0] == '/') {
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
if (ar.formated.name[1] == '/') {
if (ar.formatted.name[0] == '/') {
#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
* in static variable long_names for use in future entries */
ar_long_name_size = typed->size;
ar_long_names = xmalloc(ar_long_name_size);
bb_xread_all(archive_handle->src_fd, ar_long_names, ar_long_name_size);
xread(archive_handle->src_fd, ar_long_names, ar_long_name_size);
archive_handle->offset += ar_long_name_size;
/* 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.formated.name[1] == ' ') {
return get_header_ar(archive_handle); /* Return next header */
}
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.formated.name[1]);
if (long_offset >= ar_long_name_size) {
bb_error_msg_and_die("Cant resolve long filename");
}
typed->name = bb_xstrdup(ar_long_names + long_offset);
return get_header_ar(archive_handle); /* Return next header */
}
/* 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
} else {
/* short filenames */
typed->name = bb_xstrndup(ar.formated.name, 16);
typed->name = xstrndup(ar.formatted.name, 16);
}
typed->name[strcspn(typed->name, " /")] = '\0';
@@ -110,7 +109,8 @@ char get_header_ar(archive_handle_t *archive_handle)
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_header(typed);
if (archive_handle->sub_archive) {
while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS);
while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS)
/* repeat */;
} else {
archive_handle->action_data(archive_handle);
}
@@ -122,5 +122,5 @@ char get_header_ar(archive_handle_t *archive_handle)
/* Set the file pointer to the correct spot, we may have been reading a compressed file */
lseek(archive_handle->src_fd, archive_handle->offset, SEEK_SET);
return(EXIT_SUCCESS);
return EXIT_SUCCESS;
}
+70 -70
View File
@@ -1,29 +1,14 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
/* vi: set sw=4 ts=4: */
/* Copyright 2002 Laurence Anderson
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/sysmacros.h> /* major() and minor() */
#include "unarchive.h"
#include "libbb.h"
#include "unarchive.h"
typedef struct hardlinks_s {
file_header_t *entry;
char *name;
int inode;
struct hardlinks_s *next;
} hardlinks_t;
@@ -31,118 +16,133 @@ 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;
char dummy[16];
int major, minor, nlink, inode;
int major, minor, nlink;
if (pending_hardlinks) { /* Deal with any pending hardlinks */
hardlinks_t *tmp;
hardlinks_t *oldtmp;
hardlinks_t *tmp, *oldtmp;
tmp = saved_hardlinks;
oldtmp = NULL;
file_header->link_target = file_header->name;
file_header->size = 0;
while (tmp) {
bb_error_msg_and_die("need to fix this\n");
if (tmp->entry->link_name) { /* Found a hardlink ready to be extracted */
file_header = tmp->entry;
if (oldtmp) {
oldtmp->next = tmp->next; /* Remove item from linked list */
} else {
saved_hardlinks = tmp->next;
}
free(tmp);
if (tmp->inode != inode) {
tmp = tmp->next;
continue;
}
file_header->name = tmp->name;
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_data(archive_handle);
archive_handle->action_header(archive_handle->file_header);
}
pending_hardlinks--;
oldtmp = tmp;
tmp = tmp->next;
free(oldtmp->name);
free(oldtmp);
if (oldtmp == saved_hardlinks)
saved_hardlinks = tmp;
}
pending_hardlinks = 0; /* No more pending hardlinks, read next file entry */
file_header->name = file_header->link_target;
if (pending_hardlinks > 1) {
bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?");
}
/* No more pending hardlinks, read next file entry */
pending_hardlinks = 0;
}
/* There can be padding before archive header */
data_align(archive_handle, 4);
if (archive_xread_all_eof(archive_handle, (unsigned char*)cpio_header, 110) == 0) {
return(EXIT_FAILURE);
return EXIT_FAILURE;
}
archive_handle->offset += 110;
if ((strncmp(&cpio_header[0], "07070", 5) != 0) || ((cpio_header[5] != '1') && (cpio_header[5] != '2'))) {
bb_error_msg_and_die("Unsupported cpio format, use newc or crc");
if (strncmp(&cpio_header[0], "07070", 5) != 0
|| (cpio_header[5] != '1' && cpio_header[5] != '2')
) {
bb_error_msg_and_die("unsupported cpio format, use newc or crc");
}
{
unsigned long tmpsize;
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
unsigned long tmpsize;
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
dummy, &inode, (unsigned int*)&file_header->mode,
(unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
&nlink, &file_header->mtime, &tmpsize,
dummy, &major, &minor, &namesize, dummy);
file_header->size = tmpsize;
file_header->size = tmpsize;
}
file_header->name = (char *) xmalloc(namesize + 1);
archive_xread_all(archive_handle, file_header->name, namesize); /* Read in filename */
file_header->name[namesize] = '\0';
free(file_header->name);
file_header->name = xzalloc(namesize + 1);
/* Read in filename */
xread(archive_handle->src_fd, file_header->name, namesize);
archive_handle->offset += namesize;
/* Update offset amount and skip padding before file contents */
data_align(archive_handle, 4);
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
printf("%d blocks\n", (int) (archive_handle->offset % 512 ? (archive_handle->offset / 512) + 1 : archive_handle->offset / 512)); /* Always round up */
/* Always round up */
printf("%d blocks\n", (int) (archive_handle->offset % 512 ?
archive_handle->offset / 512 + 1 :
archive_handle->offset / 512
));
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
hardlinks_t *tmp = saved_hardlinks;
hardlinks_t *oldtmp = NULL;
while (tmp) {
bb_error_msg("%s not created: cannot resolve hardlink", tmp->entry->name);
bb_error_msg("%s not created: cannot resolve hardlink", tmp->name);
oldtmp = tmp;
tmp = tmp->next;
free (oldtmp->entry->name);
free (oldtmp->entry);
free (oldtmp);
free(oldtmp->name);
free(oldtmp);
}
saved_hardlinks = NULL;
pending_hardlinks = 0;
}
return(EXIT_FAILURE);
return EXIT_FAILURE;
}
if (S_ISLNK(file_header->mode)) {
file_header->link_name = (char *) xmalloc(file_header->size + 1);
archive_xread_all(archive_handle, file_header->link_name, file_header->size);
file_header->link_name[file_header->size] = '\0';
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 */
hardlinks_t *new = xmalloc(sizeof(hardlinks_t));
new->next = saved_hardlinks;
new->inode = inode;
new->entry = file_header;
/* name current allocated, freed later */
new->name = file_header->name;
file_header->name = NULL;
saved_hardlinks = new;
return(EXIT_SUCCESS); // Skip this one
} else { /* Found the file with data in */
hardlinks_t *tmp = saved_hardlinks;
pending_hardlinks = 1;
while (tmp) {
if (tmp->inode == inode) {
tmp->entry->link_name = bb_xstrdup(file_header->name);
nlink--;
}
tmp = tmp->next;
}
if (nlink > 1) {
bb_error_msg("error resolving hardlink: did you create the archive with GNU cpio 2.0-2.2?");
}
return EXIT_SUCCESS; /* Skip this one */
}
/* Found the file with data in */
pending_hardlinks = nlink;
}
file_header->device = makedev(major, minor);
@@ -155,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);
return EXIT_SUCCESS;
}
+210 -125
View File
@@ -1,3 +1,4 @@
/* vi: set sw=4 ts=4: */
/* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* FIXME:
@@ -10,146 +11,198 @@
* http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/sysmacros.h> /* For makedev */
#include "unarchive.h"
#include "libbb.h"
#include "unarchive.h"
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
static char *longname = NULL;
static char *linkname = NULL;
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
static char *longname;
static char *linkname;
#else
enum {
longname = 0,
linkname = 0,
};
#endif
/* NB: _DESTROYS_ str[len] character! */
static unsigned long long getOctal(char *str, int len)
{
unsigned long long v;
/* Actually, tar header allows leading spaces also.
* Oh well, we will be liberal and skip this...
* The only downside probably is that we allow "-123" too :)
if (*str < '0' || *str > '7')
bb_error_msg_and_die("corrupted octal value in tar header");
*/
str[len] = '\0';
v = strtoull(str, &str, 8);
if (*str && (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY || *str != ' '))
bb_error_msg_and_die("corrupted octal value in tar header");
return v;
}
#define GET_OCTAL(a) getOctal((a), sizeof(a))
void BUG_tar_header_size(void);
char get_header_tar(archive_handle_t *archive_handle)
{
file_header_t *file_header = archive_handle->file_header;
union {
/* ustar header, Posix 1003.1 */
unsigned char raw[512];
struct {
char name[100]; /* 0-99 */
char mode[8]; /* 100-107 */
char uid[8]; /* 108-115 */
char gid[8]; /* 116-123 */
char size[12]; /* 124-135 */
char mtime[12]; /* 136-147 */
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[100]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
char uname[32]; /* 265-296 */
char gname[32]; /* 297-328 */
char devmajor[8]; /* 329-336 */
char devminor[8]; /* 337-344 */
char prefix[155]; /* 345-499 */
char padding[12]; /* 500-512 */
} formated;
} tar;
long sum = 0;
long i;
static int end = 0;
static smallint end;
file_header_t *file_header = archive_handle->file_header;
struct {
/* ustar header, Posix 1003.1 */
char name[100]; /* 0-99 */
char mode[8]; /* 100-107 */
char uid[8]; /* 108-115 */
char gid[8]; /* 116-123 */
char size[12]; /* 124-135 */
char mtime[12]; /* 136-147 */
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[100]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
char uname[32]; /* 265-296 */
char gname[32]; /* 297-328 */
char devmajor[8]; /* 329-336 */
char devminor[8]; /* 337-344 */
char prefix[155]; /* 345-499 */
char padding[12]; /* 500-512 */
} tar;
char *cp;
int i, sum_u, sum;
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
int sum_s;
#endif
int parse_names;
if (sizeof(tar) != 512)
BUG_tar_header_size();
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
again:
#endif
/* Align header */
data_align(archive_handle, 512);
if (bb_full_read(archive_handle->src_fd, tar.raw, 512) != 512) {
/* Assume end of file */
bb_error_msg_and_die("Short header");
//return(EXIT_FAILURE);
}
again_after_align:
xread(archive_handle->src_fd, &tar, 512);
archive_handle->offset += 512;
/* If there is no filename its an empty header */
if (tar.formated.name[0] == 0) {
if (tar.name[0] == 0) {
if (end) {
/* This is the second consecutive empty header! End of archive!
* Read until the end to empty the pipe from gz or bz2
*/
while (bb_full_read(archive_handle->src_fd, tar.raw, 512) == 512);
return(EXIT_FAILURE);
while (full_read(archive_handle->src_fd, &tar, 512) == 512)
/* repeat */;
return EXIT_FAILURE;
}
end = 1;
return(EXIT_SUCCESS);
return EXIT_SUCCESS;
}
end = 0;
/* Check header has valid magic, "ustar" is for the proper tar
* 0's are for the old tar format
*/
if (strncmp(tar.formated.magic, "ustar", 5) != 0) {
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0)
if (strncmp(tar.magic, "ustar", 5) != 0) {
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
if (memcmp(tar.magic, "\0\0\0\0", 5) != 0)
#endif
bb_error_msg_and_die("Invalid tar magic");
}
/* Do checksum on headers */
for (i = 0; i < 148 ; i++) {
sum += tar.raw[i];
}
sum += ' ' * 8;
for (i = 156; i < 512 ; i++) {
sum += tar.raw[i];
}
if (sum != strtol(tar.formated.chksum, NULL, 8)) {
bb_error_msg("Invalid tar header checksum");
return(EXIT_FAILURE);
bb_error_msg_and_die("invalid tar magic");
}
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
if (longname) {
file_header->name = longname;
longname = NULL;
}
else if (linkname) {
file_header->name = linkname;
linkname = NULL;
} else
/* 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
{
file_header->name = bb_xstrndup(tar.formated.name,100);
if (tar.formated.prefix[0]) {
char *temp = file_header->name;
file_header->name = concat_path_file(tar.formated.prefix, temp);
free(temp);
}
}
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
}
#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
file_header->uid = strtol(tar.formated.uid, NULL, 8);
file_header->gid = strtol(tar.formated.gid, NULL, 8);
file_header->size = strtol(tar.formated.size, NULL, 8);
file_header->mtime = strtol(tar.formated.mtime, NULL, 8);
file_header->link_name = (tar.formated.linkname[0] != '\0') ?
bb_xstrdup(tar.formated.linkname) : NULL;
file_header->device = makedev(strtol(tar.formated.devmajor, NULL, 8),
strtol(tar.formated.devminor, NULL, 8));
/* 0 is reserved for high perf file, treat as normal file */
if (!tar.typeflag) tar.typeflag = '0';
parse_names = (tar.typeflag >= '0' && tar.typeflag <= '7');
/* getOctal trashes subsequent field, therefore we call it
* on fields in reverse order */
if (tar.devmajor[0]) {
unsigned minor = GET_OCTAL(tar.devminor);
unsigned major = GET_OCTAL(tar.devmajor);
file_header->device = makedev(major, minor);
}
file_header->link_target = NULL;
if (!linkname && parse_names && tar.linkname[0]) {
/* we trash magic[0] here, it's ok */
tar.linkname[sizeof(tar.linkname)] = '\0';
file_header->link_target = xstrdup(tar.linkname);
/* 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);
file_header->gid = GET_OCTAL(tar.gid);
file_header->uid = GET_OCTAL(tar.uid);
/* Set bits 0-11 of the files mode */
file_header->mode = 07777 & strtol(tar.formated.mode, NULL, 8);
file_header->mode = 07777 & GET_OCTAL(tar.mode);
file_header->name = NULL;
if (!longname && parse_names) {
/* we trash mode[0] here, it's ok */
tar.name[sizeof(tar.name)] = '\0';
if (tar.prefix[0]) {
/* and padding[0] */
tar.prefix[sizeof(tar.prefix)] = '\0';
file_header->name = concat_path_file(tar.prefix, tar.name);
} else
file_header->name = xstrdup(tar.name);
}
/* Set bits 12-15 of the files mode */
switch (tar.formated.typeflag) {
/* (typeflag was not trashed because chksum does not use getOctal) */
switch (tar.typeflag) {
/* busybox identifies hard links as being regular files with 0 size and a link name */
case '1':
file_header->mode |= S_IFREG;
break;
case 'x':
case 'g':
bb_error_msg_and_die("pax is not tar");
break;
case '7':
/* Reserved for high performance files, treat as normal file */
case 0:
/* case 0: */
case '0':
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
if (last_char_is(file_header->name, '/')) {
file_header->mode |= S_IFDIR;
} else
#endif
file_header->mode |= S_IFREG;
file_header->mode |= S_IFREG;
break;
case '2':
file_header->mode |= S_IFLNK;
@@ -166,53 +219,85 @@ char get_header_tar(archive_handle_t *archive_handle)
case '6':
file_header->mode |= S_IFIFO;
break;
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
case 'L': {
longname = xmalloc(file_header->size + 1);
archive_xread_all(archive_handle, longname, file_header->size);
longname[file_header->size] = '\0';
archive_handle->offset += file_header->size;
return(get_header_tar(archive_handle));
}
case 'K': {
linkname = xmalloc(file_header->size + 1);
archive_xread_all(archive_handle, linkname, file_header->size);
linkname[file_header->size] = '\0';
archive_handle->offset += file_header->size;
file_header->name = linkname;
return(get_header_tar(archive_handle));
}
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
case 'L':
/* free: paranoia: tar with several consecutive longnames */
free(longname);
/* For paranoia reasons we allocate extra NUL char */
longname = xzalloc(file_header->size + 1);
/* We read ASCIZ string, including NUL */
xread(archive_handle->src_fd, longname, file_header->size);
archive_handle->offset += file_header->size;
/* return get_header_tar(archive_handle); */
/* gcc 4.1.1 didn't optimize it into jump */
/* so we will do it ourself, this also saves stack */
goto again;
case 'K':
free(linkname);
linkname = xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, linkname, file_header->size);
archive_handle->offset += file_header->size;
/* return get_header_tar(archive_handle); */
goto again;
case 'D': /* GNU dump dir */
case 'M': /* Continuation of multi volume archive*/
case 'M': /* Continuation of multi volume archive */
case 'N': /* Old GNU for names > 100 characters */
case 'S': /* Sparse file */
case 'V': /* Volume header */
bb_error_msg("Ignoring GNU extension type %c", tar.formated.typeflag);
#endif
case 'g': /* pax global header */
case 'x': { /* pax extended header */
off_t sz;
bb_error_msg("warning: skipping header '%c'", tar.typeflag);
sz = (file_header->size + 511) & ~(off_t)511;
archive_handle->offset += sz;
sz >>= 9; /* sz /= 512 but w/o contortions for signed div */
while (sz--)
xread(archive_handle->src_fd, &tar, 512);
/* return get_header_tar(archive_handle); */
goto again_after_align;
}
default:
bb_error_msg("Unknown typeflag: 0x%x", tar.formated.typeflag);
bb_error_msg_and_die("unknown typeflag: 0x%x", tar.typeflag);
}
{ /* Strip trailing '/' in directories */
/* Must be done after mode is set as '/' is used to check if its a directory */
char *tmp = last_char_is(file_header->name, '/');
if (tmp) {
*tmp = '\0';
}
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
if (longname) {
file_header->name = longname;
longname = NULL;
}
if (linkname) {
file_header->link_target = linkname;
linkname = NULL;
}
#endif
if (!strncmp(file_header->name, "/../"+1, 3)
|| strstr(file_header->name, "/../")
) {
bb_error_msg_and_die("name with '..' encountered: '%s'",
file_header->name);
}
/* Strip trailing '/' in directories */
/* Must be done after mode is set as '/' is used to check if it's a directory */
cp = last_char_is(file_header->name, '/');
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
archive_handle->action_header(archive_handle->file_header);
/* Note that we kill the '/' only after action_header() */
/* (like GNU tar 1.15.1: verbose mode outputs "dir/dir/") */
if (cp) *cp = '\0';
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
archive_handle->action_data(archive_handle);
archive_handle->passed = llist_add_to(archive_handle->passed, file_header->name);
llist_add_to(&(archive_handle->passed), file_header->name);
} else {
data_skip(archive_handle);
free(file_header->name);
}
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);
return EXIT_SUCCESS;
}
+7 -25
View File
@@ -1,38 +1,20 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "libbb.h"
#include "unarchive.h"
char get_header_tar_bz2(archive_handle_t *archive_handle)
{
/* Cant lseek over pipe's */
archive_handle->seek = seek_by_char;
/* 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);
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
/* Can only do one file at a time */
return(EXIT_FAILURE);
return EXIT_FAILURE;
}
+17 -23
View File
@@ -1,42 +1,36 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* 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
/* Cant lseek over pipe's */
archive_handle->seek = seek_by_char;
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
archive_xread_all(archive_handle, &magic, 2);
/* 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");
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);
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
/* Can only do one file at a time */
return(EXIT_FAILURE);
return EXIT_FAILURE;
}
+5 -5
View File
@@ -1,3 +1,4 @@
/* vi: set sw=4 ts=4: */
/*
* Small lzma deflate implementation.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
@@ -5,19 +6,18 @@
* 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)
{
/* Can't lseek over pipes */
archive_handle->seek = seek_by_char;
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);
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
/* Can only do one file at a time */
return EXIT_FAILURE;
}
/* vi:set ts=4: */
+5 -1
View File
@@ -1,4 +1,8 @@
#include <stdio.h>
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
void header_list(const file_header_t *file_header)
+5 -1
View File
@@ -1,4 +1,8 @@
#include <stdio.h>
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
void header_skip(const file_header_t *file_header ATTRIBUTE_UNUSED)
+9 -7
View File
@@ -1,6 +1,8 @@
#include <stdio.h>
#include <string.h>
#include <time.h>
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
@@ -8,11 +10,11 @@ void header_verbose_list(const file_header_t *file_header)
{
struct tm *mtime = localtime(&(file_header->mtime));
printf("%s %d/%d%10u %4u-%02u-%02u %02u:%02u:%02u %s",
printf("%s %d/%d %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
bb_mode_string(file_header->mode),
file_header->uid,
file_header->gid,
(unsigned int) file_header->size,
file_header->size,
1900 + mtime->tm_year,
1 + mtime->tm_mon,
mtime->tm_mday,
@@ -21,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("");
+6 -20
View File
@@ -1,21 +1,8 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <unistd.h>
#include <string.h>
#include "libbb.h"
#include "unarchive.h"
@@ -23,14 +10,13 @@ archive_handle_t *init_handle(void)
{
archive_handle_t *archive_handle;
/* Initialise default values */
archive_handle = xmalloc(sizeof(archive_handle_t));
memset(archive_handle, 0, sizeof(archive_handle_t));
archive_handle->file_header = xmalloc(sizeof(file_header_t));
/* Initialize default values */
archive_handle = xzalloc(sizeof(archive_handle_t));
archive_handle->file_header = xzalloc(sizeof(file_header_t));
archive_handle->action_header = header_skip;
archive_handle->action_data = data_skip;
archive_handle->filter = filter_accept_all;
archive_handle->seek = seek_by_jump;
return(archive_handle);
return archive_handle;
}
+38 -30
View File
@@ -1,51 +1,59 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* 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 */
int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd))
/*
* 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),
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) {
bb_perror_msg_and_die("Fork failed");
}
#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 */
transformer(src_fd, fd_pipe[1]);
close(fd_pipe[1]); /* Send EOF */
close(src_fd);
exit(0);
/* notreached */
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]);
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 */
}
/* parent process */
close(fd_pipe[1]); /* Don't want to write to the child */
return(fd_pipe[0]);
return fd_pipe[0];
}
-178
View File
@@ -1,178 +0,0 @@
/*
* Small range coder implementation for lzma.
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
*
* Based on LzmaDecode.c from the LZMA SDK 4.22 (http://www.7-zip.org/)
* Copyright (c) 1999-2005 Igor Pavlov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdint.h>
#include "libbb.h"
#ifndef always_inline
# if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >0)
# define always_inline __attribute__((always_inline)) inline
# else
# define always_inline inline
# endif
#endif
#ifdef CONFIG_FEATURE_LZMA_FAST
# define speed_inline always_inline
#else
# define speed_inline
#endif
typedef struct {
int fd;
uint8_t *ptr;
uint8_t *buffer;
uint8_t *buffer_end;
int buffer_size;
uint32_t code;
uint32_t range;
uint32_t bound;
} rc_t;
#define RC_TOP_BITS 24
#define RC_MOVE_BITS 5
#define RC_MODEL_TOTAL_BITS 11
/* Called twice: once at startup and once in rc_normalize() */
static void rc_read(rc_t * rc)
{
rc->buffer_size = read(rc->fd, rc->buffer, rc->buffer_size);
if (rc->buffer_size <= 0)
bb_error_msg_and_die("unexpected EOF");
rc->ptr = rc->buffer;
rc->buffer_end = rc->buffer + rc->buffer_size;
}
/* Called once */
static always_inline void rc_init(rc_t * rc, int fd, int buffer_size)
{
int i;
rc->fd = fd;
rc->buffer = malloc(buffer_size);
rc->buffer_size = buffer_size;
rc->buffer_end = rc->buffer + rc->buffer_size;
rc->ptr = rc->buffer_end;
rc->code = 0;
rc->range = 0xFFFFFFFF;
for (i = 0; i < 5; i++) {
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->code = (rc->code << 8) | *rc->ptr++;
}
}
/* Called once. TODO: bb_maybe_free() */
static always_inline void rc_free(rc_t * rc)
{
if (ENABLE_FEATURE_CLEAN_UP)
free(rc->buffer);
}
/* Called twice, but one callsite is in speed_inline'd rc_is_bit_0_helper() */
static void rc_do_normalize(rc_t * rc)
{
if (rc->ptr >= rc->buffer_end)
rc_read(rc);
rc->range <<= 8;
rc->code = (rc->code << 8) | *rc->ptr++;
}
static always_inline void rc_normalize(rc_t * rc)
{
if (rc->range < (1 << RC_TOP_BITS)) {
rc_do_normalize(rc);
}
}
/* Called 9 times */
/* Why rc_is_bit_0_helper exists?
* Because we want to always expose (rc->code < rc->bound) to optimizer
*/
static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
{
rc_normalize(rc);
rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
return rc->bound;
}
static always_inline int rc_is_bit_0(rc_t * rc, uint16_t * p)
{
uint32_t t = rc_is_bit_0_helper(rc, p);
return rc->code < t;
}
/* Called ~10 times, but very small, thus inlined */
static speed_inline void rc_update_bit_0(rc_t * rc, uint16_t * p)
{
rc->range = rc->bound;
*p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS;
}
static speed_inline void rc_update_bit_1(rc_t * rc, uint16_t * p)
{
rc->range -= rc->bound;
rc->code -= rc->bound;
*p -= *p >> RC_MOVE_BITS;
}
/* Called 4 times in unlzma loop */
static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
{
if (rc_is_bit_0(rc, p)) {
rc_update_bit_0(rc, p);
*symbol *= 2;
return 0;
} else {
rc_update_bit_1(rc, p);
*symbol = *symbol * 2 + 1;
return 1;
}
}
/* Called once */
static always_inline int rc_direct_bit(rc_t * rc)
{
rc_normalize(rc);
rc->range >>= 1;
if (rc->code >= rc->range) {
rc->code -= rc->range;
return 1;
}
return 0;
}
/* Called twice */
static speed_inline void
rc_bit_tree_decode(rc_t * rc, uint16_t * p, int num_levels, int *symbol)
{
int i = num_levels;
*symbol = 1;
while (i--)
rc_get_bit(rc, p + *symbol, symbol);
*symbol -= 1 << num_levels;
}
/* vi:set ts=4: */
-32
View File
@@ -1,32 +0,0 @@
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include "unarchive.h"
#include "busybox.h"
/* If we are reading through a pipe(), or from stdin then we cant lseek,
* we must read and discard the data to skip over it.
*
* TODO: rename to seek_by_read
*/
void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size)
{
if (jump_size) {
bb_copyfd_size(archive_handle->src_fd, -1, jump_size);
}
}
+5 -21
View File
@@ -1,35 +1,19 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* 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_char(archive_handle, amount);
seek_by_read(archive_handle, amount);
} else
#endif
bb_perror_msg_and_die("Seek failure");
bb_perror_msg_and_die("seek failure");
}
}
+16
View File
@@ -0,0 +1,16 @@
/* vi: set sw=4 ts=4: */
/*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include "libbb.h"
#include "unarchive.h"
/* If we are reading through a pipe(), or from stdin then we can't lseek,
* we must read and discard the data to skip over it.
*/
void seek_by_read(const archive_handle_t *archive_handle, const unsigned int jump_size)
{
if (jump_size)
bb_copyfd_exact_size(archive_handle->src_fd, -1, jump_size);
}
+6 -19
View File
@@ -1,31 +1,18 @@
/* vi: set sw=4 ts=4: */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include "libbb.h"
#include "unarchive.h"
#include "busybox.h"
void unpack_ar_archive(archive_handle_t *ar_archive)
{
char magic[7];
archive_xread_all(ar_archive, magic, 7);
xread(ar_archive->src_fd, magic, 7);
if (strncmp(magic, "!<arch>", 7) != 0) {
bb_error_msg_and_die("Invalid ar magic");
bb_error_msg_and_die("invalid ar magic");
}
ar_archive->offset += 7;
+226 -167
View File
@@ -7,57 +7,47 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include <fcntl.h>
#include <netinet/in.h> /* For ntohl & htonl function */
#include <string.h> /* For strncmp */
#include <sys/mman.h> /* For mmap */
#include <time.h> /* For ctime */
#include "busybox.h"
#include "libbb.h"
#include "unarchive.h"
#define RPM_HEADER_MAGIC "\216\255\350"
#define RPM_CHAR_TYPE 1
#define RPM_INT8_TYPE 2
#define RPM_INT16_TYPE 3
#define RPM_INT32_TYPE 4
/* #define RPM_INT64_TYPE 5 ---- These aren't supported (yet) */
#define RPM_STRING_TYPE 6
#define RPM_BIN_TYPE 7
#define RPM_STRING_ARRAY_TYPE 8
#define RPM_I18NSTRING_TYPE 9
#define RPM_HEADER_MAGIC "\216\255\350"
#define RPM_CHAR_TYPE 1
#define RPM_INT8_TYPE 2
#define RPM_INT16_TYPE 3
#define RPM_INT32_TYPE 4
/* #define RPM_INT64_TYPE 5 ---- These aren't supported (yet) */
#define RPM_STRING_TYPE 6
#define RPM_BIN_TYPE 7
#define RPM_STRING_ARRAY_TYPE 8
#define RPM_I18NSTRING_TYPE 9
#define RPMTAG_NAME 1000
#define RPMTAG_VERSION 1001
#define RPMTAG_RELEASE 1002
#define RPMTAG_SUMMARY 1004
#define RPMTAG_DESCRIPTION 1005
#define RPMTAG_BUILDTIME 1006
#define RPMTAG_BUILDHOST 1007
#define RPMTAG_SIZE 1009
#define RPMTAG_VENDOR 1011
#define RPMTAG_LICENSE 1014
#define RPMTAG_PACKAGER 1015
#define RPMTAG_GROUP 1016
#define RPMTAG_URL 1020
#define RPMTAG_PREIN 1023
#define RPMTAG_POSTIN 1024
#define RPMTAG_FILEFLAGS 1037
#define RPMTAG_FILEUSERNAME 1039
#define RPMTAG_FILEGROUPNAME 1040
#define RPMTAG_SOURCERPM 1044
#define RPMTAG_PREINPROG 1085
#define RPMTAG_POSTINPROG 1086
#define RPMTAG_PREFIXS 1098
#define RPMTAG_DIRINDEXES 1116
#define RPMTAG_BASENAMES 1117
#define RPMTAG_DIRNAMES 1118
#define RPMFILE_CONFIG (1 << 0)
#define RPMFILE_DOC (1 << 1)
#define TAG_NAME 1000
#define TAG_VERSION 1001
#define TAG_RELEASE 1002
#define TAG_SUMMARY 1004
#define TAG_DESCRIPTION 1005
#define TAG_BUILDTIME 1006
#define TAG_BUILDHOST 1007
#define TAG_SIZE 1009
#define TAG_VENDOR 1011
#define TAG_LICENSE 1014
#define TAG_PACKAGER 1015
#define TAG_GROUP 1016
#define TAG_URL 1020
#define TAG_PREIN 1023
#define TAG_POSTIN 1024
#define TAG_FILEFLAGS 1037
#define TAG_FILEUSERNAME 1039
#define TAG_FILEGROUPNAME 1040
#define TAG_SOURCERPM 1044
#define TAG_PREINPROG 1085
#define TAG_POSTINPROG 1086
#define TAG_PREFIXS 1098
#define TAG_DIRINDEXES 1116
#define TAG_BASENAMES 1117
#define TAG_DIRNAMES 1118
#define RPMFILE_CONFIG (1 << 0)
#define RPMFILE_DOC (1 << 1)
enum rpm_functions_e {
rpm_query = 1,
@@ -80,43 +70,43 @@ static void *map;
static rpm_index **mytags;
static int tagcount;
void extract_cpio_gz(int fd);
rpm_index **rpm_gettags(int fd, int *num_tags);
int bsearch_rpmtag(const void *key, const void *item);
char *rpm_getstring(int tag, int itemindex);
int rpm_getint(int tag, int itemindex);
int rpm_getcount(int tag);
void exec_script(int progtag, int datatag, char *prefix);
void fileaction_dobackup(char *filename, int fileref);
void fileaction_setowngrp(char *filename, int fileref);
void fileaction_list(char *filename, int itemno);
void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref));
static void extract_cpio_gz(int fd);
static rpm_index **rpm_gettags(int fd, int *num_tags);
static int bsearch_rpmtag(const void *key, const void *item);
static char *rpm_getstr(int tag, int itemindex);
static int rpm_getint(int tag, int itemindex);
static int rpm_getcount(int tag);
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;
const int pagesize = getpagesize();
while ((opt = getopt(argc, argv, "iqpldc")) != -1) {
switch (opt) {
case 'i': // First arg: Install mode, with q: Information
if (!func) func |= rpm_install;
case 'i': /* First arg: Install mode, with q: Information */
if (!func) func = rpm_install;
else func |= rpm_query_info;
break;
case 'q': // First arg: Query mode
if (!func) func |= rpm_query;
else bb_show_usage();
case 'q': /* First arg: Query mode */
if (func) bb_show_usage();
func = rpm_query;
break;
case 'p': // Query a package
case 'p': /* Query a package */
func |= rpm_query_package;
break;
case 'l': // List files in a package
case 'l': /* List files in a package */
func |= rpm_query_list;
break;
case 'd': // List doc files in a package (implies list)
case 'd': /* List doc files in a package (implies list) */
func |= rpm_query_list;
func |= rpm_query_list_doc;
break;
case 'c': // List config files in a package (implies list)
case 'c': /* List config files in a package (implies list) */
func |= rpm_query_list;
func |= rpm_query_list_config;
break;
@@ -124,68 +114,92 @@ int rpm_main(int argc, char **argv)
bb_show_usage();
}
}
argv += optind;
argc -= optind;
if (!argc) bb_show_usage();
while (*argv) {
rpm_fd = xopen(*argv++, O_RDONLY);
mytags = rpm_gettags(rpm_fd, &tagcount);
if (!mytags)
bb_error_msg_and_die("error reading rpm header");
offset = xlseek(rpm_fd, 0, SEEK_CUR);
/* Mimimum is one page */
map = mmap(0, offset > pagesize ? (offset + offset % pagesize) : pagesize, PROT_READ, MAP_PRIVATE, rpm_fd, 0);
if (optind == argc) bb_show_usage();
while (optind < argc) {
rpm_fd = bb_xopen(argv[optind], O_RDONLY);
mytags = rpm_gettags(rpm_fd, (int *) &tagcount);
offset = lseek(rpm_fd, 0, SEEK_CUR);
if (!mytags) { printf("Error reading rpm header\n"); exit(-1); }
map = mmap(0, offset > getpagesize() ? (offset + offset % getpagesize()) : getpagesize(), PROT_READ, MAP_PRIVATE, rpm_fd, 0); // Mimimum is one page
if (func & rpm_install) {
loop_through_files(RPMTAG_BASENAMES, fileaction_dobackup); /* Backup any config files */
extract_cpio_gz(rpm_fd); // Extact the archive
loop_through_files(RPMTAG_BASENAMES, fileaction_setowngrp); /* Set the correct file uid/gid's */
} else if (func & rpm_query && func & rpm_query_package) {
if (!((func & rpm_query_info) || (func & rpm_query_list))) { // If just a straight query, just give package name
printf("%s-%s-%s\n", rpm_getstring(RPMTAG_NAME, 0), rpm_getstring(RPMTAG_VERSION, 0), rpm_getstring(RPMTAG_RELEASE, 0));
/* Backup any config files */
loop_through_files(TAG_BASENAMES, fileaction_dobackup);
/* Extact the archive */
extract_cpio_gz(rpm_fd);
/* Set the correct file uid/gid's */
loop_through_files(TAG_BASENAMES, fileaction_setowngrp);
}
else if ((func & (rpm_query|rpm_query_package)) == (rpm_query|rpm_query_package)) {
if (!(func & (rpm_query_info|rpm_query_list))) {
/* If just a straight query, just give package name */
printf("%s-%s-%s\n", rpm_getstr(TAG_NAME, 0), rpm_getstr(TAG_VERSION, 0), rpm_getstr(TAG_RELEASE, 0));
}
if (func & rpm_query_info) {
/* Do the nice printout */
time_t bdate_time;
struct tm *bdate;
char bdatestring[50];
printf("Name : %-29sRelocations: %s\n", rpm_getstring(RPMTAG_NAME, 0), rpm_getstring(RPMTAG_PREFIXS, 0) ? rpm_getstring(RPMTAG_PREFIXS, 0) : "(not relocateable)");
printf("Version : %-34sVendor: %s\n", rpm_getstring(RPMTAG_VERSION, 0), rpm_getstring(RPMTAG_VENDOR, 0) ? rpm_getstring(RPMTAG_VENDOR, 0) : "(none)");
bdate_time = rpm_getint(RPMTAG_BUILDTIME, 0);
printf("Name : %-29sRelocations: %s\n", rpm_getstr(TAG_NAME, 0), rpm_getstr(TAG_PREFIXS, 0) ? rpm_getstr(TAG_PREFIXS, 0) : "(not relocateable)");
printf("Version : %-34sVendor: %s\n", rpm_getstr(TAG_VERSION, 0), rpm_getstr(TAG_VENDOR, 0) ? rpm_getstr(TAG_VENDOR, 0) : "(none)");
bdate_time = rpm_getint(TAG_BUILDTIME, 0);
bdate = localtime((time_t *) &bdate_time);
strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate);
printf("Release : %-30sBuild Date: %s\n", rpm_getstring(RPMTAG_RELEASE, 0), bdatestring);
printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstring(RPMTAG_BUILDHOST, 0));
printf("Group : %-30sSource RPM: %s\n", rpm_getstring(RPMTAG_GROUP, 0), rpm_getstring(RPMTAG_SOURCERPM, 0));
printf("Size : %-33dLicense: %s\n", rpm_getint(RPMTAG_SIZE, 0), rpm_getstring(RPMTAG_LICENSE, 0));
printf("URL : %s\n", rpm_getstring(RPMTAG_URL, 0));
printf("Summary : %s\n", rpm_getstring(RPMTAG_SUMMARY, 0));
printf("Description :\n%s\n", rpm_getstring(RPMTAG_DESCRIPTION, 0));
printf("Release : %-30sBuild Date: %s\n", rpm_getstr(TAG_RELEASE, 0), bdatestring);
printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstr(TAG_BUILDHOST, 0));
printf("Group : %-30sSource RPM: %s\n", rpm_getstr(TAG_GROUP, 0), rpm_getstr(TAG_SOURCERPM, 0));
printf("Size : %-33dLicense: %s\n", rpm_getint(TAG_SIZE, 0), rpm_getstr(TAG_LICENSE, 0));
printf("URL : %s\n", rpm_getstr(TAG_URL, 0));
printf("Summary : %s\n", rpm_getstr(TAG_SUMMARY, 0));
printf("Description :\n%s\n", rpm_getstr(TAG_DESCRIPTION, 0));
}
if (func & rpm_query_list) {
int count, it, flags;
count = rpm_getcount(RPMTAG_BASENAMES);
count = rpm_getcount(TAG_BASENAMES);
for (it = 0; it < count; it++) {
flags = rpm_getint(RPMTAG_FILEFLAGS, it);
switch ((func & rpm_query_list_doc) + (func & rpm_query_list_config))
{
case rpm_query_list_doc: if (!(flags & RPMFILE_DOC)) continue; break;
case rpm_query_list_config: if (!(flags & RPMFILE_CONFIG)) continue; break;
case rpm_query_list_doc + rpm_query_list_config: if (!((flags & RPMFILE_CONFIG) || (flags & RPMFILE_DOC))) continue; break;
flags = rpm_getint(TAG_FILEFLAGS, it);
switch (func & (rpm_query_list_doc|rpm_query_list_config)) {
case rpm_query_list_doc:
if (!(flags & RPMFILE_DOC)) continue;
break;
case rpm_query_list_config:
if (!(flags & RPMFILE_CONFIG)) continue;
break;
case rpm_query_list_doc|rpm_query_list_config:
if (!(flags & (RPMFILE_CONFIG|RPMFILE_DOC))) continue;
break;
}
printf("%s%s\n", rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES, it)), rpm_getstring(RPMTAG_BASENAMES, it));
printf("%s%s\n",
rpm_getstr(TAG_DIRNAMES, rpm_getint(TAG_DIRINDEXES, it)),
rpm_getstr(TAG_BASENAMES, it));
}
}
}
optind++;
free (mytags);
free(mytags);
}
return 0;
}
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_char;
archive_handle->seek = seek_by_read;
//archive_handle->action_header = header_list;
archive_handle->action_data = data_extract_all;
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
@@ -193,26 +207,54 @@ void extract_cpio_gz(int fd) {
archive_handle->src_fd = fd;
archive_handle->offset = 0;
bb_xread_all(archive_handle->src_fd, &magic, 2);
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);
chdir("/"); // 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);
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
continue;
}
rpm_index **rpm_gettags(int fd, int *num_tags)
static rpm_index **rpm_gettags(int fd, int *num_tags)
{
rpm_index **tags = calloc(200, sizeof(struct rpmtag *)); /* We should never need mode than 200, and realloc later */
/* We should never need mode than 200, and realloc later */
rpm_index **tags = xzalloc(200 * sizeof(struct rpmtag *));
int pass, tagindex = 0;
lseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */
for (pass = 0; pass < 2; pass++) { /* 1st pass is the signature headers, 2nd is the main stuff */
xlseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */
/* 1st pass is the signature headers, 2nd is the main stuff */
for (pass = 0; pass < 2; pass++) {
struct {
char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */
uint8_t version; /* 1 byte version number */
@@ -223,87 +265,112 @@ rpm_index **rpm_gettags(int fd, int *num_tags)
rpm_index *tmpindex;
int storepos;
read(fd, &header, sizeof(header));
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) return NULL; /* Invalid magic */
if (header.version != 1) return NULL; /* This program only supports v1 headers */
xread(fd, &header, sizeof(header));
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0)
return NULL; /* Invalid magic */
if (header.version != 1)
return NULL; /* This program only supports v1 headers */
header.size = ntohl(header.size);
header.entries = ntohl(header.entries);
storepos = lseek(fd,0,SEEK_CUR) + header.entries * 16;
storepos = xlseek(fd,0,SEEK_CUR) + header.entries * 16;
while (header.entries--) {
tmpindex = tags[tagindex++] = xmalloc(sizeof(rpm_index));
read(fd, tmpindex, sizeof(rpm_index));
tmpindex->tag = ntohl(tmpindex->tag); tmpindex->type = ntohl(tmpindex->type); tmpindex->count = ntohl(tmpindex->count);
xread(fd, tmpindex, sizeof(rpm_index));
tmpindex->tag = ntohl(tmpindex->tag);
tmpindex->type = ntohl(tmpindex->type);
tmpindex->count = ntohl(tmpindex->count);
tmpindex->offset = storepos + ntohl(tmpindex->offset);
if (pass==0) tmpindex->tag -= 743;
if (pass==0)
tmpindex->tag -= 743;
}
lseek(fd, header.size, SEEK_CUR); /* Seek past store */
if (pass==0) lseek(fd, (8 - (lseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR); /* Skip padding to 8 byte boundary after reading signature headers */
xlseek(fd, header.size, SEEK_CUR); /* Seek past store */
/* Skip padding to 8 byte boundary after reading signature headers */
if (pass==0)
xlseek(fd, (8 - (xlseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR);
}
tags = realloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */
tags = xrealloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */
*num_tags = tagindex;
return tags; /* All done, leave the file at the start of the gzipped cpio archive */
}
int bsearch_rpmtag(const void *key, const void *item)
static int bsearch_rpmtag(const void *key, const void *item)
{
int *tag = (int *)key;
rpm_index **tmp = (rpm_index **) item;
return (*tag - tmp[0]->tag);
}
int rpm_getcount(int tag)
static int rpm_getcount(int tag)
{
rpm_index **found;
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
if (!found) return 0;
else return found[0]->count;
if (!found)
return 0;
return found[0]->count;
}
char *rpm_getstring(int tag, int itemindex)
static char *rpm_getstr(int tag, int itemindex)
{
rpm_index **found;
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
if (!found || itemindex >= found[0]->count) return NULL;
if (!found || itemindex >= found[0]->count)
return NULL;
if (found[0]->type == RPM_STRING_TYPE || found[0]->type == RPM_I18NSTRING_TYPE || found[0]->type == RPM_STRING_ARRAY_TYPE) {
int n;
char *tmpstr = (char *) (map + found[0]->offset);
for (n=0; n < itemindex; n++) tmpstr = tmpstr + strlen(tmpstr) + 1;
for (n=0; n < itemindex; n++)
tmpstr = tmpstr + strlen(tmpstr) + 1;
return tmpstr;
} else return NULL;
}
return NULL;
}
int rpm_getint(int tag, int itemindex)
static int rpm_getint(int tag, int itemindex)
{
rpm_index **found;
int n, *tmpint;
int *tmpint; /* NB: using int8_t* would be easier to code */
/* gcc throws warnings here when sizeof(void*)!=sizeof(int) ...
* it's ok to ignore it because tag won't be used as a pointer */
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
if (!found || itemindex >= found[0]->count) return -1;
if (!found || itemindex >= found[0]->count)
return -1;
tmpint = (int *) (map + found[0]->offset);
if (found[0]->type == RPM_INT32_TYPE) {
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 4);
return ntohl(*tmpint);
} else if (found[0]->type == RPM_INT16_TYPE) {
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 2);
return ntohs(*tmpint);
} else if (found[0]->type == RPM_INT8_TYPE) {
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 1);
return ntohs(*tmpint);
} else return -1;
tmpint = (int *) ((char *) tmpint + itemindex*4);
/*return ntohl(*tmpint);*/
/* int can be != int32_t */
return ntohl(*(int32_t*)tmpint);
}
if (found[0]->type == RPM_INT16_TYPE) {
tmpint = (int *) ((char *) tmpint + itemindex*2);
/* ??? read int, and THEN ntohs() it?? */
/*return ntohs(*tmpint);*/
return ntohs(*(int16_t*)tmpint);
}
if (found[0]->type == RPM_INT8_TYPE) {
tmpint = (int *) ((char *) tmpint + itemindex);
/* ??? why we don't read byte here??? */
/*return ntohs(*tmpint);*/
return *(int8_t*)tmpint;
}
return -1;
}
void fileaction_dobackup(char *filename, int fileref)
static void fileaction_dobackup(char *filename, int fileref)
{
struct stat oldfile;
int stat_res;
char *newname;
if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */
stat_res = lstat (filename, &oldfile);
if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */
newname = bb_xstrdup(filename);
newname = strcat(newname, ".rpmorig");
if (rpm_getint(TAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) {
/* Only need to backup config files */
stat_res = lstat(filename, &oldfile);
if (stat_res == 0 && S_ISREG(oldfile.st_mode)) {
/* File already exists - really should check MD5's etc to see if different */
newname = xasprintf("%s.rpmorig", filename);
copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS);
remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE);
free(newname);
@@ -311,29 +378,21 @@ void fileaction_dobackup(char *filename, int fileref)
}
}
void fileaction_setowngrp(char *filename, int fileref)
static void fileaction_setowngrp(char *filename, int fileref)
{
int uid, gid;
uid = bb_xgetpwnam(rpm_getstring(RPMTAG_FILEUSERNAME, fileref));
gid = bb_xgetgrnam(rpm_getstring(RPMTAG_FILEGROUPNAME, fileref));
chown (filename, uid, gid);
uid = xuname2uid(rpm_getstr(TAG_FILEUSERNAME, fileref));
gid = xgroup2gid(rpm_getstr(TAG_FILEGROUPNAME, fileref));
chown(filename, uid, gid);
}
void fileaction_list(char *filename, int ATTRIBUTE_UNUSED fileref)
{
printf("%s\n", filename);
}
void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref))
static void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref))
{
int count = 0;
char *filename, *tmp_dirname, *tmp_basename;
while (rpm_getstring(filetag, count)) {
tmp_dirname = rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES, count)); /* 1st put on the directory */
tmp_basename = rpm_getstring(RPMTAG_BASENAMES, count);
filename = xmalloc(strlen(tmp_basename) + strlen(tmp_dirname) + 1);
strcpy(filename, tmp_dirname); /* First the directory name */
strcat(filename, tmp_basename); /* then the filename */
while (rpm_getstr(filetag, count)) {
char* filename = xasprintf("%s%s",
rpm_getstr(TAG_DIRNAMES, rpm_getint(TAG_DIRINDEXES, count)),
rpm_getstr(TAG_BASENAMES, count));
fileaction(filename, count++);
free(filename);
}
+14 -30
View File
@@ -4,26 +4,9 @@
*
* Copyright (C) 2001 by Laurence Anderson
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <sys/types.h>
#include <netinet/in.h> /* For ntohl & htonl function */
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include "busybox.h"
#include "libbb.h"
#include "unarchive.h"
#define RPM_MAGIC "\355\253\356\333"
@@ -52,12 +35,12 @@ static void skip_header(int rpm_fd)
{
struct rpm_header header;
bb_xread_all(rpm_fd, &header, sizeof(struct rpm_header));
xread(rpm_fd, &header, sizeof(struct rpm_header));
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) {
bb_error_msg_and_die("Invalid RPM header magic"); /* Invalid magic */
bb_error_msg_and_die("invalid RPM header magic"); /* Invalid magic */
}
if (header.version != 1) {
bb_error_msg_and_die("Unsupported RPM header version"); /* This program only supports v1 headers */
bb_error_msg_and_die("unsupported RPM header version"); /* This program only supports v1 headers */
}
header.entries = ntohl(header.entries);
header.size = ntohl(header.size);
@@ -66,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;
@@ -75,12 +59,12 @@ int rpm2cpio_main(int argc, char **argv)
if (argc == 1) {
rpm_fd = STDIN_FILENO;
} else {
rpm_fd = bb_xopen(argv[1], O_RDONLY);
rpm_fd = xopen(argv[1], O_RDONLY);
}
bb_xread_all(rpm_fd, &lead, sizeof(struct rpm_lead));
xread(rpm_fd, &lead, sizeof(struct rpm_lead));
if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) {
bb_error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */
bb_error_msg_and_die("invalid RPM magic"); /* Just check the magic, the rest is irrelevant */
}
/* Skip the signature header */
@@ -90,14 +74,14 @@ int rpm2cpio_main(int argc, char **argv)
/* Skip the main header */
skip_header(rpm_fd);
bb_xread_all(rpm_fd, &magic, 2);
xread(rpm_fd, &magic, 2);
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
bb_error_msg_and_die("Invalid gzip magic");
bb_error_msg_and_die("invalid gzip magic");
}
check_header_gzip(rpm_fd);
if (inflate_gunzip(rpm_fd, STDOUT_FILENO) != 0) {
bb_error_msg("Error inflating");
check_header_gzip_or_die(rpm_fd);
if (unpack_gz_stream(rpm_fd, STDOUT_FILENO) < 0) {
bb_error_msg("error inflating");
}
close(rpm_fd);
+478 -414
View File
File diff suppressed because it is too large. Load diff
-114
View File
@@ -1,114 +0,0 @@
/* vi: set sw=4 ts=4: */
/*
* Uncompress applet for busybox (c) 2002 Glenn McGrath
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "libbb.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 = bb_getopt_ulflags(argc, argv, "cf");
while (optind < argc) {
const char *compressed_file = argv[optind++];
const char *delete_path = NULL;
char *uncompressed_file = NULL;
int src_fd;
int dst_fd;
if (strcmp(compressed_file, "-") == 0) {
src_fd = STDIN_FILENO;
flags |= GUNZIP_TO_STDOUT;
} else {
src_fd = bb_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 = bb_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 */
dst_fd = bb_xopen(uncompressed_file, O_WRONLY | O_CREAT);
/* Set permissions on the file */
stat(compressed_file, &stat_buf);
chmod(uncompressed_file, stat_buf.st_mode);
/* If unzip succeeds remove the old file */
delete_path = compressed_file;
}
/* do the decompression, and cleanup */
if ((bb_xread_char(src_fd) != 0x1f) || (bb_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("Couldn't remove %s", delete_path);
}
free(uncompressed_file);
}
return status;
}
-65
View File
@@ -1,65 +0,0 @@
/*
* 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.
*/
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "busybox.h"
#include "unarchive.h"
#define UNLZMA_OPT_STDOUT 1
int unlzma_main(int argc, char **argv)
{
char *filename;
unsigned long opt;
int status, src_fd, dst_fd;
opt = bb_getopt_ulflags(argc, argv, "c");
/* Set input filename and number */
filename = argv[optind];
if ((filename) && (filename[0] != '-') && (filename[1] != '\0')) {
/* Open input file */
src_fd = bb_xopen(filename, O_RDONLY);
} else {
src_fd = STDIN_FILENO;
filename = 0;
}
/* if called as lzmacat force the stdout flag */
if ((opt & UNLZMA_OPT_STDOUT) || bb_applet_name[4] == 'c')
filename = 0;
if (filename) {
char *extension = filename + strlen(filename) - 5;
if (strcmp(extension, ".lzma") != 0) {
bb_error_msg_and_die("Invalid extension");
}
*extension = 0;
dst_fd = bb_xopen(filename, O_WRONLY | O_CREAT);
} else
dst_fd = STDOUT_FILENO;
status = unlzma(src_fd, dst_fd);
if (filename) {
if (!status)
filename[strlen(filename)] = '.';
if (unlink(filename) < 0) {
bb_error_msg_and_die("Couldn't remove %s", filename);
}
}
return status;
}
/* vi:set ts=4: */
+70 -122
View File
@@ -24,39 +24,13 @@
* - central directory
*/
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "libbb.h"
#include "unarchive.h"
#include "busybox.h"
#if BB_BIG_ENDIAN
static inline unsigned short
__swap16(unsigned short x) {
return (((uint16_t)(x) & 0xFF) << 8) | (((uint16_t)(x) & 0xFF00) >> 8);
}
static inline uint32_t
__swap32(uint32_t x) {
return (((x & 0xFF) << 24) |
((x & 0xFF00) << 8) |
((x & 0xFF0000) >> 8) |
((x & 0xFF000000) >> 24));
}
#else /* it's little-endian */
# define __swap16(x) (x)
# define __swap32(x) (x)
#endif /* BB_BIG_ENDIAN */
#define ZIP_FILEHEADER_MAGIC __swap32(0x04034b50)
#define ZIP_CDS_MAGIC __swap32(0x02014b50)
#define ZIP_CDS_END_MAGIC __swap32(0x06054b50)
#define ZIP_DD_MAGIC __swap32(0x08074b50)
extern unsigned int gunzip_crc;
extern unsigned int gunzip_bytes_out;
#define ZIP_FILEHEADER_MAGIC SWAP_LE32(0x04034b50)
#define ZIP_CDS_MAGIC SWAP_LE32(0x02014b50)
#define ZIP_CDS_END_MAGIC SWAP_LE32(0x06054b50)
#define ZIP_DD_MAGIC SWAP_LE32(0x08074b50)
typedef union {
unsigned char raw[26];
@@ -71,63 +45,55 @@ typedef union {
unsigned int ucmpsize ATTRIBUTE_PACKED; /* 18-21 */
unsigned short filename_len; /* 22-23 */
unsigned short extra_len; /* 24-25 */
} formated ATTRIBUTE_PACKED;
} formatted ATTRIBUTE_PACKED;
} zip_header_t;
static void unzip_skip(int fd, off_t skip)
{
if (lseek(fd, skip, SEEK_CUR) == (off_t)-1) {
if ((errno != ESPIPE) || (bb_copyfd_size(fd, -1, skip) != skip)) {
bb_error_msg_and_die("Seek failure");
}
}
}
static void unzip_read(int fd, void *buf, size_t count)
{
if (bb_xread(fd, buf, count) != count) {
bb_error_msg_and_die("Read failure");
if (errno != ESPIPE)
bb_error_msg_and_die("seek failure");
bb_copyfd_exact_size(fd, -1, skip);
}
}
static void unzip_create_leading_dirs(char *fn)
{
/* Create all leading directories */
char *name = bb_xstrdup(fn);
char *name = xstrdup(fn);
if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) {
bb_error_msg_and_die("Failed to create directory");
bb_error_msg_and_die("exiting"); /* bb_make_directory is noisy */
}
free(name);
}
static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
{
if (zip_header->formated.method == 0) {
if (zip_header->formatted.method == 0) {
/* Method 0 - stored (not compressed) */
int size = zip_header->formated.ucmpsize;
if (size && (bb_copyfd_size(src_fd, dst_fd, size) != size)) {
bb_error_msg_and_die("Cannot complete extraction");
}
off_t size = zip_header->formatted.ucmpsize;
if (size)
bb_copyfd_exact_size(src_fd, dst_fd, size);
} else {
/* Method 8 - inflate */
inflate_init(zip_header->formated.cmpsize);
inflate_unzip(src_fd, dst_fd);
inflate_cleanup();
inflate_unzip_result res;
/* err = */ inflate_unzip(&res, zip_header->formatted.cmpsize, src_fd, dst_fd);
// we should check for -1 error return
/* Validate decompression - crc */
if (zip_header->formated.crc32 != (gunzip_crc ^ 0xffffffffL)) {
bb_error_msg("Invalid compressed data--crc error");
if (zip_header->formatted.crc32 != (res.crc ^ 0xffffffffL)) {
bb_error_msg("invalid compressed data--%s error", "crc");
return 1;
}
/* Validate decompression - size */
if (zip_header->formated.ucmpsize != gunzip_bytes_out) {
bb_error_msg("Invalid compressed data--length error");
if (zip_header->formatted.ucmpsize != res.bytes_out) {
bb_error_msg("invalid compressed data--%s error", "length");
return 1;
}
}
return 0;
}
int unzip_main(int argc, char **argv);
int unzip_main(int argc, char **argv)
{
zip_header_t zip_header;
@@ -144,10 +110,10 @@ int unzip_main(int argc, char **argv)
char key_buf[512];
struct stat stat_buf;
while((opt = getopt(argc, argv, "-d:lnopqx")) != -1) {
switch(opt_range) {
while ((opt = getopt(argc, argv, "-d:lnopqx")) != -1) {
switch (opt_range) {
case 0: /* Options */
switch(opt) {
switch (opt) {
case 'l': /* List */
verbosity = v_list;
break;
@@ -168,7 +134,8 @@ int unzip_main(int argc, char **argv)
break;
case 1 : /* The zip file */
src_fn = bb_xstrndup(optarg, strlen(optarg)+4);
src_fn = xmalloc(strlen(optarg)+4);
strcpy(src_fn, optarg);
opt_range++;
break;
@@ -180,7 +147,7 @@ int unzip_main(int argc, char **argv)
case 1: /* Include files */
if (opt == 1) {
zaccept = llist_add_to(zaccept, optarg);
llist_add_to(&zaccept, optarg);
} else if (opt == 'd') {
base_dir = optarg;
@@ -196,7 +163,7 @@ int unzip_main(int argc, char **argv)
case 2 : /* Exclude files */
if (opt == 1) {
zreject = llist_add_to(zreject, optarg);
llist_add_to(&zreject, optarg);
} else if (opt == 'd') { /* Extract to base directory */
base_dir = optarg;
@@ -217,28 +184,26 @@ int unzip_main(int argc, char **argv)
}
/* Open input file */
if (strcmp("-", src_fn) == 0) {
if (LONE_DASH(src_fn)) {
src_fd = STDIN_FILENO;
/* Cannot use prompt mode since zip data is arriving on STDIN */
overwrite = (overwrite == o_prompt) ? o_never : overwrite;
} else {
static const char *const extn[] = {"", ".zip", ".ZIP"};
int orig_src_fn_len = strlen(src_fn);
for(i = 0; (i < 3) && (src_fd == -1); i++) {
for (i = 0; (i < 3) && (src_fd == -1); i++) {
strcpy(src_fn + orig_src_fn_len, extn[i]);
src_fd = open(src_fn, O_RDONLY);
}
if (src_fd == -1) {
src_fn[orig_src_fn_len] = 0;
bb_error_msg_and_die("Cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
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);
}
}
/* Change dir if necessary */
if (base_dir && chdir(base_dir)) {
bb_perror_msg_and_die("Cannot chdir");
}
if (base_dir)
xchdir(base_dir);
if (verbosity != v_silent)
printf("Archive: %s\n", src_fn);
@@ -249,43 +214,40 @@ int unzip_main(int argc, char **argv)
unsigned int magic;
/* Check magic number */
unzip_read(src_fd, &magic, 4);
xread(src_fd, &magic, 4);
if (magic == ZIP_CDS_MAGIC) {
break;
} else if (magic != ZIP_FILEHEADER_MAGIC) {
bb_error_msg_and_die("Invalid zip magic %08X", magic);
bb_error_msg_and_die("invalid zip magic %08X", magic);
}
/* Read the file header */
unzip_read(src_fd, zip_header.raw, 26);
#if BB_BIG_ENDIAN
zip_header.formated.version = __swap16(zip_header.formated.version);
zip_header.formated.flags = __swap16(zip_header.formated.flags);
zip_header.formated.method = __swap16(zip_header.formated.method);
zip_header.formated.modtime = __swap16(zip_header.formated.modtime);
zip_header.formated.moddate = __swap16(zip_header.formated.moddate);
zip_header.formated.crc32 = __swap32(zip_header.formated.crc32);
zip_header.formated.cmpsize = __swap32(zip_header.formated.cmpsize);
zip_header.formated.ucmpsize = __swap32(zip_header.formated.ucmpsize);
zip_header.formated.filename_len = __swap16(zip_header.formated.filename_len);
zip_header.formated.extra_len = __swap16(zip_header.formated.extra_len);
#endif /* BB_BIG_ENDIAN */
if ((zip_header.formated.method != 0) && (zip_header.formated.method != 8)) {
bb_error_msg_and_die("Unsupported compression method %d", zip_header.formated.method);
xread(src_fd, zip_header.raw, 26);
zip_header.formatted.version = SWAP_LE32(zip_header.formatted.version);
zip_header.formatted.flags = SWAP_LE32(zip_header.formatted.flags);
zip_header.formatted.method = SWAP_LE32(zip_header.formatted.method);
zip_header.formatted.modtime = SWAP_LE32(zip_header.formatted.modtime);
zip_header.formatted.moddate = SWAP_LE32(zip_header.formatted.moddate);
zip_header.formatted.crc32 = SWAP_LE32(zip_header.formatted.crc32);
zip_header.formatted.cmpsize = SWAP_LE32(zip_header.formatted.cmpsize);
zip_header.formatted.ucmpsize = SWAP_LE32(zip_header.formatted.ucmpsize);
zip_header.formatted.filename_len = SWAP_LE32(zip_header.formatted.filename_len);
zip_header.formatted.extra_len = SWAP_LE32(zip_header.formatted.extra_len);
if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) {
bb_error_msg_and_die("unsupported compression method %d", zip_header.formatted.method);
}
/* Read filename */
free(dst_fn);
dst_fn = xmalloc(zip_header.formated.filename_len + 1);
unzip_read(src_fd, dst_fn, zip_header.formated.filename_len);
dst_fn[zip_header.formated.filename_len] = 0;
dst_fn = xzalloc(zip_header.formatted.filename_len + 1);
xread(src_fd, dst_fn, zip_header.formatted.filename_len);
/* Skip extra header bytes */
unzip_skip(src_fd, zip_header.formated.extra_len);
unzip_skip(src_fd, zip_header.formatted.extra_len);
if ((verbosity == v_list) && !list_header_done){
printf(" Length Date Time Name\n");
printf(" -------- ---- ---- ----\n");
puts(" Length Date Time Name\n"
" -------- ---- ---- ----");
list_header_done = 1;
}
@@ -295,12 +257,12 @@ int unzip_main(int argc, char **argv)
i = 'n';
} else { /* Extract entry */
total_size += zip_header.formated.ucmpsize;
total_size += zip_header.formatted.ucmpsize;
if (verbosity == v_list) { /* List entry */
unsigned int dostime = zip_header.formated.modtime | (zip_header.formated.moddate << 16);
unsigned int dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
zip_header.formated.ucmpsize,
zip_header.formatted.ucmpsize,
(dostime & 0x01e00000) >> 21,
(dostime & 0x001f0000) >> 16,
(((dostime & 0xfe000000) >> 25) + 1980) % 100,
@@ -309,21 +271,19 @@ int unzip_main(int argc, char **argv)
dst_fn);
total_entries++;
i = 'n';
} else if (dst_fd == STDOUT_FILENO) { /* Extracting to STDOUT */
i = -1;
} else if (last_char_is(dst_fn, '/')) { /* Extract directory */
if (stat(dst_fn, &stat_buf) == -1) {
if (errno != ENOENT) {
bb_perror_msg_and_die("Cannot stat '%s'",dst_fn);
bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
}
if (verbosity == v_normal) {
printf(" creating: %s\n", dst_fn);
}
unzip_create_leading_dirs(dst_fn);
if (bb_make_directory(dst_fn, 0777, 0)) {
bb_error_msg_and_die("Failed to create directory");
bb_error_msg_and_die("exiting");
}
} else {
if (!S_ISDIR(stat_buf.st_mode)) {
@@ -333,28 +293,25 @@ int unzip_main(int argc, char **argv)
i = 'n';
} else { /* Extract file */
_check_file:
_check_file:
if (stat(dst_fn, &stat_buf) == -1) { /* File does not exist */
if (errno != ENOENT) {
bb_perror_msg_and_die("Cannot stat '%s'",dst_fn);
bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
}
i = 'y';
} else { /* File already exists */
if (overwrite == o_never) {
i = 'n';
} else if (S_ISREG(stat_buf.st_mode)) { /* File is regular file */
if (overwrite == o_always) {
i = 'y';
} else {
printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
if (!fgets(key_buf, 512, stdin)) {
bb_perror_msg_and_die("Cannot read input");
bb_perror_msg_and_die("cannot read input");
}
i = key_buf[0];
}
} else { /* File is not regular file */
bb_error_msg_and_die("'%s' exists but is not regular file",dst_fn);
}
@@ -367,13 +324,13 @@ int unzip_main(int argc, char **argv)
overwrite = o_always;
case 'y': /* Open file and fall into unzip */
unzip_create_leading_dirs(dst_fn);
dst_fd = bb_xopen(dst_fn, O_WRONLY | O_CREAT);
dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC);
case -1: /* Unzip */
if (verbosity == v_normal) {
printf(" inflating: %s\n", dst_fn);
}
if (unzip_extract(&zip_header, src_fd, dst_fd)) {
failed = 1;
failed = 1;
}
if (dst_fd != STDOUT_FILENO) {
/* closing STDOUT is potentially bad for future business */
@@ -385,17 +342,17 @@ int unzip_main(int argc, char **argv)
overwrite = o_never;
case 'n':
/* Skip entry data */
unzip_skip(src_fd, zip_header.formated.cmpsize);
unzip_skip(src_fd, zip_header.formatted.cmpsize);
break;
case 'r':
/* Prompt for new name */
printf("new name: ");
if (!fgets(key_buf, 512, stdin)) {
bb_perror_msg_and_die("Cannot read input");
bb_perror_msg_and_die("cannot read input");
}
free(dst_fn);
dst_fn = bb_xstrdup(key_buf);
dst_fn = xstrdup(key_buf);
chomp(dst_fn);
goto _check_file;
@@ -405,7 +362,7 @@ int unzip_main(int argc, char **argv)
}
/* Data descriptor section */
if (zip_header.formated.flags & 4) {
if (zip_header.formatted.flags & 4) {
/* skip over duplicate crc, compressed size and uncompressed size */
unzip_skip(src_fd, 12);
}
@@ -418,12 +375,3 @@ int unzip_main(int argc, char **argv)
return failed;
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+35 -11
View File
@@ -5,74 +5,98 @@
menu "Console Utilities"
config CONFIG_CHVT
config CHVT
bool "chvt"
default n
help
This program is used to change to another terminal.
Example: chvt 4 (change to terminal /dev/tty4)
config CONFIG_CLEAR
config CLEAR
bool "clear"
default n
help
This program clears the terminal screen.
config CONFIG_DEALLOCVT
config DEALLOCVT
bool "deallocvt"
default n
help
This program deallocates unused virtual consoles.
config CONFIG_DUMPKMAP
config DUMPKMAP
bool "dumpkmap"
default n
help
This program dumps the kernel's keyboard translation table to
stdout, in binary format. You can then use loadkmap to load it.
config CONFIG_LOADFONT
config LOADFONT
bool "loadfont"
default n
help
This program loads a console font from standard input.
config CONFIG_LOADKMAP
config LOADKMAP
bool "loadkmap"
default n
help
This program loads a keyboard translation table from
standard input.
config CONFIG_OPENVT
config OPENVT
bool "openvt"
default n
help
This program is used to start a command on an unused
virtual terminal.
config CONFIG_RESET
config RESET
bool "reset"
default n
help
This program is used to reset the terminal screen, if it
gets messed up.
config CONFIG_SETCONSOLE
config RESIZE
bool "resize"
default n
help
This program is used to (re)set the width and height of your current
terminal.
config FEATURE_RESIZE_PRINT
bool "print environment variables"
default n
depends on RESIZE
help
Prints the newly set size (number of columns and rows) of
the terminal.
E.g.:
COLUMNS=80;LINES=44;export COLUMNS LINES;
config SETCONSOLE
bool "setconsole"
default n
help
This program redirects the system console to another device,
like the current tty while logged in via telnet.
config CONFIG_SETKEYCODES
config FEATURE_SETCONSOLE_LONG_OPTIONS
bool "Enable long options"
default n
depends on SETCONSOLE && GETOPT_LONG
help
Support long options for the setconsole applet.
config SETKEYCODES
bool "setkeycodes"
default n
help
This program loads entries into the kernel's scancode-to-keycode
map, allowing unusual keyboards to generate usable keycodes.
config CONFIG_SETLOGCONS
config SETLOGCONS
bool "setlogcons"
default n
help
+19
View File
@@ -0,0 +1,19 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
lib-y:=
lib-$(CONFIG_CHVT) += chvt.o
lib-$(CONFIG_CLEAR) += clear.o
lib-$(CONFIG_DEALLOCVT) += deallocvt.o
lib-$(CONFIG_DUMPKMAP) += dumpkmap.o
lib-$(CONFIG_SETCONSOLE) += setconsole.o
lib-$(CONFIG_LOADFONT) += loadfont.o
lib-$(CONFIG_LOADKMAP) += loadkmap.o
lib-$(CONFIG_OPENVT) += openvt.o
lib-$(CONFIG_RESET) += reset.o
lib-$(CONFIG_RESIZE) += resize.o
lib-$(CONFIG_SETKEYCODES) += setkeycodes.o
lib-$(CONFIG_SETLOGCONS) += setlogcons.o
-23
View File
@@ -1,23 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
ifndef top_srcdir
top_srcdir=..
endif
ifndef top_builddir
top_builddir=..
endif
srcdir=$(top_srcdir)/console/tools
CONSOLETOOLS_DIR:=./
include $(top_builddir)/Rules.mak
include $(top_builddir)/.config
include $(srcdir)/Makefile.in
all: $(libraries-y)
-include $(top_builddir)/.depend
clean:
rm -f *.o *.a $(AR_TARGET)
-38
View File
@@ -1,38 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
CONSOLETOOLS_AR:=console-tools.a
ifndef $(CONSOLETOOLS_DIR)
CONSOLETOOLS_DIR:=$(top_builddir)/console-tools/
endif
srcdir=$(top_srcdir)/console-tools
CONSOLETOOLS-y:=
CONSOLETOOLS-$(CONFIG_CHVT) += chvt.o
CONSOLETOOLS-$(CONFIG_CLEAR) += clear.o
CONSOLETOOLS-$(CONFIG_DEALLOCVT) += deallocvt.o
CONSOLETOOLS-$(CONFIG_DUMPKMAP) += dumpkmap.o
CONSOLETOOLS-$(CONFIG_SETCONSOLE) += setconsole.o
CONSOLETOOLS-$(CONFIG_LOADFONT) += loadfont.o
CONSOLETOOLS-$(CONFIG_LOADKMAP) += loadkmap.o
CONSOLETOOLS-$(CONFIG_OPENVT) += openvt.o
CONSOLETOOLS-$(CONFIG_RESET) += reset.o
CONSOLETOOLS-$(CONFIG_SETKEYCODES) += setkeycodes.o
CONSOLETOOLS-$(CONFIG_SETLOGCONS) += setlogcons.o
ifneq ($(strip $(CONSOLETOOLS-y)),)
libraries-y+=$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR)
endif
CONSOLETOOLS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(CONSOLETOOLS-y))
CONSOLETOOLS_SRC-a:=$(wildcard $(srcdir)/*.c)
APPLET_SRC-y+=$(CONSOLETOOLS_SRC-y)
APPLET_SRC-a+=$(CONSOLETOOLS_SRC-a)
$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR): $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS-y))
$(do_ar)
$(CONSOLETOOLS_DIR)%.o: $(srcdir)/%.c
$(compile.c)
+7 -35
View File
@@ -4,29 +4,10 @@
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* no options, no getopt */
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include "busybox.h"
#include "libbb.h"
/* From <linux/vt.h> */
enum {
@@ -34,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;
@@ -43,19 +25,9 @@ int chvt_main(int argc, char **argv)
}
fd = get_console_fd();
num = bb_xgetlarg(argv[1], 10, 0, INT_MAX);
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;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+3 -17
View File
@@ -4,29 +4,15 @@
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
*/
/* 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;
+12 -31
View File
@@ -5,52 +5,33 @@
* Copyright (C) 2003 by Tito Ragusa <farmatito@tiscali.it>
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* no options, no getopt */
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#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:
if ((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0) {
bb_error_msg_and_die("0: illegal VT number");
}
case 2:
num = xatou_range(argv[1], 1, 63);
/* Fallthrough */
case 1:
break;
default:
bb_show_usage();
case 1:
break;
default:
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;
}
+11 -29
View File
@@ -4,30 +4,11 @@
*
* Copyright (C) Arne Bernin <arne@matrix.loopback.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
*/
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include "busybox.h"
#include "libbb.h"
/* From <linux/kd.h> */
struct kbentry {
@@ -41,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 = bb_xopen(CURRENT_VC, O_RDWR);
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] */
@@ -68,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);
}
}
+51 -79
View File
@@ -7,21 +7,10 @@
* Loads the console font, and possibly the corresponding screen map(s).
* (Adapted for busybox by Matej Vela.)
*/
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <memory.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <sys/ioctl.h>
#include "libbb.h"
#include <sys/kd.h>
#include <endian.h>
#include "busybox.h"
enum{
enum {
PSF_MAGIC1 = 0x36,
PSF_MAGIC2 = 0x04,
@@ -32,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 = bb_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);
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;
@@ -75,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
@@ -92,14 +66,14 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
struct unipair *up;
int ct = 0, maxct;
int glyph;
u_short unicode;
uint16_t unicode;
maxct = tailsz; /* more than enough */
up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
up = xmalloc(maxct * sizeof(struct unipair));
for (glyph = 0; glyph < fontsize; glyph++) {
while (tailsz >= 2) {
unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
unicode = (((uint16_t) inbuf[1]) << 8) + inbuf[0];
tailsz -= 2;
inbuf += 2;
if (unicode == PSF_SEPARATOR)
@@ -116,54 +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)) {
#if 0
if (errno == ENOMEM) {
/* change advice parameters */
}
#endif
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))
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");
inputlth = full_read(STDIN_FILENO, inbuf, INBUF_SIZE);
if (inputlth < 0)
bb_perror_msg_and_die("error reading input font");
if (inputlth >= INBUF_SIZE)
bb_error_msg_and_die("font too large");
/* test for psf first */
{
struct psf_header psfhdr;
int fontsize;
int hastable;
unsigned int head0, head;
unsigned head0, head;
if (inputlth < sizeof(struct psf_header))
goto no_psf;
@@ -174,11 +132,11 @@ static void loadnewfont(int fd)
goto no_psf;
if (psfhdr.mode > PSF_MAXMODE)
bb_error_msg_and_die("Unsupported psf file mode");
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");
bb_error_msg_and_die("only fontsize 256 supported");
#endif
hastable = (psfhdr.mode & PSF_MODEHASTAB);
unit = psfhdr.charsize;
@@ -186,14 +144,14 @@ static void loadnewfont(int fd)
head = head0 + fontsize * unit;
if (head > inputlth || (!hastable && head != inputlth))
bb_error_msg_and_die("Input file: bad length");
bb_error_msg_and_die("input file: bad length");
do_loadfont(fd, inbuf + head0, unit, fontsize);
if (hastable)
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
return;
}
no_psf:
no_psf:
/* file with three code pages? */
if (inputlth == 9780) {
offset = 40;
@@ -201,9 +159,23 @@ static void loadnewfont(int fd)
} else {
/* bare font */
if (inputlth & 0377)
bb_error_msg_and_die("Bad input file size");
bb_error_msg_and_die("bad input file size");
offset = 0;
unit = inputlth / 256;
}
do_loadfont(fd, inbuf + offset, unit, 256);
}
int loadfont_main(int argc, char **argv);
int loadfont_main(int argc, char **argv)
{
int fd;
if (argc != 1)
bb_show_usage();
fd = xopen(CURRENT_VC, O_RDWR);
loadnewfont(fd);
return EXIT_SUCCESS;
}
+12 -32
View File
@@ -4,30 +4,11 @@
*
* Copyright (C) 1998 Enrique Zanardi <ezanardi@ull.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
*/
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include "busybox.h"
#include "libbb.h"
#define BINARY_KEYMAP_MAGIC "bkeymap"
@@ -44,28 +25,29 @@ 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;
int i, j, fd;
u_short ibuff[NR_KEYS];
uint16_t ibuff[NR_KEYS];
char flags[MAX_NR_KEYMAPS];
char buff[7];
if (argc != 1)
bb_show_usage();
fd = bb_xopen(CURRENT_VC, O_RDWR);
fd = xopen(CURRENT_VC, O_RDWR);
if ((bb_full_read(0, buff, 7) != 7) || (strncmp(buff, BINARY_KEYMAP_MAGIC, 7) != 0))
bb_error_msg_and_die("This is not a valid binary keymap.");
xread(0, buff, 7);
if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
bb_error_msg_and_die("this is not a valid binary keymap");
if (bb_full_read(0, flags, MAX_NR_KEYMAPS) != MAX_NR_KEYMAPS)
bb_perror_msg_and_die("Error reading keymap flags");
xread(0, flags, MAX_NR_KEYMAPS);
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
if (flags[i] == 1) {
bb_full_read(0, ibuff, NR_KEYS * sizeof(u_short));
xread(0, ibuff, NR_KEYS * sizeof(uint16_t));
for (j = 0; j < NR_KEYS; j++) {
ke.kb_index = j;
ke.kb_table = i;
@@ -75,8 +57,6 @@ int loadkmap_main(int argc, char **argv)
}
}
/* Don't bother to close files. Exit does that
* automagically, so we can save a few bytes */
/* close(fd); */
return EXIT_SUCCESS;
if (ENABLE_FEATURE_CLEAN_UP) close(fd);
return 0;
}
+14 -52
View File
@@ -5,69 +5,31 @@
* busyboxed by Quy Tonthat <quy@signal3.com>
* hacked by Tito <farmatito@tiscali.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* getopt not needed */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
#include <ctype.h>
#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 > 12 */
sprintf(vtname, VC_FORMAT, (int)bb_xgetlarg(argv[1], 10, 1, 12));
if (fork() == 0) {
/* leave current vt */
if (setsid() < 0) {
bb_perror_msg_and_die("setsid");
}
close(0); /* so that new vt becomes stdin */
/* check for illegal vt number: < 1 or > 63 */
sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63));
/* and grab new one */
fd = bb_xopen(vtname, O_RDWR);
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);
/* Reassign stdout and sterr */
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
execvp(argv[2], &argv[2]);
_exit(1);
}
return EXIT_SUCCESS;
BB_EXECVP(argv[2], &argv[2]);
_exit(1);
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+3 -18
View File
@@ -5,29 +5,14 @@
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
* Written by Erik Andersen and Kent Robotti <robotti@metconnect.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* 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)) {
+69
View File
@@ -0,0 +1,69 @@
/* vi: set sw=4 ts=4: */
/*
* resize - set terminal width and height.
*
* Copyright 2006 Bernhard Fischer
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* no options, no getopt */
#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 new;
struct winsize w = { 0,0,0,0 };
int ret;
/* 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);
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
*/
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;
}
+15 -39
View File
@@ -4,44 +4,30 @@
*
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <getopt.h> /* struct option */
#include <getopt.h>
#include "libbb.h"
#include "busybox.h"
static const struct option setconsole_long_options[] = {
{ "reset", 0, NULL, 'r' },
{ 0, 0, 0, 0 }
};
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
static const char setconsole_longopts[] ALIGN1 =
"reset\0" No_argument "r"
;
#endif
#define OPT_SETCONS_RESET 1
int setconsole_main(int argc, char **argv);
int setconsole_main(int argc, char **argv)
{
unsigned long flags;
const char *device = CURRENT_TTY;
bb_applet_long_options = setconsole_long_options;
flags = bb_getopt_ulflags(argc, argv, "r");
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
applet_long_options = setconsole_longopts;
#endif
flags = getopt32(argv, "r");
if (argc - optind > 1)
bb_show_usage();
@@ -52,19 +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(bb_xopen(device, O_RDONLY), TIOCCONS)) {
bb_perror_msg_and_die("TIOCCONS");
}
xioctl(xopen(device, O_RDONLY), TIOCCONS, NULL);
return EXIT_SUCCESS;
}
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
+21 -46
View File
@@ -6,28 +6,11 @@
*
* Adjusted for BusyBox by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* 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 {
@@ -37,38 +20,30 @@ 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)
{
char *ep;
int fd, sc;
struct kbkeycode a;
int fd, sc;
struct kbkeycode a;
if (argc % 2 != 1 || argc < 2) {
bb_show_usage();
if (argc % 2 != 1 || argc < 2) {
bb_show_usage();
}
fd = get_console_fd();
while (argc > 2) {
a.keycode = atoi(argv[2]);
a.scancode = sc = strtol(argv[1], &ep, 16);
if (*ep) {
bb_error_msg_and_die("error reading SCANCODE: '%s'", argv[1]);
while (argc > 2) {
a.keycode = xatoul_range(argv[2], 0, 127);
a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255);
if (a.scancode > 127) {
a.scancode -= 0xe000;
a.scancode += 128;
}
ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
"failed to set SCANCODE %x to KEYCODE %d",
sc, a.keycode);
argc -= 2;
argv += 2;
}
if (a.scancode > 127) {
a.scancode -= 0xe000;
a.scancode += 128;
}
if (a.scancode > 255 || a.keycode > 127) {
bb_error_msg_and_die("SCANCODE or KEYCODE outside bounds");
}
if (ioctl(fd,KDSETKEYCODE,&a)) {
perror("KDSETKEYCODE");
bb_error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
}
argc -= 2;
argv += 2;
}
return EXIT_SUCCESS;
}
+7 -10
View File
@@ -1,5 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
* setlogcons: Send kernel messages to the current console or to console N
* setlogcons: Send kernel messages to the current console or to console N
*
* Copyright (C) 2006 by Jan Kiszka <jan.kiszka@web.de>
*
@@ -8,13 +9,10 @@
* 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 "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;
@@ -25,10 +23,9 @@ extern int setlogcons_main(int argc, char **argv)
arg.subarg = 0; /* to specified console (current as default) */
if (argc == 2)
arg.subarg = atoi(argv[1]);
arg.subarg = xatoul_range(argv[1], 0, 63);
if (ioctl(bb_xopen("/dev/tty1", O_RDONLY), TIOCLINUX, &arg))
bb_perror_msg_and_die("TIOCLINUX");;
xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
return 0;
}
+276 -165
View File
@@ -5,7 +5,7 @@
menu "Coreutils"
config CONFIG_BASENAME
config BASENAME
bool "basename"
default n
help
@@ -13,88 +13,94 @@ config CONFIG_BASENAME
leaving just the filename itself. Enable this option if you wish
to enable the 'basename' utility.
config CONFIG_CAL
config CAL
bool "cal"
default n
help
cal is used to display a monthly calender.
config CONFIG_CAT
config CAT
bool "cat"
default n
help
cat is used to concatenate files and print them to the standard
output. Enable this option if you wish to enable the 'cat' utility.
config CONFIG_CHGRP
config CATV
bool "catv"
default n
help
Display nonprinting characters as escape sequences (like some
implementations' cat -v option).
config CHGRP
bool "chgrp"
default n
help
chgrp is used to change the group ownership of files.
config CONFIG_CHMOD
config CHMOD
bool "chmod"
default n
help
chmod is used to change the access permission of files.
config CONFIG_CHOWN
config CHOWN
bool "chown"
default n
help
chown is used to change the user and/or group ownership
of files.
config CONFIG_CHROOT
config CHROOT
bool "chroot"
default n
help
chroot is used to change the root directory and run a command.
The default command is `/bin/sh'.
config CONFIG_CMP
bool "cmp"
config CKSUM
bool "cksum"
default n
help
cmp is used to compare two files and returns the result
to standard output.
cksum is used to calculate the CRC32 checksum of a file.
config CONFIG_COMM
config COMM
bool "comm"
default n
help
comm is used to compare two files line by line and return
a three-column output.
config CONFIG_CP
config CP
bool "cp"
default n
help
cp is used to copy files and directories.
config CONFIG_CUT
config CUT
bool "cut"
default n
help
cut is used to print selected parts of lines from
each file to stdout.
config CONFIG_DATE
config DATE
bool "date"
default n
help
date is used to set the system date or display the
current time in the given format.
config CONFIG_FEATURE_DATE_ISOFMT
bool " Enable ISO date format output (-I)"
config FEATURE_DATE_ISOFMT
bool "Enable ISO date format output (-I)"
default y
depends on CONFIG_DATE
depends on DATE
help
Enable option (-I) to output an ISO-8601 compliant
date/time string.
config CONFIG_DD
config DD
bool "dd"
default n
help
@@ -102,61 +108,84 @@ config CONFIG_DD
by default) using specific input and output blocksizes,
while optionally performing conversions on it.
config CONFIG_DF
config FEATURE_DD_SIGNAL_HANDLING
bool "Enable DD signal handling for status reporting"
default y
depends on DD
help
sending a SIGUSR1 signal to a running `dd' process makes it
print to standard error the number of records read and written
so far, then to resume copying.
$ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid
10899206+0 records in 10899206+0 records out
config FEATURE_DD_IBS_OBS
bool "Enable ibs, obs and conv options"
default n
depends on DD
help
Enables support for writing a certain number of bytes in and out,
at a time, and performing conversions on the data stream.
config DF
bool "df"
default n
help
df reports the amount of disk space used and available
on filesystems.
config CONFIG_DIRNAME
config DIRNAME
bool "dirname"
default n
help
dirname is used to strip a non-directory suffix from
a file name.
config CONFIG_DOS2UNIX
config DOS2UNIX
bool "dos2unix/unix2dos"
default n
help
dos2unix is used to convert a text file from DOS format to
UNIX format, and vice versa.
config CONFIG_UNIX2DOS
config UNIX2DOS
bool
default y
depends on CONFIG_DOS2UNIX
depends on DOS2UNIX
help
unix2dos is used to convert a text file from UNIX format to
DOS format, and vice versa.
config CONFIG_DU
config DU
bool "du (default blocksize of 512 bytes)"
default n
help
du is used to report the amount of disk space used
for specified files.
config CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
bool " Use a default blocksize of 1024 bytes (1K)"
config FEATURE_DU_DEFAULT_BLOCKSIZE_1K
bool "Use a default blocksize of 1024 bytes (1K)"
default y
depends on CONFIG_DU
depends on DU
help
Use a blocksize of (1K) instead of the default 512b.
config CONFIG_ECHO
config ECHO
bool "echo (basic SuSv3 version taking no options)"
default n
help
echo is used to print a specified string to stdout.
# this entry also appears in shell/Config.in, next to the echo builtin
config CONFIG_FEATURE_FANCY_ECHO
bool " Enable echo options (-n and -e)"
config FEATURE_FANCY_ECHO
bool "Enable echo options (-n and -e)"
default y
depends on CONFIG_ECHO
depends on ECHO
help
This adds options (-n and -e) to echo.
config CONFIG_ENV
config ENV
bool "env"
default n
help
@@ -164,144 +193,171 @@ config CONFIG_ENV
a command; without options it displays the current
environment.
config CONFIG_EXPR
config FEATURE_ENV_LONG_OPTIONS
bool "Enable long options"
default n
depends on ENV && GETOPT_LONG
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
help
expr is used to calculate numbers and print the result
to standard output.
config CONFIG_EXPR_MATH_SUPPORT_64
bool " Extend Posix numbers support to 64 bit"
config EXPR_MATH_SUPPORT_64
bool "Extend Posix numbers support to 64 bit"
default n
depends on CONFIG_EXPR
depends on EXPR
help
Enable 64-bit math support in the expr applet. This will make
the applet slightly larger, but will allow computation with very
large numbers.
config CONFIG_FALSE
config FALSE
bool "false"
default n
help
false returns an exit code of FALSE (1).
config CONFIG_FOLD
config FOLD
bool "fold"
default n
help
Wrap text to fit a specific width.
config CONFIG_HEAD
config HEAD
bool "head"
default n
help
head is used to print the first specified number of lines
from files.
config CONFIG_FEATURE_FANCY_HEAD
bool " Enable head options (-c, -q, and -v)"
config FEATURE_FANCY_HEAD
bool "Enable head options (-c, -q, and -v)"
default n
depends on CONFIG_HEAD
depends on HEAD
help
This enables the head options (-c, -q, and -v).
config CONFIG_HOSTID
config HOSTID
bool "hostid"
default n
help
hostid prints the numeric identifier (in hexadecimal) for
the current host.
config CONFIG_ID
config ID
bool "id"
default n
help
id displays the current user and group ID names.
config CONFIG_INSTALL
config INSTALL
bool "install"
default n
help
Copy files and set attributes.
config CONFIG_LENGTH
config FEATURE_INSTALL_LONG_OPTIONS
bool "Enable long options"
default n
depends on INSTALL && GETOPT_LONG
help
Support long options for the install applet.
config LENGTH
bool "length"
default n
help
length is used to print out the length of a specified string.
config CONFIG_LN
config LN
bool "ln"
default n
help
ln is used to create hard or soft links between files.
config CONFIG_LOGNAME
config LOGNAME
bool "logname"
default n
help
logname is used to print the current user's login name.
config CONFIG_LS
config LS
bool "ls"
default n
help
ls is used to list the contents of directories.
config CONFIG_FEATURE_LS_FILETYPES
bool " Enable filetyping options (-p and -F)"
config FEATURE_LS_FILETYPES
bool "Enable filetyping options (-p and -F)"
default y
depends on CONFIG_LS
depends on LS
help
Enable the ls options (-p and -F).
config CONFIG_FEATURE_LS_FOLLOWLINKS
bool " Enable symlinks dereferencing (-L)"
config FEATURE_LS_FOLLOWLINKS
bool "Enable symlinks dereferencing (-L)"
default y
depends on CONFIG_LS
depends on LS
help
Enable the ls option (-L).
config CONFIG_FEATURE_LS_RECURSIVE
bool " Enable recursion (-R)"
config FEATURE_LS_RECURSIVE
bool "Enable recursion (-R)"
default y
depends on CONFIG_LS
depends on LS
help
Enable the ls option (-R).
config CONFIG_FEATURE_LS_SORTFILES
bool " Sort the file names"
config FEATURE_LS_SORTFILES
bool "Sort the file names"
default y
depends on CONFIG_LS
depends on LS
help
Allow ls to sort file names alphabetically.
config CONFIG_FEATURE_LS_TIMESTAMPS
bool " Show file timestamps"
config FEATURE_LS_TIMESTAMPS
bool "Show file timestamps"
default y
depends on CONFIG_LS
depends on LS
help
Allow ls to display timestamps for files.
config CONFIG_FEATURE_LS_USERNAME
bool " Show username/groupnames"
config FEATURE_LS_USERNAME
bool "Show username/groupnames"
default y
depends on CONFIG_LS
depends on LS
help
Allow ls to display username/groupname for files.
config CONFIG_FEATURE_LS_COLOR
bool " Allow use of color to identify file types"
config FEATURE_LS_COLOR
bool "Allow use of color to identify file types"
default y
depends on CONFIG_LS
depends on LS && GETOPT_LONG
help
This enables the --color option to ls.
config CONFIG_FEATURE_LS_COLOR_IS_DEFAULT
bool " Produce colored ls output by default"
config FEATURE_LS_COLOR_IS_DEFAULT
bool "Produce colored ls output by default"
default n
depends on CONFIG_FEATURE_LS_COLOR
depends on FEATURE_LS_COLOR
help
Saying yes here will turn coloring on by default,
even if no "--color" option is given to the ls command.
@@ -309,129 +365,157 @@ config CONFIG_FEATURE_LS_COLOR_IS_DEFAULT
configurable, and the output may not be legible on
many output screens.
config CONFIG_MD5SUM
config MD5SUM
bool "md5sum"
default n
help
md5sum is used to print or check MD5 checksums.
config CONFIG_MKDIR
config MKDIR
bool "mkdir"
default n
help
mkdir is used to create directories with the specified names.
config CONFIG_MKFIFO
config FEATURE_MKDIR_LONG_OPTIONS
bool "Enable long options"
default n
depends on MKDIR && GETOPT_LONG
help
Support long options for the mkdir applet.
config MKFIFO
bool "mkfifo"
default n
help
mkfifo is used to create FIFOs (named pipes).
The `mknod' program can also create FIFOs.
config CONFIG_MKNOD
config MKNOD
bool "mknod"
default n
help
mknod is used to create FIFOs or block/character special
files with the specified names.
config CONFIG_MV
config MV
bool "mv"
default n
help
mv is used to move or rename files or directories.
config CONFIG_NICE
config FEATURE_MV_LONG_OPTIONS
bool "Enable long options"
default n
depends on MV && GETOPT_LONG
help
Support long options for the mv applet.
config NICE
bool "nice"
default n
help
nice runs a program with modified scheduling priority.
config CONFIG_NOHUP
config NOHUP
bool "nohup"
default n
help
run a command immune to hangups, with output to a non-tty.
config CONFIG_OD
config OD
bool "od"
default n
help
od is used to dump binary files in octal and other formats.
config CONFIG_PRINTENV
config PRINTENV
bool "printenv"
default n
help
printenv is used to print all or part of environment.
config CONFIG_PRINTF
config PRINTF
bool "printf"
default n
help
printf is used to format and print specified strings.
It's similar to `echo' except it has more options.
config CONFIG_PWD
config PWD
bool "pwd"
default n
help
pwd is used to print the current directory.
config CONFIG_REALPATH
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
help
Return the canonicalized absolute pathname.
This isn't provided by GNU shellutils, but where else does it belong.
config CONFIG_RM
config RM
bool "rm"
default n
help
rm is used to remove files or directories.
config CONFIG_RMDIR
config RMDIR
bool "rmdir"
default n
help
rmdir is used to remove empty directories.
config CONFIG_SEQ
config SEQ
bool "seq"
default n
help
print a sequence of numbers
config CONFIG_SHA1SUM
config SHA1SUM
bool "sha1sum"
default n
help
Compute and check SHA1 message digest
config CONFIG_SLEEP
config SLEEP
bool "sleep (single integer arg with no suffix)"
default n
help
sleep is used to pause for a specified number of seconds,
config CONFIG_FEATURE_FANCY_SLEEP
bool " Enable multiple integer args and optional time suffixes"
config FEATURE_FANCY_SLEEP
bool "Enable multiple integer args and optional time suffixes"
default n
depends on CONFIG_SLEEP
depends on SLEEP
help
Allow sleep to pause for specified minutes, hours, and days.
config CONFIG_SORT
config SORT
bool "sort"
default n
help
sort is used to sort lines of text in specified files.
config CONFIG_FEATURE_SORT_BIG
bool " full SuSv3 compliant sort (Support -ktcsbdfiozgM)"
config FEATURE_SORT_BIG
bool "full SuSv3 compliant sort (Support -ktcsbdfiozgM)"
default y
depends on CONFIG_SORT
depends on SORT
help
Without this, sort only supports -r, -u, and an integer version
of -n. Selecting this adds sort keys, floating point support, and
@@ -440,109 +524,124 @@ config CONFIG_FEATURE_SORT_BIG
The SuSv3 sort standard is available at:
http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
config CONFIG_STAT
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
help
display file or filesystem status.
config CONFIG_FEATURE_STAT_FORMAT
bool " Enable custom formats (-c)"
config FEATURE_STAT_FORMAT
bool "Enable custom formats (-c)"
default n
depends on CONFIG_STAT
depends on STAT
help
Without this, stat will not support the '-c format' option where
users can pass a custom format string for output. This adds about
7k to a nonstatic build on amd64.
config CONFIG_STTY
config STTY
bool "stty"
default n
help
stty is used to change and print terminal line settings.
config CONFIG_SUM
config SUM
bool "sum"
default n
help
checksum and count the blocks in a file
config CONFIG_SYNC
config SYNC
bool "sync"
default n
help
sync is used to flush filesystem buffers.
config CONFIG_TAIL
config TAIL
bool "tail"
default n
help
tail is used to print the last specified number of lines
from files.
config CONFIG_FEATURE_FANCY_TAIL
bool " Enable extra tail options (-q, -s, and -v)"
config FEATURE_FANCY_TAIL
bool "Enable extra tail options (-q, -s, and -v)"
default y
depends on CONFIG_TAIL
depends on TAIL
help
The options (-q, -s, and -v) are provided by GNU tail, but
are not specific in the SUSv3 standard.
config CONFIG_TEE
config TEE
bool "tee"
default n
help
tee is used to read from standard input and write
to standard output and files.
config CONFIG_FEATURE_TEE_USE_BLOCK_IO
bool " Enable block i/o (larger/faster) instead of byte i/o."
config FEATURE_TEE_USE_BLOCK_IO
bool "Enable block i/o (larger/faster) instead of byte i/o."
default n
depends on CONFIG_TEE
depends on TEE
help
Enable this option for a faster tee, at expense of size.
config CONFIG_TEST
config TEST
bool "test"
default n
help
test is used to check file types and compare values,
returning an appropriate exit code. The shells (ash
and bash) have test builtin.
returning an appropriate exit code. The bash shell
has test built in, ash can build it in optionally.
config CONFIG_FEATURE_TEST_64
bool " Extend test to 64 bit"
config FEATURE_TEST_64
bool "Extend test to 64 bit"
default n
depends on CONFIG_TEST
depends on TEST
help
Enable 64-bit support in test.
config CONFIG_TOUCH
config TOUCH
bool "touch"
default n
help
touch is used to create or change the access and/or
modification timestamp of specified files.
config CONFIG_TR
config TR
bool "tr"
default n
help
tr is used to squeeze, and/or delete characters from standard
input, writing to standard output.
config CONFIG_FEATURE_TR_CLASSES
bool " Enable character classes (such as [:upper:])"
config FEATURE_TR_CLASSES
bool "Enable character classes (such as [:upper:])"
default n
depends on CONFIG_TR
depends on TR
help
Enable character classes, enabling commands such as:
tr [:upper:] [:lower:] to convert input into lowercase.
config CONFIG_FEATURE_TR_EQUIV
bool " Enable equivalence classes"
config FEATURE_TR_EQUIV
bool "Enable equivalence classes"
default n
depends on CONFIG_TR
depends on TR
help
Enable equivalence classes, which essentially add the enclosed
character to the current set. For instance, tr [=a=] xyz would
@@ -550,79 +649,91 @@ config CONFIG_FEATURE_TR_EQUIV
useful for cases when no other way of expressing a character
is possible.
config CONFIG_TRUE
config TRUE
bool "true"
default n
help
true returns an exit code of TRUE (0).
config CONFIG_TTY
config TTY
bool "tty"
default n
help
tty is used to print the name of the current terminal to
standard output.
config CONFIG_UNAME
config UNAME
bool "uname"
default n
help
uname is used to print system information.
config CONFIG_UNIQ
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
help
uniq is used to remove duplicate lines from a sorted file.
config CONFIG_USLEEP
config USLEEP
bool "usleep"
default n
help
usleep is used to pause for a specified number of microseconds.
config CONFIG_UUDECODE
config UUDECODE
bool "uudecode"
default n
help
uudecode is used to decode a uuencoded file.
config CONFIG_UUENCODE
config UUENCODE
bool "uuencode"
default n
help
uuencode is used to uuencode a file.
config CONFIG_WATCH
bool "watch"
default n
select CONFIG_DATE
help
watch is used to execute a program periodically, showing
output to the screen.
config CONFIG_WC
config WC
bool "wc"
default n
help
wc is used to print the number of bytes, words, and lines,
in specified files.
config CONFIG_WHO
config FEATURE_WC_LARGE
bool "Support very large files in wc"
default n
depends on WC
help
Use "unsigned long long" in wc for count variables
config WHO
bool "who"
default n
select CONFIG_FEATURE_UTMP
select FEATURE_UTMP
help
who is used to show who is logged on.
config CONFIG_WHOAMI
config WHOAMI
bool "whoami"
default n
help
whoami is used to print the username of the current
user id (same as id -un).
config CONFIG_YES
config YES
bool "yes"
default n
help
@@ -630,46 +741,46 @@ config CONFIG_YES
the default string `y'.
comment "Common options for cp and mv"
depends on CONFIG_CP || CONFIG_MV
depends on CP || MV
config CONFIG_FEATURE_PRESERVE_HARDLINKS
bool " Preserve hard links"
config FEATURE_PRESERVE_HARDLINKS
bool "Preserve hard links"
default n
depends on CONFIG_CP || CONFIG_MV
depends on CP || MV
help
Allow cp and mv to preserve hard links.
comment "Common options for ls, more and telnet"
depends on CONFIG_LS || CONFIG_MORE || CONFIG_TELNET
depends on LS || MORE || TELNET
config CONFIG_FEATURE_AUTOWIDTH
bool " Calculate terminal & column widths"
config FEATURE_AUTOWIDTH
bool "Calculate terminal & column widths"
default y
depends on CONFIG_LS || CONFIG_MORE || CONFIG_TELNET
depends on LS || MORE || TELNET
help
This option allows utilities such as 'ls', 'more' and 'telnet'
to determine the width of the screen, which can allow them to
to determine the width of the screen, which can allow them to
display additional text or avoid wrapping text onto the next line.
If you leave this disabled, your utilities will be especially
If you leave this disabled, your utilities will be especially
primitive and will be unable to determine the current screen width.
comment "Common options for df, du, ls"
depends on CONFIG_DF || CONFIG_DU || CONFIG_LS
depends on DF || DU || LS
config CONFIG_FEATURE_HUMAN_READABLE
bool " Support for human readable output (example 13k, 23M, 235G)"
config FEATURE_HUMAN_READABLE
bool "Support for human readable output (example 13k, 23M, 235G)"
default n
depends on CONFIG_DF || CONFIG_DU || CONFIG_LS
depends on DF || DU || LS
help
Allow df, du, and ls to have human readable output.
comment "Common options for md5sum, sha1sum"
depends on CONFIG_MD5SUM || CONFIG_SHA1SUM
depends on MD5SUM || SHA1SUM
config CONFIG_FEATURE_MD5_SHA1_SUM_CHECK
bool " Enable -c, -s and -w options"
config FEATURE_MD5_SHA1_SUM_CHECK
bool "Enable -c, -s and -w options"
default n
depends on CONFIG_MD5SUM || CONFIG_SHA1SUM
depends on MD5SUM || SHA1SUM
help
Enabling the -c options allows files to be checked
against pre-calculated hash values.
+86
View File
@@ -0,0 +1,86 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
libs-y += libcoreutils/
lib-y:=
lib-$(CONFIG_BASENAME) += basename.o
lib-$(CONFIG_CAL) += cal.o
lib-$(CONFIG_CAT) += cat.o
lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
lib-$(CONFIG_LESS) += cat.o # less too
lib-$(CONFIG_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_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_DIRNAME) += dirname.o
lib-$(CONFIG_DOS2UNIX) += dos2unix.o
lib-$(CONFIG_DU) += du.o
lib-$(CONFIG_ECHO) += echo.o
lib-$(CONFIG_ASH) += echo.o # used by ash
lib-$(CONFIG_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
lib-$(CONFIG_HOSTID) += hostid.o
lib-$(CONFIG_ID) += id.o
lib-$(CONFIG_INSTALL) += install.o
lib-$(CONFIG_LENGTH) += length.o
lib-$(CONFIG_LN) += ln.o
lib-$(CONFIG_LOGNAME) += logname.o
lib-$(CONFIG_LS) += ls.o
lib-$(CONFIG_MD5SUM) += md5_sha1_sum.o
lib-$(CONFIG_MKDIR) += mkdir.o
lib-$(CONFIG_MKFIFO) += mkfifo.o
lib-$(CONFIG_MKNOD) += mknod.o
lib-$(CONFIG_MV) += mv.o
lib-$(CONFIG_NICE) += nice.o
lib-$(CONFIG_NOHUP) += nohup.o
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
lib-$(CONFIG_SUM) += sum.o
lib-$(CONFIG_SYNC) += sync.o
lib-$(CONFIG_TAIL) += tail.o
lib-$(CONFIG_TEE) += tee.o
lib-$(CONFIG_TEST) += test.o
lib-$(CONFIG_ASH) += test.o # used by ash
lib-$(CONFIG_TOUCH) += touch.o
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_WC) += wc.o
lib-$(CONFIG_WHO) += who.o
lib-$(CONFIG_WHOAMI) += whoami.o
lib-$(CONFIG_YES) += yes.o
-23
View File
@@ -1,23 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
ifndef top_srcdir
top_srcdir=..
endif
ifndef top_builddir
top_builddir=..
endif
srcdir=$(top_srcdir)/coreutils
SHELLUTILS_DIR:=./
include $(top_builddir)/Rules.mak
include $(top_builddir)/.config
include $(srcdir)/Makefile.in
all: $(libraries-y)
-include $(top_builddir)/.depend
clean:
rm -f *.o *.a $(AR_TARGET)
-99
View File
@@ -1,99 +0,0 @@
# Makefile for busybox
#
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
#
# Licensed under the GPL v2, see the file LICENSE in this tarball.
COREUTILS_AR:=coreutils.a
ifndef $(COREUTILS_DIR)
COREUTILS_DIR:=$(top_builddir)/coreutils/
endif
srcdir=$(top_srcdir)/coreutils
COREUTILS-y:=
COREUTILS-$(CONFIG_BASENAME) += basename.o
COREUTILS-$(CONFIG_CAL) += cal.o
COREUTILS-$(CONFIG_CAT) += cat.o
COREUTILS-$(CONFIG_CHGRP) += chgrp.o
COREUTILS-$(CONFIG_CHMOD) += chmod.o
COREUTILS-$(CONFIG_CHOWN) += chown.o
COREUTILS-$(CONFIG_CHROOT) += chroot.o
COREUTILS-$(CONFIG_CMP) += cmp.o
COREUTILS-$(CONFIG_COMM) += comm.o
COREUTILS-$(CONFIG_CP) += cp.o
COREUTILS-$(CONFIG_CUT) += cut.o
COREUTILS-$(CONFIG_DATE) += date.o
COREUTILS-$(CONFIG_DD) += dd.o
COREUTILS-$(CONFIG_DF) += df.o
COREUTILS-$(CONFIG_DIRNAME) += dirname.o
COREUTILS-$(CONFIG_DOS2UNIX) += dos2unix.o
COREUTILS-$(CONFIG_DU) += du.o
COREUTILS-$(CONFIG_ECHO) += echo.o
COREUTILS-$(CONFIG_ENV) += env.o
COREUTILS-$(CONFIG_EXPR) += expr.o
COREUTILS-$(CONFIG_FALSE) += false.o
COREUTILS-$(CONFIG_FOLD) += fold.o
COREUTILS-$(CONFIG_HEAD) += head.o
COREUTILS-$(CONFIG_HOSTID) += hostid.o
COREUTILS-$(CONFIG_ID) += id.o
COREUTILS-$(CONFIG_INSTALL) += install.o
COREUTILS-$(CONFIG_LENGTH) += length.o
COREUTILS-$(CONFIG_LN) += ln.o
COREUTILS-$(CONFIG_LOGNAME) += logname.o
COREUTILS-$(CONFIG_LS) += ls.o
COREUTILS-$(CONFIG_MD5SUM) += md5_sha1_sum.o
COREUTILS-$(CONFIG_MKDIR) += mkdir.o
COREUTILS-$(CONFIG_MKFIFO) += mkfifo.o
COREUTILS-$(CONFIG_MKNOD) += mknod.o
COREUTILS-$(CONFIG_MV) += mv.o
COREUTILS-$(CONFIG_NICE) += nice.o
COREUTILS-$(CONFIG_NOHUP) += nohup.o
COREUTILS-$(CONFIG_OD) += od.o
COREUTILS-$(CONFIG_PRINTENV) += printenv.o
COREUTILS-$(CONFIG_PRINTF) += printf.o
COREUTILS-$(CONFIG_PWD) += pwd.o
COREUTILS-$(CONFIG_REALPATH) += realpath.o
COREUTILS-$(CONFIG_RM) += rm.o
COREUTILS-$(CONFIG_RMDIR) += rmdir.o
COREUTILS-$(CONFIG_SEQ) += seq.o
COREUTILS-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
COREUTILS-$(CONFIG_SLEEP) += sleep.o
COREUTILS-$(CONFIG_SORT) += sort.o
COREUTILS-$(CONFIG_STAT) += stat.o
COREUTILS-$(CONFIG_STTY) += stty.o
COREUTILS-$(CONFIG_SUM) += sum.o
COREUTILS-$(CONFIG_SYNC) += sync.o
COREUTILS-$(CONFIG_TAIL) += tail.o
COREUTILS-$(CONFIG_TEE) += tee.o
COREUTILS-$(CONFIG_TEST) += test.o
COREUTILS-$(CONFIG_TOUCH) += touch.o
COREUTILS-$(CONFIG_TR) += tr.o
COREUTILS-$(CONFIG_TRUE) += true.o
COREUTILS-$(CONFIG_TTY) += tty.o
COREUTILS-$(CONFIG_UNAME) += uname.o
COREUTILS-$(CONFIG_UNIQ) += uniq.o
COREUTILS-$(CONFIG_USLEEP) += usleep.o
COREUTILS-$(CONFIG_UUDECODE) += uudecode.o
COREUTILS-$(CONFIG_UUENCODE) += uuencode.o
COREUTILS-$(CONFIG_WATCH) += watch.o
COREUTILS-$(CONFIG_WC) += wc.o
COREUTILS-$(CONFIG_WHO) += who.o
COREUTILS-$(CONFIG_WHOAMI) += whoami.o
COREUTILS-$(CONFIG_YES) += yes.o
COREUTILS-y:=$(sort $(COREUTILS-y))
ifneq ($(strip $(COREUTILS-y)),)
libraries-y+=$(COREUTILS_DIR)$(COREUTILS_AR)
endif
COREUTILS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(COREUTILS-y))
COREUTILS_SRC-a:=$(wildcard $(srcdir)/*.c)
APPLET_SRC-y+=$(COREUTILS_SRC-y)
APPLET_SRC-a+=$(COREUTILS_SRC-a)
$(COREUTILS_DIR)$(COREUTILS_AR): $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
$(do_ar)
$(COREUTILS_DIR)%.o: $(srcdir)/%.c
$(compile.c)
+6 -18
View File
@@ -4,19 +4,7 @@
*
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
*/
@@ -32,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;
@@ -58,5 +46,5 @@ int basename_main(int argc, char **argv)
puts(s);
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
return fflush(stdout);
}
+63 -95
View File
@@ -1,23 +1,11 @@
/* vi: set sw=4 ts=4: */
/*
* Calendar implementation for busybox
*
* See original copyright at the end of this file
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* BB_AUDIT SUSv3 compliant with -j and -y extensions (from util-linux). */
/* BB_AUDIT BUG: The output of 'cal -j 1752' is incorrect. The upstream
@@ -29,19 +17,9 @@
* Major size reduction... over 50% (>1.5k) on i386.
*/
#include <sys/types.h>
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "libbb.h"
#include "busybox.h"
#ifdef CONFIG_LOCALE_SUPPORT
#include <locale.h>
#endif
/* 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 */
@@ -52,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[] = {
1, 2, 14, 15, 16,
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) \
@@ -88,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)
@@ -101,29 +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];
#ifdef CONFIG_LOCALE_SUPPORT
setlocale(LC_TIME, "");
#endif
flags = bb_getopt_ulflags(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();
}
@@ -136,18 +105,18 @@ int cal_main(int argc, char **argv)
}
} else {
if (argc == 2) {
month = bb_xgetularg10_bnd(*argv++, 1, 12);
month = xatou_range(*argv++, 1, 12);
}
year = bb_xgetularg10_bnd(*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 {
zero_tm.tm_mon = i;
strftime(buf, sizeof(buf), "%B", &zero_tm);
month_names[i] = bb_xstrdup(buf);
month_names[i] = xstrdup(buf);
if (i < 7) {
zero_tm.tm_wday = i;
@@ -157,13 +126,13 @@ 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);
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
bb_printf("%*s%s\n%s\n",
printf("%*s%s\n%s\n",
((7*julian + WEEK_LEN) - len) / 2, "",
lineout, day_headings);
for (row = 0; row < 6; row++) {
@@ -172,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);
@@ -194,9 +163,9 @@ int cal_main(int argc, char **argv)
center(month_names[month + 1], week_len, HEAD_SEP);
}
center(month_names[month + 2 - julian], week_len, 0);
bb_printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings);
printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings);
if (!julian) {
bb_printf("%*s%s", HEAD_SEP, "", day_headings);
printf("%*s%s", HEAD_SEP, "", day_headings);
}
putchar('\n');
for (row = 0; row < (6*7); row += 7) {
@@ -210,7 +179,7 @@ int cal_main(int argc, char **argv)
}
}
bb_fflush_stdout_and_exit(0);
fflush_stdout_and_exit(0);
}
/*
@@ -220,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));
@@ -241,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)) {
@@ -254,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);
}
@@ -277,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)
@@ -290,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';
@@ -301,11 +269,11 @@ 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;
bb_printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
}
static void blank_string(char *buf, size_t buflen)
@@ -314,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) {
@@ -331,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';
@@ -375,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.
*/
Loaded 100 of 965 files, more files were not shown because too many files have changed in this diff. Show more