Compare commits

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

# size */*/diff.o
   text    data     bss     dec     hex filename
   7055       8     305    7368    1cc8 busybox.t2/coreutils/diff.o
   7002       0       0    7002    1b5a busybox.t3/coreutils/diff.o
2007-06-04 12:21:53 +00:00
Denis Vlasenko 821cc25f43 ping: stop using data/bss
function                                             old     new   delta
ping_main                                            375     392     +17
unpack_tail                                          317     320      +3
ping4                                                525     528      +3
ping6                                                772     773      +1
sendping6                                             99      98      -1
sendping4                                            184     183      -1
myid                                                   2       -      -2
sendping_tail                                        154     151      -3
tsum                                                   4       -      -4
tmin                                                   4       -      -4
tmax                                                   4       -      -4
source_lsa                                             4       -      -4
pingsock                                               4       -      -4
pingcount                                              4       -      -4
ntransmitted                                           4       -      -4
nrepeats                                               4       -      -4
nreceived                                              4       -      -4
if_index                                               4       -      -4
hostname                                               8       4      -4
dotted                                                 4       -      -4
datalen                                                4       -      -4
pingaddr                                              28       -     -28
rcvd_tbl                                             128       -    -128
------------------------------------------------------------------------------
(add/remove: 0/15 grow/shrink: 4/4 up/down: 24/-215)         Total: -191 bytes
   text    data     bss     dec     hex filename
 679835    2728   16736  699299   aaba3 busybox_old
 679851    2720   16536  699107   aaae3 busybox_unstripped
2007-06-04 10:33:48 +00:00
Denis Vlasenko 74324c8666 Audit bb_common_bufsiz usage, add script which looks for misuse.
tr: stop using globals needlessly.
code: -103 bytes
2007-06-04 10:16:52 +00:00
Denis Vlasenko 4e5f82c76f find_stray_communal_vars: script which finds communal variables
resize: remove globals var
mdev: remove globals var
2007-06-03 22:30:22 +00:00
Denis Vlasenko dd6e1f0deb start 1.7.x version 2007-06-02 12:54:09 +00:00
390 changed files with 12653 additions and 9133 deletions

No files matched your search

