Compare commits

...
199 Commits
Author SHA1 Message Date
Denys Vlasenko e73f3c1d3d Apply post-1.21.0 patches, bump version to 1.21.1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-06-29 17:00:22 +02:00
Denys Vlasenko 64406a92a0 Bump version to 1.21.0
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-21 08:51:23 +01:00
Denys Vlasenko 0cfba07fcd fix testsuite false positive
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-21 08:28:37 +01:00
Denys Vlasenko 4609f477c7 mdev: fix mode of dir1 in =dir1/dir2/file rule
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-21 01:22:12 +01:00
Denys Vlasenko 31dc8603ee ifconfig: do not accept "ifconfig eth0 up 1.2.3.4/17" (ip with mask). Closes 5786
function                                             old     new   delta
ifconfig_main                                       1221    1237     +16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-20 18:10:12 +01:00
Denys Vlasenko 2f5b5beb28 grep: fix grep -Fw not respecting the -w option. Closes 5792
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-20 16:57:19 +01:00
Denys Vlasenko 81fa999540 syslogd: do not segfault on parse error when using default config. Closes 5762
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-20 16:05:41 +01:00
Denys Vlasenko 2cfcc9e9d7 sha3: code shrink
function                                             old     new   delta
sha3_hash                                            155     101     -54

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-20 00:38:09 +01:00
Peter Korsgaard 9980707efc syslogd: convert dummy functions to statics and get rid of IF_FEATURE_* checks
As suggested by Mike. No bloat-o-meter difference, but a bit nicer to look at.
We cannot convert the call to log_to_shmem() as it checks for G.shbuf outside
the function, and G.shbuf is only available when IPC support is enabled.

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-18 19:46:47 +01:00
Denys Vlasenko 9daf33fc52 dc: code shrink
function                                             old     new   delta
stack_machine                                        103     101      -2
operators                                            176     168      -8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-18 13:30:13 +01:00
Denys Vlasenko 7c4b13e019 ash: revert wrong "fix" for an apparent memory leak. Closes 5822
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-17 13:02:27 +01:00
Denys Vlasenko 5d78355d5a code shrink
function                                             old     new   delta
applet_name_compare                                   36      31      -5
find_applet_by_name                                   43      25     -18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-17 11:02:43 +01:00
Denys Vlasenko 5ca853e5da fix a typo in config help text. Closes 5714
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-17 10:24:51 +01:00
Bernhard Reutner-Fischer 20c5e5a626 mount: fix -o user=foo mishandling, fix unc= generation, add prefixpath=
function                                             old     new   delta
singlemount                                         1019    1049     +30
packed_usage                                       29252   29257      +5
parse_mount_options                                  230     232      +2
mount_option_str                                     337     338      +1
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 38/0)               Total: 38 bytes

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-17 02:30:35 +01:00
Denys Vlasenko e4f0f26bad sha3: s/sha3_process_block76/sha3_process_block72/
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-16 12:23:23 +01:00
Denys Vlasenko 5368fe541c sha3: rename KeccakF->sha3_process_block76.
This brings the naming more in line with other hashes.
Pulled most statics and constants into it.
Also noticed that two byte arrays are 1 element too big.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-16 02:20:31 +01:00
Martin Santesson 406ea15e2c mount: add unc option to CIFS mount (needed for Linux 3.4+)
unc option for CIFS mount is mandatory after CIFS option parsing
was rewritten in Linux 3.4

Signed-off-by: Martin Santesson <martinsn@axis.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-16 00:47:19 +01:00
Denys Vlasenko 970aa6b5bd sha3: cache ctx->bytes_queued
function                                             old     new   delta
sha3_hash                                            171     155     -16

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 22:19:24 +01:00
Denys Vlasenko 8fb3ab528e sha3: remove two "small code" codepaths: I can't reproduce code size win on them anymore
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 22:07:48 +01:00
Denys Vlasenko 8e7312e12f sha3: tweak choice of a fast code path for 64-bit
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 21:50:41 +01:00
Denys Vlasenko 5b7f50f372 sha3: cosmetic tweaks to various names, comments. No logic changes.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 19:52:30 +01:00
Denys Vlasenko ac4100e103 sha3: code shrink
function                                             old     new   delta
KeccakF                                             1053    1078     +25
KeccakF_RoundConstants                               192      48    -144

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 16:27:39 +01:00
Denys Vlasenko a55df27936 sha3: code shrink
function                                             old     new   delta
KeccakF                                             1064    1053     -11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 15:22:30 +01:00
Denys Vlasenko 07a54e21dd sha3: another speedup for SHA3_SMALL=0 case
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 14:47:05 +01:00
Denys Vlasenko 6830ade6aa whitespace fixes. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 13:58:01 +01:00
Denys Vlasenko 30a8652fbf sha3: make size/speed optimization decision configurable
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-15 01:12:26 +01:00
Denys Vlasenko 60cb48ca50 whitespace cleanup. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 15:57:44 +01:00
Lauri Kasanen b8173b603f sha3sum: new applet
function                                             old     new   delta
KeccakF                                                -     496    +496
KeccakF_RoundConstants                                 -     192    +192
sha3_hash                                              -     171    +171
sha3_end                                               -      40     +40
hash_file                                            274     299     +25
KeccakF_RotationConstants                              -      25     +25
KeccakF_PiLane                                         -      25     +25
packed_usage                                       29213   29232     +19
sha3_begin                                             -      18     +18
KeccakF_Mod5                                           -      10     +10
applet_names                                        2445    2453      +8
applet_main                                         1420    1424      +4
applet_nameofs                                       710     712      +2
------------------------------------------------------------------------------
(add/remove: 8/0 grow/shrink: 9/7 up/down: 1049/-54)         Total: ~995 bytes

Signed-off-by: Lauri Kasanen <curaga@operamail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 05:20:50 +01:00
Paul Marks b7841cf7b9 ntpd: fix incorrect m_status field in outgoing packets. Closes 5120
When using busybox ntpd with an NTPv3 client and NTPv4 server (or vice
versa), the version numbers can be incorrectly ORed together, yielding
the bogus value of "NTPv7".  This makes ntpd unusable with clients
such as Chrony and Windows "Internet Time".

This patch avoids the version mangling, by copying only the Leap
Indicator bits from the server's status field.

Signed-off-by: Paul Marks <paul@pmarks.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 02:39:10 +01:00
Denys Vlasenko 90801dadfa Remove redundant 'config FEATURE_VOLUMEID_SQUASHFS'
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 02:24:27 +01:00
Sven-Göran Bergh 6928d9f049 volume_id: add squashfs detection
function                                             old     new   delta
volume_id_probe_squashfs                               -      74     +74
fs1                                                   12      16      +4

Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 02:21:41 +01:00
Denys Vlasenko 6967578728 whitespace fixes. no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 01:34:48 +01:00
Sven-Göran Bergh 5218515508 volume_id: uuid_format small code shrink
function                                             old     new   delta
volume_id_set_uuid                                   318     300     -18

Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 00:52:03 +01:00
Sven-Göran Bergh 07b419dbcb volume_id: display hfs[+] 128-bit UUID properly
Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 00:37:00 +01:00
Sven-Göran Bergh a58f7b7d2f blkid: add type display for hfsplus
Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2013-01-14 00:35:31 +01:00
Peter Korsgaard cd776cf967 syslogd: add option to log to Linux kernel printk buffer
Why invent our own shared memory circular buffer when the kernel has a
perfectly fine one already?

This can be used as a smaller/simpler alternative to the syslogd IPC support
(as IPC shmem/klogd/logread aren't needed), while also allowing centralised
logging of everything (kernel messages, userspace bootup and syslog)
when used together with ttyprintk.

Notice that kernel 3.5+ is needed to store syslog facility in printk buffer,
otherwise only the priority is stored.

bloat-o-meter compared to IPC+klogd+logread:
function                                             old     new   delta
get_linux_version_code                                 -      84     +84
lbb_prepare                                           25      90     +65
applet_nameofs                                         6       -      -6
static.stdout@@GLIBC_2                                 8       -      -8
applet_names                                          23       9     -14
bb_msg_standard_output                                16       -     -16
init_sem                                              18       -     -18
xatoull_range                                         19       -     -19
overlapping_strcpy                                    21       -     -21
init_data                                             56      32     -24
applet_main                                           24       -     -24
main                                                 124      99     -25
full_write2_str                                       26       -     -26
error_exit                                            26       -     -26
bb_basename                                           30       -     -30
sem_up                                                32       -     -32
interrupted                                           35       -     -35
fflush_stdout_and_exit                                38       -     -38
bb_banner                                             46       -     -46
find_applet_by_name                                   59       -     -59
bb_signals_recursive_norestart                        90       -     -90
run_applet_no_and_exit                               104       -    -104
timestamp_and_log                                    651     523    -128
syslogd_main                                         798     581    -217
xstrtoull_range_sfx                                  267       -    -267
run_applet_and_exit                                  432       -    -432
klogd_main                                           490       -    -490
logread_main                                         508       -    -508
.rodata                                             1870     937    -933
bb_common_bufsiz1                                   8193       -   -8193
------------------------------------------------------------------------------
(add/remove: 2/26 grow/shrink: 1/6 up/down: 149/-11829)    Total: -11680 bytes

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-01-06 13:30:50 -05:00
Peter Korsgaard d189b598b4 klogd: handle multi-char log levels
Since Linux 3.5 (7ff9554bb5: printk: convert byte-buffer to variable-length
record buffer), klog buffer can now contain log lines with multi-char
loglevel indicators (<[0-9]+>) - So use strtoul to parse it.

function                                             old     new   delta
klogd_main                                           490     525     +35
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 35/0)               Total: 35 bytes

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-01-05 21:03:19 -05:00
Peter Korsgaard 3917fa32dc dmesg: handle multi-char log levels
Since Linux 3.5 (7ff9554bb5: printk: convert byte-buffer to variable-length
record buffer), klog buffer can now contain log lines with multi-char
loglevel indicators (<[0-9]+>) - So we can no longer just skip 3 bytes.

Instead skip past the terminating '>' like util-linux does.

function                                             old     new   delta
dmesg_main                                           266     280     +13
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 13/0)               Total: 13 bytes

Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-01-05 21:02:14 -05:00
Lauri Hintsala fb499c5752 powertop: fix error message
Application tries to use timer_stats module instead of cpufreq_stats.
Error message is printed if opening of the file /proc/timer_stats fails.

Signed-off-by: Lauri Hintsala <lauri.hintsala@bluegiga.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-01-04 17:45:44 -05:00
Mike Frysinger a38f9faa9f ifenslave: fix missing close paren
Reported-by: David J Cozatt <ygdrasil@comcast.net>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-12-26 17:12:26 -05:00
Anthony G. Basile 12677acf0a CONFIG_PID_FILE_PATH: new configuration option for pidfile paths
We set a default path for the directory where pidfiles are create
when FEATURE_PIDFILE is selected.  The default has no effect on
applets which must specify a pidfile path on the command line to
run, and it can be overridden by applets which optionally allow
the user to specify the pidfile path.

We also add pidfile write/remove support for klogd, ntpd and watchdog.
For syslogd, we add a missing remove_pidfile() for better cleanup
on daemon exit.

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-12-19 15:53:33 -05:00
Denys Vlasenko 393c395ca5 du: document incompatibility with standard tool
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-12-14 17:14:11 +01:00
Denys Vlasenko 4d5955e9ec decompress_uncompress: comment out a bigger chunk of debug code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-12-05 11:08:30 +01:00
Denys Vlasenko a8461173ba decompress_uncompress: comment out debug printout on corrupted data
99% plus of all people who'll get corrupted archive wouldn't bother
debugging it. The rest can uncomment the code.

function                                             old     new   delta
unpack_Z_stream                                     1304    1234     -70

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-12-05 01:06:05 +01:00
Denys Vlasenko c71547ccfc decompress_uncompress: move 'code' variable into loop - sole user
Apparently, gcc does this optimization itself, since generated code is the same.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-12-05 01:04:54 +01:00
Jon Tollefson 4ba6c5d3ba ash: fix a memory leak
The script which triggers the leak:

while true
  do
    while true
      do
        break;
    done</dev/null
done

Signed-off-by: Jon Tollefson <kniht@linux.vnet.ibm.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-11-13 19:26:53 +01:00
S-G Bergh e4b9451413 volume_id: add exFAT detection
function                                             old     new   delta
volume_id_probe_exfat                                  -     294    +294

Signed-off-by: S-G Bergh <sgb@systemasis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-11-13 14:40:37 +01:00
Denys Vlasenko 3f21044f20 ifupdown: code shrink
function                                             old     new   delta
execute                                              571     548     -23

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-11-09 17:16:40 +01:00
Denys Vlasenko a803bfa0f0 ifupdown: remove unused errno assignments
function                                             old     new   delta
execute                                              607     571     -36

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-11-05 14:18:36 +01:00
Denys Vlasenko 11181335f9 ifupdown: simple code shrink
function                                             old     new   delta
execute                                              631     607     -24

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-11-05 13:22:56 +01:00
S-G Bergh d2d5049c1d blkid: show filesystem when both label and UUID are missing, but type is known
Signed-off-by: S-G Bergh <sgb@systemasis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-11-05 13:16:07 +01:00
Mike Frysinger 5694afd72a build system: use pkg-config to look up selinux libs
Newer versions of libselinux has started linking against more libs.
Rather than continuing hardcoding things, switch to using pkg-config
to query for its dependencies.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-10-20 15:01:26 -04:00
Timo Teräs 67dc7b21ca fbsplash: fix regression from e4fa7b7
commit e4fa7b7 (limit progress bar flicker) made the progress bar
counter unsigned causing i < 0 to never come true.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-17 19:39:34 +02:00
Baruch Siach 3aeb870b22 nanddump: invert the meaning of the -o parameter to match upstream
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-15 14:32:23 +02:00
Baruch Siach 98f6b2d399 nanddump: skip bad blocks when instructed to do so
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-15 14:25:26 +02:00
Baruch Siach da0200a1e5 nanddump: use the right operator of logic AND
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-15 14:21:45 +02:00
Ron Yorston eab343e7e1 mktemp: fix mktemp -u temp.XXXXXX returning garbage when TMPDIR is set
Use mktemp instead of tempnam for compatibility with real mktemp.
Don't let mktemp fail silently, print some simple error messages.
Don't ignore -q.

Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-08 11:47:22 +02:00
Tito Ragusa 8dc6d1a813 adduser: make it accept "adduser USER GROUP" form
Signed-off-by: Tito Ragusa <farmatito@tiscali.it>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-08 11:18:08 +02:00
Denys Vlasenko fd77ea505e mark get_shell_name FAST_FUNC
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-03 09:42:21 +02:00
Denys Vlasenko 32711c4141 top/ps: argv0:"gdm-session-worker [pam/gdm-password]" == comm:"gdm-session-wor"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-02 11:31:37 +02:00
Denys Vlasenko d527588882 ash: implement export -n
function                                             old     new   delta
exportcmd                                            129     175     +46

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-10-01 13:41:17 +02:00
Nicolas Thill f47ce07b26 brctl: fix description and usage
brctl uncorrectly displays the "showmacs" command as being supported while
it is not, remove it from the usage and Config.src file.

Signed-off-by: Nicolas Thill <nico@openwrt.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-29 16:43:33 +02:00
Felix Fietkau 1c7a58dfb8 udhcpc[6]: allow discover_retries == 0 (infinite)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-27 16:22:24 +02:00
Manuel Zerpies d109798882 flashcp: remove unused variable opts
Signed-off-by: Manuel Zerpies <manuel.f.zerpies@ww.stud.uni-erlangen.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-27 16:06:34 +02:00
Denys Vlasenko b2320370be lineedit: in !EDITING config, return -1 on fgets error
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-27 16:03:49 +02:00
Denys Vlasenko 9371043698 fix unsafe bb_perror_msg(filename) calls
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-27 15:35:10 +02:00
Denys Vlasenko 225cc1327a scripts/kconfig/mconf: work on systems w/o SIGWINCH
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-27 15:26:40 +02:00
Denys Vlasenko c4f2d997a4 libbb: correctness/size tweaks in signal-related helpers
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-27 13:20:34 +02:00
Denys Vlasenko 73a1990897 top: do not touch stdin if -b
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-26 16:58:25 +02:00
Denys Vlasenko 06a98e32ae modprobe_small: make rmmod to NOT remove dependencies. Closes 5162
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-25 20:37:38 +02:00
Denys Vlasenko 0b4980c252 ash: trivial fixes for compile failures
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-25 12:49:29 +02:00
Denys Vlasenko ffe03f04cb top: fix build failure in !USE_TERMIOS case
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-25 12:48:46 +02:00
Denys Vlasenko 42be921d48 ps: fix build failure in !DESKTOP case
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-25 12:48:10 +02:00
Denys Vlasenko 2fb8d0dee9 top: implement scrolling up/down (_very_ useful)
function                                             old     new   delta
handle_input                                         494     564     +70
top_main                                             928     947     +19
display_topmem_process_list                          363     381     +18
display_process_list                                1442    1453     +11
clearmems                                             38      28     -10
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/1 up/down: 118/-10)           Total: 108 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-21 13:04:37 +02:00
Alexey Froloff 3c62bbae94 ushcpc: gracefully handle packets with CHECKSUM_PARTIAL
function                                             old     new   delta
udhcp_recv_raw_packet                                415     579    +164
change_listen_mode                                   317     370     +53
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/0 up/down: 217/0)             Total: 217 bytes

Signed-off-by: Alexey Froloff <raorn@raorn.name>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-17 16:02:44 +02:00
Denys Vlasenko 0ffd63ca9a telnet: convert Enter -> CR LF in line mode too
function                                             old     new   delta
handle_net_output                                     87      98     +11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-17 11:54:35 +02:00
Denys Vlasenko 57f07bfcb2 telnet: shrink literal string size
text	   data	    bss	    dec	    hex	filename
 888483	    497	   7584	 896564	  dae34	busybox_old
 888450	    497	   7584	 896531	  dae13	busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-17 11:53:09 +02:00
Denys Vlasenko aca464ddac telnet: convert CR -> CR LF, not CR -> CR NUL when sending data to server
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-13 13:00:49 +02:00
Linus Walleij 6d463de46b fbsplash: support non-RGB565 pixels in 16-bit mode
function                                             old     new   delta
fbsplash_main                                        953     989     +36
fb_pixel_value                                        80     110     +30

Signed-off-by: Linus Walleij <triad@df.lth.se>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-06 16:52:31 +02:00
Denys Vlasenko 2dc1a97272 find: make -mindepth N -xdev correctly stop on mountpoints
function                                             old     new   delta
fileAction                                           153     193     +40

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-06 15:24:11 +02:00
Denys Vlasenko 9e71e3cea5 ash: fix "read -s" + ^C. Closes 5504
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-06 13:28:10 +02:00
Denys Vlasenko 50157f3dec top: fix "last CPU" parsing
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-06 12:43:22 +02:00
Joshua Kahlenberg c439851438 sysctl: implement -q
function                                             old     new   delta
packed_usage                                       29208   29223     +15
sysctl_act_recursive                                 605     598      -7
sysctl_main                                          233     222     -11

Signed-off-by: Joshua Kahlenberg <jbkberg@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-05 18:15:12 +02:00
walter harms d1d794fd48 refactor correct_password.c to avoid one if
Signed-off-by: walter harms <wharms@bfs.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-04 12:26:20 +02:00
Denys Vlasenko 9b80b903c7 build system: stop .eh_frame generation
From Rich Felker:

By default, modern GCC generates DWARF2 debug/unwind tables in the
.eh_frame section of the object files/binaries. This adds significant
bloat (as much as 15%) to the size of the busybox binary, including
the portion mapped/loaded into memory at runtime (possibly a big issue
for NOMMU targets), and the section is not strippable with the strip
command due to being part of the loaded program text.

I've since done some further checking - both testing and asking the
GCC developers about it - and it seems the solution is to add to the
CFLAGS -fno-unwind-tables and -fno-asynchronous-unwind-tables. If
debugging is disabled, this will prevent GCC from outputting DWARF2
tables entirely. But since busybox builds with -g by default, the
interesting case is what happens then. I originally thought these
options would break debugging, but they don't; instead, they tell GCC
to output the DWARF2 tables in the .debug_frame section instead of
the newish .eh_frame section (used for exception handling). With these
options added, busybox_unstripped is still fully debuggable, and the
final busybox binary loses the 15% bloat factor from the DWARF2
tables.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-04 11:46:44 +02:00
Denys Vlasenko b7812ce0f7 wget: reorder fread and poll: poll only if fread returns EAGAIN. Closes 5426
function                                             old     new   delta
retrieve_file_data                                   451     427     -24

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-03 12:49:30 +02:00
Denys Vlasenko 168f87c531 httpd_indexcgi.c: fix compile failure
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-03 12:20:10 +02:00
Denys Vlasenko 5f10fdf1dd Fix compile failure in ll_proto.c
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-03 11:41:30 +02:00
Sven-Göran Bergh c5a9fa2d2a blkid: add support for nilfs2
function                                             old     new   delta
volume_id_probe_nilfs                                  -      99     +99
fs2                                                   52      56      +4

Signed-off-by: Sven-Göran Bergh <svengbergh-busybox@yahoo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-02 15:34:39 +02:00
Denys Vlasenko 8019b3a7ae volume_id: code shrink
function                                             old     new   delta
volume_id_set_unicode16                              200     173     -27

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-02 15:33:47 +02:00
Sven-Göran Bergh 11f2c0d4f8 blkid: add type display for btrfs
Signed-off-by: Sven-Göran Bergh <svengbergh-busybox@yahoo.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-02 14:56:25 +02:00
Denys Vlasenko 405dafffbb ll_proto.c: code shrink
text    data     bss     dec     hex filename
    762       0       0     762     2fa ll_proto.o.old
    526       0       0     526     20e ll_proto.o

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-02 14:29:45 +02:00
Denys Vlasenko a0fd4a789c style fixes, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-02 14:29:14 +02:00
Denys Vlasenko 41f7885f06 getty: tweak style, no code changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-09-02 13:57:49 +02:00
Denys Vlasenko 9c55143bbf wget: try reading after poll timeout - stdio may have buffered data. Closes 5426
function                                             old     new   delta
retrieve_file_data                                   436     451     +15

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-08-16 16:52:27 +02:00
Denys Vlasenko 45c35e9de0 getty: add commented-out extended error diagnostic
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-08-16 13:29:25 +02:00
Denys Vlasenko dba7094d62 login: increase login name size limit from 32 to 64
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-08-15 17:06:37 +02:00
Denys Vlasenko 6567edd10b udhcp[cd]: fix binding to network aliases. Closes 5432, 5438
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-08-10 00:27:22 +02:00
Cliff Frey 4919565c15 lineedit: fix Alt-D when cursor==0
Signed-off-by: Cliff Frey <cliff@meraki.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-08-07 17:59:40 +02:00
Denys Vlasenko 2ffd710656 platform.h: disable ALIGNn macros for s390[x]
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-08-06 17:17:15 +02:00
Mike Frysinger ca81a93722 disable format security warnings
We pass strings to printf directly a lot.  Some distros enable some flags
in their gcc by default like -Wformat-security.  With these two things, we
end up with a lot of build warnings like so:
	loginutils/chpasswd.c:42:3: warning: format not a string literal and
		no format arguments [-Wformat-security]

But we don't care.  Our focus is first and foremost on size, so adding a
lot of dummy calls like:
-	printf(some_constant_string);
+	printf("%s", some_constant_string);
is pointless bloat.

Disable this warning flag if the compiler supports it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-08-04 16:14:24 -04:00
Denys Vlasenko 293c94564c udhcpc: make -O <numeric_opt> work. Closes 5402
function                                             old     new   delta
udhcpc_main                                         2642    2685     +43
udhcp_recv_raw_packet                                414     415      +1
d6_recv_raw_packet                                   248     249      +1
udhcpc6_main                                        2430    2413     -17
add_client_options                                   239     213     -26
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/2 up/down: 45/-43)              Total: 2 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-27 13:25:07 +02:00
Bradley M. Kuhn 0e941d5427 Simplify copyright/license notice that appears in the binary.
Existing copyright notice for binary would need to be longer to achieve
optimal accuracy.  This compromise punts to the source for full notices,
but does note the years of the copyrights and that there are many authors,
all licensing under GPLv2.

Signed-off-by: Bradley M. Kuhn <bkuhn@ebb.org>
Signed-off-by: Tony Sebro <tony@sfconservancy.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-26 13:17:06 +02:00
Denys Vlasenko 5cfb818181 Add yet another missing ALIGN2 on a global declaration.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-26 12:58:41 +02:00
Denys Vlasenko 71045cc819 dhcpd: write lease file on exit
function                                             old     new   delta
udhcpd_main                                         1431    1403     -28

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-24 17:21:26 +02:00
Aurelien Jarno d3a42391b1 *: declare strings with ALIGN1, as appropriate
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-24 16:28:34 +02:00
Michael Tokarev 32f774cd34 *: declare strings with ALIGN1, as appropriate
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-24 15:56:37 +02:00
Yao Zhao e565383fd5 testsuite: make mkfs.minix test not fail spuriously on big endian
Signed-off-by: Yao Zhao <yao.zhao@windriver.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-24 13:58:12 +02:00
Mimi Li 37a79c092e sed: allow 'w' cmd to use two address form
function                                             old     new   delta
add_cmd                                             1101    1094      -7

Signed-off-by: Mimi Li <felloak@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-24 13:20:12 +02:00
Denys Vlasenko dbed6c4b46 tftpd: fix -u USER to work with chroot. Closes 5348
function                                             old     new   delta
tftpd_main                                           546     568     +22
tftp_protocol                                       1844    1839      -5

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-18 17:32:32 +02:00
Denys Vlasenko df8066a78c awk: fix FS assignment behavior. Closes 5108
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-11 01:27:15 +02:00
Denys Vlasenko e1db338a51 ftpd: free allocated string on error path
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-11 00:26:24 +02:00
Denys Vlasenko 3bb858765e ftpd: fix MDTM's month value. Closes 5336
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-11 00:16:08 +02:00
Denys Vlasenko 566a313a7f ash: add a comment about VEXPORT
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-07 21:40:35 +02:00
Linus Walleij b5c7220e7b fbset: respect rgba configuration lines in fb.modes
The fbset utility would not respect "rgba" config entries in
the fb.modes file such as this (for the ARM Integrator/CP):

mode "640x480-60-clcd"
    # D: 25.175 MHz, H: 31.469 kHz, V: 59.94 Hz
    geometry 640 480 640 480 16
    timings 39722 48 16 33 10 96 2
    rgba 5/10,5/5,5/0,1/15
endmode

This is important especially for this ARGB5551 device which
is hopeless to configure otherwise. I noticed this lacking
feature after the TI "fbtest" program managed to set up the
the colormode correctly.

