Compare commits

...
461 Commits
Author SHA1 Message Date
Denis Vlasenko e9f8b2f830 apply post 1.10.3 patches, release 1.10.4 2008-06-25 11:01:42 +00:00
Denis Vlasenko 49b78fc1a8 Apply post-1.10.2 fixes, bump version to 1.10.3 2008-06-05 01:10:03 +00:00
Denis Vlasenko a3087ca749 Apply post-1.10.1 patches
Bump version to 1.10.2
2008-05-08 15:26:06 +00:00
Bernhard Reutner-Fischer 0abe9d96ee - correct usage helptext of ifupdown 2008-05-08 10:40:56 +00:00
Bernhard Reutner-Fischer 378481ed1e - fix strncmp'ing "runlevel"
r21931 from trunk
2008-05-05 14:48:13 +00:00
Denis Vlasenko fc9fc1f929 apply all post 1.10.0 fixes
bump version to 1.10.1
2008-04-19 04:05:28 +00:00
Denis Vlasenko 74f8208f18 Bump version to 1.10.0 and announce it on website. 2008-03-21 20:50:37 +00:00
Denis Vlasenko ffa5d76602 update defconfig 2008-03-21 20:37:16 +00:00
Denis Vlasenko 45911a60c3 website: fix double include of menubar 2008-03-21 20:06:42 +00:00
Denis Vlasenko 31567c1c70 webpage: fix English 2008-03-21 18:52:18 +00:00
Denis Vlasenko 68d09697c9 website: announce stable point releases 2008-03-21 18:41:21 +00:00
Denis Vlasenko 4824ccae8e *: fix build problems found with randomconfig 2008-03-21 18:29:01 +00:00
Denis Vlasenko 0dc490bda2 scripts/bb_release: release script (I nearly lost it last time)
website: update links to latest releases
2008-03-21 09:56:19 +00:00
Denis Vlasenko f90ab183d6 *: use fopen_or_warn in few more places 2008-03-20 21:19:35 +00:00
Paul Fox 275b929e01 let top build without TERMIOS enabled 2008-03-20 16:05:02 +00:00
Paul Fox 9e1f92d0bb termios can be used by either top or more. 2008-03-20 16:04:36 +00:00
Denis Vlasenko 9230582315 inetd: use change_identity().
libbb: shrink our internal initgroups().
httpd: remove stray 'else' and 'index_page = "index.html"'

function                                             old     new   delta
httpd_main                                           750     743      -7
inetd_main                                          2033    2011     -22
bb_internal_initgroups                               251     228     -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-52)             Total: -52 bytes
2008-03-20 15:12:58 +00:00
Denis Vlasenko c52248e41c small NOMMU fixes 2008-03-20 14:04:30 +00:00
Denis Vlasenko 3c96d0258c hdparm: do not lie about supporting -q (quiet)
hdparm: interpret_standby() shrink
hdparm: make HDIO_GET/SET_QDMA #ifdef more complete
 (by Joe Krahn <krahn AT niehs.nih.gov>)

function                                             old     new   delta
packed_usage                                       23798   23776     -22
process_dev                                         5342    5315     -27
2008-03-20 13:44:50 +00:00
Denis Vlasenko 0f3a580c4f gcc compat fix and warning suppression
by Joe Krahn <krahn AT niehs.nih.gov>
2008-03-20 13:13:09 +00:00
Denis Vlasenko 027271e5a9 udhcp: fix wrong order of args here: index_in_strings(opt, dhcp_option_strings);
code shrink while at it:

function                                             old     new   delta
read_config                                          406     323     -83
2008-03-20 12:47:01 +00:00
Denis Vlasenko 0a0180cdc5 tftpd: small trivial shrink
tftpd_main                                           502     488     -14
2008-03-19 23:37:32 +00:00
Denis Vlasenko 104d544fd7 die_if_bad_username: shrink: 88 -> 77 bytes 2008-03-19 23:25:00 +00:00
Denis Vlasenko dd5702d696 ...and actually adding new file now... 2008-03-19 23:15:55 +00:00
Denis Vlasenko a7d6c8bab9 adduser/addgroup: check username for invalid chars
(by Tito <farmatito AT tiscali.it>). +129 bytes when enabled.
2008-03-19 23:15:26 +00:00
Denis Vlasenko cf7cf62204 *: s/BB_SIGS_FATAL/BB_FATAL_SIGS/ (latter proved easier to remember)
top: fix "top </dev/null" case (by Cristian Ionescu-Idbohrn)
2008-03-19 19:38:46 +00:00
Denis Vlasenko 0764a7f72d ifupdown: make it NOMMU-capable 2008-03-19 16:24:17 +00:00
Denis Vlasenko 7a60133c6c tftpd: fix download: we must change user AFTER bind
tftp_protocol                                       1466    1468      +2
2008-03-19 13:24:13 +00:00
Denis Vlasenko 403a5a298e tftpd: options -c (allow _new_ files to be uploaded) and -u USER
function                                             old     new   delta
tftp_protocol                                       1316    1466    +150
packed_usage                                       23774   23798     +24
tftpd_main                                           509     502      -7
tftp_main                                            311     252     -59
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/2 up/down: 174/-66)           Total: 108 bytes
   text    data     bss     dec     hex filename
 797700     641    7380  805721   c4b59 busybox_old
 797833     641    7380  805854   c4bde busybox_unstripped
2008-03-19 13:07:00 +00:00
Denis Vlasenko 71c9f015e9 tftp(d): a bit more verbose error reporting 2008-03-19 09:43:50 +00:00
Denis Vlasenko dd9228b861 tftpd: make it emit error packets
telnetd: use login always, not "sometimes login, sometimes shell"

   text    data     bss     dec     hex filename
 797612     641    7380  805633   c4b01 busybox_old
 797695     641    7380  805716   c4b54 busybox_unstripped
2008-03-19 05:00:05 +00:00
Denis Vlasenko c0183e6e0d unlzma: shrink by Pascal Bellard <pascal.bellard AT ads-lu.com> 2008-03-18 03:13:25 +00:00
Denis Vlasenko 6aa7696e28 mount: #ifdef out MOUNT_LABEL code parts if it is not selected 2008-03-18 01:44:52 +00:00
Denis Vlasenko 2a7a451391 patch: don't trash permissions of patched file 2008-03-18 01:38:04 +00:00
Denis Vlasenko d7e6af2dda tftpd: make open() check r/w permissions instead of doing it ourself.
Add -r "prohibit upload" opt for those lazy people who run tftpd as root.
-40 bytes.
2008-03-18 01:13:11 +00:00
Denis Vlasenko 78c5656530 tftpd: fix bugs spotted by Vladimir 2008-03-18 00:11:46 +00:00
Denis Vlasenko e421b5ebf6 init: do not close all descriptors > 2. We were doing it - sometimes.
Good choices are "do it, always" or "don't do it". Second is smaller.
2008-03-17 22:01:42 +00:00
Paul Fox 2724fa9d8a remove alarm() calls which were functioning as a primitive
watchdog function, presumably to catch infinite loop bugs. 
(control-C can do the same thing, and the alarms were too short in
any case.)  also, switch to sigsetjmp/siglongjmp in order to allow
repeated use of control-C -- otherwise it works once, then not again.
2008-03-17 15:28:07 +00:00
Denis Vlasenko fb274df079 init: do not use bb_sanitize_stdio(), "/dev/null" may be missing (yet) 2008-03-17 13:26:51 +00:00
Denis Vlasenko 9c8c038981 httpd: small fixlet for POST upload - skip
whitespace between "Content-length:" and number
2008-03-17 12:58:19 +00:00
Denis Vlasenko d1277c6052 remove extra spaces in help text; delete duplicate #define 2008-03-17 09:37:24 +00:00
Denis Vlasenko d0a071a528 brctl: eliminate stray data object
brctl: use constant fd to reduce parameter passing
runsvdir: do not use data/bss
od: reuse bb_argv_dash
last: do not go into endless loop on read error
mount: make it not fail scripts/find_bad_common_bufsiz check
dc: add INIT_G() (no-op for dc, but we want uniform usage of "G trick")

function                                             old     new   delta
runsvdir_main                                       1646    1672     +26
set_pgrp                                               1       -      -1
exitsoon                                               1       -      -1
check                                                679     678      -1
svnum                                                  4       -      -4
svdir                                                  4       -      -4
sv                                                     4       -      -4
stamplog                                               4       -      -4
rploglen                                               4       -      -4
rplog                                                  4       -      -4
mount_main                                           995     988      -7
static.default_file_list                               8       -      -8
pfd                                                    8       -      -8
logpipe                                                8       -      -8
static.info                                           20       -     -20
brctl_main                                           767     739     -28
------------------------------------------------------------------------------
(add/remove: 0/12 grow/shrink: 1/3 up/down: 26/-106)          Total: -80 bytes
   text    data     bss     dec     hex filename
 793327     662    7412  801401   c3a79 busybox_old
 793329     641    7372  801342   c3a3e busybox_unstripped
2008-03-17 09:33:45 +00:00
Denis Vlasenko b44c790e41 *: fix various kinds of damage to letter 'c' in Arkadiusz Mickiewicz' surname.
chrt,taskset,dc,eject: shrink
crontab: call "vi" with just name, no path
watchdog: intercept all fatal signals

function                                             old     new   delta
xstrtoull_range                                        -      35     +35
static.sg_commands                                     -      18     +18
packed_usage                                       23698   23712     +14
watchdog_main                                        148     151      +3
crontab_main                                         637     638      +1
base                                                   1       -      -1
static.ps                                              4       -      -4
pointer                                                4       -      -4
stack_machine                                         99      92      -7
run_command                                          273     260     -13
eject_main                                           360     343     -17
static.C                                              30      12     -18
ptok                                                  61      38     -23
xstrtol_range                                         27       -     -27
get_token                                             35       -     -35
taskset_main                                         586     550     -36
chrt_main                                            411     372     -39
dc_main                                              158     117     -41
time_main                                           1127    1037     -90
------------------------------------------------------------------------------
(add/remove: 2/5 grow/shrink: 3/9 up/down: 71/-355)          Total: -284 bytes
   text    data     bss     dec     hex filename
 793680     662    7420  801762   c3be2 busybox_old
 793327     662    7412  801401   c3a79 busybox_unstripped
2008-03-17 09:29:43 +00:00
Denis Vlasenko d25c33f186 volume_id: disable detection routines which are not setting label and uuid anyway
function                                             old     new   delta
static.warn                                            1       -      -1
static.drive_name_string                              14      12      -2
static.offsets                                         8       -      -8
static.sectors                                        10       -     -10
fs2                                                   60      48     -12
raid2                                                 16       -     -16
uuidcache_init                                       704     677     -27
raid1                                                 32       -     -32
volume_id_probe_all                                  198     158     -40
volume_id_probe_lvm1                                  58       -     -58
volume_id_probe_highpoint_37x_raid                    63       -     -63
volume_id_probe_hpfs                                  67       -     -67
volume_id_probe_minix                                 74       -     -74
volume_id_probe_lvm2                                  78       -     -78
volume_id_probe_silicon_medley_raid                   97       -     -97
volume_id_probe_via_raid                             101       -    -101
volume_id_probe_highpoint_45x_raid                   104       -    -104
volume_id_probe_nvidia_raid                          108       -    -108
volume_id_probe_lsi_mega_raid                        108       -    -108
volume_id_probe_intel_software_raid                  108       -    -108
volume_id_probe_ufs                                  126       -    -126
volume_id_probe_promise_fasttrack_raid               144       -    -144
------------------------------------------------------------------------------
(add/remove: 0/18 grow/shrink: 0/4 up/down: 0/-1384)        Total: -1384 bytes
   text    data     bss     dec     hex filename
 794244     662    7420  802326   c3e16 busybox_old
 792698     662    7420  800780   c380c busybox_unstripped
2008-03-17 09:25:05 +00:00
Denis Vlasenko c5b737231d volude_id: remove unused fields and functions which were setting them
function                                             old     new   delta
uuidcache_init                                       567     704    +137
findfs_main                                            -     125    +125
packed_usage                                       23662   23694     +32
static.drive_name_string                               -      14     +14
applet_names                                        1815    1822      +7
applet_main                                         1104    1108      +4
volume_id_open_node                                   35      38      +3
applet_nameofs                                       552     554      +2
get_devname_from_label                                78      79      +1
applet_install_loc                                   138     139      +1
volume_id_set_label_unicode16                         31      27      -4
volume_id_set_label_string                            74      70      -4
get_devname_from_uuid                                 63      59      -4
fs1                                                   12       8      -4
volume_id_set_unicode16                              209     202      -7
volume_id_free_buffer                                 71      56     -15
free_volume_id                                        52      37     -15
volume_id_probe_luks                                  97      79     -18
volume_id_set_usage_part                              21       -     -21
volume_id_probe_ufs                                  148     126     -22
volume_id_probe_lsi_mega_raid                        131     108     -23
volume_id_probe_highpoint_45x_raid                   127     104     -23
volume_id_probe_highpoint_37x_raid                    87      63     -24
volume_id_set_usage                                   28       -     -28
volume_id_probe_romfs                                121      93     -28
volume_id_set_label_raw                               30       -     -30
volume_id_probe_promise_fasttrack_raid               174     144     -30
volume_id_set_uuid                                   373     342     -31
volume_id_probe_xfs                                  122      91     -31
volume_id_probe_jfs                                  138     107     -31
volume_id_probe_ocfs2                                139     107     -32
volume_id_probe_lvm1                                  90      58     -32
volume_id_probe_cramfs                               106      63     -43
volume_id_probe_via_raid                             145     101     -44
volume_id_probe_intel_software_raid                  153     108     -45
volume_id_probe_minix                                121      74     -47
volume_id_probe_udf                                  682     632     -50
volume_id_probe_nvidia_raid                          158     108     -50
volume_id_probe_lvm2                                 128      78     -50
volume_id_probe_hpfs                                 117      67     -50
volume_id_probe_ext                                  143      93     -50
volume_id_probe_linux_raid                           191     139     -52
volume_id_probe_sysv                                 244     187     -57
volume_id_probe_silicon_medley_raid                  158      97     -61
usage_to_string                                       64       -     -64
volume_id_probe_linux_swap                           263     198     -65
volume_id_get_buffer                                 372     307     -65
volume_id_probe_iso9660                              412     332     -80
volume_id_probe_hfs_hfsplus                          888     806     -82
volume_id_probe_ntfs                                 396     294    -102
volume_id_probe_vfat                                 980     872    -108
volume_id_probe_reiserfs                             417     268    -149
dev_get_major_minor                                  175       -    -175
uuidcache_check_device                               692     499    -193
volume_id_probe_mac_partition_map                    697       -    -697
------------------------------------------------------------------------------
(add/remove: 2/6 grow/shrink: 8/39 up/down: 326/-2836)      Total: -2510 bytes
   text    data     bss     dec     hex filename
 797220     662    7420  805302   c49b6 busybox_old
 794244     662    7420  802326   c3e16 busybox_unstripped
2008-03-17 09:21:26 +00:00
Denis Vlasenko 592d4fe772 selinux/*: -Wunused-parameter fixes
runsv: make it NOMMU-capable

function                                             old     new   delta
startservice                                         291     313     +22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 22/0)               Total: 22 bytes
2008-03-17 09:19:26 +00:00
Denis Vlasenko 4866e905d7 svn add/svn rm to actually move tcp/udpsvd... 2008-03-17 09:17:27 +00:00
Denis Vlasenko 4ee7cd4f6f *: mode tcp/udpsvd to networking, delete ipsvd/*
*/Config.in: fixes to text
svlogd: make it NOMMU capable

function                                             old     new   delta
processorstart                                       378     420     +42
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 42/0)               Total: 42 bytes
   text    data     bss     dec     hex filename
 797153     662    7420  805235   c4973 busybox_old
 797196     662    7420  805278   c499e busybox_unstripped
2008-03-17 09:13:22 +00:00
Denis Vlasenko aa9b1828b9 tftpd: new applet (mostly using existing code for tftp)
function                                             old     new   delta
tftp_protocol                                          -    1173   +1173
tftpd_main                                             -     500    +500
tftp_option_get                                        -     102    +102
packed_usage                                       23650   23662     +12
applet_names                                        1809    1815      +6
applet_main                                         1100    1104      +4
applet_nameofs                                       550     552      +2
tftp_main                                            302     301      -1
get_nport                                             32       -     -32
tftp                                                1172       -   -1172
------------------------------------------------------------------------------
(add/remove: 3/2 grow/shrink: 4/1 up/down: 1799/-1205)        Total: 594 bytes
   text    data     bss     dec     hex filename
 796479     662    7420  804561   c46d1 busybox_old
 797153     662    7420  805235   c4973 busybox_unstripped
2008-03-17 09:10:39 +00:00
Denis Vlasenko 1d42665b6b *: shrink: use Vladimir's "o+" specifier instead of xatou(opt_param)
function                                             old     new   delta
getopt32                                            1370    1385     +15
sulogin_main                                         490     494      +4
realpath_main                                         84      86      +2
sleep_main                                            76      77      +1
mt_main                                              256     257      +1
printenv_main                                         75      74      -1
fdformat_main                                        546     545      -1
usleep_main                                           44      42      -2
setlogcons_main                                       77      75      -2
ed_main                                             2654    2649      -5
deallocvt_main                                        69      64      -5
addgroup_main                                        373     368      -5
mkfs_minix_main                                     2989    2982      -7
tail_main                                           1221    1213      -8
sv_main                                             1254    1241     -13
du_main                                              348     328     -20
tftp_main                                            325     302     -23
split_main                                           581     558     -23
nc_main                                             1000     977     -23
diff_main                                            891     868     -23
arping_main                                         1797    1770     -27
ls_main                                              893     847     -46
od_main                                             2797    2750     -47
readprofile_main                                    1944    1895     -49
tcpudpsvd_main                                      1973    1922     -51
udhcpc_main                                         2590    2513     -77
grep_main                                            824     722    -102
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/22 up/down: 23/-560)         Total: -537 bytes
   text    data     bss     dec     hex filename
 796973     658    7428  805059   c48c3 busybox_old
 796479     662    7420  804561   c46d1 busybox_unstripped
2008-03-17 09:09:09 +00:00
Denis Vlasenko 62a90cdd74 *: shrink by using [f]open_or_warn_stdin where appropriate
function                                             old     new   delta
lsattr_main                                           62     143     +81
open_or_warn_stdin                                     -      36     +36
fclose_if_not_stdin                                   20      47     +27
xfopen_stdin                                           -      20     +20
tac_main                                             336     356     +20
cksum_main                                           249     259     +10
bb_argv_dash                                           -       8      +8
su_main                                              448     455      +7
cmp_main                                             630     633      +3
passwd_main                                         1072    1074      +2
uudecode_main                                        317     315      -2
text_yank                                            110     108      -2
handle_incoming_and_exit                            2653    2651      -2
flags                                                  5       1      -4
write_leases                                         235     230      -5
fopen_or_warn_stdin                                   48      42      -6
fold_main                                            648     642      -6
static.argv_dash                                       8       -      -8
sum_main                                             142     128     -14
tail_main                                           1237    1221     -16
sed_main                                             711     695     -16
cmp_xfopen_input                                      17       -     -17
bb_cat                                               113      96     -17
catv_main                                            328     306     -22
strings_main                                         457     434     -23
hash_file                                            298     274     -24
sum_file                                             353     325     -28
sort_main                                            904     859     -45
expand_main                                          736     686     -50
cut_main                                            1116    1065     -51
md5_sha1_sum_main                                    549     493     -56
lsattr_args                                           90       -     -90
read_stduu                                           408     255    -153
------------------------------------------------------------------------------
(add/remove: 3/3 grow/shrink: 7/20 up/down: 214/-657)        Total: -443 bytes
   text    data     bss     dec     hex filename
 797417     658    7428  805503   c4a7f busybox_old
 796973     658    7428  805059   c48c3 busybox_unstripped
2008-03-17 09:07:36 +00:00
Denis Vlasenko d02db89244 clean up TODO file. No real code changes. 2008-03-17 09:05:21 +00:00
Denis Vlasenko 85c247161b *: fix fallout from -Wunused-parameter
function                                             old     new   delta
bbunpack                                             358     366      +8
passwd_main                                         1070    1072      +2
handle_incoming_and_exit                            2651    2653      +2
getpty                                                88      86      -2
script_main                                          975     972      -3
inetd_main                                          2036    2033      -3
dname_enc                                            377     373      -4
make_new_session                                     474     462     -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/5 up/down: 12/-24)            Total: -12 bytes
   text    data     bss     dec     hex filename
 797429     658    7428  805515   c4a8b busybox_old
 797417     658    7428  805503   c4a7f busybox_unstripped
2008-03-17 09:04:04 +00:00
Denis Vlasenko 081eb71ebd dnsd: properly set _src_ IP:port on outgoing UDP packets
function                                             old     new   delta
send_to_from                                           -     258    +258
dnsd_main                                           1500    1568     +68
interrupt                                             17      19      +2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 328/0)             Total: 328 bytes
   text    data     bss     dec     hex filename
 797101     658    7428  805187   c4943 busybox_old
 797429     658    7428  805515   c4a8b busybox_unstripped
2008-03-17 09:02:21 +00:00
Denis Vlasenko 68404f13d4 *: add -Wunused-parameter; fix resulting breakage
function                                             old     new   delta
procps_scan                                         1265    1298     +33
aliascmd                                             278     283      +5
parse_file_cmd                                       116     120      +4
dname_enc                                            373     377      +4
setcmd                                                90      93      +3
execcmd                                               57      60      +3
count_lines                                           72      74      +2
process_command_subs                                 340     339      -1
test_main                                            409     407      -2
mknod_main                                           179     177      -2
handle_incoming_and_exit                            2653    2651      -2
argstr                                              1312    1310      -2
shiftcmd                                             131     128      -3
exitcmd                                               46      43      -3
dotcmd                                               297     294      -3
breakcmd                                              86      83      -3
evalpipe                                             353     349      -4
evalcommand                                         1180    1176      -4
evalcmd                                              109     105      -4
send_tree                                            374     369      -5
mkfifo_main                                           82      77      -5
evalsubshell                                         152     147      -5
typecmd                                               75      69      -6
letcmd                                                61      55      -6
add_cmd                                             1190    1183      -7
main                                                 891     883      -8
ash_main                                            1415    1407      -8
parse_stream                                        1377    1367     -10
alloc_procps_scan                                     55       -     -55
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 7/21 up/down: 54/-148)          Total: -94 bytes
   text    data     bss     dec     hex filename
 797195     658    7428  805281   c49a1 busybox_old
 797101     658    7428  805187   c4943 busybox_unstripped
2008-03-17 09:00:54 +00:00
Denis Vlasenko a55bd05f3c fsck: shrink (we were passing around some params which were unused)
function                                             old     new   delta
fsck_main                                           1807    2256    +449
fsck_device                                          196     189      -7
create_fs_device                                     131     124      -7
wait_one                                             325     309     -16
wait_many                                             52      33     -19
free_instance                                         38       -     -38
packed_usage                                       23698   23650     -48
execute                                             2508    2402    -106
check_all                                            609       -    -609
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/6 up/down: 449/-850)         Total: -401 bytes
   text    data     bss     dec     hex filename
 797604     658    7428  805690   c4b3a busybox_old
 797195     658    7428  805281   c49a1 busybox_unstripped
2008-03-17 08:59:19 +00:00
Denis Vlasenko 397de617f3 help text: regularize format, and shrink
getty: shrink, and improve comments
mount: OPT_ALL is superfluous, we already have OPT_a

function                                             old     new   delta
bcode                                                 47      25     -22
getty_main                                          2503    2349    -154
packed_usage                                       23928   23698    -230
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-406)           Total: -406 bytes
   text    data     bss     dec     hex filename
 798031     658    7428  806117   c4ce5 busybox_old
 797604     658    7428  805690   c4b3a busybox_unstripped
2008-03-17 08:55:44 +00:00
Denis Vlasenko a4522c5a66 mount: plug a hole where FEATURE_MOUNT_HELPERS could allow execution
of arbitrary command.

function                                             old     new   delta
mount_it_now                                         266     309     +43
2008-03-17 08:46:43 +00:00
Denis Vlasenko afc4113ed7 fuser: bugfixes and shrink. It was assuming that xmalloc zeroes returned area!
function                                             old     new   delta
scan_dir_links                                         -     106    +106
add_inode                                              -      89     +89
scan_link                                              -      78     +78
file_to_dev_inode                                      -      64     +64
search_dev_inode                                       -      63     +63
add_pid                                                -      39     +39
packed_usage                                       23948   23928     -20
fuser_add_pid                                         49       -     -49
fuser_file_to_dev_inode                               64       -     -64
fuser_search_dev_inode                                77       -     -77
fuser_scan_link                                       91       -     -91
fuser_scan_dir_links                                 108       -    -108
fuser_add_inode                                      124       -    -124
fuser_main                                          1450    1243    -207
------------------------------------------------------------------------------
(add/remove: 6/6 grow/shrink: 0/2 up/down: 439/-740)         Total: -301 bytes
   text    data     bss     dec     hex filename
 798327     658    7428  806413   c4e0d busybox_old
 797988     658    7428  806074   c4cba busybox_unstripped
2008-03-17 08:44:58 +00:00
Denis Vlasenko cdf62770af dos2unix: tiny shrink
login,su: fix setup_environment() so that it works as intended
          (parameter names were a bit misleading)
fdisk: shrink
help text: shrink

function                                             old     new   delta
login_main                                          1658    1701     +43
setup_environment                                    206     203      -3
dos_compatible_flag                                    4       1      -3
dos2unix_main                                        383     375      -8
get_boot                                            1724    1702     -22
fdisk_main                                          2949    2889     -60
packed_usage                                       24250   23948    -302
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/6 up/down: 43/-398)          Total: -355 bytes
   text    data     bss     dec     hex filename
 798768     661    7428  806857   c4fc9 busybox_old
 798327     658    7428  806413   c4e0d busybox_unstripped
2008-03-17 08:42:43 +00:00
Denis Vlasenko 107fe7c081 less: improve search when data is not supplied fast enough by stdin -
now will try reading for 1-2 seconds before declaring that there is no match.
This fixes a very common annoyance with long manpages.

function                                             old     new   delta
read_lines                                           653     719     +66
buffer_down                                           28      83     +55
goto_match                                           140     141      +1
cap_cur_fline                                         72       -     -72
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 3/0 up/down: 122/-72)            Total: 50 bytes
   text    data     bss     dec     hex filename
 798734     661    7428  806823   c4fa7 busybox_old
 798768     661    7428  806857   c4fc9 busybox_unstripped
2008-03-17 08:38:45 +00:00
Denis Vlasenko aefed941c2 tcpsvd,udpsvd: make them NOMMU-capable
inetd: make udp nowait work

function                                             old     new   delta
inetd_main                                          1797    2036    +239
tcpudpsvd_main                                      1839    1973    +134
xsetenv_plain                                          -      39     +39
xsetenv_proto                                         23      40     +17
bump_nofile                                          169     170      +1
sig_term_handler                                      72      69      -3
sig_child_handler                                    239     233      -6
connection_status                                     37      31      -6
parse_one_line                                      1102    1092     -10
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 4/4 up/down: 430/-25)           Total: 405 bytes
   text    data     bss     dec     hex filename
 798437     661    7428  806526   c4e7e busybox_old
 798734     661    7428  806823   c4fa7 busybox_unstripped
2008-03-17 08:35:44 +00:00
Denis Vlasenko 9f153f610f fsck_minix: getopt32-ification; code shrink; reduce stack usage;
fix bug in map_block2: s/(blknr >= 256 * 256)/(blknr < 256 * 256)/

function                                             old     new   delta
get_inode_common                                       -     291    +291
add_zone_common                                        -     205    +205
ask                                                  229     215     -14
write_super_block                                    109      90     -19
write_block                                          653     629     -24
bad_zone                                              95      64     -31
read_block                                           241     198     -43
fsck_minix_main                                     3285    3195     -90
add_zone2                                            217      34    -183
add_zone                                             216      33    -183
recursive_check                                     1097     866    -231
recursive_check2                                    1340     956    -384
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/10 up/down: 496/-1202)       Total: -706 bytes
   text    data     bss     dec     hex filename
 799349     661    7428  807438   c520e busybox_old
 798437     661    7428  806526   c4e7e busybox_unstripped
2008-03-17 08:32:26 +00:00
Denis Vlasenko 3f165fa5b3 libbb: introduce and use sigprocmask_allsigs and sigaction_set.
libbb: rename sig_pause to wait_for_any_sig.
2008-03-17 08:29:08 +00:00
Denis Vlasenko 8e2cfec1cd libbb: introduse and use signal_[no_]SA_RESTART_empty_mask and sigaction_set
signal_SA_RESTART_empty_mask                           -      65     +65
signal_no_SA_RESTART_empty_mask                        -      54     +54
dd_main                                             1325    1369     +44
sigaction_set                                          -      19     +19
dname_enc                                            373     377      +4
UNSPEC_print                                          64      66      +2
setsignal                                            296     294      -2
bb_signals_recursive                                  95      92      -3
bb_askpass                                           367     361      -6
inetd_main                                          1810    1797     -13
rx_main                                              912     883     -29
sigdelset                                             32       -     -32
__sigdelset                                           32       -     -32
__GI_sigdelset                                        32       -     -32
sighup_handler                                        84      37     -47
arping_main                                         1844    1797     -47
fsck_main                                           1869    1807     -62
run_list                                            1917    1844     -73
vlock_main                                           492     409     -83
progressmeter                                        883     798     -85
handle_incoming_and_exit                            2737    2651     -86
------------------------------------------------------------------------------
(add/remove: 3/3 grow/shrink: 3/12 up/down: 188/-632)        Total: -444 bytes
2008-03-12 23:19:35 +00:00
Denis Vlasenko 4cf1d08fc2 nc: remove a bit of bloat
inetd: more NOMMU fixes
rx: shrink
devfsd: minor shrink
vlock: shrink
tcpudp: narrow down window where we have no wildcard socket

parse_one_line                                      1015    1102     +87
init_ring                                              -      53     +53
xzalloc_lsa                                            -      48     +48
read_byte                                             51      50      -1
rearm_alarm                                           28      25      -3
nc_main                                             1028    1000     -28
initring                                              53       -     -53
vlock_main                                           583     496     -87
reread_config_file                                  1089     991     -98
rx_main                                             1046     912    -134
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 1/6 up/down: 188/-404)         Total: -216 bytes
   text    data     bss     dec     hex filename
 800120     661    7428  808209   c5511 busybox_old
 799796     661    7428  807885   c53cd busybox_unstripped
2008-03-12 23:13:50 +00:00
Denis Vlasenko 4e6d5117b8 inetd: make it NOMMU-capable and IPv6-friendly. Lots of renames
of variable/function names

Total: -2474 bytes
   text    data     bss     dec     hex filename
 802215     661    7452  810328   c5d58 busybox_old
 800120     661    7428  808209   c5511 busybox_unstripped
2008-03-12 22:14:34 +00:00
Denis Vlasenko 4e6c8120a5 crond: make it NOMMU-capable
function                                             old     new   delta
safe_setenv4                                           -      62     +62
ForkJob                                              472     511     +39
change_identity                                       21      57     +36
ParseField                                           564     571      +7
SynchronizeDir                                       178     176      -2
LogLevel                                               4       -      -4
LogFile                                                4       -      -4
FileBase                                               4       -      -4
DebugOpt                                               4       -      -4
CDir                                                   4       -      -4
DeleteFile                                           141     132      -9
packed_usage                                       24248   24228     -20
crondlog                                             157     113     -44
change_identity_e2str                                 54       -     -54
SynchronizeFile                                      729     671     -58
crond_main                                          1555    1404    -151
------------------------------------------------------------------------------
(add/remove: 1/6 grow/shrink: 3/6 up/down: 144/-358)         Total: -214 bytes
2008-03-12 22:10:25 +00:00
Paul Fox 35e9c5d83a fixups to vi usage, and move the initial redraw() past the
execution of commands supplied by -c or EXINIT, so their
effect is displayed correctly.
2008-03-06 16:26:12 +00:00
Paul Fox c51fc7bed6 fixed the "dot" (i.e. '.') command, to properly re-init its
buffer between commands, not recalculate its length all the time,
and to not reallocate its fixed-length buffer frequently.

fixed the 'c', 'd', and 'y' commands to properly handle both motions
that are just part of a line, and those that are multiline.  for
instance, now "c%" and "2cw" work correctly, whether the motions span
lines or not.

added some permissble motions for 'c', 'd', and 'y':  namely 'h',
'l', SPACE, BS, and DEL
2008-03-06 01:34:23 +00:00
Paul Fox b4a5087ee0 define DEBUG as 0, for when ENABLE_FEATURE_DEVPTS is not on. 2008-03-05 22:01:45 +00:00
Paul Fox 4917c11432 fix vi's '?' and '/' commands to correctly set a new direction
when reusing a previous search pattern.  previously only 'n' and 'N'
reversed directions properly.
2008-03-05 16:44:02 +00:00
Denis Vlasenko a43dba76ea msh: create testsuite (based on hush one)
hush: add TODO (doesn't know ":" command)
2008-03-02 19:57:53 +00:00
Denis Vlasenko 444639cc21 unlzma: save a few more bytes, and maybe even a bit faster now 2008-03-02 18:56:23 +00:00
Denis Vlasenko c3fff877e1 unlzma: if !LZMA_FAST, save ~200 more bytes (Pascal Bellard <pascal.bellard AT ads-lu.com>) 2008-03-02 18:55:49 +00:00
Denis Vlasenko 4aafd5f4e3 msh: a few fields renamed; short->int conversion for a field
holding file descriptors; short->smalling for flag field

synio                                                263     264      +1
readc                                                247     242      -5
forkexec                                            1339    1307     -32
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 1/-37)             Total: -36 bytes
2008-03-02 14:33:26 +00:00
Denis Vlasenko d18f52bd18 actually add bb_qsort.c
*: s/Denis/Denys/
2008-03-02 12:53:15 +00:00
Denis Vlasenko fb29038b59 libbb: inntroduce and use bb_pstrcmp() and qsort_string_vector()
msh: glob0/glob1/glob2/glob3 are just a sorting routine! remove them.

bb_pstrcmp                                             -      25     +25
qsort_string_vector                                    -      24     +24
expand                                              2209    2227     +18
getopt32                                            1359    1370     +11
passwd_main                                         1072    1074      +2
handle_incoming_and_exit                            2737    2735      -2
UNSPEC_print                                          66      64      -2
forkexec                                            1343    1339      -4
input_tab                                           3338    3330      -8
get_dir                                              185     177      -8
expmeta                                              481     473      -8
cmdputs                                              405     397      -8
xstrcmp                                               12       -     -12
find_pair                                            187     167     -20
match_compare                                         25       -     -25
dir_strcmp                                            25       -     -25
glob2                                                 27       -     -27
glob3                                                 34       -     -34
glob1                                                256       -    -256
------------------------------------------------------------------------------
(add/remove: 2/6 grow/shrink: 3/8 up/down: 80/-439)          Total: -359 bytes
2008-03-02 12:51:26 +00:00
Denis Vlasenko 509697f00d msh: renames: ->words => ->op_words, space() => get_space()
msh: simplify glob0/glob1/glob2/glob3

get_space                                              -      26     +26
glob3                                                 35      34      -1
glob2                                                 28      27      -1
strsave                                               55      53      -2
globv                                                  4       -      -4
func                                                   4       -      -4
xstrcmp                                               25      12     -13
dodot                                                178     164     -14
rexecve                                              272     257     -15
space                                                 26       -     -26
glob1                                                292     256     -36
expand                                              2246    2209     -37
------------------------------------------------------------------------------
(add/remove: 1/3 grow/shrink: 0/8 up/down: 26/-153)          Total: -127 bytes
2008-03-02 12:49:39 +00:00
Denis Vlasenko da8ae75340 doc: add info about sed s/.../.../I modifier 2008-03-01 19:29:56 +00:00
Denis Vlasenko fe2188378c msh: fix for bug 846 ("break" didn't work second time)
msh: don't use floating point in "times" builtin
+4 bytes difference
2008-03-01 09:35:39 +00:00
Denis Vlasenko 8a2e421f26 nmeter: fix bug where %[mf] behaves as %[mt] 2008-02-29 07:46:19 +00:00
Denis Vlasenko 19fb67eee4 run-parts: add --reverse 2008-02-28 21:30:22 +00:00
Denis Vlasenko b29028e351 zcip: chdiring to root when daemonizing is not useful,
only makes strip writer's life more miserable. Who want
to have zcip run in root dir, can trivially do that.
2008-02-28 18:02:23 +00:00
Denis Vlasenko f39c7c0c86 sed: n cmd must reset "we had successful subst" flag. closes bug 1214. 2008-02-28 17:59:01 +00:00
Denis Vlasenko cd174d1f31 microcom: shrink 2008-02-28 13:14:42 +00:00
Denis Vlasenko 32fd76c1d5 script: correctly handle buffered "tail" of output. +35 bytes. 2008-02-28 10:10:10 +00:00
Bernhard Reutner-Fischer 93e1a215af - Don't point to obsolete patches but the current fixes for the stable releases 2008-02-27 21:42:13 +00:00
Bernhard Reutner-Fischer 3444bd4fc2 - update docs to point to the current stable branch 2008-02-27 21:28:02 +00:00
Bernhard Reutner-Fischer 51f421a55c - fix compilation failure due to implicit decl of resolve_mount_spec().
DCE DTRT so remove the wrong guard.
2008-02-27 21:14:52 +00:00
Denis Vlasenko 1acb4ef87e httpd: fix breakage introduced by "support for I:index.xml" 2008-02-27 20:59:54 +00:00
Denis Vlasenko 574f2f4394 *: add optimization barrier to all "G trick" locations 2008-02-27 18:41:59 +00:00
Denis Vlasenko fe66a0eca1 lpr: removed stdio; added "job received" message in verbose mode. 2008-02-27 14:35:21 +00:00
Denis Vlasenko c8f2f74ddd libbb: add forgotten part of "script" applet change 2008-02-27 14:33:28 +00:00
Denis Vlasenko 5014dada3f script: new applet by Pascal Bellard <pascal.bellard AT ads-lu.com> 2008-02-27 11:54:59 +00:00
Denis Vlasenko 8195d20e36 sendmail: yet another maintainer's update 2008-02-27 09:39:04 +00:00
Denis Vlasenko 17db1a9ac1 sendmail: update from maintainer 2008-02-26 21:13:17 +00:00
Denis Vlasenko 7be1030dcc lpr: fflush stdout fix 2008-02-26 20:23:02 +00:00
Denis Vlasenko be048f21e6 syslogd: optional support for dropping dups. closes bug 436. 2008-02-26 20:13:52 +00:00
Denis Vlasenko 06aed4316e ifenslave: new applet. closes bug 115. 2008-02-26 18:25:24 +00:00
Denis Vlasenko 04bb2d2d06 start_stop_daemon: stop using data/bss
function                                             old     new   delta
start_stop_daemon_main                               749     770     +21
do_procinit                                          184     185      +1
quiet                                                  1       -      -1
userspec                                               4       -      -4
user_id                                                4       -      -4
signal_nr                                              4       -      -4
pidfile                                                4       -      -4
found                                                  4       -      -4
execname                                               4       -      -4
cmdname                                                4       -      -4
------------------------------------------------------------------------------
(add/remove: 0/8 grow/shrink: 2/0 up/down: 22/-29)             Total: -7 bytes
2008-02-26 16:08:02 +00:00
Denis Vlasenko d4f0b9476a reset: call "stty sane". Closes bug 1414.
reset_main                                            26      59     +33
static.args                                            -      12     +12
2008-02-26 15:33:10 +00:00
Denis Vlasenko d686482d05 actually add libbb/safe_gethostname.c 2008-02-25 23:24:32 +00:00
Denis Vlasenko 6f1713f216 *: intrduce and use safe_gethostname. By Tito <farmatito AT tiscali.it>
safe_gethostname                                       -      48     +48
glob3                                                 35      37      +2
timestamp_and_log                                    314     315      +1
udhcp_send_kernel_packet                             234     231      -3
scan_tree                                            275     271      -4
passwd_main                                         1074    1070      -4
print_login_prompt                                    68      58     -10
obscure                                              392     377     -15
syslogd_main                                         882     866     -16
print_login_issue                                    516     478     -38
hostname_main                                        278     223     -55
parse_and_put_prompt                                 825     756     -69
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/9 up/down: 51/-214)          Total: -163 bytes
   text    data     bss     dec     hex filename
 798791     728    7484  807003   c505b busybox_old
 798631     728    7484  806843   c4fbb busybox_unstripped
2008-02-25 23:23:58 +00:00
Denis Vlasenko 394eebed66 lpd: spool mode added by Vladimir
lpr: more robust error reporting
*: introduce and use xchroot
libbb: full_read/write now will report partial data counts prior to error
isdirectory.c: style fixes

lpd_main                                             249     486    +237
xchroot                                                -      29     +29
get_response_or_say_and_die                          110     139     +29
full_write                                            52      60      +8
full_read                                             55      63      +8
static.newline                                         1       -      -1
switch_root_main                                     404     400      -4
chpst_main                                          1089    1079     -10
getopt32                                            1370    1359     -11
chroot_main                                          115     101     -14
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 4/4 up/down: 311/-40)           Total: 271 bytes
   text    data     bss     dec     hex filename
 798472     728    7484  806684   c4f1c busybox_old
 798775     728    7484  806987   c504b busybox_unstripped
2008-02-25 20:30:24 +00:00
Denis Vlasenko 38b8831b32 lpd: now with "svn add"... 2008-02-25 14:48:15 +00:00
Denis Vlasenko f99afb5dff lpd: new applet by Vladimir Dronnikov <dronnikov AT gmail.com> 2008-02-24 23:32:36 +00:00
Denis Vlasenko a2f47358eb forgotten bit of rmdir long options support 2008-02-24 22:45:04 +00:00
Denis Vlasenko 6d8112cc24 fix typo in comment, no code changes 2008-02-24 22:08:57 +00:00
Denis Vlasenko 8f8a420f12 lpr: fixing vda's thinko 2008-02-24 19:22:25 +00:00
Denis Vlasenko b78d1c045f less: shrink 2008-02-24 19:18:18 +00:00
Denis Vlasenko 4f82bdb050 lpr,lpq: rework by dronnikov AT gmail.com 2008-02-24 18:44:20 +00:00
Denis Vlasenko 52feee9b1f rmdir: optional long options support for Debian users. +68 bytes.
By Roberto Gordo Saez <roberto.gordo AT gmail.com>
2008-02-24 14:56:10 +00:00
Denis Vlasenko 28b29916cb watch: shrink (by walter harms <WHarms AT bfs.de>)
watch_main                                           327     263     -64
2008-02-24 14:33:17 +00:00
Denis Vlasenko 400d8bb45e less,klogd,syslogd,nc,tcpudp: exit on signal by killing itself, not exit(1)
*: minor shrink
2008-02-24 13:36:01 +00:00
Denis Vlasenko d553faf5a5 less: small shrink 2008-02-23 12:22:17 +00:00
Denis Vlasenko a7259b64e8 syslogd: small shrink 2008-02-23 12:08:36 +00:00
Denis Vlasenko d2172c04e6 less: make it a bit more resistant against statusline corruption.
less: "examine" command will not bomb out on bad file name now

less_main                                           1663    1694     +31
examine_file                                          87     114     +27
less_getch                                           138     160     +22
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 80/0)               Total: 80 bytes
   text    data     bss     dec     hex filename
 798368     740    7484  806592   c4ec0 busybox_old
 798470     740    7484  806694   c4f26 busybox_unstripped
2008-02-23 11:54:37 +00:00
Denis Vlasenko 33196372be less: update line input so that it doesn't interfere with
screen update. Makes "man bash", [enter], [/],
<enter search pattern>, [enter] more usable - manpage
draws as you enter the pattern! Yay!!
less: fix bug where backspace wasn't actually deleting chars
less: "examine file with empty name" doesn't abort anymore.
libbb: add "all fatal signals" mask.

getch_nowait                                           -     207    +207
status_print                                           -     105    +105
examine_file                                          64      87     +23
move_cursor                                            -      16     +16
m_status_print                                       185     195     +10
less_main                                           1656    1663      +7
decode_format_string                                 790     795      +5
test_main                                            403     405      +2
process0_stdin                                       247     249      +2
passwd_main                                         1070    1072      +2
less_gets                                            196     178     -18
buffer_print                                         169      71     -98
less_getch                                           362     138    -224
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 7/3 up/down: 379/-340)           Total: 39 bytes
   text    data     bss     dec     hex filename
 798329     740    7484  806553   c4e99 busybox_old
 798368     740    7484  806592   c4ec0 busybox_unstripped
2008-02-23 01:25:38 +00:00
Denis Vlasenko 86620756d2 lpr: document options better 2008-02-22 23:21:31 +00:00
Denis Vlasenko 32b2a9fd6a small code readability and typo fixes 2008-02-22 22:43:22 +00:00
Denis Vlasenko 68444b9f0c lpr and lpq applets by Walter Harms.
text    data     bss     dec     hex filename
    392       0       0     392     188 lpq.o
   1378       0       0    1378     562 lpr.o
    142       0       0     142      8e parse_prt.o
2008-02-22 22:24:48 +00:00
Denis Vlasenko 6aa74fcf5b ash: s/ckzmalloc/ckzalloc/ 2008-02-21 04:35:14 +00:00
Denis Vlasenko 838ffd5be2 ash: sprinkle a bit more of zeroed allocations. 2008-02-21 04:32:08 +00:00
Denis Vlasenko 2f518b078b httpd: "HEAD" support. Closes bug 1530.
send_file_and_exit                                   629     645     +16
static.request_HEAD                                    -       5      +5
handle_incoming_and_exit                            2732    2737      +5
send_headers                                         594     597      +3
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 3/0 up/down: 29/0)               Total: 29 bytes
   text    data     bss     dec     hex filename
 796283     740    7484  804507   c469b busybox_old
 796312     740    7484  804536   c46b8 busybox_unstripped
2008-02-21 00:12:07 +00:00
Denis Vlasenko 081efd1232 corrected English in comment 2008-02-20 22:57:24 +00:00
Denis Vlasenko a523e2efad udhcp: we were forgetting to set right op byte in tha packet
for DHCPDECLINE. Fixing, and making code smaller.
2008-02-20 22:33:38 +00:00
Denis Vlasenko 84da0bf475 udhcp: make paths configurable
syslogd: trivial build fix
2008-02-20 22:29:52 +00:00
Denis Vlasenko e376d454bb libbb: introduce and use nonblock_safe_read(). Yay!
Our shells are immune from this nasty O_NONBLOCK now!

function                                             old     new   delta
nonblock_safe_read                                     -      78     +78
file_get                                             276     295     +19
generateMTFValues                                    428     435      +7
read_line_input                                     1776    1772      -4
preadbuffer                                          543     450     -93
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 104/-97)             Total: 7 bytes
   text    data     bss     dec     hex filename
 615190     715   23924  639829   9c355 busybox_old
 615168     715   23924  639807   9c33f busybox_unstripped
2008-02-20 22:23:24 +00:00
Mike Frysinger ae86a338b8 [#1334] exec script for devices even if they dont have device nodes 2008-02-20 18:31:36 +00:00
Denis Vlasenko 597906c436 ash: introduce and use stzalloc and ckzalloc.
function                                             old     new   delta
stzalloc                                               -      29     +29
ckzalloc                                               -      29     +29
recordregion                                         108     102      -6
cmdlookup                                            158     152      -6
pipeline                                             188     181      -7
parseheredoc                                         135     128      -7
makename                                              42      35      -7
list                                                 355     348      -7
setvareq                                             221     212      -9
aliascmd                                             324     311     -13
pushfile                                              83      69     -14
readtoken1                                          2872    2849     -23
parse_command                                       1430    1391     -39
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 0/11 up/down: 58/-138)          Total: -80 bytes
   text    data     bss     dec     hex filename
 577227     706   23740  601673   92e49 busybox_old
 577147     706   23740  601593   92df9 busybox_unstripped
2008-02-20 16:38:54 +00:00
Denis Vlasenko e7b43cf59f trivial fixes to config system 2008-02-19 23:42:22 +00:00
Denis Vlasenko c12d51e94e ash: fix fallout from "A=1 B=$A; echo $B" code. 2008-02-19 23:31:05 +00:00
Denis Vlasenko 624188aec0 microcom: tiny shrink, adding comments 2008-02-19 18:26:40 +00:00
Denis Vlasenko 671ca33aa1 init: make it NOMMU-capable
httpd: trivial compile fix
2008-02-19 14:13:20 +00:00
Denis Vlasenko a58a637bed init: fix comments 2008-02-19 12:10:18 +00:00
Denis Vlasenko 99a61842df init: HUP should not be temporarily set to "restart",
we use it for config reload, and we have QUIT for "restart".
2008-02-19 12:08:38 +00:00
Denis Vlasenko 8617454027 fix chat CONFIG_xxx dependencies 2008-02-19 11:36:22 +00:00
Denis Vlasenko e93550866b chat: now with "svn add" 2008-02-19 11:35:08 +00:00
Denis Vlasenko 53ce7f0d71 findfs,mount: trivial build fix and whitespace fiexs 2008-02-19 11:29:46 +00:00
Denis Vlasenko 431a7c9c53 tar: optional autodetection of gz/bz2 compressed tarballs.
+130 bytes. Closes bug 992.
2008-02-19 11:26:28 +00:00
Denis Vlasenko a37e7134f7 init: fix bug 1111: restart actions were not splitting words:
::restart:/sbin/rc restart
resulted in:
exec of '/sbin/rc restart' failed: No such file or directory
2008-02-19 02:57:07 +00:00
Denis Vlasenko 92657d484f syslogd: tighten up hostname handling. 2008-02-19 01:10:20 +00:00
Denis Vlasenko e8419c90f1 tail: fix "tail -c 20 /dev/huge_disk" (was taking ages)
tail: a few variables renamed
wc: tiny optimization.
2008-02-19 00:38:10 +00:00
Denis Vlasenko 5233cd3800 chat: new applet by dronnikov AT gmail.com. With all options on:
function                                             old     new   delta
chat_main                                              -    1230   +1230
unescape                                               -     135    +135
packed_usage                                       23802   23922    +120
signal_handler                                       123     131      +8
input_backward                                       123     128      +5
applet_names                                        1775    1780      +5
applet_main                                         1076    1080      +4
applet_nameofs                                       538     540      +2
exitcode                                               -       1      +1
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 6/0 up/down: 1510/0)           Total: 1510 bytes
2008-02-18 23:24:46 +00:00
Denis Vlasenko 6f04391cec lineedit: tiny shrink 2008-02-18 22:28:03 +00:00
Denis Vlasenko de7684a309 support for mount by label (not yet tested)
Also adds findfs applet. Closes bug 1143.
2008-02-18 21:08:49 +00:00
Bernhard Reutner-Fischer 27dd495b98 - fix open(creat) without a mode 2008-02-18 18:35:53 +00:00
Denis Vlasenko b4133683a4 mount: with -vv -f, say what mount() calls we were going to make
782357     728    7476  790561   c1021 busybox_old
 782429     728    7476  790633   c1069 busybox_unstripped
2008-02-18 13:05:38 +00:00
Denis Vlasenko f732e96757 mount: optional support for -vv verbosity
mount: do "struct globals" trick

With -vv on:

function                                             old     new   delta
verbose_mount                                          -      83     +83
mount_main                                           970     988     +18
mount_it_now                                         219     229     +10
singlemount                                         4564    4570      +6
mount_option_str                                     227     233      +6
nfs_mount_version                                      1       -      -1
fslist                                                 4       -      -4
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 4/0 up/down: 123/-5)            Total: 118 bytes
2008-02-18 12:07:49 +00:00
Denis Vlasenko c9ca0a3274 mount: recognize "dirsync" (closes bug 835)
mount: sanitize environ if called by non-root
*: adjust for slightly different sanitize routine
2008-02-18 11:08:33 +00:00
Denis Vlasenko 56244736ec whitespace fixes 2008-02-17 15:14:04 +00:00
Denis Vlasenko 542963685c dos2unix: shrink
bloatcheck for last four commits:
function                                             old     new   delta
xrename                                                -      38     +38
md5_hash_block                                       437     458     +21
sv_main                                             1237    1254     +17
update_status                                        569     580     +11
decode_format_string                                 795     805     +10
doset                                                317     326      +9
passwd_main                                         1070    1074      +4
sha1_compile                                         447     446      -1
rename_or_warn                                        49      47      -2
fill_bounds                                          174     172      -2
buffer_fill_and_print                                 76      73      -3
bb_perror_nomsg                                        9       -      -9
get_next_block                                      1810    1795     -15
patch_main                                          1107    1085     -22
write_status_file                                   1123    1077     -46
remove                                                52       -     -52
__GI_remove                                           52       -     -52
open_as_user                                         171     111     -60
microcom_main                                        811     747     -64
dos2unix_main                                        452     383     -69
------------------------------------------------------------------------------
(add/remove: 1/3 grow/shrink: 6/10 up/down: 110/-397)        Total: -287 bytes
2008-02-17 14:31:50 +00:00
Denis Vlasenko 03b4c14bd4 crontab: stop using remove() - use unlink() instead 2008-02-17 14:30:03 +00:00
Denis Vlasenko b3b0753593 dpkg: fix bug where existence check was reversed 2008-02-17 14:29:25 +00:00
Denis Vlasenko cb448fe01b libbb: introduce and use xrename and rename_or_warn. 2008-02-17 14:28:53 +00:00
Denis Vlasenko ffae845cfd microcom: maintainer update 2008-02-16 23:40:47 +00:00
Denis Vlasenko b1d8e7db0f mount: make -f work even without mtab support
(Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>)
2008-02-16 23:28:42 +00:00
Denis Vlasenko 25591c322c libbb: introduce bb_signals and bb_signals_recursive,
which sets same handler for many signals. sig_catch is nuked
(bb_signals_recursive is more descriptive name).
*: use them as appropriate. 

function                                             old     new   delta
bb_signals_recursive                                   -      95     +95
bb_signals                                             -      52     +52
run_command                                          258     273     +15
svlogd_main                                         1368    1377      +9
runsv_main                                          1746    1752      +6
runsvdir_main                                       1643    1646      +3
UNSPEC_print                                          64      66      +2
time_main                                           1128    1127      -1
...
resize_main                                          246     210     -36
sig_catch                                             63       -     -63
set_fatal_sighandler                                  85      14     -71
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 5/24 up/down: 182/-548)        Total: -366 bytes
2008-02-16 22:58:56 +00:00
Denis Vlasenko 7fc294cdfe crontab: clear env if run by non-root, so that we can use PATH now
crontab: make "-c /tmp/ -e" work
2008-02-16 13:47:57 +00:00
Denis Vlasenko 3718832a15 *: more readable handling of pipe fds. No code changes. 2008-02-16 13:20:56 +00:00
Denis Vlasenko 1e18f1bab3 ifupdowm: shrink
ifupdown_main                                       2170    2459    +289
find_iface_state                                      57      56      -1
next_word                                             63      58      -5
popen2                                               350       -    -350
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/2 up/down: 289/-356)          Total: -67 bytes
2008-02-16 13:19:19 +00:00
Denis Vlasenko 284d0faed6 random s/short/int/
add_cmd                                             1189    1190      +1
xconnect_ftpdata                                     118     117      -1
data_align                                            86      84      -2
process_files                                       2101    2096      -5
forkexec                                            1345    1334     -11
2008-02-16 13:18:17 +00:00
Denis Vlasenko 069e347863 crontab: almost complete rewrite
crontab: make options consistent with other implementations

   text    data     bss     dec     hex filename
   2042       4       0    2046     7fe busybox.t1/miscutils/crontab.o
   1331       0       0    1331     533 busybox.t2/miscutils/crontab.o

function                                             old     new   delta
edit_file                                            733     956    +223
open_as_user                                           -     171    +171
packed_usage                                       23652   23650      -2
CDir                                                   8       4      -4
ChangeUser                                           139       -    -139
crontab_main                                        1522     616    -906
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/3 up/down: 394/-1051)        Total: -657 bytes
2008-02-16 13:17:13 +00:00
Denis Vlasenko cd5c61cd3b ifupdown: code shrink
function                                             old     new   delta
next_word                                             78      63     -15
ifupdown_main                                       2381    2170    -211
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-226)           Total: -226 bytes
2008-02-15 16:20:26 +00:00
Denis Vlasenko 753f42ab8d adduser: optional support for long options. +110 bytes.
closes bug 2134.
2008-02-15 15:17:23 +00:00
Denis Vlasenko 0e6f661e23 ash: handle "A=1 A=2 B=$A; echo $B". closes bug 947. 2008-02-15 15:02:15 +00:00
Mike Frysinger 977bc6a137 we need to pass back the rtc device name that was actually used so that we can turn around and check its sysfs status 2008-02-15 07:19:03 +00:00
Mike Frysinger ea915363e7 fix build failure when long opts are enabled 2008-02-15 02:33:22 +00:00
Mike Frysinger 6b160e490d split some rtc funcs out of hwclock and into an rtc header/lib so that the new rtcwake applet as well as hwclock can utilize the same code 2008-02-15 02:27:19 +00:00
Mike Frysinger be7d2a8ded sendmail is lexically after selinux, so fix the order 2008-02-15 01:43:22 +00:00
Mike Frysinger 25cd7fd702 add a test case for usage strings to catch people forgetting to add trailing escape in middle of usage 2008-02-15 01:42:28 +00:00
Mike Frysinger 1e47c429bf fix microcom usage 2008-02-15 01:34:14 +00:00
Denis Vlasenko e00e5025ec tar: real support for -p. +200 if selected.
By Natanael Copa <natanael.copa at gmail.com>
2008-02-14 20:37:54 +00:00
Denis Vlasenko 39487e2d6a libbb: filename completion should match dangling symlinks too 2008-02-14 19:55:58 +00:00
Denis Vlasenko 94e87bc83d ash: explain why "set -o BOGUS" doesn't abort 2008-02-14 16:51:58 +00:00
Denis Vlasenko 28bf671d6d ash: make ash -c 'if set -o barfoo 2>/dev/null; then echo foo; else echo bar; fi' work
(fixes bug 1142)

function                                             old     new   delta
options                                              551     565     +14
ash_main                                            1397    1411     +14
setcmd                                                77      90     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 41/0)               Total: 41 bytes
2008-02-14 15:01:47 +00:00
Denis Vlasenko f1d93ec420 build system: pass CFLAGS to link stage too (closes bug 1376) 2008-02-14 12:24:14 +00:00
Denis Vlasenko b2e578a1f2 umount: instead of non-standard -D, use -d with opposite meaning
(closes bug 1604)
umount: do not try to free loop device or erase mtab if remounted ro
umount: do not complain several times about the same mountpoint

function                                             old     new   delta
umount_main                                          646     638      -8
packed_usage                                       23662   23652     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-18)             Total: -18 bytes
2008-02-14 12:00:21 +00:00
Denis Vlasenko 773f6710c1 typo fix 2008-02-14 10:31:18 +00:00
Denis Vlasenko 12c0622231 tar: do "short EOF" compat only if CONFIG_DESKTOP.
ash: add a comment about new minor bug
2008-02-14 08:52:30 +00:00
Paul Fox b5ee8db9b5 add ',' and 'gg' commands (patch from Leo Jay) 2008-02-14 01:17:01 +00:00
Denis Vlasenko 65eb550024 reinstate redir.tests with correct perms 2008-02-13 18:10:46 +00:00
Denis Vlasenko 81887e2342 ash: add a testcase for recently fixed signal bug 2008-02-13 18:09:56 +00:00
Denis Vlasenko 23ffb6a4a2 tar: compat: handle tarballs with only one zero block at the end 2008-02-13 17:52:42 +00:00
Denis Vlasenko 6dd03f04ea switch_root: stop at first non-option. Closes bug 1425. 2008-02-13 17:25:31 +00:00
Denis Vlasenko 87cf2ee8ab tar: move FNM_LEADING_DIR #define to tar.c - no other users.
Closes bug 1332.
2008-02-13 17:06:53 +00:00
Denis Vlasenko d5fe880a57 cp: add ENABLE_FEATURE_VERBOSE_CP_MESSAGE. Closes bug 1470 2008-02-13 16:52:00 +00:00
Denis Vlasenko 9d96af2e83 mkswap: fix help text to not lie about supported options.
mkswap: use uint32, not int, to match kernel.
mkswap: optimization: use pre-zeroed buffer
2008-02-13 15:35:52 +00:00
Denis Vlasenko 3b92eaac53 sort: -z outputs NUL terminated lines. Closes bug 1591. 2008-02-13 14:30:33 +00:00
Denis Vlasenko 75cddd8eb5 syslogd: send '\n'-terminated messages over the network.
fully closes bug 1574. +8 bytes.
2008-02-13 09:19:14 +00:00
Denis Vlasenko 0a4624aece build system: don't use -o /dev/null, old gcc can delete /dev/null! 2008-02-13 07:47:37 +00:00
Denis Vlasenko 59bb4a4f50 website: add direct links to every last stable release tarball 2008-02-12 19:01:34 +00:00
Denis Vlasenko 7c5258b1c4 website: fix English 2008-02-12 18:53:16 +00:00
Denis Vlasenko 3d3d698594 Announce 1.9.1 2008-02-12 17:53:59 +00:00
Denis Vlasenko fee2d0c256 msh: stop trying to parse variables in "msh SCRIPT VAR=val param".
They should be passed as ordinary parameters.
2008-02-12 10:12:18 +00:00
Denis Vlasenko 7e497527ea msh: instead of fixing "ls | cd", "cd | ls" etc just disallow
builtins in pipes. They make no sense there anyway.
msh: shrink umask builtin.

function                                             old     new   delta
execute                                             2508    2509      +1
doset                                                326     317      -9
forkexec                                            1370    1345     -25
doumask                                              165     101     -64
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 1/-98)             Total: -97 bytes
2008-02-12 09:51:03 +00:00
Denis Vlasenko e26b2783a5 ash: fix warning about _GNU_SOURCE being redefined, fix typo in comment. 2008-02-12 07:40:29 +00:00
Denis Vlasenko 648b44fd78 msh: shrink, mainly by using smallints
function                                             old     new   delta
synio                                                251     263     +12
filechar                                             310     315      +5
subgetc                                              781     785      +4
brkcontin                                            106     109      +3
...
yylex                                                981     976      -5
execute                                             2513    2508      -5
waitfor                                              321     315      -6
onintr                                               103      97      -6
doset                                                332     326      -6
doexec                                               186     180      -6
yyparse                                               65      57      -8
thenpart                                             135     126      -9
forkexec                                            1379    1370      -9
onecommand                                           457     433     -24
newtp                                                 52      28     -24
command                                             1086    1061     -25
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 7/23 up/down: 27/-163)         Total: -136 bytes
2008-02-12 06:04:06 +00:00
Denis Vlasenko a5f2cd30c9 msh: do not run pipes where last command is a builtin
msh: code shrink and some renames for better readability
2008-02-11 18:10:06 +00:00
Denis Vlasenko fc21305892 httpd: fix bug where we did chdir("") if CGI path had only one "/".
httpd: fix bug 2004: wrong argv when interpreter is invoked

+8 bytes growth
2008-02-11 16:26:22 +00:00
Bernhard Reutner-Fischer f536b99d26 - shrink a tiny bit (-30Bytes) 2008-02-11 13:26:54 +00:00
Bernhard Reutner-Fischer a985d306a1 - spelling fixes 2008-02-11 11:44:38 +00:00
Denis Vlasenko 83177991c8 hush: die_sllep needs restoring only if job control is on 2008-02-11 08:44:36 +00:00
Denis Vlasenko 08126f665d hush: close-on-exec interactive_fd 2008-02-11 08:39:11 +00:00
Denis Vlasenko 459a5ad410 hush: set CLOEXEC on script file being executed 2008-02-11 08:35:03 +00:00
Denis Vlasenko 4ecfcdcced hush: fix the comment 2008-02-11 08:32:31 +00:00
Denis Vlasenko c04163a289 hush: reset die_sleep to 0 in child after fork 2008-02-11 08:30:53 +00:00
Denis Vlasenko 04e11c9209 getpot: add support for "a+" specifier for nonnegative int parameters.
By Vladimir Dronnikov <dronnikov at gmail.com>.
fdisk and top are converted as an example.

function                                             old     new   delta
getopt32                                            1340    1370     +30
top_main                                            1137    1120     -17
fdisk_main                                          3033    2949     -84
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 30/-101)           Total: -71 bytes
2008-02-10 19:44:20 +00:00
Denis Vlasenko 9304d6ea92 microcom: read more than 1 byte from device, if possible 2008-02-10 19:05:56 +00:00
Denis Vlasenko 991a1da148 ash: fix "orwell bug" 1984. Testcase:
trap_handler() {
        echo trap
    }
    trap trap_handler USR1
    sleep 3600 &
    while true; do wait; done
2008-02-10 19:02:53 +00:00
Denis Vlasenko 0ef240d979 hush: small fixes to docs/testsuite 2008-02-10 16:00:30 +00:00
Denis Vlasenko 05743d7949 hush: reinstate cmd handling for NOMMU (with fat big warning).
hush: fix a case where none of pipe members could be started
  because of fork failure
hush: rename functions: xxx_real -> xxx
hush: try to add a bit more of vfork-friendliness
hush: add rudimentary design docs
hush: add TODO (newly discovered bug with globbing)
2008-02-10 12:10:08 +00:00
Denis Vlasenko 68e8e96d7f microcom: compile fixes 2008-02-09 11:39:00 +00:00
Denis Vlasenko d56e3ccf96 microcom: split -d (delay) option away from -t 2008-02-09 11:37:21 +00:00
Denis Vlasenko 937b10f35d build system: make it do without od -t 2008-02-09 09:26:43 +00:00
Denis Vlasenko 761e1d1462 mktemp: don't advertise -q option 2008-02-09 06:29:32 +00:00
Denis Vlasenko 65581f3ed1 mktemp: support -p DIR (Timo Teras <timo.teras at iki.fi>)
packed_usage                                       23595   23660     +65
mktemp_main                                          139     157     +18
2008-02-09 06:26:53 +00:00
Denis Vlasenko 1e2a7e4ed1 test: fix mishandling of 'test ! arg1 op arg2 more args'; add testsuite 2008-02-09 05:48:42 +00:00
Denis Vlasenko 6d52c1ee24 sendmail: update from maintainer 2008-02-08 18:24:54 +00:00
Denis Vlasenko dc1c45795b microcom: update from maintainer 2008-02-08 17:30:39 +00:00
Denis Vlasenko 97bd0e05cc README: doccument the need of CONFIG_DESKTOP
od: fix help text to include -t
od: handle /proc files (which have filesize 0) correctly
od: fix comments to not lie about return value
od: "%u" is 1 byte less than "%zu"
cat: fix English
2008-02-08 15:41:01 +00:00
Denis Vlasenko 7dbf1b4d9e httpd: add a bit of error logging; a few code simplifications. +29 bytes. 2008-02-08 15:21:55 +00:00
Bernhard Reutner-Fischer afdad653ac - add eject -s for SCSI- and USB-devices (Nico Erfurth) 2008-02-08 15:04:00 +00:00
Mike Frysinger 534b8d0483 force disable setlocalversion usage in busybox 2008-02-07 22:44:27 +00:00
Mike Frysinger 9412ec7555 some more fixes for cross-compiling on an OS X host: apple provides core types so dont redefine them, sys/statfs.h is not available, and only use some newer AF_* defines if they are actually available 2008-02-07 22:41:33 +00:00
Mike Frysinger 22876c797c only include mntent.h according to HAVE_MNTENT_H and dont define this on OS X 2008-02-07 22:10:07 +00:00
Denis Vlasenko b386c1c614 udhcp: ifdef out unused members 2008-02-04 13:23:53 +00:00
Denis Vlasenko d55fe3e595 udhcp: optional support for non-standard DHCP ports (+300 bytes when selected) 2008-02-04 13:12:16 +00:00
Denis Vlasenko e8ef7ec7de unzip: do not try to read entire compressed stream at once (it can be huge)
unzip: handle short reads correctly
2008-02-04 12:12:48 +00:00
Denis Vlasenko f3f33ebb0b zcip: open ARP socket before openlog
(else we can thrash syslog socket)
2008-02-04 09:42:05 +00:00
Denis Vlasenko f8157cafcb nohup: compat patch by Christoph Gysin <mailinglist.cache at gmail.com> 2008-02-04 00:30:06 +00:00
Denis Vlasenko 32d49bc70f mkswap: do not do extra seek
mount: add another mount helper call method
2008-02-03 23:52:41 +00:00
Denis Vlasenko c85bfcad52 ps: fixlet to disabled compat code 2008-02-03 22:04:19 +00:00
Denis Vlasenko 5c3d2b334a ash: readability enhancement, no code changes 2008-02-03 22:01:08 +00:00
Denis Vlasenko 95dc672326 getty: don't try to detect parity on local lines
(Joakim Tjernlund <Joakim.Tjernlund at transmode.se>)
2008-02-02 19:05:36 +00:00
Denis Vlasenko 30eb319103 fsck: don't kill pid -1! (Roy Marples <roy at marples.name>) 2008-02-02 18:54:58 +00:00
Denis Vlasenko 6e602c4931 msh: also handle EOF/read errors correctly 2008-02-02 18:50:50 +00:00
Denis Vlasenko 80667e30fb msh: fix Ctrl-C handling with line editing 2008-02-02 18:35:55 +00:00
Denis Vlasenko a2980c6249 sendmail: fixes by Vladimir Dronnikov <dronnikov at gmail.com> 2008-02-02 17:54:35 +00:00
Denis Vlasenko 5de754a395 ps: add (disabled) compat code 2008-02-02 16:43:51 +00:00
Denis Vlasenko 7cff01ec2d nc: fix fallout from C99 standard compliance change 2008-02-02 16:23:43 +00:00
Paul Fox 0b2b5842a1 Fix compilation error when FEATURE_FANCY_PING enabled. Also
reorder networking/Config.in moving FEATURE_FANCY_PING next to
PING6.  (Cristian Ionescu-Idbohrn)
2008-02-01 23:25:32 +00:00
Mike Frysinger f0044c480c add support for renaming/relocating device nodes 2008-02-01 06:53:50 +00:00
Mike Frysinger c348e0bc7b add a mini-faq about std{in,out,err} 2008-02-01 01:41:57 +00:00
Bernhard Reutner-Fischer 8c69afd992 - be C99 friendly. Anonymous unions are a GNU extension. This change is
size-neutral WRT -std=gnu99 and fixes several compilation errors for strict
  C99 mode.
2008-01-29 10:33:34 +00:00
Denis Vlasenko c882f341ce init: allow last line to be not terminated by '\n' 2008-01-29 09:56:21 +00:00
Denis Vlasenko 8c638cbf09 mount: allow and ignore _netdev option 2008-01-29 09:31:09 +00:00
Bernhard Reutner-Fischer c96d37050f - update defconfig 2008-01-29 09:28:02 +00:00
Denis Vlasenko 36fc3cd8bc ash: code readability enhancements, no real code changes 2008-01-29 09:23:49 +00:00
Denis Vlasenko ddd42cb064 sendmail: really svn add it 2008-01-29 00:59:15 +00:00
Denis Vlasenko 9772816570 *: move getopt reset code to better place(s) 2008-01-28 22:57:10 +00:00
Denis Vlasenko 73032ca04b sendmail: new applet by dronnikov at gmail.com 2008-01-28 22:47:03 +00:00
Denis Vlasenko 847fa779af *: tidy up usage of char **environ 2008-01-28 22:45:43 +00:00
Denis Vlasenko 0effc2410b microcom: undo #define trick, gcc fails to take advantage of it 2008-01-28 09:39:30 +00:00
Denis Vlasenko b5c60fc787 mkswap, readahead: stop using fdlength, it is reported to be unreliable 2008-01-27 23:41:34 +00:00
Denis Vlasenko da42bd5bbe stty: fix mishandling of 'control' keywords (Ralf Friedl <Ralf.Friedl@online.de>) 2008-01-27 23:24:31 +00:00
Denis Vlasenko ef67c5758a microcom: update from the author 2008-01-27 22:40:39 +00:00
Denis Vlasenko c4e4be9414 tentatively fix getopt state corruption for NOFORK applets 2008-01-27 22:39:55 +00:00
Bernhard Reutner-Fischer f470196a41 - fix conflicting decls of syslog related facilitynames and prioritynames tables 2008-01-27 12:50:12 +00:00
Mike Frysinger 61160dd0a1 do not respect CONFIG_MODULES as it breaks building if it is defined in the build env 2008-01-27 09:41:24 +00:00
Denis Vlasenko b76b9a4328 udhcpc: filter unwanted packets in kernel
(Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>)
2008-01-25 22:46:34 +00:00
Denis Vlasenko 893988182a fdisk: comment out unused function 2008-01-25 20:18:46 +00:00
Denis Vlasenko ca9635b19d udhcpc: fix wrong options in decline and release packets
(Jonas Danielsson <jonas.danielsson at axis.com>)
2008-01-25 19:27:08 +00:00
Denis Vlasenko a5549c9617 fdisk: fix a case where break was reached only for DOS labels 2008-01-24 22:49:15 +00:00
Denis Vlasenko 680b86afbb halt: write wtmp entry if wtmp support is enabled 2008-01-24 02:28:00 +00:00
Denis Vlasenko 1d290d1e24 halt: update help text 2008-01-24 02:27:30 +00:00
Denis Vlasenko 9e58921e7e comment fix 2008-01-24 01:33:42 +00:00
Denis Vlasenko 314820e595 crond: small code shrink and readability enhancements 2008-01-24 01:33:12 +00:00
Denis Vlasenko 8e8200a772 grep: fix wrong filename in error message 2008-01-24 01:30:36 +00:00
Mike Frysinger 46ef46aefb as reported by George Boudreau, make sure we properly skip blank lines 2008-01-23 18:48:26 +00:00
Bernhard Reutner-Fischer 46904bfbcc - Fix hdparm's ioctl parameter passing (John Brandwood) 2008-01-19 11:27:11 +00:00
Paul Fox 518d8dd979 eliminated CONFIG_FEATURE_EDITING_FANCY_KEYS. the size savings
was small, compared to the total size of the command-line editing
features, and it removed key bindings that most wouldn't consider
"fancy", like ^U, and 'l' and 'h' in vi mode, ^F and ^B in emacs
mode.
2008-01-18 20:41:24 +00:00
Bernhard Reutner-Fischer 52432f2b06 - correct helptext of stat (Cristian Ionescu-Idbohrn) 2008-01-17 11:05:09 +00:00
Bernhard Reutner-Fischer 2b11fb483e - implement brctl setpathcost, setportprio, setbridgeprio, stp
text    data     bss     dec     hex filename
    907      20       0     927     39f networking/brctl.o
2008-01-14 16:10:11 +00:00
Bernhard Reutner-Fischer c2f0de5eef - mention strtod code-duplication as TODO for cleanup 2008-01-14 14:32:56 +00:00
Bernhard Reutner-Fischer 1aac3ab49f - shrink a bit and implement time related fancy features. Improve help texts.
text	   data	    bss	    dec	    hex	filename
    253	     20	      0	    273	    111	networking/brctl.o.bare
    613	     20	      0	    633	    279	networking/brctl.o.fancy-time
2008-01-13 18:43:50 +00:00
Bernhard Reutner-Fischer 78e1d58d3a - fix commentary typo 2008-01-13 17:52:53 +00:00
Bernhard Reutner-Fischer c44c21060e - save four bytes by manually hoisting the br assignment 2008-01-13 15:43:28 +00:00
Bernhard Reutner-Fischer ce34cccf28 - update defconfig 2008-01-13 15:33:13 +00:00
Bernhard Reutner-Fischer d27d925a6d - new applet brctl
text	   data	    bss	    dec	    hex	filename
    289	     20	      0	    309	    135	networking/brctl.o
    335	     23	      0	    358	    166	networking/brctl-verbose-ops.o
2008-01-13 15:23:27 +00:00
Bernhard Reutner-Fischer 481ce92bdf - add ipsvd 2008-01-11 20:52:45 +00:00
Paul Fox 84bbac5a09 enable use of ^V prefix to allow forced insertion of any character. in
particular, without this it's impossible to enter a TAB on the commandline
(whether tab completion is enabled or not).
2008-01-11 16:50:08 +00:00
Paul Fox ee8e3ee919 allow 8-bit characters 2008-01-11 16:12:57 +00:00
Denis Vlasenko de24bd960f tac: handle NULs properly. +145 bytes 2008-01-09 23:00:00 +00:00
Denis Vlasenko d2c450ce81 hush: report [v]fork failures
hush: more correct handling of piping
config: add CONFIG_NOMMU
2008-01-08 20:32:12 +00:00
Denis Vlasenko 474d1c57c8 whitespace fixes 2008-01-07 19:06:47 +00:00
Denis Vlasenko 9b4c072a04 ps: fix yet another buglet from recent ulltoa conversion :( 2008-01-07 16:51:25 +00:00
Denis Vlasenko 766f65919b ps: fix COMMAND column adjustment 2008-01-07 16:41:41 +00:00
Denis Vlasenko 482f2b31e7 tac: *really* add tac.c now 2008-01-07 16:14:14 +00:00
Denis Vlasenko 6b404431aa ps: fix build breakage from vda's recent commit
*: whitespace fixes
2008-01-07 16:13:14 +00:00
Denis Vlasenko 4e9ca75281 syslogd: fix shmat error check 2008-01-07 15:58:02 +00:00
Denis Vlasenko bcd5fc12ec tac: new applet. ~240 bytes.
Copyright (C) 2003  Yang Xiaopeng  <yxp at hanwang.com.cn>
Copyright (C) 2007  Natanael Copa  <natanael.copa@gmail.com>
Copyright (C) 2007  Tito Ragusa    <farmatito@tiscali.it>
2008-01-06 06:27:17 +00:00
Denis Vlasenko 56ea65ca5f ps: fix overflow in USER and VSZ columns
function                                             old     new   delta
smart_ulltoa4                                          -     280    +280
smart_ulltoa5                                        283     408    +125
ulltoa6_and_space                                      -      25     +25
scale                                                 28      38     +10
bbunpack                                             358     366      +8
ps_main                                              259     261      +2
glob3                                                 35      37      +2
fill_bounds                                          172     174      +2
process_stdin                                        456     446     -10
smart_ulltoa6                                        406       -    -406
------------------------------------------------------------------------------
(add/remove: 2/1 grow/shrink: 6/1 up/down: 454/-416)           Total: 38 bytes
2008-01-06 03:26:53 +00:00
Denis Vlasenko 5fee2e1a79 ps: add conditional support for -o [e]time 2008-01-05 03:26:41 +00:00
Denis Vlasenko 9cd30d30a0 Makefile.help: removing allbareconfig target from help
applet_tables: fix allnoconfig
2008-01-04 20:10:51 +00:00
Denis Vlasenko 83c44229d2 ip route: "ip route" was misbehaving (extra argv+1 ate 1st env var) 2008-01-04 15:28:28 +00:00
Denis Vlasenko 21e20cb4ad init: wait for orphaned children too while waiting
for sysinit-like processes (Harald Küthe <harald-tuxbox@arcor.de>)
2008-01-04 15:10:47 +00:00
Denis Vlasenko 4dada747e5 syslogd: avoid excessive tine() system calls
function                                             old     new   delta
timestamp_and_log_internal                             -      24     +24
log_locally                                          741     744      +3
timestamp_and_log                                    313     314      +1
syslogd_main                                         904     897      -7
quit_signal                                          101      94      -7
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/2 up/down: 28/-14)             Total: 14 bytes
2008-01-03 12:13:42 +00:00
Denis Vlasenko 4f2e8bc765 syslogd: don't die if remote host's IP cannot be resolved.
retry resolutions every two minutes instead.

function                                             old     new   delta
syslogd_main                                         865     904     +39
timestamp_and_log                                    324     313     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 39/-11)             Total: 28 bytes
2008-01-03 12:12:27 +00:00
Denis Vlasenko fb0eba706c libbb: introduce and use safe_waitpid (loops in EINTR)
*: use more approproate (shorter) versions of wait()

function                                             old     new   delta
safe_waitpid                                           -      48     +48
wait_any_nohang                                        -      17     +17
send_tree                                            365     369      +4
processorstop                                        432     435      +3
text_yank                                            110     108      -2
make_human_readable_str                              202     200      -2
crond_main                                          1368    1366      -2
handle_sigchld                                        49      43      -6
reapchild                                            166     159      -7
custom                                               260     250     -10
checkscript                                          191     177     -14
wait_nohang                                           17       -     -17
wait_pid                                              43       -     -43
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 2/7 up/down: 72/-103)           Total: -31 bytes
2008-01-02 19:55:04 +00:00
Denis Vlasenko 27963980db adding libbb/printable.c 2007-12-30 20:13:39 +00:00
Denis Vlasenko d3c042fc60 libbb: introduce fputc_printable (from ed)
netstat: print control chars as ^C etc
vi: style fixlet

function                                             old     new   delta
fputc_printable                                        -     100    +100
unix_do_one                                          451     487     +36
printLines                                           258     190     -68
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 136/-68)            Total: 68 bytes
2007-12-30 01:59:53 +00:00
Denis Vlasenko fcd878efcd httpd: support for "I:index.xml" syntax (Peter Korsgaard <jacmet@uclibc.org>)
function                                             old     new   delta
parse_conf                                          1481    1507     +26
handle_incoming_and_exit                            2650    2663     +13
httpd_main                                           749     759     +10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/0 up/down: 49/0)               Total: 49 bytes
2007-12-29 02:16:23 +00:00
Denis Vlasenko 3f9c848576 trylink: instead of build error, disable --gc-sections if GLIBC && STATIC
nameif: glibc build fixlet
2007-12-28 17:04:42 +00:00
Denis Vlasenko ddc865fb0d netstat: in error message, report filename and line number
where we see problematic data

   text    data     bss     dec     hex filename
 778456     832    7344  786632   c00c8 busybox_old
 778394     832    7344  786570   c008a busybox_unstripped
2007-12-26 21:49:33 +00:00
Denis Vlasenko c03e872112 save a bit of code with *strchrnul = '\0' trick
function                                             old     new   delta
nextline                                              59      55      -4
include_conf                                         902     898      -4
read_config                                          414     406      -8
fsck_main                                           1880    1869     -11
2007-12-26 20:56:55 +00:00
Denis Vlasenko abee3d0e0d Fix xmalloc_fgets_str so that it really does NOT strip terminator.
Add xmalloc_fgetline_str which does strip terminator,
and use it in dpkg instead of xmalloc_fgets_str.
netstat: use xmalloc_fgets_str - allows to eat strings with NULs
(this fixes bug with some weird /proc/net/unix input)

function                                             old     new   delta
xmalloc_fgets_internal                                 -     191    +191
xmalloc_fgetline_str                                   -      18     +18
do_info                                              116     120      +4
unix_do_one                                          451     447      -4
tcp_do_one                                           423     419      -4
send_tree                                            369     365      -4
xmalloc_fgets_str                                    178      15    -163
------------------------------------------------------------------------------
(add/remove: 2/0 grow/shrink: 1/4 up/down: 213/-175)           Total: 38 bytes
   text    data     bss     dec     hex filename
 778445     832    7344  786621   c00bd busybox_old
 778483     832    7344  786659   c00e3 busybox_unstripped
2007-12-26 20:44:45 +00:00
Denis Vlasenko d55268d0d4 init: don't spawn tons of waiting children, one is enough
init: shrink signal disabling code
init: rename some functions
   text    data     bss     dec     hex filename
 778657     832    7344  786833   c0191 busybox_old
 778445     832    7344  786621   c00bd busybox_unstripped
2007-12-26 18:32:58 +00:00
Denis Vlasenko 5adfa44101 init: sometimes, #ifdefs are cleaner. 2007-12-25 16:08:53 +00:00
Denis Vlasenko 1d61416b5a sync examples to what actual actual code expects 2007-12-25 15:32:56 +00:00
Mike Frysinger 08137c28c4 add expected output 2007-12-25 04:35:05 +00:00
Mike Frysinger bb50fdfe07 convert #if to if -- let gcc optimize away dead code for us 2007-12-25 04:30:14 +00:00
Denis Vlasenko ec5631b6d6 init: add FEATURE_KILL_REMOVED (Eugene Bordenkircher <eugebo@gmail.com>)
init: slight size optimization
2007-12-25 01:08:58 +00:00
Denis Vlasenko 7b55c7f97d fix typo in web page 2007-12-24 17:33:56 +00:00
Denis Vlasenko 8e5b6f58a2 Makefile: change version to 1.10.0.svn
udhcpc: make UDP packet sending the same as raw sending in regards
  to error messages. Minor code size shrink. Total size grows due
  to added messages:

   text    data     bss     dec     hex filename
 770312     683    7244  778239   bdfff busybox_old
 770327     683    7244  778254   be00e busybox_unstripped
2007-12-24 17:32:22 +00:00
Denis Vlasenko 299c5c379e Announce 1.9.0 2007-12-24 14:43:25 +00:00
Denis Vlasenko 3b4921674e hush: fixlet for NOMMU
update TODO_config_nommu
2007-12-24 14:26:57 +00:00
Denis Vlasenko f7be20e70c nameif: extended matching (Nico Erfurth <masta@perlgolf.de>)
*: whitespace fixes

function                                             old     new   delta
prepend_new_eth_table                                  -     304    +304
nameif_main                                          620     684     +64
cc_macaddr                                            51       -     -51
------------------------------------------------------------------------------
(add/remove: 1/1 grow/shrink: 1/0 up/down: 368/-51)           Total: 317 bytes
2007-12-24 14:09:19 +00:00
Denis Vlasenko fcfb5c04bb defconfig: update
appletli.c: add vda's (C)
top: fixlet for incorrect display of "0"
Makefile: reduce stack size from 20k to 16k
2007-12-24 12:16:24 +00:00
Denis Vlasenko e4bc603f0b od: reduce data/bss usage (code size went down too) 2007-12-24 12:14:24 +00:00
Denis Vlasenko ef36c04ccf umount: fix fallout from stack reduction change 2007-12-24 12:11:57 +00:00
Denis Vlasenko f882f08627 vi: speed up some string ops 2007-12-23 02:36:51 +00:00
Denis Vlasenko 528a8b9769 cttyhack: trivial build fixlet 2007-12-22 19:57:28 +00:00
Denis Vlasenko 4baed3a080 vi: reduce amount of memset'ing on each screen refresh 2007-12-22 17:31:29 +00:00
Denis Vlasenko e3cbfb91d2 vi: introduce FEATURE_VI_8BIT (as vi currently is not Unicode capable,
people may want to disable display of high-bit chars)
ip: build fixlet
2007-12-22 17:00:11 +00:00
Denis Vlasenko 94e3365b8f perror_nomsg: don't print extra colon
losetup: print name of loop device in error messages
2007-12-22 15:44:23 +00:00
Denis Vlasenko 88adfcd178 vi: change MAX_LINELEN meaning: now it is the biggest supported
screen wigth. Introduce MAX_TABSTOP and MAX_INPUT_LEN. Fix redraw
of very long lines and cursor movement past NULs.
2007-12-22 15:40:13 +00:00
Denis Vlasenko ee87ebf381 fix buglets found by randomconfig 2007-12-21 22:18:16 +00:00
Denis Vlasenko 26b6fba9d3 vi: fix a problem with displaying overlong lines 2007-12-21 21:34:37 +00:00
Denis Vlasenko 619879246d udhcp: decided to not send "short" dhcp packets,
but lets add comments how to do it if needed.
2007-12-21 16:32:30 +00:00
Denis Vlasenko fff145dba3 udhcp: fix oversized packet sending (introduced by "slack for bad dhcp servers" options);
slight optimizations and function renaming

udhcp_send_raw_packet                                  -     391    +391
udhcp_send_kernel_packet                               -     197    +197
udhcp_recv_packet                                      -     134    +134
get_raw_packet                                       353     326     -27
udhcp_get_packet                                     134       -    -134
udhcp_kernel_packet                                  197       -    -197
udhcp_raw_packet                                     391       -    -391
------------------------------------------------------------------------------
(add/remove: 3/3 grow/shrink: 0/1 up/down: 722/-749)          Total: -27 bytes
2007-12-20 21:11:38 +00:00
Denis Vlasenko f77f369ce8 fdisk: reduce global data/bss usage. 8k data+bss build is achievable soon ;)
(add/remove: 0/13 grow/shrink: 6/19 up/down: 74/-492)        Total: -418 bytes
   text    data     bss     dec     hex filename
 778330     860    7408  786598   c00a6 busybox_old
 777970     840    7376  786186   bff0a busybox_unstripped
2007-12-16 17:22:33 +00:00
Denis Vlasenko c794c51a1a msh: reduce global data/bss usage
(add/remove: 1/5 grow/shrink: 28/6 up/down: 464/-394)          Total: 70 bytes
   text    data     bss     dec     hex filename
 778077     908    7568  786553   c0079 busybox_old
 778330     860    7408  786598   c00a6 busybox_unstripped
2007-12-16 17:21:29 +00:00
Denis Vlasenko 0163111325 ash: reduce global data/bss usage
(add/remove: 4/29 grow/shrink: 76/21 up/down: 1007/-1713)    Total: -706 bytes
   text    data     bss     dec     hex filename
 777206    1084    8976  787266   c0342 busybox_old
 778077     908    7568  786553   c0079 busybox_unstripped
2007-12-16 17:20:38 +00:00
Denis Vlasenko 9ad2cb3f1a traceroute: stop using global data/bss
(add/remove: 0/15 grow/shrink: 0/1 up/down: 0/-95)            Total: -95 bytes
   text    data     bss     dec     hex filename
 777245    1094    9008  787347   c0393 busybox_old
 777206    1084    8976  787266   c0342 busybox_unstripped
2007-12-16 17:19:40 +00:00
Denis Vlasenko 4ca2965b99 add a link to vda's pet projects 2007-12-13 00:15:50 +00:00
Denis Vlasenko 2cd4a747e5 num conversions: allow for leading '+' (renice needs that) 2007-12-11 13:15:11 +00:00
Denis Vlasenko d7e2e127a9 cttyhack: add missing ';'
init: remove pointless access() check
2007-12-10 08:40:29 +00:00
Denis Vlasenko 2afabe8b83 init: remove superfluous forks and messing up with argv[0]
cttyhack: add stealing of ctty
2007-12-10 07:06:04 +00:00
Denis Vlasenko 191836845e udhcpc: support for -O <option>.
Two important notes:
* nissrv and nisdomain are not requested by default anymore!
* inconsistency between "XXXsvr" and "XXsrv" in option names resolved,
  all are "XXXsrv" now.

function                                             old     new   delta
udhcpc_main                                         2494    2600    +106
packed_usage                                       23023   23067     +44
add_requests                                          91     119     +28
static.udhcpc_longopts                               209     226     +17
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 195/0)             Total: 195 bytes
2007-12-10 07:03:38 +00:00
Denis Vlasenko 75aa615bef find: add -iname support (Alexander Griesser <alexander.griesser@lkh-vil.or.at>) 2007-12-09 10:07:39 +00:00
Denis Vlasenko 9cb220be9d lineedit: don't violate API if we do simple fgets
ash: cosmetic style fixes, no code changes
2007-12-09 10:03:28 +00:00
Denis Vlasenko a96425fe82 vi: don't use common_bufsiz as read buffer, it can be too small
(found by Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>)
2007-12-09 04:13:43 +00:00
Denis Vlasenko b851c42a14 signal names hack was wrong, it broke "get signal name" function.
Reverting :(
2007-12-04 21:44:52 +00:00
Denis Vlasenko f3fca91e9f getty: a small code shrink
touch                                                  -      40     +40
fakehost                                               4       -      -4
getty_main                                          2546    2493     -53
2007-12-04 18:46:01 +00:00
Denis Vlasenko c689fcfdb0 Make signal table a bit smaller
get_signum                                           136     151     +15
signals                                              224     192     -32
2007-12-04 10:20:48 +00:00
Denis Vlasenko 5f934b0785 guard against SIGxxx >= 32 (no code changes on i386) 2007-12-04 10:05:28 +00:00
Denis Vlasenko d0bbbdcd6e getty: don't accept ancient '#' and '@' as backspace/kill line,
it only confuses people.
(Alexander Griesser <alexander.griesser@lkh-vil.or.at> (LKH Villach))
various other cleanups.

function                                             old     new   delta
getty_main                                          2526    2546     +20
static.baud_index                                      4       -      -4
parse_speeds                                          91       -     -91
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 1/0 up/down: 20/-95)            Total: -75 bytes
   text    data     bss     dec     hex filename
 773152    1086    9008  783246   bf38e busybox_old
 773081    1086    9008  783175   bf347 busybox_unstripped
2007-12-04 09:48:40 +00:00
Denis Vlasenko 7221c8c22d lineedit: reduce stack usage
netstat: reduce stack usage; fix handling of NULs in unix socket filenames

static.has_inode                                       1       -      -1
do_info                                              119     116      -3
deinit_S                                              60      51      -9
unix_do_one                                          578     451    -127
parse_and_put_prompt                                 966     825    -141
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 0/4 up/down: 0/-281)           Total: -281 bytes
2007-12-03 10:45:14 +00:00
Denis Vlasenko 2bec513996 fix whitespace damage 2007-12-02 08:56:53 +00:00
Denis Vlasenko 7ab3699b58 mkfs.minix: add testsuite; disable code which makes images variable 2007-12-02 08:55:34 +00:00
Denis Vlasenko ab801874f8 attack the biggest stack users:
-mkfs_minix_main [busybox_unstripped]:                  4288
-mkfs_minix_main [busybox_unstripped]:                  4276
-grave [busybox_unstripped]:                            4260
(bzip2 users too - not listed)

price we pay in code size increase:
mainSort                                            2458    2515     +57
grave                                               1005    1058     +53
sendMTFValues                                       2177    2195     +18
BZ2_blockSort                                        122     125      +3
mkfs_minix_main                                     3070    3022     -48
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 131/-48)            Total: 83 bytes
2007-12-02 08:35:37 +00:00
Denis Vlasenko 8003e266ed explain why we use mmap instead of malloc 2007-12-02 07:18:29 +00:00
Denis Vlasenko 8723a94c25 libnetlink: comment out unused code; don't use 8k stack buffers
function                                             old     new   delta
ipaddr_modify                                       1305    1297      -8
do_iprule                                            963     955      -8
do_iproute                                          2193    2169     -24
xrtnl_dump_filter                                    418     391     -27
rtnl_talk                                            671     536    -135
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-202)           Total: -202 bytes
2007-12-02 06:30:57 +00:00
Denis Vlasenko 5cb40bbbd3 Fix minor discrepancy in "make help" 2007-12-02 05:36:37 +00:00
Denis Vlasenko 4c13922961 Introduce FEATURE_COPYBUF_KB.
People who want smaller stack at any cost may use it
to reduce cp's stack usage (FEATURE_COPYBUF_KB=1).
Desktop people may get faster copy of big files
(FEATURE_COPYBUF_KB=32 is ~30% faster than 4kb)
2007-12-02 03:27:42 +00:00
Denis Vlasenko e2532ab5f2 dd: fix a bug where we don't report write errors
testsuite: small cleanup

full_write_or_warn                                    38      40      +2
write_and_stats                                       66      67      +1
dd_main                                             1358    1335     -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 3/-23)             Total: -20 bytes
2007-12-02 01:44:42 +00:00
Denis Vlasenko 1796e2c495 dd: add testsuite entry for write errors 2007-12-02 01:43:18 +00:00
Denis Vlasenko 6672c8e480 test: stop using lots of bss.
function                                             old     new   delta
test_main                                            425     456     +31
t_lex                                                 69      73      +4
syntax                                               100     104      +4
ptr_to_statics                                         8      12      +4
t_wp_op                                                4       -      -4
t_wp                                                   4       -      -4
ngroups                                                4       -      -4
group_array                                            4       -      -4
binop                                                590     585      -5
oexpr                                                104      97      -7
aexpr                                                101      94      -7
nexpr                                                831     820     -11
leaving                                              156       -    -156
------------------------------------------------------------------------------
(add/remove: 0/5 grow/shrink: 4/4 up/down: 43/-202)          Total: -159 bytes
   text    data     bss     dec     hex filename
 775098     929    9084  785111   bfad7 busybox_old
 775107     933    8908  784948   bfa34 busybox_unstripped
2007-11-30 07:29:05 +00:00
Denis Vlasenko b539c8452f dhcp: heed TODO item - divorced options from their string descriptions
code shrink while at it.

function                                             old     new   delta
dhcp_option_strings                                    -     258    +258
udhcp_run_script                                    1135    1174     +39
dhcp_option_lengths                                    -      11     +11
udhcp_add_simple_option                               93      92      -1
packet_num                                             4       -      -4
read_opt                                             746     739      -7
udhcp_option_lengths                                  11       -     -11
udhcpc_main                                         2590    2494     -96
dhcp_options                                         490      70    -420
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 1/4 up/down: 308/-539)         Total: -231 bytes
   text    data     bss     dec     hex filename
 775309     929    9100  785338   bfbba busybox_old
 775098     929    9084  785111   bfad7 busybox_unstripped
2007-11-29 08:17:45 +00:00
Denis Vlasenko 64309f8669 sysctl: add -e: supress warnings about invalid key (Jeremy Kerr <jk@ozlabs.org>)
code shrink:

   text    data     bss     dec     hex filename
 775565     929    9100  785594   bfcba busybox_old
 775296     929    9100  785325   bfbad busybox_unstripped
2007-11-29 06:40:28 +00:00
Denis Vlasenko 745cd17926 Further optimize applet tables; prettify build output
text    data     bss     dec     hex filename
 775923     929    9100  785952   bfe20 busybox_old
 775565     929    9100  785594   bfcba busybox_unstripped
2007-11-29 03:31:20 +00:00
Denis Vlasenko c253778de9 touch: accept and ignore -f 2007-11-28 19:25:32 +00:00
Denis Vlasenko 35ff74676b dhcpc: let server know we don't like oversized packets.
add TODO comment
2007-11-28 19:23:12 +00:00
Denis Vlasenko 41f5add965 forgotten part of previous commit 2007-11-28 06:49:42 +00:00
Denis Vlasenko 1aa7e477b1 reorganize applet table. Eliminates pointers to names.
Should be a big win for libbusybox. busybox wins too:

   text    data     bss     dec     hex filename
 776524     929    9100  786553   c0079 busybox_old
 775903     929    9100  785932   bfe0c busybox_unstripped
2007-11-28 06:49:03 +00:00
Denis Vlasenko 79c6904faf ip route: add comment, no code changes 2007-11-27 09:42:33 +00:00
Denis Vlasenko 186c2b3d0e iproute: fix a bug where "ip r flush table main" was rejected,
add "ip r flush cache" (however I'm unsure it is really valid syntax)
Add a few comments and stop mixing params and params' keywords.
2007-11-26 18:29:52 +00:00
Denis Vlasenko 30297a5b83 fix vda's testsuite bogons, part 2 2007-11-26 07:23:27 +00:00
Denis Vlasenko bd9a48bc9c fix vda's testsuite bogons, part 1 2007-11-26 07:23:09 +00:00
Denis Vlasenko 4e1e720523 testsuite: add tests for cut and grep;
slight improvements to infrastructure
2007-11-26 05:38:20 +00:00
Denis Vlasenko ed270a5f32 ash: make code simpler, and do not do close(-1) - it's rude 2007-11-26 05:37:07 +00:00
Denis Vlasenko b1bac0dab2 zcip: simplify code a bit 2007-11-25 12:53:25 +00:00
Denis Vlasenko a09300a88c zcip: use low-order 4 bytes of MAC as random seed, not 4 high-order
arping: fix wrong roundtrip calculation
arping,zcip: cleanups and code shrink

run                                                  389     402     +13
arp                                                  195     188      -7
zcip_main                                           1524    1495     -29
arping_main                                         1874    1823     -51
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 13/-87)            Total: -74 bytes
   text    data     bss     dec     hex filename
 776587     929    9100  786616   c00b8 busybox_old
 776499     929    9100  786528   c0060 busybox_unstripped
2007-11-25 12:40:56 +00:00
Denis Vlasenko 7c9d533a85 cttyhack should be in /bin, not /usr/bin 2007-11-25 07:58:42 +00:00
Denis Vlasenko 6446c2d4ab which: fix testsuite failure
pidof: do not output empty line if nothing found
testsuite: disable false positive
2007-11-25 04:54:13 +00:00
Denis Vlasenko 72e76044cf dhcpc: cope with buggy DHCP servers which send oversized packets
(Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>)
2007-11-25 03:15:24 +00:00
Denis Vlasenko a8875efa85 Announce 1.8.2 and 1.7.4 2007-11-24 04:49:07 +00:00
Denis Vlasenko dd8bbfd084 stty: reorganize data tables - save 0.5k
function                                             old     new   delta
mode_name                                              -     496    +496
control_name                                           -      91     +91
stty_main                                           1235    1255     +20
find_mode                                             45      63     +18
find_control                                          45      63     +18
do_display                                           482     493     +11
wrapf                                                165     166      +1
set_mode                                             761     759      -2
max_col                                                4       -      -4
device_name                                            4       -      -4
control_info                                         153      34    -119
mode_info                                           1700     680   -1020
------------------------------------------------------------------------------
(add/remove: 2/2 grow/shrink: 5/3 up/down: 655/-1149)        Total: -494 bytes
   text    data     bss     dec     hex filename
 777037     937    9100  787074   c0282 busybox_old
 776551     929    9100  786580   c0094 busybox_unstripped
2007-11-24 04:32:49 +00:00
Denis Vlasenko fe5e23bf75 remove echo_main -> bb_echo indirection 2007-11-24 02:23:51 +00:00
Denis Vlasenko c3c6659f12 hush: fix segfault in "echo $@" when we have no arguments 2007-11-24 00:22:42 +00:00
Denis Vlasenko d2023283ac fix buglets found by randomconfig 2007-11-23 23:39:01 +00:00
Denis Vlasenko 1da0ad13fb update defconfig 2007-11-23 23:37:19 +00:00
Denis Vlasenko 96702ca945 kill lash. "lash" builtin still exists, but it runs hush. 2007-11-23 23:28:55 +00:00
Denis Vlasenko 8ec6ee47f1 Add an RFC for future ipv6 ftp work 2007-11-23 21:43:40 +00:00
Denis Vlasenko 5bc593ccb8 hush: implement echo builtin
builtin_echo                                           -      36     +36
bltins                                               384     396     +12
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/0 up/down: 48/0)               Total: 48 bytes
2007-11-23 21:20:21 +00:00
Denis Vlasenko cccdc4e01a hush: fix $ expansion in redirections, add testcase for that 2007-11-23 21:08:38 +00:00
Denis Vlasenko 835068637e hush: implement test builtin 2007-11-23 13:11:42 +00:00
Denis Vlasenko f962a0354e hush: plug memory leak 2007-11-23 12:50:54 +00:00
Denis Vlasenko f23c3f95e8 arping: fix help text (-i -> -I), and shorten it a bit 2007-11-23 09:27:05 +00:00
Denis Vlasenko fff9b699f1 arping: fix a bug where there is implicit count of 4G;
eliminate data/bss usage; code shrink

function                                             old     new   delta
timeout_us                                             4       -      -4
static.start                                           4       -      -4
src                                                    4       -      -4
sock                                                   4       -      -4
sent                                                   4       -      -4
req_recv                                               4       -      -4
received                                               4       -      -4
last                                                   4       -      -4
dst                                                    4       -      -4
count                                                  4       -      -4
brd_sent                                               4       -      -4
brd_recv                                               4       -      -4
catcher                                              375     365     -10
me                                                    20       -     -20
he                                                    20       -     -20
arping_main                                         1941    1874     -67
------------------------------------------------------------------------------
(add/remove: 0/14 grow/shrink: 0/2 up/down: 0/-165)          Total: -165 bytes
   text    data     bss     dec     hex filename
 783035     941    9244  793220   c1a84 busybox_old
 782907     937    9156  793000   c19a8 busybox_unstripped
2007-11-23 09:15:26 +00:00
Denis Vlasenko 3831c91c95 cut: add proper stdout error handling, fix "-" handling;
modest code shrink
2007-11-23 07:26:15 +00:00
Denis Vlasenko e85dbae389 logread: add forgotten INIT_G(); 2007-11-23 03:41:20 +00:00
Denis Vlasenko ff2b6d2185 logread: eliminate usage of data/bss
ifup: don't remove virtual iface prefixes (eth0:0)

function                                             old     new   delta
shbuf                                                  4       -      -4
SMrup                                                  6       -      -6
SMrdn                                                 12       -     -12
static.label_buf                                      20       4     -16
get_var                                              158     140     -18
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 0/2 up/down: 0/-56)             Total: -56 bytes
   text    data     bss     dec     hex filename
 783501     962    9260  793723   c1c7b busybox_old
 783483     942    9244  793669   c1c45 busybox_unstripped
2007-11-23 03:39:45 +00:00
Denis Vlasenko 6884f665bd dhcp: stop using magic constants; use (htonl(CONST) != a) - it's smaller
function                                             old     new   delta
udhcp_get_packet                                     146     134     -12
get_raw_packet                                       368     353     -15
2007-11-23 00:08:54 +00:00
Denis Vlasenko 68af8e7a08 udhcpc: remove -W option, -A can be reused for that
help texts: trimmed a bit

static.udhcpc_longopts                               227     209     -18
udhcpc_main                                         2633    2590     -43
packed_usage                                       22927   22871     -56
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-117)           Total: -117 bytes
2007-11-22 21:41:14 +00:00
Denis Vlasenko b559105cfb fix a thinko in build system 2007-11-22 20:09:41 +00:00
Denis Vlasenko 7d75a96b15 ash: fix bug where redirection of closed fd was leaving it open afterwards.
redirect                                             983    1024     +41
bb_echo                                              276     301     +25
popredir                                             118     132     +14
evalcommand                                         1163    1176     +13
bbunpack                                             358     366      +8
echocmd                                               13       5      -8
echo_main                                             13       5      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 5/2 up/down: 101/-16)            Total: 85 bytes
   text    data     bss     dec     hex filename
 774999     962    9236  785197   bfb2d busybox_old
 775084     962    9236  785282   bfb82 busybox_unstripped
2007-11-22 08:16:57 +00:00
Denis Vlasenko 705eaf8b40 sestatus: new SELinux applet (KaiGai Kohei <kaigai@ak.jp.nec.com>) 2007-11-22 01:10:41 +00:00
Denis Vlasenko 9cdfd14223 dhcpc: cleanup and comments; fix buggy timeout handling in corner cases.
-25 bytes.
2007-11-22 01:00:00 +00:00
Denis Vlasenko 223bc97f61 udhcpc: an option to perform ARP check (Jonas Danielsson <jonas.danielsson@axis.com>)
configurable, ~+300 bytes when on.
2007-11-22 00:58:49 +00:00
Mike Frysinger c881c733bb cleanup comments and coding style and rewrite the mdev.conf parser to use common busybox functions and call strdup() less often ... saves a ~few hundred bytes 2007-11-19 09:04:22 +00:00
Denis Vlasenko ed6a49c657 ip: stop propagating argc; optimize ip_parse_common_args
function                                             old     new   delta
find_pair                                            167     187     +20
static.families                                        -      17     +17
die_must_be_on_off                                     -      11     +11
...
on_off                                                33      22     -11
do_ipaddr                                            103      90     -13
do_iptunnel                                         1001     986     -15
iproute_list_or_flush                               1237    1217     -20
static.ip_common_commands                             43      22     -21
do_iproute                                          2217    2193     -24
parse_args                                          1444    1414     -30
ip_do                                                 47      16     -31
do_iprule                                            994     963     -31
ip_main                                              153     113     -40
ipaddr_modify                                       1357    1305     -52
ipaddr_list_or_flush                                2543    2490     -53
ip_parse_common_args                                 294     159    -135
------------------------------------------------------------------------------
(add/remove: 4/1 grow/shrink: 4/24 up/down: 85/-563)         Total: -478 bytes
   text    data     bss     dec     hex filename
 775561     966    9236  785763   bfd63 busybox_old
 775073     962    9236  785271   bfb77 busybox_unstripped
2007-11-18 22:56:25 +00:00
Denis Vlasenko 2a587df80a stty: mark variable as static 2007-11-18 11:47:25 +00:00
Mike Frysinger 49d15890e0 make output a little more friendly 2007-11-18 06:42:56 +00:00
Mike Frysinger e13bd362e3 merge from upstream for systems that dont integrate libintl into their C library:
commit aa1e5ef5c1d95e7ebf0821d9ba27debe43a87a22
Author: Sam Ravnborg <sam@ravnborg.org>
Date:   Sun Aug 12 23:15:44 2007 +0200

    kbuild: check if we can link gettext not just compile

    cygwin provides the header file but the lib file needs
    to be added manually. A generic fix is to check if
    we can compile and link a program that uses gettext()
    and if it fails fall back to NO_NLS.

    International users of cygwin may have to specify
    HOST_LOADLIBES := "-lintl" on the make command line.

    Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
2007-11-18 06:17:52 +00:00
Mike Frysinger dbd18f639c exported symbols may be weak, so allow symbols marked as W 2007-11-18 06:13:58 +00:00
Denis Vlasenko 70ab28f907 syslogd: use DEV_CONSOLE consistently
init: remove obsolete comment
2007-11-18 05:43:05 +00:00
Denis Vlasenko fbe5f39f0f hexdump: add hd alias, add -R option 2007-11-18 05:36:50 +00:00
Paul Fox 16aec39ebe add comment clarifying busybox's use of non-standard tar header 2007-11-17 19:11:05 +00:00
Denis Vlasenko 8512862163 tar: fix a case where glibc detects bogus buffer overrun
which is not really there!
2007-11-16 20:35:30 +00:00
Denis Vlasenko 7e3a5f58bc dmesg,klogd: make code more readable
libbb: explain why we declare klogctl
libbb: move defs around so that order makes more sense
2007-11-16 20:18:54 +00:00
Bernhard Reutner-Fischer 7c2db5c198 - use standard-imposed constants some more 2007-11-16 12:39:16 +00:00
Bernhard Reutner-Fischer a702457eac - remove most of the forward declarations. No obj-code changes. 2007-11-16 12:20:30 +00:00
Bernhard Reutner-Fischer e8979889b4 - add note about SUSv3 missing options. 2007-11-16 11:52:42 +00:00
Denis Vlasenko 01cd9570c7 who: add -a (by Tito) 2007-11-16 05:24:43 +00:00
Denis Vlasenko a6899c3587 lash: fix compile-time warning 2007-11-15 17:47:45 +00:00
Denis Vlasenko 6d38dc3af4 df: add -a
df: don't special case rootfs and /dev/root

function                                             old     new   delta
df_main                                              746     684     -62
find_block_device                                    111       -    -111
find_block_device_in_dir                             243       -    -243
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 0/1 up/down: 0/-416)           Total: -416 bytes
2007-11-15 09:02:12 +00:00
Denis Vlasenko f430cdbf2e df: add -i (conditional on CONFIG)
uasge: trim a bit
2007-11-15 07:02:55 +00:00
Denis Vlasenko 1fe4e9e573 cosmetic change in message text 2007-11-15 00:57:40 +00:00
Paul Fox ae6bf96659 bad syntax error should go to stderr 2007-11-14 23:48:35 +00:00
Denis Vlasenko 9d6c46955f Introduce FEATURE_PREFER_IPV4_ADDRESS. If selected, we have:
function                                             old     new   delta
str2sockaddr                                         328     344     +16
2007-11-14 10:18:33 +00:00
Denis Vlasenko 8d0a734d91 tr: more of code shrink (getopt32-ification)
runtest: cleanup. Method of getting $applets was truly bizarre

function                                             old     new   delta
tr_main                                              655     527    -128
2007-11-13 22:23:57 +00:00
Denis Vlasenko 3d461676a9 tr: better comments, small code shrink
function                                             old     new   delta
expand                                              2232    2230      -2
tr_main                                              677     655     -22
2007-11-13 22:22:29 +00:00
Denis Vlasenko a89d50fb9a tr: properly detect read errors (Fernando Silveira <fsilveira@gmail.com>)
readprofile: use xwrite

function                                             old     new   delta
tr_main                                              679     677      -2
readprofile_main                                    1964    1944     -20
2007-11-13 17:51:40 +00:00
Denis Vlasenko 130f559f4d trylink: accomodate older versions of ld 2007-11-13 17:36:12 +00:00
Denis Vlasenko 05c8c4f745 who: code shrink by Tito <farmatito@tiscali.it>
function                                             old     new   delta
who_main                                             271     259     -12
2007-11-13 17:26:21 +00:00
Denis Vlasenko 72cc9641f8 add sed mini-doc 2007-11-13 17:13:31 +00:00
Denis Vlasenko 40276648ab sed: support GNU-like '\t' escape in substitutions 2007-11-13 16:48:10 +00:00
Denis Vlasenko 6df9e3c9a3 inetd: revert bogus fix for bug 1562; shrink inetd a bit
function                                             old     new   delta
dupconfig                                            159     146     -13
getconfigent                                        1123    1073     -50
2007-11-12 21:21:35 +00:00
Denis Vlasenko 059c91711f open_transformer: do not duplicate "<program> -cf -"
text    data     bss     dec     hex filename
 677858     738    7236  685832   a7708 busybox_old
 677804     738    7236  685778   a76d2 busybox_unstripped
2007-11-12 02:13:12 +00:00
Denis Vlasenko 4bfb84db4e gzip: fix a case where tar xzf fails (we use uninitialized fd) 2007-11-12 01:44:49 +00:00
Denis Vlasenko e5569cb52e who: fix wrong date/time field size 2007-11-11 06:35:41 +00:00
Denis Vlasenko 40702dac93 Announce 1.8.1 2007-11-10 03:24:21 +00:00
Denis Vlasenko f6ccc62c70 init: fix bug 1584: improper check for fork error 2007-11-10 01:57:35 +00:00
Denis Vlasenko 5cc6459c46 umount: stop using excessive aounts of stack. Surprisingly,
code shrank a lot too

function                                             old     new   delta
umount_main                                          751     640    -111
2007-11-10 01:45:03 +00:00
Denis Vlasenko 73cb1fdfea lineedit: stop using both data/bss and tons of stack.
stack usage was ~10 kb!
unfortunately, noticeable code size growth:
   text    data     bss     dec     hex filename
   9252      12     181    9445    24e5 busybox.t7/libbb/lineedit.o
   9714       4       0    9718    25f6 busybox.t8/libbb/lineedit.o
2007-11-10 01:35:47 +00:00
Denis Vlasenko e7fca5125a *: remove superfluous "?" in option parsing 2007-11-10 01:32:18 +00:00
Denis Vlasenko b4f608d8e0 readlink: realpath requires PATH_MAX, bb_common_bufsiz1 can be too small
umount: don't actually need char[2 * PATH_MAX] for realpath
2007-11-10 01:31:19 +00:00
Denis Vlasenko d031b203c7 syslogd: support "symlink to symlink" for /dev/log; reduce stack usage
function                                             old     new   delta
create_socket                                          -     134    +134
syslogd_main                                        1132     865    -267
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/1 up/down: 134/-267)         Total: -133 bytes
   text    data     bss     dec     hex filename
 775603     974    9420  785997   bfe4d busybox_old
 775445     974    9420  785839   bfdaf busybox_unstripped
2007-11-10 01:28:19 +00:00
Bernhard Reutner-Fischer 9bd8d0c23e - commentary fixes
- use common exit sequence for failure path:
   text	   data	    bss	    dec	    hex	filename
    308	      0	      0	    308	    134	libbb/xreadlink.o.pgf
    296	      0	      0	    296	    128	libbb/xreadlink.o
2007-11-08 21:11:43 +00:00
Paul Fox 599bbfbd9b xmalloc_follow_symlinks() -- fix ELOOP issue with absolute paths,
return full path in cases where path doesn't resolve to a link. 
change name to better differentiate from xmalloc_readlink().
2007-11-08 20:00:36 +00:00
Denis Vlasenko abbd363261 xreadlink: code shrink
udhcp: add missing tryagain member to client_config

function                                             old     new   delta
xmalloc_readlink_follow                              169     154     -15
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-15)             Total: -15 bytes
2007-11-08 17:40:23 +00:00
Paul Fox 53bd4015aa follow symlinks to find the true passwd file before updating. 2007-11-08 01:12:38 +00:00
Paul Fox 459a2ba1ef new xmalloc_readlink_follow() routine to fully expand trailing symlinks
to get to a "real" file (or directory).
2007-11-08 01:11:41 +00:00
Paul Fox 49cce2b838 add "-A N" / "--tryagain=N" option to client, to allow altering the
default 60 second wait after failure to get a lease.
2007-11-07 16:01:28 +00:00
Paul Fox 6e1b62b18c flush typeahead before prompt 2007-11-07 15:51:35 +00:00
Denis Vlasenko a29a5e40ae login: fix PAM login (was unable to complete Kerberos login) 2007-11-07 00:23:47 +00:00
Denis Vlasenko cb12cb2407 modprobe: fix a bug where we were entering endless loop
syslogd: strip trailing '\n' too, not only NULs
2007-11-06 11:34:03 +00:00
Denis Vlasenko 5281630229 login: clear dangerous environment variables if started by non-root 2007-11-06 05:26:51 +00:00
Denis Vlasenko 6bef3d1d22 fbset: fix buglet where we were using wrong pointer
readahead: stop using stdio.h
*: style fixes
2007-11-06 03:05:54 +00:00
Denis Vlasenko 1bec1b980e telnet: use poll, it's shorter
*: style fixes
2007-11-06 02:23:39 +00:00
Denis Vlasenko cd0fbb5e77 unzip: hmm... gcc doesn't like ATTRIBUTE_PACKED?? Document that... 2007-11-06 02:16:01 +00:00
Denis Vlasenko ef66d75704 insmod: make error reporting less verbose 2007-11-06 02:02:45 +00:00
Denis Vlasenko 018b155ad9 telnetd: fix problem with zombies (by Paul Fox <pgf@brightstareng.com>)
syslogd: strip trailing NULs
2007-11-06 01:38:46 +00:00
Paul Fox cb981638f5 change safety check on zip header to allow for extra length, and
revert the header read to use the correct constant rather than
sizeof.  at least one version of gcc (armv4-linux-gcc-3.4.1) pads
the struct to 28 bytes in spite of the packing.
2007-11-05 23:09:03 +00:00
Denis Vlasenko f8b21d0933 swaponoff: prevent arithmetic overflow (spotted by Paul Fox <pgf@brightstareng.com>) 2007-11-05 19:33:38 +00:00
Denis Vlasenko 15c3885688 fix incorrect text of link-time error message. No code changes 2007-11-05 19:31:01 +00:00
Denis Vlasenko 9fcd799b98 webpage: fix typo, remove inconsistent trailing dots
Makefile: version is 1.9.0.svn now
2007-11-05 16:26:34 +00:00
Denis Vlasenko 3a3e50e3db update screenshot 2007-11-04 15:57:35 +00:00
513 changed files with 28089 additions and 14078 deletions

No files matched your search

+13 -2
View File
@@ -111,7 +111,7 @@ config LOCALE_SUPPORT
busybox to support locale settings.
config GETOPT_LONG
bool "Enable support for --long-options"
bool "Support for --long-options"
default y
help
Enable this if you want busybox applets to use the gnu --long-option
@@ -280,6 +280,17 @@ config STATIC
Most people will leave this set to 'N'.
config NOMMU
bool "Force NOMMU build"
default n
help
Busybox tries to detect whether architecture it is being
built against supports MMU or not. If this detection fails,
or if you want to build NOMMU version of busybox for testing,
you may force NOMMU build here.
Most people will leave this set to 'N'.
config BUILD_LIBBUSYBOX
bool "Build shared libbusybox"
default n
@@ -555,4 +566,4 @@ source shell/Config.in
source sysklogd/Config.in
source runit/Config.in
source selinux/Config.in
source ipsvd/Config.in
source printutils/Config.in
+9 -5
View File
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 8
SUBLEVEL = 0
PATCHLEVEL = 10
SUBLEVEL = 4
EXTRAVERSION =
NAME = Unnamed
@@ -437,7 +437,6 @@ libs-y := \
editors/ \
findutils/ \
init/ \
ipsvd/ \
libbb/ \
libpwdgrp/ \
loginutils/ \
@@ -446,12 +445,14 @@ libs-y := \
networking/ \
networking/libiproute/ \
networking/udhcp/ \
printutils/ \
procps/ \
runit/ \
selinux/ \
shell/ \
sysklogd/ \
util-linux/ \
util-linux/volume_id/ \
endif # KBUILD_EXTMOD
@@ -571,6 +572,7 @@ quiet_cmd_busybox__ ?= LINK $@
cmd_busybox__ ?= $(srctree)/scripts/trylink \
"$@" \
"$(CC)" \
"$(CFLAGS)" \
"$(LDFLAGS) $(EXTRA_LDFLAGS)" \
"$(core-y)" \
"$(libs-y)" \
@@ -729,7 +731,7 @@ localver = $(subst $(space),, \
# Currently, only git is supported.
# Other SCMs can edit scripts/setlocalversion and add the appropriate
# checks as needed.
ifdef CONFIG_LOCALVERSION_AUTO
ifdef _BB_DISABLED_CONFIG_LOCALVERSION_AUTO
_localver-auto = $(shell $(CONFIG_SHELL) \
$(srctree)/scripts/setlocalversion $(srctree))
localver-auto = $(LOCALVERSION)$(_localver-auto)
@@ -842,7 +844,7 @@ depend dep:
# ---------------------------------------------------------------------------
# Modules
ifdef CONFIG_MODULES
ifdef _BB_DISABLED_CONFIG_MODULES
# By default, build modules as well
@@ -928,6 +930,8 @@ MRPROPER_FILES += .config .config.old include/asm .version .old_version \
include/autoconf.h \
include/bbconfigopts.h \
include/usage_compressed.h \
include/applet_tables.h \
applets/usage \
.kernelrelease Module.symvers tags TAGS cscope*
# clean - Delete most, but leave enough to build external modules
+1 -1
View File
@@ -90,7 +90,7 @@ objsizes: busybox_unstripped
.PHONY: stksizes
stksizes: busybox_unstripped
$(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH)
$(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH) | uniq
.PHONY: bigdata
bigdata: busybox_unstripped
+3 -1
View File
@@ -20,6 +20,7 @@ CPPFLAGS += \
# flag checks are grouped together to speed the checks up a bit..
CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,)
CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
# If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
# (or anything else for that matter) make sure that it is still possible
# to build bbox without warnings. Current offender: find.c:alloc_action().
@@ -97,4 +98,5 @@ 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
# Reduced from 20k to 16k in 1.9.0.
FLTFLAGS += -s 16000
+2 -3
View File
@@ -16,7 +16,6 @@ help:
@echo 'Configuration:'
@echo ' allnoconfig - disable all symbols in .config'
@echo ' allyesconfig - enable all symbols in .config (see defconfig)'
@echo ' allbareconfig - enable all applets without any sub-features'
@echo ' config - text based configurator (of last resort)'
@echo ' defconfig - set .config to largest generic configuration'
@echo ' menuconfig - interactive curses-based configurator'
@@ -24,10 +23,10 @@ help:
@echo ' hosttools - build sed for the host.'
@echo ' You can use these commands if the commands on the host'
@echo ' is unusable. Afterwards use it like:'
@echo ' make SED="$(objtree)/sed"'
@echo ' make SED="$(objtree)/sed"'
@echo
@echo 'Installation:'
@echo ' install - install busybox into $(CONFIG_PREFIX)'
@echo ' install - install busybox into CONFIG_PREFIX'
@echo ' uninstall'
@echo
@echo 'Development:'
+3
View File
@@ -82,6 +82,9 @@ Downloading the current source code:
is generally a faster way of getting it fixed, and the complete archive of
what happened is the subversion changelog.
Note: if you want to compile busybox in a busybox environment you must
select ENABLE_DESKTOP.
----------------
getting help:
+7 -22
View File
@@ -7,27 +7,21 @@ have any suggestions how they plan to go about it, and to minimize conflicts
between your work and theirs. But otherwise, all of these are fair game.
Rob Landley <rob@landley.net>:
Add BB_NOMMU to platform.h and migrate __uClinux__ tests to that.
#if defined __UCLIBC__ && !defined __ARCH_USE_MMU__
Add a libbb/platform.c
Implement fdprintf() for platforms that haven't got one.
Implement bb_realpath() that can handle NULL on non-glibc.
Cleanup bb_asprintf()
Migrate calloc() and bb_calloc() occurrences to bb_xzalloc().
Remove obsolete _() wrapper crud for internationalization we don't do.
Figure out where we need utf8 support, and add it.
sh
The command shell situation is a big mess. We have three or four different
The command shell situation is a big mess. We have three different
shells that don't really share any code, and the "standalone shell" doesn't
work all that well (especially not in a chroot environment), due to apps not
being reentrant. I'm writing a new shell (bbsh) to unify the various
shells and configurably add the minimal set of bash features people
actually use. The hardest part is it has to configure down as small as
lash while providing lash's features. The rest is easy in comparison.
bzip2
Compression-side support.
being reentrant.
lash is phased out. hush can be configured down to be nearly as small,
but less buggy :)
init
General cleanup (should use ENABLE_FEATURE_INIT_SYSLOG and ENABLE_FEATURE_INIT_DEBUG).
depmod
@@ -35,8 +29,6 @@ Rob Landley <rob@landley.net>:
use of the depmod.pl (perl is to bloated for most embedded setups) and or orig
modutils. The orig depmod is rather pointless to have to add to a firmware image
in when we already have a insmod/rmmod and friends.
Unify base64 handling.
[done]
Do a SUSv3 audit
Look at the full Single Unix Specification version 3 (available online at
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
@@ -128,9 +120,6 @@ Bernhard Fischer <busybox@busybox.net> suggests to look at these:
As yet unclaimed:
----
find
doesn't understand (), lots of susv3 stuff.
----
diff
Make sure we handle empty files properly:
@@ -148,10 +137,6 @@ patch
And while we're at it, a new patch filename quoting format is apparently
coming soon: http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
---
ps / top
Add support for both RSS and VSIZE rather than just one or the other.
Or make it a build option.
---
man
It would be nice to have a man command. Not one that handles troff or
anything, just one that can handle preformatted ascii man pages, possibly
@@ -306,15 +291,15 @@ Minor stuff:
---
Move __get_hz() to a better place and (re)use it in route.c, ash.c, msh.c
---
See grep -r strtod
Alot of duplication that wants cleanup.
---
Code cleanup:
Replace deprecated functions.
bzero() -> memset()
---
sigblock(), siggetmask(), sigsetmask(), sigmask() -> sigprocmask et al
---
vdprintf() -> similar sized functionality
---
+239 -112
View File
@@ -1,11 +1,7 @@
# This .config compiles for NOMMU.
# TODO:
# Pick disabled applet, enable & try to make it compile & work on NOMMU
#
# Automatically generated make config: don't edit
# Busybox version: 1.6.0.svn
# Wed Apr 11 01:29:04 2007
# Busybox version: 1.10.0.svn
# Thu Mar 20 14:54:21 2008
#
CONFIG_HAVE_DOT_CONFIG=y
@@ -16,9 +12,9 @@ CONFIG_HAVE_DOT_CONFIG=y
#
# General Configuration
#
# CONFIG_NITPICK is not set
# CONFIG_DESKTOP is not set
# CONFIG_FEATURE_BUFFERS_USE_MALLOC is not set
CONFIG_NITPICK=y
CONFIG_DESKTOP=y
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
CONFIG_SHOW_USAGE=y
@@ -31,29 +27,29 @@ CONFIG_FEATURE_DEVPTS=y
# CONFIG_FEATURE_CLEAN_UP is not set
CONFIG_FEATURE_PIDFILE=y
CONFIG_FEATURE_SUID=y
CONFIG_FEATURE_SYSLOG=y
# CONFIG_FEATURE_SUID_CONFIG is not set
# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
# CONFIG_FEATURE_HAVE_RPC is not set
# CONFIG_SELINUX is not set
CONFIG_FEATURE_SUID_CONFIG=y
CONFIG_FEATURE_SUID_CONFIG_QUIET=y
CONFIG_SELINUX=y
CONFIG_FEATURE_PREFER_APPLETS=y
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
CONFIG_FEATURE_SYSLOG=y
CONFIG_FEATURE_HAVE_RPC=y
#
# Build Options
#
# CONFIG_STATIC is not set
CONFIG_NOMMU=y
# CONFIG_BUILD_LIBBUSYBOX is not set
# CONFIG_FEATURE_FULL_LIBBUSYBOX is not set
# CONFIG_FEATURE_INDIVIDUAL is not set
# CONFIG_FEATURE_SHARED_BUSYBOX is not set
CONFIG_LFS=y
# CONFIG_BUILD_AT_ONCE is not set
#
# Debugging Options
#
# CONFIG_DEBUG is not set
CONFIG_WERROR=y
# CONFIG_WERROR is not set
CONFIG_NO_DEBUG_LIB=y
# CONFIG_DMALLOC is not set
# CONFIG_EFENCE is not set
@@ -65,7 +61,11 @@ CONFIG_INCLUDE_SUSv2=y
# CONFIG_INSTALL_NO_USR is not set
CONFIG_INSTALL_APPLET_SYMLINKS=y
# CONFIG_INSTALL_APPLET_HARDLINKS is not set
# CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is not set
# CONFIG_INSTALL_APPLET_DONT is not set
# CONFIG_INSTALL_SH_APPLET_SYMLINK is not set
# CONFIG_INSTALL_SH_APPLET_HARDLINK is not set
# CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER is not set
CONFIG_PREFIX="./_install"
#
@@ -73,14 +73,20 @@ CONFIG_PREFIX="./_install"
#
CONFIG_PASSWORD_MINLEN=6
CONFIG_MD5_SIZE_VS_SPEED=2
CONFIG_FEATURE_FAST_TOP=y
CONFIG_FEATURE_ETC_NETWORKS=y
CONFIG_FEATURE_EDITING=y
# CONFIG_FEATURE_EDITING_FANCY_KEYS is not set
# CONFIG_FEATURE_EDITING_VI is not set
CONFIG_FEATURE_EDITING_MAX_LEN=1024
CONFIG_FEATURE_EDITING_VI=y
CONFIG_FEATURE_EDITING_HISTORY=15
# CONFIG_FEATURE_EDITING_SAVEHISTORY is not set
# CONFIG_FEATURE_TAB_COMPLETION is not set
# CONFIG_FEATURE_USERNAME_COMPLETION is not set
# CONFIG_FEATURE_EDITING_FANCY_PROMPT is not set
CONFIG_FEATURE_TAB_COMPLETION=y
CONFIG_FEATURE_USERNAME_COMPLETION=y
CONFIG_FEATURE_EDITING_FANCY_PROMPT=y
CONFIG_FEATURE_VERBOSE_CP_MESSAGE=y
CONFIG_FEATURE_COPYBUF_KB=4
CONFIG_MONOTONIC_SYSCALL=y
CONFIG_IOCTL_HEX2STR_ERROR=y
#
# Applets
@@ -92,25 +98,30 @@ CONFIG_FEATURE_EDITING_HISTORY=15
CONFIG_AR=y
CONFIG_FEATURE_AR_LONG_FILENAMES=y
CONFIG_BUNZIP2=y
CONFIG_BZIP2=y
CONFIG_CPIO=y
# CONFIG_DPKG is not set
# CONFIG_DPKG_DEB is not set
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
CONFIG_DPKG=y
CONFIG_DPKG_DEB=y
CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY=y
CONFIG_GUNZIP=y
CONFIG_FEATURE_GUNZIP_UNCOMPRESS=y
CONFIG_GZIP=y
CONFIG_RPM2CPIO=y
# CONFIG_RPM is not set
CONFIG_RPM=y
CONFIG_FEATURE_RPM_BZ2=y
CONFIG_TAR=y
CONFIG_FEATURE_TAR_CREATE=y
# CONFIG_FEATURE_TAR_BZIP2 is not set
# CONFIG_FEATURE_TAR_LZMA is not set
CONFIG_FEATURE_TAR_GZIP=y
CONFIG_FEATURE_TAR_BZIP2=y
CONFIG_FEATURE_TAR_LZMA=y
CONFIG_FEATURE_TAR_COMPRESS=y
CONFIG_FEATURE_TAR_AUTODETECT=y
CONFIG_FEATURE_TAR_FROM=y
# CONFIG_FEATURE_TAR_GZIP is not set
# CONFIG_FEATURE_TAR_COMPRESS is not set
CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y
CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY=y
CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
CONFIG_FEATURE_TAR_LONG_OPTIONS=y
CONFIG_FEATURE_TAR_UNAME_GNAME=y
CONFIG_UNCOMPRESS=y
CONFIG_UNLZMA=y
CONFIG_FEATURE_LZMA_FAST=y
@@ -120,9 +131,13 @@ CONFIG_UNZIP=y
# Common options for cpio and tar
#
CONFIG_FEATURE_UNARCHIVE_TAPE=y
# CONFIG_FEATURE_DEB_TAR_GZ is not set
# CONFIG_FEATURE_DEB_TAR_BZ2 is not set
# CONFIG_FEATURE_DEB_TAR_LZMA is not set
#
# Common options for dpkg and dpkg_deb
#
CONFIG_FEATURE_DEB_TAR_GZ=y
CONFIG_FEATURE_DEB_TAR_BZ2=y
CONFIG_FEATURE_DEB_TAR_LZMA=y
#
# Coreutils
@@ -136,7 +151,6 @@ CONFIG_CHMOD=y
CONFIG_CHOWN=y
CONFIG_CHROOT=y
CONFIG_CKSUM=y
CONFIG_CMP=y
CONFIG_COMM=y
CONFIG_CP=y
CONFIG_CUT=y
@@ -146,10 +160,7 @@ CONFIG_DD=y
CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
CONFIG_FEATURE_DD_IBS_OBS=y
CONFIG_DF=y
CONFIG_DIFF=y
CONFIG_FEATURE_DIFF_BINARY=y
CONFIG_FEATURE_DIFF_DIR=y
CONFIG_FEATURE_DIFF_MINIMAL=y
CONFIG_FEATURE_DF_INODE=y
CONFIG_DIRNAME=y
CONFIG_DOS2UNIX=y
CONFIG_UNIX2DOS=y
@@ -159,6 +170,8 @@ CONFIG_ECHO=y
CONFIG_FEATURE_FANCY_ECHO=y
CONFIG_ENV=y
CONFIG_FEATURE_ENV_LONG_OPTIONS=y
CONFIG_EXPAND=y
CONFIG_FEATURE_EXPAND_LONG_OPTIONS=y
CONFIG_EXPR=y
CONFIG_EXPR_MATH_SUPPORT_64=y
CONFIG_FALSE=y
@@ -194,9 +207,12 @@ CONFIG_OD=y
CONFIG_PRINTENV=y
CONFIG_PRINTF=y
CONFIG_PWD=y
CONFIG_READLINK=y
CONFIG_FEATURE_READLINK_FOLLOW=y
CONFIG_REALPATH=y
CONFIG_RM=y
CONFIG_RMDIR=y
CONFIG_FEATURE_RMDIR_LONG_OPTIONS=y
CONFIG_SEQ=y
CONFIG_SHA1SUM=y
CONFIG_SLEEP=y
@@ -210,6 +226,7 @@ CONFIG_FEATURE_STAT_FORMAT=y
CONFIG_STTY=y
CONFIG_SUM=y
CONFIG_SYNC=y
CONFIG_TAC=y
CONFIG_TAIL=y
CONFIG_FEATURE_FANCY_TAIL=y
CONFIG_TEE=y
@@ -223,11 +240,12 @@ CONFIG_FEATURE_TR_EQUIV=y
CONFIG_TRUE=y
CONFIG_TTY=y
CONFIG_UNAME=y
CONFIG_UNEXPAND=y
CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS=y
CONFIG_UNIQ=y
CONFIG_USLEEP=y
CONFIG_UUDECODE=y
CONFIG_UUENCODE=y
CONFIG_WATCH=y
CONFIG_WC=y
CONFIG_FEATURE_WC_LARGE=y
CONFIG_WHO=y
@@ -261,6 +279,7 @@ CONFIG_CHVT=y
CONFIG_CLEAR=y
CONFIG_DEALLOCVT=y
CONFIG_DUMPKMAP=y
CONFIG_KBD_MODE=y
CONFIG_LOADFONT=y
CONFIG_LOADKMAP=y
CONFIG_OPENVT=y
@@ -277,14 +296,12 @@ CONFIG_SETLOGCONS=y
#
CONFIG_MKTEMP=y
CONFIG_PIPE_PROGRESS=y
CONFIG_READLINK=y
CONFIG_FEATURE_READLINK_FOLLOW=y
CONFIG_RUN_PARTS=y
CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS=y
CONFIG_FEATURE_RUN_PARTS_FANCY=y
# CONFIG_START_STOP_DAEMON is not set
# CONFIG_FEATURE_START_STOP_DAEMON_FANCY is not set
# CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS is not set
CONFIG_START_STOP_DAEMON=y
CONFIG_FEATURE_START_STOP_DAEMON_FANCY=y
CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS=y
CONFIG_WHICH=y
#
@@ -292,10 +309,17 @@ CONFIG_WHICH=y
#
CONFIG_AWK=y
CONFIG_FEATURE_AWK_MATH=y
CONFIG_CMP=y
CONFIG_DIFF=y
CONFIG_FEATURE_DIFF_BINARY=y
CONFIG_FEATURE_DIFF_DIR=y
CONFIG_FEATURE_DIFF_MINIMAL=y
CONFIG_ED=y
CONFIG_PATCH=y
CONFIG_SED=y
CONFIG_VI=y
CONFIG_FEATURE_VI_MAX_LEN=4096
CONFIG_FEATURE_VI_8BIT=y
CONFIG_FEATURE_VI_COLON=y
CONFIG_FEATURE_VI_YANKMARK=y
CONFIG_FEATURE_VI_SEARCH=y
@@ -318,6 +342,7 @@ CONFIG_FEATURE_FIND_MMIN=y
CONFIG_FEATURE_FIND_PERM=y
CONFIG_FEATURE_FIND_TYPE=y
CONFIG_FEATURE_FIND_XDEV=y
CONFIG_FEATURE_FIND_MAXDEPTH=y
CONFIG_FEATURE_FIND_NEWER=y
CONFIG_FEATURE_FIND_INUM=y
CONFIG_FEATURE_FIND_EXEC=y
@@ -328,6 +353,10 @@ CONFIG_FEATURE_FIND_DEPTH=y
CONFIG_FEATURE_FIND_PAREN=y
CONFIG_FEATURE_FIND_SIZE=y
CONFIG_FEATURE_FIND_PRUNE=y
CONFIG_FEATURE_FIND_DELETE=y
CONFIG_FEATURE_FIND_PATH=y
CONFIG_FEATURE_FIND_REGEX=y
CONFIG_FEATURE_FIND_CONTEXT=y
CONFIG_GREP=y
CONFIG_FEATURE_GREP_EGREP_ALIAS=y
CONFIG_FEATURE_GREP_FGREP_ALIAS=y
@@ -341,14 +370,16 @@ CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
#
# Init Utilities
#
# CONFIG_INIT is not set
CONFIG_INIT=y
# CONFIG_DEBUG_INIT is not set
# CONFIG_FEATURE_USE_INITTAB is not set
# CONFIG_FEATURE_INIT_SCTTY is not set
# CONFIG_FEATURE_INIT_SYSLOG is not set
# CONFIG_FEATURE_EXTRA_QUIET is not set
# CONFIG_FEATURE_INIT_COREDUMPS is not set
# CONFIG_FEATURE_INITRD is not set
CONFIG_FEATURE_USE_INITTAB=y
CONFIG_FEATURE_KILL_REMOVED=y
CONFIG_FEATURE_KILL_DELAY=1
CONFIG_FEATURE_INIT_SCTTY=y
CONFIG_FEATURE_INIT_SYSLOG=y
CONFIG_FEATURE_EXTRA_QUIET=y
CONFIG_FEATURE_INIT_COREDUMPS=y
CONFIG_FEATURE_INITRD=y
CONFIG_HALT=y
CONFIG_MESG=y
@@ -361,16 +392,23 @@ CONFIG_USE_BB_PWD_GRP=y
CONFIG_ADDGROUP=y
CONFIG_FEATURE_ADDUSER_TO_GROUP=y
CONFIG_DELGROUP=y
CONFIG_FEATURE_DEL_USER_FROM_GROUP=y
CONFIG_FEATURE_CHECK_NAMES=y
CONFIG_ADDUSER=y
CONFIG_FEATURE_ADDUSER_LONG_OPTIONS=y
CONFIG_DELUSER=y
CONFIG_GETTY=y
CONFIG_FEATURE_UTMP=y
CONFIG_FEATURE_WTMP=y
CONFIG_LOGIN=y
# CONFIG_PAM is not set
CONFIG_LOGIN_SCRIPTS=y
CONFIG_FEATURE_NOLOGIN=y
CONFIG_FEATURE_SECURETTY=y
CONFIG_PASSWD=y
CONFIG_FEATURE_PASSWD_WEAK_CHECK=y
CONFIG_CRYPTPW=y
CONFIG_CHPASSWD=y
CONFIG_SU=y
CONFIG_FEATURE_SU_SYSLOG=y
CONFIG_FEATURE_SU_CHECKS_SHELLS=y
@@ -426,6 +464,7 @@ CONFIG_FEATURE_SGI_LABEL=y
CONFIG_FEATURE_SUN_LABEL=y
CONFIG_FEATURE_OSF_LABEL=y
CONFIG_FEATURE_FDISK_ADVANCED=y
CONFIG_FINDFS=y
CONFIG_FREERAMDISK=y
CONFIG_FSCK_MINIX=y
CONFIG_MKFS_MINIX=y
@@ -436,6 +475,8 @@ CONFIG_MKFS_MINIX=y
CONFIG_FEATURE_MINIX2=y
CONFIG_GETOPT=y
CONFIG_HEXDUMP=y
CONFIG_FEATURE_HEXDUMP_REVERSE=y
CONFIG_HD=y
CONFIG_HWCLOCK=y
CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS=y
CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS=y
@@ -444,19 +485,43 @@ CONFIG_IPCS=y
CONFIG_LOSETUP=y
CONFIG_MDEV=y
CONFIG_FEATURE_MDEV_CONF=y
CONFIG_FEATURE_MDEV_RENAME=y
CONFIG_FEATURE_MDEV_EXEC=y
CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
CONFIG_MKSWAP=y
CONFIG_FEATURE_MKSWAP_V0=y
CONFIG_MORE=y
CONFIG_FEATURE_USE_TERMIOS=y
CONFIG_VOLUMEID=y
CONFIG_FEATURE_VOLUMEID_EXT=y
CONFIG_FEATURE_VOLUMEID_REISERFS=y
CONFIG_FEATURE_VOLUMEID_FAT=y
CONFIG_FEATURE_VOLUMEID_HFS=y
CONFIG_FEATURE_VOLUMEID_JFS=y
CONFIG_FEATURE_VOLUMEID_XFS=y
CONFIG_FEATURE_VOLUMEID_NTFS=y
CONFIG_FEATURE_VOLUMEID_ISO9660=y
CONFIG_FEATURE_VOLUMEID_UDF=y
CONFIG_FEATURE_VOLUMEID_LUKS=y
CONFIG_FEATURE_VOLUMEID_LINUXSWAP=y
CONFIG_FEATURE_VOLUMEID_CRAMFS=y
CONFIG_FEATURE_VOLUMEID_ROMFS=y
CONFIG_FEATURE_VOLUMEID_SYSV=y
CONFIG_FEATURE_VOLUMEID_OCFS2=y
CONFIG_FEATURE_VOLUMEID_LINUXRAID=y
CONFIG_MOUNT=y
# CONFIG_FEATURE_MOUNT_NFS is not set
CONFIG_FEATURE_MOUNT_FAKE=y
CONFIG_FEATURE_MOUNT_VERBOSE=y
CONFIG_FEATURE_MOUNT_HELPERS=y
CONFIG_FEATURE_MOUNT_LABEL=y
CONFIG_FEATURE_MOUNT_NFS=y
CONFIG_FEATURE_MOUNT_CIFS=y
CONFIG_FEATURE_MOUNT_FLAGS=y
CONFIG_FEATURE_MOUNT_FSTAB=y
CONFIG_PIVOT_ROOT=y
CONFIG_RDATE=y
CONFIG_READPROFILE=y
CONFIG_RTCWAKE=y
CONFIG_SETARCH=y
CONFIG_SWAPONOFF=y
CONFIG_SWITCH_ROOT=y
@@ -473,12 +538,20 @@ CONFIG_FEATURE_MOUNT_LOOP=y
# Miscellaneous Utilities
#
CONFIG_ADJTIMEX=y
# CONFIG_BBCONFIG is not set
CONFIG_BBCONFIG=y
CONFIG_CHAT=y
CONFIG_FEATURE_CHAT_NOFAIL=y
CONFIG_FEATURE_CHAT_TTY_HIFI=y
CONFIG_FEATURE_CHAT_IMPLICIT_CR=y
CONFIG_FEATURE_CHAT_SWALLOW_OPTS=y
CONFIG_FEATURE_CHAT_SEND_ESCAPES=y
CONFIG_FEATURE_CHAT_VAR_ABORT_LEN=y
CONFIG_FEATURE_CHAT_CLR_ABORT=y
CONFIG_CHRT=y
# CONFIG_CROND is not set
# CONFIG_DEBUG_CROND_OPTION is not set
# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set
# CONFIG_CRONTAB is not set
CONFIG_CROND=y
CONFIG_DEBUG_CROND_OPTION=y
CONFIG_FEATURE_CROND_CALL_SENDMAIL=y
CONFIG_CRONTAB=y
CONFIG_DC=y
# CONFIG_DEVFSD is not set
# CONFIG_DEVFSD_MODLOAD is not set
@@ -486,6 +559,7 @@ CONFIG_DC=y
# CONFIG_DEVFSD_VERBOSE is not set
# CONFIG_FEATURE_DEVFS is not set
CONFIG_EJECT=y
CONFIG_FEATURE_EJECT_SCSI=y
CONFIG_LAST=y
CONFIG_LESS=y
CONFIG_FEATURE_LESS_MAXLINES=9999999
@@ -504,27 +578,32 @@ CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA=y
CONFIG_MAKEDEVS=y
# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
CONFIG_FEATURE_MAKEDEVS_TABLE=y
CONFIG_MICROCOM=y
CONFIG_MOUNTPOINT=y
CONFIG_MT=y
CONFIG_NMETER=y
CONFIG_RAIDAUTORUN=y
CONFIG_READAHEAD=y
CONFIG_RUNLEVEL=y
CONFIG_RX=y
CONFIG_SCRIPT=y
CONFIG_STRINGS=y
CONFIG_SETSID=y
# CONFIG_TASKSET is not set
# CONFIG_FEATURE_TASKSET_FANCY is not set
CONFIG_TASKSET=y
CONFIG_FEATURE_TASKSET_FANCY=y
CONFIG_TIME=y
CONFIG_TTYSIZE=y
CONFIG_WATCHDOG=y
#
# Networking Utilities
#
CONFIG_FEATURE_IPV6=y
# CONFIG_VERBOSE_RESOLUTION_ERRORS is not set
CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y
CONFIG_VERBOSE_RESOLUTION_ERRORS=y
CONFIG_ARP=y
CONFIG_ARPING=y
CONFIG_BRCTL=y
CONFIG_FEATURE_BRCTL_FANCY=y
CONFIG_DNSD=y
CONFIG_ETHER_WAKE=y
CONFIG_FAKEIDENTD=y
@@ -532,37 +611,43 @@ CONFIG_FTPGET=y
CONFIG_FTPPUT=y
CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y
CONFIG_HOSTNAME=y
# CONFIG_HTTPD is not set
# CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP is not set
# CONFIG_FEATURE_HTTPD_SETUID is not set
# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set
# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES is not set
# CONFIG_FEATURE_HTTPD_CGI is not set
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set
# CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set
# CONFIG_FEATURE_HTTPD_ENCODE_URL_STR is not set
CONFIG_HTTPD=y
CONFIG_FEATURE_HTTPD_RANGES=y
CONFIG_FEATURE_HTTPD_USE_SENDFILE=y
CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP=y
CONFIG_FEATURE_HTTPD_SETUID=y
CONFIG_FEATURE_HTTPD_BASIC_AUTH=y
CONFIG_FEATURE_HTTPD_AUTH_MD5=y
CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES=y
CONFIG_FEATURE_HTTPD_CGI=y
CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR=y
CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV=y
CONFIG_FEATURE_HTTPD_ENCODE_URL_STR=y
CONFIG_FEATURE_HTTPD_ERROR_PAGES=y
CONFIG_FEATURE_HTTPD_PROXY=y
CONFIG_IFCONFIG=y
CONFIG_FEATURE_IFCONFIG_STATUS=y
CONFIG_FEATURE_IFCONFIG_SLIP=y
CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y
CONFIG_FEATURE_IFCONFIG_HW=y
CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
# CONFIG_IFUPDOWN is not set
# CONFIG_FEATURE_IFUPDOWN_IP is not set
# CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN is not set
CONFIG_IFENSLAVE=y
CONFIG_IFUPDOWN=y
CONFIG_IFUPDOWN_IFSTATE_PATH="/var/run/ifstate"
CONFIG_FEATURE_IFUPDOWN_IP=y
CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN=y
# CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN is not set
# CONFIG_FEATURE_IFUPDOWN_IPV4 is not set
# CONFIG_FEATURE_IFUPDOWN_IPV6 is not set
# CONFIG_FEATURE_IFUPDOWN_IPX is not set
# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
# CONFIG_INETD is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set
# CONFIG_FEATURE_INETD_RPC is not set
CONFIG_FEATURE_IFUPDOWN_IPV4=y
CONFIG_FEATURE_IFUPDOWN_IPV6=y
CONFIG_FEATURE_IFUPDOWN_MAPPING=y
CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP=y
CONFIG_INETD=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME=y
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN=y
CONFIG_FEATURE_INETD_RPC=y
CONFIG_IP=y
CONFIG_FEATURE_IP_ADDRESS=y
CONFIG_FEATURE_IP_LINK=y
@@ -570,6 +655,7 @@ CONFIG_FEATURE_IP_ROUTE=y
CONFIG_FEATURE_IP_TUNNEL=y
CONFIG_FEATURE_IP_RULE=y
CONFIG_FEATURE_IP_SHORT_FORMS=y
CONFIG_FEATURE_IP_RARE_PROTOCOLS=y
CONFIG_IPADDR=y
CONFIG_IPLINK=y
CONFIG_IPROUTE=y
@@ -579,41 +665,56 @@ CONFIG_IPCALC=y
CONFIG_FEATURE_IPCALC_FANCY=y
CONFIG_FEATURE_IPCALC_LONG_OPTIONS=y
CONFIG_NAMEIF=y
CONFIG_FEATURE_NAMEIF_EXTENDED=y
CONFIG_NC=y
CONFIG_NC_SERVER=y
CONFIG_NC_EXTRA=y
CONFIG_NETSTAT=y
CONFIG_FEATURE_NETSTAT_WIDE=y
CONFIG_NSLOOKUP=y
CONFIG_PING=y
CONFIG_PING6=y
CONFIG_FEATURE_FANCY_PING=y
CONFIG_PSCAN=y
CONFIG_ROUTE=y
CONFIG_SENDMAIL=y
CONFIG_FETCHMAIL=y
CONFIG_SLATTACH=y
CONFIG_TELNET=y
CONFIG_FEATURE_TELNET_TTYPE=y
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
# CONFIG_TELNETD is not set
# CONFIG_FEATURE_TELNETD_STANDALONE is not set
CONFIG_TELNETD=y
CONFIG_FEATURE_TELNETD_STANDALONE=y
CONFIG_TFTP=y
CONFIG_TFTPD=y
CONFIG_FEATURE_TFTP_GET=y
CONFIG_FEATURE_TFTP_PUT=y
CONFIG_FEATURE_TFTP_BLOCKSIZE=y
# CONFIG_DEBUG_TFTP is not set
CONFIG_DEBUG_TFTP=y
CONFIG_TRACEROUTE=y
# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE=y
CONFIG_FEATURE_TRACEROUTE_USE_ICMP=y
CONFIG_APP_UDHCPD=y
CONFIG_APP_DHCPRELAY=y
CONFIG_APP_DUMPLEASES=y
# CONFIG_APP_UDHCPC is not set
# CONFIG_FEATURE_UDHCP_DEBUG is not set
CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY=y
CONFIG_DHCPD_LEASES_FILE="/var/lib/misc/udhcpd.leases"
CONFIG_APP_UDHCPC=y
CONFIG_FEATURE_UDHCPC_ARPING=y
CONFIG_FEATURE_UDHCP_PORT=y
CONFIG_FEATURE_UDHCP_DEBUG=y
CONFIG_FEATURE_RFC3397=y
CONFIG_DHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80
CONFIG_VCONFIG=y
CONFIG_WGET=y
CONFIG_FEATURE_WGET_STATUSBAR=y
CONFIG_FEATURE_WGET_AUTHENTICATION=y
CONFIG_FEATURE_WGET_LONG_OPTIONS=y
CONFIG_ZCIP=y
CONFIG_TCPSVD=y
CONFIG_UDPSVD=y
#
# Process Utilities
@@ -623,23 +724,31 @@ CONFIG_FUSER=y
CONFIG_KILL=y
CONFIG_KILLALL=y
CONFIG_KILLALL5=y
CONFIG_NMETER=y
CONFIG_PGREP=y
CONFIG_PIDOF=y
CONFIG_FEATURE_PIDOF_SINGLE=y
CONFIG_FEATURE_PIDOF_OMIT=y
CONFIG_PKILL=y
CONFIG_PS=y
CONFIG_FEATURE_PS_WIDE=y
CONFIG_FEATURE_PS_TIME=y
CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS=y
CONFIG_RENICE=y
CONFIG_BB_SYSCTL=y
CONFIG_TOP=y
CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y
CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS=y
CONFIG_FEATURE_TOP_DECIMALS=y
CONFIG_FEATURE_TOPMEM=y
CONFIG_UPTIME=y
CONFIG_WATCH=y
#
# Shells
#
# CONFIG_FEATURE_SH_IS_ASH is not set
# CONFIG_FEATURE_SH_IS_HUSH is not set
# CONFIG_FEATURE_SH_IS_LASH is not set
# CONFIG_FEATURE_SH_IS_MSH is not set
CONFIG_FEATURE_SH_IS_NONE=y
# CONFIG_ASH is not set
@@ -657,8 +766,14 @@ CONFIG_FEATURE_SH_IS_NONE=y
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
# CONFIG_ASH_RANDOM_SUPPORT is not set
# CONFIG_ASH_EXPAND_PRMT is not set
# CONFIG_HUSH is not set
# CONFIG_LASH is not set
CONFIG_HUSH=y
CONFIG_HUSH_HELP=y
CONFIG_HUSH_INTERACTIVE=y
CONFIG_HUSH_JOB=y
CONFIG_HUSH_TICK=y
CONFIG_HUSH_IF=y
CONFIG_HUSH_LOOPS=y
CONFIG_LASH=y
CONFIG_MSH=y
#
@@ -666,6 +781,7 @@ CONFIG_MSH=y
#
CONFIG_FEATURE_SH_EXTRA_QUIET=y
CONFIG_FEATURE_SH_STANDALONE=y
CONFIG_CTTYHACK=y
#
# System Logging Utilities
@@ -673,6 +789,7 @@ CONFIG_FEATURE_SH_STANDALONE=y
CONFIG_SYSLOGD=y
CONFIG_FEATURE_ROTATE_LOGFILE=y
CONFIG_FEATURE_REMOTE_LOG=y
CONFIG_FEATURE_SYSLOGD_DUP=y
CONFIG_FEATURE_IPC_SYSLOG=y
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=16
CONFIG_LOGREAD=y
@@ -683,28 +800,38 @@ CONFIG_LOGGER=y
#
# Runit Utilities
#
# CONFIG_RUNSV is not set
# CONFIG_RUNSVDIR is not set
CONFIG_RUNSV=y
CONFIG_RUNSVDIR=y
CONFIG_SV=y
# CONFIG_SVLOGD is not set
CONFIG_SVLOGD=y
CONFIG_CHPST=y
CONFIG_SETUIDGID=y
CONFIG_ENVUIDGID=y
CONFIG_ENVDIR=y
CONFIG_SOFTLIMIT=y
# CONFIG_CHCON is not set
# CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set
# CONFIG_GETENFORCE is not set
# CONFIG_GETSEBOOL is not set
# CONFIG_LOAD_POLICY is not set
# CONFIG_MATCHPATHCON is not set
# CONFIG_RUNCON is not set
# CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set
# CONFIG_SELINUXENABLED is not set
# CONFIG_SETENFORCE is not set
#
# ipsvd utilities
# Selinux Utilities
#
# CONFIG_TCPSVD is not set
# CONFIG_UDPSVD is not set
CONFIG_CHCON=y
CONFIG_FEATURE_CHCON_LONG_OPTIONS=y
CONFIG_GETENFORCE=y
CONFIG_GETSEBOOL=y
CONFIG_LOAD_POLICY=y
CONFIG_MATCHPATHCON=y
CONFIG_RESTORECON=y
CONFIG_RUNCON=y
CONFIG_FEATURE_RUNCON_LONG_OPTIONS=y
CONFIG_SELINUXENABLED=y
CONFIG_SETENFORCE=y
CONFIG_SETFILES=y
CONFIG_FEATURE_SETFILES_CHECK_OPTION=y
CONFIG_SETSEBOOL=y
CONFIG_SESTATUS=y
#
# Print Utilities
#
CONFIG_LPD=y
CONFIG_LPR=y
CONFIG_LPQ=y
+14 -5
View File
@@ -8,18 +8,27 @@ obj-y :=
obj-y += applets.o
hostprogs-y:=
hostprogs-y += usage
hostprogs-y += usage applet_tables
always:= $(hostprogs-y)
# Generated files need additional love
HOSTCFLAGS_usage.o = -I$(srctree)/include
applets/applets.o: include/usage_compressed.h include/applet_tables.h
applets/usage: .config $(srctree)/applets/usage_compressed
applets/applet_tables: .config
quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
cmd_gen_usage_compressed = $(srctree)/applets/usage_compressed include/usage_compressed.h applets
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)
quiet_cmd_gen_applet_tables = GEN include/applet_tables.h
cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h
include/applet_tables.h: applets/applet_tables
$(call cmd,gen_applet_tables)
+115
View File
@@ -0,0 +1,115 @@
/* vi: set sw=4 ts=4: */
/*
* Applet table generator.
* Runs on host and produces include/applet_tables.h
*
* Copyright (C) 2007 Denys Vlasenko <vda.linux@googlemail.com>
*
* Licensed under GPLv2, see file License in this tarball for details.
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "../include/autoconf.h"
#include "../include/busybox.h"
struct bb_applet {
const char *name;
const char *main;
enum bb_install_loc_t install_loc;
enum bb_suid_t need_suid;
/* true if instead of fork(); exec("applet"); waitpid();
* one can do fork(); exit(applet_main(argc,argv)); waitpid(); */
unsigned char noexec;
/* Even nicer */
/* true if instead of fork(); exec("applet"); waitpid();
* one can simply call applet_main(argc,argv); */
unsigned char nofork;
};
/* Define struct bb_applet applets[] */
#include "../include/applets.h"
enum { NUM_APPLETS = ARRAY_SIZE(applets) };
static int offset[NUM_APPLETS];
static int cmp_name(const void *a, const void *b)
{
const struct bb_applet *aa = a;
const struct bb_applet *bb = b;
return strcmp(aa->name, bb->name);
}
int main(int argc, char **argv)
{
int i;
int ofs;
qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name);
ofs = 0;
for (i = 0; i < NUM_APPLETS; i++) {
offset[i] = ofs;
ofs += strlen(applets[i].name) + 1;
}
/* We reuse 4 high-order bits of offset array for other purposes,
* so if they are indeed needed, refuse to proceed */
if (ofs > 0xfff)
return 1;
if (!argv[1])
return 1;
i = open(argv[1], O_WRONLY | O_TRUNC | O_CREAT, 0666);
if (i < 0)
return 1;
dup2(i, 1);
/* Keep in sync with include/busybox.h! */
puts("/* This is a generated file, don't edit */");
puts("const char applet_names[] ALIGN1 = \"\"\n");
for (i = 0; i < NUM_APPLETS; i++) {
printf("\"%s\" \"\\0\"\n", applets[i].name);
}
puts(";");
puts("int (*const applet_main[])(int argc, char **argv) = {");
for (i = 0; i < NUM_APPLETS; i++) {
printf("%s_main,\n", applets[i].main);
}
puts("};");
puts("const uint16_t applet_nameofs[] ALIGN2 = {");
for (i = 0; i < NUM_APPLETS; i++) {
printf("0x%04x,\n",
offset[i]
#if ENABLE_FEATURE_PREFER_APPLETS
+ (applets[i].nofork << 12)
+ (applets[i].noexec << 13)
#endif
#if ENABLE_FEATURE_SUID
+ (applets[i].need_suid << 14) /* 2 bits */
#endif
);
}
puts("};");
#if ENABLE_FEATURE_INSTALLER
puts("const uint8_t applet_install_loc[] ALIGN1 = {");
i = 0;
while (i < NUM_APPLETS) {
int v = applets[i].install_loc; /* 3 bits */
if (++i < NUM_APPLETS)
v |= applets[i].install_loc << 4; /* 3 bits */
printf("0x%02x,\n", v);
i++;
}
puts("};");
#endif
return 0;
}
+3 -14
View File
@@ -2,7 +2,7 @@
/*
* Stub for linking busybox binary against libbusybox.
*
* Copyright (C) 2007 Denis Vlasenko
* Copyright (C) 2007 Denys Vlasenko <vda.linux@googlemail.com>
*
* Licensed under GPLv2, see file License in this tarball for details.
*/
@@ -10,20 +10,9 @@
#include <assert.h>
#include "busybox.h"
/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
#warning Static linking against glibc produces buggy executables
#warning (glibc does not cope well with ld --gc-sections).
#warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
#warning Note that glibc is unsuitable for static linking anyway.
#warning If you still want to do it, remove -Wl,--gc-sections
#warning from top-level Makefile and remove this warning.
#error Aborting compilation.
#endif
#if ENABLE_BUILD_LIBBUSYBOX
int main(int argc, char **argv)
int main(int argc ATTRIBUTE_UNUSED, char **argv)
{
return lbb_main(argc, argv);
return lbb_main(argv);
}
#endif
+12 -4
View File
@@ -12,8 +12,16 @@ sz=`"$loc/usage" | wc -c` || exit 1
exec >"$target"
echo 'static const char packed_usage[] ALIGN1 = '
"$loc/usage" | bzip2 -1 | od -v -t x1 \
| $SED -e 's/^[^ ]*//' -e 's/ *\(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/'
echo ';'
echo 'static const char packed_usage[] ALIGN1 = {'
# Extra effort to avoid using "od -t x1": -t is not available
# in non-CONFIG_DESKTOPed busybox od
"$loc/usage" | bzip2 -1 | od -v -x \
| $SED -e 's/^[^ ]*//' \
| $SED -e 's/ //g' \
| grep -v '^$' \
| $SED -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
echo '};'
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
+38 -21
View File
@@ -29,7 +29,7 @@ config AR
probably say N here.
config FEATURE_AR_LONG_FILENAMES
bool "Enable support for long filenames (not need for debs)"
bool "Support for long filenames (not need for debs)"
default n
depends on AR
help
@@ -99,7 +99,7 @@ config DPKG_DEB
probably say N here.
config FEATURE_DPKG_DEB_EXTRACT_ONLY
bool "extract only (-x)"
bool "Extract only (-x)"
default n
depends on DPKG_DEB
help
@@ -166,6 +166,14 @@ config FEATURE_TAR_CREATE
If you enable this option you'll be able to create
tar archives using the `-c' option.
config FEATURE_TAR_GZIP
bool "Enable -z option"
default y
depends on TAR
help
If you enable this option tar will be able to call gzip,
when creating or extracting tar gziped archives.
config FEATURE_TAR_BZIP2
bool "Enable -j option to handle .tar.bz2 files"
default n
@@ -182,22 +190,6 @@ config FEATURE_TAR_LZMA
If you enable this option you'll be able to extract
archives compressed with lzma.
config FEATURE_TAR_FROM
bool "Enable -X (exclude from) and -T (include from) options)"
default n
depends on TAR
help
If you enable this option you'll be able to specify
a list of files to include or exclude from an archive.
config FEATURE_TAR_GZIP
bool "Enable -z option"
default y
depends on TAR
help
If you enable this option tar will be able to call gzip,
when creating or extracting tar gziped archives.
config FEATURE_TAR_COMPRESS
bool "Enable -Z option"
default n
@@ -206,8 +198,24 @@ config FEATURE_TAR_COMPRESS
If you enable this option tar will be able to call uncompress,
when extracting .tar.Z archives.
config FEATURE_TAR_AUTODETECT
bool "Let tar autodetect gz/bz2 compresses tarballs"
default n
depends on FEATURE_TAR_GZIP || FEATURE_TAR_BZIP2
help
With this option tar can automatically detect gzip/bzip2 compressed
tarballs. Currently it works only on seekable streams.
config FEATURE_TAR_FROM
bool "Enable -X (exclude from) and -T (include from) options)"
default n
depends on TAR
help
If you enable this option you'll be able to specify
a list of files to include or exclude from an archive.
config FEATURE_TAR_OLDGNU_COMPATIBILITY
bool "Enable support for old tar header format"
bool "Support for old tar header format"
default N
depends on TAR
help
@@ -225,7 +233,7 @@ config FEATURE_TAR_OLDSUN_COMPATIBILITY
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"
bool "Support for GNU tar extensions (long filenames)"
default y
depends on TAR
help
@@ -237,7 +245,16 @@ config FEATURE_TAR_LONG_OPTIONS
default n
depends on TAR && GETOPT_LONG
help
Enable use of long options, increases size by about 400 Bytes
Enable use of long options, increases size by about 400 Bytes
config FEATURE_TAR_UNAME_GNAME
bool "Enable use of user and group names"
default n
depends on TAR
help
Enables use of user and group names in tar. This affects contents
listings (-t) and preserving permissions when unpacking (-p).
+200 bytes.
config UNCOMPRESS
bool "uncompress"
+4 -4
View File
@@ -159,7 +159,7 @@ USE_DESKTOP(long long) int unpack_bunzip2(void)
}
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int bunzip2_main(int argc, char **argv)
int bunzip2_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
getopt32(argv, "cfvdt");
argv += optind;
@@ -257,7 +257,7 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
}
int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int gunzip_main(int argc, char **argv)
int gunzip_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
getopt32(argv, "cfvdt");
argv += optind;
@@ -295,7 +295,7 @@ USE_DESKTOP(long long) int unpack_unlzma(void)
}
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int unlzma_main(int argc, char **argv)
int unlzma_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
getopt32(argv, "cf");
argv += optind;
@@ -337,7 +337,7 @@ USE_DESKTOP(long long) int unpack_uncompress(void)
}
int uncompress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int uncompress_main(int argc, char **argv)
int uncompress_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
getopt32(argv, "cf");
argv += optind;
+15 -6
View File
@@ -721,7 +721,8 @@ void mainQSort3(uint32_t* ptr,
#define CLEARMASK (~(SETMASK))
static NOINLINE
void mainSort(uint32_t* ptr,
void mainSort(EState* state,
uint32_t* ptr,
uint8_t* block,
uint16_t* quadrant,
uint32_t* ftab,
@@ -729,13 +730,18 @@ void mainSort(uint32_t* ptr,
int32_t* budget)
{
int32_t i, j, k, ss, sb;
int32_t runningOrder[256];
Bool bigDone[256];
int32_t copyStart[256];
int32_t copyEnd [256];
uint8_t c1;
int32_t numQSorted;
uint16_t s;
Bool bigDone[256];
/* bbox: moved to EState to save stack
int32_t runningOrder[256];
int32_t copyStart[256];
int32_t copyEnd [256];
*/
#define runningOrder (state->mainSort__runningOrder)
#define copyStart (state->mainSort__copyStart)
#define copyEnd (state->mainSort__copyEnd)
/*-- set up the 2-byte frequency table --*/
/* was: for (i = 65536; i >= 0; i--) ftab[i] = 0; */
@@ -985,6 +991,9 @@ void mainSort(uint32_t* ptr,
AssertH(((bbSize-1) >> shifts) <= 65535, 1002);
}
}
#undef runningOrder
#undef copyStart
#undef copyEnd
}
#undef BIGFREQ
@@ -1041,7 +1050,7 @@ void BZ2_blockSort(EState* s)
*/
budget = nblock * ((wfact-1) / 3);
mainSort(ptr, block, quadrant, ftab, nblock, &budget);
mainSort(s, ptr, block, quadrant, ftab, nblock, &budget);
if (budget < 0) {
fallbackSort(s->arr1, s->arr2, ftab, nblock);
}
+14 -5
View File
@@ -178,13 +178,22 @@ typedef struct EState {
uint8_t selector [BZ_MAX_SELECTORS];
uint8_t selectorMtf[BZ_MAX_SELECTORS];
uint8_t len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
int32_t code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
int32_t rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
uint8_t len[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
/* stack-saving measures: these can be local, but they are too big */
int32_t sendMTFValues__code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
int32_t sendMTFValues__rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
#if CONFIG_BZIP2_FEATURE_SPEED >= 5
/* second dimension: only 3 needed; 4 makes index calculations faster */
uint32_t len_pack[BZ_MAX_ALPHA_SIZE][4];
uint32_t sendMTFValues__len_pack[BZ_MAX_ALPHA_SIZE][4];
#endif
int32_t BZ2_hbMakeCodeLengths__heap [BZ_MAX_ALPHA_SIZE + 2];
int32_t BZ2_hbMakeCodeLengths__weight[BZ_MAX_ALPHA_SIZE * 2];
int32_t BZ2_hbMakeCodeLengths__parent[BZ_MAX_ALPHA_SIZE * 2];
int32_t mainSort__runningOrder[256];
int32_t mainSort__copyStart[256];
int32_t mainSort__copyEnd[256];
} EState;
@@ -203,7 +212,7 @@ static void
BZ2_hbAssignCodes(int32_t*, uint8_t*, int32_t, int32_t, int32_t);
static void
BZ2_hbMakeCodeLengths(uint8_t*, int32_t*, int32_t, int32_t);
BZ2_hbMakeCodeLengths(EState*, uint8_t*, int32_t*, int32_t, int32_t);
/*-------------------------------------------------------------*/
/*--- end bzlib_private.h ---*/
+8 -2
View File
@@ -264,13 +264,16 @@ void sendMTFValues(EState* s)
* are also globals only used in this proc.
* Made global to keep stack frame size small.
*/
#define code sendMTFValues__code
#define rfreq sendMTFValues__rfreq
#define len_pack sendMTFValues__len_pack
uint16_t cost[BZ_N_GROUPS];
int32_t fave[BZ_N_GROUPS];
uint16_t* mtfv = s->mtfv;
alphaSize = s->nInUse+2;
alphaSize = s->nInUse + 2;
for (t = 0; t < BZ_N_GROUPS; t++)
for (v = 0; v < alphaSize; v++)
s->len[t][v] = BZ_GREATER_ICOST;
@@ -453,7 +456,7 @@ void sendMTFValues(EState* s)
/* maxLen was changed from 20 to 17 in bzip2-1.0.3. See
* comment in huffman.c for details. */
for (t = 0; t < nGroups; t++)
BZ2_hbMakeCodeLengths(&(s->len[t][0]), &(s->rfreq[t][0]), alphaSize, 17 /*20*/);
BZ2_hbMakeCodeLengths(s, &(s->len[t][0]), &(s->rfreq[t][0]), alphaSize, 17 /*20*/);
}
AssertH(nGroups < 8, 3002);
@@ -602,6 +605,9 @@ void sendMTFValues(EState* s)
selCtr++;
}
AssertH(selCtr == nSelectors, 3007);
#undef code
#undef rfreq
#undef len_pack
}
+10 -1
View File
@@ -98,7 +98,8 @@ void DOWNHEAP1(int32_t *heap, int32_t *weight, int32_t nHeap)
/*---------------------------------------------------*/
static
void BZ2_hbMakeCodeLengths(uint8_t *len,
void BZ2_hbMakeCodeLengths(EState *s,
uint8_t *len,
int32_t *freq,
int32_t alphaSize,
int32_t maxLen)
@@ -110,9 +111,14 @@ void BZ2_hbMakeCodeLengths(uint8_t *len,
int32_t nNodes, nHeap, n1, n2, i, j, k;
Bool tooLong;
/* bbox: moved to EState to save stack
int32_t heap [BZ_MAX_ALPHA_SIZE + 2];
int32_t weight[BZ_MAX_ALPHA_SIZE * 2];
int32_t parent[BZ_MAX_ALPHA_SIZE * 2];
*/
#define heap (s->BZ2_hbMakeCodeLengths__heap)
#define weight (s->BZ2_hbMakeCodeLengths__weight)
#define parent (s->BZ2_hbMakeCodeLengths__parent)
for (i = 0; i < alphaSize; i++)
weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
@@ -189,6 +195,9 @@ void BZ2_hbMakeCodeLengths(uint8_t *len,
weight[i] = j << 8;
}
}
#undef heap
#undef weight
#undef parent
}
+1 -1
View File
@@ -141,7 +141,7 @@ char* make_new_name_bzip2(char *filename)
}
int bzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int bzip2_main(int argc, char **argv)
int bzip2_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
unsigned opt;
+9 -13
View File
@@ -602,7 +602,7 @@ 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;
}
field_num = index_in_strings(field_names, field_name);
@@ -745,7 +745,7 @@ static void index_status_file(const char *filename)
unsigned status_num;
status_file = xfopen(filename, "r");
while ((control_buffer = xmalloc_fgets_str(status_file, "\n\n")) != NULL) {
while ((control_buffer = xmalloc_fgetline_str(status_file, "\n\n")) != NULL) {
const unsigned package_num = fill_package_struct(control_buffer);
if (package_num != -1) {
status_node = xmalloc(sizeof(status_node_t));
@@ -798,7 +798,7 @@ static void write_status_file(deb_file_t **deb_file)
int i = 0;
/* Update previously known packages */
while ((control_buffer = xmalloc_fgets_str(old_status_file, "\n\n")) != NULL) {
while ((control_buffer = xmalloc_fgetline_str(old_status_file, "\n\n")) != NULL) {
tmp_string = strstr(control_buffer, "Package:");
if (tmp_string == NULL) {
continue;
@@ -913,20 +913,16 @@ static void write_status_file(deb_file_t **deb_file)
fclose(old_status_file);
fclose(new_status_file);
/* Create a separate backfile to dpkg */
if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) {
struct stat stat_buf;
xstat("/var/lib/dpkg/status", &stat_buf);
if (errno != ENOENT)
bb_error_msg_and_die("cannot create backup status file");
/* Its ok if renaming the status file fails because status
* file doesnt exist, maybe we are starting from scratch */
bb_error_msg("no status file found, creating new one");
}
if (rename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status") == -1) {
bb_error_msg_and_die("DANGER: cannot create status file, "
"you need to manually repair your status file");
}
xrename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status");
}
/* This function returns TRUE if the given package can satisfy a
@@ -953,7 +949,7 @@ static int package_satisfies_dependency(int package, int depend_type)
return 0;
}
static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count - ?? */)
{
int *conflicts = NULL;
int conflicts_num = 0;
@@ -1344,7 +1340,7 @@ static void remove_package(const unsigned package_num, int noisy)
free_array(exclude_files);
/* rename <package>.conffile to <package>.list */
rename(conffile_name, list_name);
xrename(conffile_name, list_name);
/* Change package status */
set_status(status_num, "config-files", 3);
@@ -1693,7 +1689,7 @@ int dpkg_main(int argc, char **argv)
/* Check that the deb file arguments are installable */
if (!(opt & OPT_force_ignore_depends)) {
if (!check_deps(deb_file, 0, deb_count)) {
if (!check_deps(deb_file, 0 /*, deb_count*/)) {
bb_error_msg_and_die("dependency check failed");
}
}
+1 -1
View File
@@ -41,7 +41,7 @@ int dpkg_deb_main(int argc, char **argv)
llist_add_to(&control_tar_llist, (char*)"control.tar.bz2");
#endif
opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
opt_complementary = "c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
opt = getopt32(argv, "cefXx");
if (opt & DPKG_DEB_OPT_CONTENTS) {
+6 -2
View File
@@ -2026,7 +2026,11 @@ USE_DESKTOP(long long) int pack_gzip(void)
}
int gzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
#if ENABLE_GUNZIP
int gzip_main(int argc, char **argv)
#else
int gzip_main(int argc ATTRIBUTE_UNUSED, char **argv)
#endif
{
unsigned opt;
@@ -2042,8 +2046,8 @@ int gzip_main(int argc, char **argv)
//if (opt & 0x4) // -v
argv += optind;
PTR_TO_GLOBALS = xzalloc(sizeof(struct globals) + sizeof(struct globals2))
+ sizeof(struct globals);
SET_PTR_TO_GLOBALS(xzalloc(sizeof(struct globals) + sizeof(struct globals2))
+ sizeof(struct globals));
G2.l_desc.dyn_tree = G2.dyn_ltree;
G2.l_desc.static_tree = G2.static_ltree;
G2.l_desc.extra_bits = extra_lbits;
+2 -4
View File
@@ -3,14 +3,12 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
//#include <sys/types.h>
#include "libbb.h"
#include "unarchive.h"
void data_align(archive_handle_t *archive_handle, const unsigned short boundary)
void data_align(archive_handle_t *archive_handle, unsigned boundary)
{
const unsigned short skip_amount = (boundary - (archive_handle->offset % boundary)) % boundary;
unsigned skip_amount = (boundary - (archive_handle->offset % boundary)) % boundary;
archive_handle->seek(archive_handle, skip_amount);
archive_handle->offset += skip_amount;
+15
View File
@@ -112,7 +112,22 @@ void data_extract_all(archive_handle_t *archive_handle)
}
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) {
#if ENABLE_FEATURE_TAR_UNAME_GNAME
uid_t uid = file_header->uid;
gid_t gid = file_header->gid;
if (file_header->uname) {
struct passwd *pwd = getpwnam(file_header->uname);
if (pwd) uid = pwd->pw_uid;
}
if (file_header->gname) {
struct group *grp = getgrnam(file_header->gname);
if (grp) gid = grp->gr_gid;
}
lchown(file_header->name, uid, gid);
#else
lchown(file_header->name, file_header->uid, file_header->gid);
#endif
}
if ((file_header->mode & S_IFMT) != S_IFLNK) {
/* uclibc has no lchmod, glibc is even stranger -
+41 -40
View File
@@ -282,14 +282,16 @@ unpack_lzma_stream(int src_fd, int dst_fd)
while (global_pos + buffer_pos < header.dst_size) {
int pos_state = (buffer_pos + global_pos) & pos_state_mask;
prob =
p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state;
prob = p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state;
if (rc_is_bit_0(rc, prob)) {
mi = 1;
rc_update_bit_0(rc, prob);
prob = (p + LZMA_LITERAL + (LZMA_LIT_SIZE
* ((((buffer_pos + global_pos) & literal_pos_mask) << lc)
+ (previous_byte >> (8 - lc)))));
prob = (p + LZMA_LITERAL
+ (LZMA_LIT_SIZE * ((((buffer_pos + global_pos) & literal_pos_mask) << lc)
+ (previous_byte >> (8 - lc))
)
)
);
if (state >= LZMA_NUM_LIT_STATES) {
int match_byte;
@@ -304,21 +306,25 @@ unpack_lzma_stream(int src_fd, int dst_fd)
match_byte <<= 1;
bit = match_byte & 0x100;
prob_lit = prob + 0x100 + bit + mi;
if (rc_get_bit(rc, prob_lit, &mi)) {
if (!bit)
break;
} else {
if (bit)
break;
}
bit ^= (rc_get_bit(rc, prob_lit, &mi) << 8); /* 0x100 or 0 */
if (bit)
break;
} while (mi < 0x100);
}
while (mi < 0x100) {
prob_lit = prob + mi;
rc_get_bit(rc, prob_lit, &mi);
}
previous_byte = (uint8_t) mi;
state -= 3;
if (state < 4-3)
state = 0;
if (state >= 10-3)
state -= 6-3;
previous_byte = (uint8_t) mi;
#if ENABLE_FEATURE_LZMA_FAST
one_byte1:
buffer[buffer_pos++] = previous_byte;
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
@@ -327,12 +333,10 @@ unpack_lzma_stream(int src_fd, int dst_fd)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
}
if (state < 4)
state = 0;
else if (state < 10)
state -= 3;
else
state -= 6;
#else
len = 1;
goto one_byte2;
#endif
} else {
int offset;
uint16_t *prob_len;
@@ -352,24 +356,23 @@ unpack_lzma_stream(int src_fd, int dst_fd)
if (rc_is_bit_0(rc, prob)) {
rc_update_bit_0(rc, prob);
prob = (p + LZMA_IS_REP_0_LONG
+ (state << LZMA_NUM_POS_BITS_MAX) + pos_state);
+ (state << LZMA_NUM_POS_BITS_MAX)
+ pos_state
);
if (rc_is_bit_0(rc, prob)) {
rc_update_bit_0(rc, prob);
state = state < LZMA_NUM_LIT_STATES ? 9 : 11;
#if ENABLE_FEATURE_LZMA_FAST
pos = buffer_pos - rep0;
while (pos >= header.dict_size)
pos += header.dict_size;
previous_byte = buffer[pos];
buffer[buffer_pos++] = previous_byte;
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
global_pos += header.dict_size;
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
goto bad;
USE_DESKTOP(total_written += header.dict_size;)
}
continue;
goto one_byte1;
#else
len = 1;
goto string;
#endif
} else {
rc_update_bit_1(rc, prob);
}
@@ -405,7 +408,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
if (rc_is_bit_0(rc, prob_len)) {
rc_update_bit_0(rc, prob_len);
prob_len = (prob + LZMA_LEN_LOW
+ (pos_state << LZMA_LEN_NUM_LOW_BITS));
+ (pos_state << LZMA_LEN_NUM_LOW_BITS));
offset = 0;
num_bits = LZMA_LEN_NUM_LOW_BITS;
} else {
@@ -414,14 +417,14 @@ unpack_lzma_stream(int src_fd, int dst_fd)
if (rc_is_bit_0(rc, prob_len)) {
rc_update_bit_0(rc, prob_len);
prob_len = (prob + LZMA_LEN_MID
+ (pos_state << LZMA_LEN_NUM_MID_BITS));
+ (pos_state << LZMA_LEN_NUM_MID_BITS));
offset = 1 << LZMA_LEN_NUM_LOW_BITS;
num_bits = LZMA_LEN_NUM_MID_BITS;
} else {
rc_update_bit_1(rc, prob_len);
prob_len = prob + LZMA_LEN_HIGH;
offset = ((1 << LZMA_LEN_NUM_LOW_BITS)
+ (1 << LZMA_LEN_NUM_MID_BITS));
+ (1 << LZMA_LEN_NUM_MID_BITS));
num_bits = LZMA_LEN_NUM_HIGH_BITS;
}
}
@@ -432,12 +435,10 @@ unpack_lzma_stream(int src_fd, int dst_fd)
int pos_slot;
state += LZMA_NUM_LIT_STATES;
prob =
p + LZMA_POS_SLOT +
((len <
LZMA_NUM_LEN_TO_POS_STATES ? len :
LZMA_NUM_LEN_TO_POS_STATES - 1)
<< LZMA_NUM_POS_SLOT_BITS);
prob = p + LZMA_POS_SLOT +
((len < LZMA_NUM_LEN_TO_POS_STATES ? len :
LZMA_NUM_LEN_TO_POS_STATES - 1)
<< LZMA_NUM_POS_SLOT_BITS);
rc_bit_tree_decode(rc, prob, LZMA_NUM_POS_SLOT_BITS,
&pos_slot);
if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
@@ -468,12 +469,13 @@ unpack_lzma_stream(int src_fd, int dst_fd)
}
len += LZMA_MATCH_MIN_LEN;
SKIP_FEATURE_LZMA_FAST(string:)
do {
pos = buffer_pos - rep0;
while (pos >= header.dict_size)
pos += header.dict_size;
previous_byte = buffer[pos];
SKIP_FEATURE_LZMA_FAST(one_byte2:)
buffer[buffer_pos++] = previous_byte;
if (buffer_pos == header.dict_size) {
buffer_pos = 0;
@@ -487,7 +489,6 @@ unpack_lzma_stream(int src_fd, int dst_fd)
}
}
if (full_write(dst_fd, buffer, buffer_pos) != buffer_pos) {
bad:
rc_free(rc);
+18 -6
View File
@@ -85,7 +85,8 @@ typedef struct state_t {
/* input (compressed) data */
unsigned char *bytebuffer; /* buffer itself */
unsigned bytebuffer_max; /* buffer size */
off_t to_read; /* compressed bytes to read (unzip only, -1 for gunzip) */
// unsigned bytebuffer_max; /* buffer size */
unsigned bytebuffer_offset; /* buffer position */
unsigned bytebuffer_size; /* how much data is there (size <= max) */
@@ -126,7 +127,10 @@ typedef struct state_t {
#define gunzip_crc_table (S()gunzip_crc_table )
#define gunzip_bb (S()gunzip_bb )
#define gunzip_bk (S()gunzip_bk )
#define bytebuffer_max (S()bytebuffer_max )
#define to_read (S()to_read )
// #define bytebuffer_max (S()bytebuffer_max )
// Both gunzip and unzip can use constant buffer size now (16k):
#define bytebuffer_max 0x4000
#define bytebuffer (S()bytebuffer )
#define bytebuffer_offset (S()bytebuffer_offset )
#define bytebuffer_size (S()bytebuffer_size )
@@ -251,13 +255,18 @@ static unsigned fill_bitbuffer(STATE_PARAM unsigned bitbuffer, unsigned *current
{
while (*current < required) {
if (bytebuffer_offset >= bytebuffer_size) {
unsigned sz = bytebuffer_max - 4;
if (to_read >= 0 && to_read < sz) /* unzip only */
sz = to_read;
/* Leave the first 4 bytes empty so we can always unwind the bitbuffer
* to the front of the bytebuffer */
bytebuffer_size = safe_read(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 4);
bytebuffer_size = safe_read(gunzip_src_fd, &bytebuffer[4], sz);
if ((int)bytebuffer_size < 1) {
error_msg = "unexpected end of file";
abort_unzip(PASS_STATE_ONLY);
}
if (to_read >= 0) /* unzip only */
to_read -= bytebuffer_size;
bytebuffer_size += 4;
bytebuffer_offset = 4;
}
@@ -1025,14 +1034,15 @@ inflate_unzip_internal(STATE_PARAM int in, int out)
/* For unzip */
USE_DESKTOP(long long) int
inflate_unzip(inflate_unzip_result *res, unsigned bufsize, int in, int out)
inflate_unzip(inflate_unzip_result *res, off_t compr_size, int in, int out)
{
USE_DESKTOP(long long) int n;
DECLARE_STATE;
ALLOC_STATE;
bytebuffer_max = bufsize + 4;
to_read = compr_size;
// bytebuffer_max = 0x8000;
bytebuffer_offset = 4;
bytebuffer = xmalloc(bytebuffer_max);
n = inflate_unzip_internal(PASS_STATE in, out);
@@ -1176,8 +1186,10 @@ unpack_gz_stream(int in, int out)
n = 0;
ALLOC_STATE;
bytebuffer_max = 0x8000;
to_read = -1;
// bytebuffer_max = 0x8000;
bytebuffer = xmalloc(bytebuffer_max);
gunzip_src_fd = in;
again:
if (!check_header_gzip(PASS_STATE_ONLY)) {
@@ -13,11 +13,14 @@
*/
char filter_accept_reject_list(archive_handle_t *archive_handle)
{
const char *key = archive_handle->file_header->name;
const llist_t *reject_entry = find_list_entry2(archive_handle->reject, key);
const char *key;
const llist_t *reject_entry;
const llist_t *accept_entry;
key = archive_handle->file_header->name;
/* If the key is in a reject list fail */
reject_entry = find_list_entry2(archive_handle->reject, key);
if (reject_entry) {
return EXIT_FAILURE;
}
+1 -1
View File
@@ -38,7 +38,7 @@ const llist_t *find_list_entry2(const llist_t *list, const char *filename)
if (*c++ == '/') pattern_slash_cnt++;
c = filename;
d = buf;
/* paranoia is better that buffer overflows */
/* paranoia is better than buffer overflows */
while (*c && d != buf + sizeof(buf)-1) {
if (*c == '/' && --pattern_slash_cnt < 0)
break;
+82 -17
View File
@@ -46,6 +46,9 @@ void BUG_tar_header_size(void);
char get_header_tar(archive_handle_t *archive_handle)
{
static smallint end;
#if ENABLE_FEATURE_TAR_AUTODETECT
static smallint not_first;
#endif
file_header_t *file_header = archive_handle->file_header;
struct {
@@ -59,8 +62,12 @@ char get_header_tar(archive_handle_t *archive_handle)
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[100]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
/* POSIX: "ustar" NUL "00" */
/* GNU tar: "ustar " NUL */
/* Normally it's defined as magic[6] followed by
* version[2], but we put them together to save code.
*/
char magic[8]; /* 257-264 */
char uname[32]; /* 265-296 */
char gname[32]; /* 297-328 */
char devmajor[8]; /* 329-336 */
@@ -86,17 +93,32 @@ char get_header_tar(archive_handle_t *archive_handle)
again_after_align:
#if ENABLE_DESKTOP
i = full_read(archive_handle->src_fd, &tar, 512);
/* if GNU tar sees EOF in above read, it says:
* "tar: A lone zero block at N", where N = kilobyte
* where EOF was met (not EOF block, actual EOF!),
* and tar will exit with error code 0.
* We will mimic exit(EXIT_SUCCESS), although we will not mimic
* the message and we don't check whether we indeed
* saw zero block directly before this. */
if (i == 0)
xfunc_error_retval = 0;
if (i != 512)
bb_error_msg_and_die("short read");
#else
xread(archive_handle->src_fd, &tar, 512);
#endif
archive_handle->offset += 512;
/* If there is no filename its an empty header */
if (tar.name[0] == 0) {
if (tar.name[0] == 0 && tar.prefix[0] == 0) {
if (end) {
/* This is the second consecutive empty header! End of archive!
* Read until the end to empty the pipe from gz or bz2
*/
while (full_read(archive_handle->src_fd, &tar, 512) == 512)
/* repeat */;
continue;
return EXIT_FAILURE;
}
end = 1;
@@ -104,16 +126,49 @@ char get_header_tar(archive_handle_t *archive_handle)
}
end = 0;
/* Check header has valid magic, "ustar" is for the proper tar
* 0's are for the old tar format
*/
if (strncmp(tar.magic, "ustar", 5) != 0) {
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
if (memcmp(tar.magic, "\0\0\0\0", 5) != 0)
/* Check header has valid magic, "ustar" is for the proper tar,
* five NULs are for the old tar format */
if (strncmp(tar.magic, "ustar", 5) != 0
&& (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
|| memcmp(tar.magic, "\0\0\0\0", 5) != 0)
) {
#if ENABLE_FEATURE_TAR_AUTODETECT
char (*get_header_ptr)(archive_handle_t *);
/* tar gz/bz autodetect: check for gz/bz2 magic.
* If it is the very first block, and we see the magic,
* we can switch to get_header_tar_gz/bz2/lzma().
* Needs seekable fd. I wish recv(MSG_PEEK) works
* on any fd... */
if (not_first)
goto err;
#if ENABLE_FEATURE_TAR_GZIP
if (tar.name[0] == 0x1f && tar.name[1] == (char)0x8b) { /* gzip */
get_header_ptr = get_header_tar_gz;
} else
#endif
bb_error_msg_and_die("invalid tar magic");
#if ENABLE_FEATURE_TAR_BZIP2
if (tar.name[0] == 'B' && tar.name[1] == 'Z'
&& tar.name[2] == 'h' && isdigit(tar.name[3])
) { /* bzip2 */
get_header_ptr = get_header_tar_bz2;
} else
#endif
goto err;
if (lseek(archive_handle->src_fd, -512, SEEK_CUR) != 0)
goto err;
while (get_header_ptr(archive_handle) == EXIT_SUCCESS)
continue;
return EXIT_FAILURE;
err:
#endif /* FEATURE_TAR_AUTODETECT */
bb_error_msg_and_die("invalid tar magic");
}
#if ENABLE_FEATURE_TAR_AUTODETECT
not_first = 1;
#endif
/* Do checksum on headers.
* POSIX says that checksum is done on unsigned bytes, but
* Sun and HP-UX gets it wrong... more details in
@@ -156,18 +211,23 @@ char get_header_tar(archive_handle_t *archive_handle)
/* getOctal trashes subsequent field, therefore we call it
* on fields in reverse order */
if (tar.devmajor[0]) {
char t = tar.prefix[0];
/* we trash prefix[0] here, but we DO need it later! */
unsigned minor = GET_OCTAL(tar.devminor);
unsigned major = GET_OCTAL(tar.devmajor);
file_header->device = makedev(major, minor);
tar.prefix[0] = t;
}
file_header->link_target = NULL;
if (!linkname && parse_names && tar.linkname[0]) {
/* we trash magic[0] here, it's ok */
tar.linkname[sizeof(tar.linkname)] = '\0';
file_header->link_target = xstrdup(tar.linkname);
file_header->link_target = xstrndup(tar.linkname, sizeof(tar.linkname));
/* FIXME: what if we have non-link object with link_target? */
/* Will link_target be free()ed? */
}
#if ENABLE_FEATURE_TAR_UNAME_GNAME
file_header->uname = tar.uname[0] ? xstrndup(tar.uname, sizeof(tar.uname)) : NULL;
file_header->gname = tar.gname[0] ? xstrndup(tar.gname, sizeof(tar.gname)) : NULL;
#endif
file_header->mtime = GET_OCTAL(tar.mtime);
file_header->size = GET_OCTAL(tar.size);
file_header->gid = GET_OCTAL(tar.gid);
@@ -178,10 +238,12 @@ char get_header_tar(archive_handle_t *archive_handle)
file_header->name = NULL;
if (!longname && parse_names) {
/* we trash mode[0] here, it's ok */
tar.name[sizeof(tar.name)] = '\0';
//tar.name[sizeof(tar.name)] = '\0'; - gcc 4.3.0 would complain
tar.mode[0] = '\0';
if (tar.prefix[0]) {
/* and padding[0] */
tar.prefix[sizeof(tar.prefix)] = '\0';
//tar.prefix[sizeof(tar.prefix)] = '\0'; - gcc 4.3.0 would complain
tar.padding[0] = '\0';
file_header->name = concat_path_file(tar.prefix, tar.name);
} else
file_header->name = xstrdup(tar.name);
@@ -298,6 +360,9 @@ char get_header_tar(archive_handle_t *archive_handle)
free(file_header->link_target);
/* Do not free(file_header->name)! */
#if ENABLE_FEATURE_TAR_UNAME_GNAME
free(file_header->uname);
free(file_header->gname);
#endif
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, unpack_bz2_stream, "bunzip2", "bunzip2", "-cf", "-", NULL);
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2");
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
continue;
+1 -1
View File
@@ -25,7 +25,7 @@ char get_header_tar_gz(archive_handle_t *archive_handle)
}
#endif
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip", "gunzip", "-cf", "-", NULL);
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip");
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
continue;
+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, unpack_lzma_stream, "unlzma", "unlzma", "-cf", "-", NULL);
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma");
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
continue;
@@ -10,6 +10,33 @@ void header_verbose_list(const file_header_t *file_header)
{
struct tm *mtime = localtime(&(file_header->mtime));
#if ENABLE_FEATURE_TAR_UNAME_GNAME
char uid[8];
char gid[8];
char *user = file_header->uname;
char *group = file_header->gname;
if (user == NULL) {
snprintf(uid, sizeof(uid), "%u", (unsigned)file_header->uid);
user = uid;
}
if (group == NULL) {
snprintf(gid, sizeof(gid), "%u", (unsigned)file_header->gid);
group = gid;
}
printf("%s %s/%s %9u %4u-%02u-%02u %02u:%02u:%02u %s",
bb_mode_string(file_header->mode),
user,
group,
(unsigned int) file_header->size,
1900 + mtime->tm_year,
1 + mtime->tm_mon,
mtime->tm_mday,
mtime->tm_hour,
mtime->tm_min,
mtime->tm_sec,
file_header->name);
#else /* !FEATURE_TAR_UNAME_GNAME */
printf("%s %d/%d %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
bb_mode_string(file_header->mode),
file_header->uid,
@@ -22,6 +49,7 @@ void header_verbose_list(const file_header_t *file_header)
mtime->tm_min,
mtime->tm_sec,
file_header->name);
#endif /* FEATURE_TAR_UNAME_GNAME */
if (file_header->link_target) {
printf(" -> %s", file_header->link_target);
+21 -19
View File
@@ -8,17 +8,17 @@
/* 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.
* On MMU machine, the transform_prog is removed by macro magic
* in include/unarchive.h. On NOMMU, transformer is removed.
*/
int open_transformer(int src_fd,
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd),
const char *transform_prog, ...)
const char *transform_prog)
{
int fd_pipe[2];
struct fd_pair fd_pipe;
int pid;
xpipe(fd_pipe);
xpiped_pair(fd_pipe);
#if BB_MMU
pid = fork();
@@ -29,32 +29,34 @@ int open_transformer(int src_fd,
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 */
close(fd_pipe.rd); /* We don't want to read from the parent */
// FIXME: error check?
#if BB_MMU
transformer(src_fd, fd_pipe[1]);
transformer(src_fd, fd_pipe.wr);
if (ENABLE_FEATURE_CLEAN_UP) {
close(fd_pipe[1]); /* Send EOF */
close(fd_pipe.wr); /* Send EOF */
close(src_fd);
}
exit(0);
#else
xmove_fd(src_fd, 0);
xmove_fd(fd_pipe[1], 1);
va_start(ap, transform_prog);
/* hoping that va_list -> char** on our CPU is working... */
BB_EXECVP(transform_prog, (void*)ap);
bb_perror_msg_and_die("exec failed");
{
char *argv[4];
xmove_fd(src_fd, 0);
xmove_fd(fd_pipe.wr, 1);
argv[0] = (char*)transform_prog;
argv[1] = (char*)"-cf";
argv[2] = (char*)"-";
argv[3] = NULL;
BB_EXECVP(transform_prog, argv);
bb_perror_msg_and_die("exec failed");
}
#endif
/* notreached */
}
/* parent process */
close(fd_pipe[1]); /* Don't want to write to the child */
close(fd_pipe.wr); /* Don't want to write to the child */
return fd_pipe[0];
return fd_pipe.rd;
}
+1 -1
View File
@@ -6,7 +6,7 @@
#include "libbb.h"
#include "unarchive.h"
void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount)
void seek_by_jump(const archive_handle_t *archive_handle, unsigned amount)
{
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
#if ENABLE_FEATURE_UNARCHIVE_TAPE
+2 -2
View File
@@ -6,10 +6,10 @@
#include "libbb.h"
#include "unarchive.h"
/* If we are reading through a pipe(), or from stdin then we can't lseek,
/* If we are reading through a pipe, or from stdin then we can't lseek,
* we must read and discard the data to skip over it.
*/
void seek_by_read(const archive_handle_t *archive_handle, const unsigned int jump_size)
void seek_by_read(const archive_handle_t *archive_handle, unsigned jump_size)
{
if (jump_size)
bb_copyfd_exact_size(archive_handle->src_fd, -1, jump_size);
+1 -1
View File
@@ -237,7 +237,7 @@ static void extract_cpio_gz(int fd)
}
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->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog);
archive_handle->offset = 0;
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
continue;
+51 -22
View File
@@ -28,8 +28,22 @@
#include "libbb.h"
#include "unarchive.h"
/* FIXME: Stop using this non-standard feature */
#ifndef FNM_LEADING_DIR
#define FNM_LEADING_DIR 0
#endif
#define block_buf bb_common_bufsiz1
#if !ENABLE_FEATURE_TAR_GZIP && !ENABLE_FEATURE_TAR_BZIP2
/* Do not pass gzip flag to writeTarFile() */
#define writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude, gzip) \
writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude)
#endif
#if ENABLE_FEATURE_TAR_CREATE
/* Tar file constants */
@@ -50,14 +64,18 @@ struct TarHeader { /* byte offset */
char chksum[8]; /* 148-155 */
char typeflag; /* 156-156 */
char linkname[NAME_SIZE]; /* 157-256 */
char magic[6]; /* 257-262 */
char version[2]; /* 263-264 */
/* POSIX: "ustar" NUL "00" */
/* GNU tar: "ustar " NUL */
/* Normally it's defined as magic[6] followed by
* version[2], but we put them together to save code.
*/
char magic[8]; /* 257-264 */
char uname[32]; /* 265-296 */
char gname[32]; /* 297-328 */
char devmajor[8]; /* 329-336 */
char devminor[8]; /* 337-344 */
char prefix[155]; /* 345-499 */
char padding[12]; /* 500-512 (pad to exactly the TAR_BLOCK_SIZE) */
char padding[12]; /* 500-512 (pad to exactly TAR_BLOCK_SIZE) */
};
/*
@@ -505,21 +523,26 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
bb_perror_msg_and_die("cannot stat tar file");
if ((ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2) && gzip) {
// On Linux, vfork never unpauses parent early, although standard
// allows for that. Do we want to waste bytes checking for it?
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
if (gzip) {
#if ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
#elif ENABLE_FEATURE_TAR_GZIP
const char *zip_exec = "gzip";
#else /* only ENABLE_FEATURE_TAR_BZIP2 */
const char *zip_exec = "bzip2";
#endif
// On Linux, vfork never unpauses parent early, although standard
// allows for that. Do we want to waste bytes checking for it?
#define WAIT_FOR_CHILD 0
volatile int vfork_exec_errno = 0;
#if WAIT_FOR_CHILD
struct { int rd; int wr; } gzipStatusPipe;
struct fd_pair gzipStatusPipe;
#endif
struct { int rd; int wr; } gzipDataPipe;
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
xpipe(&gzipDataPipe.rd);
struct fd_pair gzipDataPipe;
xpiped_pair(gzipDataPipe);
#if WAIT_FOR_CHILD
xpipe(&gzipStatusPipe.rd);
xpiped_pair(gzipStatusPipe);
#endif
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
@@ -537,13 +560,16 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
if (gzipPid == 0) {
/* child */
xmove_fd(tbInfo.tarFd, 1);
xmove_fd(gzipDataPipe.rd, 0);
/* NB: close _first_, then move fds! */
close(gzipDataPipe.wr);
#if WAIT_FOR_CHILD
close(gzipStatusPipe.rd);
/* gzipStatusPipe.wr will close only on exec -
* parent waits for this close to happen */
fcntl(gzipStatusPipe.wr, F_SETFD, FD_CLOEXEC);
#endif
xmove_fd(gzipDataPipe.rd, 0);
xmove_fd(tbInfo.tarFd, 1);
/* exec gzip/bzip2 program/applet */
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
vfork_exec_errno = errno;
@@ -561,7 +587,7 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
/* Wait until child execs (or fails to) */
n = full_read(gzipStatusPipe.rd, &buf, 1);
if ((n < 0) && (/*errno == EAGAIN ||*/ errno == EINTR))
if (n < 0 /* && errno == EAGAIN */)
continue; /* try it again */
}
@@ -572,6 +598,7 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
bb_perror_msg_and_die("cannot exec %s", zip_exec);
}
}
#endif
tbInfo.excludeList = exclude;
@@ -606,7 +633,7 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
if (gzipPid) {
int status;
if (waitpid(gzipPid, &status, 0) == -1)
if (safe_waitpid(gzipPid, &status, 0) == -1)
bb_perror_msg("waitpid");
else if (!WIFEXITED(status) || WEXITSTATUS(status))
/* gzip was killed or has exited with nonzero! */
@@ -662,7 +689,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, "uncompress", "uncompress", "-cf", "-", NULL);
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress, "uncompress");
archive_handle->offset = 0;
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
continue;
@@ -684,7 +711,7 @@ static void handle_SIGCHLD(int status)
/* Actually, 'status' is a signo. We reuse it for other needs */
/* Wait for any child without blocking */
if (waitpid(-1, &status, WNOHANG) < 0)
if (wait_any_nohang(&status) < 0)
/* wait failed?! I'm confused... */
return;
@@ -922,11 +949,13 @@ int tar_main(int argc, char **argv)
/* create an archive */
if (opt & OPT_CREATE) {
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
int zipMode = 0;
if (ENABLE_FEATURE_TAR_GZIP && get_header_ptr == get_header_tar_gz)
if (ENABLE_FEATURE_TAR_GZIP && (opt & OPT_GZIP))
zipMode = 1;
if (ENABLE_FEATURE_TAR_BZIP2 && get_header_ptr == get_header_tar_bz2)
if (ENABLE_FEATURE_TAR_BZIP2 && (opt & OPT_BZIP2))
zipMode = 2;
#endif
/* NB: writeTarFile() closes tar_handle->src_fd */
return writeTarFile(tar_handle->src_fd, verboseFlag, opt & OPT_DEREFERENCE,
tar_handle->accept,
@@ -934,7 +963,7 @@ int tar_main(int argc, char **argv)
}
while (get_header_ptr(tar_handle) == EXIT_SUCCESS)
/* nothing */;
continue;
/* Check that every file that should have been extracted was */
while (tar_handle->accept) {
+12 -4
View File
@@ -41,8 +41,10 @@ enum {
#endif
};
#define ZIP_HEADER_LEN 26
typedef union {
uint8_t raw[26];
uint8_t raw[ZIP_HEADER_LEN];
struct {
uint16_t version; /* 0-1 */
uint16_t flags; /* 2-3 */
@@ -55,10 +57,16 @@ typedef union {
uint16_t filename_len; /* 22-23 */
uint16_t extra_len; /* 24-25 */
} formatted ATTRIBUTE_PACKED;
} zip_header_t;
} zip_header_t; /* ATTRIBUTE_PACKED - gcc 4.2.1 doesn't like it (spews warning) */
/* Check the offset of the last element, not the length. This leniency
* allows for poor packing, whereby the overall struct may be too long,
* even though the elements are all in the right place.
*/
struct BUG_zip_header_must_be_26_bytes {
char BUG_zip_header_must_be_26_bytes[sizeof(zip_header_t) == 26 ? 1 : -1];
char BUG_zip_header_must_be_26_bytes[
offsetof(zip_header_t, formatted.extra_len) + 2 ==
ZIP_HEADER_LEN ? 1 : -1];
};
#define FIX_ENDIANNESS(zip_header) do { \
@@ -256,7 +264,7 @@ int unzip_main(int argc, char **argv)
bb_error_msg_and_die("invalid zip magic %08X", magic);
/* Read the file header */
xread(src_fd, zip_header.raw, sizeof(zip_header));
xread(src_fd, zip_header.raw, ZIP_HEADER_LEN);
FIX_ENDIANNESS(zip_header);
if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) {
bb_error_msg_and_die("unsupported method %d", zip_header.formatted.method);
+1 -1
View File
@@ -72,7 +72,7 @@ config RESIZE
terminal.
config FEATURE_RESIZE_PRINT
bool "print environment variables"
bool "Print environment variables"
default n
depends on RESIZE
help
+1 -1
View File
@@ -13,7 +13,7 @@
#include "libbb.h"
int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int clear_main(int argc, char **argv)
int clear_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
return printf("\033[H\033[J") != 6;
}
+4 -8
View File
@@ -16,19 +16,15 @@
enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
int deallocvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int deallocvt_main(int argc, char **argv)
int deallocvt_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
/* num = 0 deallocate all unused consoles */
int num = 0;
switch (argc) {
case 2:
if (argv[1]) {
if (argv[2])
bb_show_usage();
num = xatou_range(argv[1], 1, 63);
/* Fallthrough */
case 1:
break;
default:
bb_show_usage();
}
/* double cast suppresses "cast to ptr from int of different size" */
+1 -1
View File
@@ -167,7 +167,7 @@ static void loadnewfont(int fd)
}
int loadfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int loadfont_main(int argc, char **argv)
int loadfont_main(int argc, char **argv ATTRIBUTE_UNUSED)
{
int fd;
+1 -1
View File
@@ -26,7 +26,7 @@ struct kbentry {
#define MAX_NR_KEYMAPS 256
int loadkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int loadkmap_main(int argc, char **argv)
int loadkmap_main(int argc, char **argv ATTRIBUTE_UNUSED)
{
struct kbentry ke;
int i, j, fd;
+4 -3
View File
@@ -27,9 +27,10 @@ int openvt_main(int argc, char **argv)
/* grab new one */
close(0);
xopen(vtname, O_RDWR);
dup2(0, STDOUT_FILENO);
dup2(0, STDERR_FILENO);
xdup2(0, STDOUT_FILENO);
xdup2(0, STDERR_FILENO);
BB_EXECVP(argv[2], &argv[2]);
argv += 2;
BB_EXECVP(argv[0], argv);
_exit(1);
}
+22 -5
View File
@@ -8,14 +8,25 @@
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/
/* no options, no getopt */
#include "libbb.h"
/* BTW, which "standard" package has this utility? It doesn't seem
* to be ncurses, coreutils, console-tools... then what? */
#if ENABLE_STTY
int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
#endif
int reset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int reset_main(int argc, char **argv)
int reset_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
if (isatty(1)) {
static const char *const args[] = {
"stty", "sane", NULL
};
/* no options, no getopt */
if (isatty(0) && isatty(1)) {
/* See 'man 4 console_codes' for details:
* "ESC c" -- Reset
* "ESC ( K" -- Select user mapping
@@ -24,7 +35,13 @@ int reset_main(int argc, char **argv)
* "ESC [ ? 25 h" -- Make cursor visible.
*/
printf("\033c\033(K\033[J\033[0m\033[?25h");
/* http://bugs.busybox.net/view.php?id=1414:
* people want it to reset echo etc: */
#if ENABLE_STTY
return stty_main(2, (char**)args);
#else
execvp("stty", (char**)args);
#endif
}
return EXIT_SUCCESS;
}
+8 -6
View File
@@ -21,10 +21,10 @@ onintr(int sig ATTRIBUTE_UNUSED)
}
int resize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int resize_main(int argc, char **argv)
int resize_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
struct termios new;
struct winsize w = { 0,0,0,0 };
struct winsize w = { 0, 0, 0, 0 };
int ret;
/* We use _stderr_ in order to make resize usable
@@ -37,10 +37,12 @@ int resize_main(int argc, char **argv)
new = old_termios;
new.c_cflag |= (CLOCAL | CREAD);
new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
signal(SIGINT, onintr);
signal(SIGQUIT, onintr);
signal(SIGTERM, onintr);
signal(SIGALRM, onintr);
bb_signals(0
+ (1 << SIGINT)
+ (1 << SIGQUIT)
+ (1 << SIGTERM)
+ (1 << SIGALRM)
, onintr);
tcsetattr(STDERR_FILENO, TCSANOW, &new);
/* save_cursor_pos 7
+2 -2
View File
@@ -14,7 +14,7 @@
/* From <linux/kd.h> */
struct kbkeycode {
unsigned int scancode, keycode;
unsigned scancode, keycode;
};
enum {
KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
@@ -33,7 +33,7 @@ int setkeycodes_main(int argc, char **argv)
fd = get_console_fd();
while (argc > 2) {
a.keycode = xatoul_range(argv[2], 0, 127);
a.keycode = xatou_range(argv[2], 0, 127);
a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255);
if (a.scancode > 127) {
a.scancode -= 0xe000;
+3 -3
View File
@@ -12,7 +12,7 @@
#include "libbb.h"
int setlogcons_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int setlogcons_main(int argc, char **argv)
int setlogcons_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
struct {
char fn;
@@ -22,8 +22,8 @@ int setlogcons_main(int argc, char **argv)
arg.fn = 11; /* redirect kernel messages */
arg.subarg = 0; /* to specified console (current as default) */
if (argc == 2)
arg.subarg = xatoul_range(argv[1], 0, 63);
if (argv[1])
arg.subarg = xatou_range(argv[1], 0, 63);
xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
+24 -3
View File
@@ -135,6 +135,13 @@ config DF
df reports the amount of disk space used and available
on filesystems.
config FEATURE_DF_INODE
bool "Enable -i (inode information)"
default n
depends on DF
help
This option enables support for df -i.
config DIRNAME
bool "dirname"
default n
@@ -481,6 +488,14 @@ config RMDIR
help
rmdir is used to remove empty directories.
config FEATURE_RMDIR_LONG_OPTIONS
bool "Enable long options"
default n
depends on RMDIR && GETOPT_LONG
help
Support long options for the rmdir applet, including
--ignore-fail-on-non-empty for compatibility with GNU rmdir.
config SEQ
bool "seq"
default n
@@ -513,7 +528,7 @@ config SORT
sort is used to sort lines of text in specified files.
config FEATURE_SORT_BIG
bool "full SuSv3 compliant sort (Support -ktcsbdfiozgM)"
bool "Full SuSv3 compliant sort (support -ktcsbdfiozgM)"
default y
depends on SORT
help
@@ -531,7 +546,7 @@ config SPLIT
split a file into pieces.
config FEATURE_SPLIT_FANCY
bool "fancy extensions"
bool "Fancy extensions"
default n
depends on SPLIT
help
@@ -572,6 +587,12 @@ config SYNC
help
sync is used to flush filesystem buffers.
config TAC
bool "tac"
default n
help
tac is used to concatenate and print files in reverse.
config TAIL
bool "tail"
default n
@@ -595,7 +616,7 @@ config TEE
to standard output and files.
config FEATURE_TEE_USE_BLOCK_IO
bool "Enable block i/o (larger/faster) instead of byte i/o."
bool "Enable block I/O (larger/faster) instead of byte I/O"
default n
depends on TEE
help
+2
View File
@@ -12,6 +12,7 @@ lib-$(CONFIG_CAL) += cal.o
lib-$(CONFIG_CAT) += cat.o
lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
lib-$(CONFIG_LESS) += cat.o # less too
lib-$(CONFIG_CRONTAB) += cat.o # crontab -l
lib-$(CONFIG_CATV) += catv.o
lib-$(CONFIG_CHGRP) += chgrp.o chown.o
lib-$(CONFIG_CHMOD) += chmod.o
@@ -66,6 +67,7 @@ lib-$(CONFIG_STAT) += stat.o
lib-$(CONFIG_STTY) += stty.o
lib-$(CONFIG_SUM) += sum.o
lib-$(CONFIG_SYNC) += sync.o
lib-$(CONFIG_TAC) += tac.o
lib-$(CONFIG_TAIL) += tail.o
lib-$(CONFIG_TEE) += tee.o
lib-$(CONFIG_TEST) += test.o
+4 -8
View File
@@ -17,20 +17,16 @@
int bb_cat(char **argv)
{
static const char *const argv_dash[] = { "-", NULL };
int fd;
int retval = EXIT_SUCCESS;
if (!*argv)
argv = (char**) &argv_dash;
argv = (char**) &bb_argv_dash;
do {
fd = STDIN_FILENO;
if (!LONE_DASH(*argv))
fd = open_or_warn(*argv, O_RDONLY);
fd = open_or_warn_stdin(*argv);
if (fd >= 0) {
/* This is not an xfunc - never exits */
/* This is not a xfunc - never exits */
off_t r = bb_copyfd_eof(fd, STDOUT_FILENO);
if (fd != STDIN_FILENO)
close(fd);
@@ -44,7 +40,7 @@ int bb_cat(char **argv)
}
int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cat_main(int argc, char **argv)
int cat_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
getopt32(argv, "u");
argv += optind;
+4 -8
View File
@@ -13,7 +13,7 @@
#include "libbb.h"
int catv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int catv_main(int argc, char **argv)
int catv_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int retval = EXIT_SUCCESS;
int fd;
@@ -27,18 +27,14 @@ int catv_main(int argc, char **argv)
argv += optind;
/* Read from stdin if there's nothing else to do. */
fd = 0;
if (!argv[0]) {
argv--;
goto jump_in;
}
if (!argv[0])
*--argv = (char*)"-";
do {
fd = open_or_warn(*argv, O_RDONLY);
fd = open_or_warn_stdin(*argv);
if (fd < 0) {
retval = EXIT_FAILURE;
continue;
}
jump_in:
for (;;) {
int i, res;
+1 -1
View File
@@ -68,7 +68,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* param, i
}
int chmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int chmod_main(int argc, char **argv)
int chmod_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int retval = EXIT_SUCCESS;
char *arg, **argp;
+2 -2
View File
@@ -42,7 +42,7 @@ typedef int (*chown_fptr)(const char *, uid_t, gid_t);
static struct bb_uidgid_t ugid = { -1, -1 };
static int fileAction(const char *fileName, struct stat *statbuf,
void *cf, int depth)
void *cf, int depth ATTRIBUTE_UNUSED)
{
uid_t u = (ugid.uid == (uid_t)-1) ? statbuf->st_uid : ugid.uid;
gid_t g = (ugid.gid == (gid_t)-1) ? statbuf->st_gid : ugid.gid;
@@ -62,7 +62,7 @@ static int fileAction(const char *fileName, struct stat *statbuf,
}
int chown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int chown_main(int argc, char **argv)
int chown_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int retval = EXIT_SUCCESS;
int flags;
+1 -3
View File
@@ -19,9 +19,7 @@ int chroot_main(int argc, char **argv)
}
++argv;
if (chroot(*argv)) {
bb_perror_msg_and_die("cannot change root directory to %s", *argv);
}
xchroot(*argv);
xchdir("/");
++argv;
+20 -18
View File
@@ -9,46 +9,48 @@
#include "libbb.h"
int cksum_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cksum_main(int argc, char **argv)
int cksum_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
uint32_t *crc32_table = crc32_filltable(NULL, 1);
FILE *fp;
uint32_t crc;
long length, filesize;
int bytes_read;
char *cp;
uint8_t *cp;
int inp_stdin = (argc == optind) ? 1 : 0;
#if ENABLE_DESKTOP
getopt32(argv, ""); /* coreutils 6.9 compat */
argv += optind;
#else
argv++;
#endif
do {
fp = fopen_or_warn_stdin((inp_stdin) ? bb_msg_standard_input : *++argv);
int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input);
if (fd < 0)
continue;
crc = 0;
length = 0;
#define read_buf bb_common_bufsiz1
while ((bytes_read = fread(read_buf, 1, BUFSIZ, fp)) > 0) {
while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 0) {
cp = read_buf;
length += bytes_read;
while (bytes_read--)
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ (*cp++)) & 0xffL];
do {
crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *cp++];
} while (--bytes_read);
}
close(fd);
filesize = length;
for (; length; length >>= 8)
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xffL];
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xff];
crc ^= 0xffffffffL;
if (inp_stdin) {
printf("%" PRIu32 " %li\n", crc, filesize);
break;
}
printf("%" PRIu32 " %li %s\n", crc, filesize, *argv);
fclose(fp);
} while (*(argv + 1));
printf((*argv ? "%" PRIu32 " %li %s\n" : "%" PRIu32 " %li\n"),
crc, filesize, *argv);
} while (*argv && *++argv);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
+1 -1
View File
@@ -36,7 +36,7 @@ static void writeline(char *line, int class, int flags)
}
int comm_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int comm_main(int argc, char **argv)
int comm_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
#define LINE_LEN 100
#define BB_EOF_0 0x1
+32 -41
View File
@@ -16,13 +16,11 @@
/* option vars */
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)
#define CUT_OPT_DELIM_FLGS (1<<3)
#define CUT_OPT_SUPPRESS_FLGS (1<<4)
static char delim = '\t'; /* delimiter, default is tab */
#define CUT_OPT_BYTE_FLGS (1 << 0)
#define CUT_OPT_CHAR_FLGS (1 << 1)
#define CUT_OPT_FIELDS_FLGS (1 << 2)
#define CUT_OPT_DELIM_FLGS (1 << 3)
#define CUT_OPT_SUPPRESS_FLGS (1 << 4)
struct cut_list {
int startpos;
@@ -47,7 +45,7 @@ static int cmpfunc(const void *a, const void *b)
}
static void cut_file(FILE * file)
static void cut_file(FILE *file, char delim)
{
char *line = NULL;
unsigned int linenum = 0; /* keep these zero-based to be consistent */
@@ -163,11 +161,10 @@ static void cut_file(FILE * file)
}
}
static const char _op_on_field[] ALIGN1 = " only when operating on fields";
int cut_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int cut_main(int argc, char **argv)
int cut_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
char delim = '\t'; /* delimiter, default is tab */
char *sopt, *ltok;
opt_complementary = "b--bcf:c--bcf:f--bcf";
@@ -178,7 +175,7 @@ int cut_main(int argc, char **argv)
bb_error_msg_and_die("expected a list of bytes, characters, or fields");
if (option_mask32 & CUT_OPT_DELIM_FLGS) {
if (strlen(ltok) > 1) {
if (ltok[0] && ltok[1]) { /* more than 1 char? */
bb_error_msg_and_die("the delimiter must be a single character");
}
delim = ltok[0];
@@ -186,6 +183,8 @@ int cut_main(int argc, char **argv)
/* non-field (char or byte) cutting has some special handling */
if (!(option_mask32 & CUT_OPT_FIELDS_FLGS)) {
static const char _op_on_field[] ALIGN1 = " only when operating on fields";
if (option_mask32 & CUT_OPT_SUPPRESS_FLGS) {
bb_error_msg_and_die
("suppressing non-delimited lines makes sense%s",
@@ -206,19 +205,16 @@ int cut_main(int argc, char **argv)
char *ntok;
int s = 0, e = 0;
/* take apart the lists, one by one (they are separated with commas */
/* take apart the lists, one by one (they are separated with commas) */
while ((ltok = strsep(&sopt, ",")) != NULL) {
/* it's actually legal to pass an empty list */
if (strlen(ltok) == 0)
if (!ltok[0])
continue;
/* get the start pos */
ntok = strsep(&ltok, "-");
if (ntok == NULL) {
bb_error_msg
("internal error: ntok is null for start pos!?\n");
} else if (strlen(ntok) == 0) {
if (!ntok[0]) {
s = BOL;
} else {
s = xatoi_u(ntok);
@@ -229,13 +225,12 @@ int cut_main(int argc, char **argv)
}
/* get the end pos */
ntok = strsep(&ltok, "-");
if (ntok == NULL) {
if (ltok == NULL) {
e = NON_RANGE;
} else if (strlen(ntok) == 0) {
} else if (!ltok[0]) {
e = EOL;
} else {
e = xatoi_u(ntok);
e = xatoi_u(ltok);
/* if the user specified and end position of 0, that means "til the
* end of the line */
if (e == 0)
@@ -245,11 +240,6 @@ int cut_main(int argc, char **argv)
e = NON_RANGE;
}
/* if there's something left to tokenize, the user passed
* an invalid list */
if (ltok)
bb_error_msg_and_die("invalid byte or field list");
/* add the new list */
cut_lists = xrealloc(cut_lists, sizeof(struct cut_list) * (++nlists));
cut_lists[nlists-1].startpos = s;
@@ -266,23 +256,24 @@ int cut_main(int argc, char **argv)
qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc);
}
/* argv[0..argc-1] should be names of file to process. If no
* files were specified or '-' was specified, take input from stdin.
* Otherwise, we process all the files specified. */
if (argv[0] == NULL || LONE_DASH(argv[0])) {
cut_file(stdin);
} else {
FILE *file;
{
int retval = EXIT_SUCCESS;
if (!*argv)
*--argv = (char *)"-";
do {
file = fopen_or_warn(argv[0], "r");
if (file) {
cut_file(file);
fclose(file);
FILE *file = fopen_or_warn_stdin(*argv);
if (!file) {
retval = EXIT_FAILURE;
continue;
}
cut_file(file, delim);
fclose_if_not_stdin(file);
} while (*++argv);
if (ENABLE_FEATURE_CLEAN_UP)
free(cut_lists);
fflush_stdout_and_exit(retval);
}
if (ENABLE_FEATURE_CLEAN_UP)
free(cut_lists);
return EXIT_SUCCESS;
}
+55 -59
View File
@@ -14,6 +14,11 @@
/* This is a NOEXEC applet. Be very careful! */
enum {
ifd = STDIN_FILENO,
ofd = STDOUT_FILENO,
};
static const struct suffix_mult dd_suffixes[] = {
{ "c", 1 },
{ "w", 2 },
@@ -45,19 +50,19 @@ static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal)
G.out_full, G.out_part);
}
static ssize_t full_write_or_warn(int fd, const void *buf, size_t len,
static ssize_t full_write_or_warn(const void *buf, size_t len,
const char *const filename)
{
ssize_t n = full_write(fd, buf, len);
ssize_t n = full_write(ofd, buf, len);
if (n < 0)
bb_perror_msg("writing '%s'", filename);
return n;
}
static bool write_and_stats(int fd, const void *buf, size_t len, size_t obs,
static bool write_and_stats(const void *buf, size_t len, size_t obs,
const char *filename)
{
ssize_t n = full_write_or_warn(fd, buf, len, filename);
ssize_t n = full_write_or_warn(buf, len, filename);
if (n < 0)
return 1;
if (n == obs)
@@ -105,40 +110,32 @@ int dd_main(int argc, char **argv)
OP_conv_noerror,
#endif
};
int exitcode = EXIT_FAILURE;
size_t ibs = 512, obs = 512;
ssize_t n, w;
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(&Z, 0, sizeof(Z));
INIT_G();
//fflush(NULL); - is this needed because of NOEXEC?
#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);
signal_SA_RESTART_empty_mask(SIGUSR1, dd_output_status);
#endif
for (n = 1; n < argc; n++) {
@@ -160,40 +157,40 @@ int dd_main(int argc, char **argv)
if (what == 0)
bb_show_usage();
arg += key_len;
/* Must fit into positive ssize_t */
#if ENABLE_FEATURE_DD_IBS_OBS
if (what == OP_ibs) {
ibs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
continue;
}
if (what == OP_obs) {
obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
continue;
}
if (what == OP_conv) {
while (1) {
/* find ',', replace them with nil so we can use arg for
* index_in_strings() without copying.
* We rely on arg being non-null, else strchr would fault.
*/
key = strchr(arg, ',');
if (key)
*key = '\0';
what = index_in_strings(keywords, arg) + 1;
if (what < OP_conv_notrunc)
bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv");
if (what == OP_conv_notrunc)
flags |= FLAG_NOTRUNC;
if (what == OP_conv_sync)
flags |= FLAG_SYNC;
if (what == OP_conv_noerror)
flags |= FLAG_NOERROR;
if (!key) /* no ',' left, so this was the last specifier */
break;
arg = key + 1; /* skip this keyword and ',' */
}
continue;
if (what == OP_ibs) {
/* Must fit into positive ssize_t */
ibs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
continue;
}
if (what == OP_obs) {
obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
continue;
}
if (what == OP_conv) {
while (1) {
/* find ',', replace them with NUL so we can use arg for
* index_in_strings() without copying.
* We rely on arg being non-null, else strchr would fault.
*/
key = strchr(arg, ',');
if (key)
*key = '\0';
what = index_in_strings(keywords, arg) + 1;
if (what < OP_conv_notrunc)
bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv");
if (what == OP_conv_notrunc)
flags |= FLAG_NOTRUNC;
if (what == OP_conv_sync)
flags |= FLAG_SYNC;
if (what == OP_conv_noerror)
flags |= FLAG_NOERROR;
if (!key) /* no ',' left, so this was the last specifier */
break;
arg = key + 1; /* skip this keyword and ',' */
}
continue;
}
#endif
if (what == OP_bs) {
ibs = obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
@@ -227,9 +224,8 @@ int dd_main(int argc, char **argv)
obuf = xmalloc(obs);
}
if (infile != NULL)
ifd = xopen(infile, O_RDONLY);
xmove_fd(xopen(infile, O_RDONLY), ifd);
else {
/* ifd = STDIN_FILENO; - it's zero and it's already there */
infile = bb_msg_standard_input;
}
if (outfile != NULL) {
@@ -238,7 +234,7 @@ int dd_main(int argc, char **argv)
if (!seek && !(flags & FLAG_NOTRUNC))
oflag |= O_TRUNC;
ofd = xopen(outfile, oflag);
xmove_fd(xopen(outfile, oflag), ofd);
if (seek && !(flags & FLAG_NOTRUNC)) {
if (ftruncate(ofd, seek * obs) < 0) {
@@ -250,7 +246,6 @@ int dd_main(int argc, char **argv)
}
}
} else {
ofd = STDOUT_FILENO;
outfile = bb_msg_standard_output;
}
if (skip) {
@@ -276,11 +271,10 @@ int dd_main(int argc, char **argv)
if (n == 0)
break;
if (n < 0) {
if (flags & FLAG_NOERROR) {
n = ibs;
bb_simple_perror_msg(infile);
} else
if (!(flags & FLAG_NOERROR))
goto die_infile;
n = ibs;
bb_simple_perror_msg(infile);
}
if ((size_t)n == ibs)
G.in_full++;
@@ -303,17 +297,17 @@ int dd_main(int argc, char **argv)
tmp += d;
oc += d;
if (oc == obs) {
if (write_and_stats(ofd, obuf, obs, obs, outfile))
if (write_and_stats(obuf, obs, obs, outfile))
goto out_status;
oc = 0;
}
}
} else if (write_and_stats(ofd, ibuf, n, obs, outfile))
} else if (write_and_stats(ibuf, n, obs, outfile))
goto out_status;
}
if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
w = full_write_or_warn(ofd, obuf, oc, outfile);
w = full_write_or_warn(obuf, oc, outfile);
if (w < 0) goto out_status;
if (w > 0)
G.out_part++;
@@ -327,8 +321,10 @@ int dd_main(int argc, char **argv)
die_outfile:
bb_simple_perror_msg_and_die(outfile);
}
exitcode = EXIT_SUCCESS;
out_status:
dd_output_status(0);
return EXIT_SUCCESS;
return exitcode;
}
+32 -8
View File
@@ -45,23 +45,32 @@ int df_main(int argc, char **argv)
/* default display is kilobytes */
const char *disp_units_hdr = "1k-blocks";
enum {
OPT_ALL = (1 << 0),
OPT_INODE = (ENABLE_FEATURE_HUMAN_READABLE ? (1 << 4) : (1 << 2))
* ENABLE_FEATURE_DF_INODE
};
#if ENABLE_FEATURE_HUMAN_READABLE
opt_complementary = "h-km:k-hm:m-hk";
opt = getopt32(argv, "hmk");
if (opt & 1) {
opt = getopt32(argv, "ahmk" USE_FEATURE_DF_INODE("i"));
if (opt & (1 << 1)) { // -h
df_disp_hr = 0;
disp_units_hdr = " Size";
}
if (opt & 2) {
if (opt & (1 << 2)) { // -m
df_disp_hr = 1024*1024;
disp_units_hdr = "1M-blocks";
}
if (opt & OPT_INODE) {
disp_units_hdr = " Inodes";
}
#else
opt = getopt32(argv, "k");
opt = getopt32(argv, "ak" USE_FEATURE_DF_INODE("i"));
#endif
printf("Filesystem%11s%-15sUsed Available Use%% Mounted on\n",
"", disp_units_hdr);
printf("Filesystem %-15sUsed Available Use%% Mounted on\n",
disp_units_hdr);
mount_table = NULL;
argv += optind;
@@ -104,7 +113,16 @@ int df_main(int argc, char **argv)
goto SET_ERROR;
}
if ((s.f_blocks > 0) || !mount_table){
if ((s.f_blocks > 0) || !mount_table || (opt & OPT_ALL)) {
if (opt & OPT_INODE) {
s.f_blocks = s.f_files;
s.f_bavail = s.f_bfree = s.f_ffree;
s.f_bsize = 1;
#if ENABLE_FEATURE_HUMAN_READABLE
if (df_disp_hr)
df_disp_hr = 1;
#endif
}
blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = 0;
if (blocks_used + s.f_bavail) {
@@ -113,9 +131,14 @@ int df_main(int argc, char **argv)
) / (blocks_used + s.f_bavail);
}
#ifdef WHY_IT_SHOULD_BE_HIDDEN
if (strcmp(device, "rootfs") == 0) {
continue;
} else if (strcmp(device, "/dev/root") == 0) {
}
#endif
#ifdef WHY_WE_DO_IT_FOR_DEV_ROOT_ONLY
/* ... and also this is the only user of find_block_device */
if (strcmp(device, "/dev/root") == 0) {
/* Adjusts device to be the real root device,
* or leaves device alone if it can't find it */
device = find_block_device("/");
@@ -123,6 +146,7 @@ int df_main(int argc, char **argv)
goto SET_ERROR;
}
}
#endif
if (printf("\n%-20s" + 1, device) > 20)
printf("\n%-20s", "");
+19 -35
View File
@@ -20,62 +20,49 @@ enum {
};
/* if fn is NULL then input is stdin and output is stdout */
static int convert(char *fn, int conv_type)
static void convert(char *fn, int conv_type)
{
FILE *in, *out;
int i;
#define name_buf bb_common_bufsiz1
char *name_buf = name_buf; /* for compiler */
in = stdin;
out = stdout;
if (fn != NULL) {
in = xfopen(fn, "rw");
in = xfopen(fn, "r");
/*
The file is then created with mode read/write and
permissions 0666 for glibc 2.0.6 and earlier or
0600 for glibc 2.0.7 and later.
*/
snprintf(name_buf, sizeof(name_buf), "%sXXXXXX", fn);
i = mkstemp(&name_buf[0]);
if (i == -1 || chmod(name_buf, 0600) == -1) {
name_buf = xasprintf("%sXXXXXX", fn);
i = mkstemp(name_buf);
if (i == -1
|| fchmod(i, 0600) == -1
|| !(out = fdopen(i, "w+"))
) {
bb_perror_nomsg_and_die();
}
out = fdopen(i, "w+");
if (!out) {
close(i);
remove(name_buf);
return -2;
}
}
while ((i = fgetc(in)) != EOF) {
if (i == '\r')
continue;
if (i == '\n') {
if (i == '\n')
if (conv_type == CT_UNIX2DOS)
fputc('\r', out);
fputc('\n', out);
continue;
}
fputc(i, out);
}
if (fn != NULL) {
if (fclose(in) < 0 || fclose(out) < 0) {
bb_perror_nomsg();
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(name_buf, fn) < 0) {
bb_perror_msg("cannot rename '%s' as '%s'", name_buf, fn);
return -1;
unlink(name_buf);
bb_perror_nomsg_and_die();
}
// TODO: destroys symlinks. See how passwd handles this
xrename(name_buf, fn);
free(name_buf);
}
return 0;
}
int dos2unix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
@@ -84,10 +71,9 @@ int dos2unix_main(int argc, char **argv)
int o, conv_type;
/* See if we are supposed to be doing dos2unix or unix2dos */
conv_type = CT_UNIX2DOS;
if (applet_name[0] == 'd') {
conv_type = CT_DOS2UNIX; /* 2 */
} else {
conv_type = CT_UNIX2DOS; /* 1 */
conv_type = CT_DOS2UNIX;
}
/* -u convert to unix, -d convert to dos */
@@ -101,11 +87,9 @@ int dos2unix_main(int argc, char **argv)
do {
/* might be convert(NULL) if there is no filename given */
o = convert(argv[optind], conv_type);
if (o < 0)
break;
convert(argv[optind], conv_type);
optind++;
} while (optind < argc);
return o;
return 0;
}
+5 -10
View File
@@ -141,12 +141,11 @@ static unsigned long du(const char *filename)
}
int du_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int du_main(int argc, char **argv)
int du_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
unsigned long total;
int slink_depth_save;
bool print_final_total;
char *smax_print_depth;
unsigned opt;
#if ENABLE_FEATURE_HUMAN_READABLE
@@ -168,8 +167,8 @@ int du_main(int argc, char **argv)
* ignore -a. This is consistent with -s being equivalent to -d 0.
*/
#if ENABLE_FEATURE_HUMAN_READABLE
opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s:d+";
opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &G.max_print_depth);
argv += optind;
if (opt & (1 << 9)) {
/* -h opt */
@@ -184,8 +183,8 @@ int du_main(int argc, char **argv)
G.disp_hr = 1024;
}
#else
opt_complementary = "H-L:L-H:s-d:d-s";
opt = getopt32(argv, "aHkLsx" "d:" "lc", &smax_print_depth);
opt_complementary = "H-L:L-H:s-d:d-s:d+";
opt = getopt32(argv, "aHkLsx" "d:" "lc", &G.max_print_depth);
argv += optind;
#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
if (opt & (1 << 2)) {
@@ -211,10 +210,6 @@ int du_main(int argc, char **argv)
G.max_print_depth = 0;
}
G.one_file_system = opt & (1 << 5); /* -x opt */
if (opt & (1 << 6)) {
/* -d opt */
G.max_print_depth = xatoi_u(smax_print_depth);
}
if (opt & (1 << 7)) {
/* -l opt */
G.count_hardlinks = MAXINT(nlink_t);
+148 -13
View File
@@ -25,7 +25,11 @@
#include "libbb.h"
int bb_echo(char **argv)
/* This is a NOFORK applet. Be very careful! */
/* NB: can be used by shell even if not enabled as applet */
int echo_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
const char *arg;
#if !ENABLE_FEATURE_FANCY_ECHO
@@ -33,6 +37,18 @@ int bb_echo(char **argv)
eflag = '\\',
nflag = 1, /* 1 -- print '\n' */
};
/* We must check that stdout is not closed.
* The reason for this is highly non-obvious.
* echo_main is used from shell. Shell must correctly handle "echo foo"
* if stdout is closed. With stdio, output gets shoveled into
* stdout buffer, and even fflush cannot clear it out. It seems that
* even if libc receives EBADF on write attempts, it feels determined
* to output data no matter what. So it will try later,
* and possibly will clobber future output. Not good. */
if (dup2(1, 1) != 1)
return -1;
arg = *++argv;
if (!arg)
goto newline_ret;
@@ -41,6 +57,10 @@ int bb_echo(char **argv)
char nflag = 1;
char eflag = 0;
/* We must check that stdout is not closed. */
if (dup2(1, 1) != 1)
return -1;
while (1) {
arg = *++argv;
if (!arg)
@@ -88,15 +108,19 @@ int bb_echo(char **argv)
}
#if !ENABLE_FEATURE_FANCY_ECHO
/* SUSv3 specifies that octal escapes must begin with '0'. */
if ( (((unsigned char)*arg) - '1') >= 7)
if ( ((int)(unsigned char)(*arg) - '0') >= 8) /* '8' or bigger */
#endif
{
/* Since SUSv3 mandates a first digit of 0, 4-digit octals
* of the form \0### are accepted. */
if (*arg == '0' && ((unsigned char)(arg[1]) - '0') < 8) {
arg++;
if (*arg == '0') {
/* NB: don't turn "...\0" into "...\" */
if (arg[1] && ((unsigned char)(arg[1]) - '0') < 8) {
arg++;
}
}
/* bb_process_escape_sequence can handle nul correctly */
/* bb_process_escape_sequence handles NUL correctly
* ("...\" case). */
c = bb_process_escape_sequence(&arg);
}
}
@@ -117,14 +141,6 @@ int bb_echo(char **argv)
return fflush(stdout);
}
/* This is a NOFORK applet. Be very careful! */
int echo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int echo_main(int argc, char **argv)
{
return bb_echo(argv);
}
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -163,3 +179,122 @@ int echo_main(int argc, char **argv)
*
* @(#)echo.c 8.1 (Berkeley) 5/31/93
*/
#ifdef VERSION_WITH_WRITEV
/* We can't use stdio.
* The reason for this is highly non-obvious.
* echo_main is used from shell. Shell must correctly handle "echo foo"
* if stdout is closed. With stdio, output gets shoveled into
* stdout buffer, and even fflush cannot clear it out. It seems that
* even if libc receives EBADF on write attempts, it feels determined
* to output data no matter what. So it will try later,
* and possibly will clobber future output. Not good.
*
* Using writev instead, with 'direct' conversion of argv vector.
*/
int echo_main(int argc, char **argv)
{
struct iovec io[argc];
struct iovec *cur_io = io;
char *arg;
char *p;
#if !ENABLE_FEATURE_FANCY_ECHO
enum {
eflag = '\\',
nflag = 1, /* 1 -- print '\n' */
};
arg = *++argv;
if (!arg)
goto newline_ret;
#else
char nflag = 1;
char eflag = 0;
while (1) {
arg = *++argv;
if (!arg)
goto newline_ret;
if (*arg != '-')
break;
/* If it appears that we are handling options, then make sure
* that all of the options specified are actually valid.
* Otherwise, the string should just be echoed.
*/
p = arg + 1;
if (!*p) /* A single '-', so echo it. */
goto just_echo;
do {
if (!strrchr("neE", *p))
goto just_echo;
} while (*++p);
/* All of the options in this arg are valid, so handle them. */
p = arg + 1;
do {
if (*p == 'n')
nflag = 0;
if (*p == 'e')
eflag = '\\';
} while (*++p);
}
just_echo:
#endif
while (1) {
/* arg is already == *argv and isn't NULL */
int c;
cur_io->iov_base = p = arg;
if (!eflag) {
/* optimization for very common case */
p += strlen(arg);
} else while ((c = *arg++)) {
if (c == eflag) { /* Check for escape seq. */
if (*arg == 'c') {
/* '\c' means cancel newline and
* ignore all subsequent chars. */
cur_io->iov_len = p - (char*)cur_io->iov_base;
cur_io++;
goto ret;
}
#if !ENABLE_FEATURE_FANCY_ECHO
/* SUSv3 specifies that octal escapes must begin with '0'. */
if ( (((unsigned char)*arg) - '1') >= 7)
#endif
{
/* Since SUSv3 mandates a first digit of 0, 4-digit octals
* of the form \0### are accepted. */
if (*arg == '0' && ((unsigned char)(arg[1]) - '0') < 8) {
arg++;
}
/* bb_process_escape_sequence can handle nul correctly */
c = bb_process_escape_sequence( (void*) &arg);
}
}
*p++ = c;
}
arg = *++argv;
if (arg)
*p++ = ' ';
cur_io->iov_len = p - (char*)cur_io->iov_base;
cur_io++;
if (!arg)
break;
}
newline_ret:
if (nflag) {
cur_io->iov_base = (char*)"\n";
cur_io->iov_len = 1;
cur_io++;
}
ret:
/* TODO: implement and use full_writev? */
return writev(1, io, (cur_io - io)) >= 0;
}
#endif
+1 -3
View File
@@ -30,8 +30,6 @@
*/
#include <getopt.h> /* struct option */
extern char **environ;
#include "libbb.h"
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
@@ -42,7 +40,7 @@ static const char env_longopts[] ALIGN1 =
#endif
int env_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int env_main(int argc, char **argv)
int env_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
/* cleanenv was static - why? */
char *cleanenv[1];
+8 -17
View File
@@ -126,7 +126,7 @@ static void unexpand(FILE *file, unsigned int tab_size, unsigned opt)
#endif
int expand_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int expand_main(int argc, char **argv)
int expand_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
/* Default 8 spaces for 1 tab */
const char *opt_t = "8";
@@ -154,7 +154,7 @@ int expand_main(int argc, char **argv)
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) {
} else {
USE_FEATURE_UNEXPAND_LONG_OPTIONS(applet_long_options = unexpand_longopts);
/* -t NUM sets also -a */
opt_complementary = "ta";
@@ -166,32 +166,23 @@ int expand_main(int argc, char **argv)
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;
file = fopen_or_warn_stdin(*argv);
if (!file) {
exit_status = EXIT_FAILURE;
continue;
}
if (ENABLE_EXPAND && (!ENABLE_UNEXPAND || applet_name[0] == 'e'))
USE_EXPAND(expand(file, tab_size, opt));
else if (ENABLE_UNEXPAND)
else
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)) {
if (fclose_if_not_stdin(file)) {
bb_simple_perror_msg(*argv);
exit_status = EXIT_FAILURE;
}
+13 -16
View File
@@ -12,18 +12,17 @@
#include "libbb.h"
static unsigned long flags;
#define FLAG_COUNT_BYTES 1
#define FLAG_BREAK_SPACES 2
#define FLAG_WIDTH 4
/* Must match getopt32 call */
#define FLAG_COUNT_BYTES 1
#define FLAG_BREAK_SPACES 2
#define FLAG_WIDTH 4
/* Assuming the current column is COLUMN, return the column that
printing C will move the cursor to.
The first column is 0. */
static int adjust_column(int column, char c)
{
if (!(flags & FLAG_COUNT_BYTES)) {
if (!(option_mask32 & FLAG_COUNT_BYTES)) {
if (c == '\b') {
if (column > 0)
column--;
@@ -54,29 +53,27 @@ int fold_main(int argc, char **argv)
char const *a = argv[i];
if (*a++ == '-') {
if (*a == '-' && !a[1])
if (*a == '-' && !a[1]) /* "--" */
break;
if (isdigit(*a)) {
if (isdigit(*a))
argv[i] = xasprintf("-w%s", a);
}
}
}
}
flags = getopt32(argv, "bsw:", &w_opt);
if (flags & FLAG_WIDTH)
getopt32(argv, "bsw:", &w_opt);
if (option_mask32 & FLAG_WIDTH)
width = xatoul_range(w_opt, 1, 10000);
argv += optind;
if (!*argv) {
if (!*argv)
*--argv = (char*)"-";
}
do {
FILE *istream = fopen_or_warn_stdin(*argv);
int c;
int column = 0; /* Screen column where next char will go. */
int offset_out = 0; /* Index in `line_out' for next char. */
int offset_out = 0; /* Index in 'line_out' for next char. */
if (istream == NULL) {
errs |= EXIT_FAILURE;
@@ -102,7 +99,7 @@ int fold_main(int argc, char **argv)
/* This character would make the line too long.
Print the line plus a newline, and make this character
start the next line. */
if (flags & FLAG_BREAK_SPACES) {
if (option_mask32 & FLAG_BREAK_SPACES) {
/* Look for the last blank. */
int logical_end;
@@ -144,7 +141,7 @@ int fold_main(int argc, char **argv)
fwrite(line_out, sizeof(char), (size_t) offset_out, stdout);
}
if (ferror(istream) || fclose_if_not_stdin(istream)) {
if (fclose_if_not_stdin(istream)) {
bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
errs |= EXIT_FAILURE;
}
+5 -5
View File
@@ -91,19 +91,19 @@ int head_main(int argc, char **argv)
}
}
argc -= optind;
argv += optind;
if (!*argv) {
if (!*argv)
*--argv = (char*)"-";
}
fmt = header_fmt_str + 1;
#if ENABLE_FEATURE_FANCY_HEAD
if (argc - optind <= header_threshhold) {
if (argc <= header_threshhold) {
header_threshhold = 0;
}
#else
if (argc <= optind + 1) {
fmt += 11;
if (argc <= 1) {
fmt += 11; /* "" */
}
/* Now define some things here to avoid #ifdefs in the code below.
* These should optimize out of the if conditions below. */
+1 -1
View File
@@ -37,7 +37,7 @@ static int printf_full(unsigned int id, const char *arg, const char prefix)
}
int id_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int id_main(int argc, char **argv)
int id_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
struct passwd *p;
uid_t uid;
+1 -1
View File
@@ -11,6 +11,6 @@ typedef int (*stat_func)(const char *fn, struct stat *ps);
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);
mode_t getopt_mk_fifo_nod(int argc, char **argv);
mode_t getopt_mk_fifo_nod(char **argv);
#endif
+6
View File
@@ -27,6 +27,12 @@ int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf)
{
if (sf(fn, fn_stat) < 0) {
if (errno != ENOENT) {
#if ENABLE_FEATURE_VERBOSE_CP_MESSAGE
if (errno == ENOTDIR) {
bb_error_msg("cannot stat '%s': Path has non-directory component", fn);
return -1;
}
#endif
bb_perror_msg("cannot stat '%s'", fn);
return -1;
}
+1 -1
View File
@@ -23,7 +23,7 @@
#include "libbb.h"
#include "coreutils.h"
mode_t getopt_mk_fifo_nod(int argc, char **argv)
mode_t getopt_mk_fifo_nod(char **argv)
{
mode_t mode = 0666;
char *smode = NULL;
+2 -7
View File
@@ -799,8 +799,6 @@ int ls_main(int argc, char **argv)
int ac;
int i;
char **av;
USE_FEATURE_AUTOWIDTH(char *tabstops_str = NULL;)
USE_FEATURE_AUTOWIDTH(char *terminal_width_str = NULL;)
USE_FEATURE_LS_COLOR(char *color_opt;)
#if ENABLE_FEATURE_LS_TIMESTAMPS
@@ -820,12 +818,9 @@ 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(argv, ls_options, &tabstops_str, &terminal_width_str
opt_complementary = "T+:w+"; /* -T N, -w N */
opt = getopt32(argv, ls_options, &tabstops, &terminal_width
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(argv, ls_options USE_FEATURE_LS_COLOR(, &color_opt));
#endif
+14 -23
View File
@@ -36,12 +36,9 @@ static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
void (*update)(const void*, size_t, void*);
void (*final)(void*, void*);
src_fd = STDIN_FILENO;
if (NOT_LONE_DASH(filename)) {
src_fd = open_or_warn(filename, O_RDONLY);
if (src_fd < 0) {
return NULL;
}
src_fd = open_or_warn_stdin(filename);
if (src_fd < 0) {
return NULL;
}
/* figure specific hash algorithims */
@@ -78,7 +75,7 @@ static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
}
int md5_sha1_sum_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int md5_sha1_sum_main(int argc, char **argv)
int md5_sha1_sum_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int return_value = EXIT_SUCCESS;
uint8_t *hash_value;
@@ -90,6 +87,10 @@ int md5_sha1_sum_main(int argc, char **argv)
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
flags = getopt32(argv, "scw");
else optind = 1;
argv += optind;
//argc -= optind;
if (!*argv)
*--argv = (char*)"-";
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && !(flags & FLAG_CHECK)) {
if (flags & FLAG_SILENT) {
@@ -101,26 +102,18 @@ int md5_sha1_sum_main(int argc, char **argv)
}
}
if (argc == optind) {
argv[argc++] = (char*)"-";
}
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK && (flags & FLAG_CHECK)) {
FILE *pre_computed_stream;
int count_total = 0;
int count_failed = 0;
char *file_ptr = argv[optind];
char *line;
if (optind + 1 != argc) {
if (argv[1]) {
bb_error_msg_and_die
("only one argument may be specified when using -c");
}
pre_computed_stream = stdin;
if (NOT_LONE_DASH(file_ptr)) {
pre_computed_stream = xfopen(file_ptr, "r");
}
pre_computed_stream = xfopen_stdin(argv[0]);
while ((line = xmalloc_getline(pre_computed_stream)) != NULL) {
char *filename_ptr;
@@ -168,17 +161,15 @@ int md5_sha1_sum_main(int argc, char **argv)
}
*/
} else {
while (optind < argc) {
char *file_ptr = argv[optind++];
hash_value = hash_file(file_ptr, hash_algo);
do {
hash_value = hash_file(*argv, hash_algo);
if (hash_value == NULL) {
return_value = EXIT_FAILURE;
} else {
printf("%s %s\n", hash_value, file_ptr);
printf("%s %s\n", hash_value, *argv);
free(hash_value);
}
}
} while (*++argv);
}
return return_value;
}
+2 -2
View File
@@ -14,12 +14,12 @@
#include "libcoreutils/coreutils.h"
int mkfifo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int mkfifo_main(int argc, char **argv)
int mkfifo_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
mode_t mode;
int retval = EXIT_SUCCESS;
mode = getopt_mk_fifo_nod(argc, argv);
mode = getopt_mk_fifo_nod(argv);
argv += optind;
if (!*argv) {
+21 -15
View File
@@ -24,27 +24,33 @@ int mknod_main(int argc, char **argv)
dev_t dev;
const char *name;
mode = getopt_mk_fifo_nod(argc, argv);
mode = getopt_mk_fifo_nod(argv);
argv += optind;
argc -= optind;
if ((argc >= 2) && ((name = strchr(modes_chars, argv[1][0])) != NULL)) {
mode |= modes_cubp[(int)(name[4])];
if (argc >= 2) {
name = strchr(modes_chars, argv[1][0]);
if (name != NULL) {
mode |= modes_cubp[(int)(name[4])];
dev = 0;
if ((*name != 'p') && ((argc -= 2) == 2)) {
/* Autodetect what the system supports; these macros should
* optimize out to two constants. */
dev = makedev(xatoul_range(argv[2], 0, major(UINT_MAX)),
xatoul_range(argv[3], 0, minor(UINT_MAX)));
}
dev = 0;
if (*name != 'p') {
argc -= 2;
if (argc == 2) {
/* Autodetect what the system supports; these macros should
* optimize out to two constants. */
dev = makedev(xatoul_range(argv[2], 0, major(UINT_MAX)),
xatoul_range(argv[3], 0, minor(UINT_MAX)));
}
}
if (argc == 2) {
name = *argv;
if (mknod(name, mode, dev) == 0) {
return EXIT_SUCCESS;
if (argc == 2) {
name = *argv;
if (mknod(name, mode, dev) == 0) {
return EXIT_SUCCESS;
}
bb_simple_perror_msg_and_die(name);
}
bb_simple_perror_msg_and_die(name);
}
}
bb_show_usage();
+1 -1
View File
@@ -58,7 +58,7 @@ int mv_main(int argc, char **argv)
if (argc == 2) {
dest_exists = cp_mv_stat(last, &dest_stat);
if (dest_exists < 0) {
return 1;
return EXIT_FAILURE;
}
if (!(dest_exists & 2)) {
+33 -15
View File
@@ -12,21 +12,41 @@
#include "libbb.h"
/* Compat info: nohup (GNU coreutils 6.8) does this:
# nohup true
nohup: ignoring input and appending output to `nohup.out'
# nohup true 1>/dev/null
nohup: ignoring input and redirecting stderr to stdout
# nohup true 2>zz
# cat zz
nohup: ignoring input and appending output to `nohup.out'
# nohup true 2>zz 1>/dev/null
# cat zz
nohup: ignoring input
# nohup true </dev/null 1>/dev/null
nohup: redirecting stderr to stdout
# nohup true </dev/null 2>zz 1>/dev/null
# cat zz
(nothing)
#
*/
int nohup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int nohup_main(int argc, char **argv)
{
int nullfd;
const char *nohupout;
char *home = NULL;
char *home;
xfunc_error_retval = 127;
if (argc < 2) bb_show_usage();
nullfd = xopen(bb_dev_null, O_WRONLY|O_APPEND);
/* If stdin is a tty, detach from it. */
if (isatty(STDIN_FILENO))
dup2(nullfd, STDIN_FILENO);
if (isatty(STDIN_FILENO)) {
/* bb_error_msg("ignoring input"); */
close(STDIN_FILENO);
xopen(bb_dev_null, O_RDONLY); /* will be fd 0 (STDIN_FILENO) */
}
nohupout = "nohup.out";
/* Redirect stdout to nohup.out, either in "." or in "$HOME". */
@@ -37,24 +57,22 @@ int nohup_main(int argc, char **argv)
if (home) {
nohupout = concat_path_file(home, nohupout);
xopen3(nohupout, O_CREAT|O_WRONLY|O_APPEND, S_IRUSR|S_IWUSR);
} else {
xopen(bb_dev_null, O_RDONLY); /* will be fd 1 */
}
}
} else dup2(nullfd, STDOUT_FILENO);
bb_error_msg("appending output to %s", nohupout);
}
/* If we have a tty on stderr, announce filename and redirect to stdout.
* Else redirect to /dev/null.
*/
/* If we have a tty on stderr, redirect to stdout. */
if (isatty(STDERR_FILENO)) {
bb_error_msg("appending to %s", nohupout);
/* if (stdout_wasnt_a_tty)
bb_error_msg("redirecting stderr to stdout"); */
dup2(STDOUT_FILENO, STDERR_FILENO);
} else dup2(nullfd, STDERR_FILENO);
}
if (nullfd > 2)
close(nullfd);
signal(SIGHUP, SIG_IGN);
BB_EXECVP(argv[1], argv+1);
if (ENABLE_FEATURE_CLEAN_UP && home)
free((char*)nohupout);
bb_simple_perror_msg_and_die(argv[1]);
}
+45 -65
View File
@@ -17,7 +17,7 @@
/* Written by Jim Meyering. */
/* Busyboxed by Denis Vlasenko
/* Busyboxed by Denys Vlasenko
Based on od.c from coreutils-5.2.1
Top bloat sources:
@@ -181,37 +181,23 @@ 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
no larger than 16 -- unless specified with the -w option. */
static size_t bytes_per_block;
/* Human-readable representation of *file_list (for error messages).
It differs from *file_list only when *file_list is "-". */
static char const *input_filename;
static unsigned bytes_per_block = 32; /* have to use unsigned, not size_t */
/* A NULL-terminated list of the file-arguments from the command line. */
static char const *const *file_list;
/* Initializer for file_list if no file-arguments
were specified on the command line. */
static char const *const default_file_list[] = { "-", NULL };
static const char *const *file_list;
/* The input stream associated with the current file. */
static FILE *in_stream;
#define MAX_INTEGRAL_TYPE_SIZE sizeof(ulonglong_t)
static unsigned char integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1] ALIGN1 = {
static const unsigned char integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1] ALIGN1 = {
[sizeof(char)] = CHAR,
#if USHRT_MAX != UCHAR_MAX
[sizeof(short)] = SHORT,
@@ -228,7 +214,7 @@ static unsigned char integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1] ALIGN1 = {
};
#define MAX_FP_TYPE_SIZE sizeof(longdouble_t)
static unsigned char fp_type_size[MAX_FP_TYPE_SIZE + 1] ALIGN1 = {
static const 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,
@@ -374,7 +360,7 @@ print_long_double(size_t n_bytes, const char *block, const char *fmt_string)
}
/* print_[named]_ascii are optimized for speed.
* Remember, someday you may want to pump gigabytes thru this thing.
* Remember, someday you may want to pump gigabytes through this thing.
* Saving a dozen of .text bytes here is counter-productive */
static void
@@ -481,14 +467,10 @@ static void
open_next_file(void)
{
while (1) {
input_filename = *file_list;
if (!input_filename)
if (!*file_list)
return;
file_list++;
in_stream = fopen_or_warn_stdin(input_filename);
in_stream = fopen_or_warn_stdin(*file_list++);
if (in_stream) {
if (in_stream == stdin)
input_filename = bb_msg_standard_input;
break;
}
ioerror = 1;
@@ -510,7 +492,10 @@ check_and_close(void)
{
if (in_stream) {
if (ferror(in_stream)) {
bb_error_msg("%s: read error", input_filename);
bb_error_msg("%s: read error", (in_stream == stdin)
? bb_msg_standard_input
: file_list[-1]
);
ioerror = 1;
}
fclose_if_not_stdin(in_stream);
@@ -738,7 +723,7 @@ decode_one_format(const char *s_orig, const char *s, const char **next,
/* Decode the modern od format string S. Append the decoded
representation to the global array SPEC, reallocating SPEC if
necessary. Return zero if S is valid, nonzero otherwise. */
necessary. */
static void
decode_format_string(const char *s)
@@ -791,21 +776,22 @@ skip(off_t n_skip)
as large as the size of the current file, we can
decrement n_skip and go on to the next file. */
if (fstat(fileno(in_stream), &file_stats) == 0
&& S_ISREG(file_stats.st_mode) && file_stats.st_size >= 0
&& S_ISREG(file_stats.st_mode) && file_stats.st_size > 0
) {
if (file_stats.st_size < n_skip) {
n_skip -= file_stats.st_size;
/* take check&close / open_next route */
/* take "check & close / open_next" route */
} else {
if (fseeko(in_stream, n_skip, SEEK_CUR) != 0)
ioerror = 1;
return;
}
} else {
/* If it's not a regular file with nonnegative size,
/* If it's not a regular file with positive size,
position the file pointer by reading. */
char buf[BUFSIZ];
size_t n_bytes_read, n_bytes_to_read = BUFSIZ;
char buf[1024];
size_t n_bytes_to_read = 1024;
size_t n_bytes_read;
while (n_skip > 0) {
if (n_skip < n_bytes_to_read)
@@ -1014,23 +1000,18 @@ parse_old_offset(const char *s, off_t *offset)
spec, extend the input block with zero bytes until its length is a
multiple of all format spec sizes. Write the final block. Finally,
write on a line by itself the offset of the byte after the last byte
read. Accumulate return values from calls to read_block and
check_and_close, and if any was nonzero, return nonzero.
Otherwise, return zero. */
read. */
static void
dump(void)
dump(off_t current_offset, off_t end_offset)
{
char *block[2];
off_t current_offset;
int idx;
size_t n_bytes_read;
block[0] = xmalloc(2*bytes_per_block);
block[1] = block[0] + bytes_per_block;
current_offset = n_bytes_to_skip;
idx = 0;
if (limit_bytes_to_format) {
while (1) {
@@ -1095,8 +1076,7 @@ dump(void)
and INPUT_FILENAME so they correspond to the next file in the list.
Then try to read a byte from the newly opened file. Repeat if
necessary until EOF is reached for the last file in FILE_LIST, then
set *C to EOF and return. Subsequent calls do likewise. The return
value is nonzero if any errors occured, zero otherwise. */
set *C to EOF and return. Subsequent calls do likewise. */
static void
read_char(int *c)
@@ -1129,15 +1109,13 @@ read_char(int *c)
A string constant is a run of at least 'string_min' ASCII
graphic (or formatting) characters terminated by a null.
Based on a function written by Richard Stallman for a
traditional version of od. Return nonzero if an error
occurs. Otherwise, return zero. */
traditional version of od. */
static void
dump_strings(void)
dump_strings(off_t address, off_t end_offset)
{
size_t bufsize = MAX(100, string_min);
char *buf = xmalloc(bufsize);
off_t address = n_bytes_to_skip;
while (1) {
size_t i;
@@ -1169,7 +1147,7 @@ dump_strings(void)
if (i < string_min) /* Too short! */
goto tryline;
/* If we get here, the string is all printable and null-terminated,
/* If we get here, the string is all printable and NUL-terminated,
* so print it. It is all in 'buf' and 'i' is its length. */
buf[i] = 0;
format_address(address - i - 1, ' ');
@@ -1183,7 +1161,7 @@ dump_strings(void)
case '\r': fputs("\\r", stdout); break;
case '\t': fputs("\\t", stdout); break;
case '\v': fputs("\\v", stdout); break;
default: bb_putchar(c);
default: putchar(c);
}
}
putchar('\n');
@@ -1205,11 +1183,6 @@ int od_main(int argc, char **argv)
{ "m", 1024*1024 },
{ }
};
unsigned opt;
int l_c_m;
/* The old-style 'pseudo starting address' to be printed in parentheses
after any true address. */
off_t pseudo_start = 0; // only for gcc
enum {
OPT_A = 1 << 0,
OPT_N = 1 << 1,
@@ -1244,8 +1217,18 @@ int od_main(int argc, char **argv)
;
#endif
char *str_A, *str_N, *str_j, *str_S;
char *str_w = NULL;
llist_t *lst_t = NULL;
unsigned opt;
int l_c_m;
/* The old-style 'pseudo starting address' to be printed in parentheses
after any true address. */
off_t pseudo_start = pseudo_start; // for gcc
/* The number of input bytes to skip before formatting and writing. */
off_t n_bytes_to_skip = 0;
/* The offset of the first byte after the last byte to be formatted. */
off_t end_offset = 0;
/* The maximum number of bytes that will be formatted. */
off_t max_bytes_to_format = 0;
spec = NULL;
format_address = format_address_std;
@@ -1254,7 +1237,7 @@ int od_main(int argc, char **argv)
/* flag_dump_strings = 0; - already is */
/* Parse command line */
opt_complementary = "t::"; // list
opt_complementary = "w+:t::"; /* -w N, -t is a list */
#if ENABLE_GETOPT_LONG
applet_long_options = od_longopts;
#endif
@@ -1263,7 +1246,7 @@ int od_main(int argc, char **argv)
// -S was -s and also had optional parameter
// but in coreutils 6.3 it was renamed and now has
// _mandatory_ parameter
&str_A, &str_N, &str_j, &lst_t, &str_S, &str_w);
&str_A, &str_N, &str_j, &lst_t, &str_S, &bytes_per_block);
argc -= optind;
argv += optind;
if (opt & OPT_A) {
@@ -1399,7 +1382,7 @@ int od_main(int argc, char **argv)
/* If no files were listed on the command line,
set the global pointer FILE_LIST so that it
references the null-terminated list of one name: "-". */
file_list = default_file_list;
file_list = bb_argv_dash;
if (argc > 0) {
/* Set the global pointer FILE_LIST so that it
references the first file-argument on the command-line. */
@@ -1411,7 +1394,7 @@ int od_main(int argc, char **argv)
/* skip over any unwanted header bytes */
skip(n_bytes_to_skip);
if (!in_stream)
return 1;
return EXIT_FAILURE;
pseudo_offset = (flag_pseudo_start ? pseudo_start - n_bytes_to_skip : 0);
@@ -1419,12 +1402,9 @@ int od_main(int argc, char **argv)
l_c_m = get_lcm();
if (opt & OPT_w) { /* -w: width */
bytes_per_block = 32;
if (str_w)
bytes_per_block = xatou(str_w);
if (!bytes_per_block || bytes_per_block % l_c_m != 0) {
bb_error_msg("warning: invalid width %zu; using %d instead",
bytes_per_block, l_c_m);
bb_error_msg("warning: invalid width %u; using %d instead",
(unsigned)bytes_per_block, l_c_m);
bytes_per_block = l_c_m;
}
} else {
@@ -1441,9 +1421,9 @@ int od_main(int argc, char **argv)
#endif
if (flag_dump_strings)
dump_strings();
dump_strings(n_bytes_to_skip, end_offset);
else
dump();
dump(n_bytes_to_skip, end_offset);
if (fclose(stdin) == EOF)
bb_perror_msg_and_die(bb_msg_standard_input);
+2 -3
View File
@@ -9,13 +9,12 @@
*/
#include "libbb.h"
extern char **environ;
int printenv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int printenv_main(int argc, char **argv)
int printenv_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
/* no variables specified, show whole env */
if (argc == 1) {
if (!argv[1]) {
int e = 0;
while (environ[e])
puts(environ[e++]);
+1 -1
View File
@@ -12,7 +12,7 @@
/* This is a NOFORK applet. Be very careful! */
int pwd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int pwd_main(int argc, char **argv)
int pwd_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
char *buf;
+3 -3
View File
@@ -8,14 +8,14 @@
*/
#include <getopt.h>
#include "libbb.h"
int readlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int readlink_main(int argc, char **argv)
int readlink_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
char *buf;
char *fname;
char pathbuf[PATH_MAX];
USE_FEATURE_READLINK_FOLLOW(
unsigned opt;
@@ -34,7 +34,7 @@ int readlink_main(int argc, char **argv)
logmode = LOGMODE_NONE;
if (opt) {
buf = realpath(fname, bb_common_bufsiz1);
buf = realpath(fname, pathbuf);
} else {
buf = xmalloc_readlink_or_warn(fname);
}
+3 -4
View File
@@ -13,7 +13,7 @@
#include "libbb.h"
int realpath_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int realpath_main(int argc, char **argv)
int realpath_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int retval = EXIT_SUCCESS;
@@ -25,19 +25,18 @@ int realpath_main(int argc, char **argv)
# define resolved_path_MUST_FREE 0
#endif
if (--argc == 0) {
if (!*++argv) {
bb_show_usage();
}
do {
argv++;
if (realpath(*argv, resolved_path) != NULL) {
puts(resolved_path);
} else {
retval = EXIT_FAILURE;
bb_simple_perror_msg(*argv);
}
} while (--argc);
} while (*++argv);
#if ENABLE_FEATURE_CLEAN_UP && resolved_path_MUST_FREE
RELEASE_CONFIG_BUFFER(resolved_path);
+1 -1
View File
@@ -20,7 +20,7 @@
/* This is a NOFORK applet. Be very careful! */
int rm_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int rm_main(int argc, char **argv)
int rm_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int status = 0;
int flags = 0;
+22 -13
View File
@@ -10,20 +10,30 @@
/* BB_AUDIT SUSv3 compliant */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/rmdir.html */
#include <libgen.h>
#include "libbb.h"
/* This is a NOFORK applet. Be very careful! */
#define PARENTS 0x01
#define IGNORE_NON_EMPTY 0x02
int rmdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int rmdir_main(int argc, char **argv)
int rmdir_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int status = EXIT_SUCCESS;
int flags;
int do_dot;
char *path;
#if ENABLE_FEATURE_RMDIR_LONG_OPTIONS
static const char rmdir_longopts[] ALIGN1 =
"parents\0" No_argument "p"
/* Debian etch: many packages fail to be purged or installed
* because they desperately want this option: */
"ignore-fail-on-non-empty\0" No_argument "\xff"
;
applet_long_options = rmdir_longopts;
#endif
flags = getopt32(argv, "p");
argv += optind;
@@ -34,27 +44,26 @@ int rmdir_main(int argc, char **argv)
do {
path = *argv;
/* Record if the first char was a '.' so we can use dirname later. */
do_dot = (*path == '.');
while (1) {
if (rmdir(path) < 0) {
#if ENABLE_FEATURE_RMDIR_LONG_OPTIONS
if ((flags & IGNORE_NON_EMPTY) && errno == ENOTEMPTY)
break;
#endif
bb_perror_msg("'%s'", path); /* Match gnu rmdir msg. */
status = EXIT_FAILURE;
} else if (flags) {
/* Note: path was not empty or null since rmdir succeeded. */
} else if (flags & PARENTS) {
/* Note: path was not "" since rmdir succeeded. */
path = dirname(path);
/* Path is now just the parent component. Note that dirname
* returns "." if there are no parents. We must distinguish
* this from the case of the original path starting with '.'.
/* Path is now just the parent component. Dirname
* returns "." if there are no parents.
*/
if (do_dot || (*path != '.') || path[1]) {
if (NOT_LONE_CHAR(path, '.')) {
continue;
}
}
break;
}
} while (*++argv);
return status;
+6 -11
View File
@@ -34,17 +34,16 @@ static const struct suffix_mult sfx[] = {
#endif
int sleep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int sleep_main(int argc, char **argv)
int sleep_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
unsigned duration;
++argv;
if (!*argv)
bb_show_usage();
#if ENABLE_FEATURE_FANCY_SLEEP
if (argc < 2) {
bb_show_usage();
}
++argv;
duration = 0;
do {
duration += xatoul_range_sfx(*argv, 0, UINT_MAX-duration, sfx);
@@ -52,11 +51,7 @@ int sleep_main(int argc, char **argv)
#else /* FEATURE_FANCY_SLEEP */
if (argc != 2) {
bb_show_usage();
}
duration = xatou(argv[1]);
duration = xatou(*argv);
#endif /* FEATURE_FANCY_SLEEP */
+16 -11
View File
@@ -32,7 +32,7 @@ enum {
FLAG_u = 8, /* Unique */
FLAG_c = 0x10, /* Check: no output, exit(!ordered) */
FLAG_s = 0x20, /* Stable sort, no ascii fallback at end */
FLAG_z = 0x40, /* Input is null terminated, not \n */
FLAG_z = 0x40, /* Input and output is NUL terminated, not \n */
/* These can be applied to search keys, the previous four can't */
FLAG_b = 0x80, /* Ignore leading blanks */
FLAG_r = 0x100, /* Reverse */
@@ -275,7 +275,7 @@ static unsigned str2u(char **str)
#endif
int sort_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int sort_main(int argc, char **argv)
int sort_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
FILE *fp, *outfile = stdout;
char *line, **lines = NULL;
@@ -351,10 +351,13 @@ int sort_main(int argc, char **argv)
if (option_mask32 & FLAG_b) option_mask32 |= FLAG_bb;
/* Open input files and read data */
for (i = argv[optind] ? optind : optind-1; argv[i]; i++) {
fp = stdin;
if (i >= optind && NOT_LONE_DASH(argv[i]))
fp = xfopen(argv[i], "r");
argv += optind;
if (!*argv)
*--argv = (char*)"-";
do {
/* coreutils 6.9 compat: abort on first open error,
* do not continue to next file: */
fp = xfopen_stdin(*argv);
for (;;) {
line = GET_LINE(fp);
if (!line) break;
@@ -362,8 +365,9 @@ int sort_main(int argc, char **argv)
lines = xrealloc(lines, sizeof(char *) * (linecount + 64));
lines[linecount++] = line;
}
fclose(fp);
}
fclose_if_not_stdin(fp);
} while (*++argv);
#if ENABLE_FEATURE_SORT_BIG
/* if no key, perform alphabetic sort */
if (!key_list)
@@ -374,9 +378,9 @@ int sort_main(int argc, char **argv)
for (i = 1; i < linecount; i++)
if (compare_keys(&lines[i-1], &lines[i]) > j) {
fprintf(stderr, "Check line %d\n", i);
return 1;
return EXIT_FAILURE;
}
return 0;
return EXIT_SUCCESS;
}
#endif
/* Perform the actual sort */
@@ -396,8 +400,9 @@ int sort_main(int argc, char **argv)
if (linecount) linecount = flag+1;
}
/* Print it */
flag = (option_mask32 & FLAG_z) ? '\0' : '\n';
for (i = 0; i < linecount; i++)
fprintf(outfile, "%s\n", lines[i]);
fprintf(outfile, "%s%c", lines[i], flag);
fflush_stdout_and_exit(EXIT_SUCCESS);
}
+7 -9
View File
@@ -56,7 +56,7 @@ enum { READ_BUFFER_SIZE = COMMON_BUFSIZE - 1 };
#define SPLIT_OPT_a (1<<2)
int split_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int split_main(int argc, char **argv)
int split_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
unsigned suffix_len = 2;
char *pfx;
@@ -68,15 +68,13 @@ int split_main(int argc, char **argv)
ssize_t bytes_read, to_write;
char *src;
opt_complementary = "?2";
opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &sfx);
opt_complementary = "?2:a+"; /* max 2 args; -a N */
opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len);
if (opt & SPLIT_OPT_l)
cnt = xatoul(count_p);
if (opt & SPLIT_OPT_b)
cnt = xatoul_sfx(count_p, split_suffices);
if (opt & SPLIT_OPT_a)
suffix_len = xatou(sfx);
cnt = XATOOFF(count_p);
if (opt & SPLIT_OPT_b) // FIXME: also needs XATOOFF
cnt = xatoull_sfx(count_p, split_suffices);
sfx = "x";
argv += optind;
@@ -137,5 +135,5 @@ int split_main(int argc, char **argv)
src += to_write;
} while (bytes_read);
}
return 0;
return EXIT_SUCCESS;
}
+18 -3
View File
@@ -21,6 +21,12 @@
#define OPT_DEREFERENCE (1 << 2)
#define OPT_SELINUX (1 << 3)
#if ENABLE_FEATURE_STAT_FORMAT
typedef bool (*statfunc_ptr)(const char *, const char *);
#else
typedef bool (*statfunc_ptr)(const char *);
#endif
static const char *file_type(const struct stat *st)
{
/* See POSIX 1003.1-2001 XCU Table 4-8 lines 17093-17107
@@ -338,8 +344,14 @@ static void print_it(const char *masterformat, const char *filename,
#endif
/* Stat the file system and print what we find. */
#if !ENABLE_FEATURE_STAT_FORMAT
#define do_statfs(filename, format) do_statfs(filename)
#endif
static bool do_statfs(const char *filename, const char *format)
{
#if !ENABLE_FEATURE_STAT_FORMAT
const char *format;
#endif
struct statfs statfsbuf;
#if ENABLE_SELINUX
security_context_t scontext = NULL;
@@ -447,6 +459,9 @@ static bool do_statfs(const char *filename, const char *format)
}
/* stat the file and print what we find */
#if !ENABLE_FEATURE_STAT_FORMAT
#define do_stat(filename, format) do_stat(filename)
#endif
static bool do_stat(const char *filename, const char *format)
{
struct stat statbuf;
@@ -612,10 +627,10 @@ static bool do_stat(const char *filename, const char *format)
int stat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int stat_main(int argc, char **argv)
{
char *format = NULL;
USE_FEATURE_STAT_FORMAT(char *format = NULL;)
int i;
int ok = 1;
bool (*statfunc)(const char *, const char *) = do_stat;
statfunc_ptr statfunc = do_stat;
getopt32(argv, "ftL"
USE_SELINUX("Z")
@@ -633,7 +648,7 @@ int stat_main(int argc, char **argv)
}
#endif /* ENABLE_SELINUX */
for (i = optind; i < argc; ++i)
ok &= statfunc(argv[i], format);
ok &= statfunc(argv[i] USE_FEATURE_STAT_FORMAT(, format));
return (ok ? EXIT_SUCCESS : EXIT_FAILURE);
}
+361 -152
View File
@@ -133,18 +133,27 @@ enum {
#define REV 4 /* Can be turned off by prepending '-' */
#define OMIT 8 /* Don't display value */
/* Each mode */
/* Each mode.
* This structure should be kept as small as humanly possible.
*/
struct mode_info {
const char name[9]; /* 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: */
const uint8_t type; /* Which structure element to change */
const uint8_t flags; /* Setting and display options */
/* only these values are ever used, so... */
#if (CSIZE | NLDLY | CRDLY | TABDLY | BSDLY | VTDLY | FFDLY) < 0x100
const uint8_t mask;
#elif (CSIZE | NLDLY | CRDLY | TABDLY | BSDLY | VTDLY | FFDLY) < 0x10000
const uint16_t mask;
#else
const tcflag_t mask; /* Other bits to turn off for this mode */
#endif
/* was using short here, but ppc32 was unhappy */
const tcflag_t bits; /* Bits to set for this mode */
};
enum {
/* Must match mode_info[] order! */
/* Must match mode_name[] and mode_info[] order! */
IDX_evenp = 0,
IDX_parity,
IDX_oddp,
@@ -170,151 +179,302 @@ enum {
#endif
};
#define MI_ENTRY(N,T,F,B,M) { N, T, F, M, B }
#define MI_ENTRY(N,T,F,B,M) N "\0"
static const struct mode_info mode_info[] = {
MI_ENTRY("evenp", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("parity", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("oddp", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("nl", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("ek", combination, OMIT, 0, 0 ),
MI_ENTRY("sane", combination, OMIT, 0, 0 ),
MI_ENTRY("cooked", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("raw", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("pass8", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("litout", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("cbreak", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("crt", combination, OMIT, 0, 0 ),
MI_ENTRY("dec", combination, OMIT, 0, 0 ),
/* Mode names given on command line */
static const char mode_name[] =
MI_ENTRY("evenp", combination, REV | OMIT, 0, 0 )
MI_ENTRY("parity", combination, REV | OMIT, 0, 0 )
MI_ENTRY("oddp", combination, REV | OMIT, 0, 0 )
MI_ENTRY("nl", combination, REV | OMIT, 0, 0 )
MI_ENTRY("ek", combination, OMIT, 0, 0 )
MI_ENTRY("sane", combination, OMIT, 0, 0 )
MI_ENTRY("cooked", combination, REV | OMIT, 0, 0 )
MI_ENTRY("raw", combination, REV | OMIT, 0, 0 )
MI_ENTRY("pass8", combination, REV | OMIT, 0, 0 )
MI_ENTRY("litout", combination, REV | OMIT, 0, 0 )
MI_ENTRY("cbreak", combination, REV | OMIT, 0, 0 )
MI_ENTRY("crt", combination, OMIT, 0, 0 )
MI_ENTRY("dec", combination, OMIT, 0, 0 )
#ifdef IXANY
MI_ENTRY("decctlq", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("decctlq", combination, REV | OMIT, 0, 0 )
#endif
#if defined(TABDLY) || defined(OXTABS)
MI_ENTRY("tabs", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("tabs", combination, REV | OMIT, 0, 0 )
#endif
#if defined(XCASE) && defined(IUCLC) && defined(OLCUC)
MI_ENTRY("lcase", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("LCASE", combination, REV | OMIT, 0, 0 ),
MI_ENTRY("lcase", combination, REV | OMIT, 0, 0 )
MI_ENTRY("LCASE", combination, REV | OMIT, 0, 0 )
#endif
MI_ENTRY("parenb", control, REV, PARENB, 0 ),
MI_ENTRY("parodd", control, REV, PARODD, 0 ),
MI_ENTRY("cs5", control, 0, CS5, CSIZE),
MI_ENTRY("cs6", control, 0, CS6, CSIZE),
MI_ENTRY("cs7", control, 0, CS7, CSIZE),
MI_ENTRY("cs8", control, 0, CS8, CSIZE),
MI_ENTRY("hupcl", control, REV, HUPCL, 0 ),
MI_ENTRY("hup", control, REV | OMIT, HUPCL, 0 ),
MI_ENTRY("cstopb", control, REV, CSTOPB, 0 ),
MI_ENTRY("cread", control, SANE_SET | REV, CREAD, 0 ),
MI_ENTRY("clocal", control, REV, CLOCAL, 0 ),
MI_ENTRY("parenb", control, REV, PARENB, 0 )
MI_ENTRY("parodd", control, REV, PARODD, 0 )
MI_ENTRY("cs5", control, 0, CS5, CSIZE)
MI_ENTRY("cs6", control, 0, CS6, CSIZE)
MI_ENTRY("cs7", control, 0, CS7, CSIZE)
MI_ENTRY("cs8", control, 0, CS8, CSIZE)
MI_ENTRY("hupcl", control, REV, HUPCL, 0 )
MI_ENTRY("hup", control, REV | OMIT, HUPCL, 0 )
MI_ENTRY("cstopb", control, REV, CSTOPB, 0 )
MI_ENTRY("cread", control, SANE_SET | REV, CREAD, 0 )
MI_ENTRY("clocal", control, REV, CLOCAL, 0 )
#ifdef CRTSCTS
MI_ENTRY("crtscts", control, REV, CRTSCTS, 0 ),
MI_ENTRY("crtscts", control, REV, CRTSCTS, 0 )
#endif
MI_ENTRY("ignbrk", input, SANE_UNSET | REV, IGNBRK, 0 ),
MI_ENTRY("brkint", input, SANE_SET | REV, BRKINT, 0 ),
MI_ENTRY("ignpar", input, REV, IGNPAR, 0 ),
MI_ENTRY("parmrk", input, REV, PARMRK, 0 ),
MI_ENTRY("inpck", input, REV, INPCK, 0 ),
MI_ENTRY("istrip", input, REV, ISTRIP, 0 ),
MI_ENTRY("inlcr", input, SANE_UNSET | REV, INLCR, 0 ),
MI_ENTRY("igncr", input, SANE_UNSET | REV, IGNCR, 0 ),
MI_ENTRY("icrnl", input, SANE_SET | REV, ICRNL, 0 ),
MI_ENTRY("ixon", input, REV, IXON, 0 ),
MI_ENTRY("ixoff", input, SANE_UNSET | REV, IXOFF, 0 ),
MI_ENTRY("tandem", input, REV | OMIT, IXOFF, 0 ),
MI_ENTRY("ignbrk", input, SANE_UNSET | REV, IGNBRK, 0 )
MI_ENTRY("brkint", input, SANE_SET | REV, BRKINT, 0 )
MI_ENTRY("ignpar", input, REV, IGNPAR, 0 )
MI_ENTRY("parmrk", input, REV, PARMRK, 0 )
MI_ENTRY("inpck", input, REV, INPCK, 0 )
MI_ENTRY("istrip", input, REV, ISTRIP, 0 )
MI_ENTRY("inlcr", input, SANE_UNSET | REV, INLCR, 0 )
MI_ENTRY("igncr", input, SANE_UNSET | REV, IGNCR, 0 )
MI_ENTRY("icrnl", input, SANE_SET | REV, ICRNL, 0 )
MI_ENTRY("ixon", input, REV, IXON, 0 )
MI_ENTRY("ixoff", input, SANE_UNSET | REV, IXOFF, 0 )
MI_ENTRY("tandem", input, REV | OMIT, IXOFF, 0 )
#ifdef IUCLC
MI_ENTRY("iuclc", input, SANE_UNSET | REV, IUCLC, 0 ),
MI_ENTRY("iuclc", input, SANE_UNSET | REV, IUCLC, 0 )
#endif
#ifdef IXANY
MI_ENTRY("ixany", input, SANE_UNSET | REV, IXANY, 0 ),
MI_ENTRY("ixany", input, SANE_UNSET | REV, IXANY, 0 )
#endif
#ifdef IMAXBEL
MI_ENTRY("imaxbel", input, SANE_SET | REV, IMAXBEL, 0 ),
MI_ENTRY("imaxbel", input, SANE_SET | REV, IMAXBEL, 0 )
#endif
MI_ENTRY("opost", output, SANE_SET | REV, OPOST, 0 ),
MI_ENTRY("opost", output, SANE_SET | REV, OPOST, 0 )
#ifdef OLCUC
MI_ENTRY("olcuc", output, SANE_UNSET | REV, OLCUC, 0 ),
MI_ENTRY("olcuc", output, SANE_UNSET | REV, OLCUC, 0 )
#endif
#ifdef OCRNL
MI_ENTRY("ocrnl", output, SANE_UNSET | REV, OCRNL, 0 ),
MI_ENTRY("ocrnl", output, SANE_UNSET | REV, OCRNL, 0 )
#endif
#ifdef ONLCR
MI_ENTRY("onlcr", output, SANE_SET | REV, ONLCR, 0 ),
MI_ENTRY("onlcr", output, SANE_SET | REV, ONLCR, 0 )
#endif
#ifdef ONOCR
MI_ENTRY("onocr", output, SANE_UNSET | REV, ONOCR, 0 ),
MI_ENTRY("onocr", output, SANE_UNSET | REV, ONOCR, 0 )
#endif
#ifdef ONLRET
MI_ENTRY("onlret", output, SANE_UNSET | REV, ONLRET, 0 ),
MI_ENTRY("onlret", output, SANE_UNSET | REV, ONLRET, 0 )
#endif
#ifdef OFILL
MI_ENTRY("ofill", output, SANE_UNSET | REV, OFILL, 0 ),
MI_ENTRY("ofill", output, SANE_UNSET | REV, OFILL, 0 )
#endif
#ifdef OFDEL
MI_ENTRY("ofdel", output, SANE_UNSET | REV, OFDEL, 0 ),
MI_ENTRY("ofdel", output, SANE_UNSET | REV, OFDEL, 0 )
#endif
#ifdef NLDLY
MI_ENTRY("nl1", output, SANE_UNSET, NL1, NLDLY),
MI_ENTRY("nl0", output, SANE_SET, NL0, NLDLY),
MI_ENTRY("nl1", output, SANE_UNSET, NL1, NLDLY)
MI_ENTRY("nl0", output, SANE_SET, NL0, NLDLY)
#endif
#ifdef CRDLY
MI_ENTRY("cr3", output, SANE_UNSET, CR3, CRDLY),
MI_ENTRY("cr2", output, SANE_UNSET, CR2, CRDLY),
MI_ENTRY("cr1", output, SANE_UNSET, CR1, CRDLY),
MI_ENTRY("cr0", output, SANE_SET, CR0, CRDLY),
MI_ENTRY("cr3", output, SANE_UNSET, CR3, CRDLY)
MI_ENTRY("cr2", output, SANE_UNSET, CR2, CRDLY)
MI_ENTRY("cr1", output, SANE_UNSET, CR1, CRDLY)
MI_ENTRY("cr0", output, SANE_SET, CR0, CRDLY)
#endif
#ifdef TABDLY
MI_ENTRY("tab3", output, SANE_UNSET, TAB3, TABDLY),
MI_ENTRY("tab2", output, SANE_UNSET, TAB2, TABDLY),
MI_ENTRY("tab1", output, SANE_UNSET, TAB1, TABDLY),
MI_ENTRY("tab0", output, SANE_SET, TAB0, TABDLY),
MI_ENTRY("tab3", output, SANE_UNSET, TAB3, TABDLY)
MI_ENTRY("tab2", output, SANE_UNSET, TAB2, TABDLY)
MI_ENTRY("tab1", output, SANE_UNSET, TAB1, TABDLY)
MI_ENTRY("tab0", output, SANE_SET, TAB0, TABDLY)
#else
# ifdef OXTABS
MI_ENTRY("tab3", output, SANE_UNSET, OXTABS, 0 ),
MI_ENTRY("tab3", output, SANE_UNSET, OXTABS, 0 )
# endif
#endif
#ifdef BSDLY
MI_ENTRY("bs1", output, SANE_UNSET, BS1, BSDLY),
MI_ENTRY("bs0", output, SANE_SET, BS0, BSDLY),
MI_ENTRY("bs1", output, SANE_UNSET, BS1, BSDLY)
MI_ENTRY("bs0", output, SANE_SET, BS0, BSDLY)
#endif
#ifdef VTDLY
MI_ENTRY("vt1", output, SANE_UNSET, VT1, VTDLY),
MI_ENTRY("vt0", output, SANE_SET, VT0, VTDLY),
MI_ENTRY("vt1", output, SANE_UNSET, VT1, VTDLY)
MI_ENTRY("vt0", output, SANE_SET, VT0, VTDLY)
#endif
#ifdef FFDLY
MI_ENTRY("ff1", output, SANE_UNSET, FF1, FFDLY),
MI_ENTRY("ff0", output, SANE_SET, FF0, FFDLY),
MI_ENTRY("ff1", output, SANE_UNSET, FF1, FFDLY)
MI_ENTRY("ff0", output, SANE_SET, FF0, FFDLY)
#endif
MI_ENTRY("isig", local, SANE_SET | REV, ISIG, 0 ),
MI_ENTRY("icanon", local, SANE_SET | REV, ICANON, 0 ),
MI_ENTRY("isig", local, SANE_SET | REV, ISIG, 0 )
MI_ENTRY("icanon", local, SANE_SET | REV, ICANON, 0 )
#ifdef IEXTEN
MI_ENTRY("iexten", local, SANE_SET | REV, IEXTEN, 0 ),
MI_ENTRY("iexten", local, SANE_SET | REV, IEXTEN, 0 )
#endif
MI_ENTRY("echo", local, SANE_SET | REV, ECHO, 0 ),
MI_ENTRY("echoe", local, SANE_SET | REV, ECHOE, 0 ),
MI_ENTRY("crterase", local, REV | OMIT, ECHOE, 0 ),
MI_ENTRY("echok", local, SANE_SET | REV, ECHOK, 0 ),
MI_ENTRY("echonl", local, SANE_UNSET | REV, ECHONL, 0 ),
MI_ENTRY("noflsh", local, SANE_UNSET | REV, NOFLSH, 0 ),
MI_ENTRY("echo", local, SANE_SET | REV, ECHO, 0 )
MI_ENTRY("echoe", local, SANE_SET | REV, ECHOE, 0 )
MI_ENTRY("crterase", local, REV | OMIT, ECHOE, 0 )
MI_ENTRY("echok", local, SANE_SET | REV, ECHOK, 0 )
MI_ENTRY("echonl", local, SANE_UNSET | REV, ECHONL, 0 )
MI_ENTRY("noflsh", local, SANE_UNSET | REV, NOFLSH, 0 )
#ifdef XCASE
MI_ENTRY("xcase", local, SANE_UNSET | REV, XCASE, 0 ),
MI_ENTRY("xcase", local, SANE_UNSET | REV, XCASE, 0 )
#endif
#ifdef TOSTOP
MI_ENTRY("tostop", local, SANE_UNSET | REV, TOSTOP, 0 ),
MI_ENTRY("tostop", local, SANE_UNSET | REV, TOSTOP, 0 )
#endif
#ifdef ECHOPRT
MI_ENTRY("echoprt", local, SANE_UNSET | REV, ECHOPRT, 0 ),
MI_ENTRY("prterase", local, REV | OMIT, ECHOPRT, 0 ),
MI_ENTRY("echoprt", local, SANE_UNSET | REV, ECHOPRT, 0 )
MI_ENTRY("prterase", local, REV | OMIT, ECHOPRT, 0 )
#endif
#ifdef ECHOCTL
MI_ENTRY("echoctl", local, SANE_SET | REV, ECHOCTL, 0 ),
MI_ENTRY("ctlecho", local, REV | OMIT, ECHOCTL, 0 ),
MI_ENTRY("echoctl", local, SANE_SET | REV, ECHOCTL, 0 )
MI_ENTRY("ctlecho", local, REV | OMIT, ECHOCTL, 0 )
#endif
#ifdef ECHOKE
MI_ENTRY("echoke", local, SANE_SET | REV, ECHOKE, 0 ),
MI_ENTRY("crtkill", local, REV | OMIT, ECHOKE, 0 ),
MI_ENTRY("echoke", local, SANE_SET | REV, ECHOKE, 0 )
MI_ENTRY("crtkill", local, REV | OMIT, ECHOKE, 0 )
#endif
;
#undef MI_ENTRY
#define MI_ENTRY(N,T,F,B,M) { T, F, M, B },
static const struct mode_info mode_info[] = {
/* This should be verbatim cut-n-paste copy of the above MI_ENTRYs */
MI_ENTRY("evenp", combination, REV | OMIT, 0, 0 )
MI_ENTRY("parity", combination, REV | OMIT, 0, 0 )
MI_ENTRY("oddp", combination, REV | OMIT, 0, 0 )
MI_ENTRY("nl", combination, REV | OMIT, 0, 0 )
MI_ENTRY("ek", combination, OMIT, 0, 0 )
MI_ENTRY("sane", combination, OMIT, 0, 0 )
MI_ENTRY("cooked", combination, REV | OMIT, 0, 0 )
MI_ENTRY("raw", combination, REV | OMIT, 0, 0 )
MI_ENTRY("pass8", combination, REV | OMIT, 0, 0 )
MI_ENTRY("litout", combination, REV | OMIT, 0, 0 )
MI_ENTRY("cbreak", combination, REV | OMIT, 0, 0 )
MI_ENTRY("crt", combination, OMIT, 0, 0 )
MI_ENTRY("dec", combination, OMIT, 0, 0 )
#ifdef IXANY
MI_ENTRY("decctlq", combination, REV | OMIT, 0, 0 )
#endif
#if defined(TABDLY) || defined(OXTABS)
MI_ENTRY("tabs", combination, REV | OMIT, 0, 0 )
#endif
#if defined(XCASE) && defined(IUCLC) && defined(OLCUC)
MI_ENTRY("lcase", combination, REV | OMIT, 0, 0 )
MI_ENTRY("LCASE", combination, REV | OMIT, 0, 0 )
#endif
MI_ENTRY("parenb", control, REV, PARENB, 0 )
MI_ENTRY("parodd", control, REV, PARODD, 0 )
MI_ENTRY("cs5", control, 0, CS5, CSIZE)
MI_ENTRY("cs6", control, 0, CS6, CSIZE)
MI_ENTRY("cs7", control, 0, CS7, CSIZE)
MI_ENTRY("cs8", control, 0, CS8, CSIZE)
MI_ENTRY("hupcl", control, REV, HUPCL, 0 )
MI_ENTRY("hup", control, REV | OMIT, HUPCL, 0 )
MI_ENTRY("cstopb", control, REV, CSTOPB, 0 )
MI_ENTRY("cread", control, SANE_SET | REV, CREAD, 0 )
MI_ENTRY("clocal", control, REV, CLOCAL, 0 )
#ifdef CRTSCTS
MI_ENTRY("crtscts", control, REV, CRTSCTS, 0 )
#endif
MI_ENTRY("ignbrk", input, SANE_UNSET | REV, IGNBRK, 0 )
MI_ENTRY("brkint", input, SANE_SET | REV, BRKINT, 0 )
MI_ENTRY("ignpar", input, REV, IGNPAR, 0 )
MI_ENTRY("parmrk", input, REV, PARMRK, 0 )
MI_ENTRY("inpck", input, REV, INPCK, 0 )
MI_ENTRY("istrip", input, REV, ISTRIP, 0 )
MI_ENTRY("inlcr", input, SANE_UNSET | REV, INLCR, 0 )
MI_ENTRY("igncr", input, SANE_UNSET | REV, IGNCR, 0 )
MI_ENTRY("icrnl", input, SANE_SET | REV, ICRNL, 0 )
MI_ENTRY("ixon", input, REV, IXON, 0 )
MI_ENTRY("ixoff", input, SANE_UNSET | REV, IXOFF, 0 )
MI_ENTRY("tandem", input, REV | OMIT, IXOFF, 0 )
#ifdef IUCLC
MI_ENTRY("iuclc", input, SANE_UNSET | REV, IUCLC, 0 )
#endif
#ifdef IXANY
MI_ENTRY("ixany", input, SANE_UNSET | REV, IXANY, 0 )
#endif
#ifdef IMAXBEL
MI_ENTRY("imaxbel", input, SANE_SET | REV, IMAXBEL, 0 )
#endif
MI_ENTRY("opost", output, SANE_SET | REV, OPOST, 0 )
#ifdef OLCUC
MI_ENTRY("olcuc", output, SANE_UNSET | REV, OLCUC, 0 )
#endif
#ifdef OCRNL
MI_ENTRY("ocrnl", output, SANE_UNSET | REV, OCRNL, 0 )
#endif
#ifdef ONLCR
MI_ENTRY("onlcr", output, SANE_SET | REV, ONLCR, 0 )
#endif
#ifdef ONOCR
MI_ENTRY("onocr", output, SANE_UNSET | REV, ONOCR, 0 )
#endif
#ifdef ONLRET
MI_ENTRY("onlret", output, SANE_UNSET | REV, ONLRET, 0 )
#endif
#ifdef OFILL
MI_ENTRY("ofill", output, SANE_UNSET | REV, OFILL, 0 )
#endif
#ifdef OFDEL
MI_ENTRY("ofdel", output, SANE_UNSET | REV, OFDEL, 0 )
#endif
#ifdef NLDLY
MI_ENTRY("nl1", output, SANE_UNSET, NL1, NLDLY)
MI_ENTRY("nl0", output, SANE_SET, NL0, NLDLY)
#endif
#ifdef CRDLY
MI_ENTRY("cr3", output, SANE_UNSET, CR3, CRDLY)
MI_ENTRY("cr2", output, SANE_UNSET, CR2, CRDLY)
MI_ENTRY("cr1", output, SANE_UNSET, CR1, CRDLY)
MI_ENTRY("cr0", output, SANE_SET, CR0, CRDLY)
#endif
#ifdef TABDLY
MI_ENTRY("tab3", output, SANE_UNSET, TAB3, TABDLY)
MI_ENTRY("tab2", output, SANE_UNSET, TAB2, TABDLY)
MI_ENTRY("tab1", output, SANE_UNSET, TAB1, TABDLY)
MI_ENTRY("tab0", output, SANE_SET, TAB0, TABDLY)
#else
# ifdef OXTABS
MI_ENTRY("tab3", output, SANE_UNSET, OXTABS, 0 )
# endif
#endif
#ifdef BSDLY
MI_ENTRY("bs1", output, SANE_UNSET, BS1, BSDLY)
MI_ENTRY("bs0", output, SANE_SET, BS0, BSDLY)
#endif
#ifdef VTDLY
MI_ENTRY("vt1", output, SANE_UNSET, VT1, VTDLY)
MI_ENTRY("vt0", output, SANE_SET, VT0, VTDLY)
#endif
#ifdef FFDLY
MI_ENTRY("ff1", output, SANE_UNSET, FF1, FFDLY)
MI_ENTRY("ff0", output, SANE_SET, FF0, FFDLY)
#endif
MI_ENTRY("isig", local, SANE_SET | REV, ISIG, 0 )
MI_ENTRY("icanon", local, SANE_SET | REV, ICANON, 0 )
#ifdef IEXTEN
MI_ENTRY("iexten", local, SANE_SET | REV, IEXTEN, 0 )
#endif
MI_ENTRY("echo", local, SANE_SET | REV, ECHO, 0 )
MI_ENTRY("echoe", local, SANE_SET | REV, ECHOE, 0 )
MI_ENTRY("crterase", local, REV | OMIT, ECHOE, 0 )
MI_ENTRY("echok", local, SANE_SET | REV, ECHOK, 0 )
MI_ENTRY("echonl", local, SANE_UNSET | REV, ECHONL, 0 )
MI_ENTRY("noflsh", local, SANE_UNSET | REV, NOFLSH, 0 )
#ifdef XCASE
MI_ENTRY("xcase", local, SANE_UNSET | REV, XCASE, 0 )
#endif
#ifdef TOSTOP
MI_ENTRY("tostop", local, SANE_UNSET | REV, TOSTOP, 0 )
#endif
#ifdef ECHOPRT
MI_ENTRY("echoprt", local, SANE_UNSET | REV, ECHOPRT, 0 )
MI_ENTRY("prterase", local, REV | OMIT, ECHOPRT, 0 )
#endif
#ifdef ECHOCTL
MI_ENTRY("echoctl", local, SANE_SET | REV, ECHOCTL, 0 )
MI_ENTRY("ctlecho", local, REV | OMIT, ECHOCTL, 0 )
#endif
#ifdef ECHOKE
MI_ENTRY("echoke", local, SANE_SET | REV, ECHOKE, 0 )
MI_ENTRY("crtkill", local, REV | OMIT, ECHOKE, 0 )
#endif
};
@@ -322,15 +482,15 @@ enum {
NUM_mode_info = ARRAY_SIZE(mode_info)
};
/* Control characters */
struct control_info {
const char name[7]; /* Name given on command line */
const unsigned char saneval; /* Value to set for 'stty sane' */
const unsigned char offset; /* Offset in c_cc */
const uint8_t saneval; /* Value to set for 'stty sane' */
const uint8_t offset; /* Offset in c_cc */
};
enum {
/* Must match control_info[] order! */
/* Must match control_name[] and control_info[] order! */
CIDX_intr = 0,
CIDX_quit,
CIDX_erase,
@@ -368,60 +528,111 @@ enum {
CIDX_time,
};
static const struct control_info control_info[] = {
{"intr", CINTR, VINTR},
{"quit", CQUIT, VQUIT},
{"erase", CERASE, VERASE},
{"kill", CKILL, VKILL},
{"eof", CEOF, VEOF},
{"eol", CEOL, VEOL},
#define CI_ENTRY(n,s,o) n "\0"
/* Name given on command line */
static const char control_name[] =
CI_ENTRY("intr", CINTR, VINTR )
CI_ENTRY("quit", CQUIT, VQUIT )
CI_ENTRY("erase", CERASE, VERASE )
CI_ENTRY("kill", CKILL, VKILL )
CI_ENTRY("eof", CEOF, VEOF )
CI_ENTRY("eol", CEOL, VEOL )
#ifdef VEOL2
{"eol2", CEOL2, VEOL2},
CI_ENTRY("eol2", CEOL2, VEOL2 )
#endif
#ifdef VSWTCH
{"swtch", CSWTCH, VSWTCH},
CI_ENTRY("swtch", CSWTCH, VSWTCH )
#endif
{"start", CSTART, VSTART},
{"stop", CSTOP, VSTOP},
{"susp", CSUSP, VSUSP},
CI_ENTRY("start", CSTART, VSTART )
CI_ENTRY("stop", CSTOP, VSTOP )
CI_ENTRY("susp", CSUSP, VSUSP )
#ifdef VDSUSP
{"dsusp", CDSUSP, VDSUSP},
CI_ENTRY("dsusp", CDSUSP, VDSUSP )
#endif
#ifdef VREPRINT
{"rprnt", CRPRNT, VREPRINT},
CI_ENTRY("rprnt", CRPRNT, VREPRINT)
#endif
#ifdef VWERASE
{"werase", CWERASE, VWERASE},
CI_ENTRY("werase", CWERASE, VWERASE )
#endif
#ifdef VLNEXT
{"lnext", CLNEXT, VLNEXT},
CI_ENTRY("lnext", CLNEXT, VLNEXT )
#endif
#ifdef VFLUSHO
{"flush", CFLUSHO, VFLUSHO},
CI_ENTRY("flush", CFLUSHO, VFLUSHO )
#endif
#ifdef VSTATUS
{"status", CSTATUS, VSTATUS},
CI_ENTRY("status", CSTATUS, VSTATUS )
#endif
/* These must be last because of the display routines */
{"min", 1, VMIN},
{"time", 0, VTIME},
CI_ENTRY("min", 1, VMIN )
CI_ENTRY("time", 0, VTIME )
;
#undef CI_ENTRY
#define CI_ENTRY(n,s,o) { s, o },
static const struct control_info control_info[] = {
/* This should be verbatim cut-n-paste copy of the above CI_ENTRYs */
CI_ENTRY("intr", CINTR, VINTR )
CI_ENTRY("quit", CQUIT, VQUIT )
CI_ENTRY("erase", CERASE, VERASE )
CI_ENTRY("kill", CKILL, VKILL )
CI_ENTRY("eof", CEOF, VEOF )
CI_ENTRY("eol", CEOL, VEOL )
#ifdef VEOL2
CI_ENTRY("eol2", CEOL2, VEOL2 )
#endif
#ifdef VSWTCH
CI_ENTRY("swtch", CSWTCH, VSWTCH )
#endif
CI_ENTRY("start", CSTART, VSTART )
CI_ENTRY("stop", CSTOP, VSTOP )
CI_ENTRY("susp", CSUSP, VSUSP )
#ifdef VDSUSP
CI_ENTRY("dsusp", CDSUSP, VDSUSP )
#endif
#ifdef VREPRINT
CI_ENTRY("rprnt", CRPRNT, VREPRINT)
#endif
#ifdef VWERASE
CI_ENTRY("werase", CWERASE, VWERASE )
#endif
#ifdef VLNEXT
CI_ENTRY("lnext", CLNEXT, VLNEXT )
#endif
#ifdef VFLUSHO
CI_ENTRY("flush", CFLUSHO, VFLUSHO )
#endif
#ifdef VSTATUS
CI_ENTRY("status", CSTATUS, VSTATUS )
#endif
/* These must be last because of the display routines */
CI_ENTRY("min", 1, VMIN )
CI_ENTRY("time", 0, VTIME )
};
enum {
NUM_control_info = ARRAY_SIZE(control_info)
};
/* The width of the screen, for output wrapping */
unsigned max_col = 80; /* default */
struct globals {
const char *device_name; // = bb_msg_standard_input;
/* The width of the screen, for output wrapping */
unsigned max_col; // = 80;
/* Current position, to know when to wrap */
unsigned current_col;
char buf[10];
};
#define G (*(struct globals*)&bb_common_bufsiz1)
#define INIT_G() \
do { \
G.device_name = bb_msg_standard_input; \
G.max_col = 80; \
} while (0)
static const char *device_name = bb_msg_standard_input;
/* Return a string that is the printable representation of character CH */
/* Adapted from 'cat' by Torbjorn Granlund */
@@ -454,7 +665,7 @@ static const char *visible(unsigned ch)
static tcflag_t *mode_type_flag(unsigned type, const struct termios *mode)
{
static const unsigned char tcflag_offsets[] ALIGN1 = {
static const uint8_t tcflag_offsets[] ALIGN1 = {
offsetof(struct termios, c_cflag), /* control */
offsetof(struct termios, c_iflag), /* input */
offsetof(struct termios, c_oflag), /* output */
@@ -484,12 +695,12 @@ static void set_speed_or_die(enum speed_setting type, const char *const arg,
static ATTRIBUTE_NORETURN void perror_on_device_and_die(const char *fmt)
{
bb_perror_msg_and_die(fmt, device_name);
bb_perror_msg_and_die(fmt, G.device_name);
}
static void perror_on_device(const char *fmt)
{
bb_perror_msg(fmt, device_name);
bb_perror_msg(fmt, G.device_name);
}
/* Print format string MESSAGE and optional args.
@@ -511,7 +722,7 @@ static void wrapf(const char *message, ...)
if (G.current_col > 0) {
G.current_col++;
if (buf[0] != '\n') {
if (G.current_col + buflen >= max_col) {
if (G.current_col + buflen >= G.max_col) {
bb_putchar('\n');
G.current_col = 0;
} else
@@ -526,7 +737,7 @@ static void wrapf(const char *message, ...)
static void set_window_size(const int rows, const int cols)
{
struct winsize win = { 0, 0, 0, 0};
struct winsize win = { 0, 0, 0, 0 };
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &win)) {
if (errno != EINVAL) {
@@ -569,20 +780,14 @@ static const struct suffix_mult stty_suffixes[] = {
static const struct mode_info *find_mode(const char *name)
{
int i;
for (i = 0; i < NUM_mode_info; ++i)
if (!strcmp(name, mode_info[i].name))
return &mode_info[i];
return 0;
int i = index_in_strings(mode_name, name);
return i >= 0 ? &mode_info[i] : NULL;
}
static const struct control_info *find_control(const char *name)
{
int i;
for (i = 0; i < NUM_control_info; ++i)
if (!strcmp(name, control_info[i].name))
return &control_info[i];
return 0;
int i = index_in_strings(control_name, name);
return i >= 0 ? &control_info[i] : NULL;
}
enum {
@@ -704,7 +909,7 @@ static void do_display(const struct termios *mode, const int all)
continue;
}
#endif
wrapf("%s = %s;", control_info[i].name,
wrapf("%s = %s;", nth_string(control_name, i),
visible(mode->c_cc[control_info[i].offset]));
}
#if VEOF == VMIN
@@ -726,12 +931,13 @@ static void do_display(const struct termios *mode, const int all)
mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits;
if ((*bitsp & mask) == mode_info[i].bits) {
if (all || (mode_info[i].flags & SANE_UNSET))
wrapf("%s", mode_info[i].name);
wrapf("-%s"+1, nth_string(mode_name, i));
} else {
if ((all && mode_info[i].flags & REV) ||
(!all &&
(mode_info[i].flags & (SANE_SET | REV)) == (SANE_SET | REV)))
wrapf("-%s", mode_info[i].name);
if ((all && mode_info[i].flags & REV)
|| (!all && (mode_info[i].flags & (SANE_SET | REV)) == (SANE_SET | REV))
) {
wrapf("-%s", nth_string(mode_name, i));
}
}
}
if (G.current_col) wrapf("\n");
@@ -861,8 +1067,8 @@ static void set_mode(const struct mode_info *info, int reversed,
mode->c_oflag &= ~OPOST;
}
} else if (info == &mode_info[IDX_raw] || info == &mode_info[IDX_cooked]) {
if ((info->name[0] == 'r' && reversed)
|| (info->name[0] == 'c' && !reversed)
if ((info == &mode_info[IDX_raw] && reversed)
|| (info == &mode_info[IDX_cooked] && !reversed)
) {
/* Cooked mode */
mode->c_iflag |= BRKINT | IGNPAR | ISTRIP | ICRNL | IXON;
@@ -944,11 +1150,12 @@ static void set_control_char_or_die(const struct control_info *info,
mode->c_cc[info->offset] = value;
}
#define STTY_require_set_attr (1<<0)
#define STTY_speed_was_set (1<<1)
#define STTY_verbose_output (1<<2)
#define STTY_recoverable_output (1<<3)
#define STTY_noargs (1<<4)
#define STTY_require_set_attr (1 << 0)
#define STTY_speed_was_set (1 << 1)
#define STTY_verbose_output (1 << 2)
#define STTY_recoverable_output (1 << 3)
#define STTY_noargs (1 << 4)
int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int stty_main(int argc, char **argv)
{
@@ -959,6 +1166,8 @@ int stty_main(int argc, char **argv)
int stty_state;
int k;
INIT_G();
stty_state = STTY_noargs;
output_func = do_display;
@@ -1086,8 +1295,8 @@ int stty_main(int argc, char **argv)
/* Now it is safe to start doing things */
if (file_name) {
int fd, fdflags;
device_name = file_name;
fd = xopen(device_name, O_RDONLY | O_NONBLOCK);
G.device_name = file_name;
fd = xopen(G.device_name, O_RDONLY | O_NONBLOCK);
if (fd != STDIN_FILENO) {
dup2(fd, STDIN_FILENO);
close(fd);
@@ -1105,7 +1314,7 @@ int stty_main(int argc, char **argv)
perror_on_device_and_die("%s");
if (stty_state & (STTY_verbose_output | STTY_recoverable_output | STTY_noargs)) {
get_terminal_width_height(STDOUT_FILENO, &max_col, NULL);
get_terminal_width_height(STDOUT_FILENO, &G.max_col, NULL);
output_func(&mode, display_all);
return EXIT_SUCCESS;
}
+13 -14
View File
@@ -21,20 +21,17 @@ enum { SUM_BSD, PRINT_NAME, SUM_SYSV };
The checksum varies depending on sizeof (int). */
/* SYSV: calculate and print the checksum and the size in 512-byte blocks */
/* Return 1 if successful. */
static unsigned sum_file(const char *file, const unsigned type)
static unsigned sum_file(const char *file, unsigned type)
{
#define buf bb_common_bufsiz1
unsigned long long total_bytes = 0;
int fd = 0, r;
int fd, r;
/* The sum of all the input bytes, modulo (UINT_MAX + 1). */
unsigned s = 0;
if (NOT_LONE_DASH(file)) {
fd = open(file, O_RDONLY);
if (fd == -1)
goto ret_bad;
}
fd = open_or_warn_stdin(file);
if (fd == -1)
return 0;
while (1) {
size_t bytes_read = safe_read(fd, buf, BUFSIZ);
@@ -44,7 +41,6 @@ static unsigned sum_file(const char *file, const unsigned type)
if (!bytes_read && !r)
/* no error */
break;
ret_bad:
bb_perror_msg(file);
return 0;
}
@@ -75,26 +71,29 @@ static unsigned sum_file(const char *file, const unsigned type)
}
int sum_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int sum_main(int argc, char **argv)
int sum_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
unsigned n;
unsigned type = SUM_BSD;
n = getopt32(argv, "sr");
argv += optind;
if (n & 1) type = SUM_SYSV;
/* give the bsd priority over sysv func */
if (n & 2) type = SUM_BSD;
if (argc == optind) {
if (!argv[0]) {
/* Do not print the name */
n = sum_file("-", type);
} else {
/* Need to print the name if either
- more than one file given
- doing sysv */
type += argc - 1 > optind || type == SUM_SYSV;
for (n = 1; optind < argc; optind++)
n &= sum_file(argv[optind], type);
type += (argv[1] || type == SUM_SYSV);
n = 1;
do {
n &= sum_file(*argv, type);
} while (*++argv);
}
return !n;
}
+2 -1
View File
@@ -14,8 +14,9 @@
/* This is a NOFORK applet. Be very careful! */
int sync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int sync_main(int argc, char **argv)
int sync_main(int argc, char **argv ATTRIBUTE_UNUSED)
{
/* coreutils-6.9 compat */
bb_warn_ignoring_args(argc - 1);
sync();
+106
View File
@@ -0,0 +1,106 @@
/* vi: set sw=4 ts=4: */
/*
* tac implementation for busybox
*
* Copyright (C) 2003 Yang Xiaopeng <yxp at hanwang.com.cn>
* Copyright (C) 2007 Natanael Copa <natanael.copa@gmail.com>
* Copyright (C) 2007 Tito Ragusa <farmatito@tiscali.it>
*
* Licensed under GPLv2, see file License in this tarball for details.
*
*/
/* tac - concatenate and print files in reverse */
/* Based on Yang Xiaopeng's (yxp at hanwang.com.cn) patch
* http://www.uclibc.org/lists/busybox/2003-July/008813.html
*/
#include "libbb.h"
/* This is a NOEXEC applet. Be very careful! */
struct lstring {
int size;
char buf[1];
};
int tac_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int tac_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
char **name;
FILE *f;
struct lstring *line = NULL;
llist_t *list = NULL;
int retval = EXIT_SUCCESS;
#if ENABLE_DESKTOP
/* tac from coreutils 6.9 supports:
-b, --before
attach the separator before instead of after
-r, --regex
interpret the separator as a regular expression
-s, --separator=STRING
use STRING as the separator instead of newline
We support none, but at least we will complain or handle "--":
*/
getopt32(argv, "");
argv += optind;
#else
argv++;
#endif
if (!*argv)
*--argv = (char *)"-";
/* We will read from last file to first */
name = argv;
while (*name)
name++;
do {
int ch, i;
name--;
f = fopen_or_warn_stdin(*name);
if (f == NULL) {
/* error message is printed by fopen_or_warn_stdin */
retval = EXIT_FAILURE;
continue;
}
errno = i = 0;
do {
ch = fgetc(f);
if (ch != EOF) {
if (!(i & 0x7f))
/* Grow on every 128th char */
line = xrealloc(line, i + 0x7f + sizeof(int) + 1);
line->buf[i++] = ch;
}
if (ch == '\n' || (ch == EOF && i != 0)) {
line = xrealloc(line, i + sizeof(int));
line->size = i;
llist_add_to(&list, line);
line = NULL;
i = 0;
}
} while (ch != EOF);
/* fgetc sets errno to ENOENT on EOF, we don't want
* to warn on this non-error! */
if (errno && errno != ENOENT) {
bb_simple_perror_msg(*name);
retval = EXIT_FAILURE;
}
} while (name != argv);
while (list) {
line = (struct lstring *)list->data;
xwrite(STDOUT_FILENO, line->buf, line->size);
if (ENABLE_FEATURE_CLEAN_UP) {
free(llist_pop(&list));
} else {
list = list->link;
}
}
return retval;
}
+50 -54
View File
@@ -74,7 +74,7 @@ static unsigned eat_num(const char *p)
p++;
else if (*p == '+') {
p++;
G.status = EXIT_FAILURE;
G.status = 1; /* mark that we saw "+" */
}
return xatou_sfx(p, tail_suffixes);
}
@@ -87,12 +87,11 @@ int tail_main(int argc, char **argv)
bool from_top;
int header_threshhold = 1;
const char *str_c, *str_n;
USE_FEATURE_FANCY_TAIL(const char *str_s;)
char *tailbuf;
size_t tailbufsize;
int taillen = 0;
int newline = 0;
int newlines_seen = 0;
int nfiles, nread, nwrite, seen, i, opt;
int *fds;
@@ -101,21 +100,18 @@ int tail_main(int argc, char **argv)
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_TAIL
/* Allow legacy syntax of an initial numeric option without -n. */
if (argc >= 2 && (argv[1][0] == '+' || argv[1][0] == '-')
if (argv[1] && (argv[1][0] == '+' || argv[1][0] == '-')
&& isdigit(argv[1][1])
) {
/* replacing arg[0] with "-n" can segfault, so... */
argv[1] = xasprintf("-n%s", argv[1]);
#if 0 /* If we ever decide to make tail NOFORK */
char *s = alloca(strlen(argv[1]) + 3);
sprintf(s, "-n%s", argv[1]);
argv[1] = s;
#endif
count = eat_num(&argv[1][1]);
argv++;
argc--;
}
#endif
USE_FEATURE_FANCY_TAIL(opt_complementary = "s+";) /* -s N */
opt = getopt32(argv, "fc:n:" USE_FEATURE_FANCY_TAIL("qs:v"),
&str_c, &str_n USE_FEATURE_FANCY_TAIL(,&str_s));
&str_c, &str_n USE_FEATURE_FANCY_TAIL(,&sleep_period));
#define FOLLOW (opt & 0x1)
#define COUNT_BYTES (opt & 0x2)
//if (opt & 0x1) // -f
@@ -123,18 +119,16 @@ int tail_main(int argc, char **argv)
if (opt & 0x4) count = eat_num(str_n); // -n
#if ENABLE_FEATURE_FANCY_TAIL
if (opt & 0x8) header_threshhold = INT_MAX; // -q
if (opt & 0x10) sleep_period = xatou(str_s); // -s
if (opt & 0x20) header_threshhold = 0; // -v
#endif
argc -= optind;
argv += optind;
from_top = G.status;
from_top = G.status; /* 1 if there was "-c +N" or "-n +N" */
G.status = EXIT_SUCCESS;
/* open all the files */
fds = xmalloc(sizeof(int) * (argc + 1));
nfiles = i = 0;
G.status = EXIT_SUCCESS;
if (argc == 0) {
if (!argv[0]) {
struct stat statbuf;
if (!fstat(STDIN_FILENO, &statbuf) && S_ISFIFO(statbuf.st_mode)) {
@@ -142,52 +136,59 @@ int tail_main(int argc, char **argv)
}
*argv = (char *) bb_msg_standard_input;
}
nfiles = i = 0;
do {
FILE* fil = fopen_or_warn_stdin(argv[i]);
if (!fil) {
int fd = open_or_warn_stdin(argv[i]);
if (fd < 0) {
G.status = EXIT_FAILURE;
continue;
}
fds[nfiles] = fileno(fil);
fds[nfiles] = fd;
argv[nfiles++] = argv[i];
} while (++i < argc);
if (!nfiles)
bb_error_msg_and_die("no files");
/* prepare the buffer */
tailbufsize = BUFSIZ;
/* tail the files */
if (!from_top && COUNT_BYTES) {
if (tailbufsize < count) {
if (tailbufsize < count + BUFSIZ) {
tailbufsize = count + BUFSIZ;
}
}
tailbuf = xmalloc(tailbufsize);
buf = tailbuf = xmalloc(tailbufsize);
/* tail the files */
fmt = header_fmt + 1; /* Skip header leading newline on first output. */
i = 0;
do {
/* Be careful. It would be possible to optimize the count-bytes
* case if the file is seekable. If you do though, remember that
* starting file position may not be the beginning of the file.
* Beware of backing up too far. See example in wc.c.
*/
if (!(count | from_top) && lseek(fds[i], 0, SEEK_END) >= 0) {
continue;
}
if (nfiles > header_threshhold) {
tail_xprint_header(fmt, argv[i]);
fmt = header_fmt;
}
/* Optimizing count-bytes case if the file is seekable.
* Beware of backing up too far.
* Also we exclude files with size 0 (because of /proc/xxx) */
if (COUNT_BYTES && !from_top) {
off_t current = lseek(fds[i], 0, SEEK_END);
if (current > 0) {
if (count == 0)
continue; /* showing zero lines is easy :) */
current -= count;
if (current < 0)
current = 0;
xlseek(fds[i], current, SEEK_SET);
bb_copyfd_size(fds[i], STDOUT_FILENO, count);
continue;
}
}
buf = tailbuf;
taillen = 0;
seen = 1;
newline = 0;
newlines_seen = 0;
while ((nread = tail_read(fds[i], buf, tailbufsize-taillen)) > 0) {
if (from_top) {
nwrite = nread;
@@ -215,34 +216,32 @@ int tail_main(int argc, char **argv)
}
} else {
int k = nread;
int nbuf = 0;
int newlines_in_buf = 0;
while (k) {
--k;
do { /* count '\n' in last read */
k--;
if (buf[k] == '\n') {
++nbuf;
newlines_in_buf++;
}
}
} while (k);
if (newline + nbuf < count) {
newline += nbuf;
if (newlines_seen + newlines_in_buf < count) {
newlines_seen += newlines_in_buf;
taillen += nread;
} else {
int extra = 0;
int extra = (buf[nread-1] != '\n');
if (buf[nread-1] != '\n')
extra = 1;
k = newline + nbuf + extra - count;
k = newlines_seen + newlines_in_buf + extra - count;
s = tailbuf;
while (k) {
if (*s == '\n') {
--k;
k--;
}
++s;
s++;
}
taillen += nread - (s - tailbuf);
memmove(tailbuf, s, taillen);
newline = count - extra;
newlines_seen = count - extra;
}
if (tailbufsize < taillen + BUFSIZ) {
tailbufsize = taillen + BUFSIZ;
@@ -251,13 +250,10 @@ int tail_main(int argc, char **argv)
}
buf = tailbuf + taillen;
}
}
} /* while (tail_read() > 0) */
if (!from_top) {
xwrite(STDOUT_FILENO, tailbuf, taillen);
}
taillen = 0;
} while (++i < nfiles);
buf = xrealloc(tailbuf, BUFSIZ);
+2 -2
View File
@@ -36,12 +36,12 @@ int tee_main(int argc, char **argv)
mode += (retval & 2); /* Since 'a' is the 2nd option... */
if (retval & 1) {
signal(SIGINT, SIG_IGN); /* TODO - switch to sigaction. */
signal(SIGINT, SIG_IGN); /* TODO - switch to sigaction. (why?) */
}
retval = EXIT_SUCCESS;
/* gnu tee ignores SIGPIPE in case one of the output files is a pipe
* that doesn't consume all its input. Good idea... */
signal(SIGPIPE, SIG_IGN); /* TODO - switch to sigaction. */
signal(SIGPIPE, SIG_IGN);
/* Allocate an array of FILE *'s, with one extra for a sentinal. */
fp = files = xzalloc(sizeof(FILE *) * (argc + 2));
+315 -276
View File
@@ -23,7 +23,11 @@
#include "libbb.h"
#include <setjmp.h>
/* This is a NOEXEC applet. Be very careful! */
/* This is a NOFORK applet. Be very careful! */
/* test_main() is called from shells, and we need to be extra careful here.
* This is true regardless of PREFER_APPLETS and STANDALONE_SHELL
* state. */
/* test(1) accepts the following grammar:
@@ -85,12 +89,12 @@ enum token {
RPAREN,
OPERAND
};
#define is_int_op(a) (((unsigned char)((a) - INTEQ)) <= 5)
#define is_str_op(a) (((unsigned char)((a) - STREZ)) <= 5)
#define is_file_op(a) (((unsigned char)((a) - FILNT)) <= 2)
#define is_int_op(a) (((unsigned char)((a) - INTEQ)) <= 5)
#define is_str_op(a) (((unsigned char)((a) - STREZ)) <= 5)
#define is_file_op(a) (((unsigned char)((a) - FILNT)) <= 2)
#define is_file_access(a) (((unsigned char)((a) - FILRD)) <= 2)
#define is_file_type(a) (((unsigned char)((a) - FILREG)) <= 5)
#define is_file_bit(a) (((unsigned char)((a) - FILSUID)) <= 2)
#define is_file_type(a) (((unsigned char)((a) - FILREG)) <= 5)
#define is_file_bit(a) (((unsigned char)((a) - FILSUID)) <= 2)
enum token_types {
UNOP,
BINOP,
@@ -153,98 +157,36 @@ typedef int64_t arith_t;
typedef int arith_t;
#endif
/* Cannot eliminate these static data (do the G trick)
* because of test_main usage from other applets */
static char **t_wp;
static const struct t_op *t_wp_op;
static gid_t *group_array;
static int ngroups;
static jmp_buf leaving;
static enum token t_lex(char *s);
static arith_t oexpr(enum token n);
static arith_t aexpr(enum token n);
static arith_t nexpr(enum token n);
static int binop(void);
/* We try to minimize both static and stack usage. */
struct statics {
char **t_wp;
const struct t_op *t_wp_op;
gid_t *group_array;
int ngroups;
jmp_buf leaving;
};
/* Make it reside in writable memory, yet make compiler understand
* that it is not going to change. */
static struct statics *const ptr_to_statics __attribute__ ((section (".data")));
#define S (*ptr_to_statics)
#define t_wp (S.t_wp )
#define t_wp_op (S.t_wp_op )
#define group_array (S.group_array )
#define ngroups (S.ngroups )
#define leaving (S.leaving )
#define INIT_S() do { \
(*(struct statics**)&ptr_to_statics) = xzalloc(sizeof(S)); \
barrier(); \
} while (0)
#define DEINIT_S() do { \
free(ptr_to_statics); \
} while (0)
static arith_t primary(enum token n);
static int filstat(char *nm, enum token mode);
static arith_t getn(const char *s);
/* UNUSED
static int newerf(const char *f1, const char *f2);
static int olderf(const char *f1, const char *f2);
static int equalf(const char *f1, const char *f2);
*/
static int test_eaccess(char *path, int mode);
static int is_a_group_member(gid_t gid);
static void initialize_group_array(void);
int test_main(int argc, char **argv)
{
int res;
const char *arg0;
bool _off;
arg0 = bb_basename(argv[0]);
if (arg0[0] == '[') {
--argc;
if (!arg0[1]) { /* "[" ? */
if (NOT_LONE_CHAR(argv[argc], ']')) {
bb_error_msg("missing ]");
return 2;
}
} else { /* assuming "[[" */
if (strcmp(argv[argc], "]]") != 0) {
bb_error_msg("missing ]]");
return 2;
}
}
argv[argc] = NULL;
}
res = setjmp(leaving);
if (res)
return res;
/* resetting ngroups is probably unnecessary. it will
* force a new call to getgroups(), which prevents using
* group data fetched during a previous call. but the
* only way the group data could be stale is if there's
* been an intervening call to setgroups(), and this
* isn't likely in the case of a shell. paranoia
* prevails...
*/
ngroups = 0;
/* Implement special cases from POSIX.2, section 4.62.4 */
if (argc == 1)
return 1;
if (argc == 2)
return *argv[1] == '\0';
//assert(argc);
/* remember if we saw argc==4 which wants *no* '!' test */
_off = argc - 4;
if (_off ?
(LONE_CHAR(argv[1], '!'))
: (argv[1][0] != '!' || argv[1][1] != '\0'))
{
if (argc == 3)
return *argv[2] != '\0';
t_lex(argv[2 + _off]);
if (t_wp_op && t_wp_op->op_type == BINOP) {
t_wp = &argv[1 + _off];
return binop() == _off;
}
}
t_wp = &argv[1];
res = !oexpr(t_lex(*t_wp));
if (*t_wp != NULL && *++t_wp != NULL) {
bb_error_msg("%s: unknown operand", *t_wp);
return 2;
}
return res;
}
static void syntax(const char *op, const char *msg) ATTRIBUTE_NORETURN;
static void syntax(const char *op, const char *msg)
@@ -257,69 +199,82 @@ static void syntax(const char *op, const char *msg)
longjmp(leaving, 2);
}
static arith_t oexpr(enum token n)
/* atoi with error detection */
//XXX: FIXME: duplicate of existing libbb function?
static arith_t getn(const char *s)
{
arith_t res;
char *p;
#if ENABLE_FEATURE_TEST_64
long long r;
#else
long r;
#endif
res = aexpr(n);
if (t_lex(*++t_wp) == BOR) {
return oexpr(t_lex(*++t_wp)) || res;
}
t_wp--;
return res;
errno = 0;
#if ENABLE_FEATURE_TEST_64
r = strtoll(s, &p, 10);
#else
r = strtol(s, &p, 10);
#endif
if (errno != 0)
syntax(s, "out of range");
if (*(skip_whitespace(p)))
syntax(s, "bad number");
return r;
}
static arith_t aexpr(enum token n)
/* UNUSED
static int newerf(const char *f1, const char *f2)
{
arith_t res;
struct stat b1, b2;
res = nexpr(n);
if (t_lex(*++t_wp) == BAND)
return aexpr(t_lex(*++t_wp)) && res;
t_wp--;
return res;
return (stat(f1, &b1) == 0 &&
stat(f2, &b2) == 0 && b1.st_mtime > b2.st_mtime);
}
static arith_t nexpr(enum token n)
static int olderf(const char *f1, const char *f2)
{
if (n == UNOT)
return !nexpr(t_lex(*++t_wp));
return primary(n);
struct stat b1, b2;
return (stat(f1, &b1) == 0 &&
stat(f2, &b2) == 0 && b1.st_mtime < b2.st_mtime);
}
static arith_t primary(enum token n)
static int equalf(const char *f1, const char *f2)
{
arith_t res;
struct stat b1, b2;
if (n == EOI) {
syntax(NULL, "argument expected");
}
if (n == LPAREN) {
res = oexpr(t_lex(*++t_wp));
if (t_lex(*++t_wp) != RPAREN)
syntax(NULL, "closing paren expected");
return res;
}
if (t_wp_op && t_wp_op->op_type == UNOP) {
/* unary expression */
if (*++t_wp == NULL)
syntax(t_wp_op->op_text, "argument expected");
if (n == STREZ)
return t_wp[0][0] == '\0';
if (n == STRNZ)
return t_wp[0][0] != '\0';
if (n == FILTT)
return isatty(getn(*t_wp));
return filstat(*t_wp, n);
}
t_lex(t_wp[1]);
if (t_wp_op && t_wp_op->op_type == BINOP) {
return binop();
}
return t_wp[0][0] != '\0';
return (stat(f1, &b1) == 0 &&
stat(f2, &b2) == 0 &&
b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino);
}
*/
static enum token t_lex(char *s)
{
const struct t_op *op;
t_wp_op = NULL;
if (s == NULL) {
return EOI;
}
op = ops;
do {
if (strcmp(s, op->op_text) == 0) {
t_wp_op = op;
return op->op_num;
}
op++;
} while (op < ops + ARRAY_SIZE(ops));
return OPERAND;
}
static int binop(void)
{
@@ -381,6 +336,80 @@ static int binop(void)
return 1; /* NOTREACHED */
}
static void initialize_group_array(void)
{
ngroups = getgroups(0, NULL);
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 test_main can be entered repeatedly by shell.
* Testcase (ash): 'while true; do test -x some_file; done'
* and watch top. (some_file must have owner != you) */
group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
getgroups(ngroups, group_array);
}
}
/* Return non-zero if GID is one that we have in our groups list. */
//XXX: FIXME: duplicate of existing libbb function?
// see toplevel TODO file:
// possible code duplication ingroup() and is_a_group_member()
static int is_a_group_member(gid_t gid)
{
int i;
/* Short-circuit if possible, maybe saving a call to getgroups(). */
if (gid == getgid() || gid == getegid())
return 1;
if (ngroups == 0)
initialize_group_array();
/* Search through the list looking for GID. */
for (i = 0; i < ngroups; i++)
if (gid == group_array[i])
return 1;
return 0;
}
/* Do the same thing access(2) does, but use the effective uid and gid,
and don't make the mistake of telling root that any file is
executable. */
static int test_eaccess(char *path, int mode)
{
struct stat st;
unsigned int euid = geteuid();
if (stat(path, &st) < 0)
return -1;
if (euid == 0) {
/* Root can read or write any file. */
if (mode != X_OK)
return 0;
/* Root can execute any file that has any one of the execute
bits set. */
if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
return 0;
}
if (st.st_uid == euid) /* owner */
mode <<= 6;
else if (is_a_group_member(st.st_gid))
mode <<= 3;
if (st.st_mode & mode)
return 0;
return -1;
}
static int filstat(char *nm, enum token mode)
{
struct stat s;
@@ -453,147 +482,157 @@ static int filstat(char *nm, enum token mode)
return 1; /* NOTREACHED */
}
static enum token t_lex(char *s)
{
const struct t_op *op;
t_wp_op = NULL;
if (s == NULL) {
return EOI;
static arith_t nexpr(enum token n)
{
if (n == UNOT)
return !nexpr(t_lex(*++t_wp));
return primary(n);
}
static arith_t aexpr(enum token n)
{
arith_t res;
res = nexpr(n);
if (t_lex(*++t_wp) == BAND)
return aexpr(t_lex(*++t_wp)) && res;
t_wp--;
return res;
}
static arith_t oexpr(enum token n)
{
arith_t res;
res = aexpr(n);
if (t_lex(*++t_wp) == BOR) {
return oexpr(t_lex(*++t_wp)) || res;
}
t_wp--;
return res;
}
static arith_t primary(enum token n)
{
arith_t res;
if (n == EOI) {
syntax(NULL, "argument expected");
}
if (n == LPAREN) {
res = oexpr(t_lex(*++t_wp));
if (t_lex(*++t_wp) != RPAREN)
syntax(NULL, "closing paren expected");
return res;
}
if (t_wp_op && t_wp_op->op_type == UNOP) {
/* unary expression */
if (*++t_wp == NULL)
syntax(t_wp_op->op_text, "argument expected");
if (n == STREZ)
return t_wp[0][0] == '\0';
if (n == STRNZ)
return t_wp[0][0] != '\0';
if (n == FILTT)
return isatty(getn(*t_wp));
return filstat(*t_wp, n);
}
op = ops;
do {
if (strcmp(s, op->op_text) == 0) {
t_wp_op = op;
return op->op_num;
t_lex(t_wp[1]);
if (t_wp_op && t_wp_op->op_type == BINOP) {
return binop();
}
return t_wp[0][0] != '\0';
}
int test_main(int argc, char **argv)
{
int res;
const char *arg0;
bool negate = 0;
arg0 = bb_basename(argv[0]);
if (arg0[0] == '[') {
--argc;
if (!arg0[1]) { /* "[" ? */
if (NOT_LONE_CHAR(argv[argc], ']')) {
bb_error_msg("missing ]");
return 2;
}
} else { /* assuming "[[" */
if (strcmp(argv[argc], "]]") != 0) {
bb_error_msg("missing ]]");
return 2;
}
}
op++;
} while (op < ops + ARRAY_SIZE(ops));
return OPERAND;
}
/* atoi with error detection */
//XXX: FIXME: duplicate of existing libbb function?
static arith_t getn(const char *s)
{
char *p;
#if ENABLE_FEATURE_TEST_64
long long r;
#else
long r;
#endif
errno = 0;
#if ENABLE_FEATURE_TEST_64
r = strtoll(s, &p, 10);
#else
r = strtol(s, &p, 10);
#endif
if (errno != 0)
syntax(s, "out of range");
if (*(skip_whitespace(p)))
syntax(s, "bad number");
return r;
}
/* UNUSED
static int newerf(const char *f1, const char *f2)
{
struct stat b1, b2;
return (stat(f1, &b1) == 0 &&
stat(f2, &b2) == 0 && b1.st_mtime > b2.st_mtime);
}
static int olderf(const char *f1, const char *f2)
{
struct stat b1, b2;
return (stat(f1, &b1) == 0 &&
stat(f2, &b2) == 0 && b1.st_mtime < b2.st_mtime);
}
static int equalf(const char *f1, const char *f2)
{
struct stat b1, b2;
return (stat(f1, &b1) == 0 &&
stat(f2, &b2) == 0 &&
b1.st_dev == b2.st_dev && b1.st_ino == b2.st_ino);
}
*/
/* Do the same thing access(2) does, but use the effective uid and gid,
and don't make the mistake of telling root that any file is
executable. */
static int test_eaccess(char *path, int mode)
{
struct stat st;
unsigned int euid = geteuid();
if (stat(path, &st) < 0)
return -1;
if (euid == 0) {
/* Root can read or write any file. */
if (mode != X_OK)
return 0;
/* Root can execute any file that has any one of the execute
bits set. */
if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
return 0;
argv[argc] = NULL;
}
if (st.st_uid == euid) /* owner */
mode <<= 6;
else if (is_a_group_member(st.st_gid))
mode <<= 3;
/* We must do DEINIT_S() prior to returning */
INIT_S();
if (st.st_mode & mode)
return 0;
res = setjmp(leaving);
if (res)
goto ret;
return -1;
}
/* resetting ngroups is probably unnecessary. it will
* force a new call to getgroups(), which prevents using
* group data fetched during a previous call. but the
* only way the group data could be stale is if there's
* been an intervening call to setgroups(), and this
* isn't likely in the case of a shell. paranoia
* prevails...
*/
ngroups = 0;
static void initialize_group_array(void)
{
ngroups = getgroups(0, NULL);
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 test_main can be entered repeatedly by shell.
* Testcase (ash): 'while true; do test -x some_file; done'
* and watch top. (some_file must have owner != you) */
group_array = xrealloc(group_array, ngroups * sizeof(gid_t));
getgroups(ngroups, group_array);
//argc--;
argv++;
/* Implement special cases from POSIX.2, section 4.62.4 */
if (!argv[0]) { /* "test" */
res = 1;
goto ret;
}
if (LONE_CHAR(argv[0], '!') && argv[1]) {
negate = 1;
//argc--;
argv++;
}
if (!argv[1]) { /* "test [!] arg" */
res = (*argv[0] == '\0');
goto ret;
}
if (argv[2] && !argv[3]) {
t_lex(argv[1]);
if (t_wp_op && t_wp_op->op_type == BINOP) {
/* "test [!] arg1 <binary_op> arg2" */
t_wp = &argv[0];
res = (binop() == 0);
goto ret;
}
}
}
/* Return non-zero if GID is one that we have in our groups list. */
//XXX: FIXME: duplicate of existing libbb function?
// see toplevel TODO file:
// possible code duplication ingroup() and is_a_group_member()
static int is_a_group_member(gid_t gid)
{
int i;
/* Some complex expression. Undo '!' removal */
if (negate) {
negate = 0;
//argc++;
argv--;
}
t_wp = &argv[0];
res = !oexpr(t_lex(*t_wp));
/* Short-circuit if possible, maybe saving a call to getgroups(). */
if (gid == getgid() || gid == getegid())
return 1;
if (ngroups == 0)
initialize_group_array();
/* Search through the list looking for GID. */
for (i = 0; i < ngroups; i++)
if (gid == group_array[i])
return 1;
return 0;
if (*t_wp != NULL && *++t_wp != NULL) {
bb_error_msg("%s: unknown operand", *t_wp);
res = 2;
}
ret:
DEINIT_S();
return negate ? !res : res;
}
+3 -2
View File
@@ -22,12 +22,13 @@
/* This is a NOFORK applet. Be very careful! */
int touch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int touch_main(int argc, char **argv)
int touch_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
int fd;
int status = EXIT_SUCCESS;
int flags = getopt32(argv, "c");
int flags = getopt32(argv, "cf");
flags &= 1; /* ignoring -f (BSD compat thingy) */
argv += optind;
if (!*argv) {
+80 -77
View File
@@ -22,10 +22,6 @@
#define ASCII 0377
#define TR_OPT_complement (1<<0)
#define TR_OPT_delete (1<<1)
#define TR_OPT_squeeze_reps (1<<2)
static void map(char *pvector,
unsigned char *string1, unsigned int string1_len,
unsigned char *string2, unsigned int string2_len)
@@ -42,19 +38,46 @@ static void map(char *pvector,
}
/* supported constructs:
* Ranges, e.g., [0-9] ==> 0123456789
* Escapes, e.g., \a ==> Control-G
* Character classes, e.g. [:upper:] ==> A ... Z
* Ranges, e.g., 0-9 ==> 0123456789
* Ranges, e.g., [0-9] ==> 0123456789
* Escapes, e.g., \a ==> Control-G
* Character classes, e.g. [:upper:] ==> A...Z
* Equiv classess, e.g. [=A=] ==> A (hmmmmmmm?)
*/
static unsigned int expand(const char *arg, char *buffer)
{
char *buffer_start = buffer;
unsigned i; /* XXX: FIXME: use unsigned char? */
unsigned i; /* can't be unsigned char: must be able to hold 256 */
unsigned char ac;
while (*arg) {
if (*arg == '\\') {
arg++;
*buffer++ = bb_process_escape_sequence(&arg);
continue;
}
if (arg[1] == '-') { /* "0-9..." */
ac = arg[2];
if (ac == '\0') { /* "0-": copy verbatim */
*buffer++ = *arg++; /* copy '0' */
continue; /* next iter will copy '-' and stop */
}
i = *arg;
while (i <= ac) /* ok: i is unsigned _int_ */
*buffer++ = i++;
arg += 3; /* skip 0-9 */
continue;
}
if (*arg == '[') { /* "[xyz..." */
arg++;
i = *arg++;
/* "[xyz...", i=x, arg points to y */
if (ENABLE_FEATURE_TR_CLASSES && i == ':') {
#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;
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
@@ -68,27 +91,9 @@ static unsigned int expand(const char *arg, char *buffer)
//#define CLASS_xdigit 10
//#define CLASS_graph 11
//#define CLASS_print 12
while (*arg) {
if (*arg == '\\') {
arg++;
*buffer++ = bb_process_escape_sequence(&arg);
} else if (*(arg+1) == '-') {
ac = *(arg+2);
if (ac == 0) {
*buffer++ = *arg++;
continue;
}
i = *arg;
while (i <= ac)
*buffer++ = i++;
arg += 3; /* Skip the assumed a-z */
} else if (*arg == '[') {
arg++;
i = *arg++;
if (ENABLE_FEATURE_TR_CLASSES && i == ':') {
smalluint j;
{ /* not really pretty.. */
char *tmp = xstrndup(arg, 7); // warning: xdigit needs 8, not 7
char *tmp = xstrndup(arg, 7); // warning: xdigit would need 8, not 7
j = index_in_strings(classes, tmp) + 1;
free(tmp);
}
@@ -115,10 +120,9 @@ static unsigned int expand(const char *arg, char *buffer)
*buffer++ = ' ';
}
if (j == CLASS_punct || j == CLASS_cntrl) {
for (i = 0; i <= ASCII; i++)
if ((j == CLASS_punct &&
isprint(i) && (!isalnum(i)) && (!isspace(i))) ||
(j == CLASS_cntrl && iscntrl(i)))
for (i = '\0'; i <= ASCII; i++)
if ((j == CLASS_punct && isprint(i) && !isalnum(i) && !isspace(i))
|| (j == CLASS_cntrl && iscntrl(i)))
*buffer++ = i;
}
if (j == CLASS_invalid) {
@@ -128,22 +132,26 @@ static unsigned int expand(const char *arg, char *buffer)
}
break;
}
if (ENABLE_FEATURE_TR_EQUIV && i == '=') {
*buffer++ = *arg;
arg += 3; /* Skip the closing =] */
/* "[xyz...", i=x, arg points to y */
if (ENABLE_FEATURE_TR_EQUIV && i == '=') { /* [=CHAR=] */
*buffer++ = *arg; /* copy CHAR */
arg += 3; /* skip CHAR=] */
continue;
}
if (*arg++ != '-') {
if (*arg != '-') { /* not [x-...] - copy verbatim */
*buffer++ = '[';
arg -= 2;
continue;
arg--; /* points to x */
continue; /* copy all, including eventual ']' */
}
/* [x-y...] */
arg++;
ac = *arg++;
while (i <= ac)
*buffer++ = i++;
arg++; /* Skip the assumed ']' */
} else
*buffer++ = *arg++;
arg++; /* skip the assumed ']' */
continue;
}
*buffer++ = *arg++;
}
return (buffer - buffer_start);
}
@@ -154,7 +162,7 @@ static int complement(char *buffer, int buffer_len)
char conv[ASCII + 2];
ix = 0;
for (i = 0; i <= ASCII; i++) {
for (i = '\0'; i <= ASCII; i++) {
for (j = 0; j < buffer_len; j++)
if (buffer[j] == i)
break;
@@ -166,46 +174,41 @@ static int complement(char *buffer, int buffer_len)
}
int tr_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int tr_main(int argc, char **argv)
int tr_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
unsigned char *ptr;
int output_length = 0, input_length;
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);
smalluint flags;
ssize_t read_chars = 0;
size_t in_index = 0, out_index = 0;
unsigned last = UCHAR_MAX + 1; /* not equal to any char */
unsigned char coded, c;
unsigned char *output = xmalloc(BUFSIZ);
char *vector = xzalloc((ASCII+1) * 3);
char *invec = vector + (ASCII+1);
char *outvec = vector + (ASCII+1) * 2;
#define TR_OPT_complement (1 << 0)
#define TR_OPT_delete (1 << 1)
#define TR_OPT_squeeze_reps (1 << 2)
flags = getopt32(argv, "+cds"); /* '+': stop at first non-option */
argv += optind;
if (argc > 1 && argv[idx][0] == '-') {
for (ptr = (unsigned char *) &argv[idx][1]; *ptr; ptr++) {
if (*ptr == 'c')
flags |= TR_OPT_complement;
else if (*ptr == 'd')
flags |= TR_OPT_delete;
else if (*ptr == 's')
flags |= TR_OPT_squeeze_reps;
else
bb_show_usage();
}
idx++;
}
for (i = 0; i <= ASCII; i++) {
vector[i] = i;
invec[i] = outvec[i] = FALSE;
/*invec[i] = outvec[i] = FALSE; - done by xzalloc */
}
#define tr_buf bb_common_bufsiz1
if (argv[idx] != NULL) {
input_length = expand(argv[idx++], tr_buf);
if (*argv != NULL) {
input_length = expand(*argv++, tr_buf);
if (flags & TR_OPT_complement)
input_length = complement(tr_buf, input_length);
if (argv[idx] != NULL) {
if (*argv[idx] == '\0')
if (*argv) {
if (argv[0][0] == '\0')
bb_error_msg_and_die("STRING2 cannot be empty");
output_length = expand(argv[idx], output);
output_length = expand(*argv, output);
map(vector, tr_buf, input_length, output, output_length);
}
for (i = 0; i < input_length; i++)
@@ -221,10 +224,10 @@ int tr_main(int argc, char **argv)
xwrite(STDOUT_FILENO, (char *)output, out_index);
out_index = 0;
}
read_chars = read(STDIN_FILENO, tr_buf, BUFSIZ);
read_chars = safe_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);
if (read_chars < 0)
bb_perror_msg_and_die(bb_msg_read_error);
exit(EXIT_SUCCESS);
}
in_index = 0;
@@ -233,8 +236,8 @@ int tr_main(int argc, char **argv)
coded = vector[c];
if ((flags & TR_OPT_delete) && invec[c])
continue;
if ((flags & TR_OPT_squeeze_reps) && last == coded &&
(invec[c] || outvec[coded]))
if ((flags & TR_OPT_squeeze_reps) && last == coded
&& (invec[c] || outvec[coded]))
continue;
output[out_index++] = last = coded;
}
+1 -1
View File
@@ -15,7 +15,7 @@
/* This is a NOFORK applet. Be very careful! */
int true_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int true_main(int argc, char **argv)
int true_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
{
return EXIT_SUCCESS;
}
+5 -3
View File
@@ -13,7 +13,7 @@
#include "libbb.h"
int tty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int tty_main(int argc, char **argv)
int tty_main(int argc, char **argv SKIP_INCLUDE_SUSv2(ATTRIBUTE_UNUSED))
{
const char *s;
USE_INCLUDE_SUSv2(int silent;) /* Note: No longer relevant in SUSv3. */
@@ -22,15 +22,17 @@ int tty_main(int argc, char **argv)
xfunc_error_retval = 2; /* SUSv3 requires > 1 for error. */
USE_INCLUDE_SUSv2(silent = getopt32(argv, "s");)
USE_INCLUDE_SUSv2(argc -= optind;)
SKIP_INCLUDE_SUSv2(argc -= 1;)
/* gnu tty outputs a warning that it is ignoring all args. */
bb_warn_ignoring_args(argc - optind);
bb_warn_ignoring_args(argc);
retval = 0;
s = ttyname(0);
if (s == NULL) {
/* According to SUSv3, ttyname can on fail with EBADF or ENOTTY.
/* According to SUSv3, ttyname can fail with EBADF or ENOTTY.
* We know the file descriptor is good, so failure means not a tty. */
s = "not a tty";
retval = 1;
Loaded 100 of 513 files, more files were not shown because too many files have changed in this diff. Show more