+19 -19
View File
@@ -101,8 +101,7 @@ config FEATURE_INSTALLER
help
Enable 'busybox --install [-s]' support. This will allow you to use
busybox at runtime to create hard links or symlinks for all the
applets that are compiled into busybox. This feature requires the
/proc filesystem.
applets that are compiled into busybox.
config LOCALE_SUPPORT
bool "Enable locale support (system needs locale for this to work)"
@@ -145,8 +144,8 @@ config FEATURE_PIDFILE
bool "Support writing pidfiles"
default n
help
This option makes some applets (crond, syslogd and inetd) write
a pidfile in /var/run. Some applications rely on them
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"
@@ -163,13 +162,6 @@ config FEATURE_SUID
are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs,
and vlock.
config FEATURE_SYSLOG
bool "Support for syslog"
default n
help
This option is auto-selected when you select any applet which may
send its output to syslog. You do not need to select it manually.
config FEATURE_SUID_CONFIG
bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
default n if FEATURE_SUID
@@ -210,14 +202,6 @@ config FEATURE_SUID_CONFIG_QUIET
/etc/busybox.conf should be readable by the user needing the SUID, check
this option to avoid users to be notified about missing permissions.
config FEATURE_HAVE_RPC
bool "RPC support"
default y
help
Select this if you have rpc support.
This automatically turns off all configuration options that rely
on RPC.
config SELINUX
bool "Support NSA Security Enhanced Linux"
default n
@@ -262,6 +246,22 @@ config BUSYBOX_EXEC_PATH
executable. If you haven't got /proc, set this to wherever you
want to run BusyBox from.
# These are auto-selected by other options
config FEATURE_SYSLOG
bool "Support for logging to syslog"
default n
help
This option is auto-selected when you select any applet which may
send its output to syslog. You do not need to select it manually.
config FEATURE_HAVE_RPC
bool "RPC support"
default n
help
This is automatically selected if any of enabled applets need it.
You do not need to select it manually.
endmenu
menu 'Build Options'
+14 -8
View File
@@ -1,5 +1,5 @@
VERSION = 1
PATCHLEVEL = 6
PATCHLEVEL = 7
SUBLEVEL = 2
EXTRAVERSION =
NAME = Unnamed
@@ -183,11 +183,6 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi)
HOSTCC = gcc
HOSTCXX = g++
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
HOSTCXXFLAGS = -O2
# Decide whether to build built-in, modular, or both.
# Normally, just do built-in.
@@ -262,9 +257,16 @@ export quiet Q KBUILD_VERBOSE
# Look for make include files relative to root of kernel src
MAKEFLAGS += --include-dir=$(srctree)
HOSTCC = gcc
HOSTCXX = g++
HOSTCFLAGS :=
HOSTCXXFLAGS :=
# We need some generic definitions
include $(srctree)/scripts/Kbuild.include
HOSTCFLAGS += $(call hostcc-option,-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer,)
HOSTCXXFLAGS += -O2
# For maximum performance (+ possibly random breakage, uncomment
# the following)
@@ -567,7 +569,7 @@ busybox-all := $(core-y) $(libs-y)
# May be overridden by arch/$(ARCH)/Makefile
quiet_cmd_busybox__ ?= LINK $@
cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) $(LDFLAGS) \
-o $@ -Wl,-M \
-o $@ -Wl,-Map -Wl,$@.map \
-Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
-Wl,--start-group $(busybox-all) -Wl,--end-group \
$(LDLIBS)
@@ -677,8 +679,12 @@ busybox_unstripped: $(busybox-all) FORCE
$(Q)rm -f .old_version
busybox: busybox_unstripped
ifeq ($(SKIP_STRIP),y)
$(Q)cp $< $@
else
$(Q)$(STRIP) -s --remove-section=.note --remove-section=.comment \
busybox_unstripped -o $@
endif
# The actual objects are generated when descending,
# make sure no implicit rule kicks in
@@ -754,7 +760,7 @@ PHONY += prepare-all
# 2) Create the include2 directory, used for the second asm symlink
prepare3: .kernelrelease
ifneq ($(KBUILD_SRC),)
@echo ' Using $(srctree) as source for kernel'
@echo ' Using $(srctree) as source for busybox'
$(Q)if [ -f $(srctree)/.config ]; then \
echo " $(srctree) is not clean, please run 'make mrproper'";\
echo " in the '$(srctree)' directory.";\
+6 -4
View File
@@ -2,9 +2,6 @@
# Build system
# ==========================================================================
%.bflt: %_unstripped
$(CROSS_COMPILE)elf2flt $(ELF2FLTFLAGS) $< -o $@
busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h $(srctree)/include/applets.h
$(Q)-$(SHELL) $^ >$@
@@ -70,6 +67,7 @@ sizes: busybox_unstripped
.PHONY: bloatcheck
bloatcheck: busybox_old busybox_unstripped
@$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped
@$(CROSS_COMPILE)size busybox_old busybox_unstripped
.PHONY: baseline
baseline: busybox_unstripped
@@ -79,9 +77,13 @@ baseline: busybox_unstripped
objsizes: busybox_unstripped
$(srctree)/scripts/objsizes
.PHONY: stksizes
stksizes: busybox_unstripped
$(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH)
.PHONY: bigdata
bigdata: busybox_unstripped
nm --size-sort busybox_unstripped | grep -vi ' [tr] ' | tail -20
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [tr] '
# Documentation Targets
.PHONY: doc
+23 -3
View File
@@ -3,6 +3,7 @@
# ==========================================================================
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,)
@@ -27,6 +28,9 @@ CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
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)
@@ -55,19 +59,35 @@ 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)
LDLIBS += -lselinux -lsepol
BBOX_LIB_LIST += selinux sepol
endif
ifeq ($(CONFIG_EFENCE),y)
LDLIBS += -lefence
BBOX_LIB_LIST += efence
endif
ifeq ($(CONFIG_DMALLOC),y)
LDLIBS += -ldmalloc
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
+2
View File
@@ -39,4 +39,6 @@ help:
@echo ' release - create a distribution tarball'
@echo ' sizes - show size of all enabled busybox symbols'
@echo ' objsizes - show size of each .o object built'
@echo ' bigdata - show data objects, biggest first'
@echo ' stksizes - show stack users, biggest first'
@echo
-1
View File
@@ -606,7 +606,6 @@ CONFIG_APP_UDHCPD=y
CONFIG_APP_DHCPRELAY=y
CONFIG_APP_DUMPLEASES=y
# CONFIG_APP_UDHCPC is not set
CONFIG_FEATURE_UDHCP_SYSLOG=y
# CONFIG_FEATURE_UDHCP_DEBUG is not set
CONFIG_FEATURE_RFC3397=y
CONFIG_VCONFIG=y
+12 -8
View File
@@ -5,17 +5,21 @@
# Licensed under the GPL v2, see the file LICENSE in this tarball.
obj-y:=
obj-y += applets.o
# Generated file needs additional love
applets/applets.o: .config include/usage_compressed.h
obj-y += applets.o
hostprogs-y:=
hostprogs-y += usage
always := $(hostprogs-y)
HOSTCFLAGS_usage.o = -I$(srctree)/include
always:= $(hostprogs-y)
# Generated files need additional love
quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
cmd_gen_usage_compressed = $(srctree)/applets/usage_compressed include/usage_compressed.h applets
include/usage_compressed.h: .config $(srctree)/include/usage.h applets/usage
HOSTCFLAGS_usage.o = -I$(srctree)/include
applets/applets.o: include/usage_compressed.h
applets/usage: .config $(srctree)/applets/usage_compressed
include/usage_compressed.h: applets/usage $(srctree)/applets/usage_compressed
$(call cmd,gen_usage_compressed)
+24 -35
View File
@@ -34,7 +34,7 @@
#if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE
/* Define usage_messages[] */
static const char usage_messages[] = ""
static const char usage_messages[] ALIGN1 = ""
#define MAKE_USAGE
#include "usage.h"
#include "applets.h"
@@ -47,8 +47,10 @@ static const char usage_messages[] = ""
/* Define struct bb_applet applets[] */
#include "applets.h"
/* The -1 arises because of the {0,NULL,0,-1} entry. */
const unsigned short NUM_APPLETS = sizeof(applets) / sizeof(applets[0]) - 1;
#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
@@ -109,12 +111,12 @@ static char *get_trimmed_slice(char *s, char *e)
}
/* Don't depend on the tools to combine strings. */
static const char config_file[] = "/etc/busybox.conf";
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[] = {
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 */
@@ -256,7 +258,7 @@ static void parse_config_file(void)
for (i = 0; i < 3; i++) {
/* There are 4 chars + 1 nul for each of user/group/other. */
static const char mode_chars[] = "Ssx-\0" "Ssx-\0" "Ttx-";
static const char mode_chars[] ALIGN1 = "Ssx-\0" "Ssx-\0" "Ttx-";
const char *q;
q = strchrnul(mode_chars + 5*i, *e++);
@@ -467,11 +469,11 @@ void bb_show_usage(void)
i--;
}
format_string = "%s\n\nUsage: %s %s\n\n";
fprintf(stderr, "%s multi-call binary\n", bb_banner);
format_string = "\nUsage: %s %s\n\n";
if (*p == '\b')
format_string = "%s\n\nNo help available.\n\n";
fprintf(stderr, format_string, bb_msg_full_version,
applet_name, p);
format_string = "\nNo help available.\n\n";
fprintf(stderr, format_string, applet_name, p);
dealloc_usage_messages((char*)usage_string);
}
xfunc_die();
@@ -488,7 +490,7 @@ static int applet_name_compare(const void *name, const void *vapplet)
const struct bb_applet *find_applet_by_name(const char *name)
{
/* Do a binary search to find the applet entry given the name. */
return bsearch(name, applets, NUM_APPLETS, sizeof(applets[0]),
return bsearch(name, applets, ARRAY_SIZE(applets)-1, sizeof(applets[0]),
applet_name_compare);
}
@@ -500,8 +502,8 @@ 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 [] = "/usr/bin";
static const char usr_sbin[] = "/usr/sbin";
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" */
@@ -544,14 +546,14 @@ static int busybox_main(char **argv)
help:
output_width = 80;
if (ENABLE_FEATURE_AUTOWIDTH) {
/* Obtain the terminal width. */
/* Obtain the terminal width */
get_terminal_width_height(0, &output_width, NULL);
}
/* leading tab and room to wrap */
output_width -= sizeof("start-stop-daemon, ") + 8;
printf("%s\n"
"Copyright (C) 1998-2006  Erik Andersen, Rob Landley, and others.\n"
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"
@@ -561,7 +563,7 @@ static int busybox_main(char **argv)
"\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);
"\nCurrently defined functions:\n");
col = 0;
a = applets;
while (a->name) {
@@ -577,21 +579,12 @@ static int busybox_main(char **argv)
}
if (ENABLE_FEATURE_INSTALLER && strcmp(argv[1], "--install") == 0) {
int use_symbolic_links = 0;
char *busybox;
/* to use symlinks, or not to use symlinks... */
if (argv[2])
if (strcmp(argv[2], "-s") == 0)
use_symbolic_links = 1;
/* link */
busybox = xmalloc_readlink_or_warn("/proc/self/exe");
const char *busybox;
busybox = xmalloc_readlink(bb_busybox_exec_path);
if (!busybox)
return 1;
install_links(busybox, use_symbolic_links);
if (ENABLE_FEATURE_CLEAN_UP)
free(busybox);
busybox = bb_busybox_exec_path;
/* -s makes symlinks */
install_links(busybox, argv[2] && strcmp(argv[2], "-s") == 0);
return 0;
}
@@ -648,8 +641,6 @@ int *const bb_errno __attribute__ ((section (".data")));
int main(int argc, char **argv)
{
const char *s;
#ifdef __GLIBC__
(*(int **)&bb_errno) = __errno_location();
#endif
@@ -664,9 +655,7 @@ int main(int argc, char **argv)
applet_name = argv[0];
if (applet_name[0] == '-')
applet_name++;
s = strrchr(applet_name, '/');
if (s)
applet_name = s + 1;
applet_name = bb_basename(applet_name);
parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */
+2 -2
View File
@@ -43,7 +43,7 @@ if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then
inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'`
sub_shell_it=`
cd "$prefix"
for d in usr/sbin usr/bin sbin bin ; do
for d in usr/sbin usr/bin sbin bin; do
pd=$PWD
if [ -d "$d" ]; then
cd $d
@@ -58,7 +58,7 @@ rm -f $prefix/bin/busybox || exit 1
mkdir -p $prefix/bin || exit 1
install -m 755 busybox $prefix/bin/busybox || exit 1
for i in $h ; do
for i in $h; do
appdir=`dirname $i`
mkdir -p $prefix/$appdir || exit 1
if [ "$2" = "--hardlinks" ]; then
+2
View File
@@ -1,6 +1,8 @@
/* 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[] = ""
+1 -1
View File
@@ -12,7 +12,7 @@ sz=`"$loc/usage" | wc -c` || exit 1
exec >"$target"
echo 'static const char packed_usage[] = '
echo 'static const char packed_usage[] ALIGN1 = '
"$loc/usage" | bzip2 -1 | od -v -t x1 \
| $SED -e 's/^[^ ]*//' -e 's/ *\(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/'
echo ';'
+2
View File
@@ -2,4 +2,6 @@
# 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,)
+16
View File
@@ -133,6 +133,13 @@ config RPM
help
Mini RPM applet - queries and extracts RPM packages.
config FEATURE_RPM_BZ2
bool "Enable handling of rpms with bzip2-compressed data inside"
default n
depends on RPM
help
Enable handling of rpms with bzip2-compressed data inside.
config TAR
bool "tar"
default n
@@ -198,6 +205,15 @@ config FEATURE_TAR_OLDGNU_COMPATIBILITY
the old GNU format; help to kill this old format by
repacking your ancient archives with the new format.
config FEATURE_TAR_OLDSUN_COMPATIBILITY
bool "Enable untarring of tarballs with checksums produced by buggy Sun tar"
default N
depends on TAR
help
This option is required to unpack archives created by some old
version of Sun's tar (it was calculating checksum using signed arithmetic).
It is said to be fixed in newer Sun tar, but "old" tarballs still exist.
config FEATURE_TAR_GNU_EXTENSIONS
bool "Enable support for some GNU tar extensions"
default y
+7 -5
View File
@@ -41,17 +41,18 @@ static void header_verbose_list_ar(const file_header_t *file_header)
int ar_main(int argc, char **argv);
int ar_main(int argc, char **argv)
{
static const char msg_unsupported_err[] ALIGN1 =
"archive %s is not supported";
archive_handle_t *archive_handle;
unsigned opt;
static const char msg_unsupported_err[] =
"Archive %s not supported. Install binutils 'ar'.";
char magic[8];
archive_handle = init_handle();
/* Prepend '-' to the first argument if required */
opt_complementary = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
opt = getopt32(argc, argv, "ptxovcr");
opt_complementary = "--:p:t:x:-1:p--tx:t--px:x--pt";
opt = getopt32(argv, "ptxovcr");
if (opt & AR_CTX_PRINT) {
archive_handle->action_data = data_extract_to_stdout;
@@ -88,7 +89,8 @@ int ar_main(int argc, char **argv)
}
archive_handle->offset += 7;
while (get_header_ar(archive_handle) == EXIT_SUCCESS) /* repeat */;
while (get_header_ar(archive_handle) == EXIT_SUCCESS)
continue;
return EXIT_SUCCESS;
}
+8 -8
View File
@@ -155,13 +155,13 @@ char* make_new_name_bunzip2(char *filename)
static
USE_DESKTOP(long long) int unpack_bunzip2(void)
{
return uncompressStream(STDIN_FILENO, STDOUT_FILENO);
return unpack_bz2_stream(STDIN_FILENO, STDOUT_FILENO);
}
int bunzip2_main(int argc, char **argv);
int bunzip2_main(int argc, char **argv)
{
getopt32(argc, argv, "cf");
getopt32(argv, "cf");
argv += optind;
if (applet_name[2] == 'c')
option_mask32 |= OPT_STDOUT;
@@ -212,7 +212,7 @@ char* make_new_name_gunzip(char *filename)
extension++;
if (strcmp(extension, "tgz" + 1) == 0
#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
#if ENABLE_FEATURE_GUNZIP_UNCOMPRESS
|| strcmp(extension, "Z") == 0
#endif
) {
@@ -242,7 +242,7 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
status = uncompress(STDIN_FILENO, STDOUT_FILENO);
} else if (magic2 == 0x8b) {
check_header_gzip_or_die(STDIN_FILENO);
status = inflate_gunzip(STDIN_FILENO, STDOUT_FILENO);
status = unpack_gz_stream(STDIN_FILENO, STDOUT_FILENO);
} else {
goto bad_magic;
}
@@ -260,7 +260,7 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
int gunzip_main(int argc, char **argv);
int gunzip_main(int argc, char **argv)
{
getopt32(argc, argv, "cfvdt");
getopt32(argv, "cfvdt");
argv += optind;
/* if called as zcat */
if (applet_name[1] == 'c')
@@ -292,13 +292,13 @@ char* make_new_name_unlzma(char *filename)
static
USE_DESKTOP(long long) int unpack_unlzma(void)
{
return unlzma(STDIN_FILENO, STDOUT_FILENO);
return unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO);
}
int unlzma_main(int argc, char **argv);
int unlzma_main(int argc, char **argv)
{
getopt32(argc, argv, "c");
getopt32(argv, "cf");
argv += optind;
/* lzmacat? */
if (applet_name[4] == 'c')
@@ -340,7 +340,7 @@ USE_DESKTOP(long long) int unpack_uncompress(void)
int uncompress_main(int argc, char **argv);
int uncompress_main(int argc, char **argv)
{
getopt32(argc, argv, "cf");
getopt32(argv, "cf");
argv += optind;
return bbunpack(argv, make_new_name_uncompress, unpack_uncompress);
+1 -1
View File
@@ -35,7 +35,7 @@ int cpio_main(int argc, char **argv)
archive_handle->seek = seek_by_read;
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
opt = getopt32(argc, argv, "ituvF:dm", &cpio_filename);
opt = getopt32(argv, "ituvF:dm", &cpio_filename);
/* One of either extract or test options must be given */
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
+16 -16
View File
@@ -413,7 +413,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
or_edge = xmalloc(sizeof(edge_t));
or_edge->type = edge_type + 1;
or_edge->name = search_name_hashtable(field);
or_edge->version = 0; // tracks the number of altenatives
or_edge->version = 0; // tracks the number of alternatives
add_edge_to_node(parent_node, or_edge);
}
@@ -432,7 +432,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
edge->version = search_name_hashtable("ANY");
} else {
/* Skip leading ' ' or '(' */
version += strspn(field2, " (");
version += strspn(version, " (");
/* Calculate length of any operator characters */
offset_ch = strspn(version, "<=>");
/* Determine operator */
@@ -582,10 +582,10 @@ static int read_package_field(const char *package_buffer, char **field_name, cha
static unsigned fill_package_struct(char *control_buffer)
{
static const char *const field_names[] = { "Package", "Version",
"Pre-Depends", "Depends","Replaces", "Provides",
"Conflicts", "Suggests", "Recommends", "Enhances", NULL
};
static const char field_names[] ALIGN1 =
"Package\0""Version\0"
"Pre-Depends\0""Depends\0""Replaces\0""Provides\0"
"Conflicts\0""Suggests\0""Recommends\0""Enhances\0";
common_node_t *new_node = xzalloc(sizeof(common_node_t));
char *field_name;
@@ -602,10 +602,10 @@ static unsigned fill_package_struct(char *control_buffer)
&field_name, &field_value);
if (field_name == NULL) {
goto fill_package_struct_cleanup; /* Oh no, the dreaded goto statement ! */
goto fill_package_struct_cleanup; /* Oh no, the dreaded goto statement! */
}
field_num = index_in_str_array(field_names, field_name);
field_num = index_in_strings(field_names, field_name);
switch (field_num) {
case 0: /* Package */
new_node->name = search_name_hashtable(field_value);
@@ -712,9 +712,9 @@ static void set_status(const unsigned status_node_num, const char *new_value, co
static const char *describe_status(int status_num)
{
int status_want, status_state ;
int status_want, status_state;
if (status_hashtable[status_num] == NULL || status_hashtable[status_num]->status == 0)
return "is not installed or flagged to be installed\n";
return "is not installed or flagged to be installed";
status_want = get_status(status_num, 1);
status_state = get_status(status_num, 3);
@@ -1227,7 +1227,7 @@ static int run_package_script(const char *package_name, const char *script_type)
return result;
}
static const char *all_control_files[] = {
static const char *const all_control_files[] = {
"preinst", "postinst", "prerm", "postrm",
"list", "md5sums", "shlibs", "conffiles",
"config", "templates", NULL
@@ -1412,10 +1412,10 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
tar_handle->src_fd = ar_handle->src_fd;
/* We don't care about data.tar.* or debian-binary, just control.tar.* */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
#if ENABLE_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_handle->accept), (char*)"control.tar.gz");
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
#if ENABLE_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_handle->accept), (char*)"control.tar.bz2");
#endif
@@ -1432,10 +1432,10 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
tar_handle->src_fd = ar_handle->src_fd;
/* We don't care about control.tar.* or debian-binary, just data.tar.* */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
#if ENABLE_FEATURE_DEB_TAR_GZ
llist_add_to(&(ar_handle->accept), (char*)"data.tar.gz");
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
#if ENABLE_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_handle->accept), (char*)"data.tar.bz2");
#endif
@@ -1579,7 +1579,7 @@ int dpkg_main(int argc, char **argv)
OPT_unpack = 0x40,
};
opt = getopt32(argc, argv, "CF:ilPru", &str_f);
opt = getopt32(argv, "CF:ilPru", &str_f);
//if (opt & OPT_configure) ... // -C
if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg)
if (strcmp(str_f, "depends"))
+3 -3
View File
@@ -31,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
#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
#if ENABLE_FEATURE_DEB_TAR_BZ2
llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2");
llist_add_to(&control_tar_llist, (char*)"control.tar.bz2");
#endif
opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
opt = getopt32(argc, argv, "cefXx");
opt = getopt32(argv, "cefXx");
if (opt & DPKG_DEB_OPT_CONTENTS) {
tar_archive->action_header = header_verbose_list;
+11 -13
View File
@@ -49,10 +49,10 @@ aa: 85.1% -- replaced with aa.gz
#ifdef DEBUG
# define Assert(cond,msg) { if (!(cond)) bb_error_msg(msg); }
# define Trace(x) fprintf x
# define Tracev(x) {if (verbose) fprintf x ;}
# define Tracevv(x) {if (verbose > 1) fprintf x ;}
# define Tracec(c,x) {if (verbose && (c)) fprintf x ;}
# define Tracecv(c,x) {if (verbose > 1 && (c)) fprintf x ;}
# define Tracev(x) {if (verbose) fprintf x; }
# define Tracevv(x) {if (verbose > 1) fprintf x; }
# define Tracec(c,x) {if (verbose && (c)) fprintf x; }
# define Tracecv(c,x) {if (verbose > 1 && (c)) fprintf x; }
#else
# define Assert(cond,msg)
# define Trace(x)
@@ -768,26 +768,24 @@ static void check_match(IPos start, IPos match, int length)
#define BL_CODES 19
/* number of codes used to transfer the bit lengths */
typedef uch extra_bits_t;
/* extra bits for each length code */
static const extra_bits_t extra_lbits[LENGTH_CODES]= {
static const uint8_t extra_lbits[LENGTH_CODES] ALIGN1 = {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,
4, 4, 5, 5, 5, 5, 0
};
/* extra bits for each distance code */
static const extra_bits_t extra_dbits[D_CODES] = {
static const uint8_t extra_dbits[D_CODES] ALIGN1 = {
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
10, 10, 11, 11, 12, 12, 13, 13
};
/* extra bits for each bit length code */
static const extra_bits_t extra_blbits[BL_CODES] = {
static const uint8_t extra_blbits[BL_CODES] ALIGN1 = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7 };
/* number of codes at each bit length for an optimal tree */
static const uch bl_order[BL_CODES] = {
static const uint8_t bl_order[BL_CODES] ALIGN1 = {
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
#define STORED_BLOCK 0
@@ -861,7 +859,7 @@ typedef struct ct_data {
typedef struct tree_desc {
ct_data *dyn_tree; /* the dynamic tree */
ct_data *static_tree; /* corresponding static tree or NULL */
const extra_bits_t *extra_bits; /* extra bits for each code or NULL */
const uint8_t *extra_bits; /* extra bits for each code or NULL */
int extra_base; /* base index for extra_bits */
int elems; /* max number of elements in the tree */
int max_length; /* max bit length for the codes */
@@ -1064,7 +1062,7 @@ static void pqdownheap(ct_data * tree, int k)
static void gen_bitlen(tree_desc * desc)
{
ct_data *tree = desc->dyn_tree;
const extra_bits_t *extra = desc->extra_bits;
const uint8_t *extra = desc->extra_bits;
int base = desc->extra_base;
int max_code = desc->max_code;
int max_length = desc->max_length;
@@ -2033,7 +2031,7 @@ int gzip_main(int argc, char **argv)
unsigned opt;
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
opt = getopt32(argc, argv, "cfv" USE_GUNZIP("d") "q123456789" );
opt = getopt32(argv, "cfv" USE_GUNZIP("d") "q123456789" );
option_mask32 &= 0x7; /* Clear -d, ignore -q, -0..9 */
//if (opt & 0x1) // -c
//if (opt & 0x2) // -f
+29 -29
View File
@@ -35,34 +35,34 @@ DPKG_FILES:= \
get_header_tar.o \
filter_accept_list_reassign.o
# open_transformer uses fork(). Compile it only if absolutely necessary
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_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_TAR) += get_header_tar.o
lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
lib-$(CONFIG_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
+27 -23
View File
@@ -25,7 +25,8 @@ void data_extract_all(archive_handle_t *archive_handle)
&& (unlink(file_header->name) == -1)
&& (errno != ENOENT)
) {
bb_perror_msg_and_die("cannot remove old file");
bb_perror_msg_and_die("cannot remove old file %s",
file_header->name);
}
}
else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) {
@@ -52,13 +53,16 @@ void data_extract_all(archive_handle_t *archive_handle)
/* Handle hard links separately
* We identified hard links as regular files of size 0 with a symlink */
if (S_ISREG(file_header->mode) && (file_header->link_name)
if (S_ISREG(file_header->mode) && (file_header->link_target)
&& (file_header->size == 0)
) {
/* hard link */
res = link(file_header->link_name, file_header->name);
res = link(file_header->link_target, file_header->name);
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
bb_perror_msg("cannot create hard link");
bb_perror_msg("cannot create %slink "
"from %s to %s", "hard",
file_header->name,
file_header->link_target);
}
} else {
/* Create the filesystem entry */
@@ -73,22 +77,22 @@ void data_extract_all(archive_handle_t *archive_handle)
}
case S_IFDIR:
res = mkdir(file_header->name, file_header->mode);
if ((errno != EISDIR) && (res == -1)
if ((res == -1) && (errno != EISDIR)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("extract_archive: %s", file_header->name);
bb_perror_msg("cannot make dir %s", file_header->name);
}
break;
case S_IFLNK:
/* Symlink */
res = symlink(file_header->link_name, file_header->name);
res = symlink(file_header->link_target, file_header->name);
if ((res == -1)
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
) {
bb_perror_msg("cannot create symlink "
"from %s to '%s'",
bb_perror_msg("cannot create %slink "
"from %s to %s", "sym",
file_header->name,
file_header->link_name);
file_header->link_target);
}
break;
case S_IFSOCK:
@@ -110,18 +114,18 @@ void data_extract_all(archive_handle_t *archive_handle)
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) {
lchown(file_header->name, file_header->uid, file_header->gid);
}
/* 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)
&& (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);
}
}
}
+2 -2
View File
@@ -700,7 +700,7 @@ void dealloc_bunzip(bunzip_data *bd)
/* Decompress src_fd to dst_fd. Stops at end of bzip data, not end of file. */
USE_DESKTOP(long long) int
uncompressStream(int src_fd, int dst_fd)
unpack_bz2_stream(int src_fd, int dst_fd)
{
USE_DESKTOP(long long total_written = 0;)
char *outbuf;
@@ -751,7 +751,7 @@ static char *const bunzip_errors[] = {
/* Dumb little test thing, decompress stdin to stdout */
int main(int argc, char **argv)
{
int i = uncompressStream(0, 1);
int i = unpack_bz2_stream(0, 1);
char c;
if (i < 0)
+47 -47
View File
@@ -7,7 +7,6 @@
* (see disclaimer below)
*/
/* (N)compress42.c - File compression ala IEEE Computer, Mar 1992.
*
* Authors:
@@ -34,53 +33,48 @@
#define OBUFSIZ 2048
/* Defines for third byte of header */
#define MAGIC_1 (char_type)'\037' /* First byte of compressed file */
#define MAGIC_2 (char_type)'\235' /* Second byte of compressed file */
#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */
/* Masks 0x20 and 0x40 are free. */
/* I think 0x20 should mean that there is */
/* a fourth header byte (for expansion). */
#define BLOCK_MODE 0x80 /* Block compresssion if table is full and */
/* compression rate is dropping flush tables */
/* the next two codes should not be changed lightly, as they must not */
/* lie within the contiguous general code space. */
#define FIRST 257 /* first free entry */
#define CLEAR 256 /* table clear output code */
#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */
/* Masks 0x20 and 0x40 are free. */
/* I think 0x20 should mean that there is */
/* a fourth header byte (for expansion). */
#define BLOCK_MODE 0x80 /* Block compression if table is full and */
/* compression rate is dropping flush tables */
/* the next two codes should not be changed lightly, as they must not */
/* lie within the contiguous general code space. */
#define FIRST 257 /* first free entry */
#define CLEAR 256 /* table clear output code */
#define INIT_BITS 9 /* initial number of bits/code */
#define INIT_BITS 9 /* initial number of bits/code */
/* machine variants which require cc -Dmachine: pdp11, z8000, DOS */
#define FAST
#define HBITS 17 /* 50% occupancy */
#define HSIZE (1<<HBITS)
#define HMASK (HSIZE-1)
#define HPRIME 9941
#define BITS 16
#undef MAXSEG_64K
#define MAXCODE(n) (1L << (n))
#define htabof(i) htab[i]
#define codetabof(i) codetab[i]
#define tab_prefixof(i) codetabof(i)
#define tab_suffixof(i) ((unsigned char *)(htab))[i]
#define de_stack ((unsigned char *)&(htab[HSIZE-1]))
#define clear_htab() memset(htab, -1, HSIZE)
#define clear_tab_prefixof() memset(codetab, 0, 256);
#define HBITS 17 /* 50% occupancy */
#define HSIZE (1<<HBITS)
#define HMASK (HSIZE-1) /* unused */
#define HPRIME 9941 /* unused */
#define BITS 16
#define BITS_STR "16"
#undef MAXSEG_64K /* unused */
#define MAXCODE(n) (1L << (n))
#define htabof(i) htab[i]
#define codetabof(i) codetab[i]
#define tab_prefixof(i) codetabof(i)
#define tab_suffixof(i) ((unsigned char *)(htab))[i]
#define de_stack ((unsigned char *)&(htab[HSIZE-1]))
#define clear_tab_prefixof() memset(codetab, 0, 256)
/*
* Decompress stdin to stdout. This routine adapts to the codes in the
* file building the "string" table on-the-fly; requiring no table to
* be stored in the compressed file. The tables used herein are shared
* with those of the compress() routine. See the definitions above.
* be stored in the compressed file.
*/
USE_DESKTOP(long long) int
uncompress(int fd_in, int fd_out)
{
USE_DESKTOP(long long total_written = 0;)
USE_DESKTOP(long long) int retval = -1;
unsigned char *stackp;
long code;
int finchar;
@@ -96,10 +90,10 @@ uncompress(int fd_in, int fd_out)
long maxmaxcode;
int n_bits;
int rsize = 0;
RESERVE_CONFIG_UBUFFER(inbuf, IBUFSIZ + 64);
RESERVE_CONFIG_UBUFFER(outbuf, OBUFSIZ + 2048);
unsigned char htab[HSIZE];
unsigned short codetab[HSIZE];
unsigned char *inbuf; /* were eating insane amounts of stack - */
unsigned char *outbuf; /* bad for some embedded targets */
unsigned char *htab;
unsigned short *codetab;
/* Hmm, these were statics - why?! */
/* user settable max # bits/code */
@@ -107,8 +101,10 @@ uncompress(int fd_in, int fd_out)
/* block compress mode -C compatible with 2.0 */
int block_mode; /* = BLOCK_MODE; */
memset(inbuf, 0, IBUFSIZ + 64);
memset(outbuf, 0, OBUFSIZ + 2048);
inbuf = xzalloc(IBUFSIZ + 64);
outbuf = xzalloc(OBUFSIZ + 2048);
htab = xzalloc(HSIZE); /* wsn't zeroed out before, maybe can xmalloc? */
codetab = xzalloc(HSIZE * sizeof(codetab[0]));
insize = 0;
@@ -116,7 +112,7 @@ uncompress(int fd_in, int fd_out)
* to do some cleanup (e.g. delete incomplete unpacked file etc) */
if (full_read(fd_in, inbuf, 1) != 1) {
bb_error_msg("short read");
return -1;
goto err;
}
maxbits = inbuf[0] & BIT_MASK;
@@ -125,8 +121,8 @@ uncompress(int fd_in, int fd_out)
if (maxbits > BITS) {
bb_error_msg("compressed with %d bits, can only handle "
"%d bits", maxbits, BITS);
return -1;
BITS_STR" bits", maxbits);
goto err;
}
n_bits = INIT_BITS;
@@ -140,7 +136,7 @@ uncompress(int fd_in, int fd_out)
free_ent = ((block_mode) ? FIRST : 256);
/* As above, initialize the first 256 entries in the table. */
clear_tab_prefixof();
/*clear_tab_prefixof(); - done by xzalloc */
for (code = 255; code >= 0; --code) {
tab_suffixof(code) = (unsigned char) code;
@@ -232,7 +228,7 @@ uncompress(int fd_in, int fd_out)
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
(posbits & 07));
bb_error_msg("uncompress: corrupt input");
return -1;
goto err;
}
*--stackp = (unsigned char) finchar;
@@ -299,7 +295,11 @@ uncompress(int fd_in, int fd_out)
USE_DESKTOP(total_written += outpos;)
}
RELEASE_CONFIG_BUFFER(inbuf);
RELEASE_CONFIG_BUFFER(outbuf);
return USE_DESKTOP(total_written) + 0;
retval = USE_DESKTOP(total_written) + 0;
err:
free(inbuf);
free(outbuf);
free(htab);
free(codetab);
return retval;
}
+11 -9
View File
@@ -12,8 +12,8 @@
#include "libbb.h"
#include "unarchive.h"
#ifdef CONFIG_FEATURE_LZMA_FAST
# define speed_inline ATTRIBUTE_ALWAYS_INLINE
#if ENABLE_FEATURE_LZMA_FAST
# define speed_inline ALWAYS_INLINE
#else
# define speed_inline
#endif
@@ -78,7 +78,7 @@ static rc_t* rc_init(int fd) /*, int buffer_size) */
}
/* Called once */
static ATTRIBUTE_ALWAYS_INLINE void rc_free(rc_t * rc)
static ALWAYS_INLINE void rc_free(rc_t * rc)
{
if (ENABLE_FEATURE_CLEAN_UP)
free(rc);
@@ -92,16 +92,18 @@ static void rc_do_normalize(rc_t * rc)
rc->range <<= 8;
rc->code = (rc->code << 8) | *rc->ptr++;
}
static ATTRIBUTE_ALWAYS_INLINE void rc_normalize(rc_t * rc)
static ALWAYS_INLINE void rc_normalize(rc_t * rc)
{
if (rc->range < (1 << RC_TOP_BITS)) {
rc_do_normalize(rc);
}
}
/* Called 9 times */
/* rc_is_bit_0 is called 9 times */
/* Why rc_is_bit_0_helper exists?
* Because we want to always expose (rc->code < rc->bound) to optimizer
* Because we want to always expose (rc->code < rc->bound) to optimizer.
* Thus rc_is_bit_0 is always inlined, and rc_is_bit_0_helper is inlined
* only if we compile for speed.
*/
static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
{
@@ -109,7 +111,7 @@ static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
return rc->bound;
}
static ATTRIBUTE_ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
static ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
{
uint32_t t = rc_is_bit_0_helper(rc, p);
return rc->code < t;
@@ -143,7 +145,7 @@ static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
}
/* Called once */
static ATTRIBUTE_ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
static ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
{
rc_normalize(rc);
rc->range >>= 1;
@@ -228,7 +230,7 @@ enum {
USE_DESKTOP(long long) int
unlzma(int src_fd, int dst_fd)
unpack_lzma_stream(int src_fd, int dst_fd)
{
USE_DESKTOP(long long total_written = 0;)
lzma_header_t header;
+8 -8
View File
@@ -182,39 +182,39 @@ static state_t* alloc_state(void)
#endif
static const unsigned short mask_bits[] = {
static const unsigned short mask_bits[] ALIGN2 = {
0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
};
/* Copy lengths for literal codes 257..285 */
static const unsigned short cplens[] = {
static const unsigned short cplens[] ALIGN2 = {
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59,
67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
};
/* note: see note #13 above about the 258 in this list. */
/* Extra bits for literal codes 257..285 */
static const unsigned char cplext[] = {
static const unsigned char cplext[] ALIGN1 = {
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5,
5, 5, 5, 0, 99, 99
}; /* 99 == invalid */
/* Copy offsets for distance codes 0..29 */
static const unsigned short cpdist[] = {
static const unsigned short cpdist[] ALIGN2 = {
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513,
769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577
};
/* Extra bits for distance codes */
static const unsigned char cpdext[] = {
static const unsigned char cpdext[] ALIGN1 = {
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
11, 11, 12, 12, 13, 13
};
/* Tables for deflate from PKZIP's appnote.txt. */
/* Order of the bit length code lengths */
static const unsigned char border[] = {
static const unsigned char border[] ALIGN1 = {
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
};
@@ -981,7 +981,7 @@ static int inflate_get_next_window(STATE_PARAM_ONLY)
}
/* Called from inflate_gunzip() and inflate_unzip() */
/* Called from unpack_gz_stream() and inflate_unzip() */
/* NB: bytebuffer is allocated here but freeing it is left to the caller! */
static USE_DESKTOP(long long) int
inflate_unzip_internal(STATE_PARAM int in, int out)
@@ -1056,7 +1056,7 @@ inflate_unzip(inflate_unzip_result *res, unsigned bufsize, int in, int out)
USE_DESKTOP(long long) int
inflate_gunzip(int in, int out)
unpack_gz_stream(int in, int out)
{
uint32_t stored_crc = 0;
unsigned count;
@@ -23,13 +23,13 @@ char filter_accept_list_reassign(archive_handle_t *archive_handle)
name_ptr = strrchr(archive_handle->file_header->name, '.');
/* Modify the subarchive handler based on the extension */
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
#if ENABLE_FEATURE_DEB_TAR_GZ
if (strcmp(name_ptr, ".gz") == 0) {
archive_handle->action_data_subarchive = get_header_tar_gz;
return EXIT_SUCCESS;
}
#endif
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
#if ENABLE_FEATURE_DEB_TAR_BZ2
if (strcmp(name_ptr, ".bz2") == 0) {
archive_handle->action_data_subarchive = get_header_tar_bz2;
return EXIT_SUCCESS;
+8 -7
View File
@@ -16,8 +16,9 @@ typedef struct hardlinks_s {
char get_header_cpio(archive_handle_t *archive_handle)
{
static hardlinks_t *saved_hardlinks = NULL;
static unsigned short pending_hardlinks = 0;
static unsigned pending_hardlinks = 0;
static int inode;
file_header_t *file_header = archive_handle->file_header;
char cpio_header[110];
int namesize;
@@ -30,7 +31,7 @@ char get_header_cpio(archive_handle_t *archive_handle)
tmp = saved_hardlinks;
oldtmp = NULL;
file_header->link_name = file_header->name;
file_header->link_target = file_header->name;
file_header->size = 0;
while (tmp) {
@@ -56,7 +57,7 @@ char get_header_cpio(archive_handle_t *archive_handle)
saved_hardlinks = tmp;
}
file_header->name = file_header->link_name;
file_header->name = file_header->link_target;
if (pending_hardlinks > 1) {
bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?");
@@ -122,12 +123,12 @@ char get_header_cpio(archive_handle_t *archive_handle)
}
if (S_ISLNK(file_header->mode)) {
file_header->link_name = xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, file_header->link_name, file_header->size);
file_header->link_target = xzalloc(file_header->size + 1);
xread(archive_handle->src_fd, file_header->link_target, file_header->size);
archive_handle->offset += file_header->size;
file_header->size = 0; /* Stop possible seeks in future */
} else {
file_header->link_name = NULL;
file_header->link_target = NULL;
}
if (nlink > 1 && !S_ISDIR(file_header->mode)) {
if (file_header->size == 0) { /* Put file on a linked list for later */
@@ -154,7 +155,7 @@ char get_header_cpio(archive_handle_t *archive_handle)
archive_handle->offset += file_header->size;
free(file_header->link_name);
free(file_header->link_target);
return EXIT_SUCCESS;
}
+34 -15
View File
@@ -36,7 +36,7 @@ static unsigned long long getOctal(char *str, int len)
*/
str[len] = '\0';
v = strtoull(str, &str, 8);
if (*str)
if (*str && (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY || *str != ' '))
bb_error_msg_and_die("corrupted octal value in tar header");
return v;
}
@@ -45,7 +45,7 @@ static unsigned long long getOctal(char *str, int len)
void BUG_tar_header_size(void);
char get_header_tar(archive_handle_t *archive_handle)
{
static int end;
static smallint end;
file_header_t *file_header = archive_handle->file_header;
struct {
@@ -69,7 +69,10 @@ char get_header_tar(archive_handle_t *archive_handle)
char padding[12]; /* 500-512 */
} tar;
char *cp;
int i, sum_u, sum_s, sum;
int i, sum_u, sum;
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
int sum_s;
#endif
int parse_names;
if (sizeof(tar) != 512)
@@ -115,20 +118,36 @@ char get_header_tar(archive_handle_t *archive_handle)
* POSIX says that checksum is done on unsigned bytes, but
* Sun and HP-UX gets it wrong... more details in
* GNU tar source. */
sum_s = sum_u = ' ' * sizeof(tar.chksum);
for (i = 0; i < 148 ; i++) {
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
sum_s = ' ' * sizeof(tar.chksum);
#endif
sum_u = ' ' * sizeof(tar.chksum);
for (i = 0; i < 148; i++) {
sum_u += ((unsigned char*)&tar)[i];
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
sum_s += ((signed char*)&tar)[i];
#endif
}
for (i = 156; i < 512 ; i++) {
for (i = 156; i < 512; i++) {
sum_u += ((unsigned char*)&tar)[i];
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
sum_s += ((signed char*)&tar)[i];
#endif
}
/* This field does not need special treatment (getOctal) */
sum = xstrtoul(tar.chksum, 8);
if (sum_u != sum && sum_s != sum) {
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
sum = strtoul(tar.chksum, &cp, 8);
if ((*cp && *cp != ' ')
|| (sum_u != sum USE_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum))
) {
bb_error_msg_and_die("invalid tar header checksum");
}
#else
/* This field does not need special treatment (getOctal) */
sum = xstrtoul(tar.chksum, 8);
if (sum_u != sum USE_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum)) {
bb_error_msg_and_die("invalid tar header checksum");
}
#endif
/* 0 is reserved for high perf file, treat as normal file */
if (!tar.typeflag) tar.typeflag = '0';
@@ -141,13 +160,13 @@ char get_header_tar(archive_handle_t *archive_handle)
unsigned major = GET_OCTAL(tar.devmajor);
file_header->device = makedev(major, minor);
}
file_header->link_name = NULL;
file_header->link_target = NULL;
if (!linkname && parse_names && tar.linkname[0]) {
/* we trash magic[0] here, it's ok */
tar.linkname[sizeof(tar.linkname)] = '\0';
file_header->link_name = xstrdup(tar.linkname);
/* FIXME: what if we have non-link object with link_name? */
/* Will link_name be free()ed? */
file_header->link_target = xstrdup(tar.linkname);
/* FIXME: what if we have non-link object with link_target? */
/* Will link_target be free()ed? */
}
file_header->mtime = GET_OCTAL(tar.mtime);
file_header->size = GET_OCTAL(tar.size);
@@ -248,7 +267,7 @@ char get_header_tar(archive_handle_t *archive_handle)
longname = NULL;
}
if (linkname) {
file_header->link_name = linkname;
file_header->link_target = linkname;
linkname = NULL;
}
#endif
@@ -277,7 +296,7 @@ char get_header_tar(archive_handle_t *archive_handle)
}
archive_handle->offset += file_header->size;
free(file_header->link_name);
free(file_header->link_target);
/* Do not free(file_header->name)! */
return EXIT_SUCCESS;
+1 -1
View File
@@ -11,7 +11,7 @@ char get_header_tar_bz2(archive_handle_t *archive_handle)
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompressStream);
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2", "bunzip2", "-cf", "-", NULL);
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
+8 -1
View File
@@ -8,19 +8,26 @@
char get_header_tar_gz(archive_handle_t *archive_handle)
{
#if BB_MMU
unsigned char magic[2];
#endif
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
/* Check gzip magic only if open_transformer will invoke unpack_gz_stream (MMU case).
* Otherwise, it will invoke an external helper "gunzip -cf" (NOMMU case) which will
* need the header. */
#if BB_MMU
xread(archive_handle->src_fd, &magic, 2);
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
bb_error_msg_and_die("invalid gzip magic");
}
check_header_gzip_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) /**/;
+1 -1
View File
@@ -14,7 +14,7 @@ char get_header_tar_lzma(archive_handle_t * archive_handle)
/* Can't lseek over pipes */
archive_handle->seek = seek_by_read;
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unlzma);
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma", "unlzma", "-cf", "-", NULL);
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
+2 -2
View File
@@ -23,8 +23,8 @@ void header_verbose_list(const file_header_t *file_header)
mtime->tm_sec,
file_header->name);
if (file_header->link_name) {
printf(" -> %s", file_header->link_name);
if (file_header->link_target) {
printf(" -> %s", file_header->link_target);
}
/* putchar isnt used anywhere else i dont think */
puts("");
+26 -5
View File
@@ -7,27 +7,48 @@
#include "unarchive.h"
/* transformer(), more than meets the eye */
/*
* On MMU machine, the transform_prog and ... are stripped
* by a macro in include/unarchive.h. On NOMMU, transformer is stripped.
*/
int open_transformer(int src_fd,
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd))
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd),
const char *transform_prog, ...)
{
int fd_pipe[2];
int pid;
xpipe(fd_pipe);
#if BB_MMU
pid = fork();
if (pid == -1) {
#else
pid = vfork();
#endif
if (pid == -1)
bb_perror_msg_and_die("fork failed");
}
if (pid == 0) {
#if !BB_MMU
va_list ap;
#endif
/* child process */
close(fd_pipe[0]); /* We don't wan't to read from the parent */
// FIXME: error check?
#if BB_MMU
transformer(src_fd, fd_pipe[1]);
close(fd_pipe[1]); /* Send EOF */
close(src_fd);
if (ENABLE_FEATURE_CLEAN_UP) {
close(fd_pipe[1]); /* Send EOF */
close(src_fd);
}
exit(0);
#else
xmove_fd(src_fd, 0);
xmove_fd(fd_pipe[1], 1);
va_start(ap, transform_prog);
BB_EXECVP(transform_prog, ap);
bb_perror_and_die("exec failed");
#endif
/* notreached */
}
+1 -1
View File
@@ -9,7 +9,7 @@
void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount)
{
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
#ifdef CONFIG_FEATURE_UNARCHIVE_TAPE
#if ENABLE_FEATURE_UNARCHIVE_TAPE
if (errno == ESPIPE) {
seek_by_read(archive_handle, amount);
} else
+37 -6
View File
@@ -189,8 +189,15 @@ static void extract_cpio_gz(int fd)
{
archive_handle_t *archive_handle;
unsigned char magic[2];
#if BB_MMU
USE_DESKTOP(long long) int (*xformer)(int src_fd, int dst_fd);
enum { xformer_prog = 0 };
#else
enum { xformer = 0 };
const char *xformer_prog;
#endif
/* Initialise */
/* Initialize */
archive_handle = init_handle();
archive_handle->seek = seek_by_read;
//archive_handle->action_header = header_list;
@@ -201,16 +208,40 @@ static void extract_cpio_gz(int fd)
archive_handle->offset = 0;
xread(archive_handle->src_fd, &magic, 2);
#if BB_MMU
xformer = unpack_gz_stream;
#else
xformer_prog = "gunzip";
#endif
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
bb_error_msg_and_die("invalid gzip magic");
if (ENABLE_FEATURE_RPM_BZ2
&& (magic[0] == 0x42) && (magic[1] == 0x5a)) {
#if BB_MMU
xformer = unpack_bz2_stream;
#else
xformer_prog = "bunzip2";
#endif
/* We can do better, need modifying unpack_bz2_stream to not require
* first 2 bytes. Not very hard to do... I mean, TODO :) */
xlseek(archive_handle->src_fd, -2, SEEK_CUR);
} else
bb_error_msg_and_die("no gzip"
USE_FEATURE_RPM_BZ2("/bzip")
" magic");
} else {
check_header_gzip_or_die(archive_handle->src_fd);
#if !BB_MMU
/* NOMMU version of open_transformer execs an external unzipper that should
* have the file position at the start of the file */
xlseek(archive_handle->src_fd, 0, SEEK_SET);
#endif
}
check_header_gzip_or_die(archive_handle->src_fd);
xchdir("/"); /* Install RPM's to root */
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
xchdir("/"); /* Install RPM's to root */
archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog, xformer_prog, "-cf", "-", NULL);
archive_handle->offset = 0;
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
/* loop */;
continue;
}
+1 -1
View File
@@ -80,7 +80,7 @@ int rpm2cpio_main(int argc, char **argv)
}
check_header_gzip_or_die(rpm_fd);
if (inflate_gunzip(rpm_fd, STDOUT_FILENO) < 0) {
if (unpack_gz_stream(rpm_fd, STDOUT_FILENO) < 0) {
bb_error_msg("error inflating");
}
+33 -32
View File
@@ -28,6 +28,8 @@
#include "libbb.h"
#include "unarchive.h"
#define block_buf bb_common_bufsiz1
#if ENABLE_FEATURE_TAR_CREATE
/* Tar file constants */
@@ -415,11 +417,11 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
header_name = fileName;
while (header_name[0] == '/') {
static int alreadyWarned = FALSE;
static smallint warned;
if (alreadyWarned == FALSE) {
if (!warned) {
bb_error_msg("removing leading '/' from member names");
alreadyWarned = TRUE;
warned = 1;
}
header_name++;
}
@@ -475,8 +477,8 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
/* Pad the file up to the tar block size */
/* (a few tricks here in the name of code size) */
readSize = (-(int)statbuf->st_size) & (TAR_BLOCK_SIZE-1);
memset(bb_common_bufsiz1, 0, readSize);
xwrite(tbInfo->tarFd, bb_common_bufsiz1, readSize);
memset(block_buf, 0, readSize);
xwrite(tbInfo->tarFd, block_buf, readSize);
}
return TRUE;
@@ -570,8 +572,8 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
include = include->link;
}
/* Write two empty blocks to the end of the archive */
memset(bb_common_bufsiz1, 0, 2*TAR_BLOCK_SIZE);
xwrite(tbInfo.tarFd, bb_common_bufsiz1, 2*TAR_BLOCK_SIZE);
memset(block_buf, 0, 2*TAR_BLOCK_SIZE);
xwrite(tbInfo.tarFd, block_buf, 2*TAR_BLOCK_SIZE);
/* To be pedantically correct, we would check if the tarball
* is smaller than 20 tar blocks, and pad it if it was smaller,
@@ -646,7 +648,7 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
bb_error_msg_and_die("invalid magic");
}
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress);
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress, "uncompress", "uncompress", "-cf", "-", NULL);
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
/* nothing */;
@@ -713,45 +715,44 @@ enum {
OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions
};
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
static const struct option tar_long_options[] = {
{ "list", 0, NULL, 't' },
{ "extract", 0, NULL, 'x' },
{ "directory", 1, NULL, 'C' },
{ "file", 1, NULL, 'f' },
{ "to-stdout", 0, NULL, 'O' },
{ "same-permissions", 0, NULL, 'p' },
{ "verbose", 0, NULL, 'v' },
{ "keep-old", 0, NULL, 'k' },
static const char tar_longopts[] ALIGN1 =
"list\0" No_argument "t"
"extract\0" No_argument "x"
"directory\0" Required_argument "C"
"file\0" Required_argument "f"
"to-stdout\0" No_argument "O"
"same-permissions\0" No_argument "p"
"verbose\0" No_argument "v"
"keep-old\0" No_argument "k"
# if ENABLE_FEATURE_TAR_CREATE
{ "create", 0, NULL, 'c' },
{ "dereference", 0, NULL, 'h' },
"create\0" No_argument "c"
"dereference\0" No_argument "h"
# endif
# if ENABLE_FEATURE_TAR_BZIP2
{ "bzip2", 0, NULL, 'j' },
"bzip2\0" No_argument "j"
# endif
# if ENABLE_FEATURE_TAR_LZMA
{ "lzma", 0, NULL, 'a' },
"lzma\0" No_argument "a"
# endif
# if ENABLE_FEATURE_TAR_FROM
{ "files-from", 1, NULL, 'T' },
{ "exclude-from", 1, NULL, 'X' },
"files-from\0" Required_argument "T"
"exclude-from\0" Required_argument "X"
# endif
# if ENABLE_FEATURE_TAR_GZIP
{ "gzip", 0, NULL, 'z' },
"gzip\0" No_argument "z"
# endif
# if ENABLE_FEATURE_TAR_COMPRESS
{ "compress", 0, NULL, 'Z' },
"compress\0" No_argument "Z"
# endif
{ "no-same-owner", 0, NULL, 0xfd },
{ "no-same-permissions",0, NULL, 0xfe },
"no-same-owner\0" No_argument "\xfd"
"no-same-permissions\0" No_argument "\xfe"
/* --exclude takes next bit position in option mask, */
/* therefore we have to either put it _after_ --no-same-perm */
/* or add OPT[BIT]_EXCLUDE before OPT[BIT]_NOPRESERVE_OWN */
# if ENABLE_FEATURE_TAR_FROM
{ "exclude", 1, NULL, 0xff },
"exclude\0" Required_argument "\xff"
# endif
{ 0, 0, 0, 0 }
};
;
#endif
int tar_main(int argc, char **argv);
@@ -785,9 +786,9 @@ int tar_main(int argc, char **argv)
USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
applet_long_options = tar_long_options;
applet_long_options = tar_longopts;
#endif
opt = getopt32(argc, argv,
opt = getopt32(argv,
"txC:f:Opvk"
USE_FEATURE_TAR_CREATE( "ch" )
USE_FEATURE_TAR_BZIP2( "j" )
+4 -5
View File
@@ -25,10 +25,9 @@ int chvt_main(int argc, char **argv)
}
fd = get_console_fd();
num = xatoul_range(argv[1], 1, 63);
if ((-1 == ioctl(fd, VT_ACTIVATE, num))
|| (-1 == ioctl(fd, VT_WAITACTIVE, num))) {
bb_perror_msg_and_die("ioctl");
}
num = xatou_range(argv[1], 1, 63);
/* double cast suppresses "cast to ptr from int of different size */
xioctl(fd, VT_ACTIVATE, (void *)(ptrdiff_t)num);
xioctl(fd, VT_WAITACTIVE, (void *)(ptrdiff_t)num);
return EXIT_SUCCESS;
}
+3 -4
View File
@@ -23,7 +23,7 @@ int deallocvt_main(int argc, char **argv)
switch (argc) {
case 2:
num = xatoul_range(argv[1], 1, 63);
num = xatou_range(argv[1], 1, 63);
/* Fallthrough */
case 1:
break;
@@ -31,8 +31,7 @@ int deallocvt_main(int argc, char **argv)
bb_show_usage();
}
if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
bb_perror_msg_and_die("VT_DISALLOCATE");
}
/* double cast suppresses "cast to ptr from int of different size */
xioctl(get_console_fd(), VT_DISALLOCATE, (void *)(ptrdiff_t)num);
return EXIT_SUCCESS;
}
+4 -4
View File
@@ -50,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);
}
}
+40 -53
View File
@@ -21,43 +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 loadfont_main(int argc, char **argv)
{
int fd;
if (argc != 1)
bb_show_usage();
fd = xopen(CURRENT_VC, O_RDWR);
loadnewfont(fd);
return EXIT_SUCCESS;
}
static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
{
char buf[16384];
char *buf;
int i;
memset(buf, 0, sizeof(buf));
if (unit < 1 || unit > 32)
bb_error_msg_and_die("bad character size %d", unit);
buf = xzalloc(16 * 1024);
/*memset(buf, 0, 16 * 1024);*/
for (i = 0; i < fontsize; i++)
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
#if defined( PIO_FONTX ) && !defined( __sparc__ )
#if defined(PIO_FONTX) && !defined(__sparc__)
{
struct consolefontdesc cfd;
@@ -65,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
@@ -106,49 +90,38 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
advice.advised_hashsize = 0;
advice.advised_hashstep = 0;
advice.advised_hashlevel = 0;
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
#ifdef ENOIOCTLCMD
if (errno == ENOIOCTLCMD) {
bb_error_msg("it seems this kernel is older than 1.1.92");
bb_error_msg_and_die("no Unicode mapping table loaded");
} else
#endif
bb_perror_msg_and_die("PIO_UNIMAPCLR");
}
xioctl(fd, PIO_UNIMAPCLR, &advice);
ud.entry_ct = ct;
ud.entries = up;
if (ioctl(fd, PIO_UNIMAP, &ud)) {
bb_perror_msg_and_die("PIO_UNIMAP");
}
xioctl(fd, PIO_UNIMAP, &ud);
}
static void loadnewfont(int fd)
{
enum { INBUF_SIZE = 32*1024 + 1 };
int unit;
unsigned char inbuf[32768]; /* primitive */
unsigned int inputlth, offset;
unsigned inputlth, offset;
/* Was on stack, but 32k is a bit too much: */
unsigned char *inbuf = xmalloc(INBUF_SIZE);
/*
* We used to look at the length of the input file
* with stat(); now that we accept compressed files,
* just read the entire file.
*/
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
if (ferror(stdin))
inputlth = full_read(STDIN_FILENO, inbuf, INBUF_SIZE);
if (inputlth < 0)
bb_perror_msg_and_die("error reading input font");
/* use malloc/realloc in case of giant files;
maybe these do not occur: 16kB for the font,
and 16kB for the map leaves 32 unicode values
for each font position */
if (!feof(stdin))
bb_perror_msg_and_die("font too large");
if (inputlth >= INBUF_SIZE)
bb_error_msg_and_die("font too large");
/* test for psf first */
{
struct psf_header psfhdr;
int fontsize;
int hastable;
unsigned int head0, head;
unsigned head0, head;
if (inputlth < sizeof(struct psf_header))
goto no_psf;
@@ -161,7 +134,7 @@ static void loadnewfont(int fd)
if (psfhdr.mode > PSF_MAXMODE)
bb_error_msg_and_die("unsupported psf file mode");
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
#if !defined( PIO_FONTX ) || defined( __sparc__ )
#if !defined(PIO_FONTX) || defined(__sparc__)
if (fontsize != 256)
bb_error_msg_and_die("only fontsize 256 supported");
#endif
@@ -177,8 +150,8 @@ static void loadnewfont(int fd)
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
return;
}
no_psf:
no_psf:
/* file with three code pages? */
if (inputlth == 9780) {
offset = 40;
@@ -192,3 +165,17 @@ static void loadnewfont(int fd)
}
do_loadfont(fd, inbuf + offset, unit, 256);
}
int loadfont_main(int argc, char **argv);
int loadfont_main(int argc, char **argv)
{
int fd;
if (argc != 1)
bb_show_usage();
fd = xopen(CURRENT_VC, O_RDWR);
loadnewfont(fd);
return EXIT_SUCCESS;
}
+5 -6
View File
@@ -11,16 +11,15 @@
#define ESC "\033"
struct termios old;
#define old_termios (*(struct termios*)&bb_common_bufsiz1)
static void
onintr(int sig ATTRIBUTE_UNUSED)
{
tcsetattr(STDERR_FILENO, TCSANOW, &old);
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
exit(1);
}
int resize_main(int argc, char **argv);
int resize_main(int argc, char **argv)
{
@@ -34,8 +33,8 @@ int resize_main(int argc, char **argv)
* and operate on it - should we do the same?
*/
tcgetattr(STDERR_FILENO, &old); /* fiddle echo */
new = old;
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);
@@ -60,7 +59,7 @@ int resize_main(int argc, char **argv)
* (gotten via TIOCGWINSZ) and recomputing *pixel values */
ret = ioctl(STDERR_FILENO, TIOCSWINSZ, &w);
tcsetattr(STDERR_FILENO, TCSANOW, &old);
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
if (ENABLE_FEATURE_RESIZE_PRINT)
printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n",
+6 -9
View File
@@ -11,10 +11,9 @@
#include "libbb.h"
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
static const struct option setconsole_long_options[] = {
{ "reset", 0, NULL, 'r' },
{ 0, 0, 0, 0 }
};
static const char setconsole_longopts[] ALIGN1 =
"reset\0" No_argument "r"
;
#endif
#define OPT_SETCONS_RESET 1
@@ -26,9 +25,9 @@ int setconsole_main(int argc, char **argv)
const char *device = CURRENT_TTY;
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
applet_long_options = setconsole_long_options;
applet_long_options = setconsole_longopts;
#endif
flags = getopt32(argc, argv, "r");
flags = getopt32(argv, "r");
if (argc - optind > 1)
bb_show_usage();
@@ -42,8 +41,6 @@ int setconsole_main(int argc, char **argv)
device = DEV_CONSOLE;
}
if (-1 == ioctl(xopen(device, O_RDONLY), TIOCCONS)) {
bb_perror_msg_and_die("TIOCCONS");
}
xioctl(xopen(device, O_RDONLY), TIOCCONS, NULL);
return EXIT_SUCCESS;
}
+3 -3
View File
@@ -39,9 +39,9 @@ int setkeycodes_main(int argc, char** argv)
a.scancode -= 0xe000;
a.scancode += 128;
}
if (ioctl(fd, KDSETKEYCODE, &a)) {
bb_perror_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
}
ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
"failed to set SCANCODE %x to KEYCODE %d",
sc, a.keycode);
argc -= 2;
argv += 2;
}
+1 -2
View File
@@ -25,8 +25,7 @@ int setlogcons_main(int argc, char **argv)
if (argc == 2)
arg.subarg = xatoul_range(argv[1], 0, 63);
if (ioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg))
bb_perror_msg_and_die("TIOCLINUX");
xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
return 0;
}
+40 -47
View File
@@ -65,13 +65,6 @@ config CKSUM
help
cksum is used to calculate the CRC32 checksum of a file.
config CMP
bool "cmp"
default n
help
cmp is used to compare two files and returns the result
to standard output.
config COMM
bool "comm"
default n
@@ -142,38 +135,6 @@ config DF
df reports the amount of disk space used and available
on filesystems.
config DIFF
bool "diff"
default n
help
diff compares two files or directories and outputs the
differences between them in a form that can be given to
the patch command.
config FEATURE_DIFF_BINARY
bool "Enable checks for binary files"
default y
depends on DIFF
help
This option enables support for checking for binary files
before a comparison is carried out.
config FEATURE_DIFF_DIR
bool "Enable directory support"
default y
depends on DIFF
help
This option enables support for directory and subdirectory
comparison.
config FEATURE_DIFF_MINIMAL
bool "Enable -d option to find smaller sets of changes"
default n
depends on DIFF
help
Enabling this option allows the use of -d to make diff
try hard to find the smallest possible set of changes.
config DIRNAME
bool "dirname"
default n
@@ -239,6 +200,19 @@ config FEATURE_ENV_LONG_OPTIONS
help
Support long options for the env applet.
config EXPAND
bool "expand"
default n
help
By default, convert all tabs to spaces.
config FEATURE_EXPAND_LONG_OPTIONS
bool "Enable long options"
default n
depends on EXPAND && GETOPT_LONG
help
Support long options for the expand applet.
config EXPR
bool "expr"
default n
@@ -474,6 +448,20 @@ config PWD
help
pwd is used to print the current directory.
config READLINK
bool "readlink"
default n
help
This program reads a symbolic link and returns the name
of the file it points to
config FEATURE_READLINK_FOLLOW
bool "Enable canonicalization by following all symlinks (-f)"
default n
depends on READLINK
help
Enable the readlink option (-f).
config REALPATH
bool "realpath"
default n
@@ -680,6 +668,19 @@ config UNAME
help
uname is used to print system information.
config UNEXPAND
bool "unexpand"
default n
help
By default, convert only leading sequences of blanks to tabs.
config FEATURE_UNEXPAND_LONG_OPTIONS
bool "Enable long options"
default n
depends on UNEXPAND && GETOPT_LONG
help
Support long options for the unexpand applet.
config UNIQ
bool "uniq"
default n
@@ -704,14 +705,6 @@ config UUENCODE
help
uuencode is used to uuencode a file.
config WATCH
bool "watch"
default n
select DATE
help
watch is used to execute a program periodically, showing
output to the screen.
config WC
bool "wc"
default n
+3 -3
View File
@@ -18,14 +18,12 @@ lib-$(CONFIG_CHMOD) += chmod.o
lib-$(CONFIG_CHOWN) += chown.o
lib-$(CONFIG_CHROOT) += chroot.o
lib-$(CONFIG_CKSUM) += cksum.o
lib-$(CONFIG_CMP) += cmp.o
lib-$(CONFIG_COMM) += comm.o
lib-$(CONFIG_CP) += cp.o
lib-$(CONFIG_CUT) += cut.o
lib-$(CONFIG_DATE) += date.o
lib-$(CONFIG_DD) += dd.o
lib-$(CONFIG_DF) += df.o
lib-$(CONFIG_DIFF) += diff.o
lib-$(CONFIG_DIRNAME) += dirname.o
lib-$(CONFIG_DOS2UNIX) += dos2unix.o
lib-$(CONFIG_DU) += du.o
@@ -33,6 +31,7 @@ lib-$(CONFIG_ECHO) += echo.o
lib-$(CONFIG_ASH) += echo.o # used by ash
lib-$(CONFIG_ENV) += env.o
lib-$(CONFIG_EXPR) += expr.o
lib-$(CONFIG_EXPAND) += expand.o
lib-$(CONFIG_FALSE) += false.o
lib-$(CONFIG_FOLD) += fold.o
lib-$(CONFIG_HEAD) += head.o
@@ -54,6 +53,7 @@ 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
@@ -75,11 +75,11 @@ lib-$(CONFIG_TR) += tr.o
lib-$(CONFIG_TRUE) += true.o
lib-$(CONFIG_TTY) += tty.o
lib-$(CONFIG_UNAME) += uname.o
lib-$(CONFIG_UNEXPAND) += expand.o
lib-$(CONFIG_UNIQ) += uniq.o
lib-$(CONFIG_USLEEP) += usleep.o
lib-$(CONFIG_UUDECODE) += uudecode.o
lib-$(CONFIG_UUENCODE) += uuencode.o
lib-$(CONFIG_WATCH) += watch.o
lib-$(CONFIG_WC) += wc.o
lib-$(CONFIG_WHO) += who.o
lib-$(CONFIG_WHOAMI) += whoami.o
+51 -56
View File
@@ -19,6 +19,8 @@
#include "libbb.h"
/* We often use "unsigned" intead of "int", it's easier to div on most CPUs */
#define THURSDAY 4 /* for reformation */
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
@@ -28,29 +30,25 @@
#define MAXDAYS 42 /* max slots in a month array */
#define SPACE -1 /* used in day array */
static const char days_in_month[] = {
static const unsigned char days_in_month[] ALIGN1 = {
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
static const char sep1752[] = {
static const unsigned char sep1752[] ALIGN1 = {
1, 2, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30
};
static int julian;
static unsigned julian;
/* leap year -- account for Gregorian reformation in 1752 */
#define leap_year(yr) \
((yr) <= 1752 ? !((yr) % 4) : \
(!((yr) % 4) && ((yr) % 100)) || !((yr) % 400))
static int is_leap_year(int year)
static int leap_year(unsigned yr)
{
return leap_year(year);
if (yr <= 1752)
return !(yr % 4);
return (!(yr % 4) && (yr % 100)) || !(yr % 400);
}
#undef leap_year
#define leap_year(yr) is_leap_year(yr)
/* number of centuries since 1700, not inclusive */
#define centuries_since_1700(yr) \
@@ -64,12 +62,12 @@ static int is_leap_year(int year)
#define leap_years_since_year_1(yr) \
((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
static void center (char *, int, int);
static void day_array (int, int, int *);
static void trim_trailing_spaces_and_print (char *);
static void center(char *, unsigned, unsigned);
static void day_array(unsigned, unsigned, unsigned *);
static void trim_trailing_spaces_and_print(char *);
static void blank_string(char *buf, size_t buflen);
static char *build_row(char *p, int *dp);
static char *build_row(char *p, unsigned *dp);
#define DAY_LEN 3 /* 3 spaces per day */
#define J_DAY_LEN (DAY_LEN + 1)
@@ -83,20 +81,18 @@ int cal_main(int argc, char **argv)
struct tm *local_time;
struct tm zero_tm;
time_t now;
int month, year, flags, i;
unsigned month, year, flags, i;
char *month_names[12];
char day_headings[28]; /* 28 for julian, 21 for nonjulian */
char buf[40];
flags = getopt32(argc, argv, "jy");
flags = getopt32(argv, "jy");
julian = flags & 1;
argv += optind;
month = 0;
argv += optind;
argc -= optind;
if ((argc -= optind) > 2) {
if (argc > 2) {
bb_show_usage();
}
@@ -109,12 +105,12 @@ int cal_main(int argc, char **argv)
}
} else {
if (argc == 2) {
month = xatoul_range(*argv++, 1, 12);
month = xatou_range(*argv++, 1, 12);
}
year = xatoul_range(*argv, 1, 9999);
year = xatou_range(*argv, 1, 9999);
}
blank_string(day_headings, sizeof(day_headings) - 7 + 7*julian);
blank_string(day_headings, sizeof(day_headings) - 7 + 7*julian);
i = 0;
do {
@@ -130,8 +126,8 @@ int cal_main(int argc, char **argv)
} while (++i < 12);
if (month) {
int row, len, days[MAXDAYS];
int *dp = days;
unsigned row, len, days[MAXDAYS];
unsigned *dp = days;
char lineout[30];
day_array(month, year, dp);
@@ -145,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);
@@ -193,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));
@@ -214,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)) {
@@ -227,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);
}
@@ -250,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)
@@ -263,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';
@@ -274,9 +269,9 @@ static void trim_trailing_spaces_and_print(char *s)
puts(s);
}
static void center(char *str, int len, int separate)
static void center(char *str, unsigned len, unsigned separate)
{
int n = strlen(str);
unsigned n = strlen(str);
len -= n;
printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
}
@@ -287,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) {
@@ -304,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';
@@ -348,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.
*/
+1 -1
View File
@@ -46,7 +46,7 @@ int bb_cat(char **argv)
int cat_main(int argc, char **argv);
int cat_main(int argc, char **argv)
{
getopt32(argc, argv, "u");
getopt32(argv, "u");
argv += optind;
return bb_cat(argv);
}
+21 -12
View File
@@ -15,40 +15,49 @@
int catv_main(int argc, char **argv);
int catv_main(int argc, char **argv)
{
int retval = EXIT_SUCCESS, fd;
int retval = EXIT_SUCCESS;
int fd;
unsigned flags;
flags = getopt32(argc, argv, "etv");
flags = getopt32(argv, "etv");
#define CATV_OPT_e (1<<0)
#define CATV_OPT_t (1<<1)
#define CATV_OPT_v (1<<2)
flags ^= CATV_OPT_v;
argv += optind;
/* Read from stdin if there's nothing else to do. */
fd = 0;
if (!argv[0]) {
argv--;
goto jump_in;
}
do {
/* Read from stdin if there's nothing else to do. */
fd = 0;
if (*argv && 0 > (fd = xopen(*argv, O_RDONLY)))
fd = open_or_warn(*argv, O_RDONLY);
if (fd < 0) {
retval = EXIT_FAILURE;
else for (;;) {
continue;
}
jump_in:
for (;;) {
int i, res;
res = read(fd, bb_common_bufsiz1, sizeof(bb_common_bufsiz1));
#define read_buf bb_common_bufsiz1
res = read(fd, read_buf, COMMON_BUFSIZE);
if (res < 0)
retval = EXIT_FAILURE;
if (res < 1)
break;
for (i = 0; i < res; i++) {
char c = bb_common_bufsiz1[i];
unsigned char c = read_buf[i];
if (c > 126 && (flags & CATV_OPT_v)) {
if (c == 127) {
printf("^?");
continue;
} else {
printf("M-");
c -= 128;
}
printf("M-");
c -= 128;
}
if (c < 32) {
if (c == 10) {
+1 -1
View File
@@ -93,7 +93,7 @@ int chmod_main(int argc, char **argv)
/* Parse options */
opt_complementary = "-2";
getopt32(argc, argv, ("-"OPT_STR) + 1); /* Reuse string */
getopt32(argv, ("-"OPT_STR) + 1); /* Reuse string */
argv += optind;
/* Restore option-like mode if needed */
+32 -30
View File
@@ -65,10 +65,11 @@ int chown_main(int argc, char **argv);
int chown_main(int argc, char **argv)
{
int retval = EXIT_SUCCESS;
int flags;
chown_fptr chown_func;
opt_complementary = "-2";
getopt32(argc, argv, OPT_STR);
getopt32(argv, OPT_STR);
argv += optind;
/* This matches coreutils behavior (almost - see below) */
@@ -80,23 +81,21 @@ int chown_main(int argc, char **argv)
chown_func = lchown;
}
flags = ACTION_DEPTHFIRST; /* match coreutils order */
if (OPT_RECURSE)
flags |= ACTION_RECURSE;
if (OPT_TRAVERSE_TOP)
flags |= ACTION_FOLLOWLINKS_L0; /* -H/-L: follow links on depth 0 */
if (OPT_TRAVERSE)
flags |= ACTION_FOLLOWLINKS; /* follow links if -L */
parse_chown_usergroup_or_die(&ugid, argv[0]);
/* Ok, ready to do the deed now */
argv++;
do {
char *arg = *argv;
if (OPT_TRAVERSE_TOP) {
/* resolves symlink (even recursive) */
arg = xmalloc_realpath(arg);
if (!arg)
continue;
}
if (!recursive_action(arg,
(OPT_RECURSE ? ACTION_RECURSE : 0) | /* recurse */
(OPT_TRAVERSE ? ACTION_FOLLOWLINKS : 0),/* follow links if -L */
if (!recursive_action(*argv,
flags, /* flags */
fileAction, /* file action */
fileAction, /* dir action */
chown_func, /* user data */
@@ -104,9 +103,6 @@ int chown_main(int argc, char **argv)
) {
retval = EXIT_FAILURE;
}
if (OPT_TRAVERSE_TOP)
free(arg);
} while (*++argv);
return retval;
@@ -137,8 +133,10 @@ create() {
tst() {
create test1
create test2
(cd test1; $t1 $1)
(cd test2; $t2 $1)
echo "[$1]" >>test1.out
echo "[$1]" >>test2.out
(cd test1; $t1 $1) >>test1.out 2>&1
(cd test2; $t2 $1) >>test2.out 2>&1
(cd test1; ls -lnR) >out1
(cd test2; ls -lnR) >out2
echo "chown $1" >out.diff
@@ -152,18 +150,22 @@ tst_for_each() {
tst "$1 1:1 linkfile"
}
echo "If script produced 'out.diff' file, then at least one testcase failed"
>test1.out
>test2.out
# These match coreutils 6.8:
tst_for_each ""
tst_for_each "-R"
tst_for_each "-RP"
tst_for_each "-RL"
tst_for_each "-RH"
tst_for_each "-h"
tst_for_each "-hR"
tst_for_each "-hRP"
# Below: with "chown linkdir" coreutils 6.8 will chown linkdir _target_,
# we lchown _the link_. I believe we are "more correct".
#tst_for_each "-hRL"
#tst_for_each "-hRH"
tst_for_each "-v"
tst_for_each "-vR"
tst_for_each "-vRP"
tst_for_each "-vRL"
tst_for_each "-vRH"
tst_for_each "-vh"
tst_for_each "-vhR"
tst_for_each "-vhRP"
tst_for_each "-vhRL"
tst_for_each "-vhRH"
# Fix `name' in coreutils output
sed 's/`/'"'"'/g' -i test2.out
# Compare us with coreutils output
diff -u test1.out test2.out
*/
+3 -2
View File
@@ -27,8 +27,9 @@ int cksum_main(int argc, char **argv)
crc = 0;
length = 0;
while ((bytes_read = fread(bb_common_bufsiz1, 1, BUFSIZ, fp)) > 0) {
cp = bb_common_bufsiz1;
#define read_buf bb_common_bufsiz1
while ((bytes_read = fread(read_buf, 1, BUFSIZ, fp)) > 0) {
cp = read_buf;
length += bytes_read;
while (bytes_read--)
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ (*cp++)) & 0xffL];
+1 -1
View File
@@ -47,7 +47,7 @@ int comm_main(int argc, char **argv)
unsigned flags;
opt_complementary = "=2";
flags = getopt32(argc, argv, "123");
flags = getopt32(argv, "123");
argv += optind;
for (i = 0; i < 2; ++i) {
+2 -2
View File
@@ -44,8 +44,8 @@ int cp_main(int argc, char **argv)
// -P and -d are the same (-P is POSIX, -d is GNU)
// -r and -R are the same
// -a = -pdR
opt_complementary = "?:l--s:s--l:Pd:rR:apdR";
flags = getopt32(argc, argv, FILEUTILS_CP_OPTSTR "arPHL");
opt_complementary = "l--s:s--l:Pd:rR:apdR";
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPHL");
/* Default behavior of cp is to dereference, so we don't have to do
* anything special when we are given -L.
* The behavior of -H is *almost* like -L, but not quite, so let's
+3 -5
View File
@@ -15,7 +15,7 @@
/* option vars */
static const char optstring[] = "b:c:f:d:sn";
static const char optstring[] ALIGN1 = "b:c:f:d:sn";
#define CUT_OPT_BYTE_FLGS (1<<0)
#define CUT_OPT_CHAR_FLGS (1<<1)
#define CUT_OPT_FIELDS_FLGS (1<<2)
@@ -163,7 +163,7 @@ static void cut_file(FILE * file)
}
}
static const char _op_on_field[] = " only when operating on fields";
static const char _op_on_field[] ALIGN1 = " only when operating on fields";
int cut_main(int argc, char **argv);
int cut_main(int argc, char **argv)
@@ -171,13 +171,11 @@ int cut_main(int argc, char **argv)
char *sopt, *ltok;
opt_complementary = "b--bcf:c--bcf:f--bcf";
getopt32(argc, argv, optstring, &sopt, &sopt, &sopt, &ltok);
getopt32(argv, optstring, &sopt, &sopt, &sopt, &ltok);
// argc -= optind;
argv += optind;
if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
bb_error_msg_and_die("expected a list of bytes, characters, or fields");
if (option_mask32 & BB_GETOPT_ERROR)
bb_error_msg_and_die("only one type of list may be specified");
if (option_mask32 & CUT_OPT_DELIM_FLGS) {
if (strlen(ltok) > 1) {
+9 -7
View File
@@ -51,9 +51,9 @@ int date_main(int argc, char **argv)
char *isofmt_arg;
char *hintfmt_arg;
opt_complementary = "?:d--s:s--d"
opt_complementary = "d--s:s--d"
USE_FEATURE_DATE_ISOFMT(":R--I:I--R");
opt = getopt32(argc, argv, "Rs:ud:r:"
opt = getopt32(argv, "Rs:ud:r:"
USE_FEATURE_DATE_ISOFMT("I::D:"),
&date_str, &date_str, &filename
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg));
@@ -63,8 +63,9 @@ int date_main(int argc, char **argv)
if (!isofmt_arg) {
ifmt = 0; /* default is date */
} else {
static const char * const isoformats[] =
{ "date", "hours", "minutes", "seconds" };
static const char *const isoformats[] = {
"date", "hours", "minutes", "seconds"
};
for (ifmt = 0; ifmt < 4; ifmt++)
if (!strcmp(isofmt_arg, isoformats[ifmt]))
@@ -216,9 +217,10 @@ int date_main(int argc, char **argv)
date_fmt = (char*)"%a %b %e %H:%M:%S %Z %Y";
}
#define date_buf bb_common_bufsiz1
if (*date_fmt == '\0') {
/* With no format string, just print a blank line */
*bb_common_bufsiz1 = 0;
date_buf[0] = '\0';
} else {
/* Handle special conversions */
@@ -227,9 +229,9 @@ int date_main(int argc, char **argv)
}
/* Generate output string */
strftime(bb_common_bufsiz1, 200, date_fmt, &tm_time);
strftime(date_buf, sizeof(date_buf), date_fmt, &tm_time);
}
puts(bb_common_bufsiz1);
puts(date_buf);
return EXIT_SUCCESS;
}
+69 -48
View File
@@ -25,24 +25,28 @@ static const struct suffix_mult dd_suffixes[] = {
{ "M", 1048576 },
{ "GD", 1000000000 },
{ "G", 1073741824 },
{ NULL, 0 }
{ }
};
struct globals {
off_t out_full, out_part, in_full, in_part;
};
#define G (*(struct globals*)&bb_common_bufsiz1)
/* We have to zero it out because of NOEXEC */
#define INIT_G() memset(&G, 0, sizeof(G))
static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal)
{
fprintf(stderr, "%"OFF_FMT"d+%"OFF_FMT"d records in\n"
"%"OFF_FMT"d+%"OFF_FMT"d records out\n",
/* Deliberately using %u, not %d */
fprintf(stderr, "%"OFF_FMT"u+%"OFF_FMT"u records in\n"
"%"OFF_FMT"u+%"OFF_FMT"u records out\n",
G.in_full, G.in_part,
G.out_full, G.out_part);
}
static ssize_t full_write_or_warn(int fd, const void *buf, size_t len,
const char * const filename)
const char *const filename)
{
ssize_t n = full_write(fd, buf, len);
if (n < 0)
@@ -51,7 +55,7 @@ static ssize_t full_write_or_warn(int fd, const void *buf, size_t len,
}
static bool write_and_stats(int fd, const void *buf, size_t len, size_t obs,
const char * const filename)
const char *filename)
{
ssize_t n = full_write_or_warn(fd, buf, len, filename);
if (n < 0)
@@ -73,18 +77,18 @@ int dd_main(int argc, char **argv);
int dd_main(int argc, char **argv)
{
enum {
SYNC_FLAG = 1 << 0,
NOERROR = 1 << 1,
TRUNC_FLAG = 1 << 2,
TWOBUFS_FLAG = 1 << 3,
FLAG_SYNC = 1 << 0,
FLAG_NOERROR = 1 << 1,
FLAG_NOTRUNC = 1 << 2,
FLAG_TWOBUFS = 1 << 3,
FLAG_COUNT = 1 << 4,
};
static const char * const keywords[] = {
"bs=", "count=", "seek=", "skip=", "if=", "of=",
static const char keywords[] ALIGN1 =
"bs=\0""count=\0""seek=\0""skip=\0""if=\0""of=\0"
#if ENABLE_FEATURE_DD_IBS_OBS
"ibs=", "obs=", "conv=", "notrunc", "sync", "noerror",
"ibs=\0""obs=\0""conv=\0""notrunc\0""sync\0""noerror\0"
#endif
NULL
};
;
enum {
OP_bs = 1,
OP_count,
@@ -101,25 +105,41 @@ int dd_main(int argc, char **argv)
OP_conv_noerror,
#endif
};
int flags = TRUNC_FLAG;
size_t oc = 0, ibs = 512, obs = 512;
size_t ibs = 512, obs = 512;
ssize_t n, w;
off_t seek = 0, skip = 0, count = OFF_T_MAX;
int ifd, ofd;
const char *infile = NULL, *outfile = NULL;
char *ibuf, *obuf;
/* And these are all zeroed at once! */
struct {
int flags;
int ifd, ofd;
size_t oc;
off_t count;
off_t seek, skip;
const char *infile, *outfile;
#if ENABLE_FEATURE_DD_SIGNAL_HANDLING
struct sigaction sigact;
#endif
} Z;
#define flags (Z.flags )
#define ifd (Z.ifd )
#define ofd (Z.ofd )
#define oc (Z.oc )
#define count (Z.count )
#define seek (Z.seek )
#define skip (Z.skip )
#define infile (Z.infile )
#define outfile (Z.outfile)
#define sigact (Z.sigact )
memset(&G, 0, sizeof(G)); /* because of NOEXEC */
memset(&Z, 0, sizeof(Z));
INIT_G();
if (ENABLE_FEATURE_DD_SIGNAL_HANDLING) {
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = dd_output_status;
sa.sa_flags = SA_RESTART;
sigemptyset(&sa.sa_mask);
sigaction(SIGUSR1, &sa, 0);
}
#if ENABLE_FEATURE_DD_SIGNAL_HANDLING
sigact.sa_handler = dd_output_status;
sigact.sa_flags = SA_RESTART;
sigemptyset(&sigact.sa_mask);
sigaction(SIGUSR1, &sigact, NULL);
#endif
for (n = 1; n < argc; n++) {
smalluint key_len;
@@ -134,7 +154,7 @@ int dd_main(int argc, char **argv)
bb_show_usage();
key_len = key - arg + 1;
key = xstrndup(arg, key_len);
what = index_in_str_array(keywords, key) + 1;
what = index_in_strings(keywords, key) + 1;
if (ENABLE_FEATURE_CLEAN_UP)
free(key);
if (what == 0)
@@ -153,21 +173,21 @@ int dd_main(int argc, char **argv)
if (what == OP_conv) {
while (1) {
/* find ',', replace them with nil so we can use arg for
* index_in_str_array without copying.
* index_in_strings() without copying.
* We rely on arg being non-null, else strchr would fault.
*/
key = strchr(arg, ',');
if (key)
*key = '\0';
what = index_in_str_array(keywords, arg) + 1;
what = index_in_strings(keywords, arg) + 1;
if (what < OP_conv_notrunc)
bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv");
if (what == OP_conv_notrunc)
flags &= ~TRUNC_FLAG;
flags |= FLAG_NOTRUNC;
if (what == OP_conv_sync)
flags |= SYNC_FLAG;
flags |= FLAG_SYNC;
if (what == OP_conv_noerror)
flags |= NOERROR;
flags |= FLAG_NOERROR;
if (!key) /* no ',' left, so this was the last specifier */
break;
arg = key + 1; /* skip this keyword and ',' */
@@ -181,6 +201,7 @@ int dd_main(int argc, char **argv)
}
/* These can be large: */
if (what == OP_count) {
flags |= FLAG_COUNT;
count = XATOU_SFX(arg, dd_suffixes);
continue;
}
@@ -202,24 +223,24 @@ int dd_main(int argc, char **argv)
//XXX:FIXME for huge ibs or obs, malloc'ing them isn't the brightest idea ever
ibuf = obuf = xmalloc(ibs);
if (ibs != obs) {
flags |= TWOBUFS_FLAG;
flags |= FLAG_TWOBUFS;
obuf = xmalloc(obs);
}
if (infile != NULL)
ifd = xopen(infile, O_RDONLY);
else {
ifd = STDIN_FILENO;
/* ifd = STDIN_FILENO; - it's zero and it's already there */
infile = bb_msg_standard_input;
}
if (outfile != NULL) {
int oflag = O_WRONLY | O_CREAT;
if (!seek && (flags & TRUNC_FLAG))
if (!seek && !(flags & FLAG_NOTRUNC))
oflag |= O_TRUNC;
ofd = xopen(outfile, oflag);
if (seek && (flags & TRUNC_FLAG)) {
if (seek && !(flags & FLAG_NOTRUNC)) {
if (ftruncate(ofd, seek * obs) < 0) {
struct stat st;
@@ -248,14 +269,14 @@ int dd_main(int argc, char **argv)
goto die_outfile;
}
while (G.in_full + G.in_part != count) {
if (flags & NOERROR) /* Pre-zero the buffer when for NOERROR */
memset(ibuf, '\0', ibs);
while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) {
if (flags & FLAG_NOERROR) /* Pre-zero the buffer if conv=noerror */
memset(ibuf, 0, ibs);
n = safe_read(ifd, ibuf, ibs);
if (n == 0)
break;
if (n < 0) {
if (flags & NOERROR) {
if (flags & FLAG_NOERROR) {
n = ibs;
bb_perror_msg("%s", infile);
} else
@@ -265,12 +286,12 @@ int dd_main(int argc, char **argv)
G.in_full++;
else {
G.in_part++;
if (flags & SYNC_FLAG) {
if (flags & FLAG_SYNC) {
memset(ibuf + n, '\0', ibs - n);
n = ibs;
}
}
if (flags & TWOBUFS_FLAG) {
if (flags & FLAG_TWOBUFS) {
char *tmp = ibuf;
while (n) {
size_t d = obs - oc;
@@ -298,15 +319,15 @@ int dd_main(int argc, char **argv)
G.out_part++;
}
if (close(ifd) < 0) {
die_infile:
die_infile:
bb_perror_msg_and_die("%s", infile);
}
if (close(ofd) < 0) {
die_outfile:
die_outfile:
bb_perror_msg_and_die("%s", outfile);
}
out_status:
out_status:
dd_output_status(0);
return EXIT_SUCCESS;
+29 -29
View File
@@ -22,32 +22,32 @@
#include <sys/vfs.h>
#include "libbb.h"
#ifndef CONFIG_FEATURE_HUMAN_READABLE
static long kscale(long b, long bs)
#if !ENABLE_FEATURE_HUMAN_READABLE
static unsigned long kscale(unsigned long b, unsigned long bs)
{
return ( b * (long long) bs + 1024/2 ) / 1024;
return (b * (unsigned long long) bs + 1024/2) / 1024;
}
#endif
int df_main(int argc, char **argv);
int df_main(int argc, char **argv)
{
long blocks_used;
long blocks_percent_used;
#ifdef CONFIG_FEATURE_HUMAN_READABLE
unsigned long df_disp_hr = 1024;
unsigned long blocks_used;
unsigned blocks_percent_used;
#if ENABLE_FEATURE_HUMAN_READABLE
unsigned df_disp_hr = 1024;
#endif
int status = EXIT_SUCCESS;
unsigned opt;
FILE *mount_table;
struct mntent *mount_entry;
struct statfs s;
static const char hdr_1k[] = "1k-blocks"; /* default display is kilobytes */
const char *disp_units_hdr = hdr_1k;
/* default display is kilobytes */
const char *disp_units_hdr = "1k-blocks";
#ifdef CONFIG_FEATURE_HUMAN_READABLE
#if ENABLE_FEATURE_HUMAN_READABLE
opt_complementary = "h-km:k-hm:m-hk";
opt = getopt32(argc, argv, "hmk");
opt = getopt32(argv, "hmk");
if (opt & 1) {
df_disp_hr = 0;
disp_units_hdr = " Size";
@@ -57,7 +57,7 @@ int df_main(int argc, char **argv)
disp_units_hdr = "1M-blocks";
}
#else
opt = getopt32(argc, argv, "k");
opt = getopt32(argv, "k");
#endif
printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
@@ -72,7 +72,7 @@ int df_main(int argc, char **argv)
}
}
do {
while (1) {
const char *device;
const char *mount_point;
@@ -108,7 +108,7 @@ int df_main(int argc, char **argv)
blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = 0;
if (blocks_used + s.f_bavail) {
blocks_percent_used = (((long long) blocks_used) * 100
blocks_percent_used = (blocks_used * 100ULL
+ (blocks_used + s.f_bavail)/2
) / (blocks_used + s.f_bavail);
}
@@ -124,28 +124,28 @@ int df_main(int argc, char **argv)
}
}
#ifdef CONFIG_FEATURE_HUMAN_READABLE
printf("%-20s %9s ", device,
if (printf("\n%-20s" + 1, device) > 20)
printf("\n%-20s", "");
#if ENABLE_FEATURE_HUMAN_READABLE
printf(" %9s ",
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
printf("%9s ",
make_human_readable_str( (s.f_blocks - s.f_bfree),
printf(" %9s " + 1,
make_human_readable_str((s.f_blocks - s.f_bfree),
s.f_bsize, df_disp_hr));
printf("%9s %3ld%% %s\n",
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
printf("%9s %3u%% %s\n",
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
blocks_percent_used, mount_point);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
kscale(s.f_blocks, s.f_bsize),
kscale(s.f_blocks-s.f_bfree, s.f_bsize),
kscale(s.f_bavail, s.f_bsize),
blocks_percent_used, mount_point);
printf(" %9lu %9lu %9lu %3u%% %s\n",
kscale(s.f_blocks, s.f_bsize),
kscale(s.f_blocks-s.f_bfree, s.f_bsize),
kscale(s.f_bavail, s.f_bsize),
blocks_percent_used, mount_point);
#endif
}
} while (1);
}
fflush_stdout_and_exit(status);
}
+30 -35
View File
@@ -14,17 +14,20 @@
#include "libbb.h"
enum ConvType {
enum {
CT_UNIX2DOS = 1,
CT_DOS2UNIX
} ConvType;
};
/* if fn is NULL then input is stdin and output is stdout */
static int convert(char *fn)
static int convert(char *fn, int conv_type)
{
FILE *in, *out;
int i;
#define name_buf bb_common_bufsiz1
in = stdin;
out = stdout;
if (fn != NULL) {
in = xfopen(fn, "rw");
/*
@@ -32,31 +35,24 @@ static int convert(char *fn)
permissions 0666 for glibc 2.0.6 and earlier or
0600 for glibc 2.0.7 and later.
*/
snprintf(bb_common_bufsiz1, sizeof(bb_common_bufsiz1), "%sXXXXXX", fn);
/*
sizeof bb_common_bufsiz1 is 4096, so it should be big enough to
hold the full path. However if the output is truncated the
subsequent call to mkstemp would fail.
*/
i = mkstemp(&bb_common_bufsiz1[0]);
if (i == -1 || chmod(bb_common_bufsiz1, 0600) == -1) {
snprintf(name_buf, sizeof(name_buf), "%sXXXXXX", fn);
i = mkstemp(&name_buf[0]);
if (i == -1 || chmod(name_buf, 0600) == -1) {
bb_perror_nomsg_and_die();
}
out = fdopen(i, "w+");
if (!out) {
close(i);
remove(bb_common_bufsiz1);
remove(name_buf);
return -2;
}
} else {
in = stdin;
out = stdout;
}
while ((i = fgetc(in)) != EOF) {
if (i == '\r')
continue;
if (i == '\n') {
if (ConvType == CT_UNIX2DOS)
if (conv_type == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
continue;
@@ -67,14 +63,14 @@ static int convert(char *fn)
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0) {
bb_perror_nomsg();
remove(bb_common_bufsiz1);
remove(name_buf);
return -2;
}
/* Assume they are both on the same filesystem (which
* should be true since we put them into the same directory
* so we _should_ be ok, but you never know... */
if (rename(bb_common_bufsiz1, fn) < 0) {
bb_perror_msg("cannot rename '%s' as '%s'", bb_common_bufsiz1, fn);
if (rename(name_buf, fn) < 0) {
bb_perror_msg("cannot rename '%s' as '%s'", name_buf, fn);
return -1;
}
}
@@ -85,32 +81,31 @@ static int convert(char *fn)
int dos2unix_main(int argc, char **argv);
int dos2unix_main(int argc, char **argv)
{
int o;
int o, conv_type;
/* See if we are supposed to be doing dos2unix or unix2dos */
if (applet_name[0] == 'd') {
ConvType = CT_DOS2UNIX; /*2 */
conv_type = CT_DOS2UNIX; /* 2 */
} else {
ConvType = CT_UNIX2DOS; /*1 */
conv_type = CT_UNIX2DOS; /* 1 */
}
/* -u and -d are mutally exclusive */
opt_complementary = "?:u--d:d--u";
/* process parameters */
/* -u convert to unix */
/* -d convert to dos */
o = getopt32(argc, argv, "du");
/* -u convert to unix, -d convert to dos */
opt_complementary = "u--d:d--u"; /* mutually exclusive */
o = getopt32(argv, "du");
/* Do the conversion requested by an argument else do the default
* conversion depending on our name. */
if (o)
ConvType = o;
conv_type = o;
if (optind < argc) {
while (optind < argc)
if ((o = convert(argv[optind++])) < 0)
break;
} else
o = convert(NULL);
do {
/* might be convert(NULL) if there is no filename given */
o = convert(argv[optind], conv_type);
if (o < 0)
break;
optind++;
} while (optind < argc);
return o;
}
+4 -4
View File
@@ -48,7 +48,7 @@ static int one_file_system;
static dev_t dir_dev;
static void print(long size, const char * const filename)
static void print(long size, const char *const filename)
{
/* TODO - May not want to defer error checking here. */
#if ENABLE_FEATURE_HUMAN_READABLE
@@ -64,7 +64,7 @@ static void print(long size, const char * const filename)
}
/* tiny recursive du */
static long du(const char * const filename)
static long du(const char *const filename)
{
struct stat statbuf;
long sum;
@@ -170,7 +170,7 @@ int du_main(int argc, char **argv)
*/
#if ENABLE_FEATURE_HUMAN_READABLE
opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
opt = getopt32(argc, argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
if (opt & (1 << 9)) {
/* -h opt */
disp_hr = 0;
@@ -185,7 +185,7 @@ int du_main(int argc, char **argv)
}
#else
opt_complementary = "H-L:L-H:s-d:d-s";
opt = getopt32(argc, argv, "aHkLsx" "d:" "lc", &smax_print_depth);
opt = getopt32(argv, "aHkLsx" "d:" "lc", &smax_print_depth);
#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
if (opt & (1 << 2)) {
/* -k opt */
+7 -8
View File
@@ -35,11 +35,10 @@ extern char **environ;
#include "libbb.h"
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
static const struct option env_long_options[] = {
{ "ignore-environment", 0, NULL, 'i' },
{ "unset", 1, NULL, 'u' },
{ 0, 0, 0, 0 }
};
static const char env_longopts[] ALIGN1 =
"ignore-environment\0" No_argument "i"
"unset\0" Required_argument "u"
;
#endif
int env_main(int argc, char** argv);
@@ -53,9 +52,9 @@ int env_main(int argc, char** argv)
opt_complementary = "u::";
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
applet_long_options = env_long_options;
applet_long_options = env_longopts;
#endif
opt = getopt32(argc, argv, "+iu:", &unset_env);
opt = getopt32(argv, "+iu:", &unset_env);
argv += optind;
if (*argv && LONE_DASH(argv[0])) {
opt |= 1;
@@ -64,7 +63,7 @@ int env_main(int argc, char** argv)
if (opt & 1) {
cleanenv[0] = NULL;
environ = cleanenv;
} else if (opt & 2) {
} else {
while (unset_env) {
unsetenv(unset_env->data);
unset_env = unset_env->link;
+209
View File
@@ -0,0 +1,209 @@
/* expand - convert tabs to spaces
* unexpand - convert spaces to tabs
*
* Copyright (C) 89, 91, 1995-2006 Free Software Foundation, Inc.
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*
* David MacKenzie <djm@gnu.ai.mit.edu>
*
* Options for expand:
* -t num --tabs=NUM Convert tabs to num spaces (default 8 spaces).
* -i --initial Only convert initial tabs on each line to spaces.
*
* Options for unexpand:
* -a --all Convert all blanks, instead of just initial blanks.
* -f --first-only Convert only leading sequences of blanks (default).
* -t num --tabs=NUM Have tabs num characters apart instead of 8.
*
* Busybox version (C) 2007 by Tito Ragusa <farmatito@tiscali.it>
*
* Caveat: this versions of expand and unexpand don't accept tab lists.
*/
#include "libbb.h"
enum {
OPT_INITIAL = 1 << 0,
OPT_TABS = 1 << 1,
OPT_ALL = 1 << 2,
};
static void xputchar(char c)
{
if (putchar(c) < 0)
bb_error_msg_and_die(bb_msg_write_error);
}
#if ENABLE_EXPAND
static void expand(FILE *file, unsigned tab_size, unsigned opt)
{
char *line;
char *ptr;
int convert;
int pos;
/* Increment tab_size by 1 locally.*/
tab_size++;
while ((line = xmalloc_fgets(file)) != NULL) {
convert = 1;
pos = 0;
ptr = line;
while (*line) {
pos++;
if (*line == '\t' && convert) {
for (; pos < tab_size; pos++) {
xputchar(' ');
}
} else {
if ((opt & OPT_INITIAL) && !isblank(*line)) {
convert = 0;
}
xputchar(*line);
}
if (pos == tab_size) {
pos = 0;
}
line++;
}
free(ptr);
}
}
#endif
#if ENABLE_UNEXPAND
static void unexpand(FILE *file, unsigned int tab_size, unsigned opt)
{
char *line;
char *ptr;
int convert;
int pos;
int i = 0;
int column = 0;
while ((line = xmalloc_fgets(file)) != NULL) {
convert = 1;
pos = 0;
ptr = line;
while (*line) {
while ((*line == ' ' || *line == '\t') && convert) {
pos += (*line == ' ') ? 1 : tab_size;
line++;
column++;
if ((opt & OPT_ALL) && column == tab_size) {
column = 0;
goto put_tab;
}
}
if (pos) {
i = pos / tab_size;
if (i) {
for (; i > 0; i--) {
put_tab:
xputchar('\t');
}
} else {
for (i = pos % tab_size; i > 0; i--) {
xputchar(' ');
}
}
pos = 0;
} else {
if (opt & OPT_INITIAL) {
convert = 0;
}
if (opt & OPT_ALL) {
column++;
}
xputchar(*line);
line++;
}
}
free(ptr);
}
}
#endif
int expand_main(int argc, char **argv);
int expand_main(int argc, char **argv)
{
/* Default 8 spaces for 1 tab */
const char *opt_t = "8";
FILE *file;
unsigned tab_size;
unsigned opt;
int exit_status = EXIT_SUCCESS;
#if ENABLE_FEATURE_EXPAND_LONG_OPTIONS
static const char expand_longopts[] ALIGN1 =
/* name, has_arg, val */
"initial\0" No_argument "i"
"tabs\0" Required_argument "t"
;
#endif
#if ENABLE_FEATURE_UNEXPAND_LONG_OPTIONS
static const char unexpand_longopts[] ALIGN1 =
/* name, has_arg, val */
"first-only\0" No_argument "i"
"tabs\0" Required_argument "t"
"all\0" No_argument "a"
;
#endif
if (ENABLE_EXPAND && (!ENABLE_UNEXPAND || applet_name[0] == 'e')) {
USE_FEATURE_EXPAND_LONG_OPTIONS(applet_long_options = expand_longopts);
opt = getopt32(argv, "it:", &opt_t);
} else if (ENABLE_UNEXPAND) {
USE_FEATURE_UNEXPAND_LONG_OPTIONS(applet_long_options = unexpand_longopts);
/* -t NUM sets also -a */
opt_complementary = "ta";
opt = getopt32(argv, "ft:a", &opt_t);
/* -f --first-only is the default */
if (!(opt & OPT_ALL)) opt |= OPT_INITIAL;
}
tab_size = xatou_range(opt_t, 1, UINT_MAX);
argv += optind;
/* If no args are given, read from stdin */
if (!*argv) {
*--argv = (char*)bb_msg_standard_input;
goto use_stdin;
}
do {
if (NOT_LONE_CHAR(*argv, '-')) {
file = fopen_or_warn(*argv, "r");
if (!file) {
exit_status = EXIT_FAILURE;
continue;
}
} else {
use_stdin:
file = stdin;
}
if (ENABLE_EXPAND && (!ENABLE_UNEXPAND || applet_name[0] == 'e'))
USE_EXPAND(expand(file, tab_size, opt));
else if (ENABLE_UNEXPAND)
USE_UNEXPAND(unexpand(file, tab_size, opt));
/* Check and close the file */
/* We do want all of them to execute, thus | instead of || */
if (ferror(file) | fclose_if_not_stdin(file)) {
bb_perror_msg("%s", *argv);
exit_status = EXIT_FAILURE;
}
/* If stdin also clear EOF */
if (file == stdin)
clearerr(file);
} while (*++argv);
/* Now close stdin also */
/* (if we didn't read from it, it's a no-op) */
if (fclose(stdin))
bb_perror_msg_and_die(bb_msg_standard_input);
fflush_stdout_and_exit(exit_status);
}
+9 -9
View File
@@ -277,12 +277,14 @@ static VALUE *eval7(void)
static VALUE *eval6(void)
{
VALUE *l, *r, *v = NULL /* silence gcc */, *i1, *i2;
static const char * const keywords[] = {
"quote", "length", "match", "index", "substr", NULL
};
static const char keywords[] ALIGN1 =
"quote\0""length\0""match\0""index\0""substr\0";
VALUE *r, *i1, *i2;
VALUE *l = l; /* silence gcc */
VALUE *v = v; /* silence gcc */
int key = *G.args ? index_in_strings(keywords, *G.args) + 1 : 0;
smalluint key = *G.args ? index_in_str_array(keywords, *G.args) + 1 : 0;
if (key == 0) /* not a keyword */
return eval7();
G.args++; /* We have a valid token, so get the next argument. */
@@ -320,8 +322,8 @@ static VALUE *eval6(void)
i2 = eval6();
tostring(l);
if (!toarith(i1) || !toarith(i2)
|| i1->u.i > (arith_t) strlen(l->u.s)
|| i1->u.i <= 0 || i2->u.i <= 0)
|| i1->u.i > (arith_t) strlen(l->u.s)
|| i1->u.i <= 0 || i2->u.i <= 0)
v = str_value("");
else {
v = xmalloc(sizeof(VALUE));
@@ -503,5 +505,3 @@ int expr_main(int argc, char **argv)
fflush_stdout_and_exit(null(v));
}
+4 -5
View File
@@ -41,6 +41,8 @@ static int adjust_column(int column, char c)
int fold_main(int argc, char **argv);
int fold_main(int argc, char **argv)
{
char *line_out = NULL;
int allocated_out = 0;
char *w_opt;
int width = 80;
int i;
@@ -61,7 +63,7 @@ int fold_main(int argc, char **argv)
}
}
flags = getopt32(argc, argv, "bsw:", &w_opt);
flags = getopt32(argv, "bsw:", &w_opt);
if (flags & FLAG_WIDTH)
width = xatoul_range(w_opt, 1, 10000);
@@ -75,8 +77,6 @@ int fold_main(int argc, char **argv)
int c;
int column = 0; /* Screen column where next char will go. */
int offset_out = 0; /* Index in `line_out' for next char. */
static char *line_out = NULL;
static int allocated_out = 0;
if (istream == NULL) {
errs |= EXIT_FAILURE;
@@ -95,8 +95,7 @@ int fold_main(int argc, char **argv)
column = offset_out = 0;
continue;
}
rescan:
rescan:
column = adjust_column(column, c);
if (column > width) {
+3 -3
View File
@@ -13,7 +13,7 @@
#include "libbb.h"
static const char head_opts[] =
static const char head_opts[] ALIGN1 =
"n:"
#if ENABLE_FEATURE_FANCY_HEAD
"c:qv"
@@ -25,11 +25,11 @@ static const struct suffix_mult head_suffixes[] = {
{ "b", 512 },
{ "k", 1024 },
{ "m", 1024*1024 },
{ NULL, 0 }
{ }
};
#endif
static const char header_fmt_str[] = "\n==> %s <==\n";
static const char header_fmt_str[] ALIGN1 = "\n==> %s <==\n";
int head_main(int argc, char **argv);
int head_main(int argc, char **argv)
+10 -11
View File
@@ -20,13 +20,13 @@
#define JUST_USER 4
#define JUST_GROUP 8
#if ENABLE_SELINUX
#define JUST_CONTEXT 16
#define JUST_CONTEXT 16
#endif
static short printf_full(unsigned int id, const char *arg, const char prefix)
static int printf_full(unsigned int id, const char *arg, const char prefix)
{
const char *fmt = "%cid=%u";
short status = EXIT_FAILURE;
int status = EXIT_FAILURE;
if (arg) {
fmt = "%cid=%u(%s)";
@@ -49,8 +49,8 @@ int id_main(int argc, char **argv)
#endif
/* Don't allow -n -r -nr -ug -rug -nug -rnug */
/* Don't allow more than one username */
opt_complementary = "?1:?:u--g:g--u:r?ug:n?ug" USE_SELINUX(":u--Z:Z--u:g--Z:Z--g");
flags = getopt32(argc, argv, "rnug" USE_SELINUX("Z"));
opt_complementary = "?1:u--g:g--u:r?ug:n?ug" USE_SELINUX(":u--Z:Z--u:g--Z:Z--g");
flags = getopt32(argv, "rnug" USE_SELINUX("Z"));
/* This values could be overwritten later */
uid = geteuid();
@@ -71,8 +71,8 @@ int id_main(int argc, char **argv)
if (flags & (JUST_GROUP | JUST_USER USE_SELINUX(| JUST_CONTEXT))) {
/* JUST_GROUP and JUST_USER are mutually exclusive */
if (flags & NAME_NOT_NUMBER) {
/* bb_getpwuid and bb_getgrgid exit on failure so puts cannot segfault */
puts((flags & JUST_USER) ? bb_getpwuid(NULL, uid, -1 ) : bb_getgrgid(NULL, gid, -1 ));
/* bb_getXXXid(-1) exit on failure, puts cannot segfault */
puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid));
} else {
if (flags & JUST_USER) {
printf("%u\n", uid);
@@ -100,11 +100,10 @@ int id_main(int argc, char **argv)
}
/* Print full info like GNU id */
/* bb_getpwuid doesn't exit on failure here */
status = printf_full(uid, bb_getpwuid(NULL, uid, 0), 'u');
/* bb_getpwuid(0) doesn't exit on failure (returns NULL) */
status = printf_full(uid, bb_getpwuid(NULL, 0, uid), 'u');
putchar(' ');
/* bb_getgrgid doesn't exit on failure here */
status |= printf_full(gid, bb_getgrgid(NULL, gid, 0), 'g');
status |= printf_full(gid, bb_getgrgid(NULL, 0, gid), 'g');
#if ENABLE_SELINUX
if (is_selinux_enabled()) {
+88 -67
View File
@@ -1,6 +1,6 @@
/* vi: set sw=4 ts=4: */
/*
* Copyright (C) 2003 by Glenn McGrath <bug1@iinet.net.au>
* Copyright (C) 2003 by Glenn McGrath
* SELinux support: by Yuichi Nakamura <ynakam@hitachisoft.jp>
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
@@ -16,26 +16,25 @@
#include "libcoreutils/coreutils.h"
#if ENABLE_FEATURE_INSTALL_LONG_OPTIONS
static const struct option install_long_options[] = {
{ "directory", 0, NULL, 'd' },
{ "preserve-timestamps", 0, NULL, 'p' },
{ "strip", 0, NULL, 's' },
{ "group", 0, NULL, 'g' },
{ "mode", 0, NULL, 'm' },
{ "owner", 0, NULL, 'o' },
static const char install_longopts[] ALIGN1 =
"directory\0" No_argument "d"
"preserve-timestamps\0" No_argument "p"
"strip\0" No_argument "s"
"group\0" No_argument "g"
"mode\0" No_argument "m"
"owner\0" No_argument "o"
/* autofs build insists of using -b --suffix=.orig */
/* TODO? (short option for --suffix is -S) */
#if ENABLE_SELINUX
{ "context", 1, NULL, 'Z' },
{ "preserve_context", 0, NULL, 0xff },
{ "preserve-context", 0, NULL, 0xff },
"context\0" Required_argument "Z"
"preserve_context\0" No_argument "\xff"
"preserve-context\0" No_argument "\xff"
#endif
{ 0, 0, 0, 0 }
};
;
#endif
#if ENABLE_SELINUX
static bool use_default_selinux_context = 1;
static void setdefaultfilecon(const char *path)
{
struct stat s;
@@ -74,47 +73,57 @@ int install_main(int argc, char **argv)
mode_t mode;
uid_t uid;
gid_t gid;
char *arg, *last;
const char *gid_str;
const char *uid_str;
const char *mode_str;
int copy_flags = FILEUTILS_DEREFERENCE | FILEUTILS_FORCE;
int ret = EXIT_SUCCESS, flags, i, isdir;
int flags;
int ret = EXIT_SUCCESS;
int isdir;
#if ENABLE_SELINUX
security_context_t scontext;
bool use_default_selinux_context = 1;
#endif
enum {
OPT_CMD = 0x1,
OPT_DIRECTORY = 0x2,
OPT_PRESERVE_TIME = 0x4,
OPT_STRIP = 0x8,
OPT_GROUP = 0x10,
OPT_MODE = 0x20,
OPT_OWNER = 0x40,
OPT_c = 1 << 0,
OPT_v = 1 << 1,
OPT_b = 1 << 2,
OPT_DIRECTORY = 1 << 3,
OPT_PRESERVE_TIME = 1 << 4,
OPT_STRIP = 1 << 5,
OPT_GROUP = 1 << 6,
OPT_MODE = 1 << 7,
OPT_OWNER = 1 << 8,
#if ENABLE_SELINUX
OPT_SET_SECURITY_CONTEXT = 0x80,
OPT_PRESERVE_SECURITY_CONTEXT = 0x100,
OPT_SET_SECURITY_CONTEXT = 1 << 9,
OPT_PRESERVE_SECURITY_CONTEXT = 1 << 10,
#endif
};
#if ENABLE_FEATURE_INSTALL_LONG_OPTIONS
applet_long_options = install_long_options;
applet_long_options = install_longopts;
#endif
opt_complementary = "?:s--d:d--s" USE_SELINUX(":Z--\xff:\xff--Z");
opt_complementary = "s--d:d--s" USE_SELINUX(":Z--\xff:\xff--Z");
/* -c exists for backwards compatibility, it's needed */
flags = getopt32(argc, argv, "cdpsg:m:o:" USE_SELINUX("Z:"), &gid_str, &mode_str, &uid_str USE_SELINUX(, &scontext));
/* -v is ignored ("print name of each created directory") */
/* -b is ignored ("make a backup of each existing destination file") */
flags = getopt32(argv, "cvb" "dpsg:m:o:" USE_SELINUX("Z:"),
&gid_str, &mode_str, &uid_str USE_SELINUX(, &scontext));
argc -= optind;
argv += optind;
#if ENABLE_SELINUX
if (flags & OPT_PRESERVE_SECURITY_CONTEXT) {
use_default_selinux_context = 0;
copy_flags |= FILEUTILS_PRESERVE_SECURITY_CONTEXT;
if (flags & (OPT_PRESERVE_SECURITY_CONTEXT|OPT_SET_SECURITY_CONTEXT)) {
selinux_or_die();
}
if (flags & OPT_SET_SECURITY_CONTEXT) {
selinux_or_die();
setfscreatecon_or_die(scontext);
use_default_selinux_context = 0;
copy_flags |= FILEUTILS_SET_SECURITY_CONTEXT;
if (flags & OPT_PRESERVE_SECURITY_CONTEXT) {
copy_flags |= FILEUTILS_PRESERVE_SECURITY_CONTEXT;
}
if (flags & OPT_SET_SECURITY_CONTEXT) {
setfscreatecon_or_die(scontext);
copy_flags |= FILEUTILS_SET_SECURITY_CONTEXT;
}
}
#endif
@@ -123,57 +132,63 @@ int install_main(int argc, char **argv)
copy_flags |= FILEUTILS_PRESERVE_STATUS;
}
mode = 0666;
if (flags & OPT_MODE) bb_parse_mode(mode_str, &mode);
if (flags & OPT_MODE)
bb_parse_mode(mode_str, &mode);
uid = (flags & OPT_OWNER) ? get_ug_id(uid_str, xuname2uid) : getuid();
gid = (flags & OPT_GROUP) ? get_ug_id(gid_str, xgroup2gid) : getgid();
if (flags & (OPT_OWNER|OPT_GROUP)) umask(0);
if (flags & (OPT_OWNER|OPT_GROUP))
umask(0);
/* Create directories
* don't use bb_make_directory() as it can't change uid or gid
* perhaps bb_make_directory() should be improved.
*/
if (flags & OPT_DIRECTORY) {
for (argv += optind; *argv; argv++) {
char *old_argv_ptr = *argv + 1;
char *argv_ptr;
do {
argv_ptr = strchr(old_argv_ptr, '/');
old_argv_ptr = argv_ptr;
if (argv_ptr) {
*argv_ptr = '\0';
old_argv_ptr++;
}
if (mkdir(*argv, mode | 0111) == -1) {
while ((arg = *argv++) != NULL) {
char *slash = arg;
while (1) {
slash = strchr(slash + 1, '/');
if (slash)
*slash = '\0';
if (mkdir(arg, mode | 0111) == -1) {
if (errno != EEXIST) {
bb_perror_msg("cannot create %s", *argv);
bb_perror_msg("cannot create %s", arg);
ret = EXIT_FAILURE;
break;
}
}
if ((flags & (OPT_OWNER|OPT_GROUP))
&& lchown(*argv, uid, gid) == -1
} /* dir was created, chown? */
else if ((flags & (OPT_OWNER|OPT_GROUP))
&& lchown(arg, uid, gid) == -1
) {
bb_perror_msg("cannot change ownership of %s", *argv);
bb_perror_msg("cannot change ownership of %s", arg);
ret = EXIT_FAILURE;
break;
}
if (argv_ptr) {
*argv_ptr = '/';
}
} while (old_argv_ptr);
if (!slash)
break;
*slash = '/';
}
}
return ret;
}
isdir = lstat(argv[argc - 1], &statbuf) < 0 ? 0 : S_ISDIR(statbuf.st_mode);
if (argc < 2)
bb_show_usage();
for (i = optind; i < argc - 1; i++) {
char *dest;
last = argv[argc - 1];
argv[argc - 1] = NULL;
/* coreutils install resolves link in this case, don't use lstat */
isdir = stat(last, &statbuf) < 0 ? 0 : S_ISDIR(statbuf.st_mode);
dest = argv[argc - 1];
while ((arg = *argv++) != NULL) {
char *dest = last;
if (isdir)
dest = concat_path_file(argv[argc - 1], basename(argv[i]));
ret |= copy_file(argv[i], dest, copy_flags);
dest = concat_path_file(last, basename(arg));
if (copy_file(arg, dest, copy_flags)) {
/* copy is not made */
ret = EXIT_FAILURE;
goto next;
}
/* Set the file mode */
if ((flags & OPT_MODE) && chmod(dest, mode) == -1) {
@@ -192,12 +207,18 @@ int install_main(int argc, char **argv)
ret = EXIT_FAILURE;
}
if (flags & OPT_STRIP) {
if (BB_EXECLP("strip", "strip", dest, NULL) == -1) {
char *args[3];
args[0] = (char*)"strip";
args[1] = dest;
args[2] = NULL;
if (spawn_and_wait(args)) {
bb_perror_msg("strip");
ret = EXIT_FAILURE;
}
}
if (ENABLE_FEATURE_CLEAN_UP && isdir) free(dest);
next:
if (ENABLE_FEATURE_CLEAN_UP && isdir)
free(dest);
}
return ret;
+3 -3
View File
@@ -8,9 +8,9 @@
typedef int (*stat_func)(const char *fn, struct stat *ps);
extern int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf);
extern int cp_mv_stat(const char *fn, struct stat *fn_stat);
int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf);
int cp_mv_stat(const char *fn, struct stat *fn_stat);
extern mode_t getopt_mk_fifo_nod(int argc, char **argv);
mode_t getopt_mk_fifo_nod(int argc, char **argv);
#endif
+2 -2
View File
@@ -21,7 +21,7 @@
*/
#include "libbb.h"
//#include "coreutils.h"
#include "coreutils.h"
mode_t getopt_mk_fifo_nod(int argc, char **argv)
{
@@ -31,7 +31,7 @@ mode_t getopt_mk_fifo_nod(int argc, char **argv)
security_context_t scontext;
#endif
int opt;
opt = getopt32(argc, argv, "m:" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
opt = getopt32(argv, "m:" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
if (opt & 1) {
if (bb_parse_mode(smode, &mode))
umask(0);
+3 -2
View File
@@ -34,7 +34,7 @@ int ln_main(int argc, char **argv)
struct stat statbuf;
int (*link_func)(const char *, const char *);
flag = getopt32(argc, argv, "sfnbS:", &suffix);
flag = getopt32(argv, "sfnbS:", &suffix);
if (argc == optind) {
bb_show_usage();
@@ -54,7 +54,8 @@ int ln_main(int argc, char **argv)
if (is_directory(src,
(flag & LN_NODEREFERENCE) ^ LN_NODEREFERENCE,
NULL)) {
NULL)
) {
src_name = xstrdup(*argv);
src = concat_path_file(src, bb_get_last_path_component(src_name));
free(src_name);
+16 -16
View File
@@ -117,13 +117,12 @@ SPLIT_SUBDIR = 2,
/* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
#if ENABLE_FEATURE_LS_COLOR
static int show_color;
static smallint show_color;
/* long option entry used only for --color, which has no short option
* equivalent */
static const struct option ls_color_opt[] = {
{ "color", optional_argument, NULL, 1 },
{ NULL, 0, NULL, 0 }
};
static const char ls_color_opt[] ALIGN1 =
"color\0" Optional_argument "\xff" /* no short equivalent */
;
#else
enum { show_color = 0 };
#endif
@@ -132,8 +131,8 @@ enum { show_color = 0 };
* a directory entry and its stat info are stored here
*/
struct dnode { /* the basic node */
char *name; /* the dir entry name */
char *fullname; /* the dir entry name */
const char *name; /* the dir entry name */
const char *fullname; /* the dir entry name */
int allocated;
struct stat dstat; /* the file stat info */
USE_SELINUX(security_context_t sid;)
@@ -159,7 +158,7 @@ enum {
static int status = EXIT_SUCCESS;
static struct dnode *my_stat(char *fullname, char *name, int force_follow)
static struct dnode *my_stat(const char *fullname, const char *name, int force_follow)
{
struct stat dstat;
struct dnode *cur;
@@ -241,7 +240,7 @@ static int count_dirs(struct dnode **dn, int nfiles, int notsubdirs)
return 0;
dirs = 0;
for (i = 0; i < nfiles; i++) {
char *name;
const char *name;
if (!S_ISDIR(dn[i]->dstat.st_mode))
continue;
name = dn[i]->name;
@@ -288,7 +287,7 @@ static void dfree(struct dnode **dnp, int nfiles)
for (i = 0; i < nfiles; i++) {
struct dnode *cur = dnp[i];
if (cur->allocated)
free(cur->fullname); /* free the filename */
free((char*)cur->fullname); /* free the filename */
free(cur); /* free the dnode */
}
free(dnp); /* free the array holding the dnode pointers */
@@ -320,7 +319,7 @@ static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
/* copy the entrys into the file or dir array */
for (d = i = 0; i < nfiles; i++) {
if (S_ISDIR(dn[i]->dstat.st_mode)) {
char *name;
const char *name;
if (!(which & (SPLIT_DIR|SPLIT_SUBDIR)))
continue;
name = dn[i]->name;
@@ -513,7 +512,7 @@ static struct dnode **list_dir(const char *path)
continue;
}
fullname = concat_path_file(path, entry->d_name);
cur = my_stat(fullname, strrchr(fullname, '/') + 1, 0);
cur = my_stat(fullname, bb_basename(fullname), 0);
if (!cur) {
free(fullname);
continue;
@@ -711,7 +710,8 @@ static int list_single(struct dnode *dn)
/* "[-]SXvThw", GNU options, busybox optionally supports */
/* "[-]K", SELinux mandated options, busybox optionally supports */
/* "[-]e", I think we made this one up */
static const char ls_options[] = "Cadil1gnsxAk"
static const char ls_options[] ALIGN1 =
"Cadil1gnsxAk"
USE_FEATURE_LS_TIMESTAMPS("cetu")
USE_FEATURE_LS_SORTFILES("SXrv")
USE_FEATURE_LS_FILETYPES("Fp")
@@ -812,7 +812,7 @@ int ls_main(int argc, char **argv)
#if ENABLE_FEATURE_AUTOWIDTH
/* Obtain the terminal width */
get_terminal_width_height(STDOUT_FILENO, &terminal_width, NULL);
get_terminal_width_height(STDIN_FILENO, &terminal_width, NULL);
/* Go one less... */
terminal_width--;
#endif
@@ -820,14 +820,14 @@ int ls_main(int argc, char **argv)
/* process options */
USE_FEATURE_LS_COLOR(applet_long_options = ls_color_opt;)
#if ENABLE_FEATURE_AUTOWIDTH
opt = getopt32(argc, argv, ls_options, &tabstops_str, &terminal_width_str
opt = getopt32(argv, ls_options, &tabstops_str, &terminal_width_str
USE_FEATURE_LS_COLOR(, &color_opt));
if (tabstops_str)
tabstops = xatou(tabstops_str);
if (terminal_width_str)
terminal_width = xatou(terminal_width_str);
#else
opt = getopt32(argc, argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt));
opt = getopt32(argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt));
#endif
for (i = 0; opt_flags[i] != (1U<<31); i++) {
if (opt & (1 << i)) {
+2 -2
View File
@@ -84,11 +84,11 @@ int md5_sha1_sum_main(int argc, char **argv)
uint8_t *hash_value;
unsigned flags;
hash_algo_t hash_algo = ENABLE_MD5SUM
? (ENABLE_SHA1SUM ? (**argv=='m' ? HASH_MD5 : HASH_SHA1) : HASH_MD5)
? (ENABLE_SHA1SUM ? (applet_name[0] == 'm' ? HASH_MD5 : HASH_SHA1) : HASH_MD5)
: HASH_SHA1;
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
flags = getopt32(argc, argv, "scw");
flags = getopt32(argv, "scw");
else optind = 1;
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && !(flags & FLAG_CHECK)) {
+7 -8
View File
@@ -25,14 +25,13 @@
/* This is a NOFORK applet. Be very careful! */
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
static const struct option mkdir_long_options[] = {
{ "mode" , 1, NULL, 'm' },
{ "parents", 0, NULL, 'p' },
static const char mkdir_longopts[] ALIGN1 =
"mode\0" Required_argument "m"
"parents\0" No_argument "p"
#if ENABLE_SELINUX
{ "context", 1, NULL, 'Z' },
"context\0" Required_argument "Z"
#endif
{ NULL, 0, NULL, 0 }
};
;
#endif
int mkdir_main(int argc, char **argv);
@@ -48,9 +47,9 @@ int mkdir_main(int argc, char **argv)
#endif
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
applet_long_options = mkdir_long_options;
applet_long_options = mkdir_longopts;
#endif
opt = getopt32(argc, argv, "m:p" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
opt = getopt32(argv, "m:p" USE_SELINUX("Z:"), &smode USE_SELINUX(,&scontext));
if (opt & 1) {
mode = 0777;
if (!bb_parse_mode(smode, &mode)) {
+1 -1
View File
@@ -14,7 +14,7 @@
#include "libbb.h"
#include "libcoreutils/coreutils.h"
static const char modes_chars[] = { 'p', 'c', 'u', 'b', 0, 1, 1, 2 };
static const char modes_chars[] ALIGN1 = { 'p', 'c', 'u', 'b', 0, 1, 1, 2 };
static const mode_t modes_cubp[] = { S_IFIFO, S_IFCHR, S_IFBLK };
int mknod_main(int argc, char **argv);
+8 -8
View File
@@ -21,17 +21,17 @@
#include "libcoreutils/coreutils.h"
#if ENABLE_FEATURE_MV_LONG_OPTIONS
static const struct option mv_long_options[] = {
{ "interactive", 0, NULL, 'i' },
{ "force", 0, NULL, 'f' },
{ 0, 0, 0, 0 }
};
static const char mv_longopts[] ALIGN1 =
"interactive\0" No_argument "i"
"force\0" No_argument "f"
;
#endif
#define OPT_FILEUTILS_FORCE 1
#define OPT_FILEUTILS_INTERACTIVE 2
static const char fmt[] = "cannot overwrite %sdirectory with %sdirectory";
static const char fmt[] ALIGN1 =
"cannot overwrite %sdirectory with %sdirectory";
int mv_main(int argc, char **argv);
int mv_main(int argc, char **argv)
@@ -45,10 +45,10 @@ int mv_main(int argc, char **argv)
int copy_flag = 0;
#if ENABLE_FEATURE_MV_LONG_OPTIONS
applet_long_options = mv_long_options;
applet_long_options = mv_longopts;
#endif
opt_complementary = "f-i:i-f";
flags = getopt32(argc, argv, "fi");
flags = getopt32(argv, "fi");
if (optind + 2 > argc) {
bb_show_usage();
}
+3 -3
View File
@@ -131,7 +131,7 @@ odoffset(int argc, char ***argvp)
}
}
static const char * const add_strings[] = {
static const char *const add_strings[] = {
"16/1 \"%3_u \" \"\\n\"", /* a */
"8/2 \" %06o \" \"\\n\"", /* B, o */
"16/1 \"%03o \" \"\\n\"", /* b */
@@ -147,9 +147,9 @@ static const char * const add_strings[] = {
"4/4 \" %011o \" \"\\n\"", /* O */
};
static const char od_opts[] = "aBbcDdeFfHhIiLlOoXxv";
static const char od_opts[] ALIGN1 = "aBbcDdeFfHhIiLlOoXxv";
static const char od_o2si[] = {
static const char od_o2si[] ALIGN1 = {
0, 1, 2, 3, 5,
4, 6, 6, 7, 8,
9, 0xa, 0xb, 0xa, 0xa,
+59 -70
View File
@@ -129,20 +129,20 @@ struct tspec {
10 unsigned decimal
8 unsigned hexadecimal */
static const uint8_t bytes_to_oct_digits[] =
static const uint8_t bytes_to_oct_digits[] ALIGN1 =
{0, 3, 6, 8, 11, 14, 16, 19, 22, 25, 27, 30, 32, 35, 38, 41, 43};
static const uint8_t bytes_to_signed_dec_digits[] =
static const uint8_t bytes_to_signed_dec_digits[] ALIGN1 =
{1, 4, 6, 8, 11, 13, 16, 18, 20, 23, 25, 28, 30, 33, 35, 37, 40};
static const uint8_t bytes_to_unsigned_dec_digits[] =
static const uint8_t bytes_to_unsigned_dec_digits[] ALIGN1 =
{0, 3, 5, 8, 10, 13, 15, 17, 20, 22, 25, 27, 29, 32, 34, 37, 39};
static const uint8_t bytes_to_hex_digits[] =
static const uint8_t bytes_to_hex_digits[] ALIGN1 =
{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32};
/* Convert enum size_spec to the size of the named type. */
static const signed char width_bytes[] = {
static const signed char width_bytes[] ALIGN1 = {
-1,
sizeof(char),
sizeof(short),
@@ -153,50 +153,43 @@ static const signed char width_bytes[] = {
sizeof(double),
sizeof(longdouble_t)
};
/* Ensure that for each member of 'enum size_spec' there is an
initializer in the width_bytes array. */
struct dummy {
int assert_width_bytes_matches_size_spec_decl
[sizeof width_bytes / sizeof width_bytes[0] == N_SIZE_SPECS ? 1 : -1];
struct ERR_width_bytes_has_bad_size {
char ERR_width_bytes_has_bad_size[ARRAY_SIZE(width_bytes) == N_SIZE_SPECS ? 1 : -1];
};
static size_t string_min;
static int flag_dump_strings;
static smallint flag_dump_strings;
/* Non-zero if an old-style 'pseudo-address' was specified. */
static int flag_pseudo_start;
/* The difference between the old-style pseudo starting address and
the number of bytes to skip. */
static off_t pseudo_offset;
/* Function that accepts an address and an optional following char,
and prints the address and char to stdout. */
static void (*format_address) (off_t, char);
/* The number of input bytes to skip before formatting and writing. */
static off_t n_bytes_to_skip; // = 0;
/* When zero, MAX_BYTES_TO_FORMAT and END_OFFSET are ignored, and all
input is formatted. */
static int limit_bytes_to_format; // = 0;
/* The maximum number of bytes that will be formatted. */
static off_t max_bytes_to_format;
/* The offset of the first byte after the last byte to be formatted. */
static off_t end_offset;
/* When nonzero and two or more consecutive blocks are equal, format
static smallint flag_pseudo_start;
static smallint limit_bytes_to_format;
/* When zero and two or more consecutive blocks are equal, format
only the first block and output an asterisk alone on the following
line to indicate that identical blocks have been elided. */
static int abbreviate_duplicate_blocks = 1;
static smallint verbose;
static smallint ioerror;
static size_t string_min;
/* An array of specs describing how to format each input block. */
static size_t n_specs;
static struct tspec *spec;
/* Function that accepts an address and an optional following char,
and prints the address and char to stdout. */
static void (*format_address)(off_t, char);
/* The difference between the old-style pseudo starting address and
the number of bytes to skip. */
static off_t pseudo_offset;
/* The number of input bytes to skip before formatting and writing. */
static off_t n_bytes_to_skip;
/* When zero, MAX_BYTES_TO_FORMAT and END_OFFSET are ignored, and all
input is formatted. */
/* The maximum number of bytes that will be formatted. */
static off_t max_bytes_to_format;
/* The offset of the first byte after the last byte to be formatted. */
static off_t end_offset;
/* The number of input bytes formatted per output line. It must be
a multiple of the least common multiple of the sizes associated with
the specified output types. It should be as large as possible, but
@@ -217,10 +210,8 @@ static char const *const default_file_list[] = { "-", NULL };
/* The input stream associated with the current file. */
static FILE *in_stream;
static int ioerror;
#define MAX_INTEGRAL_TYPE_SIZE sizeof(ulonglong_t)
static unsigned char integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1] = {
static unsigned char integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1] ALIGN1 = {
[sizeof(char)] = CHAR,
#if USHRT_MAX != UCHAR_MAX
[sizeof(short)] = SHORT,
@@ -237,11 +228,11 @@ static unsigned char integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1] = {
};
#define MAX_FP_TYPE_SIZE sizeof(longdouble_t)
static unsigned char fp_type_size[MAX_FP_TYPE_SIZE + 1] = {
static unsigned char fp_type_size[MAX_FP_TYPE_SIZE + 1] ALIGN1 = {
/* gcc seems to allow repeated indexes. Last one stays */
[sizeof(longdouble_t)] = FLOAT_LONG_DOUBLE,
[sizeof(double)] = FLOAT_DOUBLE,
[sizeof(float)] = FLOAT_SINGLE,
[sizeof(float)] = FLOAT_SINGLE
};
@@ -391,7 +382,7 @@ print_named_ascii(size_t n_bytes, const char *block,
const char *unused_fmt_string ATTRIBUTE_UNUSED)
{
/* Names for some non-printing characters. */
static const char charname[33][3] = {
static const char charname[33][3] ALIGN1 = {
"nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
" bs", " ht", " nl", " vt", " ff", " cr", " so", " si",
"dle", "dc1", "dc2", "dc3", "dc4", "nak", "syn", "etb",
@@ -568,7 +559,7 @@ decode_one_format(const char *s_orig, const char *s, const char **next,
case 'o':
case 'u':
case 'x': {
static const char CSIL[] = "CSIL";
static const char CSIL[] ALIGN1 = "CSIL";
c = *s++;
p = strchr(CSIL, *s);
@@ -604,7 +595,7 @@ decode_one_format(const char *s_orig, const char *s, const char **next,
size_spec = integral_type_size[size];
{
static const char doux[] = "doux";
static const char doux[] ALIGN1 = "doux";
static const char doux_fmt_letter[][4] = {
"lld", "llo", "llu", "llx"
};
@@ -661,7 +652,7 @@ decode_one_format(const char *s_orig, const char *s, const char **next,
}
case 'f': {
static const char FDL[] = "FDL";
static const char FDL[] ALIGN1 = "FDL";
fmt = FLOATING_POINT;
++s;
@@ -844,7 +835,7 @@ format_address_none(off_t address ATTRIBUTE_UNUSED, char c ATTRIBUTE_UNUSED)
{
}
static char address_fmt[] = "%0n"OFF_FMT"xc";
static char address_fmt[] ALIGN1 = "%0n"OFF_FMT"xc";
/* Corresponds to 'x' above */
#define address_base_char address_fmt[sizeof(address_fmt)-3]
/* Corresponds to 'n' above */
@@ -907,8 +898,7 @@ write_block(off_t current_offset, size_t n_bytes,
static char prev_pair_equal = 0;
size_t i;
if (abbreviate_duplicate_blocks
&& !first
if (!verbose && !first
&& n_bytes == bytes_per_block
&& memcmp(prev_block, curr_block, bytes_per_block) == 0
) {
@@ -990,7 +980,7 @@ parse_old_offset(const char *s, off_t *offset)
static const struct suffix_mult Bb[] = {
{ "B", 1024 },
{ "b", 512 },
{ NULL, 0 }
{ }
};
char *p;
int radix;
@@ -1213,7 +1203,7 @@ int od_main(int argc, char **argv)
{ "b", 512 },
{ "k", 1024 },
{ "m", 1024*1024 },
{ NULL, 0 }
{ }
};
unsigned opt;
int l_c_m;
@@ -1242,17 +1232,16 @@ int od_main(int argc, char **argv)
OPT_traditional = (1 << 18) * ENABLE_GETOPT_LONG,
};
#if ENABLE_GETOPT_LONG
static const struct option long_options[] = {
{ "skip-bytes", required_argument, NULL, 'j' },
{ "address-radix", required_argument, NULL, 'A' },
{ "read-bytes", required_argument, NULL, 'N' },
{ "format", required_argument, NULL, 't' },
{ "output-duplicates", no_argument, NULL, 'v' },
{ "strings", optional_argument, NULL, 'S' },
{ "width", optional_argument, NULL, 'w' },
{ "traditional", no_argument, NULL, 0xff },
{ NULL, 0, NULL, 0 }
};
static const char od_longopts[] ALIGN1 =
"skip-bytes\0" Required_argument "j"
"address-radix\0" Required_argument "A"
"read-bytes\0" Required_argument "N"
"format\0" Required_argument "t"
"output-duplicates\0" No_argument "v"
"strings\0" Optional_argument "S"
"width\0" Optional_argument "w"
"traditional\0" No_argument "\xff"
;
#endif
char *str_A, *str_N, *str_j, *str_S;
char *str_w = NULL;
@@ -1262,14 +1251,14 @@ int od_main(int argc, char **argv)
format_address = format_address_std;
address_base_char = 'o';
address_pad_len_char = '7';
flag_dump_strings = 0;
/* flag_dump_strings = 0; - already is */
/* Parse command line */
opt_complementary = "t::"; // list
#if ENABLE_GETOPT_LONG
applet_long_options = long_options;
applet_long_options = od_longopts;
#endif
opt = getopt32(argc, argv, "A:N:abcdfhij:lot:vxsS:"
opt = getopt32(argv, "A:N:abcdfhij:lot:vxsS:"
"w::", // -w with optional param
// -S was -s and also had optional parameter
// but in coreutils 6.3 it was renamed and now has
@@ -1278,11 +1267,11 @@ int od_main(int argc, char **argv)
argc -= optind;
argv += optind;
if (opt & OPT_A) {
static const char doxn[] = "doxn";
static const char doxn_address_base_char[] = {
static const char doxn[] ALIGN1 = "doxn";
static const char doxn_address_base_char[] ALIGN1 = {
'u', 'o', 'x', /* '?' fourth one is not important */
};
static const uint8_t doxn_address_pad_len_char[] = {
static const uint8_t doxn_address_pad_len_char[] ALIGN1 = {
'7', '7', '6', /* '?' */
};
char *p;
@@ -1315,7 +1304,7 @@ int od_main(int argc, char **argv)
decode_format_string(lst_t->data);
lst_t = lst_t->link;
}
if (opt & OPT_v) abbreviate_duplicate_blocks = 0;
if (opt & OPT_v) verbose = 1;
if (opt & OPT_x) decode_format_string("x2");
if (opt & OPT_s) decode_format_string("d2");
if (opt & OPT_S) {
@@ -1459,5 +1448,5 @@ int od_main(int argc, char **argv)
if (fclose(stdin) == EOF)
bb_perror_msg_and_die(bb_msg_standard_input);
return (ioerror != 0); /* err != 0 - return 1 (failure) */
return ioerror;
}
+9 -14
View File
@@ -14,25 +14,20 @@ extern char **environ;
int printenv_main(int argc, char **argv);
int printenv_main(int argc, char **argv)
{
int e = 0;
/* no variables specified, show whole env */
if (argc == 1)
if (argc == 1) {
int e = 0;
while (environ[e])
puts(environ[e++]);
/* search for specified variables and print them out if found */
else {
int i;
size_t l;
} else {
/* search for specified variables and print them out if found */
char *arg, *env;
for (i=1; (arg = argv[i]); ++i)
for (; (env = environ[e]); ++e) {
l = strlen(arg);
if (!strncmp(env, arg, l) && env[l] == '=')
puts(env + l + 1);
}
while ((arg = *++argv) != NULL) {
env = getenv(arg);
if (env)
puts(env);
}
}
fflush_stdout_and_exit(0);
@@ -21,7 +21,7 @@ int readlink_main(int argc, char **argv)
unsigned opt;
/* We need exactly one non-option argument. */
opt_complementary = "=1";
opt = getopt32(argc, argv, "f");
opt = getopt32(argv, "f");
fname = argv[optind];
)
SKIP_FEATURE_READLINK_FOLLOW(
@@ -43,7 +43,7 @@ int readlink_main(int argc, char **argv)
return EXIT_FAILURE;
puts(buf);
if (ENABLE_FEATURE_CLEAN_UP && buf != bb_common_bufsiz1)
if (ENABLE_FEATURE_CLEAN_UP && !opt)
free(buf);
fflush_stdout_and_exit(EXIT_SUCCESS);
+1 -1
View File
@@ -27,7 +27,7 @@ int rm_main(int argc, char **argv)
unsigned opt;
opt_complementary = "f-i:i-f";
opt = getopt32(argc, argv, "fiRr");
opt = getopt32(argv, "fiRr");
argv += optind;
if (opt & 1)
flags |= FILEUTILS_FORCE;
+1 -1
View File
@@ -24,7 +24,7 @@ int rmdir_main(int argc, char **argv)
int do_dot;
char *path;
flags = getopt32(argc, argv, "p");
flags = getopt32(argv, "p");
argv += optind;
if (!*argv) {
+1 -1
View File
@@ -29,7 +29,7 @@ static const struct suffix_mult sfx[] = {
{ "m", 60 },
{ "h", 60*60 },
{ "d", 24*60*60 },
{ NULL, 0 }
{ }
};
#endif
+3 -3
View File
@@ -23,7 +23,7 @@
*/
/* These are sort types */
static const char OPT_STR[] = "ngMucszbrdfimS:T:o:k:t:";
static const char OPT_STR[] ALIGN1 = "ngMucszbrdfimS:T:o:k:t:";
enum {
FLAG_n = 1, /* Numeric sort */
FLAG_g = 2, /* Sort using strtod() */
@@ -288,9 +288,9 @@ int sort_main(int argc, char **argv)
/* Parse command line options */
/* -o and -t can be given at most once */
opt_complementary = "?:o--o:t--t:" /* -t, -o: maximum one of each */
opt_complementary = "o--o:t--t:" /* -t, -o: maximum one of each */
"k::"; /* -k takes list */
getopt32(argc, argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &lst_k, &str_t);
getopt32(argv, OPT_STR, &str_ignored, &str_ignored, &str_o, &lst_k, &str_t);
#if ENABLE_FEATURE_SORT_BIG
if (option_mask32 & FLAG_o) outfile = xfopen(str_o, "w");
if (option_mask32 & FLAG_t) {
+3 -3
View File
@@ -20,7 +20,7 @@ static const struct suffix_mult split_suffices[] = {
#if ENABLE_FEATURE_SPLIT_FANCY
{ "g", 1024*1024*1024 },
#endif
{ NULL, 0 }
{ }
};
/* Increment the suffix part of the filename.
@@ -49,7 +49,7 @@ static char *next_file(char *old, unsigned suffix_len)
}
#define read_buffer bb_common_bufsiz1
enum { READ_BUFFER_SIZE = sizeof(bb_common_bufsiz1) - 1 };
enum { READ_BUFFER_SIZE = COMMON_BUFSIZE - 1 };
#define SPLIT_OPT_l (1<<0)
#define SPLIT_OPT_b (1<<1)
@@ -69,7 +69,7 @@ int split_main(int argc, char **argv)
char *src;
opt_complementary = "?2";
opt = getopt32(argc, argv, "l:b:a:", &count_p, &count_p, &sfx);
opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &sfx);
if (opt & SPLIT_OPT_l)
cnt = xatoul(count_p);
+16 -10
View File
@@ -21,7 +21,7 @@
#define OPT_DEREFERENCE (1<<2)
#define OPT_SELINUX (1<<3)
static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")];
static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;
static char const * file_type(struct stat const *st)
{
@@ -70,7 +70,7 @@ static char const *human_fstype(long f_type)
int i;
static const struct types {
long type;
const char * const fs;
const char *const fs;
} humantypes[] = {
{ 0xADFF, "affs" },
{ 0x1Cd1, "devpts" },
@@ -118,7 +118,7 @@ static char const *human_fstype(long f_type)
#if ENABLE_FEATURE_STAT_FORMAT
/* print statfs info */
static void print_statfs(char *pformat, const size_t buf_len, const char m,
const char * const filename, void const *data
const char *const filename, void const *data
USE_SELINUX(, security_context_t scontext))
{
struct statfs const *statfsbuf = data;
@@ -168,7 +168,7 @@ static void print_statfs(char *pformat, const size_t buf_len, const char m,
/* print stat info */
static void print_stat(char *pformat, const size_t buf_len, const char m,
const char * const filename, void const *data
const char *const filename, void const *data
USE_SELINUX(, security_context_t scontext))
{
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
@@ -342,8 +342,11 @@ static bool do_statfs(char const *filename, char const *format)
security_context_t scontext = NULL;
if (option_mask32 & OPT_SELINUX) {
if ((option_mask32 & OPT_DEREFERENCE ? lgetfilecon(filename, scontext):
getfilecon(filename, scontext))< 0) {
if ((option_mask32 & OPT_DEREFERENCE
? lgetfilecon(filename, &scontext)
: getfilecon(filename, &scontext)
) < 0
) {
bb_perror_msg(filename);
return 0;
}
@@ -448,9 +451,12 @@ static bool do_stat(char const *filename, char const *format)
security_context_t scontext = NULL;
if (option_mask32 & OPT_SELINUX) {
if ((option_mask32 & OPT_DEREFERENCE ? lgetfilecon(filename, scontext):
getfilecon(filename, scontext))< 0) {
bb_perror_msg (filename);
if ((option_mask32 & OPT_DEREFERENCE
? lgetfilecon(filename, &scontext)
: getfilecon(filename, &scontext)
) < 0
) {
bb_perror_msg(filename);
return 0;
}
}
@@ -608,7 +614,7 @@ int stat_main(int argc, char **argv)
int ok = 1;
bool (*statfunc)(char const *, char const *) = do_stat;
getopt32(argc, argv, "ftL"
getopt32(argv, "ftL"
USE_SELINUX("Z")
USE_FEATURE_STAT_FORMAT("c:", &format)
);
+44 -46
View File
@@ -127,28 +127,28 @@ enum {
control, input, output, local, combination
};
static const char evenp [] = "evenp";
static const char raw [] = "raw";
static const char stty_min [] = "min";
static const char stty_time [] = "time";
static const char stty_swtch[] = "swtch";
static const char stty_eol [] = "eol";
static const char stty_eof [] = "eof";
static const char parity [] = "parity";
static const char stty_oddp [] = "oddp";
static const char stty_nl [] = "nl";
static const char stty_ek [] = "ek";
static const char stty_sane [] = "sane";
static const char cbreak [] = "cbreak";
static const char stty_pass8[] = "pass8";
static const char litout [] = "litout";
static const char cooked [] = "cooked";
static const char decctlq [] = "decctlq";
static const char stty_tabs [] = "tabs";
static const char stty_lcase[] = "lcase";
static const char stty_LCASE[] = "LCASE";
static const char stty_crt [] = "crt";
static const char stty_dec [] = "dec";
static const char evenp [] ALIGN1 = "evenp";
static const char raw [] ALIGN1 = "raw";
static const char stty_min [] ALIGN1 = "min";
static const char stty_time [] ALIGN1 = "time";
static const char stty_swtch[] ALIGN1 = "swtch";
static const char stty_eol [] ALIGN1 = "eol";
static const char stty_eof [] ALIGN1 = "eof";
static const char parity [] ALIGN1 = "parity";
static const char stty_oddp [] ALIGN1 = "oddp";
static const char stty_nl [] ALIGN1 = "nl";
static const char stty_ek [] ALIGN1 = "ek";
static const char stty_sane [] ALIGN1 = "sane";
static const char cbreak [] ALIGN1 = "cbreak";
static const char stty_pass8[] ALIGN1 = "pass8";
static const char litout [] ALIGN1 = "litout";
static const char cooked [] ALIGN1 = "cooked";
static const char decctlq [] ALIGN1 = "decctlq";
static const char stty_tabs [] ALIGN1 = "tabs";
static const char stty_lcase[] ALIGN1 = "lcase";
static const char stty_LCASE[] ALIGN1 = "LCASE";
static const char stty_crt [] ALIGN1 = "crt";
static const char stty_dec [] ALIGN1 = "dec";
/* Flags for 'struct mode_info' */
#define SANE_SET 1 /* Set in 'sane' mode */
@@ -158,7 +158,7 @@ static const char stty_dec [] = "dec";
/* Each mode */
struct mode_info {
const char * const name; /* Name given on command line */
const char *const name; /* Name given on command line */
const unsigned char type; /* Which structure element to change */
const unsigned char flags; /* Setting and display options */
/* were using short here, but ppc32 was unhappy: */
@@ -319,12 +319,12 @@ static const struct mode_info mode_info[] = {
};
enum {
NUM_mode_info = (sizeof(mode_info) / sizeof(mode_info[0]))
NUM_mode_info = ARRAY_SIZE(mode_info)
};
/* Control character settings */
struct control_info {
const char * const name; /* Name given on command line */
const char *const name; /* Name given on command line */
const unsigned char saneval; /* Value to set for 'stty sane' */
const unsigned char offset; /* Offset in c_cc */
};
@@ -371,7 +371,7 @@ static const struct control_info control_info[] = {
};
enum {
NUM_control_info = (sizeof(control_info) / sizeof(control_info[0]))
NUM_control_info = ARRAY_SIZE(control_info)
};
/* The width of the screen, for output wrapping */
@@ -417,11 +417,11 @@ static const char *visible(unsigned ch)
static tcflag_t *mode_type_flag(unsigned type, const struct termios *mode)
{
static const unsigned char tcflag_offsets[] = {
static const unsigned char tcflag_offsets[] ALIGN1 = {
offsetof(struct termios, c_cflag), /* control */
offsetof(struct termios, c_iflag), /* input */
offsetof(struct termios, c_oflag), /* output */
offsetof(struct termios, c_lflag), /* local */
offsetof(struct termios, c_lflag) /* local */
};
if (type <= local) {
@@ -430,7 +430,7 @@ static tcflag_t *mode_type_flag(unsigned type, const struct termios *mode)
return NULL;
}
static void set_speed_or_die(enum speed_setting type, const char * const arg,
static void set_speed_or_die(enum speed_setting type, const char *const arg,
struct termios * const mode)
{
speed_t baud;
@@ -524,10 +524,10 @@ static void display_window_size(const int fancy)
}
static const struct suffix_mult stty_suffixes[] = {
{"b", 512 },
{"k", 1024},
{"B", 1024},
{NULL, 0 }
{ "b", 512 },
{ "k", 1024 },
{ "B", 1024 },
{ }
};
static const struct mode_info *find_mode(const char *name)
@@ -560,20 +560,18 @@ enum {
param_ospeed = 8 | 0x80,
};
static int find_param(const char * const name)
static int find_param(const char *const name)
{
static const char * const params[] = {
"line", /* 1 */
"rows", /* 2 */
"cols", /* 3 */
"columns", /* 4 */
"size", /* 5 */
"ispeed"+1, /* 6 */
"ispeed",
"ospeed",
NULL
};
int i = index_in_str_array(params, name) + 1;
static const char params[] ALIGN1 =
"line\0" /* 1 */
"rows\0" /* 2 */
"cols\0" /* 3 */
"columns\0" /* 4 */
"size\0" /* 5 */
"speed\0" /* 6 */
"ispeed\0"
"ospeed\0";
int i = index_in_strings(params, name) + 1;
if (i == 0)
return 0;
if (i != 5 && i != 6)
+1 -1
View File
@@ -80,7 +80,7 @@ int sum_main(int argc, char **argv)
unsigned n;
unsigned type = SUM_BSD;
n = getopt32(argc, argv, "sr");
n = getopt32(argv, "sr");
if (n & 1) type = SUM_SYSV;
/* give the bsd priority over sysv func */
if (n & 2) type = SUM_BSD;
+3 -3
View File
@@ -30,7 +30,7 @@ static const struct suffix_mult tail_suffixes[] = {
{ "b", 512 },
{ "k", 1024 },
{ "m", 1024*1024 },
{ NULL, 0 }
{ }
};
struct globals {
@@ -63,7 +63,7 @@ static ssize_t tail_read(int fd, char *buf, size_t count)
return r;
}
static const char header_fmt[] = "\n==> %s <==\n";
static const char header_fmt[] ALIGN1 = "\n==> %s <==\n";
static unsigned eat_num(const char *p)
{
@@ -107,7 +107,7 @@ int tail_main(int argc, char **argv)
}
#endif
opt = getopt32(argc, argv, "fc:n:" USE_FEATURE_FANCY_TAIL("qs:v"),
opt = getopt32(argv, "fc:n:" USE_FEATURE_FANCY_TAIL("qs:v"),
&str_c, &str_n USE_FEATURE_FANCY_TAIL(,&str_s));
#define FOLLOW (opt & 0x1)
#define COUNT_BYTES (opt & 0x2)
+1 -1
View File
@@ -28,7 +28,7 @@ int tee_main(int argc, char **argv)
#else
int c;
#endif
retval = getopt32(argc, argv, "ia"); /* 'a' must be 2nd */
retval = getopt32(argv, "ia"); /* 'a' must be 2nd */
argc -= optind;
argv += optind;
+6 -17
View File
@@ -146,7 +146,6 @@ static const struct t_op {
{ ")" , RPAREN , PAREN },
};
enum { NUM_OPS = sizeof(ops) / sizeof(ops[0]) };
#if ENABLE_FEATURE_TEST_64
typedef int64_t arith_t;
@@ -155,7 +154,7 @@ typedef int arith_t;
#endif
/* Cannot eliminate these static data (do the G trick)
* because of bb_test usage from other applets */
* because of test_main usage from other applets */
static char **t_wp;
static struct t_op const *t_wp_op;
static gid_t *group_array;
@@ -179,14 +178,13 @@ static int test_eaccess(char *path, int mode);
static int is_a_group_member(gid_t gid);
static void initialize_group_array(void);
int bb_test(int argc, char **argv)
int test_main(int argc, char **argv)
{
int res;
char *arg0;
const char *arg0;
bool _off;
arg0 = strrchr(argv[0], '/');
if (!arg0++) arg0 = argv[0];
arg0 = bb_basename(argv[0]);
if (arg0[0] == '[') {
--argc;
if (!arg0[1]) { /* "[" ? */
@@ -471,7 +469,7 @@ static enum token t_lex(char *s)
return op->op_num;
}
op++;
} while (op < ops + NUM_OPS);
} while (op < ops + ARRAY_SIZE(ops));
return OPERAND;
}
@@ -569,7 +567,7 @@ static void initialize_group_array(void)
if (ngroups > 0) {
/* FIXME: ash tries so hard to not die on OOM,
* and we spoil it with just one xrealloc here */
/* We realloc, because bb_test can be entered repeatedly by shell.
/* We realloc, because test_main can be entered repeatedly by shell.
* Testcase (ash): 'while true; do test -x some_file; done'
* and watch top. (some_file must have owner != you) */
group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
@@ -599,12 +597,3 @@ static int is_a_group_member(gid_t gid)
return 0;
}
/* applet entry point */
int test_main(int argc, char **argv);
int test_main(int argc, char **argv)
{
return bb_test(argc, argv);
}
+1 -1
View File
@@ -26,7 +26,7 @@ int touch_main(int argc, char **argv)
{
int fd;
int status = EXIT_SUCCESS;
int flags = getopt32(argc, argv, "c");
int flags = getopt32(argv, "c");
argv += optind;
+42 -54
View File
@@ -25,41 +25,9 @@
#define TR_OPT_complement (1<<0)
#define TR_OPT_delete (1<<1)
#define TR_OPT_squeeze_reps (1<<2)
/* some "globals" shared across this file */
/* these last are pointers to static buffers declared in tr_main */
static char *poutput, *pvector, *pinvec, *poutvec;
static void ATTRIBUTE_NORETURN convert(const smalluint flags)
{
size_t read_chars = 0, in_index = 0, out_index = 0, c, coded, last = -1;
for (;;) {
/* If we're out of input, flush output and read more input. */
if (in_index == read_chars) {
if (out_index) {
xwrite(STDOUT_FILENO, (char *)poutput, out_index);
out_index = 0;
}
if ((read_chars = read(STDIN_FILENO, bb_common_bufsiz1, BUFSIZ)) <= 0) {
if (write(STDOUT_FILENO, (char *)poutput, out_index) != out_index)
bb_perror_msg(bb_msg_write_error);
exit(EXIT_SUCCESS);
}
in_index = 0;
}
c = bb_common_bufsiz1[in_index++];
coded = pvector[c];
if ((flags & TR_OPT_delete) && pinvec[c])
continue;
if ((flags & TR_OPT_squeeze_reps) && last == coded &&
(pinvec[c] || poutvec[coded]))
continue;
poutput[out_index++] = last = coded;
}
/* NOTREACHED */
}
static void map(unsigned char *string1, unsigned int string1_len,
static void map(char *pvector,
unsigned char *string1, unsigned int string1_len,
unsigned char *string2, unsigned int string2_len)
{
char last = '0';
@@ -83,11 +51,10 @@ static unsigned int expand(const char *arg, char *buffer)
char *buffer_start = buffer;
unsigned i; /* XXX: FIXME: use unsigned char? */
unsigned char ac;
#define CLO ":]"
static const char * const classes[] = {
"alpha"CLO, "alnum"CLO, "digit"CLO, "lower"CLO, "upper"CLO, "space"CLO,
"blank"CLO, "punct"CLO, "cntrl"CLO, NULL
};
#define CLO ":]\0"
static const char classes[] ALIGN1 =
"alpha"CLO "alnum"CLO "digit"CLO "lower"CLO "upper"CLO "space"CLO
"blank"CLO "punct"CLO "cntrl"CLO;
#define CLASS_invalid 0 /* we increment the retval */
#define CLASS_alpha 1
#define CLASS_alnum 2
@@ -121,9 +88,9 @@ static unsigned int expand(const char *arg, char *buffer)
if (ENABLE_FEATURE_TR_CLASSES && i == ':') {
smalluint j;
{ /* not really pretty.. */
char *tmp = xstrndup(arg, 7); // warning: xdigit needs 8, not 7
j = index_in_str_array(classes, tmp) + 1;
free(tmp);
char *tmp = xstrndup(arg, 7); // warning: xdigit needs 8, not 7
j = index_in_strings(classes, tmp) + 1;
free(tmp);
}
if (j == CLASS_alnum || j == CLASS_digit) {
for (i = '0'; i <= '9'; i++)
@@ -183,7 +150,7 @@ static unsigned int expand(const char *arg, char *buffer)
static int complement(char *buffer, int buffer_len)
{
short i, j, ix;
int i, j, ix;
char conv[ASCII + 2];
ix = 0;
@@ -206,17 +173,12 @@ int tr_main(int argc, char **argv)
int idx = 1;
int i;
smalluint flags = 0;
size_t read_chars = 0, in_index = 0, out_index = 0, c, coded, last = -1;
RESERVE_CONFIG_UBUFFER(output, BUFSIZ);
RESERVE_CONFIG_BUFFER(vector, ASCII+1);
RESERVE_CONFIG_BUFFER(invec, ASCII+1);
RESERVE_CONFIG_BUFFER(outvec, ASCII+1);
/* ... but make them available globally */
poutput = output;
pvector = vector;
pinvec = invec;
poutvec = outvec;
if (argc > 1 && argv[idx][0] == '-') {
for (ptr = (unsigned char *) &argv[idx][1]; *ptr; ptr++) {
if (*ptr == 'c')
@@ -235,21 +197,47 @@ int tr_main(int argc, char **argv)
invec[i] = outvec[i] = FALSE;
}
#define tr_buf bb_common_bufsiz1
if (argv[idx] != NULL) {
input_length = expand(argv[idx++], bb_common_bufsiz1);
input_length = expand(argv[idx++], tr_buf);
if (flags & TR_OPT_complement)
input_length = complement(bb_common_bufsiz1, input_length);
input_length = complement(tr_buf, input_length);
if (argv[idx] != NULL) {
if (*argv[idx] == '\0')
bb_error_msg_and_die("STRING2 cannot be empty");
output_length = expand(argv[idx], output);
map(bb_common_bufsiz1, input_length, output, output_length);
map(vector, tr_buf, input_length, output, output_length);
}
for (i = 0; i < input_length; i++)
invec[(unsigned char)bb_common_bufsiz1[i]] = TRUE;
invec[(unsigned char)tr_buf[i]] = TRUE;
for (i = 0; i < output_length; i++)
outvec[output[i]] = TRUE;
}
convert(flags);
for (;;) {
/* If we're out of input, flush output and read more input. */
if (in_index == read_chars) {
if (out_index) {
xwrite(STDOUT_FILENO, (char *)output, out_index);
out_index = 0;
}
read_chars = read(STDIN_FILENO, tr_buf, BUFSIZ);
if (read_chars <= 0) {
if (write(STDOUT_FILENO, (char *)output, out_index) != out_index)
bb_perror_msg(bb_msg_write_error);
exit(EXIT_SUCCESS);
}
in_index = 0;
}
c = tr_buf[in_index++];
coded = vector[c];
if ((flags & TR_OPT_delete) && invec[c])
continue;
if ((flags & TR_OPT_squeeze_reps) && last == coded &&
(invec[c] || outvec[coded]))
continue;
output[out_index++] = last = coded;
}
/* NOTREACHED */
return EXIT_SUCCESS;
}
+1 -1
View File
@@ -21,7 +21,7 @@ int tty_main(int argc, char **argv)
xfunc_error_retval = 2; /* SUSv3 requires > 1 for error. */
USE_INCLUDE_SUSv2(silent = getopt32(argc, argv, "s");)
USE_INCLUDE_SUSv2(silent = getopt32(argv, "s");)
/* gnu tty outputs a warning that it is ignoring all args. */
bb_warn_ignoring_args(argc - optind);
+3 -3
View File
@@ -38,8 +38,8 @@ typedef struct {
char processor[8]; /* for "unknown" */
} uname_info_t;
static const char options[] = "snrvmpa";
static const unsigned short int utsname_offset[] = {
static const char options[] ALIGN1 = "snrvmpa";
static const unsigned short utsname_offset[] ALIGN2 = {
offsetof(uname_info_t,name.sysname),
offsetof(uname_info_t,name.nodename),
offsetof(uname_info_t,name.release),
@@ -58,7 +58,7 @@ int uname_main(int argc, char **argv)
const unsigned short int *delta;
char toprint;
toprint = getopt32(argc, argv, options);
toprint = getopt32(argv, options);
if (argc != optind) {
bb_show_usage();
+2 -2
View File
@@ -12,7 +12,7 @@
#include "libbb.h"
static const char uniq_opts[] = "cdu" "f:s:" "cdu\0\1\2\4";
static const char uniq_opts[] ALIGN1 = "cdu" "f:s:" "cdu\0\1\2\4";
static FILE *xgetoptfile_uniq_s(char **argv, int read0write2)
{
@@ -45,7 +45,7 @@ int uniq_main(int argc, char **argv)
skip_fields = skip_chars = 0;
opt = getopt32(argc, argv, "cduf:s:", &s0, &s1);
opt = getopt32(argv, "cduf:s:", &s0, &s1);
if (opt & OPT_f)
skip_fields = xatoul(s0);
if (opt & OPT_s)
+57 -24
View File
@@ -68,9 +68,7 @@ static void read_stduu(FILE *src_stream, FILE *dst_stream)
static void read_base64(FILE *src_stream, FILE *dst_stream)
{
static const char base64_table[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n";
int term_count = 0;
int term_count = 1;
while (1) {
char translated[4];
@@ -80,25 +78,28 @@ static void read_base64(FILE *src_stream, FILE *dst_stream)
char *table_ptr;
int ch;
/* Get next _valid_ character */
/* Get next _valid_ character.
* global vector bb_uuenc_tbl_base64[] contains this string:
* "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n"
*/
do {
ch = fgetc(src_stream);
if (ch == EOF) {
bb_error_msg_and_die("short file");
}
} while ((table_ptr = strchr(base64_table, ch)) == NULL);
table_ptr = strchr(bb_uuenc_tbl_base64, ch);
} while (table_ptr == NULL);
/* Convert encoded charcter to decimal */
ch = table_ptr - base64_table;
/* Convert encoded character to decimal */
ch = table_ptr - bb_uuenc_tbl_base64;
if (*table_ptr == '=') {
if (term_count == 0) {
translated[count] = 0;
translated[count] = '\0';
break;
}
term_count++;
}
else if (*table_ptr == '\n') {
} else if (*table_ptr == '\n') {
/* Check for terminating line */
if (term_count == 5) {
return;
@@ -113,7 +114,9 @@ static void read_base64(FILE *src_stream, FILE *dst_stream)
}
/* Merge 6 bit chars to 8 bit */
fputc(translated[0] << 2 | translated[1] >> 4, dst_stream);
if (count > 1) {
fputc(translated[0] << 2 | translated[1] >> 4, dst_stream);
}
if (count > 2) {
fputc(translated[1] << 4 | translated[2] >> 2, dst_stream);
}
@@ -126,19 +129,16 @@ static void read_base64(FILE *src_stream, FILE *dst_stream)
int uudecode_main(int argc, char **argv);
int uudecode_main(int argc, char **argv)
{
FILE *src_stream;
FILE *src_stream = stdin;
char *outname = NULL;
char *line;
getopt32(argc, argv, "o:", &outname);
opt_complementary = "?1"; /* 1 argument max */
getopt32(argv, "o:", &outname);
argv += optind;
if (optind == argc) {
src_stream = stdin;
} else if (optind + 1 == argc) {
src_stream = xfopen(argv[optind], "r");
} else {
bb_show_usage();
}
if (argv[0])
src_stream = xfopen(argv[0], "r");
/* Search for the start of the encoding */
while ((line = xmalloc_getline(src_stream)) != NULL) {
@@ -158,6 +158,7 @@ int uudecode_main(int argc, char **argv)
continue;
}
/* begin line found. decode and exit */
mode = strtoul(line_ptr, NULL, 8);
if (outname == NULL) {
outname = strchr(line_ptr, ' ');
@@ -166,16 +167,48 @@ int uudecode_main(int argc, char **argv)
}
outname++;
}
if (LONE_DASH(outname)) {
dst_stream = stdout;
} else {
dst_stream = stdout;
if (NOT_LONE_DASH(outname)) {
dst_stream = xfopen(outname, "w");
chmod(outname, mode & (S_IRWXU | S_IRWXG | S_IRWXO));
}
free(line);
decode_fn_ptr(src_stream, dst_stream);
fclose_if_not_stdin(src_stream);
/* fclose_if_not_stdin(src_stream); - redundant */
return EXIT_SUCCESS;
}
bb_error_msg_and_die("no 'begin' line");
}
/* Test script.
Put this into an empty dir with busybox binary, an run.
#!/bin/sh
test -x busybox || { echo "No ./busybox?"; exit; }
ln -sf busybox uudecode
ln -sf busybox uuencode
>A_null
echo -n A >A
echo -n AB >AB
echo -n ABC >ABC
echo -n ABCD >ABCD
echo -n ABCDE >ABCDE
echo -n ABCDEF >ABCDEF
cat busybox >A_bbox
for f in A*; do
echo uuencode $f
./uuencode $f <$f >u_$f
./uuencode -m $f <$f >m_$f
done
mkdir unpk_u unpk_m 2>/dev/null
for f in u_*; do
./uudecode <$f -o unpk_u/${f:2}
diff -a ${f:2} unpk_u/${f:2} >/dev/null 2>&1
echo uudecode $f: $?
done
for f in m_*; do
./uudecode <$f -o unpk_m/${f:2}
diff -a ${f:2} unpk_m/${f:2} >/dev/null 2>&1
echo uudecode $f: $?
done
*/
+26 -41
View File
@@ -10,67 +10,52 @@
#include "libbb.h"
enum {
SRC_BUF_SIZE = 45, /* This *MUST* be a multiple of 3 */
DST_BUF_SIZE = 4 * ((SRC_BUF_SIZE + 2) / 3),
};
#define SRC_BUF_SIZE 45 // This *MUST* be a multiple of 3
#define DST_BUF_SIZE 4 * ((SRC_BUF_SIZE + 2) / 3)
int uuencode_main(int argc, char **argv);
int uuencode_main(int argc, char **argv)
{
const size_t src_buf_size = SRC_BUF_SIZE;
const size_t dst_buf_size = DST_BUF_SIZE;
size_t write_size = dst_buf_size;
struct stat stat_buf;
FILE *src_stream = stdin;
int src_fd = STDIN_FILENO;
const char *tbl;
size_t size;
mode_t mode;
RESERVE_CONFIG_BUFFER(src_buf, SRC_BUF_SIZE + 1);
RESERVE_CONFIG_BUFFER(dst_buf, DST_BUF_SIZE + 1);
char src_buf[SRC_BUF_SIZE];
char dst_buf[DST_BUF_SIZE + 1];
tbl = bb_uuenc_tbl_std;
if (getopt32(argc, argv, "m") & 1) {
mode = 0666 & ~umask(0666);
opt_complementary = "-1:?2"; /* must have 1 or 2 args */
if (getopt32(argv, "m")) {
tbl = bb_uuenc_tbl_base64;
}
switch (argc - optind) {
case 2:
src_stream = xfopen(argv[optind], "r");
xstat(argv[optind], &stat_buf);
mode = stat_buf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
if (src_stream == stdout) {
puts("NULL");
}
break;
case 1:
mode = 0666 & ~umask(0666);
break;
default:
bb_show_usage();
argv += optind;
if (argc == optind + 2) {
src_fd = xopen(*argv, O_RDONLY);
fstat(src_fd, &stat_buf);
mode = stat_buf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
argv++;
}
printf("begin%s %o %s", tbl == bb_uuenc_tbl_std ? "" : "-base64", mode, argv[argc - 1]);
while ((size = fread(src_buf, 1, src_buf_size, src_stream)) > 0) {
if (size != src_buf_size) {
/* write_size is always 60 until the last line */
write_size = (4 * ((size + 2) / 3));
/* pad with 0s so we can just encode extra bits */
memset(&src_buf[size], 0, src_buf_size - size);
}
printf("begin%s %o %s", tbl == bb_uuenc_tbl_std ? "" : "-base64", mode, *argv);
while (1) {
size_t size = full_read(src_fd, src_buf, SRC_BUF_SIZE);
if (!size)
break;
if ((ssize_t)size < 0)
bb_perror_msg_and_die(bb_msg_read_error);
/* Encode the buffer we just read in */
bb_uuencode((unsigned char*)src_buf, dst_buf, size, tbl);
bb_uuencode(dst_buf, src_buf, size, tbl);
putchar('\n');
if (tbl == bb_uuenc_tbl_std) {
putchar(tbl[size]);
}
if (fwrite(dst_buf, 1, write_size, stdout) != write_size) {
bb_perror_msg_and_die(bb_msg_write_error);
}
fflush(stdout);
xwrite(STDOUT_FILENO, dst_buf, 4 * ((size + 2) / 3));
}
printf(tbl == bb_uuenc_tbl_std ? "\n`\nend\n" : "\n====\n");
die_if_ferror(src_stream, "source"); /* TODO - Fix this! */
fflush_stdout_and_exit(EXIT_SUCCESS);
}
+3 -3
View File
@@ -36,14 +36,14 @@
* (adapted from example in gnu wc.c)
*
* echo hello > /tmp/testfile &&
* (dd ibs=1k skip=1 count=0 &> /dev/null ; wc -c) < /tmp/testfile
* (dd ibs=1k skip=1 count=0 &> /dev/null; wc -c) < /tmp/testfile
*
* for which 'wc -c' should output '0'.
*/
#include "libbb.h"
#ifdef CONFIG_LOCALE_SUPPORT
#if ENABLE_LOCALE_SUPPORT
#define isspace_given_isprint(c) isspace(c)
#else
#undef isspace
@@ -86,7 +86,7 @@ int wc_main(int argc, char **argv)
smallint in_word;
unsigned print_type;
print_type = getopt32(argc, argv, "lwcL");
print_type = getopt32(argv, "lwcL");
if (print_type == 0) {
print_type = (1 << WC_LINES) | (1 << WC_WORDS) | (1 << WC_CHARS);
+2 -1
View File
@@ -19,7 +19,8 @@ int whoami_main(int argc, char **argv)
if (argc > 1)
bb_show_usage();
puts(bb_getpwuid(NULL, geteuid(), -1));
/* Will complain and die if username not found */
puts(bb_getpwuid(NULL, -1, geteuid()));
return fflush(stdout);
}
Loaded 100 of 390 files, more files were not shown because too many files have changed in this diff. Show more