Signed-off-by: Linus Walleij <triad@df.lth.se>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-07 19:58:15 +02:00
Eric Martin 5345b8db8b acpid: add missing lid switch definition
This patch adds a missing LID0 switch definition.
Without it, closing the notebook lid is not detected by acpid.

Signed-off-by: Eric Martin <eric.martin@gmx.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-07-07 19:06:50 +02:00
Mike Frysinger c5fe9f7b72 include sys/resource.h where needed
We use functions from sys/resource.h in misc applets, but don't include
the header.  This breaks building with newer glibc versions, so add the
include where needed.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-07-05 23:19:09 -04:00
Denys Vlasenko 9ad8979ff1 mount: support strictatime option. Closes 5240
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-26 16:09:00 +02:00
Denys Vlasenko ea664dde87 awk: make -F STR interpret escape sequences. Closes 5126
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-22 18:41:01 +02:00
Denys Vlasenko 440a509849 dpkg: fix creation of .list files (were empty since b768aeb). Closes 5324
While at it, fix filename order and free the list of names.

function                                             old     new   delta
llist_rev                                              -      21     +21
get_header_tar                                      1733    1741      +8
unpack_package                                       587     585      -2
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 1/1 up/down: 29/-2)              Total: 27 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-22 16:27:21 +02:00
Denys Vlasenko d52c9510fd trivial small speed optimization
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-22 15:54:05 +02:00
Denys Vlasenko 6ebb2b6b24 mount: do not pass "comment=ANYTHING" option to kernel. Closes 5240
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-22 15:17:18 +02:00
Denys Vlasenko a396ade9f8 mount: undo recent breakage when mount flags were made unsigned
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-22 15:06:27 +02:00
Denys Vlasenko c9a13116a4 mount: fix the wrongly stored fs creation time
This bug made our ext2 images non-mountable by ext4 driver.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-21 16:50:46 +02:00
Denys Vlasenko 9ee4266490 mount: set up RO loop device if mount -o ro. Closes 4784
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-21 12:08:56 +02:00
Denys Vlasenko 1d7ad7a022 tweak help texts
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-21 09:45:11 +02:00
Denys Vlasenko 2bc495e4c4 adduser: install to /usr, not /, like all other similar tools
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-20 20:35:58 +02:00
Denys Vlasenko dac8e79a19 Move several applets to different install dir:
Moved to [/usr]/sbin:
addgroup, adduser, delgroup, deluser,
arping, chat, ether-wake, fdformat, ifplugd,
ip, ipaddr, iplink, iproute, iprule, iptunnel,
killall5, readahead, rtcwake, tftpd, add-shell, remove-shell, powertop.

Moved to /bin for /usr/bin: kbd_mode.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-20 20:24:57 +02:00
Denys Vlasenko e3e0d2b812 tweak help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-19 12:46:59 +02:00
Bernhard Walle 9b78e14dfb build system: fix build of kconfig on Darwin
Of course busybox cannot be used on Darwin (Mac OS X), but it can be
cross-compiled for Linux there. Cross-compilation still requires kconfig
to be built as native host tool.

Signed-off-by: Bernhard Walle <bernhard@bwalle.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-18 01:51:26 +02:00
Denys Vlasenko aacd448601 wget: fix wget-supports--P testsuite failure. Closes 4940
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-17 20:21:30 +02:00
Pierre Carrier e0a6004ce8 config: do not refer to HTTPS for wget
Signed-off-by: Pierre Carrier <pierre@spotify.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-17 19:59:53 +02:00
Denys Vlasenko 6144124aac wget: make -c _not_ truncate the file
function                                             old     new   delta
retrieve_file_data                                   396     436     +40
reset_beg_range_to_zero                               52      45      -7

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-17 19:52:25 +02:00
Denys Vlasenko c5b01016e6 unzip: make options parsing more robust on getopt w/o gnu extensions
Also, code shrank:

function                                             old     new   delta
static.extn                                           15      10      -5
packed_usage                                       29231   29217     -14
unzip_main                                          2388    2291     -97
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-116)           Total: -116 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-15 16:43:26 +02:00
Denys Vlasenko 604499e5a9 Merge branch 'master' of git+ssh://busybox.net/var/lib/git/busybox 2012-06-14 17:30:04 +02:00
Denys Vlasenko bf146b8610 wget: correctly handle failure to -c (continue)
function                                             old     new   delta
reset_beg_range_to_zero                                -      52     +52
wget_main                                           2168    2189     +21

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-13 17:31:07 +02:00
Vladimir Dronnikov f5abc78579 wget: add dummy --no-cache
function                                             old     new   delta
static.wget_longopts                                 155     166     +11
packed_usage                                       29259   29231     -28

Signed-off-by: Vladimir Dronnikov <dronnikov@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-13 17:29:41 +02:00
Michael Tokarev ac42e3de90 ps: use separate get_uptime() and make it work on non-linux too
Create get_uptime() function in procps/ps.c, and use it rather than
relying on linux-specific sysinfo() inline.

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-13 02:52:28 +02:00
Matt Reimer 6979325592 nanddump: make dumping read-only partitions work
Make dumping read-only partitions work by opening the device
O_RDONLY; otherwise the open() will fail with -EPERM.

Signed-off-by: Matt Reimer <mreimer@sdgsystems.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-13 02:39:22 +02:00
Tanguy Pruvot 772f17a843 modinfo: match more standard module fields and fix version field
Previously, -F version could match the srcversion= string.

before :
  ~ # modinfo -F version tiwlan_drv
  version:        6.1.2012.05.29
  version:        533BB7E5866E52F63B9ACCB
  version:        0x%x, oui=0x%x, 0x%x, 0x%x
  version:        0x%x

  ~ # modinfo tiwlan_drv
  filename:       tiwlan_drv.ko
  author:         Texas Instruments Inc - Retouched by CyanogenDefy
  license:        GPL
  vermagic:       2.6.32.9 preempt mod_unload ARMv7
  parm:           g_sdio_debug_level:debug level
  depends:

now :
  ~ # modinfo -F version tiwlan_drv
  version:        6.1.2012.05.29

  ~ # modinfo tiwlan_drv
  filename:       tiwlan_drv.ko
  license:        GPL
  author:         Texas Instruments Inc - Retouched by CyanogenDefy
  version:        6.1.2012.05.29
  srcversion:     533BB7E5866E52F63B9ACCB
  depends:
  uts_release:    2.6.32.9-g306944c
  vermagic:       2.6.32.9 preempt mod_unload ARMv7
  parm:           g_sdio_debug_level:debug level

This patch also add support for the old "-n" and some other helpers

Change-Id: Icb4e9ca513cbce46b075a6f038799a7a19fb7e22
Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-12 16:26:03 +02:00
Denys Vlasenko ac164dd2a7 volume_id/ext: use common bb_e2fs_defs.h for ext2/3/4 constants and structs
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-12 15:00:35 +02:00
Pascal Bellard 70fc8c17e2 su: do not change to home dir unless -l
Signed-off-by: Pascal Bellard <pascal.bellard@ads-lu.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-12 13:21:02 +02:00
Denys Vlasenko 588e284f53 remove FEATURE_VI_OPTIMIZE_CURSOR from example config
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-12 01:48:45 +02:00
Denys Vlasenko 39f82d4309 rdate: code shrink
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-11 14:57:29 +02:00
Denys Vlasenko 0ccae4d8b3 Add comments in keyboard escape sequences table
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-11 14:40:17 +02:00
Denys Vlasenko d3dff879f0 vi: save/restore screen upon invocation
function                                             old     new   delta
vi_main                                              253     273     +20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-11 13:53:26 +02:00
Denys Vlasenko 04b52892ed vi: nuke FEATURE_VI_OPTIMIZE_CURSOR
It is not Unicode safe, it is not saving much of I/O, and it's large:

function                                             old     new   delta
vi_main                                              255     253      -2
go_bottom_and_clear_to_eol                            28      26      -2
do_cmd                                              4194    4182     -12
show_status_line                                     388     374     -14
strncat                                               39       -     -39
__GI_strncat                                          39       -     -39
refresh                                              774     724     -50
place_cursor                                         276      83    -193
------------------------------------------------------------------------------
(add/remove: 0/3 grow/shrink: 0/6 up/down: 0/-351)           Total: -351 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-11 13:51:38 +02:00
Denys Vlasenko 4125a6b630 ntpd: on time step, kill all outstanding replies from other peers
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-11 11:41:46 +02:00
Tanguy Pruvot 0a393cf7da testsuite: some more awk tests related to conditions
Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-11 10:33:45 +02:00
Denys Vlasenko 93c32f2dd2 rdate: code shrink
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-11 02:06:11 +02:00
Denys Vlasenko 605f2641d8 vi: do not set autoindent by default
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-11 01:53:33 +02:00
Tias Guns c9677ed83c libbb: add missing_syscalls.c: for now, only Android syscalls
Signed-off-by: Tias Guns <tias@ulyssis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-10 14:40:30 +02:00
Tias Guns bd01f22986 android: some sensible defconfig changes
- no /usr
- no skip rootfs
- use /system/lib/modules

And for niceties:
- show usage
- have installer
- long opts
- verbose cp
- ls --color support
- bbconfig

Also adds lsof (new in 1.20.0)

Signed-off-by: Tias Guns <tias@ulyssis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-10 14:29:15 +02:00
Tias Guns 3645195377 platform.h: Android tweaks: ioprio defines, BB_ADDITIONAL_PATH
Signed-off-by: Tias Guns <tias@ulyssis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-10 14:26:32 +02:00
Tias Guns a1ec841913 android: fix 'stat', ifdef S_TYPEIS* in coreutiles/stat.c
patch modified from 'BusyBox Patch V1.0 (Vitaly Greck)'
https://code.google.com/p/busybox-android/downloads/detail?name=patch_busybox

Signed-off-by: Tias Guns <tias@ulyssis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-10 14:20:42 +02:00
Tias Guns 64f763b42a inetd: fix build failure in Android
Signed-off-by: Tias Guns <tias@ulyssis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-10 14:19:01 +02:00
Denys Vlasenko 49b8e72012 brctl: fix build failure by s/strtotimeval/bb_strtotimeval/ (android has strtotimeval)
Signed-off-by: Tias Guns <tias@ulyssis.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-10 14:16:16 +02:00
Denys Vlasenko 52de9c7141 lpr: don't send 0-byte print jobs (compat)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-10 13:47:17 +02:00
Etienne Le Sueur cfc212cdff tar: fix 256-bit encoded number decoding
Signed-off-by: Etienne Le Sueur <elesueur@vmware.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-09 08:37:05 +02:00
Denys Vlasenko f451b2cfe0 ash: fix a bug in >${varexp} handling. Closes 5282
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-09 02:06:57 +02:00
Denys Vlasenko 37ca36a711 sed: yet another fix on top of zero length match code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-08 10:25:31 +02:00
Denys Vlasenko ba1d561d76 man: fix handling of gzipped manpages
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-08 10:22:05 +02:00
Denys Vlasenko 84406e459b sed: fix breakage added by zero length match code
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-07 16:34:57 +02:00
Denys Vlasenko c35545a100 sed: code shrink
function                                             old     new   delta
process_files                                       2181    2173      -8

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-04 14:45:09 +02:00
Denys Vlasenko 21f6fbf545 sed: fix zero chars match/replace
function                                             old     new   delta
process_files                                       2099    2181     +82

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-04 14:44:47 +02:00
Denys Vlasenko 21f620f6e5 ifplugd: tweak help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-03 10:26:16 +02:00
Denys Vlasenko 085b293338 udhcpc[6]: show select timeout in log
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-06-02 23:53:53 +02:00
Natanael Copa 02112d8ae3 unzip: ignore chmod errors
This makes unzip to FAT filesystems not exit with error.
This is similar to how the "normal" unzip works.

Signed-off-by: Natanael Copa <natanael.copa@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-28 01:29:15 +02:00
Boris Reisig dfc2473b9e tar: support -J, --xz explicit compression option
function                                             old     new   delta
tar_main                                             868     881     +13
tar_longopts                                         285     290      +5
packed_usage                                       29267   29270      +3

Signed-off-by: Boris Reisig <boris@boris.ca>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-24 09:01:55 +02:00
Anthony G. Basile 6e9284db78 build system: fix build failure when only gunzip is selected
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-20 12:56:17 +02:00
Christoph Lohmann 25cb5aae2b mdev: tell kernel that we didn't find the firmware
function                                             old     new   delta
mdev_main                                            797     801      +4

Signed-off-by: Christoph Lohmann <20h@r-36.net>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-19 23:39:45 +02:00
Denys Vlasenko aaf827203d Merge branch 'master' of git+ssh://vda@busybox.net/var/lib/git/busybox 2012-05-19 22:37:07 +02:00
Natanael Copa 0446104137 tar: implement --no-recursion
function                                             old     new   delta
tar_longopts                                         259     274     +15
.rodata                                             5757    5772     +15
tar_main                                            1038    1052     +14
writeTarFile                                         362     353      -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 44/-9)              Total: 35 bytes
   text	   data	    bss	    dec	    hex	filename
  81457	   1706	   8344	  91507	  16573	busybox_old
  81477	   1706	   8344	  91527	  16587	busybox_unstripped

Signed-off-by: Natanael Copa <natanael.copa@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-18 16:34:30 +02:00
Denys Vlasenko b6beada5a1 mdev: remove undocumented subsystem/devname matching hack
It was colliding with matching of devnames with slashes.
We need a more generic way to examine env.vars in rules anyway.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-18 15:11:16 +02:00
Denys Vlasenko ea57f51819 mdev: when found, print major,minor into mdev.log
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-18 11:39:57 +02:00
Denys Vlasenko 8d11854678 tweak help text
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-18 04:47:18 +02:00
Denys Vlasenko 516530c932 mdev: add support for $DEVNAME and /dev/mdev.log debug aid
function                                             old     new   delta
make_device                                         1843    2083    +240
mdev_main                                            712     804     +92
packed_usage                                       29236   29251     +15
keywords                                             288      19    -269
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 3/1 up/down: 347/-269)           Total: 78 bytes
   text    data     bss     dec     hex filename
 887506     497    7584  895587   daa63 busybox_old
 887982     497    7584  896063   dac3f busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-18 04:45:35 +02:00
Denys Vlasenko 7c8aa2b47c typo fix in comment
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-18 02:53:11 +02:00
Denys Vlasenko 0133921726 volume_id/ext: detect ext4 too
function                                             old     new   delta
volume_id_probe_ext                                  108     132     +24

Signed-off-by: Dees Troy<dees_troy@teamw.in>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-18 02:51:27 +02:00
Denys Vlasenko be1cfeea2e find: if DESKTOP=y, support -wholename (synonym for -path)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-17 12:25:25 +02:00
Denys Vlasenko 4a6a56c778 examples/mdev_fat.conf: small addition
I needed this to make Android's adb see my phone

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-16 03:03:54 +02:00
Denys Vlasenko 02b8b9b014 busybox: tweak help text and copyright year
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-14 23:52:57 +02:00
Denys Vlasenko a5ee090e86 fix for spurious testsuite failure
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-10 19:26:37 +02:00
Simon B f1f8fcaad5 mv: accept but ignore -v
function                                             old     new   delta
mv_longopts                                           36      46     +10

Signed-off-by: Simon B <sburnet@hotmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-06 18:08:24 +02:00
Simon B 3698ed1ca1 mkdir,rmdir: accept and ignore -v, --verbose
function                                             old     new   delta
static.rmdir_longopts                                 38      48     +10
mkdir_longopts                                        18      28     +10

Signed-off-by: Simon B <sburnet@hotmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-06 15:03:32 +02:00
Simon B 8c3439554a sed: support long opts and -iSFX
function                                             old     new   delta
static.sed_longopts                                    -      67     +67
sed_main                                             618     682     +64
packed_usage                                       29179   29236     +57
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 188/0)             Total: 188 bytes

Signed-off-by: Simon B <sburnet@hotmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-06 14:01:41 +02:00
Simon B 44642d1ec1 ln: support -T and -v
function                                             old     new   delta
ln_main                                              445     524     +79
packed_usage                                       29182   29179      -3

Signed-off-by: Simon B <sburnet@hotmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-06 13:18:35 +02:00
Andreas Oberritter 556ac3633c get_linux_version_code: don't fail on Linux version strints like "3.0-foo"
Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-05-05 17:47:23 +02:00
Mike Frysinger 3da46c8163 udhcpc6: depend on ipv6
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-05-02 21:45:35 -04:00
Denys Vlasenko d133144d41 fix build failure when compressed help is selected, but bz2 compression is not
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-29 14:28:12 +02:00
Ron Yorston 576b1d3c41 sendmail: use host rather than NIS domain name for HELO
According to RFC 5321 the argument to HELO "contains the fully-qualified
domain name of the SMTP client" or its IP address if no FQDN is available.
BusyBox sendmail uses the NIS domain name instead which, in many cases,
is likely to be the default "(none)". [vda: yes, I checked my machine
and its uts.domainname was indeed "(none)"]

Using the host name is more likely to satisfy the intent of the RFC while
allowing the otherwise unused safe_getdomainname function to be removed.

Signed-off-by: Ron Yorston <rmy@tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-28 17:04:19 +02:00
Denys Vlasenko 0c62f20454 lpr: small code shrink
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-27 15:03:34 +02:00
Dennis Groenen deee356a62 lineedit: histfile can get emptied when CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y
When CONFIG_FEATURE_EDITING_SAVE_ON_EXIT is set to y, the histfile
will get cleared if the total amount of history lines is less than MAX_HISTORY.
Only if the histfile is not empty _and_ the amount of lines currently
in memory are equal to or greater than MAX_HISTORY, history saving will
work as expected with this feature enabled.

Output from defconfig + CONFIG_FEATURE_EDITING_SAVE_ON_EXIT=y:
$ echo "foo" > ~/.ash_history
$ ./busybox ash
~/busybox/a $ echo "bar" > /dev/null
~/busybox/a $ exit
$ cat ~/.ash_history
$

Output with the patch applied and same config as above:
$ echo "foo" > ~/.ash_history
$ ./busybox ash
~/busybox/b $ echo "bar" > /dev/null
~/busybox/b $ exit
$ cat ~/.ash_history
foo
echo "bar" > /dev/null
exit
$

Signed-off-by: Dennis Groenen <tj.groenen at gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-26 11:19:38 +02:00
Denys Vlasenko 9d75370238 hush: remove sighandler_t definition hack, platform.h has it too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-26 10:59:01 +02:00
Denys Vlasenko eced0c78a5 getty: fix for NOCTTY killing us with SIGHUP
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-26 10:53:48 +02:00
Denys Vlasenko b84dafb5e5 sed: slightly better fix for prev commit's problem
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-24 19:27:34 +02:00
Denys Vlasenko e39afe1fbd sed: fix handling of s/// which has empty matches
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-24 19:21:16 +02:00
Andreas Oberritter 3a9365e273 ifupdown: improve compatibility with Debian
Set environment variable 'PHASE'.
Treat post-up and pre-down as aliases for up and down.
Uses the same logic as ifupdown.nw from ifupdown-0.6.16.
Makes it possible to execute Debian's ifupdown script for
wpa-supplicant.

Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-23 22:08:39 +02:00
Denys Vlasenko b9d494453d Start 1.21.0 development cycle
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-22 03:47:39 +02:00
221 changed files with 3777 additions and 1946 deletions

No files matched your search

+13 -2
View File
@@ -310,7 +310,18 @@ config FEATURE_PIDFILE
default y
help
This option makes some applets (e.g. crond, syslogd, inetd) write
a pidfile in /var/run. Some applications rely on them.
a pidfile at the configured PID_FILE_PATH. It has no effect
on applets which require pidfiles to run.
config PID_FILE_PATH
string "Path to directory for pidfile"
default "/var/run"
depends on FEATURE_PIDFILE
help
This is the default path where pidfiles are created. Applets which
allow you to set the pidfile path on the command line will override
this value. The option has no effect on applets that require you to
specify a pidfile path.
config FEATURE_SUID
bool "Support for SUID/SGID handling"
@@ -321,7 +332,7 @@ config FEATURE_SUID
root-level operations even when run by ordinary users
(for example, mounting of user mounts in fstab needs this).
Busybox will automatically drop priviledges for applets
Busybox will automatically drop privileges for applets
that don't need root access.
If you are really paranoid and don't want to do this, build two
+3 -2
View File
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 20
SUBLEVEL = 0
PATCHLEVEL = 21
SUBLEVEL = 1
EXTRAVERSION =
NAME = Unnamed
@@ -297,6 +297,7 @@ NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
AWK = awk
GENKSYMS = scripts/genksyms/genksyms
DEPMOD = /sbin/depmod
+15 -1
View File
@@ -25,6 +25,7 @@ CFLAGS += $(call cc-option,-Wstrict-prototypes,)
CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
CFLAGS += $(call cc-option,-Wunused-function -Wunused-value,)
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
CFLAGS += $(call cc-option,-Wno-format-security,)
# warn about C99 declaration after statement
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
# If you want to add more -Wsomething above, make sure that it is
@@ -52,6 +53,9 @@ CFLAGS += $(call cc-option,-fno-builtin-strlen -finline-limit=0 -fomit-frame-poi
CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
# Defeat .eh_frame bloat (gcc 4.6.3 x86-32 defconfig: 20% smaller busybox binary):
CFLAGS += $(call cc-option,-fno-unwind-tables,)
CFLAGS += $(call cc-option,-fno-asynchronous-unwind-tables,)
# FIXME: These warnings are at least partially to be concerned about and should
# be fixed..
@@ -74,6 +78,12 @@ ARCH_FPIC ?= -fpic
ARCH_FPIE ?= -fpie
ARCH_PIE ?= -pie
# Usage: $(eval $(call pkg_check_modules,VARIABLE-PREFIX,MODULES))
define pkg_check_modules
$(1)_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags $(2))
$(1)_LIBS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs $(2))
endef
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
# on i386: 14% smaller libbusybox.so
# (code itself is 9% bigger, we save on relocs/PLT/GOT)
@@ -85,6 +95,7 @@ endif
ifeq ($(CONFIG_STATIC),y)
CFLAGS_busybox += -static
PKG_CONFIG_FLAGS += --static
endif
ifeq ($(CONFIG_PIE),y)
@@ -127,7 +138,10 @@ LDLIBS += pam pam_misc pthread
endif
ifeq ($(CONFIG_SELINUX),y)
LDLIBS += selinux sepol
SELINUX_PC_MODULES = libselinux libsepol
$(eval $(call pkg_check_modules,SELINUX,$(SELINUX_PC_MODULES)))
CPPFLAGS += $(SELINUX_CFLAGS)
LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%))
endif
ifeq ($(CONFIG_EFENCE),y)
+1 -1
View File
@@ -14,7 +14,7 @@ const char *applet_name;
int main(int argc, char **argv)
{
applet_name = argv[0];
return APPLET_main(argc,argv);
return APPLET_main(argc, argv);
}
void bb_show_usage(void)
+15 -15
View File
@@ -253,24 +253,24 @@ static NOINLINE int cpio_o(void)
}
bytes += printf("070701"
"%08X%08X%08X%08X%08X%08X%08X"
"%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */
"%08X%08X%08X%08X%08X%08X%08X"
"%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */
/* strlen+1: */ "%08X"
/* chksum: */ "00000000" /* (only for "070702" files) */
/* name,NUL: */ "%s%c",
(unsigned)(uint32_t) st.st_ino,
(unsigned)(uint32_t) st.st_mode,
(unsigned)(uint32_t) st.st_uid,
(unsigned)(uint32_t) st.st_gid,
(unsigned)(uint32_t) st.st_nlink,
(unsigned)(uint32_t) st.st_mtime,
(unsigned)(uint32_t) st.st_size,
(unsigned)(uint32_t) major(st.st_dev),
(unsigned)(uint32_t) minor(st.st_dev),
(unsigned)(uint32_t) major(st.st_rdev),
(unsigned)(uint32_t) minor(st.st_rdev),
(unsigned)(strlen(name) + 1),
name, '\0');
(unsigned)(uint32_t) st.st_ino,
(unsigned)(uint32_t) st.st_mode,
(unsigned)(uint32_t) st.st_uid,
(unsigned)(uint32_t) st.st_gid,
(unsigned)(uint32_t) st.st_nlink,
(unsigned)(uint32_t) st.st_mtime,
(unsigned)(uint32_t) st.st_size,
(unsigned)(uint32_t) major(st.st_dev),
(unsigned)(uint32_t) minor(st.st_dev),
(unsigned)(uint32_t) major(st.st_rdev),
(unsigned)(uint32_t) minor(st.st_rdev),
(unsigned)(strlen(name) + 1),
name, '\0');
bytes = cpio_pad4(bytes);
if (st.st_size) {
+12 -7
View File
@@ -1026,8 +1026,8 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
if (package_edge->type == EDGE_CONFLICTS) {
const unsigned package_num =
search_package_hashtable(package_edge->name,
package_edge->version,
package_edge->operator);
package_edge->version,
package_edge->operator);
int result = 0;
if (package_hashtable[package_num] != NULL) {
status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]);
@@ -1114,7 +1114,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
*/
if (root_of_alternatives && package_edge->type != root_of_alternatives->type - 1)
bb_error_msg_and_die("fatal error, package dependencies corrupt: %d != %d - 1",
package_edge->type, root_of_alternatives->type);
package_edge->type, root_of_alternatives->type);
if (package_hashtable[package_num] != NULL)
result = !package_satisfies_dependency(package_num, package_edge->type);
@@ -1665,20 +1665,25 @@ static void unpack_package(deb_file_t *deb_file)
archive_handle = init_archive_deb_ar(deb_file->filename);
init_archive_deb_data(archive_handle);
archive_handle->dpkg__sub_archive->accept = conffile_list;
/* Why ARCHIVE_REMEMBER_NAMES?
* We want names collected in ->passed list even if conffile_list
* is NULL (otherwise get_header_tar may optimize name saving out):
*/
archive_handle->dpkg__sub_archive->ah_flags |= ARCHIVE_REMEMBER_NAMES | ARCHIVE_UNLINK_OLD;
archive_handle->dpkg__sub_archive->filter = filter_rename_config;
archive_handle->dpkg__sub_archive->action_data = data_extract_all_prefix;
archive_handle->dpkg__sub_archive->dpkg__buffer = (char*)"/"; /* huh? */
archive_handle->dpkg__sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD;
unpack_ar_archive(archive_handle);
/* Create the list file */
list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list");
out_stream = xfopen_for_write(list_filename);
archive_handle->dpkg__sub_archive->passed = llist_rev(archive_handle->dpkg__sub_archive->passed);
while (archive_handle->dpkg__sub_archive->passed) {
char *filename = llist_pop(&archive_handle->dpkg__sub_archive->passed);
/* the leading . has been stripped by data_extract_all_prefix already */
fputs(archive_handle->dpkg__sub_archive->passed->data, out_stream);
fputc('\n', out_stream);
archive_handle->dpkg__sub_archive->passed = archive_handle->dpkg__sub_archive->passed->link;
fprintf(out_stream, "%s\n", filename);
free(filename);
}
fclose(out_stream);
+8 -8
View File
@@ -1179,7 +1179,7 @@ static void gen_codes(ct_data * tree, int max_code)
* must be all ones.
*/
Assert(code + G2.bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1,
"inconsistent bit counts");
"inconsistent bit counts");
Tracev((stderr, "\ngen_codes: max_code %d ", max_code));
for (n = 0; n <= max_code; n++) {
@@ -1527,9 +1527,9 @@ static int ct_tally(int dist, int lc)
}
out_length >>= 3;
Trace((stderr,
"\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ",
G2.last_lit, G2.last_dist, in_length, out_length,
100L - out_length * 100L / in_length));
"\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ",
G2.last_lit, G2.last_dist, in_length, out_length,
100L - out_length * 100L / in_length));
if (G2.last_dist < G2.last_lit / 2 && out_length < in_length / 2)
return 1;
}
@@ -1621,9 +1621,9 @@ static ulg flush_block(char *buf, ulg stored_len, int eof)
static_lenb = (G2.static_len + 3 + 7) >> 3;
Trace((stderr,
"\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ",
opt_lenb, G2.opt_len, static_lenb, G2.static_len, stored_len,
G2.last_lit, G2.last_dist));
"\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ",
opt_lenb, G2.opt_len, static_lenb, G2.static_len, stored_len,
G2.last_lit, G2.last_dist));
if (static_lenb <= opt_lenb)
opt_lenb = static_lenb;
@@ -1661,7 +1661,7 @@ static ulg flush_block(char *buf, ulg stored_len, int eof)
} else {
send_bits((DYN_TREES << 1) + eof, 3);
send_all_trees(G2.l_desc.max_code + 1, G2.d_desc.max_code + 1,
max_blindex + 1);
max_blindex + 1);
compress_block((ct_data *) G2.dyn_ltree, (ct_data *) G2.dyn_dtree);
G2.compressed_len += 3 + G2.opt_len;
}
+2 -2
View File
@@ -45,7 +45,7 @@ lib-$(CONFIG_UNXZ) += decompress_unxz.o
lib-$(CONFIG_CPIO) += get_header_cpio.o
lib-$(CONFIG_DPKG) += $(DPKG_FILES)
lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
lib-$(CONFIG_GUNZIP) += decompress_gunzip.o
lib-$(CONFIG_GUNZIP) += open_transformer.o decompress_gunzip.o
lib-$(CONFIG_RPM2CPIO) += decompress_gunzip.o get_header_cpio.o
lib-$(CONFIG_RPM) += open_transformer.o decompress_gunzip.o get_header_cpio.o
lib-$(CONFIG_TAR) += get_header_tar.o
@@ -60,7 +60,7 @@ lib-$(CONFIG_FEATURE_SEAMLESS_GZ) += open_transformer.o decompress_gunzip.
lib-$(CONFIG_FEATURE_SEAMLESS_BZ2) += open_transformer.o decompress_bunzip2.o
lib-$(CONFIG_FEATURE_SEAMLESS_LZMA) += open_transformer.o decompress_unlzma.o
lib-$(CONFIG_FEATURE_SEAMLESS_XZ) += open_transformer.o decompress_unxz.o
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += open_transformer.o decompress_bunzip2.o
lib-$(CONFIG_FEATURE_COMPRESS_BBCONFIG) += decompress_bunzip2.o
lib-$(CONFIG_FEATURE_TAR_TO_COMMAND) += data_extract_to_command.o
+2 -2
View File
@@ -293,8 +293,8 @@ static unsigned fill_bitbuffer(STATE_PARAM unsigned bitbuffer, unsigned *current
* m: maximum lookup bits, returns actual
*/
static int huft_build(const unsigned *b, const unsigned n,
const unsigned s, const unsigned short *d,
const unsigned char *e, huft_t **t, unsigned *m)
const unsigned s, const unsigned short *d,
const unsigned char *e, huft_t **t, unsigned *m)
{
unsigned a; /* counter for codes of length k */
unsigned c[BMAX + 1]; /* bit length count table */
+18 -16
View File
@@ -78,7 +78,6 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
IF_DESKTOP(long long total_written = 0;)
IF_DESKTOP(long long) int retval = -1;
unsigned char *stackp;
long code;
int finchar;
long oldcode;
long incode;
@@ -143,8 +142,10 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
/* As above, initialize the first 256 entries in the table. */
/*clear_tab_prefixof(); - done by xzalloc */
for (code = 255; code >= 0; --code) {
tab_suffixof(code) = (unsigned char) code;
{
int i;
for (i = 255; i >= 0; --i)
tab_suffixof(i) = (unsigned char) i;
}
do {
@@ -175,6 +176,8 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
(insize << 3) - (n_bits - 1));
while (inbits > posbits) {
long code;
if (free_ent > maxcode) {
posbits =
((posbits - 1) +
@@ -191,13 +194,12 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
}
{
unsigned char *p = &inbuf[posbits >> 3];
code = ((((long) (p[0])) | ((long) (p[1]) << 8) |
((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
code = ((p[0]
| ((long) (p[1]) << 8)
| ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
}
posbits += n_bits;
if (oldcode == -1) {
if (code >= 256)
bb_error_msg_and_die("corrupted data"); /* %ld", code); */
@@ -226,15 +228,16 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
/* Special case for KwKwK string. */
if (code >= free_ent) {
if (code > free_ent) {
/*
unsigned char *p;
posbits -= n_bits;
p = &inbuf[posbits >> 3];
bb_error_msg
("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)",
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
(posbits & 07));
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
(posbits & 07));
*/
bb_error_msg("corrupted data");
goto err;
}
@@ -244,7 +247,7 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
}
/* Generate output characters in reverse order */
while ((long) code >= (long) 256) {
while (code >= 256) {
if (stackp <= &htabof(0))
bb_error_msg_and_die("corrupted data");
*--stackp = tab_suffixof(code);
@@ -285,11 +288,10 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
}
/* Generate the new entry. */
code = free_ent;
if (code < maxmaxcode) {
tab_prefixof(code) = (unsigned short) oldcode;
tab_suffixof(code) = (unsigned char) finchar;
free_ent = code + 1;
if (free_ent < maxmaxcode) {
tab_prefixof(free_ent) = (unsigned short) oldcode;
tab_suffixof(free_ent) = (unsigned char) finchar;
free_ent++;
}
/* Remember previous code. */
+38 -9
View File
@@ -30,8 +30,8 @@ static uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc)
/* We use arch-optimized unaligned accessors */
#define get_unaligned_le32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_LE32(v); })
#define get_unaligned_be32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_BE32(v); })
#define put_unaligned_le32(val, buf) move_to_unaligned16(buf, SWAP_LE32(val))
#define put_unaligned_be32(val, buf) move_to_unaligned16(buf, SWAP_BE32(val))
#define put_unaligned_le32(val, buf) move_to_unaligned32(buf, SWAP_LE32(val))
#define put_unaligned_be32(val, buf) move_to_unaligned32(buf, SWAP_BE32(val))
#include "unxz/xz_dec_bcj.c"
#include "unxz/xz_dec_lzma2.c"
@@ -40,6 +40,7 @@ static uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc)
IF_DESKTOP(long long) int FAST_FUNC
unpack_xz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
{
enum xz_ret xz_result;
struct xz_buf iobuf;
struct xz_dec *state;
unsigned char *membuf;
@@ -63,9 +64,8 @@ unpack_xz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
/* Limit memory usage to about 64 MiB. */
state = xz_dec_init(XZ_DYNALLOC, 64*1024*1024);
xz_result = X_OK;
while (1) {
enum xz_ret r;
if (iobuf.in_pos == iobuf.in_size) {
int rd = safe_read(src_fd, membuf, BUFSIZ);
if (rd < 0) {
@@ -73,28 +73,57 @@ unpack_xz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
total = -1;
break;
}
if (rd == 0 && xz_result == XZ_STREAM_END)
break;
iobuf.in_size = rd;
iobuf.in_pos = 0;
}
if (xz_result == XZ_STREAM_END) {
/*
* Try to start decoding next concatenated stream.
* Stream padding must always be a multiple of four
* bytes to preserve four-byte alignment. To keep the
* code slightly smaller, we aren't as strict here as
* the .xz spec requires. We just skip all zero-bytes
* without checking the alignment and thus can accept
* files that aren't valid, e.g. the XZ utils test
* files bad-0pad-empty.xz and bad-0catpad-empty.xz.
*/
do {
if (membuf[iobuf.in_pos] != 0) {
xz_dec_reset(state);
goto do_run;
}
iobuf.in_pos++;
} while (iobuf.in_pos < iobuf.in_size);
}
do_run:
// bb_error_msg(">in pos:%d size:%d out pos:%d size:%d",
// iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size);
r = xz_dec_run(state, &iobuf);
xz_result = xz_dec_run(state, &iobuf);
// bb_error_msg("<in pos:%d size:%d out pos:%d size:%d r:%d",
// iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size, r);
// iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size, xz_result);
if (iobuf.out_pos) {
xwrite(dst_fd, iobuf.out, iobuf.out_pos);
IF_DESKTOP(total += iobuf.out_pos;)
iobuf.out_pos = 0;
}
if (r == XZ_STREAM_END) {
break;
if (xz_result == XZ_STREAM_END) {
/*
* Can just "break;" here, if not for concatenated
* .xz streams.
* Checking for padding may require buffer
* replenishment. Can't do it here.
*/
continue;
}
if (r != XZ_OK && r != XZ_UNSUPPORTED_CHECK) {
if (xz_result != XZ_OK && xz_result != XZ_UNSUPPORTED_CHECK) {
bb_error_msg("corrupted data");
total = -1;
break;
}
}
xz_dec_end(state);
free(membuf);
@@ -24,11 +24,13 @@ char FAST_FUNC filter_accept_reject_list(archive_handle_t *archive_handle)
if (reject_entry) {
return EXIT_FAILURE;
}
accept_entry = find_list_entry2(archive_handle->accept, key);
/* Fail if an accept list was specified and the key wasnt in there */
if ((accept_entry == NULL) && archive_handle->accept) {
return EXIT_FAILURE;
if (archive_handle->accept) {
accept_entry = find_list_entry2(archive_handle->accept, key);
if (!accept_entry) {
return EXIT_FAILURE;
}
}
/* Accepted */
+5 -3
View File
@@ -84,7 +84,7 @@ static unsigned long long getOctal(char *str, int len)
first >>= 1; /* now 7th bit = 6th bit */
v = first; /* sign-extend 8 bits to 64 */
while (--len != 0)
v = (v << 8) + (unsigned char) *str++;
v = (v << 8) + (uint8_t) *++str;
}
return v;
}
@@ -452,9 +452,11 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
if (cp)
*cp = '\0';
archive_handle->action_data(archive_handle);
if (archive_handle->accept || archive_handle->reject)
if (archive_handle->accept || archive_handle->reject
|| (archive_handle->ah_flags & ARCHIVE_REMEMBER_NAMES)
) {
llist_add_to(&archive_handle->passed, file_header->name);
else /* Caller isn't interested in list of unpacked files */
} else /* Caller isn't interested in list of unpacked files */
free(file_header->name);
} else {
data_skip(archive_handle);
+6 -6
View File
@@ -644,7 +644,7 @@ static int len_of_coded_match(unsigned m_len, unsigned m_off, unsigned lit)
static int min_gain(unsigned ahead, unsigned lit1,
unsigned lit2, int l1, int l2, int l3)
unsigned lit2, int l1, int l2, int l3)
{
int lazy_match_min_gain = 0;
@@ -673,7 +673,7 @@ static int min_gain(unsigned ahead, unsigned lit1,
#if defined(SWD_BEST_OFF)
static void better_match(const lzo_swd_p swd,
unsigned *m_len, unsigned *m_off)
unsigned *m_len, unsigned *m_off)
{
if (*m_len <= M2_MIN_LEN)
return;
@@ -914,8 +914,8 @@ int lzo1x_999_compress_level(const uint8_t *in, unsigned in_len,
compression_level -= 7;
return lzo1x_999_compress_internal(in, in_len, out, out_len, wrkmem,
c[compression_level].good_length,
c[compression_level].max_lazy,
c[compression_level].max_chain,
c[compression_level].use_best_off);
c[compression_level].good_length,
c[compression_level].max_lazy,
c[compression_level].max_chain,
c[compression_level].use_best_off);
}
+1 -1
View File
@@ -15,7 +15,7 @@
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
+1 -1
View File
@@ -15,7 +15,7 @@
The LZO library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
+5 -5
View File
@@ -14,7 +14,7 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
@@ -116,7 +116,7 @@ static NOINLINE int lzo1x_optimize(uint8_t *in, unsigned in_len,
unsigned nl;
unsigned long o_m1_a = 0, o_m1_b = 0, o_m2 = 0, o_m3_a = 0, o_m3_b = 0;
// LZO_UNUSED(wrkmem);
// LZO_UNUSED(wrkmem);
*out_len = 0;
@@ -346,11 +346,11 @@ static NOINLINE int lzo1x_optimize(uint8_t *in, unsigned in_len,
return LZO_E_EOF_NOT_FOUND;
eof_found:
// LZO_UNUSED(o_m1_a); LZO_UNUSED(o_m1_b); LZO_UNUSED(o_m2);
// LZO_UNUSED(o_m3_a); LZO_UNUSED(o_m3_b);
// LZO_UNUSED(o_m1_a); LZO_UNUSED(o_m1_b); LZO_UNUSED(o_m2);
// LZO_UNUSED(o_m3_a); LZO_UNUSED(o_m3_b);
*out_len = pd(op, out);
return (ip == ip_end ? LZO_E_OK :
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
}
/**********************************************************************/
+34 -16
View File
@@ -60,8 +60,8 @@
#if !ENABLE_FEATURE_SEAMLESS_GZ && !ENABLE_FEATURE_SEAMLESS_BZ2
/* Do not pass gzip flag to writeTarFile() */
#define writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude, gzip) \
writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude)
#define writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude, gzip) \
writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude)
#endif
@@ -333,13 +333,13 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
&& (filesize <= 0x3fffffffffffffffffffffffLL)
#endif
) {
/* GNU tar uses "base-256 encoding" for very large numbers.
* Encoding is binary, with highest bit always set as a marker
* and sign in next-highest bit:
* 80 00 .. 00 - zero
* bf ff .. ff - largest positive number
* ff ff .. ff - minus 1
* c0 00 .. 00 - smallest negative number
/* GNU tar uses "base-256 encoding" for very large numbers.
* Encoding is binary, with highest bit always set as a marker
* and sign in next-highest bit:
* 80 00 .. 00 - zero
* bf ff .. ff - largest positive number
* ff ff .. ff - minus 1
* c0 00 .. 00 - smallest negative number
*/
char *p8 = header.size + sizeof(header.size);
do {
@@ -598,7 +598,7 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip)
/* gcc 4.2.1 inlines it, making code bigger */
static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
int dereferenceFlag, const llist_t *include,
int recurseFlags, const llist_t *include,
const llist_t *exclude, int gzip)
{
int errorFlag = FALSE;
@@ -621,8 +621,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
/* Read the directory/files and iterate over them one at a time */
while (include) {
if (!recursive_action(include->data, ACTION_RECURSE |
(dereferenceFlag ? ACTION_FOLLOWLINKS : 0),
if (!recursive_action(include->data, recurseFlags,
writeFileToTarball, writeFileToTarball, &tbInfo, 0)
) {
errorFlag = TRUE;
@@ -662,7 +661,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
}
#else
int writeTarFile(int tar_fd, int verboseFlag,
int dereferenceFlag, const llist_t *include,
int recurseFlags, const llist_t *include,
const llist_t *exclude, int gzip);
#endif /* FEATURE_TAR_CREATE */
@@ -694,6 +693,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
//usage: "-[" IF_FEATURE_TAR_CREATE("c") "xt"
//usage: IF_FEATURE_SEAMLESS_Z("Z")
//usage: IF_FEATURE_SEAMLESS_GZ("z")
//usage: IF_FEATURE_SEAMLESS_XZ("J")
//usage: IF_FEATURE_SEAMLESS_BZ2("j")
//usage: IF_FEATURE_SEAMLESS_LZMA("a")
//usage: IF_FEATURE_TAR_CREATE("h")
@@ -720,6 +720,9 @@ static llist_t *append_file_list_to_list(llist_t *list)
//usage: IF_FEATURE_SEAMLESS_GZ(
//usage: "\n z (De)compress using gzip"
//usage: )
//usage: IF_FEATURE_SEAMLESS_XZ(
//usage: "\n J (De)compress using xz"
//usage: )
//usage: IF_FEATURE_SEAMLESS_BZ2(
//usage: "\n j (De)compress using bzip2"
//usage: )
@@ -749,6 +752,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
// o no-same-owner
// p same-permissions
// k keep-old
// no-recursion
// numeric-owner
// no-same-permissions
// overwrite
@@ -765,9 +769,11 @@ enum {
IF_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,)
IF_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,)
IF_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,)
IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) // 16th bit
IF_FEATURE_SEAMLESS_XZ( OPTBIT_XZ ,) // 16th bit
IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,)
IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,)
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
OPTBIT_NORECURSION,
IF_FEATURE_TAR_TO_COMMAND(OPTBIT_2COMMAND ,)
OPTBIT_NUMERIC_OWNER,
OPTBIT_NOPRESERVE_PERM,
@@ -789,14 +795,16 @@ enum {
OPT_INCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T
OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
OPT_XZ = IF_FEATURE_SEAMLESS_XZ( (1 << OPTBIT_XZ )) + 0, // J
OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z
OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m
OPT_NORECURSION = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NORECURSION )) + 0, // no-recursion
OPT_2COMMAND = IF_FEATURE_TAR_TO_COMMAND( (1 << OPTBIT_2COMMAND )) + 0, // to-command
OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner
OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions
OPT_OVERWRITE = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_OVERWRITE )) + 0, // overwrite
OPT_ANY_COMPRESS = (OPT_BZIP2 | OPT_LZMA | OPT_GZIP | OPT_COMPRESS),
OPT_ANY_COMPRESS = (OPT_BZIP2 | OPT_LZMA | OPT_GZIP | OPT_XZ | OPT_COMPRESS),
};
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
static const char tar_longopts[] ALIGN1 =
@@ -829,12 +837,16 @@ static const char tar_longopts[] ALIGN1 =
# if ENABLE_FEATURE_SEAMLESS_GZ
"gzip\0" No_argument "z"
# endif
# if ENABLE_FEATURE_SEAMLESS_XZ
"xz\0" No_argument "J"
# endif
# if ENABLE_FEATURE_SEAMLESS_Z
"compress\0" No_argument "Z"
# endif
# if ENABLE_FEATURE_TAR_NOPRESERVE_TIME
"touch\0" No_argument "m"
# endif
"no-recursion\0" No_argument "\xfa"
# if ENABLE_FEATURE_TAR_TO_COMMAND
"to-command\0" Required_argument "\xfb"
# endif
@@ -921,6 +933,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
IF_FEATURE_SEAMLESS_LZMA("a" )
IF_FEATURE_TAR_FROM( "T:X:")
IF_FEATURE_SEAMLESS_GZ( "z" )
IF_FEATURE_SEAMLESS_XZ( "J" )
IF_FEATURE_SEAMLESS_Z( "Z" )
IF_FEATURE_TAR_NOPRESERVE_TIME("m")
, &base_dir // -C dir
@@ -1050,7 +1063,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
zipMode = 2;
#endif
/* NB: writeTarFile() closes tar_handle->src_fd */
return writeTarFile(tar_handle->src_fd, verboseFlag, opt & OPT_DEREFERENCE,
return writeTarFile(tar_handle->src_fd, verboseFlag,
(opt & OPT_DEREFERENCE ? ACTION_FOLLOWLINKS : 0)
| (opt & OPT_NORECURSION ? 0 : ACTION_RECURSE),
tar_handle->accept,
tar_handle->reject, zipMode);
}
@@ -1071,6 +1086,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
if (opt & OPT_LZMA)
USE_FOR_MMU(xformer = unpack_lzma_stream;)
USE_FOR_NOMMU(xformer_prog = "unlzma";)
if (opt & OPT_XZ)
USE_FOR_MMU(xformer = unpack_xz_stream;)
USE_FOR_NOMMU(xformer_prog = "unxz";)
open_transformer_with_sig(tar_handle->src_fd, xformer, xformer_prog);
/* Can't lseek over pipes */
+77 -74
View File
@@ -20,16 +20,16 @@
*/
//usage:#define unzip_trivial_usage
//usage: "[-opts[modifiers]] FILE[.zip] [LIST] [-x XLIST] [-d DIR]"
//usage: "[-lnopq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]"
//usage:#define unzip_full_usage "\n\n"
//usage: "Extract files from ZIP archives\n"
//usage: "\n -l List archive contents (with -q for short form)"
//usage: "\n -n Never overwrite files (default)"
//usage: "Extract FILEs from ZIP archive\n"
//usage: "\n -l List contents (with -q for short form)"
//usage: "\n -n Never overwrite files (default: ask)"
//usage: "\n -o Overwrite"
//usage: "\n -p Send output to stdout"
//usage: "\n -p Print to stdout"
//usage: "\n -q Quiet"
//usage: "\n -x XLST Exclude these files"
//usage: "\n -d DIR Extract files into DIR"
//usage: "\n -x FILE Exclude FILEs"
//usage: "\n -d DIR Extract into DIR"
#include "libbb.h"
#include "bb_archive.h"
@@ -277,6 +277,7 @@ int unzip_main(int argc, char **argv)
IF_NOT_DESKTOP(const) smallint verbose = 0;
smallint listing = 0;
smallint overwrite = O_PROMPT;
smallint x_opt_seen;
#if ENABLE_DESKTOP
uint32_t cdf_offset;
#endif
@@ -290,7 +291,6 @@ int unzip_main(int argc, char **argv)
llist_t *zreject = NULL;
char *base_dir = NULL;
int i, opt;
int opt_range = 0;
char key_buf[80];
struct stat stat_buf;
@@ -335,81 +335,81 @@ int unzip_main(int argc, char **argv)
* 204372 1 file
*/
x_opt_seen = 0;
/* '-' makes getopt return 1 for non-options */
while ((opt = getopt(argc, argv, "-d:lnopqxv")) != -1) {
switch (opt_range) {
case 0: /* Options */
switch (opt) {
case 'l': /* List */
listing = 1;
break;
switch (opt) {
case 'd': /* Extract to base directory */
base_dir = optarg;
break;
case 'n': /* Never overwrite existing files */
overwrite = O_NEVER;
break;
case 'l': /* List */
listing = 1;
break;
case 'o': /* Always overwrite existing files */
overwrite = O_ALWAYS;
break;
case 'n': /* Never overwrite existing files */
overwrite = O_NEVER;
break;
case 'p': /* Extract files to stdout and fall through to set verbosity */
dst_fd = STDOUT_FILENO;
case 'o': /* Always overwrite existing files */
overwrite = O_ALWAYS;
break;
case 'q': /* Be quiet */
quiet++;
break;
case 'p': /* Extract files to stdout and fall through to set verbosity */
dst_fd = STDOUT_FILENO;
case 'v': /* Verbose list */
IF_DESKTOP(verbose++;)
listing = 1;
break;
case 'q': /* Be quiet */
quiet++;
break;
case 1: /* The zip file */
case 'v': /* Verbose list */
IF_DESKTOP(verbose++;)
listing = 1;
break;
case 'x':
x_opt_seen = 1;
break;
case 1:
if (!src_fn) {
/* The zip file */
/* +5: space for ".zip" and NUL */
src_fn = xmalloc(strlen(optarg) + 5);
strcpy(src_fn, optarg);
opt_range++;
break;
default:
bb_show_usage();
} else if (!x_opt_seen) {
/* Include files */
llist_add_to(&zaccept, optarg);
} else {
/* Exclude files */
llist_add_to(&zreject, optarg);
}
break;
case 1: /* Include files */
if (opt == 1) {
llist_add_to(&zaccept, optarg);
break;
}
if (opt == 'd') {
base_dir = optarg;
opt_range += 2;
break;
}
if (opt == 'x') {
opt_range++;
break;
}
bb_show_usage();
case 2 : /* Exclude files */
if (opt == 1) {
llist_add_to(&zreject, optarg);
break;
}
if (opt == 'd') { /* Extract to base directory */
base_dir = optarg;
opt_range++;
break;
}
/* fall through */
default:
bb_show_usage();
}
}
if (src_fn == NULL) {
#ifndef __GLIBC__
/*
* This code is needed for non-GNU getopt
* which doesn't understand "-" in option string.
* The -x option won't work properly in this case:
* "unzip a.zip q -x w e" will be interpreted as
* "unzip a.zip q w e -x" = "unzip a.zip q w e"
*/
argv += optind;
if (argv[0]) {
/* +5: space for ".zip" and NUL */
src_fn = xmalloc(strlen(argv[0]) + 5);
strcpy(src_fn, argv[0]);
while (*++argv)
llist_add_to(&zaccept, *argv);
}
#endif
if (!src_fn) {
bb_show_usage();
}
@@ -420,17 +420,20 @@ int unzip_main(int argc, char **argv)
if (overwrite == O_PROMPT)
overwrite = O_NEVER;
} else {
static const char extn[][5] = {"", ".zip", ".ZIP"};
int orig_src_fn_len = strlen(src_fn);
int src_fd = -1;
static const char extn[][5] = { ".zip", ".ZIP" };
char *ext = src_fn + strlen(src_fn);
int src_fd;
for (i = 0; (i < 3) && (src_fd == -1); i++) {
strcpy(src_fn + orig_src_fn_len, extn[i]);
i = 0;
for (;;) {
src_fd = open(src_fn, O_RDONLY);
}
if (src_fd == -1) {
src_fn[orig_src_fn_len] = '\0';
bb_error_msg_and_die("can't open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
if (src_fd >= 0)
break;
if (++i > 2) {
*ext = '\0';
bb_error_msg_and_die("can't open %s[.zip]", src_fn);
}
strcpy(ext, extn[i - 1]);
}
xmove_fd(src_fd, zip_fd);
}
@@ -596,7 +599,7 @@ int unzip_main(int argc, char **argv)
printf(" creating: %s\n", dst_fn);
}
unzip_create_leading_dirs(dst_fn);
if (bb_make_directory(dst_fn, dir_mode, 0)) {
if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) {
xfunc_die();
}
} else {
-1
View File
@@ -341,7 +341,6 @@ CONFIG_FEATURE_VI_READONLY=y
CONFIG_FEATURE_VI_SETOPTS=y
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_FEATURE_ALLOW_EXEC=y
#
-1
View File
@@ -346,7 +346,6 @@ CONFIG_FEATURE_VI_MAX_LEN=0
# CONFIG_FEATURE_VI_SET is not set
# CONFIG_FEATURE_VI_WIN_RESIZE is not set
# CONFIG_FEATURE_VI_ASK_TERMINAL is not set
# CONFIG_FEATURE_VI_OPTIMIZE_CURSOR is not set
# CONFIG_FEATURE_ALLOW_EXEC is not set
#
-1
View File
@@ -358,7 +358,6 @@ CONFIG_FEATURE_VI_READONLY=y
CONFIG_FEATURE_VI_SETOPTS=y
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_FEATURE_ALLOW_EXEC=y
#
-1
View File
@@ -363,7 +363,6 @@ CONFIG_FEATURE_VI_MAX_LEN=0
# CONFIG_FEATURE_VI_SET is not set
# CONFIG_FEATURE_VI_WIN_RESIZE is not set
# CONFIG_FEATURE_VI_ASK_TERMINAL is not set
# CONFIG_FEATURE_VI_OPTIMIZE_CURSOR is not set
# CONFIG_AWK is not set
# CONFIG_FEATURE_AWK_LIBM is not set
CONFIG_CMP=y
-1
View File
@@ -386,7 +386,6 @@ CONFIG_FEATURE_VI_SETOPTS=y
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
CONFIG_FEATURE_VI_ASK_TERMINAL=y
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_AWK=y
CONFIG_FEATURE_AWK_LIBM=y
CONFIG_CMP=y
+14 -15
View File
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Busybox version: 1.20.0.git
# Fri Mar 2 16:53:26 2012
# Busybox version: 1.21.0.git
# Mon May 28 21:51:18 2012
#
CONFIG_HAVE_DOT_CONFIG=y
@@ -20,11 +20,11 @@ CONFIG_PLATFORM_LINUX=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 is not set
# CONFIG_FEATURE_VERBOSE_USAGE is not set
# CONFIG_FEATURE_COMPRESS_USAGE is not set
# CONFIG_FEATURE_INSTALLER is not set
# CONFIG_INSTALL_NO_USR is not set
CONFIG_SHOW_USAGE=y
CONFIG_FEATURE_VERBOSE_USAGE=y
CONFIG_FEATURE_COMPRESS_USAGE=y
CONFIG_FEATURE_INSTALLER=y
CONFIG_INSTALL_NO_USR=y
# CONFIG_LOCALE_SUPPORT is not set
# CONFIG_UNICODE_SUPPORT is not set
# CONFIG_UNICODE_USING_LOCALE is not set
@@ -36,7 +36,7 @@ CONFIG_LAST_SUPPORTED_WCHAR=0
# CONFIG_UNICODE_BIDI_SUPPORT is not set
# CONFIG_UNICODE_NEUTRAL_TABLE is not set
# CONFIG_UNICODE_PRESERVE_BROKEN is not set
# CONFIG_LONG_OPTS is not set
CONFIG_LONG_OPTS=y
# CONFIG_FEATURE_DEVPTS is not set
# CONFIG_FEATURE_CLEAN_UP is not set
# CONFIG_FEATURE_UTMP is not set
@@ -67,7 +67,6 @@ CONFIG_EXTRA_CFLAGS="-DANDROID -D__ANDROID__ -DSK_RELEASE -nostdlib -march=armv7
CONFIG_EXTRA_LDFLAGS="-Xlinker -z -Xlinker muldefs -nostdlib -Bdynamic -Xlinker -dynamic-linker -Xlinker /system/bin/linker -Xlinker -z -Xlinker nocopyreloc -Xlinker --no-undefined ${SYSROOT}/usr/lib/crtbegin_dynamic.o ${SYSROOT}/usr/lib/crtend_android.o"
CONFIG_EXTRA_LDLIBS="dl m c gcc"
#
# Debugging Options
#
@@ -112,7 +111,7 @@ CONFIG_FEATURE_EDITING_HISTORY=0
# CONFIG_FEATURE_EDITING_FANCY_PROMPT is not set
# CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set
# CONFIG_FEATURE_NON_POSIX_CP is not set
# CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set
CONFIG_FEATURE_VERBOSE_CP_MESSAGE=y
CONFIG_FEATURE_COPYBUF_KB=4
# CONFIG_FEATURE_SKIP_ROOTFS is not set
# CONFIG_MONOTONIC_SYSCALL is not set
@@ -239,7 +238,7 @@ CONFIG_FEATURE_LS_RECURSIVE=y
CONFIG_FEATURE_LS_SORTFILES=y
CONFIG_FEATURE_LS_TIMESTAMPS=y
CONFIG_FEATURE_LS_USERNAME=y
# CONFIG_FEATURE_LS_COLOR is not set
CONFIG_FEATURE_LS_COLOR=y
# CONFIG_FEATURE_LS_COLOR_IS_DEFAULT is not set
CONFIG_MD5SUM=y
CONFIG_MKDIR=y
@@ -372,7 +371,6 @@ CONFIG_FEATURE_VI_SETOPTS=y
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
CONFIG_FEATURE_VI_ASK_TERMINAL=y
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_AWK=y
CONFIG_FEATURE_AWK_LIBM=y
CONFIG_CMP=y
@@ -516,7 +514,7 @@ CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
# CONFIG_FEATURE_MODUTILS_ALIAS is not set
# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
CONFIG_DEFAULT_MODULES_DIR="/system/lib/modules"
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
#
@@ -647,8 +645,8 @@ CONFIG_SETSERIAL=y
# CONFIG_UBIRSVOL is not set
# CONFIG_UBIUPDATEVOL is not set
# CONFIG_ADJTIMEX is not set
# CONFIG_BBCONFIG is not set
# CONFIG_FEATURE_COMPRESS_BBCONFIG is not set
CONFIG_BBCONFIG=y
CONFIG_FEATURE_COMPRESS_BBCONFIG=y
CONFIG_BEEP=y
CONFIG_FEATURE_BEEP_FREQ=4000
CONFIG_FEATURE_BEEP_LENGTH_MS=30
@@ -883,6 +881,7 @@ CONFIG_SENDMAIL=y
# Process Utilities
#
CONFIG_IOSTAT=y
CONFIG_LSOF=y
CONFIG_MPSTAT=y
CONFIG_NMETER=y
CONFIG_PMAP=y
-1
View File
@@ -363,7 +363,6 @@ CONFIG_FEATURE_VI_SETOPTS=y
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
CONFIG_FEATURE_VI_ASK_TERMINAL=y
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_AWK=y
CONFIG_FEATURE_AWK_LIBM=y
CONFIG_CMP=y
-1
View File
@@ -367,7 +367,6 @@ CONFIG_FEATURE_VI_SETOPTS=y
CONFIG_FEATURE_VI_SET=y
CONFIG_FEATURE_VI_WIN_RESIZE=y
CONFIG_FEATURE_VI_ASK_TERMINAL=y
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
CONFIG_FEATURE_ALLOW_EXEC=y
#
+1 -1
View File
@@ -229,7 +229,7 @@ static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize,
}
/* Note: after PIO_UNIMAPCLR and before PIO_UNIMAP
this printf did not work on many kernels */
* this printf did not work on many kernels */
advice.advised_hashsize = 0;
advice.advised_hashstep = 0;
+4 -3
View File
@@ -22,9 +22,10 @@ int setlogcons_main(int argc UNUSED_PARAM, char **argv)
struct {
char fn;
char subarg;
} arg = { 11, /* redirect kernel messages */
0 /* to specified console (current as default) */
};
} arg = {
11, /* redirect kernel messages */
0 /* to specified console (current as default) */
};
if (argv[1])
arg.subarg = xatou_range(argv[1], 0, 63);
+9 -3
View File
@@ -514,6 +514,12 @@ config SHA512SUM
help
Compute and check SHA512 message digest
config SHA3SUM
bool "sha3sum"
default y
help
Compute and check SHA3 (512-bit) message digest
config SLEEP
bool "sleep"
default y
@@ -766,13 +772,13 @@ config FEATURE_HUMAN_READABLE
help
Allow df, du, and ls to have human readable output.
comment "Common options for md5sum, sha1sum, sha256sum, sha512sum"
depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM
comment "Common options for md5sum, sha1sum, sha256sum, sha512sum, sha3sum"
depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM || SHA3SUM
config FEATURE_MD5_SHA1_SUM_CHECK
bool "Enable -c, -s and -w options"
default y
depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM
depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM || SHA3SUM
help
Enabling the -c options allows files to be checked
against pre-calculated hash values.
+1
View File
@@ -62,6 +62,7 @@ lib-$(CONFIG_SEQ) += seq.o
lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
lib-$(CONFIG_SHA256SUM) += md5_sha1_sum.o
lib-$(CONFIG_SHA512SUM) += md5_sha1_sum.o
lib-$(CONFIG_SHA3SUM) += md5_sha1_sum.o
lib-$(CONFIG_SLEEP) += sleep.o
lib-$(CONFIG_SPLIT) += split.o
lib-$(CONFIG_SORT) += sort.o
+8 -7
View File
@@ -43,7 +43,7 @@ static const unsigned char days_in_month[] ALIGN1 = {
};
static const unsigned char sep1752[] ALIGN1 = {
1, 2, 14, 15, 16,
1, 2, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30
};
@@ -167,8 +167,8 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
day_array(month, year, dp);
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
printf("%*s%s\n%s\n",
((7*julian + WEEK_LEN) - len) / 2, "",
lineout, day_headings);
((7*julian + WEEK_LEN) - len) / 2, "",
lineout, day_headings);
for (row = 0; row < 6; row++) {
build_row(lineout, dp)[0] = '\0';
dp += 7;
@@ -181,10 +181,11 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
sprintf(lineout, "%u", year);
center(lineout,
(WEEK_LEN * 3 + HEAD_SEP * 2)
+ julian * (J_WEEK_LEN * 2 + HEAD_SEP
- (WEEK_LEN * 3 + HEAD_SEP * 2)),
0);
(WEEK_LEN * 3 + HEAD_SEP * 2)
+ julian * (J_WEEK_LEN * 2 + HEAD_SEP
- (WEEK_LEN * 3 + HEAD_SEP * 2)),
0
);
puts("\n"); /* two \n's */
for (i = 0; i < 12; i++) {
day_array(i + 1, year, days[i]);
+2 -2
View File
@@ -126,8 +126,8 @@ int chown_main(int argc UNUSED_PARAM, char **argv)
/* This matches coreutils behavior (almost - see below) */
param.chown_func = chown;
if (OPT_NODEREF
/* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */
IF_DESKTOP( || (opt & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
/* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */
IF_DESKTOP( || (opt & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
) {
param.chown_func = lchown;
}
+1 -1
View File
@@ -212,7 +212,7 @@ int cut_main(int argc UNUSED_PARAM, char **argv)
if (opt & CUT_OPT_SUPPRESS_FLGS) {
bb_error_msg_and_die
("suppressing non-delimited lines makes sense%s",
_op_on_field);
_op_on_field);
}
if (delim != '\t') {
bb_error_msg_and_die
+4 -4
View File
@@ -110,9 +110,9 @@ int df_main(int argc UNUSED_PARAM, char **argv)
df_disp_hr = xatoul_range(chp, 1, ULONG_MAX); /* disallow 0 */
/* From the manpage of df from coreutils-6.10:
Disk space is shown in 1K blocks by default, unless the environment
variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
*/
* Disk space is shown in 1K blocks by default, unless the environment
* variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
*/
if (getenv("POSIXLY_CORRECT")) /* TODO - a new libbb function? */
df_disp_hr = 512;
@@ -221,7 +221,7 @@ int df_main(int argc UNUSED_PARAM, char **argv)
}
#else
if (printf("\n%-20s" + 1, device) > 20 && !(opt & OPT_POSIX))
printf("\n%-20s", "");
printf("\n%-20s", "");
#endif
#if ENABLE_FEATURE_HUMAN_READABLE
+4
View File
@@ -89,6 +89,10 @@ struct globals {
#define INIT_G() do { } while (0)
/* FIXME? coreutils' du rounds sizes up:
* for example, 1025k file is shown as "2" by du -m.
* We round to nearest.
*/
static void print(unsigned long long size, const char *filename)
{
/* TODO - May not want to defer error checking here. */
+1 -1
View File
@@ -174,7 +174,7 @@ int id_main(int argc UNUSED_PARAM, char **argv)
/* Don't allow -n -r -nr -ug -rug -nug -rnug -uZ -gZ -GZ*/
/* Don't allow more than one username */
opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG"
IF_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
IF_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
opt = getopt32(argv, "rnugG" IF_SELINUX("Z"));
}
+22 -6
View File
@@ -20,6 +20,8 @@
//usage: "\n -n Don't dereference symlinks - treat like normal file"
//usage: "\n -b Make a backup of the target (if exists) before link operation"
//usage: "\n -S suf Use suffix instead of ~ when making backup files"
//usage: "\n -T 2nd arg must be a DIR"
//usage: "\n -v Verbose"
//usage:
//usage:#define ln_example_usage
//usage: "$ ln -s BusyBox /tmp/ls\n"
@@ -31,11 +33,13 @@
/* This is a NOEXEC applet. Be very careful! */
#define LN_SYMLINK 1
#define LN_FORCE 2
#define LN_NODEREFERENCE 4
#define LN_BACKUP 8
#define LN_SUFFIX 16
#define LN_SYMLINK (1 << 0)
#define LN_FORCE (1 << 1)
#define LN_NODEREFERENCE (1 << 2)
#define LN_BACKUP (1 << 3)
#define LN_SUFFIX (1 << 4)
#define LN_VERBOSE (1 << 5)
#define LN_LINKFILE (1 << 6)
int ln_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int ln_main(int argc, char **argv)
@@ -50,10 +54,15 @@ int ln_main(int argc, char **argv)
int (*link_func)(const char *, const char *);
opt_complementary = "-1"; /* min one arg */
opts = getopt32(argv, "sfnbS:", &suffix);
opts = getopt32(argv, "sfnbS:vT", &suffix);
last = argv[argc - 1];
argv += optind;
argc -= optind;
if ((opts & LN_LINKFILE) && argc > 2) {
bb_error_msg_and_die("-T accepts 2 args max");
}
if (!argv[1]) {
/* "ln PATH/TO/FILE" -> "ln PATH/TO/FILE FILE" */
@@ -72,6 +81,9 @@ int ln_main(int argc, char **argv)
(opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE
)
) {
if (opts & LN_LINKFILE) {
bb_error_msg_and_die("'%s' is a directory", src);
}
src_name = xstrdup(*argv);
src = concat_path_file(src, bb_get_last_path_component_strip(src_name));
free(src_name);
@@ -112,6 +124,10 @@ int ln_main(int argc, char **argv)
link_func = symlink;
}
if (opts & LN_VERBOSE) {
printf("'%s' -> '%s'\n", src, *argv);
}
if (link_func(*argv, src) != 0) {
bb_simple_perror_msg(src);
status = EXIT_FAILURE;
+2 -2
View File
@@ -260,7 +260,7 @@ enum {
/* TODO: simple toggles may be stored as OPT_xxx bits instead */
static const uint32_t opt_flags[] = {
STYLE_COLUMNAR, /* C */
STYLE_COLUMNAR, /* C */
DISP_HIDDEN | DISP_DOT, /* a */
DISP_NOLIST, /* d */
LIST_INO, /* i */
@@ -720,7 +720,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
if ((option_mask32 & OPT_L) || force_follow) {
#if ENABLE_SELINUX
if (is_selinux_enabled()) {
getfilecon(fullname, &cur->sid);
getfilecon(fullname, &cur->sid);
}
#endif
if (stat(fullname, &statbuf)) {
+18 -1
View File
@@ -55,6 +55,16 @@
//usage: "\n -s Don't output anything, status code shows success"
//usage: "\n -w Warn about improperly formatted checksum lines"
//usage: )
//usage:
//usage:#define sha3sum_trivial_usage
//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK("[-c[sw]] ")"[FILE]..."
//usage:#define sha3sum_full_usage "\n\n"
//usage: "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " SHA3-512 checksums"
//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n"
//usage: "\n -c Check sums against list in FILEs"
//usage: "\n -s Don't output anything, status code shows success"
//usage: "\n -w Warn about improperly formatted checksum lines"
//usage: )
#include "libbb.h"
@@ -65,6 +75,7 @@ enum {
HASH_MD5 = 's', /* "md5>s<um" */
HASH_SHA1 = '1',
HASH_SHA256 = '2',
HASH_SHA3 = '3',
HASH_SHA512 = '5',
};
@@ -86,6 +97,7 @@ static uint8_t *hash_file(const char *filename)
{
int src_fd, hash_len, count;
union _ctx_ {
sha3_ctx_t sha3;
sha512_ctx_t sha512;
sha256_ctx_t sha256;
sha1_ctx_t sha1;
@@ -124,6 +136,11 @@ static uint8_t *hash_file(const char *filename)
update = (void*)sha512_hash;
final = (void*)sha512_end;
hash_len = 64;
} else if (ENABLE_SHA3SUM && hash_algo == HASH_SHA3) {
sha3_begin(&context.sha3);
update = (void*)sha3_hash;
final = (void*)sha3_end;
hash_len = 64;
} else {
xfunc_die(); /* can't reach this */
}
@@ -223,7 +240,7 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
}
if (count_failed && !(flags & FLAG_SILENT)) {
bb_error_msg("WARNING: %d of %d computed checksums did NOT match",
count_failed, count_total);
count_failed, count_total);
}
fclose_if_not_stdin(pre_computed_stream);
} else {
+2 -1
View File
@@ -48,6 +48,7 @@ static const char mkdir_longopts[] ALIGN1 =
#if ENABLE_SELINUX
"context\0" Required_argument "Z"
#endif
"verbose\0" No_argument "v"
;
#endif
@@ -66,7 +67,7 @@ int mkdir_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
applet_long_options = mkdir_longopts;
#endif
opt = getopt32(argv, "m:p" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext));
opt = getopt32(argv, "m:p" IF_SELINUX("Z:") "v", &smode IF_SELINUX(,&scontext));
if (opt & 1) {
mode_t mmode = 0777;
if (!bb_parse_mode(smode, &mmode)) {
+1 -1
View File
@@ -59,7 +59,7 @@ int mknod_main(int argc, char **argv)
/* 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)));
xatoul_range(argv[3], 0, minor(UINT_MAX)));
}
}
+11 -8
View File
@@ -33,12 +33,13 @@ static const char mv_longopts[] ALIGN1 =
"interactive\0" No_argument "i"
"force\0" No_argument "f"
"no-clobber\0" No_argument "n"
"verbose\0" No_argument "v"
;
#endif
#define OPT_FILEUTILS_FORCE 1
#define OPT_FILEUTILS_INTERACTIVE 2
#define OPT_FILEUTILS_NOCLOBBER 4
#define OPT_FORCE (1 << 0)
#define OPT_INTERACTIVE (1 << 1)
#define OPT_NOCLOBBER (1 << 2)
int mv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int mv_main(int argc, char **argv)
@@ -56,9 +57,11 @@ int mv_main(int argc, char **argv)
#endif
/* Need at least two arguments.
* If more than one of -f, -i, -n is specified , only the final one
* takes effect (it unsets previous options). */
* takes effect (it unsets previous options).
* -v is accepted but ignored.
*/
opt_complementary = "-2:f-in:i-fn:n-fi";
flags = getopt32(argv, "fin");
flags = getopt32(argv, "finv");
argc -= optind;
argv += optind;
last = argv[argc - 1];
@@ -84,11 +87,11 @@ int mv_main(int argc, char **argv)
DO_MOVE:
if (dest_exists) {
if (flags & OPT_FILEUTILS_NOCLOBBER)
if (flags & OPT_NOCLOBBER)
goto RET_0;
if (!(flags & OPT_FILEUTILS_FORCE)
if (!(flags & OPT_FORCE)
&& ((access(dest, W_OK) < 0 && isatty(0))
|| (flags & OPT_FILEUTILS_INTERACTIVE))
|| (flags & OPT_INTERACTIVE))
) {
if (fprintf(stderr, "mv: overwrite '%s'? ", dest) < 0) {
goto RET_1; /* Ouch! fprintf failed! */
+3 -3
View File
@@ -25,7 +25,7 @@
//usage:#if ENABLE_DESKTOP
//usage:#define od_trivial_usage
//usage: "[-abcdfhilovxs] [-t TYPE] [-A RADIX] [-N SIZE] [-j SKIP] [-S MINSTR] [-w WIDTH] [FILE...]"
//usage: "[-abcdfhilovxs] [-t TYPE] [-A RADIX] [-N SIZE] [-j SKIP] [-S MINSTR] [-w WIDTH] [FILE]..."
// We don't support:
// ... [FILE] [[+]OFFSET[.][b]]
// Support is buggy for:
@@ -1021,12 +1021,12 @@ dump(off_t current_offset, off_t end_offset)
l_c_m = get_lcm();
/* Make bytes_to_write the smallest multiple of l_c_m that
is at least as large as n_bytes_read. */
is at least as large as n_bytes_read. */
bytes_to_write = l_c_m * ((n_bytes_read + l_c_m - 1) / l_c_m);
memset(block[idx] + n_bytes_read, 0, bytes_to_write - n_bytes_read);
write_block(current_offset, bytes_to_write,
block[idx ^ 1], block[idx]);
block[idx ^ 1], block[idx]);
current_offset += n_bytes_read;
}
+5 -3
View File
@@ -30,8 +30,9 @@
/* This is a NOFORK applet. Be very careful! */
#define PARENTS 0x01
#define IGNORE_NON_EMPTY 0x02
#define PARENTS (1 << 0)
//efine VERBOSE (1 << 1) //accepted but ignored
#define IGNORE_NON_EMPTY (1 << 2)
int rmdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int rmdir_main(int argc UNUSED_PARAM, char **argv)
@@ -43,13 +44,14 @@ int rmdir_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_FEATURE_RMDIR_LONG_OPTIONS
static const char rmdir_longopts[] ALIGN1 =
"parents\0" No_argument "p"
"verbose\0" No_argument "v"
/* 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");
flags = getopt32(argv, "pv");
argv += optind;
if (!*argv) {
+1 -1
View File
@@ -219,7 +219,7 @@ static int compare_keys(const void *xarg, const void *yarg)
y = get_key(*(char **)yarg, key, flags);
#else
/* This curly bracket serves no purpose but to match the nesting
level of the for () loop we're not using */
* level of the for () loop we're not using */
{
x = *(char **)xarg;
y = *(char **)yarg;
+40 -28
View File
@@ -99,9 +99,15 @@ static const char *file_type(const struct stat *st)
if (S_ISFIFO(st->st_mode)) return "fifo";
if (S_ISLNK(st->st_mode)) return "symbolic link";
if (S_ISSOCK(st->st_mode)) return "socket";
#ifdef S_TYPEISMQ
if (S_TYPEISMQ(st)) return "message queue";
#endif
#ifdef S_TYPEISSEM
if (S_TYPEISSEM(st)) return "semaphore";
#endif
#ifdef S_TYPEISSHM
if (S_TYPEISSHM(st)) return "shared memory object";
#endif
#ifdef S_TYPEISTMO
if (S_TYPEISTMO(st)) return "typed memory object";
#endif
@@ -436,7 +442,7 @@ static bool do_statfs(const char *filename, const char *format)
: getfilecon(filename, &scontext)
) < 0
) {
bb_perror_msg(filename);
bb_simple_perror_msg(filename);
return 0;
}
}
@@ -549,7 +555,7 @@ static bool do_stat(const char *filename, const char *format)
: getfilecon(filename, &scontext)
) < 0
) {
bb_perror_msg(filename);
bb_simple_perror_msg(filename);
return 0;
}
}
@@ -585,37 +591,43 @@ static bool do_stat(const char *filename, const char *format)
# else
if (option_mask32 & OPT_TERSE) {
format = (option_mask32 & OPT_SELINUX ?
"%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o %C\n":
"%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o\n");
"%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o %C\n"
:
"%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o\n"
);
} else {
if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode)) {
format = (option_mask32 & OPT_SELINUX ?
" File: %N\n"
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
" Device type: %t,%T\n"
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
" S_Context: %C\n"
"Access: %x\n" "Modify: %y\n" "Change: %z\n":
" File: %N\n"
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
" Device type: %t,%T\n"
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
"Access: %x\n" "Modify: %y\n" "Change: %z\n");
" File: %N\n"
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
" Device type: %t,%T\n"
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
" S_Context: %C\n"
"Access: %x\n" "Modify: %y\n" "Change: %z\n"
:
" File: %N\n"
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
" Device type: %t,%T\n"
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
"Access: %x\n" "Modify: %y\n" "Change: %z\n"
);
} else {
format = (option_mask32 & OPT_SELINUX ?
" File: %N\n"
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
"Device: %Dh/%dd\tInode: %-10i Links: %h\n"
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
"S_Context: %C\n"
"Access: %x\n" "Modify: %y\n" "Change: %z\n":
" File: %N\n"
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
"Device: %Dh/%dd\tInode: %-10i Links: %h\n"
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
"Access: %x\n" "Modify: %y\n" "Change: %z\n");
" File: %N\n"
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
"Device: %Dh/%dd\tInode: %-10i Links: %h\n"
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
"S_Context: %C\n"
"Access: %x\n" "Modify: %y\n" "Change: %z\n"
:
" File: %N\n"
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
"Device: %Dh/%dd\tInode: %-10i Links: %h\n"
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
"Access: %x\n" "Modify: %y\n" "Change: %z\n"
);
}
}
# endif
+1 -1
View File
@@ -1056,7 +1056,7 @@ static void do_display(const struct termios *mode, int all)
}
#endif
wrapf("%s = %s;", nth_string(control_name, i),
visible(mode->c_cc[control_info[i].offset]));
visible(mode->c_cc[control_info[i].offset]));
}
#if VEOF == VMIN
if ((mode->c_lflag & ICANON) == 0)
+2 -2
View File
@@ -94,8 +94,8 @@ int sum_main(int argc UNUSED_PARAM, char **argv)
n = sum_file("-", type);
} else {
/* Need to print the name if either
- more than one file given
- doing sysv */
* - more than one file given
* - doing sysv */
type += (argv[1] || type == SUM_SYSV);
n = 1;
do {
+1 -1
View File
@@ -610,7 +610,7 @@ static int test_eaccess(char *path, int mode)
return 0;
/* Root can execute any file that has any one of the execute
bits set. */
* bits set. */
if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
return 0;
}
+19 -21
View File
@@ -38,7 +38,7 @@
//usage: "TEMPLATE must end with XXXXXX (e.g. [/dir/]nameXXXXXX).\n"
//usage: "Without TEMPLATE, -t tmp.XXXXXX is assumed.\n"
//usage: "\n -d Make directory, not file"
////usage: "\n -q Fail silently on errors" - we ignore this opt
//usage: "\n -q Fail silently on errors"
//usage: "\n -t Prepend base directory name to TEMPLATE"
//usage: "\n -p DIR Use DIR as a base directory (implies -t)"
//usage: "\n -u Do not create anything; print a name"
@@ -71,7 +71,6 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
if (!path || path[0] == '\0')
path = "/tmp";
/* -q is ignored */
opt_complementary = "?1"; /* 1 argument max */
opts = getopt32(argv, "dqtp:u", &path);
@@ -83,33 +82,32 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
chp = xstrdup("tmp.XXXXXX");
opts |= OPT_t;
}
if (opts & OPT_u) {
/* Remove (up to) 6 X's */
unsigned len = strlen(chp);
int cnt = len > 6 ? 6 : len;
while (--cnt >= 0 && chp[--len] == 'X')
chp[len] = '\0';
chp = tempnam(opts & (OPT_t|OPT_p) ? path : "./", chp);
if (!chp)
return EXIT_FAILURE;
if (!(opts & (OPT_t|OPT_p)))
chp += 2;
goto ret;
#if 0
/* Don't allow directory separator in template */
if ((opts & OPT_t) && bb_basename(chp) != chp) {
errno = EINVAL;
goto error;
}
#endif
if (opts & (OPT_t|OPT_p))
chp = concat_path_file(path, chp);
if (opts & OPT_d) {
if (opts & OPT_u) {
chp = mktemp(chp);
if (chp[0] == '\0')
goto error;
} else if (opts & OPT_d) {
if (mkdtemp(chp) == NULL)
return EXIT_FAILURE;
goto error;
} else {
if (mkstemp(chp) < 0)
return EXIT_FAILURE;
goto error;
}
ret:
puts(chp);
return EXIT_SUCCESS;
error:
if (opts & OPT_q)
return EXIT_FAILURE;
/* don't use chp as it gets mangled in case of error */
bb_perror_nomsg_and_die();
}
+7 -8
View File
@@ -4,14 +4,13 @@
*
* Copyright (C) 2007 Bernhard Reutner-Fischer
*
* Based on a older version that was in busybox which was 1k big..
* Based on a older version that was in busybox which was 1k big.
* Copyright (C) 2001 by Emanuele Aina <emanuele.aina@tiscali.it>
*
* Based on the Debian run-parts program, version 1.15
* Copyright (C) 1996 Jeff Noxon <jeff@router.patch.net>,
* Copyright (C) 1996-1999 Guy Maor <maor@debian.org>
*
*
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
*/
@@ -19,7 +18,7 @@
* attempt to write a program! :-) . */
/* This piece of code is heavily based on the original version of run-parts,
* taken from debian-utils. I've only removed the long options and a the
* taken from debian-utils. I've only removed the long options and the
* report mode. As the original run-parts support only long options, I've
* broken compatibility because the BusyBox policy doesn't allow them.
* The supported options are:
@@ -31,15 +30,15 @@
*/
//usage:#define run_parts_trivial_usage
//usage: "[-t] "IF_FEATURE_RUN_PARTS_FANCY("[-l] ")"[-a ARG] [-u MASK] DIRECTORY"
//usage: "[-t"IF_FEATURE_RUN_PARTS_FANCY("l")"] [-a ARG]... [-u MASK] DIRECTORY"
//usage:#define run_parts_full_usage "\n\n"
//usage: "Run a bunch of scripts in DIRECTORY\n"
//usage: "\n -t Print what would be run, but don't actually run anything"
//usage: "\n -a ARG Pass ARG as argument for every program"
//usage: "\n -u MASK Set the umask to MASK before running every program"
//usage: "\n -t Dry run"
//usage: IF_FEATURE_RUN_PARTS_FANCY(
//usage: "\n -l Print names of all matching files even if they are not executable"
//usage: "\n -l Print names of matching files even if they are not executable"
//usage: )
//usage: "\n -a ARG Pass ARG as argument to programs"
//usage: "\n -u MASK Set umask to MASK before running programs"
//usage:
//usage:#define run_parts_example_usage
//usage: "$ run-parts -a start /etc/init.d\n"
+2 -2
View File
@@ -478,7 +478,7 @@ static int wait_one(int flags)
instance_list = inst->next;
if (verbose > 1)
printf("Finished with %s (exit status %d)\n",
inst->device, status);
inst->device, status);
num_running--;
free_instance(inst);
@@ -844,7 +844,7 @@ static int check_all(void)
if (verbose > 1)
printf("--waiting-- (pass %d)\n", passno);
status |= wait_many(pass_done ? FLAG_WAIT_ALL :
FLAG_WAIT_ATLEAST_ONE);
FLAG_WAIT_ATLEAST_ONE);
if (pass_done) {
if (verbose > 1)
puts("----------------------------------");
+1 -1
View File
@@ -93,7 +93,7 @@ static int lsattr_dir_proc(const char *dir_name, struct dirent *de,
path = concat_path_file(dir_name, de->d_name);
if (lstat(path, &st) == -1)
bb_perror_msg(path);
bb_simple_perror_msg(path);
else {
if (de->d_name[0] != '.' || (flags & OPT_ALL)) {
list_attributes(path);
+32 -8
View File
@@ -155,7 +155,7 @@ typedef struct tsplitter_s {
/* simple token classes */
/* Order and hex values are very important!!! See next_token() */
#define TC_SEQSTART 1 /* ( */
#define TC_SEQSTART 1 /* ( */
#define TC_SEQTERM (1 << 1) /* ) */
#define TC_REGEXP (1 << 2) /* /.../ */
#define TC_OUTRDR (1 << 3) /* | > >> */
@@ -696,6 +696,10 @@ static char nextchar(char **s)
pps = *s;
if (c == '\\')
c = bb_process_escape_sequence((const char**)s);
/* Example awk statement:
* s = "abc\"def"
* we must treat \" as "
*/
if (c == '\\' && *s == pps) { /* unrecognized \z? */
c = *(*s); /* yes, fetch z */
if (c)
@@ -704,6 +708,15 @@ static char nextchar(char **s)
return c;
}
/* TODO: merge with strcpy_and_process_escape_sequences()?
*/
static void unescape_string_in_place(char *s1)
{
char *s = s1;
while ((*s1 = nextchar(&s)) != '\0')
s1++;
}
static ALWAYS_INLINE int isalnum_(int c)
{
return (isalnum(c) || c == '_');
@@ -1799,6 +1812,18 @@ static void handle_special(var *v)
is_f0_split = FALSE;
} else if (v == intvar[FS]) {
/*
* The POSIX-2008 standard says that changing FS should have no effect on the
* current input line, but only on the next one. The language is:
*
* > Before the first reference to a field in the record is evaluated, the record
* > shall be split into fields, according to the rules in Regular Expressions,
* > using the value of FS that was current at the time the record was read.
*
* So, split up current line before assignment to FS:
*/
split_f0();
mk_splitter(getvar_s(v), &fsplitter);
} else if (v == intvar[RS]) {
@@ -2992,7 +3017,7 @@ static int awk_exit(int r)
* otherwise return 0 */
static int is_assignment(const char *expr)
{
char *exprc, *val, *s, *s1;
char *exprc, *val;
if (!isalnum_(*expr) || (val = strchr(expr, '=')) == NULL) {
return FALSE;
@@ -3002,10 +3027,7 @@ static int is_assignment(const char *expr)
val = exprc + (val - expr);
*val++ = '\0';
s = s1 = val;
while ((*s1 = nextchar(&s)) != '\0')
s1++;
unescape_string_in_place(val);
setvar_u(newvar(exprc), val);
free(exprc);
return TRUE;
@@ -3118,8 +3140,10 @@ int awk_main(int argc, char **argv)
opt = getopt32(argv, "F:v:f:W:", &opt_F, &list_v, &list_f, NULL);
argv += optind;
argc -= optind;
if (opt & 0x1)
setvar_s(intvar[FS], opt_F); // -F
if (opt & 0x1) { /* -F */
unescape_string_in_place(opt_F);
setvar_s(intvar[FS], opt_F);
}
while (list_v) { /* -v */
if (!is_assignment(llist_pop(&list_v)))
bb_show_usage();
+1 -1
View File
@@ -843,7 +843,7 @@ static void diffdir(char *p[2], const char *s_start)
* add_to_dirlist will remove it. */
list[i].len = strlen(p[i]);
recursive_action(p[i], ACTION_RECURSE | ACTION_FOLLOWLINKS,
add_to_dirlist, skip_dir, &list[i], 0);
add_to_dirlist, skip_dir, &list[i], 0);
/* Sort dl alphabetically.
* GNU diff does this ignoring any number of trailing dots.
* We don't, so for us dotted files almost always are
+95 -39
View File
@@ -53,7 +53,9 @@
* Todo:
* - Create a wrapper around regex to make libc's regex conform with sed
*
* Reference http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html
* Reference
* http://www.opengroup.org/onlinepubs/007904975/utilities/sed.html
* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html
*/
//usage:#define sed_trivial_usage
@@ -62,7 +64,8 @@
//usage:#define sed_full_usage "\n\n"
//usage: " -e CMD Add CMD to sed commands to be executed"
//usage: "\n -f FILE Add FILE contents to sed commands to be executed"
//usage: "\n -i Edit files in-place (else sends result to stdout)"
//usage: "\n -i[SFX] Edit files in-place (otherwise sends to stdout)"
//usage: "\n Optionally back files up, appending SFX"
//usage: "\n -n Suppress automatic printing of pattern space"
//usage: "\n -r Use extended regex syntax"
//usage: "\n"
@@ -491,8 +494,10 @@ static const char *parse_cmd_args(sed_cmd_t *sed_cmd, const char *cmdstr)
}
/* handle edit cmds: (a)ppend, (i)nsert, and (c)hange */
else if (idx <= IDX_c) { /* a,i,c */
if ((sed_cmd->end_line || sed_cmd->end_match) && sed_cmd->cmd != 'c')
bb_error_msg_and_die("only a beginning address can be specified for edit commands");
if (idx < IDX_c) { /* a,i */
if (sed_cmd->end_line || sed_cmd->end_match)
bb_error_msg_and_die("command '%c' uses only one address", sed_cmd->cmd);
}
for (;;) {
if (*cmdstr == '\n' || *cmdstr == '\\') {
cmdstr++;
@@ -509,8 +514,10 @@ static const char *parse_cmd_args(sed_cmd_t *sed_cmd, const char *cmdstr)
}
/* handle file cmds: (r)ead */
else if (idx <= IDX_w) { /* r,w */
if (sed_cmd->end_line || sed_cmd->end_match)
bb_error_msg_and_die("command only uses one address");
if (idx < IDX_w) { /* r */
if (sed_cmd->end_line || sed_cmd->end_match)
bb_error_msg_and_die("command '%c' uses only one address", sed_cmd->cmd);
}
cmdstr += parse_file_cmd(/*sed_cmd,*/ cmdstr, &sed_cmd->string);
if (sed_cmd->cmd == 'w') {
sed_cmd->sw_file = xfopen_for_write(sed_cmd->string);
@@ -672,7 +679,7 @@ static void do_subst_w_backrefs(char *line, char *replace)
/* go through the replacement string */
for (i = 0; replace[i]; i++) {
/* if we find a backreference (\1, \2, etc.) print the backref'ed * text */
/* if we find a backreference (\1, \2, etc.) print the backref'ed text */
if (replace[i] == '\\') {
unsigned backref = replace[++i] - '0';
if (backref <= 9) {
@@ -706,8 +713,10 @@ static void do_subst_w_backrefs(char *line, char *replace)
static int do_subst_command(sed_cmd_t *sed_cmd, char **line_p)
{
char *line = *line_p;
int altered = 0;
unsigned match_count = 0;
bool altered = 0;
bool prev_match_empty = 1;
bool tried_at_eol = 0;
regex_t *current_regex;
current_regex = sed_cmd->sub_match;
@@ -734,50 +743,75 @@ static int do_subst_command(sed_cmd_t *sed_cmd, char **line_p)
/* Now loop through, substituting for matches */
do {
int start = G.regmatch[0].rm_so;
int end = G.regmatch[0].rm_eo;
int i;
/* Work around bug in glibc regexec, demonstrated by:
* echo " a.b" | busybox sed 's [^ .]* x g'
* The match_count check is so not to break
* echo "hi" | busybox sed 's/^/!/g'
*/
if (!G.regmatch[0].rm_so && !G.regmatch[0].rm_eo && match_count) {
pipe_putc(*line++);
continue;
}
match_count++;
/* If we aren't interested in this match, output old line to
end of match and continue */
* end of match and continue */
if (sed_cmd->which_match
&& (sed_cmd->which_match != match_count)
) {
for (i = 0; i < G.regmatch[0].rm_eo; i++)
for (i = 0; i < end; i++)
pipe_putc(*line++);
continue;
/* Null match? Print one more char */
if (start == end && *line)
pipe_putc(*line++);
goto next;
}
/* print everything before the match */
for (i = 0; i < G.regmatch[0].rm_so; i++)
/* Print everything before the match */
for (i = 0; i < start; i++)
pipe_putc(line[i]);
/* then print the substitution string */
do_subst_w_backrefs(line, sed_cmd->string);
/* Then print the substitution string,
* unless we just matched empty string after non-empty one.
* Example: string "cccd", pattern "c*", repl "R":
* result is "RdR", not "RRdR": first match "ccc",
* second is "" before "d", third is "" after "d".
* Second match is NOT replaced!
*/
if (prev_match_empty || start != 0 || start != end) {
//dbg("%d %d %d", prev_match_empty, start, end);
dbg("inserting replacement at %d in '%s'", start, line);
do_subst_w_backrefs(line, sed_cmd->string);
/* Flag that something has changed */
altered = 1;
} else {
dbg("NOT inserting replacement at %d in '%s'", start, line);
}
/* advance past the match */
line += G.regmatch[0].rm_eo;
/* flag that something has changed */
altered++;
/* If matched string is empty (f.e. "c*" pattern),
* copy verbatim one char after it before attempting more matches
*/
prev_match_empty = (start == end);
if (prev_match_empty) {
if (!line[end]) {
tried_at_eol = 1;
} else {
pipe_putc(line[end]);
end++;
}
}
/* Advance past the match */
dbg("line += %d", end);
line += end;
/* if we're not doing this globally, get out now */
if (sed_cmd->which_match != 0)
break;
next:
/* Exit if we are at EOL and already tried matching at it */
if (*line == '\0') {
if (tried_at_eol)
break;
tried_at_eol = 1;
}
if (*line == '\0')
break;
//maybe (G.regmatch[0].rm_eo ? REG_NOTBOL : 0) instead of unconditional REG_NOTBOL?
//maybe (end ? REG_NOTBOL : 0) instead of unconditional REG_NOTBOL?
} while (regexec(current_regex, line, 10, G.regmatch, REG_NOTBOL) != REG_NOMATCH);
/* Copy rest of string into output pipeline */
@@ -1043,7 +1077,7 @@ static void process_files(void)
/* or does this line matches our last address regex */
|| (sed_cmd->end_match && old_matched
&& (regexec(sed_cmd->end_match,
pattern_space, 0, NULL, 0) == 0)
pattern_space, 0, NULL, 0) == 0)
)
);
}
@@ -1126,7 +1160,7 @@ static void process_files(void)
case 's':
if (!do_subst_command(sed_cmd, &pattern_space))
break;
dbg("do_subst_command succeeeded:'%s'", pattern_space);
dbg("do_subst_command succeeded:'%s'", pattern_space);
substituted |= 1;
/* handle p option */
@@ -1374,6 +1408,19 @@ int sed_main(int argc UNUSED_PARAM, char **argv)
{
unsigned opt;
llist_t *opt_e, *opt_f;
char *opt_i;
#if ENABLE_LONG_OPTS
static const char sed_longopts[] ALIGN1 =
/* name has_arg short */
"in-place\0" Optional_argument "i"
"regexp-extended\0" No_argument "r"
"quiet\0" No_argument "n"
"silent\0" No_argument "n"
"expression\0" Required_argument "e"
"file\0" Required_argument "f";
#endif
int status = EXIT_SUCCESS;
INIT_G();
@@ -1382,17 +1429,21 @@ int sed_main(int argc UNUSED_PARAM, char **argv)
if (ENABLE_FEATURE_CLEAN_UP) atexit(sed_free_and_close_stuff);
/* Lie to autoconf when it starts asking stupid questions. */
if (argv[1] && !strcmp(argv[1], "--version")) {
if (argv[1] && strcmp(argv[1], "--version") == 0) {
puts("This is not GNU sed version 4.0");
return 0;
}
/* do normal option parsing */
opt_e = opt_f = NULL;
opt_i = NULL;
opt_complementary = "e::f::" /* can occur multiple times */
"nn"; /* count -n */
IF_LONG_OPTS(applet_long_options = sed_longopts);
/* -i must be first, to match OPT_in_place definition */
opt = getopt32(argv, "irne:f:", &opt_e, &opt_f,
opt = getopt32(argv, "i::rne:f:", &opt_i, &opt_e, &opt_f,
&G.be_quiet); /* counter for -n */
//argc -= optind;
argv += optind;
@@ -1474,8 +1525,13 @@ int sed_main(int argc UNUSED_PARAM, char **argv)
fclose(G.nonstdout);
G.nonstdout = stdout;
/* unlink(argv[i]); */
xrename(G.outname, argv[i]);
if (opt_i) {
char *backupname = xasprintf("%s%s", argv[i], opt_i);
xrename(argv[i], backupname);
free(backupname);
}
/* else unlink(argv[i]); - rename below does this */
xrename(G.outname, argv[i]); //TODO: rollback backup on error?
free(G.outname);
G.outname = NULL;
+76 -137
View File
@@ -14,7 +14,7 @@
* add :help command
* :map macros
* if mark[] values were line numbers rather than pointers
* it would be easier to change the mark when add/delete lines
* it would be easier to change the mark when add/delete lines
* More intelligence in refresh()
* ":r !cmd" and "!cmd" to filter text through an external command
* A true "undo" facility
@@ -136,14 +136,6 @@
//config: cursor position using "ESC [ 6 n" escape sequence, then read stdin.
//config:
//config: This is not clean but helps a lot on serial lines and such.
//config:
//config:config FEATURE_VI_OPTIMIZE_CURSOR
//config: bool "Optimize cursor movement"
//config: default y
//config: depends on VI
//config: help
//config: This will make the cursor movement faster, but requires more memory
//config: and it makes the applet a tiny bit larger.
//applet:IF_VI(APPLET(vi, BB_DIR_BIN, BB_SUID_DROP))
@@ -154,12 +146,12 @@
//usage:#define vi_full_usage "\n\n"
//usage: "Edit FILE\n"
//usage: IF_FEATURE_VI_COLON(
//usage: "\n -c Initial command to run ($EXINIT also available)"
//usage: "\n -c CMD Initial command to run ($EXINIT also available)"
//usage: )
//usage: IF_FEATURE_VI_READONLY(
//usage: "\n -R Read-only"
//usage: )
//usage: "\n -H Short help regarding available features"
//usage: "\n -H List available features"
#include "libbb.h"
/* Should be after libbb.h: on some systems regex.h needs sys/types.h: */
@@ -202,20 +194,29 @@ enum {
MAX_SCR_ROWS = CONFIG_FEATURE_VI_MAX_LEN,
};
/* vt102 typical ESC sequence */
/* terminal standout start/normal ESC sequence */
#define SOs "\033[7m"
#define SOn "\033[0m"
/* terminal bell sequence */
#define bell "\007"
/* Clear-end-of-line and Clear-end-of-screen ESC sequence */
#define Ceol "\033[K"
#define Ceos "\033[J"
/* Cursor motion arbitrary destination ESC sequence */
#define CMrc "\033[%u;%uH"
/* Cursor motion up and down ESC sequence */
#define CMup "\033[A"
#define CMdown "\n"
/* VT102 ESC sequences.
* See "Xterm Control Sequences"
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
*/
/* Inverse/Normal text */
#define ESC_BOLD_TEXT "\033[7m"
#define ESC_NORM_TEXT "\033[0m"
/* Bell */
#define ESC_BELL "\007"
/* Clear-to-end-of-line */
#define ESC_CLEAR2EOL "\033[K"
/* Clear-to-end-of-screen.
* (We use default param here.
* Full sequence is "ESC [ <num> J",
* <num> is 0/1/2 = "erase below/above/all".)
*/
#define ESC_CLEAR2EOS "\033[J"
/* Cursor to given coordinate (1,1: top left) */
#define ESC_SET_CURSOR_POS "\033[%u;%uH"
//UNUSED
///* Cursor up and down */
//#define ESC_CURSOR_UP "\033[A"
//#define ESC_CURSOR_DOWN "\n"
#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
// cmds modifying text[]
@@ -303,9 +304,6 @@ struct globals {
int lmc_len; // length of last_modifying_cmd
char *ioq, *ioq_start; // pointer to string for get_one_char to "read"
#endif
#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
int last_row; // where the cursor was last moved to
#endif
#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME
int my_pid;
#endif
@@ -389,7 +387,6 @@ struct globals {
#define lmc_len (G.lmc_len )
#define ioq (G.ioq )
#define ioq_start (G.ioq_start )
#define last_row (G.last_row )
#define my_pid (G.my_pid )
#define last_search_pattern (G.last_search_pattern)
@@ -470,10 +467,7 @@ static int file_size(const char *); // what is the byte size of "fn"
// file_insert might reallocate text[]!
static int file_insert(const char *, char *, int);
static int file_write(char *, char *, char *);
#if !ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
#define place_cursor(a, b, optimize) place_cursor(a, b)
#endif
static void place_cursor(int, int, int);
static void place_cursor(int, int);
static void screen_erase(void);
static void clear_to_eol(void);
static void clear_to_eos(void);
@@ -558,7 +552,8 @@ int vi_main(int argc, char **argv)
}
#endif
vi_setops = VI_AUTOINDENT | VI_SHOWMATCH | VI_IGNORECASE;
// autoindent is not default in vim 7.3
vi_setops = /*VI_AUTOINDENT |*/ VI_SHOWMATCH | VI_IGNORECASE;
// 1- process $HOME/.exrc file (not inplemented yet)
// 2- process EXINIT variable from environment
// 3- process command line args
@@ -584,7 +579,7 @@ int vi_main(int argc, char **argv)
#if ENABLE_FEATURE_VI_COLON
case 'c': // cmd line vi command
if (*optarg)
initial_cmds[initial_cmds[0] != 0] = xstrndup(optarg, MAX_INPUT_LEN);
initial_cmds[initial_cmds[0] != NULL] = xstrndup(optarg, MAX_INPUT_LEN);
break;
#endif
case 'H':
@@ -599,15 +594,19 @@ int vi_main(int argc, char **argv)
// The argv array can be used by the ":next" and ":rewind" commands
argv += optind;
argc -= optind;
save_argc = argc;
optind = 0;
//----- This is the main file handling loop --------------
save_argc = argc;
optind = 0;
// "Save cursor, use alternate screen buffer, clear screen"
write1("\033[?1049h");
while (1) {
edit_file(argv[optind]); /* param might be NULL */
if (++optind >= argc)
break;
}
// "Use normal screen buffer, restore cursor"
write1("\033[?1049l");
//-----------------------------------------------------------
return 0;
@@ -1191,7 +1190,7 @@ static void colon(char *buf)
char *argp;
#endif
i = 0; // offset into args
// only blank is regarded as args delmiter. What about tab '\t' ?
// only blank is regarded as args delimiter. What about tab '\t'?
if (!args[0] || strcasecmp(args, "all") == 0) {
// print out values of all options
#if ENABLE_FEATURE_VI_SETOPTS
@@ -1930,11 +1929,11 @@ static int find_range(char **start, char **stop, char c)
dot_end(); // find NL
q = dot;
} else {
// nothing -- this causes any other values of c to
// represent the one-character range under the
// cursor. this is correct for ' ' and 'l', but
// perhaps no others.
//
// nothing -- this causes any other values of c to
// represent the one-character range under the
// cursor. this is correct for ' ' and 'l', but
// perhaps no others.
//
}
if (q < p) {
t = q;
@@ -2176,7 +2175,7 @@ static void show_help(void)
"\n\tPattern searches with / and ?"
#endif
#if ENABLE_FEATURE_VI_DOT_CMD
"\n\tLast command repeat with \'.\'"
"\n\tLast command repeat with ."
#endif
#if ENABLE_FEATURE_VI_YANKMARK
"\n\tLine marking with 'x"
@@ -2187,7 +2186,7 @@ static void show_help(void)
//redundant: usage text says this too: "\n\tReadonly with -R command line arg"
#endif
#if ENABLE_FEATURE_VI_SET
"\n\tSome colon mode commands with \':\'"
"\n\tSome colon mode commands with :"
#endif
#if ENABLE_FEATURE_VI_SETOPTS
"\n\tSettable options with \":set\""
@@ -2592,107 +2591,56 @@ static int file_write(char *fn, char *first, char *last)
// 23,0 ... 23,79 <- status line
//----- Move the cursor to row x col (count from 0, not 1) -------
static void place_cursor(int row, int col, int optimize)
static void place_cursor(int row, int col)
{
char cm1[sizeof(CMrc) + sizeof(int)*3 * 2];
#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
enum {
SZ_UP = sizeof(CMup),
SZ_DN = sizeof(CMdown),
SEQ_SIZE = SZ_UP > SZ_DN ? SZ_UP : SZ_DN,
};
char cm2[SEQ_SIZE * 5 + 32]; // bigger than worst case size
#endif
char *cm;
char cm1[sizeof(ESC_SET_CURSOR_POS) + sizeof(int)*3 * 2];
if (row < 0) row = 0;
if (row >= rows) row = rows - 1;
if (col < 0) col = 0;
if (col >= columns) col = columns - 1;
//----- 1. Try the standard terminal ESC sequence
sprintf(cm1, CMrc, row + 1, col + 1);
cm = cm1;
#if ENABLE_FEATURE_VI_OPTIMIZE_CURSOR
if (optimize && col < 16) {
char *screenp;
int Rrow = last_row;
int diff = Rrow - row;
if (diff < -5 || diff > 5)
goto skip;
//----- find the minimum # of chars to move cursor -------------
//----- 2. Try moving with discreet chars (Newline, [back]space, ...)
cm2[0] = '\0';
// move to the correct row
while (row < Rrow) {
// the cursor has to move up
strcat(cm2, CMup);
Rrow--;
}
while (row > Rrow) {
// the cursor has to move down
strcat(cm2, CMdown);
Rrow++;
}
// now move to the correct column
strcat(cm2, "\r"); // start at col 0
// just send out orignal source char to get to correct place
screenp = &screen[row * columns]; // start of screen line
strncat(cm2, screenp, col);
// pick the shortest cursor motion to send out
if (strlen(cm2) < strlen(cm)) {
cm = cm2;
}
skip: ;
}
last_row = row;
#endif /* FEATURE_VI_OPTIMIZE_CURSOR */
write1(cm);
sprintf(cm1, ESC_SET_CURSOR_POS, row + 1, col + 1);
write1(cm1);
}
//----- Erase from cursor to end of line -----------------------
static void clear_to_eol(void)
{
write1(Ceol); // Erase from cursor to end of line
write1(ESC_CLEAR2EOL);
}
static void go_bottom_and_clear_to_eol(void)
{
place_cursor(rows - 1, 0, FALSE); // go to bottom of screen
clear_to_eol(); // erase to end of line
place_cursor(rows - 1, 0);
clear_to_eol();
}
//----- Erase from cursor to end of screen -----------------------
static void clear_to_eos(void)
{
write1(Ceos); // Erase from cursor to end of screen
write1(ESC_CLEAR2EOS);
}
//----- Start standout mode ------------------------------------
static void standout_start(void) // send "start reverse video" sequence
static void standout_start(void)
{
write1(SOs); // Start reverse video mode
write1(ESC_BOLD_TEXT);
}
//----- End standout mode --------------------------------------
static void standout_end(void) // send "end reverse video" sequence
static void standout_end(void)
{
write1(SOn); // End reverse video mode
write1(ESC_NORM_TEXT);
}
//----- Flash the screen --------------------------------------
static void flash(int h)
{
standout_start(); // send "start reverse video" sequence
standout_start();
redraw(TRUE);
mysleep(h);
standout_end(); // send "end reverse video" sequence
standout_end();
redraw(TRUE);
}
@@ -2703,7 +2651,7 @@ static void Indicate_Error(void)
return; // generate a random command
#endif
if (!err_method) {
write1(bell); // send out a bell character
write1(ESC_BELL);
} else {
flash(10);
}
@@ -2749,7 +2697,7 @@ static void show_status_line(void)
}
have_status_msg = 0;
}
place_cursor(crow, ccol, FALSE); // put cursor back in correct place
place_cursor(crow, ccol); // put cursor back in correct place
}
fflush_all();
}
@@ -2761,12 +2709,12 @@ static void status_line_bold(const char *format, ...)
va_list args;
va_start(args, format);
strcpy(status_buffer, SOs); // Terminal standout mode on
vsprintf(status_buffer + sizeof(SOs)-1, format, args);
strcat(status_buffer, SOn); // Terminal standout mode off
strcpy(status_buffer, ESC_BOLD_TEXT);
vsprintf(status_buffer + sizeof(ESC_BOLD_TEXT)-1, format, args);
strcat(status_buffer, ESC_NORM_TEXT);
va_end(args);
have_status_msg = 1 + sizeof(SOs) + sizeof(SOn) - 2;
have_status_msg = 1 + sizeof(ESC_BOLD_TEXT) + sizeof(ESC_NORM_TEXT) - 2;
}
// format status buffer
@@ -2798,8 +2746,8 @@ static void print_literal(char *buf, const char *s)
c = *s;
c_is_no_print = (c & 0x80) && !Isprint(c);
if (c_is_no_print) {
strcpy(d, SOn);
d += sizeof(SOn)-1;
strcpy(d, ESC_NORM_TEXT);
d += sizeof(ESC_NORM_TEXT)-1;
c = '.';
}
if (c < ' ' || c == 0x7f) {
@@ -2811,8 +2759,8 @@ static void print_literal(char *buf, const char *s)
*d++ = c;
*d = '\0';
if (c_is_no_print) {
strcpy(d, SOs);
d += sizeof(SOs)-1;
strcpy(d, ESC_BOLD_TEXT);
d += sizeof(ESC_BOLD_TEXT)-1;
}
if (*s == '\n') {
*d++ = '$';
@@ -2894,8 +2842,8 @@ static int format_edit_status(void)
//----- Force refresh of all Lines -----------------------------
static void redraw(int full_screen)
{
place_cursor(0, 0, FALSE); // put cursor in correct place
clear_to_eos(); // tell terminal to erase display
place_cursor(0, 0);
clear_to_eos();
screen_erase(); // erase the internal screen buffer
last_status_cksum = 0; // force status update
refresh(full_screen); // this will redraw the entire display
@@ -3035,22 +2983,13 @@ static void refresh(int full_screen)
if (changed) {
// copy changed part of buffer to virtual screen
memcpy(sp+cs, out_buf+cs, ce-cs+1);
// move cursor to column of first change
//if (offset != old_offset) {
// // place_cursor is still too stupid
// // to handle offsets correctly
// place_cursor(li, cs, FALSE);
//} else {
place_cursor(li, cs, TRUE);
//}
place_cursor(li, cs);
// write line out to terminal
fwrite(&sp[cs], ce - cs + 1, 1, stdout);
}
}
place_cursor(crow, ccol, TRUE);
place_cursor(crow, ccol);
old_offset = offset;
#undef old_offset
@@ -3220,9 +3159,9 @@ static void do_cmd(int c)
break;
case 12: // ctrl-L force redraw whole screen
case 18: // ctrl-R force redraw
place_cursor(0, 0, FALSE); // put cursor in correct place
clear_to_eos(); // tel terminal to erase display
mysleep(10);
place_cursor(0, 0);
clear_to_eos();
//mysleep(10); // why???
screen_erase(); // erase the internal screen buffer
last_status_cksum = 0; // force status update
refresh(TRUE); // this will redraw the entire display
@@ -4141,7 +4080,7 @@ static void crash_test()
if (msg[0]) {
printf("\n\n%d: \'%c\' %s\n\n\n%s[Hit return to continue]%s",
totalcmds, last_input_char, msg, SOs, SOn);
totalcmds, last_input_char, msg, ESC_BOLD_TEXT, ESC_NORM_TEXT);
fflush_all();
while (safe_read(STDIN_FILENO, d, 1) > 0) {
if (d[0] == '\n' || d[0] == '\r')
+8 -2
View File
@@ -7,8 +7,14 @@
# instead of the default 0:0 660.
#
# Syntax:
# %s %d:%d %s
# devicename_regex user:group mode
# [-]devicename_regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
# [-]$ENVVAR=regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
# [-]@maj,min[-min2] user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
#
# [-]: do not stop on this match, continue reading mdev.conf
# =: move, >: move and create a symlink
# !: do not create device node
# @|$|*: run@cmd if $ACTION=add, $cmd if $ACTION=remove, *cmd in all cases
null 0:0 666
zero 0:0 666
+6 -3
View File
@@ -7,10 +7,14 @@
# instead of the default 0:0 660.
#
# Syntax:
# [-]devicename_regex user:group mode [>|=path] [@|$|*cmd args...]
# [-]devicename_regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
# [-]$ENVVAR=regex user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
# [-]@maj,min[-min2] user:group mode [=path]|[>path]|[!] [@|$|*cmd args...]
#
# [-]: do not stop on this match, continue reading mdev.conf
# =: move, >: move and create a symlink
# @|$|*: run $cmd on delete, @cmd on create, *cmd on both
# !: do not create device node
# @|$|*: run cmd if $ACTION=remove, @cmd if $ACTION=add, *cmd in all cases
# support module loading on hotplug
$MODALIAS=.* root:root 660 @modprobe "$MODALIAS"
@@ -49,7 +53,6 @@ sr[0-9]* root:cdrom 660 @ln -sf $MDEV cdrom
fd[0-9]* root:floppy 660
# net devices
-net/.* root:root 600 @nameif
tun[0-9]* root:root 600 =net/
tap[0-9]* root:root 600 =net/
+32 -17
View File
@@ -728,10 +728,27 @@ static int FAST_FUNC fileAction(const char *fileName,
int depth IF_NOT_FEATURE_FIND_MAXDEPTH(UNUSED_PARAM))
{
int r;
int same_fs = 1;
#if ENABLE_FEATURE_FIND_XDEV
if (S_ISDIR(statbuf->st_mode) && G.xdev_count) {
int i;
for (i = 0; i < G.xdev_count; i++) {
if (G.xdev_dev[i] == statbuf->st_dev)
goto found;
}
//bb_error_msg("'%s': not same fs", fileName);
same_fs = 0;
found: ;
}
#endif
#if ENABLE_FEATURE_FIND_MAXDEPTH
if (depth < G.minmaxdepth[0])
return TRUE; /* skip this, continue recursing */
if (depth < G.minmaxdepth[0]) {
if (same_fs)
return TRUE; /* skip this, continue recursing */
return SKIP; /* stop recursing */
}
if (depth > G.minmaxdepth[1])
return SKIP; /* stop recursing */
#endif
@@ -747,21 +764,11 @@ static int FAST_FUNC fileAction(const char *fileName,
return SKIP;
}
#endif
#if ENABLE_FEATURE_FIND_XDEV
/* -xdev stops on mountpoints, but AFTER mountpoit itself
* is processed as usual */
if (S_ISDIR(statbuf->st_mode)) {
if (G.xdev_count) {
int i;
for (i = 0; i < G.xdev_count; i++) {
if (G.xdev_dev[i] == statbuf->st_dev)
goto found;
}
return SKIP;
found: ;
}
if (!same_fs) {
return SKIP;
}
#endif
/* Cannot return 0: our caller, recursive_action(),
* will perror() and skip dirs (if called on dir) */
@@ -831,6 +838,11 @@ static action*** parse_params(char **argv)
PARM_name ,
PARM_iname ,
IF_FEATURE_FIND_PATH( PARM_path ,)
#if ENABLE_DESKTOP
/* -wholename is a synonym for -path */
/* We support it because Linux kernel's "make tags" uses it */
IF_FEATURE_FIND_PATH( PARM_wholename ,)
#endif
IF_FEATURE_FIND_PATH( PARM_ipath ,)
IF_FEATURE_FIND_REGEX( PARM_regex ,)
IF_FEATURE_FIND_TYPE( PARM_type ,)
@@ -866,9 +878,12 @@ static action*** parse_params(char **argv)
IF_FEATURE_FIND_EXEC( "-exec\0" )
IF_FEATURE_FIND_PAREN( "(\0" )
/* All options/actions starting from here require argument */
"-name\0"
"-iname\0"
"-name\0"
"-iname\0"
IF_FEATURE_FIND_PATH( "-path\0" )
#if ENABLE_DESKTOP
IF_FEATURE_FIND_PATH( "-wholename\0")
#endif
IF_FEATURE_FIND_PATH( "-ipath\0" )
IF_FEATURE_FIND_REGEX( "-regex\0" )
IF_FEATURE_FIND_TYPE( "-type\0" )
@@ -1076,7 +1091,7 @@ static action*** parse_params(char **argv)
ap->iname = (parm == PARM_iname);
}
#if ENABLE_FEATURE_FIND_PATH
else if (parm == PARM_path || parm == PARM_ipath) {
else if (parm == PARM_path IF_DESKTOP(|| parm == PARM_wholename) || parm == PARM_ipath) {
action_path *ap;
dbg("%d", __LINE__);
ap = ALLOC_ACTION(path);
+33 -6
View File
@@ -344,10 +344,34 @@ static int grep_file(FILE *file)
while (pattern_ptr) {
gl = (grep_list_data_t *)pattern_ptr->data;
if (FGREP_FLAG) {
found |= (((option_mask32 & OPT_i)
? strcasestr(line, gl->pattern)
: strstr(line, gl->pattern)
) != NULL);
char *match;
char *str = line;
opt_f_again:
match = ((option_mask32 & OPT_i)
? strcasestr(str, gl->pattern)
: strstr(str, gl->pattern)
);
if (match) {
if (option_mask32 & OPT_x) {
if (match != str)
goto opt_f_not_found;
if (str[strlen(gl->pattern)] != '\0')
goto opt_f_not_found;
} else
if (option_mask32 & OPT_w) {
char c = (match != str) ? match[-1] : ' ';
if (!isalnum(c) && c != '_') {
c = match[strlen(gl->pattern)];
if (!c || (!isalnum(c) && c != '_'))
goto opt_f_found;
}
str = match + 1;
goto opt_f_again;
}
opt_f_found:
found = 1;
opt_f_not_found: ;
}
} else {
if (!(gl->flg_mem_alocated_compiled & COMPILED)) {
gl->flg_mem_alocated_compiled |= COMPILED;
@@ -376,7 +400,8 @@ static int grep_file(FILE *file)
if (option_mask32 & OPT_x) {
found = (gl->matched_range.rm_so == 0
&& line[gl->matched_range.rm_eo] == '\0');
} else if (!(option_mask32 & OPT_w)) {
} else
if (!(option_mask32 & OPT_w)) {
found = 1;
} else {
char c = ' ';
@@ -387,6 +412,8 @@ static int grep_file(FILE *file)
if (!c || (!isalnum(c) && c != '_'))
found = 1;
}
//BUG: "echo foop foo | grep -w foo" should match, but doesn't:
//we bail out on first "mismatch" because it's not a word.
}
}
}
@@ -638,7 +665,7 @@ int grep_main(int argc UNUSED_PARAM, char **argv)
if (opts & OPT_C) {
/* -C unsets prev -A and -B, but following -A or -B
may override it */
* may override it */
if (!(opts & OPT_A)) /* not overridden */
lines_after = Copt;
if (!(opts & OPT_B)) /* not overridden */
+21 -20
View File
@@ -70,12 +70,12 @@ INSERT
IF_TEST(APPLET_NOFORK([, test, BB_DIR_USR_BIN, BB_SUID_DROP, test))
IF_TEST(APPLET_NOFORK([[, test, BB_DIR_USR_BIN, BB_SUID_DROP, test))
IF_ACPID(APPLET(acpid, BB_DIR_SBIN, BB_SUID_DROP))
IF_ADDGROUP(APPLET(addgroup, BB_DIR_BIN, BB_SUID_DROP))
IF_ADDUSER(APPLET(adduser, BB_DIR_BIN, BB_SUID_DROP))
IF_ADDGROUP(APPLET(addgroup, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_ADDUSER(APPLET(adduser, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_ADJTIMEX(APPLET(adjtimex, BB_DIR_SBIN, BB_SUID_DROP))
IF_AR(APPLET(ar, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_ARP(APPLET(arp, BB_DIR_SBIN, BB_SUID_DROP))
IF_ARPING(APPLET(arping, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_ARPING(APPLET(arping, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_AWK(APPLET_NOEXEC(awk, awk, BB_DIR_USR_BIN, BB_SUID_DROP, awk))
IF_BASENAME(APPLET_NOFORK(basename, basename, BB_DIR_USR_BIN, BB_SUID_DROP, basename))
IF_BBCONFIG(APPLET(bbconfig, BB_DIR_BIN, BB_SUID_DROP))
@@ -86,7 +86,7 @@ IF_BZIP2(APPLET(bzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_CAL(APPLET(cal, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_CAT(APPLET_NOFORK(cat, cat, BB_DIR_BIN, BB_SUID_DROP, cat))
IF_CATV(APPLET(catv, BB_DIR_BIN, BB_SUID_DROP))
IF_CHAT(APPLET(chat, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_CHAT(APPLET(chat, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_CHATTR(APPLET(chattr, BB_DIR_BIN, BB_SUID_DROP))
IF_CHCON(APPLET(chcon, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_CHGRP(APPLET_NOEXEC(chgrp, chgrp, BB_DIR_BIN, BB_SUID_DROP, chgrp))
@@ -111,8 +111,8 @@ IF_CUT(APPLET_NOEXEC(cut, cut, BB_DIR_USR_BIN, BB_SUID_DROP, cut))
IF_DC(APPLET(dc, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_DD(APPLET_NOEXEC(dd, dd, BB_DIR_BIN, BB_SUID_DROP, dd))
IF_DEALLOCVT(APPLET(deallocvt, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_DELGROUP(APPLET_ODDNAME(delgroup, deluser, BB_DIR_BIN, BB_SUID_DROP, delgroup))
IF_DELUSER(APPLET(deluser, BB_DIR_BIN, BB_SUID_DROP))
IF_DELGROUP(APPLET_ODDNAME(delgroup, deluser, BB_DIR_USR_SBIN, BB_SUID_DROP, delgroup))
IF_DELUSER(APPLET(deluser, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_DEVFSD(APPLET(devfsd, BB_DIR_SBIN, BB_SUID_DROP))
IF_DEVMEM(APPLET(devmem, BB_DIR_SBIN, BB_SUID_DROP))
IF_DF(APPLET(df, BB_DIR_BIN, BB_SUID_DROP))
@@ -136,7 +136,7 @@ IF_EJECT(APPLET(eject, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_ENV(APPLET_NOEXEC(env, env, BB_DIR_USR_BIN, BB_SUID_DROP, env))
IF_ENVDIR(APPLET_ODDNAME(envdir, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envdir))
IF_ENVUIDGID(APPLET_ODDNAME(envuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, envuidgid))
IF_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, BB_DIR_USR_BIN, BB_SUID_DROP, ether_wake))
IF_ETHER_WAKE(APPLET_ODDNAME(ether-wake, ether_wake, BB_DIR_USR_SBIN, BB_SUID_DROP, ether_wake))
IF_EXPAND(APPLET(expand, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_EXPR(APPLET(expr, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_FAKEIDENTD(APPLET(fakeidentd, BB_DIR_USR_SBIN, BB_SUID_DROP))
@@ -144,7 +144,7 @@ IF_FALSE(APPLET_NOFORK(false, false, BB_DIR_BIN, BB_SUID_DROP, false))
IF_FBSET(APPLET(fbset, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_FBSPLASH(APPLET(fbsplash, BB_DIR_SBIN, BB_SUID_DROP))
IF_FDFLUSH(APPLET_ODDNAME(fdflush, freeramdisk, BB_DIR_BIN, BB_SUID_DROP, fdflush))
IF_FDFORMAT(APPLET(fdformat, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_FDFORMAT(APPLET(fdformat, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_FDISK(APPLET(fdisk, BB_DIR_SBIN, BB_SUID_DROP))
IF_FGCONSOLE(APPLET(fgconsole, BB_DIR_USR_BIN, BB_SUID_DROP))
/* Benefits from suid root: better access to /dev/BLOCKDEVs: */
@@ -182,7 +182,7 @@ IF_HWCLOCK(APPLET(hwclock, BB_DIR_SBIN, BB_SUID_DROP))
IF_IFCONFIG(APPLET(ifconfig, BB_DIR_SBIN, BB_SUID_DROP))
IF_IFUPDOWN(APPLET_ODDNAME(ifdown, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifdown))
IF_IFENSLAVE(APPLET(ifenslave, BB_DIR_SBIN, BB_SUID_DROP))
IF_IFPLUGD(APPLET(ifplugd, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_IFPLUGD(APPLET(ifplugd, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_IFUPDOWN(APPLET_ODDNAME(ifup, ifupdown, BB_DIR_SBIN, BB_SUID_DROP, ifup))
IF_INETD(APPLET(inetd, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_INOTIFYD(APPLET(inotifyd, BB_DIR_SBIN, BB_SUID_DROP))
@@ -193,20 +193,20 @@ IF_IONICE(APPLET(ionice, BB_DIR_BIN, BB_SUID_DROP))
|| ENABLE_FEATURE_IP_LINK \
|| ENABLE_FEATURE_IP_TUNNEL \
|| ENABLE_FEATURE_IP_RULE
IF_IP(APPLET(ip, BB_DIR_BIN, BB_SUID_DROP))
IF_IP(APPLET(ip, BB_DIR_SBIN, BB_SUID_DROP))
#endif
IF_IPADDR(APPLET(ipaddr, BB_DIR_BIN, BB_SUID_DROP))
IF_IPADDR(APPLET(ipaddr, BB_DIR_SBIN, BB_SUID_DROP))
IF_IPCALC(APPLET(ipcalc, BB_DIR_BIN, BB_SUID_DROP))
IF_IPCRM(APPLET(ipcrm, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_IPCS(APPLET(ipcs, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_IPLINK(APPLET(iplink, BB_DIR_BIN, BB_SUID_DROP))
IF_IPROUTE(APPLET(iproute, BB_DIR_BIN, BB_SUID_DROP))
IF_IPRULE(APPLET(iprule, BB_DIR_BIN, BB_SUID_DROP))
IF_IPTUNNEL(APPLET(iptunnel, BB_DIR_BIN, BB_SUID_DROP))
IF_KBD_MODE(APPLET(kbd_mode, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_IPLINK(APPLET(iplink, BB_DIR_SBIN, BB_SUID_DROP))
IF_IPROUTE(APPLET(iproute, BB_DIR_SBIN, BB_SUID_DROP))
IF_IPRULE(APPLET(iprule, BB_DIR_SBIN, BB_SUID_DROP))
IF_IPTUNNEL(APPLET(iptunnel, BB_DIR_SBIN, BB_SUID_DROP))
IF_KBD_MODE(APPLET(kbd_mode, BB_DIR_BIN, BB_SUID_DROP))
IF_KILL(APPLET(kill, BB_DIR_BIN, BB_SUID_DROP))
IF_KILLALL(APPLET_ODDNAME(killall, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall))
IF_KILLALL5(APPLET_ODDNAME(killall5, kill, BB_DIR_USR_BIN, BB_SUID_DROP, killall5))
IF_KILLALL5(APPLET_ODDNAME(killall5, kill, BB_DIR_USR_SBIN, BB_SUID_DROP, killall5))
IF_KLOGD(APPLET(klogd, BB_DIR_SBIN, BB_SUID_DROP))
IF_LAST(APPLET(last, BB_DIR_USR_BIN, BB_SUID_DROP))
//IF_LENGTH(APPLET_NOFORK(length, length, BB_DIR_USR_BIN, BB_SUID_DROP, length))
@@ -288,7 +288,7 @@ IF_PWD(APPLET_NOFORK(pwd, pwd, BB_DIR_BIN, BB_SUID_DROP, pwd))
IF_RAIDAUTORUN(APPLET(raidautorun, BB_DIR_SBIN, BB_SUID_DROP))
IF_RDATE(APPLET(rdate, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_RDEV(APPLET(rdev, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_READAHEAD(APPLET(readahead, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_READAHEAD(APPLET(readahead, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_READLINK(APPLET(readlink, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_READPROFILE(APPLET(readprofile, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_REALPATH(APPLET(realpath, BB_DIR_USR_BIN, BB_SUID_DROP))
@@ -303,7 +303,7 @@ IF_RMDIR(APPLET_NOFORK(rmdir, rmdir, BB_DIR_BIN, BB_SUID_DROP, rmdir))
IF_ROUTE(APPLET(route, BB_DIR_SBIN, BB_SUID_DROP))
IF_RPM(APPLET(rpm, BB_DIR_BIN, BB_SUID_DROP))
IF_RPM2CPIO(APPLET(rpm2cpio, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_RTCWAKE(APPLET(rtcwake, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_RTCWAKE(APPLET(rtcwake, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_RUN_PARTS(APPLET_ODDNAME(run-parts, run_parts, BB_DIR_BIN, BB_SUID_DROP, run_parts))
IF_RUNCON(APPLET(runcon, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_RUNLEVEL(APPLET(runlevel, BB_DIR_SBIN, BB_SUID_DROP))
@@ -328,6 +328,7 @@ IF_SETSEBOOL(APPLET(setsebool, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_SETSID(APPLET(setsid, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_SETUIDGID(APPLET_ODDNAME(setuidgid, chpst, BB_DIR_USR_BIN, BB_SUID_DROP, setuidgid))
IF_SHA1SUM(APPLET_NOEXEC(sha1sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha1sum))
IF_SHA3SUM(APPLET_NOEXEC(sha3sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha3sum))
IF_SHA256SUM(APPLET_NOEXEC(sha256sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha256sum))
IF_SHA512SUM(APPLET_NOEXEC(sha512sum, md5_sha1_sum, BB_DIR_USR_BIN, BB_SUID_DROP, sha512sum))
IF_SHOWKEY(APPLET(showkey, BB_DIR_USR_BIN, BB_SUID_DROP))
@@ -365,7 +366,7 @@ IF_TELNETD(APPLET(telnetd, BB_DIR_USR_SBIN, BB_SUID_DROP))
IF_TEST(APPLET_NOFORK(test, test, BB_DIR_USR_BIN, BB_SUID_DROP, test))
#if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT
IF_TFTP(APPLET(tftp, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_TFTPD(APPLET(tftpd, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_TFTPD(APPLET(tftpd, BB_DIR_USR_SBIN, BB_SUID_DROP))
#endif
IF_TIME(APPLET(time, BB_DIR_USR_BIN, BB_SUID_DROP))
IF_TIMEOUT(APPLET(timeout, BB_DIR_USR_BIN, BB_SUID_DROP))
+4 -3
View File
@@ -121,6 +121,7 @@ typedef struct archive_handle_t {
#define ARCHIVE_DONT_RESTORE_PERM (1 << 6)
#define ARCHIVE_NUMERIC_OWNER (1 << 7)
#define ARCHIVE_O_TRUNC (1 << 8)
#define ARCHIVE_REMEMBER_NAMES (1 << 9)
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
@@ -219,9 +220,9 @@ IF_DESKTOP(long long) int unpack_xz_stream(transformer_aux_data_t *aux, int src_
char* append_ext(char *filename, const char *expected_ext) FAST_FUNC;
int bbunpack(char **argv,
IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_aux_data_t *aux),
char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext),
const char *expected_ext
IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_aux_data_t *aux),
char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext),
const char *expected_ext
) FAST_FUNC;
void check_errors_in_children(int signo);
+52 -11
View File
@@ -406,25 +406,43 @@ struct ext2_super_block {
* Performance hints. Directory preallocation should only
* happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
*/
uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
uint8_t s_prealloc_blocks; /* Nr of blocks to try to preallocate*/
uint8_t s_prealloc_dir_blocks; /* Nr to preallocate for dirs */
uint16_t s_reserved_gdt_blocks; /* Per group table for online growth */
/*
* Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
*/
uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
uint32_t s_journal_inum; /* inode number of journal file */
/*D0*/ uint8_t s_journal_uuid[16]; /* uuid of journal superblock */
/*E0*/ uint32_t s_journal_inum; /* inode number of journal file */
uint32_t s_journal_dev; /* device number of journal file */
uint32_t s_last_orphan; /* start of list of inodes to delete */
uint32_t s_hash_seed[4]; /* HTREE hash seed */
uint8_t s_def_hash_version; /* Default hash version to use */
uint8_t s_jnl_backup_type; /* Default type of journal backup */
uint16_t s_reserved_word_pad;
uint32_t s_default_mount_opts;
/*100*/ uint32_t s_default_mount_opts;
uint32_t s_first_meta_bg; /* First metablock group */
/* ext3 additions */
uint32_t s_mkfs_time; /* When the filesystem was created */
uint32_t s_jnl_blocks[17]; /* Backup of the journal inode */
uint32_t s_reserved[172]; /* Padding to the end of the block */
/* 64bit support valid if EXT4_FEATURE_COMPAT_64BIT */
/*150*/ uint32_t s_blocks_count_hi; /* Blocks count */
uint32_t s_r_blocks_count_hi; /* Reserved blocks count */
uint32_t s_free_blocks_count_hi; /* Free blocks count */
uint16_t s_min_extra_isize; /* All inodes have at least # bytes */
uint16_t s_want_extra_isize; /* New inodes should reserve # bytes */
uint32_t s_flags; /* Miscellaneous flags */
uint16_t s_raid_stride; /* RAID stride */
uint16_t s_mmp_interval; /* # seconds to wait in MMP checking */
uint64_t s_mmp_block; /* Block for multi-mount protection */
uint32_t s_raid_stripe_width; /* blocks on all data disks (N*stride)*/
uint8_t s_log_groups_per_flex; /* FLEX_BG group size */
uint8_t s_reserved_char_pad2;
uint16_t s_reserved_pad;
uint32_t s_reserved[162]; /* Padding to the end of the block */
};
struct BUG_ext2_super_block {
char bug[sizeof(struct ext2_super_block) == 1024 ? 1 : -1];
};
/*
@@ -463,6 +481,7 @@ struct ext2_super_block {
#define EXT2_HAS_INCOMPAT_FEATURE(sb,mask) \
( EXT2_SB(sb)->s_feature_incompat & (mask) )
/* for s_feature_compat */
#define EXT2_FEATURE_COMPAT_DIR_PREALLOC 0x0001
#define EXT2_FEATURE_COMPAT_IMAGIC_INODES 0x0002
#define EXT3_FEATURE_COMPAT_HAS_JOURNAL 0x0004
@@ -470,23 +489,45 @@ struct ext2_super_block {
#define EXT2_FEATURE_COMPAT_RESIZE_INO 0x0010
#define EXT2_FEATURE_COMPAT_DIR_INDEX 0x0020
/* for s_feature_ro_compat */
#define EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER 0x0001
#define EXT2_FEATURE_RO_COMPAT_LARGE_FILE 0x0002
/* #define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 not used */
#define EXT2_FEATURE_RO_COMPAT_BTREE_DIR 0x0004 /* not used */
#define EXT4_FEATURE_RO_COMPAT_HUGE_FILE 0x0008
#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
#define EXT4_FEATURE_RO_COMPAT_DIR_NLINK 0x0020
#define EXT4_FEATURE_RO_COMPAT_EXTRA_ISIZE 0x0040
/* for s_feature_incompat */
#define EXT2_FEATURE_INCOMPAT_COMPRESSION 0x0001
#define EXT2_FEATURE_INCOMPAT_FILETYPE 0x0002
#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004 /* Needs recovery */
#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008 /* Journal device */
#define EXT3_FEATURE_INCOMPAT_RECOVER 0x0004
#define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV 0x0008
#define EXT2_FEATURE_INCOMPAT_META_BG 0x0010
#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040
#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040
#define EXT4_FEATURE_INCOMPAT_64BIT 0x0080
#define EXT4_FEATURE_INCOMPAT_MMP 0x0100
#define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200
#define EXT2_FEATURE_COMPAT_SUPP 0
#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE)
#define EXT2_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
#define EXT2_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
EXT2_FEATURE_INCOMPAT_META_BG)
#define EXT2_FEATURE_INCOMPAT_UNSUPPORTED (~EXT2_FEATURE_INCOMPAT_SUPP)
#define EXT2_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT2_FEATURE_RO_COMPAT_SUPP)
#define EXT3_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER| \
EXT2_FEATURE_RO_COMPAT_LARGE_FILE| \
EXT2_FEATURE_RO_COMPAT_BTREE_DIR)
#define EXT3_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE| \
EXT3_FEATURE_INCOMPAT_RECOVER| \
EXT2_FEATURE_INCOMPAT_META_BG)
#define EXT3_FEATURE_INCOMPAT_UNSUPPORTED (~EXT3_FEATURE_INCOMPAT_SUPP)
#define EXT3_FEATURE_RO_COMPAT_UNSUPPORTED (~EXT3_FEATURE_RO_COMPAT_SUPP)
/*
* Default values for user and/or group using reserved blocks
+2 -2
View File
@@ -13,10 +13,10 @@ PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
/* Defined in appletlib.c (by including generated applet_tables.h) */
/* Keep in sync with applets/applet_tables.c! */
extern const char applet_names[];
extern const char applet_names[] ALIGN1;
extern int (*const applet_main[])(int argc, char **argv);
extern const uint16_t applet_nameofs[];
extern const uint8_t applet_install_loc[];
extern const uint8_t applet_install_loc[] ALIGN1;
#if ENABLE_FEATURE_SUID || ENABLE_FEATURE_PREFER_APPLETS
# define APPLET_NAME(i) (applet_names + (applet_nameofs[i] & 0x0fff))
+12 -12
View File
@@ -64,7 +64,7 @@ extern struct group *fgetgrent(FILE *__stream);
/* Write the given entry onto the given stream. */
extern int putgrent(const struct group *__restrict __p,
FILE *__restrict __f);
FILE *__restrict __f);
#endif
/* Search for an entry with a matching group ID. */
@@ -82,32 +82,32 @@ extern struct group *getgrnam(const char *__name);
POSIX people would choose. */
extern int getgrent_r(struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
/* Search for an entry with a matching group ID. */
extern int getgrgid_r(gid_t __gid, struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
/* Search for an entry with a matching group name. */
extern int getgrnam_r(const char *__restrict __name,
struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
/* Read a group entry from STREAM. This function is not standardized
an probably never will. */
extern int fgetgrent_r(FILE *__restrict __stream,
struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
struct group *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct group **__restrict __result);
/* Store at most *NGROUPS members of the group set for USER into
*GROUPS. Also include GROUP. The actual number of groups found is
returned in *NGROUPS. Return -1 if the if *NGROUPS is too small. */
extern int getgrouplist(const char *__user, gid_t __group,
gid_t *__groups, int *__ngroups);
gid_t *__groups, int *__ngroups);
/* Initialize the group set for the current user
by reading the group database and using all groups
+30 -22
View File
@@ -333,6 +333,7 @@ enum { /* DO NOT CHANGE THESE VALUES! cp.c, mv.c, install.c depend on them. */
FILEUTILS_PRESERVE_SECURITY_CONTEXT = 1 << 9, /* -c */
FILEUTILS_SET_SECURITY_CONTEXT = 1 << 10,
#endif
FILEUTILS_IGNORE_CHMOD_ERR = 1 << 11,
};
#define FILEUTILS_CP_OPTSTR "pdRfilsLH" IF_SELINUX("c")
extern int remove_file(const char *path, int flags) FAST_FUNC;
@@ -795,7 +796,6 @@ void qsort_string_vector(char **sv, unsigned count) FAST_FUNC;
int safe_poll(struct pollfd *ufds, nfds_t nfds, int timeout_ms) FAST_FUNC;
char *safe_gethostname(void) FAST_FUNC;
char *safe_getdomainname(void) FAST_FUNC;
/* Convert each alpha char in str to lower-case */
char* str_tolower(char *str) FAST_FUNC;
@@ -1248,7 +1248,7 @@ extern void run_shell(const char *shell, int loginshell, const char *command, co
* Note that getpwuid result might need xstrdup'ing
* if there is a possibility of intervening getpwxxx() calls.
*/
const char *get_shell_name(void);
const char *get_shell_name(void) FAST_FUNC;
#if ENABLE_SELINUX
extern void renew_current_security_context(void) FAST_FUNC;
@@ -1286,6 +1286,7 @@ int sd_listen_fds(void);
#define SETUP_ENV_CHANGEENV (1 << 0)
#define SETUP_ENV_CLEARENV (1 << 1)
#define SETUP_ENV_TO_TMP (1 << 2)
#define SETUP_ENV_NO_CHDIR (1 << 4)
extern void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC;
extern int correct_password(const struct passwd *pw) FAST_FUNC;
/* Returns a malloced string */
@@ -1515,7 +1516,7 @@ struct smaprec {
procps_read_smaps(pid, total)
#endif
int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
void (*cb)(struct smaprec *, void *), void *data);
void (*cb)(struct smaprec *, void *), void *data);
typedef struct procps_status_t {
DIR *dir;
@@ -1611,8 +1612,8 @@ unsigned get_cpu_count(void) FAST_FUNC;
char *percent_decode_in_place(char *str, int strict) FAST_FUNC;
extern const char bb_uuenc_tbl_base64[];
extern const char bb_uuenc_tbl_std[];
extern const char bb_uuenc_tbl_base64[] ALIGN1;
extern const char bb_uuenc_tbl_std[] ALIGN1;
void bb_uuencode(char *store, const void *s, int length, const char *tbl) FAST_FUNC;
enum {
BASE64_FLAG_UU_STOP = 0x100,
@@ -1635,8 +1636,12 @@ typedef struct sha512_ctx_t {
uint64_t hash[8];
uint8_t wbuffer[128]; /* always correctly aligned for uint64_t */
} sha512_ctx_t;
typedef struct sha3_ctx_t {
uint64_t state[25];
unsigned bytes_queued;
} sha3_ctx_t;
void md5_begin(md5_ctx_t *ctx) FAST_FUNC;
void md5_hash(md5_ctx_t *ctx, const void *data, size_t length) FAST_FUNC;
void md5_hash(md5_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
void md5_end(md5_ctx_t *ctx, void *resbuf) FAST_FUNC;
void sha1_begin(sha1_ctx_t *ctx) FAST_FUNC;
#define sha1_hash md5_hash
@@ -1647,6 +1652,9 @@ void sha256_begin(sha256_ctx_t *ctx) FAST_FUNC;
void sha512_begin(sha512_ctx_t *ctx) FAST_FUNC;
void sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
void sha512_end(sha512_ctx_t *ctx, void *resbuf) FAST_FUNC;
void sha3_begin(sha3_ctx_t *ctx) FAST_FUNC;
void sha3_hash(sha3_ctx_t *ctx, const void *buffer, size_t len) FAST_FUNC;
void sha3_end(sha3_ctx_t *ctx, void *resbuf) FAST_FUNC;
extern uint32_t *global_crc32_table;
uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC;
@@ -1693,24 +1701,24 @@ extern const char *applet_name;
* Therefore now we use #defines.
*/
/* "BusyBox vN.N.N (timestamp or extra_version)" */
extern const char bb_banner[];
extern const char bb_msg_memory_exhausted[];
extern const char bb_msg_invalid_date[];
extern const char bb_banner[] ALIGN1;
extern const char bb_msg_memory_exhausted[] ALIGN1;
extern const char bb_msg_invalid_date[] ALIGN1;
#define bb_msg_read_error "read error"
#define bb_msg_write_error "write error"
extern const char bb_msg_unknown[];
extern const char bb_msg_can_not_create_raw_socket[];
extern const char bb_msg_perm_denied_are_you_root[];
extern const char bb_msg_you_must_be_root[];
extern const char bb_msg_requires_arg[];
extern const char bb_msg_invalid_arg[];
extern const char bb_msg_standard_input[];
extern const char bb_msg_standard_output[];
extern const char bb_msg_unknown[] ALIGN1;
extern const char bb_msg_can_not_create_raw_socket[] ALIGN1;
extern const char bb_msg_perm_denied_are_you_root[] ALIGN1;
extern const char bb_msg_you_must_be_root[] ALIGN1;
extern const char bb_msg_requires_arg[] ALIGN1;
extern const char bb_msg_invalid_arg[] ALIGN1;
extern const char bb_msg_standard_input[] ALIGN1;
extern const char bb_msg_standard_output[] ALIGN1;
/* NB: (bb_hexdigits_upcase[i] | 0x20) -> lowercase hex digit */
extern const char bb_hexdigits_upcase[];
extern const char bb_hexdigits_upcase[] ALIGN1;
extern const char bb_path_wtmp_file[];
extern const char bb_path_wtmp_file[] ALIGN1;
/* Busybox mount uses either /proc/mounts or /etc/mtab to
* get the list of currently mounted filesystems */
@@ -1724,10 +1732,10 @@ extern const char bb_path_wtmp_file[];
#define bb_path_motd_file "/etc/motd"
#define bb_dev_null "/dev/null"
extern const char bb_busybox_exec_path[];
extern const char bb_busybox_exec_path[] ALIGN1;
/* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin,
* but I want to save a few bytes here */
extern const char bb_PATH_root_path[]; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */
extern const char bb_PATH_root_path[] ALIGN1; /* "PATH=/sbin:/usr/sbin:/bin:/usr/bin" */
#define bb_default_root_path (bb_PATH_root_path + sizeof("PATH"))
#define bb_default_path (bb_PATH_root_path + sizeof("PATH=/sbin:/usr/sbin"))
@@ -1757,7 +1765,7 @@ extern struct globals *const ptr_to_globals;
* If you change LIBBB_DEFAULT_LOGIN_SHELL,
* don't forget to change increment constant. */
#define LIBBB_DEFAULT_LOGIN_SHELL "-/bin/sh"
extern const char bb_default_login_shell[];
extern const char bb_default_login_shell[] ALIGN1;
/* "/bin/sh" */
#define DEFAULT_SHELL (bb_default_login_shell+1)
/* "sh" */
+13 -3
View File
@@ -205,6 +205,7 @@
#include <stdint.h>
typedef int bb__aliased_int FIX_ALIASING;
typedef long bb__aliased_long FIX_ALIASING;
typedef uint16_t bb__aliased_uint16_t FIX_ALIASING;
typedef uint32_t bb__aliased_uint32_t FIX_ALIASING;
@@ -212,7 +213,8 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING;
* a lvalue. This makes it more likely to not swap them by mistake
*/
#if defined(i386) || defined(__x86_64__) || defined(__powerpc__)
# define move_from_unaligned_int(v, intp) ((v) = *(bb__aliased_int*)(intp))
# define move_from_unaligned_int(v, intp) ((v) = *(bb__aliased_int*)(intp))
# define move_from_unaligned_long(v, longp) ((v) = *(bb__aliased_long*)(longp))
# define move_from_unaligned16(v, u16p) ((v) = *(bb__aliased_uint16_t*)(u16p))
# define move_from_unaligned32(v, u32p) ((v) = *(bb__aliased_uint32_t*)(u32p))
# define move_to_unaligned16(u16p, v) (*(bb__aliased_uint16_t*)(u16p) = (v))
@@ -221,11 +223,12 @@ typedef uint32_t bb__aliased_uint32_t FIX_ALIASING;
#else
/* performs reasonably well (gcc usually inlines memcpy here) */
# define move_from_unaligned_int(v, intp) (memcpy(&(v), (intp), sizeof(int)))
# define move_from_unaligned_long(v, longp) (memcpy(&(v), (longp), sizeof(long)))
# define move_from_unaligned16(v, u16p) (memcpy(&(v), (u16p), 2))
# define move_from_unaligned32(v, u32p) (memcpy(&(v), (u32p), 4))
# define move_to_unaligned16(u16p, v) do { \
uint16_t __t = (v); \
memcpy((u16p), &__t, 4); \
memcpy((u16p), &__t, 2); \
} while (0)
# define move_to_unaligned32(u32p, v) do { \
uint32_t __t = (v); \
@@ -284,7 +287,8 @@ typedef unsigned smalluint;
#define fdprintf dprintf
/* Useful for defeating gcc's alignment of "char message[]"-like data */
#if 1 /* if needed: !defined(arch1) && !defined(arch2) */
#if !defined(__s390__)
/* on s390[x], non-word-aligned data accesses require larger code */
# define ALIGN1 __attribute__((aligned(1)))
# define ALIGN2 __attribute__((aligned(2)))
# define ALIGN4 __attribute__((aligned(4)))
@@ -334,6 +338,12 @@ typedef unsigned smalluint;
# define MAXSYMLINKS SYMLOOP_MAX
#endif
#if defined(ANDROID) || defined(__ANDROID__)
# define BB_ADDITIONAL_PATH ":/system/sbin:/system/bin:/system/xbin"
# define SYS_ioprio_set __NR_ioprio_set
# define SYS_ioprio_get __NR_ioprio_get
#endif
/* ---- Who misses what? ------------------------------------ */
+12 -12
View File
@@ -63,7 +63,7 @@ extern struct passwd *fgetpwent(FILE *__stream);
/* Write the given entry onto the given stream. */
extern int putpwent(const struct passwd *__restrict __p,
FILE *__restrict __f);
FILE *__restrict __f);
#endif
/* Search for an entry with a matching user ID. */
@@ -81,25 +81,25 @@ extern struct passwd *getpwnam(const char *__name);
POSIX people would choose. */
extern int getpwent_r(struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
extern int getpwuid_r(uid_t __uid,
struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
extern int getpwnam_r(const char *__restrict __name,
struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
/* Read an entry from STREAM. This function is not standardized and
probably never will. */
extern int fgetpwent_r(FILE *__restrict __stream,
struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
struct passwd *__restrict __resultbuf,
char *__restrict __buffer, size_t __buflen,
struct passwd **__restrict __result);
POP_SAVED_FUNCTION_VISIBILITY
+7 -7
View File
@@ -79,21 +79,21 @@ extern int putspent(const struct spwd *__p, FILE *__stream);
/* Reentrant versions of some of the functions above */
extern int getspent_r(struct spwd *__result_buf, char *__buffer,
size_t __buflen, struct spwd **__result);
size_t __buflen, struct spwd **__result);
#endif
extern int getspnam_r(const char *__name, struct spwd *__result_buf,
char *__buffer, size_t __buflen,
struct spwd **__result);
char *__buffer, size_t __buflen,
struct spwd **__result);
#ifdef UNUSED_FOR_NOW
extern int sgetspent_r(const char *__string, struct spwd *__result_buf,
char *__buffer, size_t __buflen,
struct spwd **__result);
char *__buffer, size_t __buflen,
struct spwd **__result);
extern int fgetspent_r(FILE *__stream, struct spwd *__result_buf,
char *__buffer, size_t __buflen,
struct spwd **__result);
char *__buffer, size_t __buflen,
struct spwd **__result);
/* Protect password file against multi writers */
extern int lckpwdf(void);
+1 -1
View File
@@ -520,7 +520,7 @@ static pid_t run(const struct init_action *a)
/* Log the process name and args */
message(L_LOG, "starting pid %d, tty '%s': '%s'",
getpid(), a->terminal, a->command);
getpid(), a->terminal, a->command);
/* Now run it. The new program will take over this PID,
* so nothing further in init.c should be run. */
+10
View File
@@ -28,6 +28,16 @@ config MD5_SMALL
2 3.0 5088
3 (smallest) 5.1 4912
config SHA3_SMALL
int "SHA3: Trade bytes for speed (0:fast, 1:slow)"
default 1
range 0 1
help
Trade binary size versus speed for the sha3sum algorithm.
SHA3_SMALL=0 compared to SHA3_SMALL=1 (approximate):
64-bit x86: +270 bytes of code, 45% faster
32-bit x86: +450 bytes of code, 75% faster
config FEATURE_FAST_TOP
bool "Faster /proc scanning code (+100 bytes)"
default y
+16 -12
View File
@@ -140,10 +140,9 @@ void FAST_FUNC bb_show_usage(void)
}
#if NUM_APPLETS > 8
/* NB: any char pointer will work as well, not necessarily applet_names */
static int applet_name_compare(const void *name, const void *v)
static int applet_name_compare(const void *name, const void *idx)
{
int i = (const char *)v - applet_names;
int i = (int)(ptrdiff_t)idx - 1;
return strcmp(name, APPLET_NAME(i));
}
#endif
@@ -152,10 +151,12 @@ int FAST_FUNC find_applet_by_name(const char *name)
#if NUM_APPLETS > 8
/* Do a binary search to find the applet entry given the name. */
const char *p;
p = bsearch(name, applet_names, ARRAY_SIZE(applet_main), 1, applet_name_compare);
if (!p)
return -1;
return p - applet_names;
p = bsearch(name, (void*)(ptrdiff_t)1, ARRAY_SIZE(applet_main), 1, applet_name_compare);
/*
* if (!p) return -1;
* ^^^^^^^^^^^^^^^^^^ the code below will do this if p == NULL :)
*/
return (int)(ptrdiff_t)p - 1;
#else
/* A version which does not pull in bsearch */
int i = 0;
@@ -627,11 +628,11 @@ static int busybox_main(char **argv)
full_write2_str(bb_banner); /* reuse const string */
full_write2_str(" multi-call binary.\n"); /* reuse */
full_write2_str(
"Copyright (C) 1998-2011 Erik Andersen, Rob Landley, Denys Vlasenko\n"
"and others. Licensed under GPLv2.\n"
"See source distribution for full notice.\n"
"BusyBox is copyrighted by many authors between 1998-2012.\n"
"Licensed under GPLv2. See source distribution for detailed\n"
"copyright notices.\n"
"\n"
"Usage: busybox [function] [arguments]...\n"
"Usage: busybox [function [arguments]...]\n"
" or: busybox --list"IF_FEATURE_INSTALLER("[-full]")"\n"
IF_FEATURE_INSTALLER(
" or: busybox --install [-s] [DIR]\n"
@@ -747,8 +748,11 @@ void FAST_FUNC run_applet_no_and_exit(int applet_no, char **argv)
/* Special case. POSIX says "test --help"
* should be no different from e.g. "test --foo". */
//TODO: just compare applet_no with APPLET_NO_test
if (!ENABLE_TEST || strcmp(applet_name, "test") != 0)
if (!ENABLE_TEST || strcmp(applet_name, "test") != 0) {
/* If you want "foo --help" to return 0: */
/*xfunc_error_retval = 0;*/
bb_show_usage();
}
}
if (ENABLE_FEATURE_SUID)
check_suid(applet_no);
+3 -6
View File
@@ -41,12 +41,6 @@ int FAST_FUNC correct_password(const struct passwd *pw)
char *unencrypted, *encrypted;
const char *correct;
int r;
#if ENABLE_FEATURE_SHADOWPASSWDS
/* Using _r function to avoid pulling in static buffers */
struct spwd spw;
char buffer[256];
#endif
/* fake salt. crypt() can choke otherwise. */
correct = "aa";
if (!pw) {
@@ -55,7 +49,10 @@ int FAST_FUNC correct_password(const struct passwd *pw)
}
correct = pw->pw_passwd;
#if ENABLE_FEATURE_SHADOWPASSWDS
/* Using _r function to avoid pulling in static buffers */
if ((correct[0] == 'x' || correct[0] == '*') && !correct[1]) {
struct spwd spw;
char buffer[256];
/* getspnam_r may return 0 yet set result to NULL.
* At least glibc 2.4 does this. Be extra paranoid here. */
struct spwd *result = NULL;
+1 -1
View File
@@ -8,7 +8,7 @@
#include "libbb.h"
const char *get_shell_name(void)
const char* FAST_FUNC get_shell_name(void)
{
struct passwd *pw;
char *shell;
+282 -12
View File
@@ -31,6 +31,11 @@ static ALWAYS_INLINE uint64_t rotr64(uint64_t x, unsigned n)
return (x >> n) | (x << (64 - n));
}
/* rotl64 only used for sha3 currently */
static ALWAYS_INLINE uint64_t rotl64(uint64_t x, unsigned n)
{
return (x << n) | (x >> (64 - n));
}
/* Feed data through a temporary buffer.
* The internal buffer remembers previous data until it has 64
@@ -51,7 +56,7 @@ static void FAST_FUNC common64_hash(md5_ctx_t *ctx, const void *buffer, size_t l
len -= remaining;
buffer = (const char *)buffer + remaining;
bufpos += remaining;
/* clever way to do "if (bufpos != 64) break; ... ; bufpos = 0;" */
/* Clever way to do "if (bufpos != N) break; ... ; bufpos = 0;" */
bufpos -= 64;
if (bufpos != 0)
break;
@@ -185,10 +190,9 @@ static void FAST_FUNC md5_process_block64(md5_ctx_t *ctx)
int i;
uint32_t temp;
# if BB_BIG_ENDIAN
for (i = 0; i < 16; i++)
words[i] = SWAP_LE32(words[i]);
# endif
if (BB_BIG_ENDIAN)
for (i = 0; i < 16; i++)
words[i] = SWAP_LE32(words[i]);
# if MD5_SMALL == 3
pc = C_array;
@@ -462,12 +466,13 @@ void FAST_FUNC md5_end(md5_ctx_t *ctx, void *resbuf)
common64_end(ctx, /*swap_needed:*/ BB_BIG_ENDIAN);
/* The MD5 result is in little endian byte order */
#if BB_BIG_ENDIAN
ctx->hash[0] = SWAP_LE32(ctx->hash[0]);
ctx->hash[1] = SWAP_LE32(ctx->hash[1]);
ctx->hash[2] = SWAP_LE32(ctx->hash[2]);
ctx->hash[3] = SWAP_LE32(ctx->hash[3]);
#endif
if (BB_BIG_ENDIAN) {
ctx->hash[0] = SWAP_LE32(ctx->hash[0]);
ctx->hash[1] = SWAP_LE32(ctx->hash[1]);
ctx->hash[2] = SWAP_LE32(ctx->hash[2]);
ctx->hash[3] = SWAP_LE32(ctx->hash[3]);
}
memcpy(resbuf, ctx->hash, sizeof(ctx->hash[0]) * 4);
}
@@ -834,7 +839,7 @@ void FAST_FUNC sha512_hash(sha512_ctx_t *ctx, const void *buffer, size_t len)
len -= remaining;
buffer = (const char *)buffer + remaining;
bufpos += remaining;
/* clever way to do "if (bufpos != 128) break; ... ; bufpos = 0;" */
/* Clever way to do "if (bufpos != N) break; ... ; bufpos = 0;" */
bufpos -= 128;
if (bufpos != 0)
break;
@@ -896,3 +901,268 @@ void FAST_FUNC sha512_end(sha512_ctx_t *ctx, void *resbuf)
}
memcpy(resbuf, ctx->hash, sizeof(ctx->hash));
}
/*
* The Keccak sponge function, designed by Guido Bertoni, Joan Daemen,
* Michael Peeters and Gilles Van Assche. For more information, feedback or
* questions, please refer to our website: http://keccak.noekeon.org/
*
* Implementation by Ronny Van Keer,
* hereby denoted as "the implementer".
*
* To the extent possible under law, the implementer has waived all copyright
* and related or neighboring rights to the source code in this file.
* http://creativecommons.org/publicdomain/zero/1.0/
*
* Busybox modifications (C) Lauri Kasanen, under the GPLv2.
*/
#if CONFIG_SHA3_SMALL < 0
# define SHA3_SMALL 0
#elif CONFIG_SHA3_SMALL > 1
# define SHA3_SMALL 1
#else
# define SHA3_SMALL CONFIG_SHA3_SMALL
#endif
enum {
SHA3_IBLK_BYTES = 72, /* 576 bits / 8 */
};
/*
* In the crypto literature this function is usually called Keccak-f().
*/
static void sha3_process_block72(uint64_t *state)
{
enum { NROUNDS = 24 };
/* Elements should be 64-bit, but top half is always zero or 0x80000000.
* We encode 63rd bits in a separate word below.
* Same is true for 31th bits, which lets us use 16-bit table instead of 64-bit.
* The speed penalty is lost in the noise.
*/
static const uint16_t IOTA_CONST[NROUNDS] = {
0x0001,
0x8082,
0x808a,
0x8000,
0x808b,
0x0001,
0x8081,
0x8009,
0x008a,
0x0088,
0x8009,
0x000a,
0x808b,
0x008b,
0x8089,
0x8003,
0x8002,
0x0080,
0x800a,
0x000a,
0x8081,
0x8080,
0x0001,
0x8008,
};
/* bit for CONST[0] is in msb: 0011 0011 0000 0111 1101 1101 */
const uint32_t IOTA_CONST_bit63 = (uint32_t)(0x3307dd00);
/* bit for CONST[0] is in msb: 0001 0110 0011 1000 0001 1011 */
const uint32_t IOTA_CONST_bit31 = (uint32_t)(0x16381b00);
static const uint8_t ROT_CONST[24] = {
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, 2, 14,
27, 41, 56, 8, 25, 43, 62, 18, 39, 61, 20, 44,
};
static const uint8_t PI_LANE[24] = {
10, 7, 11, 17, 18, 3, 5, 16, 8, 21, 24, 4,
15, 23, 19, 13, 12, 2, 20, 14, 22, 9, 6, 1,
};
/*static const uint8_t MOD5[10] = { 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, };*/
unsigned x, y;
unsigned round;
if (BB_BIG_ENDIAN) {
for (x = 0; x < 25; x++) {
state[x] = SWAP_LE64(state[x]);
}
}
for (round = 0; round < NROUNDS; ++round) {
/* Theta */
{
uint64_t BC[10];
for (x = 0; x < 5; ++x) {
BC[x + 5] = BC[x] = state[x]
^ state[x + 5] ^ state[x + 10]
^ state[x + 15] ^ state[x + 20];
}
/* Using 2x5 vector above eliminates the need to use
* BC[MOD5[x+N]] trick below to fetch BC[(x+N) % 5],
* and the code is a bit _smaller_.
*/
for (x = 0; x < 5; ++x) {
uint64_t temp = BC[x + 4] ^ rotl64(BC[x + 1], 1);
state[x] ^= temp;
state[x + 5] ^= temp;
state[x + 10] ^= temp;
state[x + 15] ^= temp;
state[x + 20] ^= temp;
}
}
/* Rho Pi */
if (SHA3_SMALL) {
uint64_t t1 = state[1];
for (x = 0; x < 24; ++x) {
uint64_t t0 = state[PI_LANE[x]];
state[PI_LANE[x]] = rotl64(t1, ROT_CONST[x]);
t1 = t0;
}
} else {
/* Especially large benefit for 32-bit arch (75% faster):
* 64-bit rotations by non-constant usually are SLOW on those.
* We resort to unrolling here.
* This optimizes out PI_LANE[] and ROT_CONST[],
* but generates 300-500 more bytes of code.
*/
uint64_t t0;
uint64_t t1 = state[1];
#define RhoPi_twice(x) \
t0 = state[PI_LANE[x ]]; \
state[PI_LANE[x ]] = rotl64(t1, ROT_CONST[x ]); \
t1 = state[PI_LANE[x+1]]; \
state[PI_LANE[x+1]] = rotl64(t0, ROT_CONST[x+1]);
RhoPi_twice(0); RhoPi_twice(2);
RhoPi_twice(4); RhoPi_twice(6);
RhoPi_twice(8); RhoPi_twice(10);
RhoPi_twice(12); RhoPi_twice(14);
RhoPi_twice(16); RhoPi_twice(18);
RhoPi_twice(20); RhoPi_twice(22);
#undef RhoPi_twice
}
/* Chi */
for (y = 0; y <= 20; y += 5) {
uint64_t BC0, BC1, BC2, BC3, BC4;
BC0 = state[y + 0];
BC1 = state[y + 1];
BC2 = state[y + 2];
state[y + 0] = BC0 ^ ((~BC1) & BC2);
BC3 = state[y + 3];
state[y + 1] = BC1 ^ ((~BC2) & BC3);
BC4 = state[y + 4];
state[y + 2] = BC2 ^ ((~BC3) & BC4);
state[y + 3] = BC3 ^ ((~BC4) & BC0);
state[y + 4] = BC4 ^ ((~BC0) & BC1);
}
/* Iota */
state[0] ^= IOTA_CONST[round]
| (uint32_t)((IOTA_CONST_bit31 << round) & 0x80000000)
| (uint64_t)((IOTA_CONST_bit63 << round) & 0x80000000) << 32;
}
if (BB_BIG_ENDIAN) {
for (x = 0; x < 25; x++) {
state[x] = SWAP_LE64(state[x]);
}
}
}
void FAST_FUNC sha3_begin(sha3_ctx_t *ctx)
{
memset(ctx, 0, sizeof(*ctx));
}
void FAST_FUNC sha3_hash(sha3_ctx_t *ctx, const void *buffer, size_t len)
{
#if SHA3_SMALL
const uint8_t *data = buffer;
unsigned bufpos = ctx->bytes_queued;
while (1) {
unsigned remaining = SHA3_IBLK_BYTES - bufpos;
if (remaining > len)
remaining = len;
len -= remaining;
/* XOR data into buffer */
while (remaining != 0) {
uint8_t *buf = (uint8_t*)ctx->state;
buf[bufpos] ^= *data++;
bufpos++;
remaining--;
}
/* Clever way to do "if (bufpos != N) break; ... ; bufpos = 0;" */
bufpos -= SHA3_IBLK_BYTES;
if (bufpos != 0)
break;
/* Buffer is filled up, process it */
sha3_process_block72(ctx->state);
/*bufpos = 0; - already is */
}
ctx->bytes_queued = bufpos + SHA3_IBLK_BYTES;
#else
/* +50 bytes code size, but a bit faster because of long-sized XORs */
const uint8_t *data = buffer;
unsigned bufpos = ctx->bytes_queued;
/* If already data in queue, continue queuing first */
while (len != 0 && bufpos != 0) {
uint8_t *buf = (uint8_t*)ctx->state;
buf[bufpos] ^= *data++;
len--;
bufpos++;
if (bufpos == SHA3_IBLK_BYTES) {
bufpos = 0;
goto do_block;
}
}
/* Absorb complete blocks */
while (len >= SHA3_IBLK_BYTES) {
/* XOR data onto beginning of state[].
* We try to be efficient - operate one word at a time, not byte.
* Careful wrt unaligned access: can't just use "*(long*)data"!
*/
unsigned count = SHA3_IBLK_BYTES / sizeof(long);
long *buf = (long*)ctx->state;
do {
long v;
move_from_unaligned_long(v, (long*)data);
*buf++ ^= v;
data += sizeof(long);
} while (--count);
len -= SHA3_IBLK_BYTES;
do_block:
sha3_process_block72(ctx->state);
}
/* Queue remaining data bytes */
while (len != 0) {
uint8_t *buf = (uint8_t*)ctx->state;
buf[bufpos] ^= *data++;
bufpos++;
len--;
}
ctx->bytes_queued = bufpos;
#endif
}
void FAST_FUNC sha3_end(sha3_ctx_t *ctx, void *resbuf)
{
/* Padding */
uint8_t *buf = (uint8_t*)ctx->state;
buf[ctx->bytes_queued] ^= 1;
buf[SHA3_IBLK_BYTES - 1] ^= 0x80;
sha3_process_block72(ctx->state);
/* Output */
memcpy(resbuf, ctx->state, 64);
}
+2 -2
View File
@@ -97,7 +97,7 @@ char* FAST_FUNC INET_rresolve(struct sockaddr_in *s_in, int numeric, uint32_t ne
if (s_in->sin_family != AF_INET) {
#ifdef DEBUG
bb_error_msg("rresolve: unsupported address family %d!",
s_in->sin_family);
s_in->sin_family);
#endif
errno = EAFNOSUPPORT;
return NULL;
@@ -195,7 +195,7 @@ char* FAST_FUNC INET6_rresolve(struct sockaddr_in6 *sin6, int numeric)
if (sin6->sin6_family != AF_INET6) {
#ifdef DEBUG
bb_error_msg("rresolve: unsupported address family %d!",
sin6->sin6_family);
sin6->sin6_family);
#endif
errno = EAFNOSUPPORT;
return NULL;
+4 -7
View File
@@ -20,18 +20,15 @@
int FAST_FUNC get_linux_version_code(void)
{
struct utsname name;
char *s;
char *s, *t;
int i, r;
if (uname(&name) == -1) {
bb_perror_msg("can't get system information");
return 0;
}
uname(&name); /* never fails */
s = name.release;
r = 0;
for (i = 0; i < 3; i++) {
r = r * 256 + atoi(strtok(s, "."));
t = strtok(s, ".");
r = r * 256 + (t ? atoi(t) : 0);
s = NULL;
}
return r;
+7 -8
View File
@@ -1352,8 +1352,7 @@ static void load_history(line_input_t *st_parm)
/* fill temp_h[], retaining only last MAX_HISTORY lines */
memset(temp_h, 0, sizeof(temp_h));
idx = 0;
if (!ENABLE_FEATURE_EDITING_SAVE_ON_EXIT)
st_parm->cnt_history_in_file = 0;
st_parm->cnt_history_in_file = 0;
while ((line = xmalloc_fgetline(fp)) != NULL) {
if (line[0] == '\0') {
free(line);
@@ -1361,8 +1360,7 @@ static void load_history(line_input_t *st_parm)
}
free(temp_h[idx]);
temp_h[idx] = line;
if (!ENABLE_FEATURE_EDITING_SAVE_ON_EXIT)
st_parm->cnt_history_in_file++;
st_parm->cnt_history_in_file++;
idx++;
if (idx == st_parm->max_history)
idx = 0;
@@ -2529,9 +2527,9 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
/* Delete word forward */
int nc, sc = cursor;
ctrl_right();
nc = cursor;
input_backward(cursor - sc);
while (--nc >= cursor)
nc = cursor - sc;
input_backward(nc);
while (--nc >= 0)
input_delete(1);
break;
}
@@ -2731,7 +2729,8 @@ int FAST_FUNC read_line_input(const char* prompt, char* command, int maxsize)
{
fputs(prompt, stdout);
fflush_all();
fgets(command, maxsize, stdin);
if (!fgets(command, maxsize, stdin))
return -1;
return strlen(command);
}
+3 -3
View File
@@ -150,9 +150,9 @@ int FAST_FUNC set_loop(char **device, const char *file, unsigned long long offse
}
/* If this block device already set up right, re-use it.
(Yes this is racy, but associating two loop devices with the same
file isn't pretty either. In general, mounting the same file twice
without using losetup manually is problematic.)
* (Yes this is racy, but associating two loop devices with the same
* file isn't pretty either. In general, mounting the same file twice
* without using losetup manually is problematic.)
*/
} else
if (strcmp(file, (char *)loopinfo.lo_file_name) != 0
+6 -1
View File
@@ -107,6 +107,10 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags)
* an error. */
if ((mode != -1) && (chmod(path, mode) < 0)) {
fail_msg = "set permissions of";
if (flags & FILEUTILS_IGNORE_CHMOD_ERR) {
flags = 0;
goto print_err;
}
break;
}
goto ret0;
@@ -116,8 +120,9 @@ int FAST_FUNC bb_make_directory(char *path, long mode, int flags)
*s = c;
} /* while (1) */
bb_perror_msg("can't %s directory '%s'", fail_msg, path);
flags = -1;
print_err:
bb_perror_msg("can't %s directory '%s'", fail_msg, path);
goto ret;
ret0:
flags = 0;
+42
View File
@@ -0,0 +1,42 @@
/*
* Copyright 2012, Denys Vlasenko
*
* Licensed under GPLv2, see file LICENSE in this source tree.
*/
//kbuild:lib-y += missing_syscalls.o
/*#include <linux/timex.h> - for struct timex, but may collide with <time.h> */
#include <sys/syscall.h>
#include "libbb.h"
#if defined(ANDROID) || defined(__ANDROID__)
pid_t getsid(pid_t pid)
{
return syscall(__NR_getsid, pid);
}
int stime(const time_t *t)
{
struct timeval tv;
tv.tv_sec = *t;
tv.tv_usec = 0;
return settimeofday(&tv, NULL);
}
int sethostname(const char *name, size_t len)
{
return syscall(__NR_sethostname, name, len);
}
struct timex;
int adjtimex(struct timex *buf)
{
return syscall(__NR_adjtimex, buf);
}
int pivot_root(const char *new_root, const char *put_old)
{
return syscall(__NR_pivot_root, new_root, put_old);
}
#endif
+4 -2
View File
@@ -180,7 +180,7 @@ static char *skip_fields(char *str, int count)
#if ENABLE_FEATURE_TOPMEM || ENABLE_PMAP
int FAST_FUNC procps_read_smaps(pid_t pid, struct smaprec *total,
void (*cb)(struct smaprec *, void *), void *data)
void (*cb)(struct smaprec *, void *), void *data)
{
FILE *file;
struct smaprec currec;
@@ -425,7 +425,7 @@ procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
if (n < 11)
continue; /* bogus data, get next /proc/XXX */
# if ENABLE_FEATURE_TOP_SMP_PROCESS
if (n < 11+15)
if (n == 11)
sp->last_seen_on_cpu = 0;
# endif
@@ -583,6 +583,8 @@ void FAST_FUNC read_cmdline(char *buf, int col, unsigned pid, const char *comm)
buf[sz] = '\0';
while (--sz >= 0 && buf[sz] == '\0')
continue;
/* Prevent basename("process foo/bar") = "bar" */
strchrnul(buf, ' ')[0] = '\0';
base = bb_basename(buf); /* before we replace argv0's NUL with space */
while (sz >= 0) {
if ((unsigned char)(buf[sz]) < ' ')
+10 -5
View File
@@ -15,7 +15,10 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout)
const char *seq;
int n;
/* Known escape sequences for cursor and function keys */
/* Known escape sequences for cursor and function keys.
* See "Xterm Control Sequences"
* http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
*/
static const char esccmds[] ALIGN1 = {
'O','A' |0x80,KEYCODE_UP ,
'O','B' |0x80,KEYCODE_DOWN ,
@@ -44,6 +47,8 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout)
/* ESC [ 1 ; 4 x, where x = A/B/C/D: Alt-Shift-<arrow> */
/* ESC [ 1 ; 5 x, where x = A/B/C/D: Ctrl-<arrow> - implemented below */
/* ESC [ 1 ; 6 x, where x = A/B/C/D: Ctrl-Shift-<arrow> */
/* ESC [ 1 ; 7 x, where x = A/B/C/D: Ctrl-Alt-<arrow> */
/* ESC [ 1 ; 8 x, where x = A/B/C/D: Ctrl-Alt-Shift-<arrow> */
'[','H' |0x80,KEYCODE_HOME , /* xterm */
'[','F' |0x80,KEYCODE_END , /* xterm */
/* [ESC] ESC [ [2] H - [Alt-][Shift-]Home (End similarly?) */
@@ -64,10 +69,10 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout)
'[','7','~' |0x80,KEYCODE_HOME , /* vt100? linux vt? or what? */
'[','8','~' |0x80,KEYCODE_END , /* vt100? linux vt? or what? */
#if 0
'[','1','1','~'|0x80,KEYCODE_FUN1 ,
'[','1','2','~'|0x80,KEYCODE_FUN2 ,
'[','1','3','~'|0x80,KEYCODE_FUN3 ,
'[','1','4','~'|0x80,KEYCODE_FUN4 ,
'[','1','1','~'|0x80,KEYCODE_FUN1 , /* old xterm, deprecated by ESC O P */
'[','1','2','~'|0x80,KEYCODE_FUN2 , /* old xterm... */
'[','1','3','~'|0x80,KEYCODE_FUN3 , /* old xterm... */
'[','1','4','~'|0x80,KEYCODE_FUN4 , /* old xterm... */
'[','1','5','~'|0x80,KEYCODE_FUN5 ,
/* [ESC] ESC [ 1 5 [;2] ~ - [Alt-][Shift-]F5 */
'[','1','7','~'|0x80,KEYCODE_FUN6 ,
+1 -1
View File
@@ -33,7 +33,7 @@ int FAST_FUNC remove_file(const char *path, int flags)
int status = 0;
if (!(flags & FILEUTILS_RECUR)) {
bb_error_msg("%s: is a directory", path);
bb_error_msg("'%s' is a directory", path);
return -1;
}
-22
View File
@@ -50,25 +50,3 @@ char* FAST_FUNC safe_gethostname(void)
uname(&uts);
return xstrndup(!uts.nodename[0] ? "?" : uts.nodename, sizeof(uts.nodename));
}
/*
* On success return the current malloced and NUL terminated domainname.
* On error return malloced and NUL terminated string "?".
* This is an illegal first character for a domainname.
* The returned malloced string must be freed by the caller.
*/
char* FAST_FUNC safe_getdomainname(void)
{
#if defined(__linux__)
/* The field domainname of struct utsname is Linux specific. */
struct utsname uts;
uname(&uts);
return xstrndup(!uts.domainname[0] ? "?" : uts.domainname, sizeof(uts.domainname));
#else
/* We really don't care about people with domain names wider than most screens */
char buf[256];
int r = getdomainname(buf, sizeof(buf));
buf[sizeof(buf)-1] = '\0';
return xstrdup(r < 0 ? "?" : buf);
#endif
}
+1 -1
View File
@@ -10,7 +10,7 @@
#include <selinux/context.h>
context_t FAST_FUNC set_security_context_component(security_context_t cur_context,
char *user, char *role, char *type, char *range)
char *user, char *role, char *type, char *range)
{
context_t con = context_new(cur_context);
if (!con)
+5 -3
View File
@@ -37,9 +37,11 @@ void FAST_FUNC setup_environment(const char *shell, int flags, const struct pass
/* Change the current working directory to be the home directory
* of the user */
if (chdir(pw->pw_dir)) {
xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
if (!(flags & SETUP_ENV_NO_CHDIR)) {
if (chdir(pw->pw_dir) != 0) {
bb_error_msg("can't change directory to '%s'", pw->pw_dir);
xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
}
}
if (flags & SETUP_ENV_CLEARENV) {
+3 -3
View File
@@ -39,7 +39,7 @@ void FAST_FUNC bb_signals(int sigs, void (*f)(int))
while (sigs) {
if (sigs & bit) {
sigs &= ~bit;
sigs -= bit;
signal(sig_no, f);
}
sig_no++;
@@ -60,7 +60,7 @@ void FAST_FUNC bb_signals_recursive_norestart(int sigs, void (*f)(int))
while (sigs) {
if (sigs & bit) {
sigs &= ~bit;
sigs -= bit;
sigaction_set(sig_no, &sa);
}
sig_no++;
@@ -97,7 +97,7 @@ void FAST_FUNC kill_myself_with_sig(int sig)
signal(sig, SIG_DFL);
sig_unblock(sig);
raise(sig);
_exit(EXIT_FAILURE); /* Should not reach it */
_exit(sig | 128); /* Should not reach it */
}
void FAST_FUNC signal_SA_RESTART_empty_mask(int sig, void (*handler)(int))
+1 -1
View File
@@ -59,7 +59,7 @@ unsigned type FAST_FUNC xstrtou(_range_sfx)(const char *numstr, int base,
}
/* Note: trailing space is an error.
It would be easy enough to allow though if desired. */
* It would be easy enough to allow though if desired. */
if (*e)
goto inval;
chk_range:
+2 -2
View File
@@ -355,13 +355,13 @@ void FAST_FUNC xsetuid(uid_t uid)
void FAST_FUNC xchdir(const char *path)
{
if (chdir(path))
bb_perror_msg_and_die("chdir(%s)", path);
bb_perror_msg_and_die("can't change directory to '%s'", path);
}
void FAST_FUNC xchroot(const char *path)
{
if (chroot(path))
bb_perror_msg_and_die("can't change root directory to %s", path);
bb_perror_msg_and_die("can't change root directory to '%s'", path);
xchdir("/");
}
+7 -7
View File
@@ -300,8 +300,8 @@ struct group *getgrgid(gid_t gid)
* to have been created as a reentrant version of the non-standard
* functions getspuid. Why getspuid was added, I do not know. */
int getspuid_r(uid_t uid, struct spwd *__restrict resultbuf,
char *__restrict buffer, size_t buflen,
struct spwd **__restrict result)
char *__restrict buffer, size_t buflen,
struct spwd **__restrict result)
{
int rv;
struct passwd *pp;
@@ -403,8 +403,8 @@ void endpwent(void)
int getpwent_r(struct passwd *__restrict resultbuf,
char *__restrict buffer, size_t buflen,
struct passwd **__restrict result)
char *__restrict buffer, size_t buflen,
struct passwd **__restrict result)
{
int rv;
@@ -451,8 +451,8 @@ void endgrent(void)
}
int getgrent_r(struct group *__restrict resultbuf,
char *__restrict buffer, size_t buflen,
struct group **__restrict result)
char *__restrict buffer, size_t buflen,
struct group **__restrict result)
{
int rv;
@@ -501,7 +501,7 @@ void endspent(void)
}
int getspent_r(struct spwd *resultbuf, char *buffer,
size_t buflen, struct spwd **result)
size_t buflen, struct spwd **result)
{
int rv;
+2 -2
View File
@@ -8,8 +8,8 @@
* for details.
*/
//applet:IF_ADD_SHELL( APPLET_ODDNAME(add-shell , add_remove_shell, BB_DIR_USR_BIN, BB_SUID_DROP, add_shell ))
//applet:IF_REMOVE_SHELL(APPLET_ODDNAME(remove-shell, add_remove_shell, BB_DIR_USR_BIN, BB_SUID_DROP, remove_shell))
//applet:IF_ADD_SHELL( APPLET_ODDNAME(add-shell , add_remove_shell, BB_DIR_USR_SBIN, BB_SUID_DROP, add_shell ))
//applet:IF_REMOVE_SHELL(APPLET_ODDNAME(remove-shell, add_remove_shell, BB_DIR_USR_SBIN, BB_SUID_DROP, remove_shell))
//kbuild:lib-$(CONFIG_ADD_SHELL) += add-remove-shell.o
//kbuild:lib-$(CONFIG_REMOVE_SHELL) += add-remove-shell.o
+14 -8
View File
@@ -9,9 +9,9 @@
*/
//usage:#define adduser_trivial_usage
//usage: "[OPTIONS] USER"
//usage: "[OPTIONS] USER [GROUP]"
//usage:#define adduser_full_usage "\n\n"
//usage: "Add a user\n"
//usage: "Create new user, or add USER to GROUP\n"
//usage: "\n -h DIR Home directory"
//usage: "\n -g GECOS GECOS field"
//usage: "\n -s SHELL Login shell"
@@ -80,7 +80,7 @@ static void passwd_study(struct passwd *p)
}
}
static void addgroup_wrapper(struct passwd *p, const char *group_name)
static int addgroup_wrapper(struct passwd *p, const char *group_name)
{
char *argv[6];
@@ -110,7 +110,7 @@ static void addgroup_wrapper(struct passwd *p, const char *group_name)
argv[5] = NULL;
}
spawn_and_wait(argv);
return spawn_and_wait(argv);
}
static void passwd_wrapper(const char *login_name) NORETURN;
@@ -162,9 +162,9 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
pw.pw_shell = (char *)get_shell_name();
pw.pw_dir = NULL;
/* exactly one non-option arg */
/* at most two non-option args */
/* disable interactive passwd for system accounts */
opt_complementary = "=1:SD:u+";
opt_complementary = "?2:SD:u+";
if (sizeof(pw.pw_uid) == sizeof(int)) {
opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &pw.pw_uid);
} else {
@@ -175,9 +175,16 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
}
}
argv += optind;
pw.pw_name = argv[0];
if (!opts && argv[1]) {
/* if called with two non-option arguments, adduser
* will add an existing user to an existing group.
*/
return addgroup_wrapper(&pw, argv[1]);
}
/* fill in the passwd struct */
pw.pw_name = argv[0];
die_if_bad_username(pw.pw_name);
if (!pw.pw_dir) {
/* create string for $HOME if not specified already */
@@ -205,7 +212,6 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
}
if (ENABLE_FEATURE_CLEAN_UP)
free(p);
#if ENABLE_FEATURE_SHADOWPASSWDS
/* /etc/shadow fields:
* 1. username
+14 -1
View File
@@ -548,8 +548,15 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
* a session leader - which is quite possible for getty!
*/
pid = getpid();
if (getsid(0) != pid)
if (getsid(0) != pid) {
//for debugging:
//bb_perror_msg_and_die("setsid failed:"
// " pid %d ppid %d"
// " sid %d pgid %d",
// pid, getppid(),
// getsid(0), getpgid(0));
bb_perror_msg_and_die("setsid");
}
/* Looks like we are already a session leader.
* In this case (setsid failed) we may still have ctty,
* and it may be different from tty we need to control!
@@ -561,8 +568,14 @@ int getty_main(int argc UNUSED_PARAM, char **argv)
*/
fd = open("/dev/tty", O_RDWR | O_NONBLOCK);
if (fd >= 0) {
/* TIOCNOTTY sends SIGHUP to the foreground
* process group - which may include us!
* Make sure to not die on it:
*/
sighandler_t old = signal(SIGHUP, SIG_IGN);
ioctl(fd, TIOCNOTTY);
close(fd);
signal(SIGHUP, old);
}
}
+2 -1
View File
@@ -37,7 +37,8 @@ static const struct pam_conv conv = {
enum {
TIMEOUT = 60,
EMPTY_USERNAME_COUNT = 10,
USERNAME_SIZE = 32,
/* Some users found 32 chars limit to be too low: */
USERNAME_SIZE = 64,
TTYNAME_SIZE = 32,
};
+1
View File
@@ -15,6 +15,7 @@
#include "libbb.h"
#include <syslog.h>
#include <sys/resource.h> /* setrlimit */
static void nuke_str(char *str)
{
+2 -1
View File
@@ -131,7 +131,8 @@ int su_main(int argc UNUSED_PARAM, char **argv)
change_identity(pw);
setup_environment(opt_shell,
((flags & SU_OPT_l) / SU_OPT_l * SETUP_ENV_CLEARENV)
+ (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV),
+ (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV)
+ (!(flags & SU_OPT_l) * SETUP_ENV_NO_CHDIR),
pw);
IF_SELINUX(set_current_security_context(NULL);)
+4 -3
View File
@@ -118,7 +118,7 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
char *opt_from;
char *s;
llist_t *list = NULL;
char *domain = sane_address(safe_getdomainname());
char *host = sane_address(safe_gethostname());
unsigned nheaders = 0;
int code;
@@ -222,8 +222,9 @@ int sendmail_main(int argc UNUSED_PARAM, char **argv)
}
// we should start with modern EHLO
if (250 != smtp_checkp("EHLO %s", domain, -1))
smtp_checkp("HELO %s", domain, 250);
if (250 != smtp_checkp("EHLO %s", host, -1))
smtp_checkp("HELO %s", host, 250);
free(host);
// perform authentication
if (opts & OPT_a) {
Loaded 100 of 221 files, more files were not shown because too many files have changed in this diff. Show more