Compare commits
455
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a81fe4173 | ||
|
|
3e7eca97b9 | ||
|
|
9e6fe061d4 | ||
|
|
a959a858a3 | ||
|
|
2957fc6992 | ||
|
|
6857e4e2f3 | ||
|
|
9a22b56d36 | ||
|
|
a4d0cd0a31 | ||
|
|
f2b846e277 | ||
|
|
fa1649e9ac | ||
|
|
dee8587d92 | ||
|
|
f941306199 | ||
|
|
dabe36e4a0 | ||
|
|
e06f61d273 | ||
|
|
7049ff8696 | ||
|
|
f26e3d2e41 | ||
|
|
d0cc3f4ade | ||
|
|
fe733a9744 | ||
|
|
70685bd022 | ||
|
|
5ec6132c98 | ||
|
|
003f9fb213 | ||
|
|
cc3f20b9bd | ||
|
|
211b59be43 | ||
|
|
2f5d0cd511 | ||
|
|
2b75a94118 | ||
|
|
ef527f50e6 | ||
|
|
a80d0e4bf7 | ||
|
|
8124a96c34 | ||
|
|
e3eae0d445 | ||
|
|
50b5cac59f | ||
|
|
2a210e5df2 | ||
|
|
b07a496229 | ||
|
|
c87339d584 | ||
|
|
d235f58ac2 | ||
|
|
20273138fc | ||
|
|
3387538bbe | ||
|
|
b175946ba4 | ||
|
|
b67004b2ae | ||
|
|
dd9c072846 | ||
|
|
1363f0df15 | ||
|
|
d5736c5607 | ||
|
|
9cd4c76b50 | ||
|
|
1ba323e5b6 | ||
|
|
324a3fdf87 | ||
|
|
4a689e9b49 | ||
|
|
55789c6646 | ||
|
|
ab876cd107 | ||
|
|
985de15bf3 | ||
|
|
c1c63b622d | ||
|
|
4954d47ab0 | ||
|
|
619b87dfa5 | ||
|
|
16c2fea280 | ||
|
|
13436ea0dd | ||
|
|
6eaf8deddd | ||
|
|
b6926109b7 | ||
|
|
988339259f | ||
|
|
30c9cc5b17 | ||
|
|
c7985b76c5 | ||
|
|
b61e13d247 | ||
|
|
ccce59d562 | ||
|
|
32d8423e63 | ||
|
|
82dfec3e4e | ||
|
|
31e1286365 | ||
|
|
8474cd38f3 | ||
|
|
f45c4f41b7 | ||
|
|
57c899e4c2 | ||
|
|
1dba30f2de | ||
|
|
f54a088429 | ||
|
|
b4c5bf615e | ||
|
|
5703c22a51 | ||
|
|
ff7cd6f925 | ||
|
|
f716a6da9a | ||
|
|
5cdc247ba4 | ||
|
|
04087c6bbd | ||
|
|
d50dda8c35 | ||
|
|
873b895d50 | ||
|
|
e235285c3a | ||
|
|
7a762f9dbf | ||
|
|
f8d01d3f66 | ||
|
|
dd316dd283 | ||
|
|
a84420062a | ||
|
|
6108dc4df6 | ||
|
|
29038c06d6 | ||
|
|
2659c63213 | ||
|
|
a1767a1f5d | ||
|
|
21765fa063 | ||
|
|
76f812803b | ||
|
|
aa9cd89c67 | ||
|
|
7504f2f5d2 | ||
|
|
e773be0428 | ||
|
|
eee4f55a65 | ||
|
|
c7497ea31b | ||
|
|
25b463079d | ||
|
|
0eb406caa8 | ||
|
|
bd8390a872 | ||
|
|
fdddab0c61 | ||
|
|
4ea83bf562 | ||
|
|
9de4622055 | ||
|
|
7e3d33b6ce | ||
|
|
76db5adbf7 | ||
|
|
bd1aeeb850 | ||
|
|
87f40bac14 | ||
|
|
43360e5178 | ||
|
|
2e76c3f901 | ||
|
|
895bea2303 | ||
|
|
46ccdcb96e | ||
|
|
7b4f3f13d3 | ||
|
|
76d50418b3 | ||
|
|
3fe4f986a0 | ||
|
|
98a6f56d49 | ||
|
|
598bb732e8 | ||
|
|
2d0529c9bc | ||
|
|
ed9d621cf4 | ||
|
|
f2cccbce37 | ||
|
|
b8c9354114 | ||
|
|
048897c971 | ||
|
|
52a8d975da | ||
|
|
b597564e4c | ||
|
|
09c0a749a1 | ||
|
|
c8fa04f9b1 | ||
|
|
0876822ded | ||
|
|
dd6f570fa3 | ||
|
|
53354ac47d | ||
|
|
f0d6c25586 | ||
|
|
c0cd9f29d2 | ||
|
|
a05c0716c2 | ||
|
|
401de648a7 | ||
|
|
7bdf0c82da | ||
|
|
797c96d8ce | ||
|
|
593f8baeb0 | ||
|
|
9b6f4aa8e8 | ||
|
|
f592aa36f3 | ||
|
|
f0d6068086 | ||
|
|
c05b1684a0 | ||
|
|
66d56c565e | ||
|
|
50120dab4e | ||
|
|
7d60fc1c0a | ||
|
|
bedfabd500 | ||
|
|
b6fe10091d | ||
|
|
e7860e358e | ||
|
|
1a9bbfb96f | ||
|
|
1da86d2f40 | ||
|
|
1e93f3c585 | ||
|
|
3b162ecdf6 | ||
|
|
630a7f75e8 | ||
|
|
85571d8d01 | ||
|
|
6075b2aee0 | ||
|
|
c2741e1f72 | ||
|
|
ef729dd90c | ||
|
|
d42816763f | ||
|
|
beac1bd58e | ||
|
|
9af7aba579 | ||
|
|
b8e653bfbf | ||
|
|
cd2663f15e | ||
|
|
d78920675f | ||
|
|
62d8503589 | ||
|
|
e0fd13e901 | ||
|
|
a76669c595 | ||
|
|
f4e6bd0bf3 | ||
|
|
1d1bba4e99 | ||
|
|
d12fcc20da | ||
|
|
3e57adb731 | ||
|
|
8f74094548 | ||
|
|
447bd66837 | ||
|
|
f9a0784144 | ||
|
|
db508e3b82 | ||
|
|
cd9d4c85a4 | ||
|
|
634b022108 | ||
|
|
17282292c2 | ||
|
|
5de8a13b08 | ||
|
|
ea9f7a6a7f | ||
|
|
417e240abb | ||
|
|
10be1a787f | ||
|
|
c21d9c7290 | ||
|
|
1510216a55 | ||
|
|
55fb9da5b8 | ||
|
|
b85fb693c1 | ||
|
|
4fec346966 | ||
|
|
9cf0f62b15 | ||
|
|
9474830006 | ||
|
|
1ea2568469 | ||
|
|
7a5f494cab | ||
|
|
c47e8978fe | ||
|
|
fc9e108032 | ||
|
|
6bb55cfb99 | ||
|
|
cf18010ca9 | ||
|
|
dc5d7fec35 | ||
|
|
423465cd5e | ||
|
|
55e547eb6f | ||
|
|
a0e17f7df6 | ||
|
|
b267ed95bc | ||
|
|
4830fc565a | ||
|
|
af6cca50af | ||
|
|
30f892a0ee | ||
|
|
69dc325397 | ||
|
|
bd23fbbd0a | ||
|
|
8e2c9e1518 | ||
|
|
e94a87134d | ||
|
|
ff9234948e | ||
|
|
cf575ca856 | ||
|
|
61082ec1cc | ||
|
|
69d5ba2f95 | ||
|
|
a959a2abdd | ||
|
|
4801441e9a | ||
|
|
e9b76e1f1e | ||
|
|
ae84b11467 | ||
|
|
dfd8282464 | ||
|
|
7b3863986d | ||
|
|
b22a8059cb | ||
|
|
869d3d318f | ||
|
|
7bd8d8fd26 | ||
|
|
49bdf28c32 | ||
|
|
6de8994440 | ||
|
|
19903f0d44 | ||
|
|
b23429198e | ||
|
|
54b90b5988 | ||
|
|
38100a4ebe | ||
|
|
0953336951 | ||
|
|
eaad910655 | ||
|
|
f02efd11c9 | ||
|
|
5e25ddb7d3 | ||
|
|
636a1f85e8 | ||
|
|
cb83abd7b6 | ||
|
|
3576bed2f9 | ||
|
|
ae4342ca3e | ||
|
|
ee56e013cf | ||
|
|
5599502a55 | ||
|
|
e125a683a7 | ||
|
|
faf334aeb8 | ||
|
|
9ddc8d54d1 | ||
|
|
b6c4855f1d | ||
|
|
29eb3599e4 | ||
|
|
d04e1fc309 | ||
|
|
2794c9bb93 | ||
|
|
85e015c7c8 | ||
|
|
29952d79fc | ||
|
|
51a06c07da | ||
|
|
b8635e28b5 | ||
|
|
dff6190112 | ||
|
|
f3b778a4dc | ||
|
|
825968f92c | ||
|
|
1b23773e26 | ||
|
|
9c3052aab6 | ||
|
|
81e97a1380 | ||
|
|
e251337a4d | ||
|
|
6b06cb80be | ||
|
|
43d5d429fd | ||
|
|
b81f97bbd2 | ||
|
|
9305cdddbf | ||
|
|
77ad97f199 | ||
|
|
c4f12f59cc | ||
|
|
023dc6798e | ||
|
|
98636eb08c | ||
|
|
50dbed95fb | ||
|
|
b89e2027d9 | ||
|
|
f3aa4a8ec5 | ||
|
|
4579e9c1c8 | ||
|
|
4b04f543a1 | ||
|
|
35d1683ce9 | ||
|
|
2af860464e | ||
|
|
6253880450 | ||
|
|
6e38d52120 | ||
|
|
647c20cfc2 | ||
|
|
6bf05cf1ff | ||
|
|
b153ace939 | ||
|
|
06ebc16461 | ||
|
|
dddfaff363 | ||
|
|
380bcfc9f7 | ||
|
|
c8f7a97f89 | ||
|
|
8abae88410 | ||
|
|
96b99b860c | ||
|
|
687a26fe0d | ||
|
|
4e79049e10 | ||
|
|
32dcc53b71 | ||
|
|
6da9b00f4f | ||
|
|
2dea01ca11 | ||
|
|
57be4abcf8 | ||
|
|
e061226668 | ||
|
|
812870a2e7 | ||
|
|
dcbd350ccf | ||
|
|
a2dcb50175 | ||
|
|
3c07e4b877 | ||
|
|
b34266b42b | ||
|
|
a0c103a30a | ||
|
|
05efca90d2 | ||
|
|
d93400bffb | ||
|
|
c450379ff0 | ||
|
|
10f6fb1d46 | ||
|
|
e4ed64067e | ||
|
|
e6520f0532 | ||
|
|
c0431ed455 | ||
|
|
4809a9f78e | ||
|
|
7dff4333d6 | ||
|
|
5d0f4aaa99 | ||
|
|
92a6f878e9 | ||
|
|
64d5bfda1a | ||
|
|
16afa38a7b | ||
|
|
b140eddc41 | ||
|
|
2c84495184 | ||
|
|
44f0821259 | ||
|
|
95842fbc16 | ||
|
|
a6b3a1f0bf | ||
|
|
4d89a8bd1d | ||
|
|
ad6cab1834 | ||
|
|
c6191e9a0a | ||
|
|
15ce7f5b58 | ||
|
|
019d299f01 | ||
|
|
b520271f65 | ||
|
|
a50a9b0fdf | ||
|
|
765c1c3c31 | ||
|
|
71e3ab327a | ||
|
|
58dc274a7a | ||
|
|
fa5b05ab07 | ||
|
|
ffdcb41fd2 | ||
|
|
9d4a17e0b6 | ||
|
|
be002adb2f | ||
|
|
1f228985b2 | ||
|
|
5d89fbaa2e | ||
|
|
9137341851 | ||
|
|
5a07a1d255 | ||
|
|
a4a93fdf18 | ||
|
|
2d94992235 | ||
|
|
376003bbbe | ||
|
|
5bb2fc2dc1 | ||
|
|
01eaee9309 | ||
|
|
0a1446275d | ||
|
|
fe493479e2 | ||
|
|
25cfe4996e | ||
|
|
5b3adae7e8 | ||
|
|
85d788e491 | ||
|
|
daeddee442 | ||
|
|
f3745ea489 | ||
|
|
d9c51e9fa7 | ||
|
|
6c10657c4a | ||
|
|
5a96c3eab6 | ||
|
|
a4e55ab840 | ||
|
|
33b92f2fdb | ||
|
|
9a7af9fc17 | ||
|
|
d2095fd903 | ||
|
|
1b2d0b2821 | ||
|
|
50d068cb76 | ||
|
|
e96dcb4dcf | ||
|
|
250aa5bb01 | ||
|
|
c033d5196d | ||
|
|
4437d19fb4 | ||
|
|
aca10f852a | ||
|
|
bc1918a7a2 | ||
|
|
3cfebe44c7 | ||
|
|
7089c31d57 | ||
|
|
c7131c3e58 | ||
|
|
b15ebe46fc | ||
|
|
4f98e19382 | ||
|
|
6d1ebecf65 | ||
|
|
24f824edb3 | ||
|
|
ffa4499c9f | ||
|
|
867bd37c7f | ||
|
|
7465dbcf2a | ||
|
|
f78a656f7c | ||
|
|
033424a213 | ||
|
|
9bc80d7062 | ||
|
|
4a9ca13fe7 | ||
|
|
55e06c1edf | ||
|
|
eecd588c53 | ||
|
|
1d690db720 | ||
|
|
3bc7d7df3d | ||
|
|
0f5dfd6b9a | ||
|
|
93b8263652 | ||
|
|
80f647c21c | ||
|
|
119f87be2a | ||
|
|
da616dbfa8 | ||
|
|
37bb6ada96 | ||
|
|
b75a1c3c2a | ||
|
|
fcc6347976 | ||
|
|
b3f39f0cfa | ||
|
|
858ebf130a | ||
|
|
b12b1c87b5 | ||
|
|
79cedcb2c0 | ||
|
|
643dcf00e3 | ||
|
|
ed23adce72 | ||
|
|
6fa1ba3972 | ||
|
|
90c31b3d4b | ||
|
|
278a1c2264 | ||
|
|
ad4da989e3 | ||
|
|
0a38bcf570 | ||
|
|
1af00eda92 | ||
|
|
1a95e3960c | ||
|
|
261f237024 | ||
|
|
7f8f0fafdb | ||
|
|
7b6d9d687d | ||
|
|
a7f4e4bbd8 | ||
|
|
2e4c3c4cc3 | ||
|
|
0edbdd8ac8 | ||
|
|
c59d802a5a | ||
|
|
9895dfdb9a | ||
|
|
9dedf72e71 | ||
|
|
468aea2d88 | ||
|
|
165f5b394f | ||
|
|
d943af058b | ||
|
|
5297809c03 | ||
|
|
1b2058fe98 | ||
|
|
f2f3868e0d | ||
|
|
aa8a601084 | ||
|
|
02f12f53e8 | ||
|
|
cae11b51aa | ||
|
|
4461564c77 | ||
|
|
7cb808e1c5 | ||
|
|
0e7940ae90 | ||
|
|
6c615a6c07 | ||
|
|
b9ad75fa60 | ||
|
|
a38ba59cc3 | ||
|
|
c4523c2b3d | ||
|
|
2570b2e575 | ||
|
|
cf26ab70c1 | ||
|
|
e1caabbb75 | ||
|
|
95891fc016 | ||
|
|
72b3442aeb | ||
|
|
11b9f26610 | ||
|
|
8ee649a02e | ||
|
|
ce7eb4443c | ||
|
|
25a9c17f55 | ||
|
|
c6dbb85c9e | ||
|
|
08ec67bc62 | ||
|
|
cc2965fd23 | ||
|
|
80591b0a00 | ||
|
|
b02cea1212 | ||
|
|
a1acfc8f37 | ||
|
|
0c3b0d501e | ||
|
|
f7d5665969 | ||
|
|
68e5e2b1c7 | ||
|
|
fa076d491f | ||
|
|
9ce4ae8142 | ||
|
|
92e13c2a11 | ||
|
|
59f351ccda | ||
|
|
f39653e306 | ||
|
|
cee01cfb2e | ||
|
|
dccfe05e17 | ||
|
|
64a76d7b44 | ||
|
|
c4c2cd44d2 | ||
|
|
e9d67a81c8 | ||
|
|
7fe0ebac5f | ||
|
|
73132b9c12 | ||
|
|
04211fd204 | ||
|
|
dc1cbf839d | ||
|
|
c693840fe8 | ||
|
|
42cc304e90 | ||
|
|
39c77c3738 | ||
|
|
0b6c6a9c9f | ||
|
|
a79428998d | ||
|
|
c93b162248 | ||
|
|
324d26f9aa | ||
|
|
715c16ab0a | ||
|
|
69ca5a70fd | ||
|
|
c8bac033f3 | ||
|
|
45ecfc2f5c | ||
|
|
b9d0f0c762 |
No files matched your search
@@ -13,22 +13,6 @@ menu "Busybox Settings"
|
||||
|
||||
menu "General Configuration"
|
||||
|
||||
config NITPICK
|
||||
bool "See lots more (probably unnecessary) configuration options."
|
||||
default n
|
||||
help
|
||||
Some BusyBox applets have more configuration options than anyone
|
||||
will ever care about. To avoid drowining people in complexity, most
|
||||
of the applet features that can be set to a sane default value are
|
||||
hidden, unless you hit the above switch.
|
||||
|
||||
This is better than to telling people to edit the busybox source
|
||||
code, but not by much.
|
||||
|
||||
See http://en.wikipedia.org/wiki/Fibber_McGee_and_Molly#The_Closet
|
||||
|
||||
You have been warned.
|
||||
|
||||
config DESKTOP
|
||||
bool "Enable options for full-blown desktop systems"
|
||||
default n
|
||||
@@ -37,10 +21,21 @@ config DESKTOP
|
||||
Select this only if you plan to use busybox on full-blown
|
||||
desktop machine with common Linux distro, not on an embedded box.
|
||||
|
||||
config FEATURE_ASSUME_UNICODE
|
||||
bool "Assume that 1:1 char/glyph correspondence is not true"
|
||||
default n
|
||||
help
|
||||
This makes various applets aware that one byte is not
|
||||
one character on screen.
|
||||
|
||||
Busybox aims to eventually work correctly with Unicode displays.
|
||||
Any older encodings are not guaranteed to work.
|
||||
Probably by the time when busybox will be fully Unicode-clean,
|
||||
other encodings will be mainly of historic interest.
|
||||
|
||||
choice
|
||||
prompt "Buffer allocation policy"
|
||||
default FEATURE_BUFFERS_USE_MALLOC
|
||||
depends on NITPICK
|
||||
help
|
||||
There are 3 ways BusyBox can handle buffer allocations:
|
||||
- Use malloc. This costs code size for the call to xmalloc.
|
||||
@@ -130,7 +125,6 @@ config FEATURE_DEVPTS
|
||||
config FEATURE_CLEAN_UP
|
||||
bool "Clean up all memory before exiting (usually not needed)"
|
||||
default n
|
||||
depends on NITPICK
|
||||
help
|
||||
As a size optimization, busybox normally exits without explicitly
|
||||
freeing dynamically allocated memory or closing files. This saves
|
||||
@@ -280,6 +274,14 @@ config STATIC
|
||||
|
||||
Most people will leave this set to 'N'.
|
||||
|
||||
config PIE
|
||||
bool "Build BusyBox as a position independent executable"
|
||||
default n
|
||||
depends on !STATIC
|
||||
help
|
||||
(TODO: what is it and why/when is it useful?)
|
||||
Most people will leave this set to 'N'.
|
||||
|
||||
config NOMMU
|
||||
bool "Force NOMMU build"
|
||||
default n
|
||||
@@ -291,10 +293,12 @@ config NOMMU
|
||||
|
||||
Most people will leave this set to 'N'.
|
||||
|
||||
# PIE can be made to work with BUILD_LIBBUSYBOX, but currently
|
||||
# build system does not support that
|
||||
config BUILD_LIBBUSYBOX
|
||||
bool "Build shared libbusybox"
|
||||
default n
|
||||
depends on !FEATURE_PREFER_APPLETS
|
||||
depends on !FEATURE_PREFER_APPLETS && !PIE && !STATIC
|
||||
help
|
||||
Build a shared library libbusybox.so.N.N.N which contains all
|
||||
busybox code.
|
||||
@@ -381,6 +385,16 @@ config LFS
|
||||
cp, mount, tar, and many others. If you want to access files larger
|
||||
than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.
|
||||
|
||||
config CROSS_COMPILER_PREFIX
|
||||
string "Cross Compiler prefix"
|
||||
default ""
|
||||
help
|
||||
If you want to build BusyBox with a cross compiler, then you
|
||||
will need to set this to the cross-compiler prefix, for example,
|
||||
"i386-uclibc-". Note that CROSS_COMPILE environment variable
|
||||
or "make CROSS_COMPILE=xxx ..." will override this selection.
|
||||
For native build leave it empty.
|
||||
|
||||
endmenu
|
||||
|
||||
menu 'Debugging Options'
|
||||
@@ -396,6 +410,17 @@ config DEBUG
|
||||
|
||||
Most people should answer N.
|
||||
|
||||
config DEBUG_PESSIMIZE
|
||||
bool "Disable compiler optimizations."
|
||||
default n
|
||||
depends on DEBUG
|
||||
help
|
||||
The compiler's optimization of source code can eliminate and reorder
|
||||
code, resulting in an executable that's hard to understand when
|
||||
stepping through it with a debugger. This switches it off, resulting
|
||||
in a much bigger executable that more closely matches the source
|
||||
code.
|
||||
|
||||
config WERROR
|
||||
bool "Abort compilation on any warning"
|
||||
default n
|
||||
@@ -404,18 +429,6 @@ config WERROR
|
||||
|
||||
Most people should answer N.
|
||||
|
||||
# Seems to be unused
|
||||
#config DEBUG_PESSIMIZE
|
||||
# bool "Disable compiler optimizations."
|
||||
# default n
|
||||
# depends on DEBUG
|
||||
# help
|
||||
# The compiler's optimization of source code can eliminate and reorder
|
||||
# code, resulting in an executable that's hard to understand when
|
||||
# stepping through it with a debugger. This switches it off, resulting
|
||||
# in a much bigger executable that more closely matches the source
|
||||
# code.
|
||||
|
||||
choice
|
||||
prompt "Additional debugging library"
|
||||
default NO_DEBUG_LIB
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 10
|
||||
SUBLEVEL = 0
|
||||
PATCHLEVEL = 11
|
||||
SUBLEVEL = 3
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
@@ -142,17 +142,6 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
|
||||
export srctree objtree VPATH TOPDIR
|
||||
|
||||
|
||||
# SUBARCH tells the usermode build what the underlying arch is. That is set
|
||||
# first, and if a usermode build is happening, the "ARCH=um" on the command
|
||||
# line overrides the setting of ARCH below. If a native build is happening,
|
||||
# then ARCH is assigned, getting whatever value it gets normally, and
|
||||
# SUBARCH is subsequently ignored.
|
||||
|
||||
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
|
||||
-e s/arm.*/arm/ -e s/sa110/arm/ \
|
||||
-e s/s390x/s390/ -e s/parisc64/parisc/ \
|
||||
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
|
||||
|
||||
# Cross compiling and selecting different set of gcc/bin-utils
|
||||
# ---------------------------------------------------------------------------
|
||||
#
|
||||
@@ -172,8 +161,32 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
|
||||
# Default value for CROSS_COMPILE is not to prefix executables
|
||||
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
|
||||
|
||||
ARCH ?= $(SUBARCH)
|
||||
CROSS_COMPILE ?=
|
||||
CROSS_COMPILE ?=
|
||||
# bbox: we may have CONFIG_CROSS_COMPILER_PREFIX in .config,
|
||||
# and it has not been included yet... thus using an awkward syntax.
|
||||
ifeq ($(CROSS_COMPILE),)
|
||||
CROSS_COMPILE := $(shell grep ^CONFIG_CROSS_COMPILER_PREFIX .config 2>/dev/null)
|
||||
CROSS_COMPILE := $(subst CONFIG_CROSS_COMPILER_PREFIX=,,$(CROSS_COMPILE))
|
||||
CROSS_COMPILE := $(subst ",,$(CROSS_COMPILE))
|
||||
endif
|
||||
|
||||
# SUBARCH tells the usermode build what the underlying arch is. That is set
|
||||
# first, and if a usermode build is happening, the "ARCH=um" on the command
|
||||
# line overrides the setting of ARCH below. If a native build is happening,
|
||||
# then ARCH is assigned, getting whatever value it gets normally, and
|
||||
# SUBARCH is subsequently ignored.
|
||||
|
||||
ifneq ($(CROSS_COMPILE),)
|
||||
SUBARCH := $(shell echo $(CROSS_COMPILE) | cut -d- -f1)
|
||||
else
|
||||
SUBARCH := $(shell uname -m)
|
||||
endif
|
||||
SUBARCH := $(shell echo $(SUBARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
|
||||
-e s/arm.*/arm/ -e s/sa110/arm/ \
|
||||
-e s/s390x/s390/ -e s/parisc64/parisc/ \
|
||||
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
|
||||
|
||||
ARCH ?= $(SUBARCH)
|
||||
|
||||
# Architecture as present in compile.h
|
||||
UTS_MACHINE := $(ARCH)
|
||||
@@ -302,6 +315,8 @@ AFLAGS_KERNEL =
|
||||
# Use LINUXINCLUDE when you must reference the include/ directory.
|
||||
# Needed to be compatible with the O= option
|
||||
CFLAGS := $(CFLAGS)
|
||||
# Added only to final link stage of busybox binary
|
||||
CFLAGS_busybox := $(CFLAGS_busybox)
|
||||
CPPFLAGS := $(CPPFLAGS)
|
||||
AFLAGS := $(AFLAGS)
|
||||
LDFLAGS := $(LDFLAGS)
|
||||
@@ -361,7 +376,8 @@ endif
|
||||
# of make so .config is not included in this case either (for *config).
|
||||
|
||||
no-dot-config-targets := clean mrproper distclean \
|
||||
cscope TAGS tags help %docs check%
|
||||
cscope TAGS tags help %docs
|
||||
#bbox# check% is removed from above
|
||||
|
||||
config-targets := 0
|
||||
mixed-targets := 0
|
||||
@@ -497,12 +513,6 @@ all: busybox
|
||||
#bbox# NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
|
||||
CHECKFLAGS += $(NOSTDINC_FLAGS)
|
||||
|
||||
# warn about C99 declaration after statement
|
||||
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
|
||||
|
||||
# disable pointer signedness warnings in gcc 4.0
|
||||
CFLAGS += $(call cc-option,-Wno-pointer-sign,)
|
||||
|
||||
# Default kernel image to build when no specific target is given.
|
||||
# KBUILD_IMAGE may be overruled on the commandline or
|
||||
# set in the environment
|
||||
@@ -572,7 +582,7 @@ quiet_cmd_busybox__ ?= LINK $@
|
||||
cmd_busybox__ ?= $(srctree)/scripts/trylink \
|
||||
"$@" \
|
||||
"$(CC)" \
|
||||
"$(CFLAGS)" \
|
||||
"$(CFLAGS) $(CFLAGS_busybox)" \
|
||||
"$(LDFLAGS) $(EXTRA_LDFLAGS)" \
|
||||
"$(core-y)" \
|
||||
"$(libs-y)" \
|
||||
@@ -688,6 +698,8 @@ ifeq ($(SKIP_STRIP),y)
|
||||
else
|
||||
$(Q)$(STRIP) -s --remove-section=.note --remove-section=.comment \
|
||||
busybox_unstripped -o $@
|
||||
# strip is confused by PIE executable and does not set exec bits
|
||||
$(Q)chmod a+x $@
|
||||
endif
|
||||
|
||||
# The actual objects are generated when descending,
|
||||
@@ -921,7 +933,7 @@ endif # CONFIG_MODULES
|
||||
|
||||
# Directories & files removed with 'make clean'
|
||||
CLEAN_DIRS += $(MODVERDIR)
|
||||
CLEAN_FILES += busybox* System.map .kernelrelease \
|
||||
CLEAN_FILES += busybox busybox_unstripped* System.map .kernelrelease \
|
||||
.tmp_kallsyms* .tmp_version .tmp_busybox* .tmp_System.map
|
||||
|
||||
# Directories & files removed with 'make mrproper'
|
||||
|
||||
+9
-4
@@ -46,15 +46,20 @@ ifneq ($(strip $(DO_INSTALL_LIBS)),n)
|
||||
done
|
||||
endif
|
||||
|
||||
# Not very elegant: copies testsuite to objdir...
|
||||
# (cp -pPR is POSIX-compliant (cp -dpR or cp -a would not be))
|
||||
.PHONY: check
|
||||
.PHONY: test
|
||||
check test: busybox busybox.links
|
||||
bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \
|
||||
$(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)
|
||||
test -d $(objtree)/testsuite || cp -pPR $(srctree)/testsuite $(objtree)
|
||||
bindir=$(objtree) srcdir=$(srctree)/testsuite \
|
||||
$(SHELL) -c "cd $(objtree)/testsuite && $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)"
|
||||
|
||||
.PHONY: release
|
||||
release: distclean
|
||||
cd ..; \
|
||||
rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
|
||||
cp -a busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
|
||||
cp -pPR busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
|
||||
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
|
||||
-name .svn \
|
||||
-print \
|
||||
@@ -94,7 +99,7 @@ stksizes: busybox_unstripped
|
||||
|
||||
.PHONY: bigdata
|
||||
bigdata: busybox_unstripped
|
||||
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [tr] '
|
||||
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [trw] '
|
||||
|
||||
# Documentation Targets
|
||||
.PHONY: doc
|
||||
|
||||
+40
-27
@@ -11,38 +11,31 @@ CPPFLAGS += $(call cc-option,-std=gnu99,)
|
||||
|
||||
CPPFLAGS += \
|
||||
-Iinclude -Ilibbb \
|
||||
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
|
||||
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include -I$(srctree)/libbb) \
|
||||
-include include/autoconf.h \
|
||||
-D_GNU_SOURCE -DNDEBUG \
|
||||
$(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
|
||||
-D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
|
||||
|
||||
# flag checks are grouped together to speed the checks up a bit..
|
||||
CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,)
|
||||
CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
|
||||
CFLAGS += $(call cc-option,-Wall,)
|
||||
CFLAGS += $(call cc-option,-Wshadow,)
|
||||
CFLAGS += $(call cc-option,-Wwrite-strings,)
|
||||
CFLAGS += $(call cc-option,-Wundef,)
|
||||
CFLAGS += $(call cc-option,-Wstrict-prototypes,)
|
||||
CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
|
||||
# If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
|
||||
# (or anything else for that matter) make sure that it is still possible
|
||||
# to build bbox without warnings. Current offender: find.c:alloc_action().
|
||||
# Looks more like gcc bug: gcc will warn on it with or without prototype.
|
||||
# But still, warning-free compile is a must, or else we will drown
|
||||
# in warnings pretty soon.
|
||||
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
|
||||
# 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
|
||||
# still possible to build bbox without warnings.
|
||||
|
||||
ifeq ($(CONFIG_WERROR),y)
|
||||
CFLAGS += $(call cc-option,-Werror,)
|
||||
else
|
||||
# for development, warn a little bit about unused results..
|
||||
CPPFLAGS += -D_FORTIFY_SOURCE=2
|
||||
endif
|
||||
# gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
|
||||
CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
|
||||
|
||||
# gcc emits bogus "no prev proto" warning on find.c:alloc_action()
|
||||
ifneq ($(CONFIG_WERROR),y)
|
||||
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
|
||||
endif
|
||||
|
||||
CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
|
||||
CFLAGS += $(call cc-option,-fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
|
||||
# -fno-guess-branch-probability: prohibit pseudo-random guessing
|
||||
# of branch probabilities (hopefully makes bloatcheck more stable):
|
||||
CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
|
||||
@@ -53,21 +46,38 @@ CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1
|
||||
# be fixed..
|
||||
#CFLAGS+=$(call cc-option,-Wconversion,)
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
CFLAGS += $(call cc-option,-g)
|
||||
ifneq ($(CONFIG_DEBUG),y)
|
||||
CFLAGS += $(call cc-option,-Os,)
|
||||
else
|
||||
CFLAGS += $(call cc-option,-g,)
|
||||
ifeq ($(CONFIG_DEBUG_PESSIMIZE),y)
|
||||
CFLAGS += $(call cc-option,-O0,)
|
||||
else
|
||||
CFLAGS += $(call cc-option,-Os,)
|
||||
endif
|
||||
endif
|
||||
|
||||
# If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
|
||||
ARCH_FPIC ?= -fpic
|
||||
ARCH_FPIE ?= -fpie
|
||||
ARCH_PIE ?= -pie
|
||||
|
||||
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
|
||||
# on i386: 14% smaller libbusybox.so
|
||||
# (code itself is 9% bigger, we save on relocs/PLT/GOT)
|
||||
CFLAGS += -fpic
|
||||
CFLAGS += $(ARCH_FPIC)
|
||||
# and another 4% reduction of libbusybox.so:
|
||||
# (external entry points must be marked EXTERNALLY_VISIBLE)
|
||||
CFLAGS += $(call cc-option,-fvisibility=hidden)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STATIC),y)
|
||||
LDFLAGS += -static
|
||||
CFLAGS_busybox += -static
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PIE),y)
|
||||
CFLAGS_busybox += $(ARCH_PIE)
|
||||
CFLAGS += $(ARCH_FPIE)
|
||||
endif
|
||||
|
||||
LDLIBS += m crypt
|
||||
@@ -88,10 +98,13 @@ ifeq ($(CONFIG_DMALLOC),y)
|
||||
LDLIBS += dmalloc
|
||||
endif
|
||||
|
||||
#LDFLAGS += -nostdlib
|
||||
|
||||
LDFLAGS_ELF2FLT = -Wl,-elf2flt
|
||||
ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
|
||||
# If a flat binary should be built, CFLAGS_busybox="-Wl,-elf2flt"
|
||||
# env var should be set for make invocation.
|
||||
# Here we check whether CFLAGS_busybox indeed contains that flag.
|
||||
# (For historical reasons, we also check LDFLAGS, which doesn't
|
||||
# seem to be entirely correct variable to put "-Wl,-elf2flt" into).
|
||||
W_ELF2FLT = -Wl,-elf2flt
|
||||
ifneq (,$(findstring $(W_ELF2FLT),$(LDFLAGS) $(CFLAGS_busybox)))
|
||||
SKIP_STRIP = y
|
||||
endif
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ do one of these bounce an email off the person it's listed under to see if they
|
||||
have any suggestions how they plan to go about it, and to minimize conflicts
|
||||
between your work and theirs. But otherwise, all of these are fair game.
|
||||
|
||||
Rob Landley <rob@landley.net>:
|
||||
Rob Landley suggested these:
|
||||
Add a libbb/platform.c
|
||||
Implement fdprintf() for platforms that haven't got one.
|
||||
Implement bb_realpath() that can handle NULL on non-glibc.
|
||||
@@ -24,11 +24,6 @@ Rob Landley <rob@landley.net>:
|
||||
but less buggy :)
|
||||
init
|
||||
General cleanup (should use ENABLE_FEATURE_INIT_SYSLOG and ENABLE_FEATURE_INIT_DEBUG).
|
||||
depmod
|
||||
busybox lacks a way to update module deps when running from firmware without the
|
||||
use of the depmod.pl (perl is to bloated for most embedded setups) and or orig
|
||||
modutils. The orig depmod is rather pointless to have to add to a firmware image
|
||||
in when we already have a insmod/rmmod and friends.
|
||||
Do a SUSv3 audit
|
||||
Look at the full Single Unix Specification version 3 (available online at
|
||||
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
|
||||
@@ -146,7 +141,7 @@ man
|
||||
(How doclifter might work into this is anybody's guess.)
|
||||
---
|
||||
ar
|
||||
Write support?
|
||||
Write support!
|
||||
---
|
||||
stty / catv
|
||||
stty's visible() function and catv's guts are identical. Merge them into
|
||||
@@ -282,10 +277,6 @@ Minor stuff:
|
||||
---
|
||||
use bb_perror_msg where appropriate: See
|
||||
egrep "[^_]perror"
|
||||
---
|
||||
Remove superfluous fmt occurances: e.g.
|
||||
fprintf(stderr, "%s: %s not found\n", "unalias", *argptr);
|
||||
-> fprintf(stderr, "unalias: %s not found\n", *argptr);
|
||||
---
|
||||
possible code duplication ingroup() and is_a_group_member()
|
||||
---
|
||||
@@ -294,6 +285,8 @@ Minor stuff:
|
||||
See grep -r strtod
|
||||
Alot of duplication that wants cleanup.
|
||||
---
|
||||
in_ether duplicated in network/{interface,ifconfig}.c
|
||||
---
|
||||
|
||||
|
||||
Code cleanup:
|
||||
|
||||
+12
-6
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.10.0.svn
|
||||
# Thu Mar 20 14:54:21 2008
|
||||
# Busybox version: 1.11.0.svn
|
||||
# Mon Apr 21 23:20:35 2008
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
@@ -12,7 +12,6 @@ CONFIG_HAVE_DOT_CONFIG=y
|
||||
#
|
||||
# General Configuration
|
||||
#
|
||||
CONFIG_NITPICK=y
|
||||
CONFIG_DESKTOP=y
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
@@ -100,6 +99,7 @@ CONFIG_FEATURE_AR_LONG_FILENAMES=y
|
||||
CONFIG_BUNZIP2=y
|
||||
CONFIG_BZIP2=y
|
||||
CONFIG_CPIO=y
|
||||
CONFIG_FEATURE_CPIO_O=y
|
||||
CONFIG_DPKG=y
|
||||
CONFIG_DPKG_DEB=y
|
||||
CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY=y
|
||||
@@ -130,7 +130,6 @@ CONFIG_UNZIP=y
|
||||
#
|
||||
# Common options for cpio and tar
|
||||
#
|
||||
CONFIG_FEATURE_UNARCHIVE_TAPE=y
|
||||
|
||||
#
|
||||
# Common options for dpkg and dpkg_deb
|
||||
@@ -486,6 +485,7 @@ CONFIG_LOSETUP=y
|
||||
CONFIG_MDEV=y
|
||||
CONFIG_FEATURE_MDEV_CONF=y
|
||||
CONFIG_FEATURE_MDEV_RENAME=y
|
||||
CONFIG_FEATURE_MDEV_RENAME_REGEXP=y
|
||||
CONFIG_FEATURE_MDEV_EXEC=y
|
||||
CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
|
||||
CONFIG_MKSWAP=y
|
||||
@@ -522,6 +522,7 @@ CONFIG_PIVOT_ROOT=y
|
||||
CONFIG_RDATE=y
|
||||
CONFIG_READPROFILE=y
|
||||
CONFIG_RTCWAKE=y
|
||||
CONFIG_SCRIPT=y
|
||||
CONFIG_SETARCH=y
|
||||
CONFIG_SWAPONOFF=y
|
||||
CONFIG_SWITCH_ROOT=y
|
||||
@@ -560,6 +561,7 @@ CONFIG_DC=y
|
||||
# CONFIG_FEATURE_DEVFS is not set
|
||||
CONFIG_EJECT=y
|
||||
CONFIG_FEATURE_EJECT_SCSI=y
|
||||
CONFIG_FBSPLASH=y
|
||||
CONFIG_LAST=y
|
||||
CONFIG_LESS=y
|
||||
CONFIG_FEATURE_LESS_MAXLINES=9999999
|
||||
@@ -578,6 +580,7 @@ CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA=y
|
||||
CONFIG_MAKEDEVS=y
|
||||
# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
|
||||
CONFIG_FEATURE_MAKEDEVS_TABLE=y
|
||||
CONFIG_MAN=y
|
||||
CONFIG_MICROCOM=y
|
||||
CONFIG_MOUNTPOINT=y
|
||||
CONFIG_MT=y
|
||||
@@ -585,9 +588,9 @@ CONFIG_RAIDAUTORUN=y
|
||||
CONFIG_READAHEAD=y
|
||||
CONFIG_RUNLEVEL=y
|
||||
CONFIG_RX=y
|
||||
CONFIG_SCRIPT=y
|
||||
CONFIG_STRINGS=y
|
||||
CONFIG_SETSID=y
|
||||
CONFIG_STRINGS=y
|
||||
CONFIG_SYMLINKS=y
|
||||
CONFIG_TASKSET=y
|
||||
CONFIG_FEATURE_TASKSET_FANCY=y
|
||||
CONFIG_TIME=y
|
||||
@@ -604,6 +607,7 @@ CONFIG_ARP=y
|
||||
CONFIG_ARPING=y
|
||||
CONFIG_BRCTL=y
|
||||
CONFIG_FEATURE_BRCTL_FANCY=y
|
||||
CONFIG_FEATURE_BRCTL_SHOW=y
|
||||
CONFIG_DNSD=y
|
||||
CONFIG_ETHER_WAKE=y
|
||||
CONFIG_FAKEIDENTD=y
|
||||
@@ -752,6 +756,7 @@ CONFIG_WATCH=y
|
||||
# CONFIG_FEATURE_SH_IS_MSH is not set
|
||||
CONFIG_FEATURE_SH_IS_NONE=y
|
||||
# CONFIG_ASH is not set
|
||||
# CONFIG_ASH_BASH_COMPAT is not set
|
||||
# CONFIG_ASH_JOB_CONTROL is not set
|
||||
# CONFIG_ASH_READ_NCHARS is not set
|
||||
# CONFIG_ASH_READ_TIMEOUT is not set
|
||||
@@ -781,6 +786,7 @@ CONFIG_MSH=y
|
||||
#
|
||||
CONFIG_FEATURE_SH_EXTRA_QUIET=y
|
||||
CONFIG_FEATURE_SH_STANDALONE=y
|
||||
CONFIG_FEATURE_SH_NOFORK=y
|
||||
CONFIG_CTTYHACK=y
|
||||
|
||||
#
|
||||
|
||||
+15
-4
@@ -47,6 +47,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int ofs;
|
||||
unsigned MAX_APPLET_NAME_LEN = 1;
|
||||
|
||||
qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name);
|
||||
|
||||
@@ -69,15 +70,23 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Keep in sync with include/busybox.h! */
|
||||
|
||||
puts("/* This is a generated file, don't edit */");
|
||||
puts("/* This is a generated file, don't edit */\n");
|
||||
|
||||
puts("const char applet_names[] ALIGN1 = \"\"\n");
|
||||
printf("#define NUM_APPLETS %u\n", NUM_APPLETS);
|
||||
if (NUM_APPLETS == 1) {
|
||||
printf("#define SINGLE_APPLET_STR \"%s\"\n", applets[0].name);
|
||||
printf("#define SINGLE_APPLET_MAIN %s_main\n", applets[0].name);
|
||||
}
|
||||
|
||||
puts("\nconst char applet_names[] ALIGN1 = \"\"");
|
||||
for (i = 0; i < NUM_APPLETS; i++) {
|
||||
printf("\"%s\" \"\\0\"\n", applets[i].name);
|
||||
if (MAX_APPLET_NAME_LEN < strlen(applets[i].name))
|
||||
MAX_APPLET_NAME_LEN = strlen(applets[i].name);
|
||||
}
|
||||
puts(";");
|
||||
|
||||
puts("int (*const applet_main[])(int argc, char **argv) = {");
|
||||
puts("\nint (*const applet_main[])(int argc, char **argv) = {");
|
||||
for (i = 0; i < NUM_APPLETS; i++) {
|
||||
printf("%s_main,\n", applets[i].main);
|
||||
}
|
||||
@@ -108,8 +117,10 @@ int main(int argc, char **argv)
|
||||
printf("0x%02x,\n", v);
|
||||
i++;
|
||||
}
|
||||
puts("};");
|
||||
puts("};\n");
|
||||
#endif
|
||||
|
||||
printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -14,13 +14,11 @@ const char *applet_name;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
applet_name = argv[0];
|
||||
|
||||
return APPLET_main(argc,argv);
|
||||
}
|
||||
|
||||
void bb_show_usage(void)
|
||||
{
|
||||
printf(APPLET_full_usage "\n");
|
||||
|
||||
exit(1);
|
||||
fputs(APPLET_full_usage "\n", stdout);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
+1
-1
@@ -37,7 +37,7 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
|
||||
for i in $DO_INSTALL_LIBS; do
|
||||
rm -f $prefix/$libdir/$i || exit 1
|
||||
if [ -f $i ]; then
|
||||
cp -a $i $prefix/$libdir/ || exit 1
|
||||
cp -pPR $i $prefix/$libdir/ || exit 1
|
||||
chmod 0644 $prefix/$libdir/$i || exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
+12
-1
@@ -5,6 +5,17 @@
|
||||
* object directory */
|
||||
#include "../include/autoconf.h"
|
||||
|
||||
/* Since we can't use platform.h, have to do this again by hand: */
|
||||
#if ENABLE_NOMMU
|
||||
#define BB_MMU 0
|
||||
#define USE_FOR_NOMMU(...) __VA_ARGS__
|
||||
#define USE_FOR_MMU(...)
|
||||
#else
|
||||
#define BB_MMU 1
|
||||
#define USE_FOR_NOMMU(...)
|
||||
#define USE_FOR_MMU(...) __VA_ARGS__
|
||||
#endif
|
||||
|
||||
static const char usage_messages[] = ""
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
@@ -13,6 +24,6 @@ static const char usage_messages[] = ""
|
||||
|
||||
int main(void)
|
||||
{
|
||||
write(1, usage_messages, sizeof(usage_messages));
|
||||
write(STDOUT_FILENO, usage_messages, sizeof(usage_messages));
|
||||
return 0;
|
||||
}
|
||||
@@ -14,14 +14,21 @@ exec >"$target"
|
||||
|
||||
echo 'static const char packed_usage[] ALIGN1 = {'
|
||||
|
||||
# Extra effort to avoid using "od -t x1": -t is not available
|
||||
# in non-CONFIG_DESKTOPed busybox od
|
||||
## Breaks on big-endian systems!
|
||||
## # Extra effort to avoid using "od -t x1": -t is not available
|
||||
## # in non-CONFIG_DESKTOPed busybox od
|
||||
##
|
||||
## "$loc/usage" | bzip2 -1 | od -v -x \
|
||||
## | $SED -e 's/^[^ ]*//' \
|
||||
## | $SED -e 's/ //g' \
|
||||
## | grep -v '^$' \
|
||||
## | $SED -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
|
||||
|
||||
"$loc/usage" | bzip2 -1 | od -v -x \
|
||||
"$loc/usage" | bzip2 -1 | od -v -t x1 \
|
||||
| $SED -e 's/^[^ ]*//' \
|
||||
| $SED -e 's/ //g' \
|
||||
| grep -v '^$' \
|
||||
| $SED -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
|
||||
| $SED -e 's/\(..\)/0x\1,/g'
|
||||
|
||||
echo '};'
|
||||
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
|
||||
+9
-8
@@ -78,6 +78,14 @@ config CPIO
|
||||
Unless you have a specific application which requires cpio, you should
|
||||
probably say N here.
|
||||
|
||||
config FEATURE_CPIO_O
|
||||
bool "Support for archive creation"
|
||||
default n
|
||||
depends on CPIO
|
||||
help
|
||||
This implementation of cpio can create cpio archives in the "newc"
|
||||
format only.
|
||||
|
||||
config DPKG
|
||||
bool "dpkg"
|
||||
default n
|
||||
@@ -279,7 +287,7 @@ config UNLZMA
|
||||
should probably say N here.
|
||||
|
||||
config FEATURE_LZMA_FAST
|
||||
bool "Optimze unlzma for speed"
|
||||
bool "Optimize unlzma for speed"
|
||||
default n
|
||||
depends on UNLZMA
|
||||
help
|
||||
@@ -299,13 +307,6 @@ config UNZIP
|
||||
comment "Common options for cpio and tar"
|
||||
depends on CPIO || TAR
|
||||
|
||||
config FEATURE_UNARCHIVE_TAPE
|
||||
bool "Enable tape drive support"
|
||||
default n
|
||||
depends on CPIO || TAR
|
||||
help
|
||||
I don't think this is needed anymore.
|
||||
|
||||
comment "Common options for dpkg and dpkg_deb"
|
||||
depends on DPKG || DPKG_DEB
|
||||
|
||||
|
||||
+15
-1
@@ -256,10 +256,24 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Linux kernel build uses gzip -d -n. We accept and ignore it.
|
||||
* Man page says:
|
||||
* -n --no-name
|
||||
* gzip: do not save the original file name and time stamp.
|
||||
* (The original name is always saved if the name had to be truncated.)
|
||||
* gunzip: do not restore the original file name/time even if present
|
||||
* (remove only the gzip suffix from the compressed file name).
|
||||
* This option is the default when decompressing.
|
||||
* -N --name
|
||||
* gzip: always save the original file name and time stamp (this is the default)
|
||||
* gunzip: restore the original file name and time stamp if present.
|
||||
*/
|
||||
|
||||
int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int gunzip_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
getopt32(argv, "cfvdt");
|
||||
getopt32(argv, "cfvdtn");
|
||||
argv += optind;
|
||||
/* if called as zcat */
|
||||
if (applet_name[1] == 'c')
|
||||
|
||||
+287
-20
@@ -7,35 +7,298 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
* Limitations:
|
||||
* Doesn't check CRC's
|
||||
* Only supports new ASCII and CRC formats
|
||||
* Doesn't check CRC's
|
||||
* Only supports new ASCII and CRC formats
|
||||
*
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define CPIO_OPT_EXTRACT 0x01
|
||||
#define CPIO_OPT_TEST 0x02
|
||||
#define CPIO_OPT_UNCONDITIONAL 0x04
|
||||
#define CPIO_OPT_VERBOSE 0x08
|
||||
#define CPIO_OPT_FILE 0x10
|
||||
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
|
||||
#define CPIO_OPT_PRESERVE_MTIME 0x40
|
||||
#if ENABLE_FEATURE_CPIO_O
|
||||
static off_t cpio_pad4(off_t size)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = (- size) & 3;
|
||||
size += i;
|
||||
while (--i >= 0)
|
||||
bb_putchar('\0');
|
||||
return size;
|
||||
}
|
||||
|
||||
/* Return value will become exit code.
|
||||
* It's ok to exit instead of return. */
|
||||
static int cpio_o(void)
|
||||
{
|
||||
struct name_s {
|
||||
struct name_s *next;
|
||||
char name[1];
|
||||
};
|
||||
struct inodes_s {
|
||||
struct inodes_s *next;
|
||||
struct name_s *names;
|
||||
struct stat st;
|
||||
};
|
||||
|
||||
struct inodes_s *links = NULL;
|
||||
off_t bytes = 0; /* output bytes count */
|
||||
|
||||
while (1) {
|
||||
const char *name;
|
||||
char *line;
|
||||
struct stat st;
|
||||
|
||||
line = xmalloc_fgetline(stdin);
|
||||
|
||||
if (line) {
|
||||
/* Strip leading "./[./]..." from the filename */
|
||||
name = line;
|
||||
while (name[0] == '.' && name[1] == '/') {
|
||||
while (*++name == '/')
|
||||
continue;
|
||||
}
|
||||
if (!*name) { /* line is empty */
|
||||
free(line);
|
||||
continue;
|
||||
}
|
||||
if (lstat(name, &st)) {
|
||||
abort_cpio_o:
|
||||
bb_simple_perror_msg_and_die(name);
|
||||
}
|
||||
|
||||
if (!(S_ISLNK(st.st_mode) || S_ISREG(st.st_mode)))
|
||||
st.st_size = 0; /* paranoia */
|
||||
|
||||
/* Store hardlinks for later processing, dont output them */
|
||||
if (!S_ISDIR(st.st_mode) && st.st_nlink > 1) {
|
||||
struct name_s *n;
|
||||
struct inodes_s *l;
|
||||
|
||||
/* Do we have this hardlink remembered? */
|
||||
l = links;
|
||||
while (1) {
|
||||
if (l == NULL) {
|
||||
/* Not found: add new item to "links" list */
|
||||
l = xzalloc(sizeof(*l));
|
||||
l->st = st;
|
||||
l->next = links;
|
||||
links = l;
|
||||
break;
|
||||
}
|
||||
if (l->st.st_ino == st.st_ino) {
|
||||
/* found */
|
||||
break;
|
||||
}
|
||||
l = l->next;
|
||||
}
|
||||
/* Add new name to "l->names" list */
|
||||
n = xmalloc(sizeof(*n) + strlen(name));
|
||||
strcpy(n->name, name);
|
||||
n->next = l->names;
|
||||
l->names = n;
|
||||
|
||||
free(line);
|
||||
continue;
|
||||
}
|
||||
|
||||
} else { /* line == NULL: EOF */
|
||||
next_link:
|
||||
if (links) {
|
||||
/* Output hardlink's data */
|
||||
st = links->st;
|
||||
name = links->names->name;
|
||||
links->names = links->names->next;
|
||||
/* GNU cpio is reported to emit file data
|
||||
* only for the last instance. Mimic that. */
|
||||
if (links->names == NULL)
|
||||
links = links->next;
|
||||
else
|
||||
st.st_size = 0;
|
||||
/* NB: we leak links->names and/or links,
|
||||
* this is intended (we exit soon anyway) */
|
||||
} else {
|
||||
/* If no (more) hardlinks to output,
|
||||
* output "trailer" entry */
|
||||
name = "TRAILER!!!";
|
||||
/* st.st_size == 0 is a must, but for uniformity
|
||||
* in the output, we zero out everything */
|
||||
memset(&st, 0, sizeof(st));
|
||||
/* st.st_nlink = 1; - GNU cpio does this */
|
||||
}
|
||||
}
|
||||
|
||||
bytes += printf("070701"
|
||||
"%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');
|
||||
bytes = cpio_pad4(bytes);
|
||||
|
||||
if (st.st_size) {
|
||||
if (S_ISLNK(st.st_mode)) {
|
||||
char *lpath = xmalloc_readlink_or_warn(name);
|
||||
if (!lpath)
|
||||
goto abort_cpio_o;
|
||||
bytes += printf("%s", lpath);
|
||||
free(lpath);
|
||||
} else { /* S_ISREG */
|
||||
int fd = xopen(name, O_RDONLY);
|
||||
fflush(stdout);
|
||||
/* We must abort if file got shorter too! */
|
||||
bb_copyfd_exact_size(fd, STDOUT_FILENO, st.st_size);
|
||||
bytes += st.st_size;
|
||||
close(fd);
|
||||
}
|
||||
bytes = cpio_pad4(bytes);
|
||||
}
|
||||
|
||||
if (!line) {
|
||||
if (links)
|
||||
goto next_link;
|
||||
/* TODO: GNU cpio pads trailer to 512 bytes, do we want that? */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
free(line);
|
||||
} /* end of "while (1)" */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* GNU cpio (GNU cpio) 2.9 help (abridged):
|
||||
|
||||
Main operation mode:
|
||||
-i, --extract Extract files from an archive
|
||||
-o, --create Create the archive
|
||||
-p, --pass-through Copy-pass mode (was ist das?!)
|
||||
-t, --list List the archive
|
||||
|
||||
Operation modifiers valid in any mode:
|
||||
--block-size=SIZE I/O block size = SIZE * 512 bytes
|
||||
-B I/O block size = 5120 bytes
|
||||
-c Use the old portable (ASCII) archive format
|
||||
-C, --io-size=NUMBER I/O block size to the given NUMBER bytes
|
||||
-f, --nonmatching Only copy files that do not match given pattern
|
||||
-F, --file=FILE Use FILE instead of standard input or output
|
||||
-H, --format=FORMAT Use given archive FORMAT
|
||||
-M, --message=STRING Print STRING when the end of a volume of the
|
||||
backup media is reached
|
||||
-n, --numeric-uid-gid If -v, show numeric UID and GID
|
||||
--quiet Do not print the number of blocks copied
|
||||
--rsh-command=COMMAND Use remote COMMAND instead of rsh
|
||||
-v, --verbose Verbosely list the files processed
|
||||
-V, --dot Print a "." for each file processed
|
||||
-W, --warning=FLAG Control warning display: 'none','truncate','all';
|
||||
multiple options accumulate
|
||||
|
||||
Operation modifiers valid only in --extract mode:
|
||||
-b, --swap Swap both halfwords of words and bytes of
|
||||
halfwords in the data (equivalent to -sS)
|
||||
-r, --rename Interactively rename files
|
||||
-s, --swap-bytes Swap the bytes of each halfword in the files
|
||||
-S, --swap-halfwords Swap the halfwords of each word (4 bytes)
|
||||
--to-stdout Extract files to standard output
|
||||
-E, --pattern-file=FILE Read additional patterns specifying filenames to
|
||||
extract or list from FILE
|
||||
--only-verify-crc Verify CRC's, don't actually extract the files
|
||||
|
||||
Operation modifiers valid only in --create mode:
|
||||
-A, --append Append to an existing archive
|
||||
-O FILE File to use instead of standard output
|
||||
|
||||
Operation modifiers valid only in --pass-through mode:
|
||||
-l, --link Link files instead of copying them, when possible
|
||||
|
||||
Operation modifiers valid in --extract and --create modes:
|
||||
--absolute-filenames Do not strip file system prefix components from
|
||||
the file names
|
||||
--no-absolute-filenames Create all files relative to the current dir
|
||||
|
||||
Operation modifiers valid in --create and --pass-through modes:
|
||||
-0, --null A list of filenames is terminated by a NUL
|
||||
-a, --reset-access-time Reset the access times of files after reading them
|
||||
-I FILE File to use instead of standard input
|
||||
-L, --dereference Dereference symbolic links (copy the files
|
||||
that they point to instead of copying the links)
|
||||
-R, --owner=[USER][:.][GROUP] Set owner of created files
|
||||
|
||||
Operation modifiers valid in --extract and --pass-through modes:
|
||||
-d, --make-directories Create leading directories where needed
|
||||
-m, --preserve-modification-time
|
||||
Retain previous file modification times when
|
||||
creating files
|
||||
--no-preserve-owner Do not change the ownership of the files
|
||||
--sparse Write files with blocks of zeros as sparse files
|
||||
-u, --unconditional Replace all files unconditionally
|
||||
*/
|
||||
|
||||
int cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int cpio_main(int argc, char **argv)
|
||||
int cpio_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
char *cpio_filename = NULL;
|
||||
char *cpio_filename;
|
||||
USE_FEATURE_CPIO_O(const char *cpio_fmt = "";)
|
||||
unsigned opt;
|
||||
enum {
|
||||
CPIO_OPT_EXTRACT = (1 << 0),
|
||||
CPIO_OPT_TEST = (1 << 1),
|
||||
CPIO_OPT_UNCONDITIONAL = (1 << 2),
|
||||
CPIO_OPT_VERBOSE = (1 << 3),
|
||||
CPIO_OPT_FILE = (1 << 4),
|
||||
CPIO_OPT_CREATE_LEADING_DIR = (1 << 5),
|
||||
CPIO_OPT_PRESERVE_MTIME = (1 << 6),
|
||||
CPIO_OPT_CREATE = (1 << 7),
|
||||
CPIO_OPT_FORMAT = (1 << 8),
|
||||
};
|
||||
|
||||
/* Initialise */
|
||||
#if ENABLE_GETOPT_LONG && ENABLE_DESKTOP
|
||||
applet_long_options =
|
||||
"extract\0" No_argument "i"
|
||||
"list\0" No_argument "t"
|
||||
#if ENABLE_FEATURE_CPIO_O
|
||||
"create\0" No_argument "o"
|
||||
"format\0" Required_argument "H"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
/* Initialize */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->src_fd = STDIN_FILENO;
|
||||
archive_handle->seek = seek_by_read;
|
||||
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
|
||||
archive_handle->flags = ARCHIVE_EXTRACT_NEWER;
|
||||
|
||||
#if ENABLE_FEATURE_CPIO_O
|
||||
opt = getopt32(argv, "ituvF:dmoH:", &cpio_filename, &cpio_fmt);
|
||||
|
||||
if (opt & CPIO_OPT_CREATE) {
|
||||
if (*cpio_fmt != 'n')
|
||||
bb_show_usage();
|
||||
if (opt & CPIO_OPT_FILE) {
|
||||
fclose(stdout);
|
||||
stdout = fopen(cpio_filename, "w");
|
||||
/* Paranoia: I don't trust libc that much */
|
||||
xdup2(fileno(stdout), STDOUT_FILENO);
|
||||
}
|
||||
return cpio_o();
|
||||
}
|
||||
#else
|
||||
opt = getopt32(argv, "ituvF:dm", &cpio_filename);
|
||||
#endif
|
||||
argv += optind;
|
||||
|
||||
/* One of either extract or test options must be given */
|
||||
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
|
||||
@@ -63,21 +326,25 @@ int cpio_main(int argc, char **argv)
|
||||
archive_handle->action_header = header_list;
|
||||
}
|
||||
}
|
||||
if (cpio_filename) { /* CPIO_OPT_FILE */
|
||||
if (opt & CPIO_OPT_FILE) { /* -F */
|
||||
archive_handle->src_fd = xopen(cpio_filename, O_RDONLY);
|
||||
archive_handle->seek = seek_by_jump;
|
||||
}
|
||||
if (opt & CPIO_OPT_CREATE_LEADING_DIR) {
|
||||
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
|
||||
}
|
||||
|
||||
while (optind < argc) {
|
||||
archive_handle->filter = filter_accept_list;
|
||||
llist_add_to(&(archive_handle->accept), argv[optind]);
|
||||
optind++;
|
||||
if (opt & CPIO_OPT_PRESERVE_MTIME) {
|
||||
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
|
||||
}
|
||||
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
|
||||
while (*argv) {
|
||||
archive_handle->filter = filter_accept_list;
|
||||
llist_add_to(&(archive_handle->accept), *argv);
|
||||
argv++;
|
||||
}
|
||||
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+107
-81
@@ -75,10 +75,21 @@ typedef struct status_node_s {
|
||||
unsigned status:16; /* was:14 */ /* has to fit STATUS_HASH_PRIME */
|
||||
} status_node_t;
|
||||
|
||||
/* Were statically declared here, but such a big bss is nommu-unfriendly */
|
||||
static char **name_hashtable; /* [NAME_HASH_PRIME + 1] */
|
||||
static common_node_t **package_hashtable; /* [PACKAGE_HASH_PRIME + 1] */
|
||||
static status_node_t **status_hashtable; /* [STATUS_HASH_PRIME + 1] */
|
||||
|
||||
/* Globals */
|
||||
struct globals {
|
||||
char *name_hashtable[NAME_HASH_PRIME + 1];
|
||||
common_node_t *package_hashtable[PACKAGE_HASH_PRIME + 1];
|
||||
status_node_t *status_hashtable[STATUS_HASH_PRIME + 1];
|
||||
};
|
||||
#define G (*ptr_to_globals)
|
||||
#define name_hashtable (G.name_hashtable )
|
||||
#define package_hashtable (G.package_hashtable)
|
||||
#define status_hashtable (G.status_hashtable )
|
||||
#define INIT_G() do { \
|
||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Even numbers are for 'extras', like ored dependencies or null */
|
||||
enum edge_type_e {
|
||||
@@ -124,7 +135,7 @@ static void make_hash(const char *key, unsigned *start, unsigned *decrement, con
|
||||
* shift amount is mod 24 because long int is 32 bit and data
|
||||
* to be shifted is 8, don't want to shift data to where it has
|
||||
* no effect*/
|
||||
hash_num += ((key[i] + key[i-1]) << ((key[i] * i) % 24));
|
||||
hash_num += (key[i] + key[i-1]) << ((key[i] * i) % 24);
|
||||
}
|
||||
*start = (unsigned) hash_num % hash_prime;
|
||||
*decrement = (unsigned) 1 + (hash_num % (hash_prime - 1));
|
||||
@@ -133,8 +144,8 @@ static void make_hash(const char *key, unsigned *start, unsigned *decrement, con
|
||||
/* this adds the key to the hash table */
|
||||
static int search_name_hashtable(const char *key)
|
||||
{
|
||||
unsigned probe_address = 0;
|
||||
unsigned probe_decrement = 0;
|
||||
unsigned probe_address;
|
||||
unsigned probe_decrement;
|
||||
|
||||
make_hash(key, &probe_address, &probe_decrement, NAME_HASH_PRIME);
|
||||
while (name_hashtable[probe_address] != NULL) {
|
||||
@@ -155,8 +166,8 @@ static int search_name_hashtable(const char *key)
|
||||
*/
|
||||
static unsigned search_status_hashtable(const char *key)
|
||||
{
|
||||
unsigned probe_address = 0;
|
||||
unsigned probe_decrement = 0;
|
||||
unsigned probe_address;
|
||||
unsigned probe_decrement;
|
||||
|
||||
make_hash(key, &probe_address, &probe_decrement, STATUS_HASH_PRIME);
|
||||
while (status_hashtable[probe_address] != NULL) {
|
||||
@@ -312,11 +323,10 @@ static int test_version(const unsigned version1, const unsigned version2, const
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static int search_package_hashtable(const unsigned name, const unsigned version, const unsigned operator)
|
||||
{
|
||||
unsigned probe_address = 0;
|
||||
unsigned probe_decrement = 0;
|
||||
unsigned probe_address;
|
||||
unsigned probe_decrement;
|
||||
|
||||
make_hash(name_hashtable[name], &probe_address, &probe_decrement, PACKAGE_HASH_PRIME);
|
||||
while (package_hashtable[probe_address] != NULL) {
|
||||
@@ -410,10 +420,10 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
|
||||
if ((edge_type == EDGE_DEPENDS || edge_type == EDGE_PRE_DEPENDS)
|
||||
&& (strcmp(field, field2) != 0)
|
||||
) {
|
||||
or_edge = xmalloc(sizeof(edge_t));
|
||||
or_edge = xzalloc(sizeof(edge_t));
|
||||
or_edge->type = edge_type + 1;
|
||||
or_edge->name = search_name_hashtable(field);
|
||||
or_edge->version = 0; // tracks the number of alternatives
|
||||
//or_edge->version = 0; // tracks the number of alternatives
|
||||
add_edge_to_node(parent_node, or_edge);
|
||||
}
|
||||
|
||||
@@ -439,17 +449,13 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
|
||||
if (offset_ch > 0) {
|
||||
if (strncmp(version, "=", offset_ch) == 0) {
|
||||
edge->operator = VER_EQUAL;
|
||||
}
|
||||
else if (strncmp(version, "<<", offset_ch) == 0) {
|
||||
} else if (strncmp(version, "<<", offset_ch) == 0) {
|
||||
edge->operator = VER_LESS;
|
||||
}
|
||||
else if (strncmp(version, "<=", offset_ch) == 0) {
|
||||
} else if (strncmp(version, "<=", offset_ch) == 0) {
|
||||
edge->operator = VER_LESS_EQUAL;
|
||||
}
|
||||
else if (strncmp(version, ">>", offset_ch) == 0) {
|
||||
} else if (strncmp(version, ">>", offset_ch) == 0) {
|
||||
edge->operator = VER_MORE;
|
||||
}
|
||||
else if (strncmp(version, ">=", offset_ch) == 0) {
|
||||
} else if (strncmp(version, ">=", offset_ch) == 0) {
|
||||
edge->operator = VER_MORE_EQUAL;
|
||||
} else {
|
||||
bb_error_msg_and_die("illegal operator");
|
||||
@@ -735,7 +741,6 @@ static const char *describe_status(int status_num)
|
||||
return "is not installed or flagged to be installed";
|
||||
}
|
||||
|
||||
|
||||
static void index_status_file(const char *filename)
|
||||
{
|
||||
FILE *status_file;
|
||||
@@ -1152,9 +1157,9 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
|
||||
static char **create_list(const char *filename)
|
||||
{
|
||||
FILE *list_stream;
|
||||
char **file_list = NULL;
|
||||
char *line = NULL;
|
||||
int count = 0;
|
||||
char **file_list;
|
||||
char *line;
|
||||
int count;
|
||||
|
||||
/* don't use [xw]fopen here, handle error ourself */
|
||||
list_stream = fopen(filename, "r");
|
||||
@@ -1162,17 +1167,15 @@ static char **create_list(const char *filename)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ((line = xmalloc_getline(list_stream)) != NULL) {
|
||||
file_list = NULL;
|
||||
count = 0;
|
||||
while ((line = xmalloc_fgetline(list_stream)) != NULL) {
|
||||
file_list = xrealloc(file_list, sizeof(char *) * (count + 2));
|
||||
file_list[count] = line;
|
||||
count++;
|
||||
file_list[count++] = line;
|
||||
file_list[count] = NULL;
|
||||
}
|
||||
fclose(list_stream);
|
||||
|
||||
if (count == 0) {
|
||||
return NULL;
|
||||
}
|
||||
file_list[count] = NULL;
|
||||
return file_list;
|
||||
}
|
||||
|
||||
@@ -1209,24 +1212,54 @@ static int remove_file_array(char **remove_names, char **exclude_names)
|
||||
return (remove_flag == 0);
|
||||
}
|
||||
|
||||
static int run_package_script(const char *package_name, const char *script_type)
|
||||
static void run_package_script_or_die(const char *package_name, const char *script_type)
|
||||
{
|
||||
struct stat path_stat;
|
||||
char *script_path;
|
||||
int result;
|
||||
|
||||
script_path = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, script_type);
|
||||
|
||||
/* If the file doesnt exist is isnt a fatal */
|
||||
result = lstat(script_path, &path_stat) < 0 ? EXIT_SUCCESS : system(script_path);
|
||||
/* If the file doesnt exist is isnt fatal */
|
||||
result = access(script_path, F_OK) ? EXIT_SUCCESS : system(script_path);
|
||||
free(script_path);
|
||||
return result;
|
||||
if (result)
|
||||
bb_error_msg_and_die("%s failed, exit code %d", script_type, result);
|
||||
}
|
||||
|
||||
/*
|
||||
The policy manual defines what scripts get called when and with
|
||||
what arguments. I realize that busybox does not support all of
|
||||
these scenarios, but it does support some of them; it does not,
|
||||
however, run them with any parameters in run_package_script_or_die().
|
||||
Here are the scripts:
|
||||
|
||||
preinst install
|
||||
preinst install <old_version>
|
||||
preinst upgrade <old_version>
|
||||
preinst abort_upgrade <new_version>
|
||||
postinst configure <most_recent_version>
|
||||
postinst abort-upgade <new_version>
|
||||
postinst abort-remove
|
||||
postinst abort-remove in-favour <package> <version>
|
||||
postinst abort-deconfigure in-favor <failed_install_package> removing <conflicting_package> <version>
|
||||
prerm remove
|
||||
prerm upgrade <new_version>
|
||||
prerm failed-upgrade <old_version>
|
||||
prerm remove in-favor <package> <new_version>
|
||||
prerm deconfigure in-favour <package> <version> removing <package> <version>
|
||||
postrm remove
|
||||
postrm purge
|
||||
postrm upgrade <new_version>
|
||||
postrm failed-upgrade <old_version>
|
||||
postrm abort-install
|
||||
postrm abort-install <old_version>
|
||||
postrm abort-upgrade <old_version>
|
||||
postrm disappear <overwriter> <version>
|
||||
*/
|
||||
static const char *const all_control_files[] = {
|
||||
"preinst", "postinst", "prerm", "postrm",
|
||||
"list", "md5sums", "shlibs", "conffiles",
|
||||
"config", "templates", NULL
|
||||
"config", "templates"
|
||||
};
|
||||
|
||||
static char **all_control_list(const char *package_name)
|
||||
@@ -1235,9 +1268,10 @@ static char **all_control_list(const char *package_name)
|
||||
char **remove_files;
|
||||
|
||||
/* Create a list of all /var/lib/dpkg/info/<package> files */
|
||||
remove_files = xzalloc(sizeof(all_control_files));
|
||||
while (all_control_files[i]) {
|
||||
remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, all_control_files[i]);
|
||||
remove_files = xzalloc(sizeof(all_control_files) + sizeof(char*));
|
||||
while (i < ARRAY_SIZE(all_control_files)) {
|
||||
remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s",
|
||||
package_name, all_control_files[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -1310,27 +1344,26 @@ static void remove_package(const unsigned package_num, int noisy)
|
||||
if (noisy)
|
||||
printf("Removing %s (%s)...\n", package_name, package_version);
|
||||
|
||||
/* run prerm script */
|
||||
if (run_package_script(package_name, "prerm") != 0) {
|
||||
bb_error_msg_and_die("script failed, prerm failure");
|
||||
}
|
||||
/* Run prerm script */
|
||||
run_package_script_or_die(package_name, "prerm");
|
||||
|
||||
/* Create a list of files to remove, and a separate list of those to keep */
|
||||
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
|
||||
sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
|
||||
remove_files = create_list(list_name);
|
||||
|
||||
sprintf(conffile_name, "/var/lib/dpkg/info/%s.conffiles", package_name);
|
||||
sprintf(conffile_name, "/var/lib/dpkg/info/%s.%s", package_name, "conffiles");
|
||||
exclude_files = create_list(conffile_name);
|
||||
|
||||
/* Some directories can't be removed straight away, so do multiple passes */
|
||||
while (remove_file_array(remove_files, exclude_files)) /*repeat */;
|
||||
while (remove_file_array(remove_files, exclude_files))
|
||||
continue;
|
||||
free_array(exclude_files);
|
||||
free_array(remove_files);
|
||||
|
||||
/* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
|
||||
exclude_files = xzalloc(sizeof(char*) * 3);
|
||||
exclude_files[0] = xstrdup(conffile_name);
|
||||
exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.postrm", package_name);
|
||||
exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
|
||||
|
||||
/* Create a list of all /var/lib/dpkg/info/<package> files */
|
||||
remove_files = all_control_list(package_name);
|
||||
@@ -1339,8 +1372,10 @@ static void remove_package(const unsigned package_num, int noisy)
|
||||
free_array(remove_files);
|
||||
free_array(exclude_files);
|
||||
|
||||
/* rename <package>.conffile to <package>.list */
|
||||
xrename(conffile_name, list_name);
|
||||
/* rename <package>.conffiles to <package>.list
|
||||
* The conffiles control file isn't required in Debian packages, so don't
|
||||
* error out if it's missing. */
|
||||
rename(conffile_name, list_name);
|
||||
|
||||
/* Change package status */
|
||||
set_status(status_num, "config-files", 3);
|
||||
@@ -1357,13 +1392,11 @@ static void purge_package(const unsigned package_num)
|
||||
|
||||
printf("Purging %s (%s)...\n", package_name, package_version);
|
||||
|
||||
/* run prerm script */
|
||||
if (run_package_script(package_name, "prerm") != 0) {
|
||||
bb_error_msg_and_die("script failed, prerm failure");
|
||||
}
|
||||
/* Run prerm script */
|
||||
run_package_script_or_die(package_name, "prerm");
|
||||
|
||||
/* Create a list of files to remove */
|
||||
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
|
||||
sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
|
||||
remove_files = create_list(list_name);
|
||||
|
||||
exclude_files = xzalloc(sizeof(char*));
|
||||
@@ -1378,10 +1411,8 @@ static void purge_package(const unsigned package_num)
|
||||
free_array(remove_files);
|
||||
free(exclude_files);
|
||||
|
||||
/* run postrm script */
|
||||
if (run_package_script(package_name, "postrm") != 0) {
|
||||
bb_error_msg_and_die("postrm failure.. set status to what?");
|
||||
}
|
||||
/* Run postrm script */
|
||||
run_package_script_or_die(package_name, "postrm");
|
||||
|
||||
/* Change package status */
|
||||
set_status(status_num, "not-installed", 3);
|
||||
@@ -1471,8 +1502,8 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
char *list_filename;
|
||||
archive_handle_t *archive_handle;
|
||||
FILE *out_stream;
|
||||
llist_t *accept_list = NULL;
|
||||
int i = 0;
|
||||
llist_t *accept_list;
|
||||
int i;
|
||||
|
||||
/* If existing version, remove it first */
|
||||
if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) {
|
||||
@@ -1486,11 +1517,13 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
}
|
||||
|
||||
/* Extract control.tar.gz to /var/lib/dpkg/info/<package>.filename */
|
||||
info_prefix = xasprintf("/var/lib/dpkg/info/%s.", package_name);
|
||||
info_prefix = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "");
|
||||
archive_handle = init_archive_deb_ar(deb_file->filename);
|
||||
init_archive_deb_control(archive_handle);
|
||||
|
||||
while (all_control_files[i]) {
|
||||
accept_list = NULL;
|
||||
i = 0;
|
||||
while (i < ARRAY_SIZE(all_control_files)) {
|
||||
char *c = xasprintf("./%s", all_control_files[i]);
|
||||
llist_add_to(&accept_list, c);
|
||||
i++;
|
||||
@@ -1503,10 +1536,7 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
unpack_ar_archive(archive_handle);
|
||||
|
||||
/* Run the preinst prior to extracting */
|
||||
if (run_package_script(package_name, "preinst") != 0) {
|
||||
/* when preinst returns exit code != 0 then quit installation process */
|
||||
bb_error_msg_and_die("subprocess pre-installation script returned error");
|
||||
}
|
||||
run_package_script_or_die(package_name, "preinst");
|
||||
|
||||
/* Extract data.tar.gz to the root directory */
|
||||
archive_handle = init_archive_deb_ar(deb_file->filename);
|
||||
@@ -1517,7 +1547,7 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
unpack_ar_archive(archive_handle);
|
||||
|
||||
/* Create the list file */
|
||||
list_filename = xasprintf("/var/lib/dpkg/info/%s.list", package_name);
|
||||
list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list");
|
||||
out_stream = xfopen(list_filename, "w");
|
||||
while (archive_handle->sub_archive->passed) {
|
||||
/* the leading . has been stripped by data_extract_all_prefix already */
|
||||
@@ -1544,17 +1574,16 @@ static void configure_package(deb_file_t *deb_file)
|
||||
printf("Setting up %s (%s)...\n", package_name, package_version);
|
||||
|
||||
/* Run the postinst script */
|
||||
if (run_package_script(package_name, "postinst") != 0) {
|
||||
/* TODO: handle failure gracefully */
|
||||
bb_error_msg_and_die("postinst failure.. set status to what?");
|
||||
}
|
||||
/* TODO: handle failure gracefully */
|
||||
run_package_script_or_die(package_name, "postinst");
|
||||
|
||||
/* Change status to reflect success */
|
||||
set_status(status_num, "install", 1);
|
||||
set_status(status_num, "installed", 3);
|
||||
}
|
||||
|
||||
int dpkg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int dpkg_main(int argc, char **argv)
|
||||
int dpkg_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
deb_file_t **deb_file = NULL;
|
||||
status_node_t *status_node;
|
||||
@@ -1575,6 +1604,8 @@ int dpkg_main(int argc, char **argv)
|
||||
OPT_unpack = 0x40,
|
||||
};
|
||||
|
||||
INIT_G();
|
||||
|
||||
opt = getopt32(argv, "CF:ilPru", &str_f);
|
||||
//if (opt & OPT_configure) ... // -C
|
||||
if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg)
|
||||
@@ -1586,16 +1617,11 @@ int dpkg_main(int argc, char **argv)
|
||||
//if (opt & OPT_purge) ... // -P
|
||||
//if (opt & OPT_remove) ... // -r
|
||||
//if (opt & OPT_unpack) ... // -u (--unpack in official dpkg)
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
/* check for non-option argument if expected */
|
||||
if (!opt || (!argc && !(opt && OPT_list_installed)))
|
||||
if (!opt || (!argv[0] && !(opt && OPT_list_installed)))
|
||||
bb_show_usage();
|
||||
|
||||
name_hashtable = xzalloc(sizeof(name_hashtable[0]) * (NAME_HASH_PRIME + 1));
|
||||
package_hashtable = xzalloc(sizeof(package_hashtable[0]) * (PACKAGE_HASH_PRIME + 1));
|
||||
status_hashtable = xzalloc(sizeof(status_hashtable[0]) * (STATUS_HASH_PRIME + 1));
|
||||
|
||||
/* puts("(Reading database ... xxxxx files and directories installed.)"); */
|
||||
index_status_file("/var/lib/dpkg/status");
|
||||
|
||||
|
||||
+15
-1
@@ -2025,6 +2025,20 @@ USE_DESKTOP(long long) int pack_gzip(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Linux kernel build uses gzip -d -n. We accept and ignore it.
|
||||
* Man page says:
|
||||
* -n --no-name
|
||||
* gzip: do not save the original file name and time stamp.
|
||||
* (The original name is always saved if the name had to be truncated.)
|
||||
* gunzip: do not restore the original file name/time even if present
|
||||
* (remove only the gzip suffix from the compressed file name).
|
||||
* This option is the default when decompressing.
|
||||
* -N --name
|
||||
* gzip: always save the original file name and time stamp (this is the default)
|
||||
* gunzip: restore the original file name and time stamp if present.
|
||||
*/
|
||||
|
||||
int gzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
#if ENABLE_GUNZIP
|
||||
int gzip_main(int argc, char **argv)
|
||||
@@ -2035,7 +2049,7 @@ int gzip_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
unsigned opt;
|
||||
|
||||
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
|
||||
opt = getopt32(argv, "cfv" USE_GUNZIP("d") "q123456789" );
|
||||
opt = getopt32(argv, "cfv" USE_GUNZIP("d") "q123456789n" );
|
||||
#if ENABLE_GUNZIP /* gunzip_main may not be visible... */
|
||||
if (opt & 0x8) // -d
|
||||
return gunzip_main(argc, argv);
|
||||
|
||||
@@ -12,7 +12,7 @@ ssize_t archive_xread_all_eof(archive_handle_t *archive_handle,
|
||||
ssize_t size;
|
||||
|
||||
size = full_read(archive_handle->src_fd, buf, count);
|
||||
if (size != 0 && size != count) {
|
||||
if (size != 0 && size != (ssize_t)count) {
|
||||
bb_error_msg_and_die("short read: %u of %u",
|
||||
(unsigned)size, (unsigned)count);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
|
||||
/* Check if the file already exists */
|
||||
if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
|
||||
/* Remove the existing entry if it exists */
|
||||
/* Remove the entry if it exists */
|
||||
if (((file_header->mode & S_IFMT) != S_IFDIR)
|
||||
&& (unlink(file_header->name) == -1)
|
||||
&& (errno != ENOENT)
|
||||
|
||||
@@ -66,7 +66,6 @@ struct group_data {
|
||||
* | grep 'bd->' | sed 's/^.*bd->/bd->/' | sort | $PAGER
|
||||
* and moved it (inbufBitCount) to offset 0.
|
||||
*/
|
||||
|
||||
struct bunzip_data {
|
||||
/* I/O tracking data (file handles, buffers, positions, etc.) */
|
||||
unsigned inbufBitCount, inbufBits;
|
||||
@@ -102,11 +101,9 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
|
||||
|
||||
/* If we need to get more data from the byte buffer, do so. (Loop getting
|
||||
one byte at a time to enforce endianness and avoid unaligned access.) */
|
||||
|
||||
while (bd->inbufBitCount < bits_wanted) {
|
||||
while ((int)(bd->inbufBitCount) < bits_wanted) {
|
||||
|
||||
/* If we need to read more data from file into byte buffer, do so */
|
||||
|
||||
if (bd->inbufPos == bd->inbufCount) {
|
||||
/* if "no input fd" case: in_fd == -1, read fails, we jump */
|
||||
bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE);
|
||||
@@ -116,7 +113,6 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
|
||||
}
|
||||
|
||||
/* Avoid 32-bit overflow (dump bit buffer to top of output) */
|
||||
|
||||
if (bd->inbufBitCount >= 24) {
|
||||
bits = bd->inbufBits & ((1 << bd->inbufBitCount) - 1);
|
||||
bits_wanted -= bd->inbufBitCount;
|
||||
@@ -125,13 +121,11 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
|
||||
}
|
||||
|
||||
/* Grab next 8 bits of input from buffer. */
|
||||
|
||||
bd->inbufBits = (bd->inbufBits << 8) | bd->inbuf[bd->inbufPos++];
|
||||
bd->inbufBitCount += 8;
|
||||
}
|
||||
|
||||
/* Calculate result */
|
||||
|
||||
bd->inbufBitCount -= bits_wanted;
|
||||
bits |= (bd->inbufBits >> bd->inbufBitCount) & ((1 << bits_wanted) - 1);
|
||||
|
||||
@@ -139,7 +133,6 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
|
||||
}
|
||||
|
||||
/* Unpacks the next block and sets up for the inverse burrows-wheeler step. */
|
||||
|
||||
static int get_next_block(bunzip_data *bd)
|
||||
{
|
||||
struct group_data *hufGroup;
|
||||
@@ -153,13 +146,11 @@ static int get_next_block(bunzip_data *bd)
|
||||
selectors = bd->selectors;
|
||||
|
||||
/* Reset longjmp I/O error handling */
|
||||
|
||||
i = setjmp(bd->jmpbuf);
|
||||
if (i) return i;
|
||||
|
||||
/* Read in header signature and CRC, then validate signature.
|
||||
(last block signature means CRC is for whole file, return now) */
|
||||
|
||||
i = get_bits(bd, 24);
|
||||
j = get_bits(bd, 24);
|
||||
bd->headerCRC = get_bits(bd, 32);
|
||||
@@ -169,17 +160,15 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* We can add support for blockRandomised if anybody complains. There was
|
||||
some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
|
||||
it didn't actually work. */
|
||||
|
||||
if (get_bits(bd, 1)) return RETVAL_OBSOLETE_INPUT;
|
||||
origPtr = get_bits(bd, 24);
|
||||
if (origPtr > dbufSize) return RETVAL_DATA_ERROR;
|
||||
if ((int)origPtr > dbufSize) return RETVAL_DATA_ERROR;
|
||||
|
||||
/* mapping table: if some byte values are never used (encoding things
|
||||
like ascii text), the compression code removes the gaps to have fewer
|
||||
symbols to deal with, and writes a sparse bitfield indicating which
|
||||
values were present. We make a translation table to convert the symbols
|
||||
back to the corresponding bytes. */
|
||||
|
||||
t = get_bits(bd, 16);
|
||||
symTotal = 0;
|
||||
for (i = 0; i < 16; i++) {
|
||||
@@ -192,7 +181,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
}
|
||||
|
||||
/* How many different Huffman coding groups does this block use? */
|
||||
|
||||
groupCount = get_bits(bd, 3);
|
||||
if (groupCount < 2 || groupCount > MAX_GROUPS)
|
||||
return RETVAL_DATA_ERROR;
|
||||
@@ -201,19 +189,16 @@ static int get_next_block(bunzip_data *bd)
|
||||
group. Read in the group selector list, which is stored as MTF encoded
|
||||
bit runs. (MTF=Move To Front, as each value is used it's moved to the
|
||||
start of the list.) */
|
||||
|
||||
nSelectors = get_bits(bd, 15);
|
||||
if (!nSelectors) return RETVAL_DATA_ERROR;
|
||||
for (i = 0; i < groupCount; i++) mtfSymbol[i] = i;
|
||||
for (i = 0; i < nSelectors; i++) {
|
||||
|
||||
/* Get next value */
|
||||
|
||||
for (j = 0; get_bits(bd, 1); j++)
|
||||
if (j >= groupCount) return RETVAL_DATA_ERROR;
|
||||
|
||||
/* Decode MTF to get the next selector */
|
||||
|
||||
uc = mtfSymbol[j];
|
||||
for (;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
|
||||
mtfSymbol[0] = selectors[i] = uc;
|
||||
@@ -221,10 +206,11 @@ static int get_next_block(bunzip_data *bd)
|
||||
|
||||
/* Read the Huffman coding tables for each group, which code for symTotal
|
||||
literal symbols, plus two run symbols (RUNA, RUNB) */
|
||||
|
||||
symCount = symTotal + 2;
|
||||
for (j = 0; j < groupCount; j++) {
|
||||
unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1];
|
||||
unsigned char length[MAX_SYMBOLS];
|
||||
/* 8 bits is ALMOST enough for temp[], see below */
|
||||
unsigned temp[MAX_HUFCODE_BITS+1];
|
||||
int minLen, maxLen, pp;
|
||||
|
||||
/* Read Huffman code lengths for each symbol. They're stored in
|
||||
@@ -233,7 +219,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
(Subtracting 1 before the loop and then adding it back at the end is
|
||||
an optimization that makes the test inside the loop simpler: symbol
|
||||
length 0 becomes negative, so an unsigned inequality catches it.) */
|
||||
|
||||
t = get_bits(bd, 5) - 1;
|
||||
for (i = 0; i < symCount; i++) {
|
||||
for (;;) {
|
||||
@@ -243,7 +228,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* If first bit is 0, stop. Else second bit indicates whether
|
||||
to increment or decrement the value. Optimization: grab 2
|
||||
bits and unget the second if the first was 0. */
|
||||
|
||||
k = get_bits(bd, 2);
|
||||
if (k < 2) {
|
||||
bd->inbufBitCount++;
|
||||
@@ -251,17 +235,14 @@ static int get_next_block(bunzip_data *bd)
|
||||
}
|
||||
|
||||
/* Add one if second bit 1, else subtract 1. Avoids if/else */
|
||||
|
||||
t += (((k+1) & 2) - 1);
|
||||
}
|
||||
|
||||
/* Correct for the initial -1, to get the final symbol length */
|
||||
|
||||
length[i] = t + 1;
|
||||
}
|
||||
|
||||
/* Find largest and smallest lengths in this group */
|
||||
|
||||
minLen = maxLen = length[0];
|
||||
for (i = 1; i < symCount; i++) {
|
||||
if (length[i] > maxLen) maxLen = length[i];
|
||||
@@ -278,7 +259,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
* number of bits can have. This is how the Huffman codes can vary in
|
||||
* length: each code with a value>limit[length] needs another bit.
|
||||
*/
|
||||
|
||||
hufGroup = bd->groups + j;
|
||||
hufGroup->minLen = minLen;
|
||||
hufGroup->maxLen = maxLen;
|
||||
@@ -286,12 +266,10 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* Note that minLen can't be smaller than 1, so we adjust the base
|
||||
and limit array pointers so we're not always wasting the first
|
||||
entry. We do this again when using them (during symbol decoding).*/
|
||||
|
||||
base = hufGroup->base - 1;
|
||||
limit = hufGroup->limit - 1;
|
||||
|
||||
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
|
||||
|
||||
pp = 0;
|
||||
for (i = minLen; i <= maxLen; i++) {
|
||||
temp[i] = limit[i] = 0;
|
||||
@@ -301,14 +279,14 @@ static int get_next_block(bunzip_data *bd)
|
||||
}
|
||||
|
||||
/* Count symbols coded for at each bit length */
|
||||
|
||||
/* NB: in pathological cases, temp[8] can end ip being 256.
|
||||
* That's why uint8_t is too small for temp[]. */
|
||||
for (i = 0; i < symCount; i++) temp[length[i]]++;
|
||||
|
||||
/* Calculate limit[] (the largest symbol-coding value at each bit
|
||||
* length, which is (previous limit<<1)+symbols at this level), and
|
||||
* base[] (number of symbols to ignore at each bit length, which is
|
||||
* limit minus the cumulative count of symbols coded for already). */
|
||||
|
||||
pp = t = 0;
|
||||
for (i = minLen; i < maxLen; i++) {
|
||||
pp += temp[i];
|
||||
@@ -319,7 +297,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
each level we're really only interested in the first few bits,
|
||||
so here we set all the trailing to-be-ignored bits to 1 so they
|
||||
don't affect the value>limit[length] comparison. */
|
||||
|
||||
limit[i] = (pp << (maxLen - i)) - 1;
|
||||
pp <<= 1;
|
||||
t += temp[i];
|
||||
@@ -335,7 +312,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
and run length encoding, saving the result into dbuf[dbufCount++] = uc */
|
||||
|
||||
/* Initialize symbol occurrence counters and symbol Move To Front table */
|
||||
|
||||
memset(byteCount, 0, sizeof(byteCount)); /* smaller, maybe slower? */
|
||||
for (i = 0; i < 256; i++) {
|
||||
//byteCount[i] = 0;
|
||||
@@ -347,8 +323,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
runPos = dbufCount = selector = 0;
|
||||
for (;;) {
|
||||
|
||||
/* fetch next Huffman coding group from list. */
|
||||
|
||||
/* Fetch next Huffman coding group from list. */
|
||||
symCount = GROUP_SIZE - 1;
|
||||
if (selector >= nSelectors) return RETVAL_DATA_ERROR;
|
||||
hufGroup = bd->groups + selectors[selector++];
|
||||
@@ -367,8 +342,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
dry). The following (up to got_huff_bits:) is equivalent to
|
||||
j = get_bits(bd, hufGroup->maxLen);
|
||||
*/
|
||||
|
||||
while (bd->inbufBitCount < hufGroup->maxLen) {
|
||||
while ((int)(bd->inbufBitCount) < hufGroup->maxLen) {
|
||||
if (bd->inbufPos == bd->inbufCount) {
|
||||
j = get_bits(bd, hufGroup->maxLen);
|
||||
goto got_huff_bits;
|
||||
@@ -382,13 +356,11 @@ static int get_next_block(bunzip_data *bd)
|
||||
got_huff_bits:
|
||||
|
||||
/* Figure how how many bits are in next symbol and unget extras */
|
||||
|
||||
i = hufGroup->minLen;
|
||||
while (j > limit[i]) ++i;
|
||||
bd->inbufBitCount += (hufGroup->maxLen - i);
|
||||
|
||||
/* Huffman decode value to get nextSym (with bounds checking) */
|
||||
|
||||
if (i > hufGroup->maxLen)
|
||||
return RETVAL_DATA_ERROR;
|
||||
j = (j >> (hufGroup->maxLen - i)) - base[i];
|
||||
@@ -400,11 +372,9 @@ static int get_next_block(bunzip_data *bd)
|
||||
byte, or a repeated run of the most recent literal byte. First,
|
||||
check if nextSym indicates a repeated run, and if so loop collecting
|
||||
how many times to repeat the last literal. */
|
||||
|
||||
if ((unsigned)nextSym <= SYMBOL_RUNB) { /* RUNA or RUNB */
|
||||
|
||||
/* If this is the start of a new run, zero out counter */
|
||||
|
||||
if (!runPos) {
|
||||
runPos = 1;
|
||||
t = 0;
|
||||
@@ -417,7 +387,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
the basic or 0/1 method (except all bits 0, which would use no
|
||||
symbols, but a run of length 0 doesn't mean anything in this
|
||||
context). Thus space is saved. */
|
||||
|
||||
t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
|
||||
if (runPos < dbufSize) runPos <<= 1;
|
||||
goto end_of_huffman_loop;
|
||||
@@ -427,7 +396,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
how many times to repeat the last literal, so append that many
|
||||
copies to our buffer of decoded symbols (dbuf) now. (The last
|
||||
literal used is the one at the head of the mtfSymbol array.) */
|
||||
|
||||
if (runPos) {
|
||||
runPos = 0;
|
||||
if (dbufCount + t >= dbufSize) return RETVAL_DATA_ERROR;
|
||||
@@ -438,7 +406,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
}
|
||||
|
||||
/* Is this the terminating symbol? */
|
||||
|
||||
if (nextSym > symTotal) break;
|
||||
|
||||
/* At this point, nextSym indicates a new literal character. Subtract
|
||||
@@ -448,7 +415,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
first symbol in the mtf array, position 0, would have been handled
|
||||
as part of a run above. Therefore 1 unused mtf position minus
|
||||
2 non-literal nextSym values equals -1.) */
|
||||
|
||||
if (dbufCount >= dbufSize) return RETVAL_DATA_ERROR;
|
||||
i = nextSym - 1;
|
||||
uc = mtfSymbol[i];
|
||||
@@ -457,7 +423,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
* small number of symbols, and are bound by 256 in any case, using
|
||||
* memmove here would typically be bigger and slower due to function
|
||||
* call overhead and other assorted setup costs. */
|
||||
|
||||
do {
|
||||
mtfSymbol[i] = mtfSymbol[i-1];
|
||||
} while (--i);
|
||||
@@ -465,13 +430,11 @@ static int get_next_block(bunzip_data *bd)
|
||||
uc = symToByte[uc];
|
||||
|
||||
/* We have our literal byte. Save it into dbuf. */
|
||||
|
||||
byteCount[uc]++;
|
||||
dbuf[dbufCount++] = (unsigned)uc;
|
||||
|
||||
/* Skip group initialization if we're not done with this group. Done
|
||||
* this way to avoid compiler warning. */
|
||||
|
||||
end_of_huffman_loop:
|
||||
if (symCount--) goto continue_this_group;
|
||||
}
|
||||
@@ -484,7 +447,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
*/
|
||||
|
||||
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
|
||||
|
||||
j = 0;
|
||||
for (i = 0; i < 256; i++) {
|
||||
k = j + byteCount[i];
|
||||
@@ -493,7 +455,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
}
|
||||
|
||||
/* Figure out what order dbuf would be in if we sorted it. */
|
||||
|
||||
for (i = 0; i < dbufCount; i++) {
|
||||
uc = (unsigned char)(dbuf[i] & 0xff);
|
||||
dbuf[byteCount[uc]] |= (i << 8);
|
||||
@@ -503,11 +464,10 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* Decode first byte by hand to initialize "previous" byte. Note that it
|
||||
doesn't get output, and if the first three characters are identical
|
||||
it doesn't qualify as a run (hence writeRunCountdown=5). */
|
||||
|
||||
if (dbufCount) {
|
||||
if (origPtr >= dbufCount) return RETVAL_DATA_ERROR;
|
||||
if ((int)origPtr >= dbufCount) return RETVAL_DATA_ERROR;
|
||||
bd->writePos = dbuf[origPtr];
|
||||
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
|
||||
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
|
||||
bd->writePos >>= 8;
|
||||
bd->writeRunCountdown = 5;
|
||||
}
|
||||
@@ -522,7 +482,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
error (all errors are negative numbers). If out_fd!=-1, outbuf and len
|
||||
are ignored, data is written to out_fd and return is RETVAL_OK or error.
|
||||
*/
|
||||
|
||||
int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
{
|
||||
const unsigned *dbuf;
|
||||
@@ -539,19 +498,15 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
/* We will always have pending decoded data to write into the output
|
||||
buffer unless this is the very first call (in which case we haven't
|
||||
Huffman-decoded a block into the intermediate buffer yet). */
|
||||
|
||||
if (bd->writeCopies) {
|
||||
|
||||
/* Inside the loop, writeCopies means extra copies (beyond 1) */
|
||||
|
||||
--bd->writeCopies;
|
||||
|
||||
/* Loop outputting bytes */
|
||||
|
||||
for (;;) {
|
||||
|
||||
/* If the output buffer is full, snapshot state and return */
|
||||
|
||||
if (gotcount >= len) {
|
||||
bd->writePos = pos;
|
||||
bd->writeCurrent = current;
|
||||
@@ -560,13 +515,11 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
}
|
||||
|
||||
/* Write next byte into output buffer, updating CRC */
|
||||
|
||||
outbuf[gotcount++] = current;
|
||||
bd->writeCRC = (bd->writeCRC << 8)
|
||||
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
|
||||
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
|
||||
|
||||
/* Loop now if we're outputting multiple copies of this byte */
|
||||
|
||||
if (bd->writeCopies) {
|
||||
--bd->writeCopies;
|
||||
continue;
|
||||
@@ -582,35 +535,29 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
/* After 3 consecutive copies of the same byte, the 4th
|
||||
* is a repeat count. We count down from 4 instead
|
||||
* of counting up because testing for non-zero is faster */
|
||||
|
||||
if (--bd->writeRunCountdown) {
|
||||
if (current != previous)
|
||||
bd->writeRunCountdown = 4;
|
||||
} else {
|
||||
|
||||
/* We have a repeated run, this byte indicates the count */
|
||||
|
||||
bd->writeCopies = current;
|
||||
current = previous;
|
||||
bd->writeRunCountdown = 5;
|
||||
|
||||
/* Sometimes there are just 3 bytes (run length 0) */
|
||||
|
||||
if (!bd->writeCopies) goto decode_next_byte;
|
||||
|
||||
/* Subtract the 1 copy we'd output anyway to get extras */
|
||||
|
||||
--bd->writeCopies;
|
||||
}
|
||||
}
|
||||
|
||||
/* Decompression of this block completed successfully */
|
||||
|
||||
bd->writeCRC = ~bd->writeCRC;
|
||||
bd->totalCRC = ((bd->totalCRC << 1) | (bd->totalCRC >> 31)) ^ bd->writeCRC;
|
||||
|
||||
/* If this block had a CRC error, force file level CRC error. */
|
||||
|
||||
if (bd->writeCRC != bd->headerCRC) {
|
||||
bd->totalCRC = bd->headerCRC + 1;
|
||||
return RETVAL_LAST_BLOCK;
|
||||
@@ -619,7 +566,6 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
|
||||
/* Refill the intermediate buffer by Huffman-decoding next block of input */
|
||||
/* (previous is just a convenient unused temp variable here) */
|
||||
|
||||
previous = get_next_block(bd);
|
||||
if (previous) {
|
||||
bd->writeCount = previous;
|
||||
@@ -631,7 +577,6 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
goto decode_next_byte;
|
||||
}
|
||||
|
||||
|
||||
/* Allocate the structure, read file header. If in_fd==-1, inbuf must contain
|
||||
a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are
|
||||
ignored, and data is read from file handle into temporary buffer. */
|
||||
@@ -639,7 +584,6 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
/* Because bunzip2 is used for help text unpacking, and because bb_show_usage()
|
||||
should work for NOFORK applets too, we must be extremely careful to not leak
|
||||
any allocations! */
|
||||
|
||||
int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
|
||||
int len)
|
||||
{
|
||||
@@ -650,16 +594,13 @@ int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
|
||||
};
|
||||
|
||||
/* Figure out how much data to allocate */
|
||||
|
||||
i = sizeof(bunzip_data);
|
||||
if (in_fd != -1) i += IOBUF_SIZE;
|
||||
|
||||
/* Allocate bunzip_data. Most fields initialize to zero. */
|
||||
|
||||
bd = *bdp = xzalloc(i);
|
||||
|
||||
/* Setup input buffer */
|
||||
|
||||
bd->in_fd = in_fd;
|
||||
if (-1 == in_fd) {
|
||||
/* in this case, bd->inbuf is read-only */
|
||||
@@ -669,22 +610,18 @@ int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
|
||||
bd->inbuf = (unsigned char *)(bd + 1);
|
||||
|
||||
/* Init the CRC32 table (big endian) */
|
||||
|
||||
crc32_filltable(bd->crc32Table, 1);
|
||||
|
||||
/* Setup for I/O error handling via longjmp */
|
||||
|
||||
i = setjmp(bd->jmpbuf);
|
||||
if (i) return i;
|
||||
|
||||
/* Ensure that file starts with "BZh['1'-'9']." */
|
||||
|
||||
i = get_bits(bd, 32);
|
||||
if ((unsigned)(i - BZh0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA;
|
||||
|
||||
/* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
|
||||
/* Fourth byte (ascii '1'-'9') indicates block size in units of 100k of
|
||||
uncompressed data. Allocate intermediate buffer for block. */
|
||||
|
||||
bd->dbufSize = 100000 * (i - BZh0);
|
||||
|
||||
/* Cannot use xmalloc - may leak bd in NOFORK case! */
|
||||
@@ -704,7 +641,6 @@ void dealloc_bunzip(bunzip_data *bd)
|
||||
|
||||
|
||||
/* Decompress src_fd to dst_fd. Stops at end of bzip data, not end of file. */
|
||||
|
||||
USE_DESKTOP(long long) int
|
||||
unpack_bz2_stream(int src_fd, int dst_fd)
|
||||
{
|
||||
@@ -761,9 +697,9 @@ int main(int argc, char **argv)
|
||||
char c;
|
||||
|
||||
if (i < 0)
|
||||
fprintf(stderr,"%s\n", bunzip_errors[-i]);
|
||||
else if (read(0, &c, 1))
|
||||
fprintf(stderr,"Trailing garbage ignored\n");
|
||||
fprintf(stderr, "%s\n", bunzip_errors[-i]);
|
||||
else if (read(STDIN_FILENO, &c, 1))
|
||||
fprintf(stderr, "Trailing garbage ignored\n");
|
||||
return -i;
|
||||
}
|
||||
#endif
|
||||
@@ -329,7 +329,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
if (buffer_pos == header.dict_size) {
|
||||
buffer_pos = 0;
|
||||
global_pos += header.dict_size;
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)
|
||||
goto bad;
|
||||
USE_DESKTOP(total_written += header.dict_size;)
|
||||
}
|
||||
@@ -480,7 +480,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
if (buffer_pos == header.dict_size) {
|
||||
buffer_pos = 0;
|
||||
global_pos += header.dict_size;
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)
|
||||
goto bad;
|
||||
USE_DESKTOP(total_written += header.dict_size;)
|
||||
}
|
||||
@@ -489,7 +489,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
}
|
||||
}
|
||||
|
||||
if (full_write(dst_fd, buffer, buffer_pos) != buffer_pos) {
|
||||
if (full_write(dst_fd, buffer, buffer_pos) != (ssize_t)buffer_pos) {
|
||||
bad:
|
||||
rc_free(rc);
|
||||
return -1;
|
||||
|
||||
@@ -922,7 +922,7 @@ static int inflate_block(STATE_PARAM smallint *e)
|
||||
/* Two callsites, both in inflate_get_next_window */
|
||||
static void calculate_gunzip_crc(STATE_PARAM_ONLY)
|
||||
{
|
||||
int n;
|
||||
unsigned n;
|
||||
for (n = 0; n < gunzip_outbuf_count; n++) {
|
||||
gunzip_crc = gunzip_crc_table[((int) gunzip_crc ^ (gunzip_window[n])) & 0xff] ^ (gunzip_crc >> 8);
|
||||
}
|
||||
@@ -1003,7 +1003,7 @@ inflate_unzip_internal(STATE_PARAM int in, int out)
|
||||
while (1) {
|
||||
int r = inflate_get_next_window(PASS_STATE_ONLY);
|
||||
nwrote = full_write(out, gunzip_window, gunzip_outbuf_count);
|
||||
if (nwrote != gunzip_outbuf_count) {
|
||||
if (nwrote != (ssize_t)gunzip_outbuf_count) {
|
||||
bb_perror_msg("write");
|
||||
n = -1;
|
||||
goto ret;
|
||||
@@ -1064,7 +1064,7 @@ static int top_up(STATE_PARAM unsigned n)
|
||||
{
|
||||
int count = bytebuffer_size - bytebuffer_offset;
|
||||
|
||||
if (count < n) {
|
||||
if (count < (int)n) {
|
||||
memmove(bytebuffer, &bytebuffer[bytebuffer_offset], count);
|
||||
bytebuffer_offset = 0;
|
||||
bytebuffer_size = full_read(gunzip_src_fd, &bytebuffer[count], bytebuffer_max - count);
|
||||
|
||||
@@ -7,71 +7,33 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
typedef struct hardlinks_s {
|
||||
char *name;
|
||||
int inode;
|
||||
struct hardlinks_s *next;
|
||||
typedef struct hardlinks_t {
|
||||
struct hardlinks_t *next;
|
||||
int inode; /* TODO: must match maj/min too! */
|
||||
int mode ;
|
||||
int mtime; /* These three are useful only in corner case */
|
||||
int uid ; /* of hardlinks with zero size body */
|
||||
int gid ;
|
||||
char name[1];
|
||||
} hardlinks_t;
|
||||
|
||||
char get_header_cpio(archive_handle_t *archive_handle)
|
||||
{
|
||||
static hardlinks_t *saved_hardlinks = NULL;
|
||||
static unsigned pending_hardlinks = 0;
|
||||
static int inode;
|
||||
static hardlinks_t *saved_hardlinks_created = NULL;
|
||||
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
char cpio_header[110];
|
||||
int namesize;
|
||||
char dummy[16];
|
||||
int major, minor, nlink;
|
||||
|
||||
if (pending_hardlinks) { /* Deal with any pending hardlinks */
|
||||
hardlinks_t *tmp, *oldtmp;
|
||||
|
||||
tmp = saved_hardlinks;
|
||||
oldtmp = NULL;
|
||||
|
||||
file_header->link_target = file_header->name;
|
||||
file_header->size = 0;
|
||||
|
||||
while (tmp) {
|
||||
if (tmp->inode != inode) {
|
||||
tmp = tmp->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
file_header->name = tmp->name;
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_data(archive_handle);
|
||||
archive_handle->action_header(archive_handle->file_header);
|
||||
}
|
||||
|
||||
pending_hardlinks--;
|
||||
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
free(oldtmp->name);
|
||||
free(oldtmp);
|
||||
if (oldtmp == saved_hardlinks)
|
||||
saved_hardlinks = tmp;
|
||||
}
|
||||
|
||||
file_header->name = file_header->link_target;
|
||||
|
||||
if (pending_hardlinks > 1) {
|
||||
bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?");
|
||||
}
|
||||
|
||||
/* No more pending hardlinks, read next file entry */
|
||||
pending_hardlinks = 0;
|
||||
}
|
||||
int namesize;
|
||||
int major, minor, nlink, mode, inode;
|
||||
unsigned size, uid, gid, mtime;
|
||||
|
||||
/* There can be padding before archive header */
|
||||
data_align(archive_handle, 4);
|
||||
|
||||
if (archive_xread_all_eof(archive_handle, (unsigned char*)cpio_header, 110) == 0) {
|
||||
return EXIT_FAILURE;
|
||||
goto create_hardlinks;
|
||||
}
|
||||
archive_handle->offset += 110;
|
||||
|
||||
@@ -81,17 +43,19 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
bb_error_msg_and_die("unsupported cpio format, use newc or crc");
|
||||
}
|
||||
|
||||
{
|
||||
unsigned long tmpsize;
|
||||
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
|
||||
dummy, &inode, (unsigned int*)&file_header->mode,
|
||||
(unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
|
||||
&nlink, &file_header->mtime, &tmpsize,
|
||||
dummy, &major, &minor, &namesize, dummy);
|
||||
file_header->size = tmpsize;
|
||||
}
|
||||
sscanf(cpio_header + 6,
|
||||
"%8x" "%8x" "%8x" "%8x"
|
||||
"%8x" "%8x" "%8x" /*maj,min:*/ "%16c"
|
||||
/*rmaj,rmin:*/"%8x" "%8x" "%8x" /*chksum:*/ "%8c",
|
||||
&inode, &mode, &uid, &gid,
|
||||
&nlink, &mtime, &size, dummy,
|
||||
&major, &minor, &namesize, dummy);
|
||||
file_header->mode = mode;
|
||||
file_header->uid = uid;
|
||||
file_header->gid = gid;
|
||||
file_header->mtime = mtime;
|
||||
file_header->size = size;
|
||||
|
||||
free(file_header->name);
|
||||
file_header->name = xzalloc(namesize + 1);
|
||||
/* Read in filename */
|
||||
xread(archive_handle->src_fd, file_header->name, namesize);
|
||||
@@ -101,25 +65,9 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
data_align(archive_handle, 4);
|
||||
|
||||
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
|
||||
/* Always round up */
|
||||
printf("%d blocks\n", (int) (archive_handle->offset % 512 ?
|
||||
archive_handle->offset / 512 + 1 :
|
||||
archive_handle->offset / 512
|
||||
));
|
||||
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
|
||||
hardlinks_t *tmp = saved_hardlinks;
|
||||
hardlinks_t *oldtmp = NULL;
|
||||
while (tmp) {
|
||||
bb_error_msg("%s not created: cannot resolve hardlink", tmp->name);
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
free(oldtmp->name);
|
||||
free(oldtmp);
|
||||
}
|
||||
saved_hardlinks = NULL;
|
||||
pending_hardlinks = 0;
|
||||
}
|
||||
return EXIT_FAILURE;
|
||||
/* Always round up. ">> 9" divides by 512 */
|
||||
printf("%"OFF_FMT"u blocks\n", (archive_handle->offset + 511) >> 9);
|
||||
goto create_hardlinks;
|
||||
}
|
||||
|
||||
if (S_ISLNK(file_header->mode)) {
|
||||
@@ -130,25 +78,33 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
} else {
|
||||
file_header->link_target = NULL;
|
||||
}
|
||||
if (nlink > 1 && !S_ISDIR(file_header->mode)) {
|
||||
if (file_header->size == 0) { /* Put file on a linked list for later */
|
||||
hardlinks_t *new = xmalloc(sizeof(hardlinks_t));
|
||||
|
||||
// TODO: data_extract_all can't deal with hardlinks to non-files...
|
||||
// (should be !S_ISDIR instead of S_ISREG here)
|
||||
|
||||
if (nlink > 1 && S_ISREG(file_header->mode)) {
|
||||
hardlinks_t *new = xmalloc(sizeof(*new) + namesize);
|
||||
new->inode = inode;
|
||||
new->mode = mode ;
|
||||
new->mtime = mtime;
|
||||
new->uid = uid ;
|
||||
new->gid = gid ;
|
||||
strcpy(new->name, file_header->name);
|
||||
/* Put file on a linked list for later */
|
||||
if (size == 0) {
|
||||
new->next = saved_hardlinks;
|
||||
new->inode = inode;
|
||||
/* name current allocated, freed later */
|
||||
new->name = file_header->name;
|
||||
file_header->name = NULL;
|
||||
saved_hardlinks = new;
|
||||
return EXIT_SUCCESS; /* Skip this one */
|
||||
/* TODO: this breaks cpio -t (it does not show hardlinks) */
|
||||
}
|
||||
/* Found the file with data in */
|
||||
pending_hardlinks = nlink;
|
||||
new->next = saved_hardlinks_created;
|
||||
saved_hardlinks_created = new;
|
||||
}
|
||||
file_header->device = makedev(major, minor);
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_data(archive_handle);
|
||||
archive_handle->action_header(archive_handle->file_header);
|
||||
archive_handle->action_header(file_header);
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
}
|
||||
@@ -156,6 +112,58 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
free(file_header->link_target);
|
||||
free(file_header->name);
|
||||
file_header->link_target = NULL;
|
||||
file_header->name = NULL;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
create_hardlinks:
|
||||
free(file_header->link_target);
|
||||
free(file_header->name);
|
||||
|
||||
while (saved_hardlinks) {
|
||||
hardlinks_t *cur;
|
||||
hardlinks_t *make_me = saved_hardlinks;
|
||||
saved_hardlinks = make_me->next;
|
||||
|
||||
memset(file_header, 0, sizeof(*file_header));
|
||||
file_header->name = make_me->name;
|
||||
file_header->mode = make_me->mode;
|
||||
/*file_header->size = 0;*/
|
||||
|
||||
/* Try to find a file we are hardlinked to */
|
||||
cur = saved_hardlinks_created;
|
||||
while (cur) {
|
||||
/* TODO: must match maj/min too! */
|
||||
if (cur->inode == make_me->inode) {
|
||||
file_header->link_target = cur->name;
|
||||
/* link_target != NULL, size = 0: "I am a hardlink" */
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS)
|
||||
archive_handle->action_data(archive_handle);
|
||||
free(make_me);
|
||||
goto next_link;
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
/* Oops... no file with such inode was created... do it now
|
||||
* (happens when hardlinked files are empty (zero length)) */
|
||||
file_header->mtime = make_me->mtime;
|
||||
file_header->uid = make_me->uid ;
|
||||
file_header->gid = make_me->gid ;
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS)
|
||||
archive_handle->action_data(archive_handle);
|
||||
/* Move to the list of created hardlinked files */
|
||||
make_me->next = saved_hardlinks_created;
|
||||
saved_hardlinks_created = make_me;
|
||||
next_link: ;
|
||||
}
|
||||
|
||||
while (saved_hardlinks_created) {
|
||||
hardlinks_t *p = saved_hardlinks_created;
|
||||
saved_hardlinks_created = p->next;
|
||||
free(p);
|
||||
}
|
||||
|
||||
return EXIT_FAILURE; /* "No more files to process" */
|
||||
}
|
||||
@@ -99,7 +99,7 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
* "tar: A lone zero block at N", where N = kilobyte
|
||||
* where EOF was met (not EOF block, actual EOF!),
|
||||
* and tar will exit with error code 0.
|
||||
* We will mimic exit(0), although we will not mimic
|
||||
* We will mimic exit(EXIT_SUCCESS), although we will not mimic
|
||||
* the message and we don't check whether we indeed
|
||||
* saw zero block directly before this. */
|
||||
if (i == 0)
|
||||
@@ -112,7 +112,7 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
archive_handle->offset += 512;
|
||||
|
||||
/* If there is no filename its an empty header */
|
||||
if (tar.name[0] == 0) {
|
||||
if (tar.name[0] == 0 && tar.prefix[0] == 0) {
|
||||
if (end) {
|
||||
/* This is the second consecutive empty header! End of archive!
|
||||
* Read until the end to empty the pipe from gz or bz2
|
||||
@@ -138,12 +138,12 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
/* tar gz/bz autodetect: check for gz/bz2 magic.
|
||||
* If it is the very first block, and we see the magic,
|
||||
* we can switch to get_header_tar_gz/bz2/lzma().
|
||||
* Needs seekable fd. I wish recv(MSG_PEEK) would work
|
||||
* Needs seekable fd. I wish recv(MSG_PEEK) works
|
||||
* on any fd... */
|
||||
if (not_first)
|
||||
goto err;
|
||||
#if ENABLE_FEATURE_TAR_GZIP
|
||||
if (tar.name[0] == 0x1f && tar.name[1] == 0x8b) { /* gzip */
|
||||
if (tar.name[0] == 0x1f && tar.name[1] == (char)0x8b) { /* gzip */
|
||||
get_header_ptr = get_header_tar_gz;
|
||||
} else
|
||||
#endif
|
||||
@@ -211,15 +211,16 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
/* getOctal trashes subsequent field, therefore we call it
|
||||
* on fields in reverse order */
|
||||
if (tar.devmajor[0]) {
|
||||
char t = tar.prefix[0];
|
||||
/* we trash prefix[0] here, but we DO need it later! */
|
||||
unsigned minor = GET_OCTAL(tar.devminor);
|
||||
unsigned major = GET_OCTAL(tar.devmajor);
|
||||
file_header->device = makedev(major, minor);
|
||||
tar.prefix[0] = t;
|
||||
}
|
||||
file_header->link_target = NULL;
|
||||
if (!linkname && parse_names && tar.linkname[0]) {
|
||||
/* we trash magic[0] here, it's ok */
|
||||
tar.linkname[sizeof(tar.linkname)] = '\0';
|
||||
file_header->link_target = xstrdup(tar.linkname);
|
||||
file_header->link_target = xstrndup(tar.linkname, sizeof(tar.linkname));
|
||||
/* FIXME: what if we have non-link object with link_target? */
|
||||
/* Will link_target be free()ed? */
|
||||
}
|
||||
@@ -237,10 +238,12 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
file_header->name = NULL;
|
||||
if (!longname && parse_names) {
|
||||
/* we trash mode[0] here, it's ok */
|
||||
tar.name[sizeof(tar.name)] = '\0';
|
||||
//tar.name[sizeof(tar.name)] = '\0'; - gcc 4.3.0 would complain
|
||||
tar.mode[0] = '\0';
|
||||
if (tar.prefix[0]) {
|
||||
/* and padding[0] */
|
||||
tar.prefix[sizeof(tar.prefix)] = '\0';
|
||||
//tar.prefix[sizeof(tar.prefix)] = '\0'; - gcc 4.3.0 would complain
|
||||
tar.padding[0] = '\0';
|
||||
file_header->name = concat_path_file(tar.prefix, tar.name);
|
||||
} else
|
||||
file_header->name = xstrdup(tar.name);
|
||||
|
||||
@@ -22,11 +22,13 @@ int open_transformer(int src_fd,
|
||||
|
||||
#if BB_MMU
|
||||
pid = fork();
|
||||
if (pid == -1)
|
||||
bb_perror_msg_and_die("can't fork");
|
||||
#else
|
||||
pid = vfork();
|
||||
#endif
|
||||
if (pid == -1)
|
||||
bb_perror_msg_and_die("fork failed");
|
||||
bb_perror_msg_and_die("can't vfork");
|
||||
#endif
|
||||
|
||||
if (pid == 0) {
|
||||
/* child process */
|
||||
@@ -38,7 +40,7 @@ int open_transformer(int src_fd,
|
||||
close(fd_pipe.wr); /* Send EOF */
|
||||
close(src_fd);
|
||||
}
|
||||
exit(0);
|
||||
exit(EXIT_SUCCESS);
|
||||
#else
|
||||
{
|
||||
char *argv[4];
|
||||
@@ -49,7 +51,7 @@ int open_transformer(int src_fd,
|
||||
argv[2] = (char*)"-";
|
||||
argv[3] = NULL;
|
||||
BB_EXECVP(transform_prog, argv);
|
||||
bb_perror_msg_and_die("exec failed");
|
||||
bb_perror_msg_and_die("can't exec %s", transform_prog);
|
||||
}
|
||||
#endif
|
||||
/* notreached */
|
||||
|
||||
@@ -9,11 +9,9 @@
|
||||
void seek_by_jump(const archive_handle_t *archive_handle, unsigned amount)
|
||||
{
|
||||
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
|
||||
#if ENABLE_FEATURE_UNARCHIVE_TAPE
|
||||
if (errno == ESPIPE) {
|
||||
if (errno == ESPIPE)
|
||||
seek_by_read(archive_handle, amount);
|
||||
} else
|
||||
#endif
|
||||
else
|
||||
bb_perror_msg_and_die("seek failure");
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -13,14 +13,14 @@
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
|
||||
struct rpm_lead {
|
||||
unsigned char magic[4];
|
||||
uint8_t major, minor;
|
||||
uint16_t type;
|
||||
uint16_t archnum;
|
||||
char name[66];
|
||||
uint16_t osnum;
|
||||
uint16_t signature_type;
|
||||
char reserved[16];
|
||||
unsigned char magic[4];
|
||||
uint8_t major, minor;
|
||||
uint16_t type;
|
||||
uint16_t archnum;
|
||||
char name[66];
|
||||
uint16_t osnum;
|
||||
uint16_t signature_type;
|
||||
char reserved[16];
|
||||
};
|
||||
|
||||
struct rpm_header {
|
||||
|
||||
+117
-119
@@ -24,7 +24,6 @@
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <getopt.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
@@ -85,26 +84,26 @@ struct TarHeader { /* byte offset */
|
||||
*/
|
||||
typedef struct HardLinkInfo HardLinkInfo;
|
||||
struct HardLinkInfo {
|
||||
HardLinkInfo *next; /* Next entry in list */
|
||||
dev_t dev; /* Device number */
|
||||
ino_t ino; /* Inode number */
|
||||
short linkCount; /* (Hard) Link Count */
|
||||
char name[1]; /* Start of filename (must be last) */
|
||||
HardLinkInfo *next; /* Next entry in list */
|
||||
dev_t dev; /* Device number */
|
||||
ino_t ino; /* Inode number */
|
||||
short linkCount; /* (Hard) Link Count */
|
||||
char name[1]; /* Start of filename (must be last) */
|
||||
};
|
||||
|
||||
/* Some info to be carried along when creating a new tarball */
|
||||
typedef struct TarBallInfo TarBallInfo;
|
||||
struct TarBallInfo {
|
||||
int tarFd; /* Open-for-write file descriptor
|
||||
for the tarball */
|
||||
struct stat statBuf; /* Stat info for the tarball, letting
|
||||
us know the inode and device that the
|
||||
tarball lives, so we can avoid trying
|
||||
to include the tarball into itself */
|
||||
int verboseFlag; /* Whether to print extra stuff or not */
|
||||
const llist_t *excludeList; /* List of files to not include */
|
||||
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
|
||||
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
|
||||
int tarFd; /* Open-for-write file descriptor
|
||||
* for the tarball */
|
||||
struct stat statBuf; /* Stat info for the tarball, letting
|
||||
* us know the inode and device that the
|
||||
* tarball lives, so we can avoid trying
|
||||
* to include the tarball into itself */
|
||||
int verboseFlag; /* Whether to print extra stuff or not */
|
||||
const llist_t *excludeList; /* List of files to not include */
|
||||
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
|
||||
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
|
||||
};
|
||||
|
||||
/* A nice enum with all the possible tar file content types */
|
||||
@@ -504,11 +503,90 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
const unsigned long dereferenceFlag, const llist_t *include,
|
||||
const llist_t *exclude, const int gzip)
|
||||
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
|
||||
#if !(ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2)
|
||||
#define vfork_compressor(tar_fd, gzip) vfork_compressor(tar_fd)
|
||||
#endif
|
||||
/* Don't inline: vfork scares gcc and pessimizes code */
|
||||
static void NOINLINE vfork_compressor(int tar_fd, int gzip)
|
||||
{
|
||||
pid_t gzipPid;
|
||||
#if ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2
|
||||
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
|
||||
#elif ENABLE_FEATURE_TAR_GZIP
|
||||
const char *zip_exec = "gzip";
|
||||
#else /* only ENABLE_FEATURE_TAR_BZIP2 */
|
||||
const char *zip_exec = "bzip2";
|
||||
#endif
|
||||
// On Linux, vfork never unpauses parent early, although standard
|
||||
// allows for that. Do we want to waste bytes checking for it?
|
||||
#define WAIT_FOR_CHILD 0
|
||||
volatile int vfork_exec_errno = 0;
|
||||
struct fd_pair gzipDataPipe;
|
||||
#if WAIT_FOR_CHILD
|
||||
struct fd_pair gzipStatusPipe;
|
||||
xpiped_pair(gzipStatusPipe);
|
||||
#endif
|
||||
xpiped_pair(gzipDataPipe);
|
||||
|
||||
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
/* Avoid vfork clobbering */
|
||||
(void) &zip_exec;
|
||||
#endif
|
||||
|
||||
gzipPid = vfork();
|
||||
if (gzipPid < 0)
|
||||
bb_perror_msg_and_die("can't vfork");
|
||||
|
||||
if (gzipPid == 0) {
|
||||
/* child */
|
||||
/* NB: close _first_, then move fds! */
|
||||
close(gzipDataPipe.wr);
|
||||
#if WAIT_FOR_CHILD
|
||||
close(gzipStatusPipe.rd);
|
||||
/* gzipStatusPipe.wr will close only on exec -
|
||||
* parent waits for this close to happen */
|
||||
fcntl(gzipStatusPipe.wr, F_SETFD, FD_CLOEXEC);
|
||||
#endif
|
||||
xmove_fd(gzipDataPipe.rd, 0);
|
||||
xmove_fd(tar_fd, 1);
|
||||
/* exec gzip/bzip2 program/applet */
|
||||
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
|
||||
vfork_exec_errno = errno;
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* parent */
|
||||
xmove_fd(gzipDataPipe.wr, tar_fd);
|
||||
close(gzipDataPipe.rd);
|
||||
#if WAIT_FOR_CHILD
|
||||
close(gzipStatusPipe.wr);
|
||||
while (1) {
|
||||
char buf;
|
||||
int n;
|
||||
|
||||
/* Wait until child execs (or fails to) */
|
||||
n = full_read(gzipStatusPipe.rd, &buf, 1);
|
||||
if (n < 0 /* && errno == EAGAIN */)
|
||||
continue; /* try it again */
|
||||
}
|
||||
close(gzipStatusPipe.rd);
|
||||
#endif
|
||||
if (vfork_exec_errno) {
|
||||
errno = vfork_exec_errno;
|
||||
bb_perror_msg_and_die("cannot exec %s", zip_exec);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2 */
|
||||
|
||||
|
||||
/* gcc 4.2.1 inlines it, making code bigger */
|
||||
static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
|
||||
int dereferenceFlag, const llist_t *include,
|
||||
const llist_t *exclude, int gzip)
|
||||
{
|
||||
pid_t gzipPid = 0;
|
||||
int errorFlag = FALSE;
|
||||
struct TarBallInfo tbInfo;
|
||||
|
||||
@@ -524,80 +602,8 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
bb_perror_msg_and_die("cannot stat tar file");
|
||||
|
||||
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
|
||||
if (gzip) {
|
||||
#if ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2
|
||||
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
|
||||
#elif ENABLE_FEATURE_TAR_GZIP
|
||||
const char *zip_exec = "gzip";
|
||||
#else /* only ENABLE_FEATURE_TAR_BZIP2 */
|
||||
const char *zip_exec = "bzip2";
|
||||
#endif
|
||||
// On Linux, vfork never unpauses parent early, although standard
|
||||
// allows for that. Do we want to waste bytes checking for it?
|
||||
#define WAIT_FOR_CHILD 0
|
||||
volatile int vfork_exec_errno = 0;
|
||||
#if WAIT_FOR_CHILD
|
||||
struct fd_pair gzipStatusPipe;
|
||||
#endif
|
||||
struct fd_pair gzipDataPipe;
|
||||
xpiped_pair(gzipDataPipe);
|
||||
#if WAIT_FOR_CHILD
|
||||
xpiped_pair(gzipStatusPipe);
|
||||
#endif
|
||||
|
||||
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
/* Avoid vfork clobbering */
|
||||
(void) &include;
|
||||
(void) &errorFlag;
|
||||
(void) &zip_exec;
|
||||
#endif
|
||||
|
||||
gzipPid = vfork();
|
||||
if (gzipPid < 0)
|
||||
bb_perror_msg_and_die("vfork gzip");
|
||||
|
||||
if (gzipPid == 0) {
|
||||
/* child */
|
||||
/* NB: close _first_, then move fds! */
|
||||
close(gzipDataPipe.wr);
|
||||
#if WAIT_FOR_CHILD
|
||||
close(gzipStatusPipe.rd);
|
||||
/* gzipStatusPipe.wr will close only on exec -
|
||||
* parent waits for this close to happen */
|
||||
fcntl(gzipStatusPipe.wr, F_SETFD, FD_CLOEXEC);
|
||||
#endif
|
||||
xmove_fd(gzipDataPipe.rd, 0);
|
||||
xmove_fd(tbInfo.tarFd, 1);
|
||||
/* exec gzip/bzip2 program/applet */
|
||||
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
|
||||
vfork_exec_errno = errno;
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
/* parent */
|
||||
xmove_fd(gzipDataPipe.wr, tbInfo.tarFd);
|
||||
close(gzipDataPipe.rd);
|
||||
#if WAIT_FOR_CHILD
|
||||
close(gzipStatusPipe.wr);
|
||||
while (1) {
|
||||
char buf;
|
||||
int n;
|
||||
|
||||
/* Wait until child execs (or fails to) */
|
||||
n = full_read(gzipStatusPipe.rd, &buf, 1);
|
||||
if (n < 0 /* && errno == EAGAIN */)
|
||||
continue; /* try it again */
|
||||
|
||||
}
|
||||
close(gzipStatusPipe.rd);
|
||||
#endif
|
||||
if (vfork_exec_errno) {
|
||||
errno = vfork_exec_errno;
|
||||
bb_perror_msg_and_die("cannot exec %s", zip_exec);
|
||||
}
|
||||
}
|
||||
if (gzip)
|
||||
vfork_compressor(tbInfo.tarFd, gzip);
|
||||
#endif
|
||||
|
||||
tbInfo.excludeList = exclude;
|
||||
@@ -631,37 +637,34 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
if (errorFlag)
|
||||
bb_error_msg("error exit delayed from previous errors");
|
||||
|
||||
if (gzipPid) {
|
||||
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
|
||||
if (gzip) {
|
||||
int status;
|
||||
if (safe_waitpid(gzipPid, &status, 0) == -1)
|
||||
if (safe_waitpid(-1, &status, 0) == -1)
|
||||
bb_perror_msg("waitpid");
|
||||
else if (!WIFEXITED(status) || WEXITSTATUS(status))
|
||||
/* gzip was killed or has exited with nonzero! */
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
#endif
|
||||
return errorFlag;
|
||||
}
|
||||
#else
|
||||
int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
const unsigned long dereferenceFlag, const llist_t *include,
|
||||
const llist_t *exclude, const int gzip);
|
||||
int writeTarFile(int tar_fd, int verboseFlag,
|
||||
int dereferenceFlag, const llist_t *include,
|
||||
const llist_t *exclude, int gzip);
|
||||
#endif /* FEATURE_TAR_CREATE */
|
||||
|
||||
#if ENABLE_FEATURE_TAR_FROM
|
||||
static llist_t *append_file_list_to_list(llist_t *list)
|
||||
{
|
||||
FILE *src_stream;
|
||||
llist_t *cur = list;
|
||||
llist_t *tmp;
|
||||
char *line;
|
||||
llist_t *newlist = NULL;
|
||||
|
||||
while (cur) {
|
||||
src_stream = xfopen(cur->data, "r");
|
||||
tmp = cur;
|
||||
cur = cur->link;
|
||||
free(tmp);
|
||||
while ((line = xmalloc_getline(src_stream)) != NULL) {
|
||||
while (list) {
|
||||
src_stream = xfopen(llist_pop(&list), "r");
|
||||
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
|
||||
/* kill trailing '/' unless the string is just "/" */
|
||||
char *cp = last_char_is(line, '/');
|
||||
if (cp > line)
|
||||
@@ -797,7 +800,7 @@ static const char tar_longopts[] ALIGN1 =
|
||||
#endif
|
||||
|
||||
int tar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int tar_main(int argc, char **argv)
|
||||
int tar_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
char (*get_header_ptr)(archive_handle_t *) = get_header_tar;
|
||||
archive_handle_t *tar_handle;
|
||||
@@ -847,6 +850,7 @@ int tar_main(int argc, char **argv)
|
||||
, &verboseFlag // combined count for -t and -v
|
||||
, &verboseFlag // combined count for -t and -v
|
||||
);
|
||||
argv += optind;
|
||||
|
||||
if (verboseFlag) tar_handle->action_header = header_verbose_list;
|
||||
if (verboseFlag == 1) tar_handle->action_header = header_list;
|
||||
@@ -892,21 +896,15 @@ int tar_main(int argc, char **argv)
|
||||
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
|
||||
#endif
|
||||
|
||||
/* Check if we are reading from stdin */
|
||||
if (argv[optind] && *argv[optind] == '-') {
|
||||
/* Default is to read from stdin, so just skip to next arg */
|
||||
optind++;
|
||||
}
|
||||
|
||||
/* Setup an array of filenames to work with */
|
||||
/* TODO: This is the same as in ar, separate function ? */
|
||||
while (optind < argc) {
|
||||
while (*argv) {
|
||||
/* kill trailing '/' unless the string is just "/" */
|
||||
char *cp = last_char_is(argv[optind], '/');
|
||||
if (cp > argv[optind])
|
||||
char *cp = last_char_is(*argv, '/');
|
||||
if (cp > *argv)
|
||||
*cp = '\0';
|
||||
llist_add_to_end(&tar_handle->accept, argv[optind]);
|
||||
optind++;
|
||||
llist_add_to_end(&tar_handle->accept, *argv);
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (tar_handle->accept || tar_handle->reject)
|
||||
|
||||
+2
-10
@@ -9,25 +9,17 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
enum {
|
||||
VT_ACTIVATE = 0x5606, /* make vt active */
|
||||
VT_WAITACTIVE = 0x5607 /* wait for vt active */
|
||||
};
|
||||
|
||||
int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
int num;
|
||||
|
||||
if (argc != 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
fd = get_console_fd();
|
||||
num = xatou_range(argv[1], 1, 63);
|
||||
/* double cast suppresses "cast to ptr from int of different size" */
|
||||
xioctl(fd, VT_ACTIVATE, (void *)(ptrdiff_t)num);
|
||||
xioctl(fd, VT_WAITACTIVE, (void *)(ptrdiff_t)num);
|
||||
console_make_active(get_console_fd(), num);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
*/
|
||||
/* no options, no getopt */
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
@@ -23,18 +24,17 @@ struct kbentry {
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int dumpkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int dumpkmap_main(int argc, char **argv)
|
||||
int dumpkmap_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
char flags[MAX_NR_KEYMAPS];
|
||||
RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
|
||||
|
||||
if (argc >= 2 && argv[1][0] == '-')
|
||||
bb_show_usage();
|
||||
/* bb_warn_ignoring_args(argc>=2);*/
|
||||
|
||||
fd = xopen(CURRENT_VC, O_RDWR);
|
||||
|
||||
write(1, "bkeymap", 7);
|
||||
write(STDOUT_FILENO, "bkeymap", 7);
|
||||
|
||||
/* Here we want to set everything to 0 except for indexes:
|
||||
* [0-2] [4-6] [8-10] [12] */
|
||||
@@ -43,7 +43,7 @@ int dumpkmap_main(int argc, char **argv)
|
||||
flags[3] = flags[7] = flags[11] = 0;
|
||||
|
||||
/* dump flags */
|
||||
write(1, flags, MAX_NR_KEYMAPS);
|
||||
write(STDOUT_FILENO, flags, MAX_NR_KEYMAPS);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
@@ -56,11 +56,14 @@ int dumpkmap_main(int argc, char **argv)
|
||||
(char *)&ke.kb_table,
|
||||
&ke.kb_value)
|
||||
) {
|
||||
write(1, (void*)&ke.kb_value, 2);
|
||||
write(STDOUT_FILENO, (void*)&ke.kb_value, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(fd);
|
||||
RELEASE_CONFIG_BUFFER(flags);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+31
-46
@@ -1,8 +1,8 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini loadkmap implementation for busybox
|
||||
* Mini kbd_mode implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2007 Loïc Grenié <loic.grenie@gmail.com>
|
||||
* Copyright (C) 2007 Loic Grenie <loic.grenie@gmail.com>
|
||||
* written using Andries Brouwer <aeb@cwi.nl>'s kbd_mode from
|
||||
* console-utils v0.2.3, licensed under GNU GPLv2
|
||||
*
|
||||
@@ -10,59 +10,44 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include "libbb.h"
|
||||
#include <linux/kd.h>
|
||||
|
||||
int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int kbd_mode_main(int argc, char **argv)
|
||||
int kbd_mode_main(int ATTRIBUTE_UNUSED argc, char **argv)
|
||||
{
|
||||
static const char opts[] = "saku";
|
||||
|
||||
const char *opt = argv[1];
|
||||
const char *p;
|
||||
int fd;
|
||||
|
||||
unsigned opt;
|
||||
enum {
|
||||
SCANCODE = (1<<0),
|
||||
ASCII = (1<<1),
|
||||
MEDIUMRAW= (1<<2),
|
||||
UNICODE = (1<<3)
|
||||
};
|
||||
static const char KD_xxx[] ALIGN1 = "saku";
|
||||
opt = getopt32(argv, KD_xxx);
|
||||
fd = get_console_fd();
|
||||
if (fd < 0) /* get_console_fd() already complained */
|
||||
/* if (fd < 0)
|
||||
return EXIT_FAILURE;
|
||||
*/
|
||||
if (!opt) { /* print current setting */
|
||||
const char *mode = "unknown";
|
||||
int m;
|
||||
|
||||
if (opt == NULL) {
|
||||
/* No arg */
|
||||
const char *msg = "unknown";
|
||||
int mode;
|
||||
|
||||
ioctl(fd, KDGKBMODE, &mode);
|
||||
switch(mode) {
|
||||
case K_RAW:
|
||||
msg = "raw (scancode)";
|
||||
break;
|
||||
case K_XLATE:
|
||||
msg = "default (ASCII)";
|
||||
break;
|
||||
case K_MEDIUMRAW:
|
||||
msg = "mediumraw (keycode)";
|
||||
break;
|
||||
case K_UNICODE:
|
||||
msg = "Unicode (UTF-8)";
|
||||
break;
|
||||
}
|
||||
printf("The keyboard is in %s mode\n", msg);
|
||||
}
|
||||
else if (argc > 2 /* more than 1 arg */
|
||||
|| *opt != '-' /* not an option */
|
||||
|| (p = strchr(opts, opt[1])) == NULL /* not an option we expect */
|
||||
|| opt[2] != '\0' /* more than one option char */
|
||||
) {
|
||||
bb_show_usage();
|
||||
/* return EXIT_FAILURE; - not reached */
|
||||
}
|
||||
else {
|
||||
#if K_RAW != 0 || K_XLATE != 1 || K_MEDIUMRAW != 2 || K_UNICODE != 3
|
||||
#error kbd_mode must be changed
|
||||
#endif
|
||||
/* The options are in the order of the various K_xxx */
|
||||
ioctl(fd, KDSKBMODE, p - opts);
|
||||
ioctl(fd, KDGKBMODE, &m);
|
||||
if (m == K_RAW)
|
||||
mode = "raw (scancode)";
|
||||
else if (m == K_XLATE)
|
||||
mode = "default (ASCII)";
|
||||
else if (m == K_MEDIUMRAW)
|
||||
mode = "mediumraw (keycode)";
|
||||
else if (m == K_UNICODE)
|
||||
mode = "Unicode (UTF-8)";
|
||||
printf("The keyboard is in %s mode\n", mode);
|
||||
} else {
|
||||
opt = opt & UNICODE ? 3 : opt >> 1;
|
||||
/* double cast prevents warnings about widening conversion */
|
||||
xioctl(fd, KDSKBMODE, (void*)(ptrdiff_t)opt);
|
||||
}
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
|
||||
+13
-12
@@ -26,28 +26,26 @@ struct kbentry {
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int loadkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int loadkmap_main(int argc, char **argv ATTRIBUTE_UNUSED)
|
||||
int loadkmap_main(int ATTRIBUTE_UNUSED argc, char **argv ATTRIBUTE_UNUSED)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
uint16_t ibuff[NR_KEYS];
|
||||
char flags[MAX_NR_KEYMAPS];
|
||||
char buff[7];
|
||||
RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
|
||||
|
||||
if (argc != 1)
|
||||
bb_show_usage();
|
||||
/* bb_warn_ignoring_args(argc>=2);*/
|
||||
|
||||
fd = xopen(CURRENT_VC, O_RDWR);
|
||||
|
||||
xread(0, buff, 7);
|
||||
if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||
bb_error_msg_and_die("this is not a valid binary keymap");
|
||||
xread(STDIN_FILENO, flags, 7);
|
||||
if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7))
|
||||
bb_error_msg_and_die("not a valid binary keymap");
|
||||
|
||||
xread(0, flags, MAX_NR_KEYMAPS);
|
||||
xread(STDIN_FILENO, flags, MAX_NR_KEYMAPS);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
xread(0, ibuff, NR_KEYS * sizeof(uint16_t));
|
||||
xread(STDIN_FILENO, ibuff, NR_KEYS * sizeof(uint16_t));
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
@@ -57,6 +55,9 @@ int loadkmap_main(int argc, char **argv ATTRIBUTE_UNUSED)
|
||||
}
|
||||
}
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP) close(fd);
|
||||
return 0;
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(fd);
|
||||
RELEASE_CONFIG_BUFFER(flags);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+162
-17
@@ -8,29 +8,174 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <linux/vt.h>
|
||||
#include "libbb.h"
|
||||
|
||||
int openvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int openvt_main(int argc, char **argv)
|
||||
/* "Standard" openvt's man page (we do not support all of this):
|
||||
|
||||
openvt [-c NUM] [-fsulv] [--] [command [args]]
|
||||
|
||||
Find the first available VT, and run command on it. Stdio is directed
|
||||
to that VT. If no command is specified then $SHELL is used.
|
||||
|
||||
-c NUM
|
||||
Use the given VT number, not the first free one.
|
||||
-f
|
||||
Force opening a VT: don't try to check if VT is already in use.
|
||||
-s
|
||||
Switch to the new VT when starting the command.
|
||||
The VT of the new command will be made the new current VT.
|
||||
-u
|
||||
Figure out the owner of the current VT, and run login as that user.
|
||||
Suitable to be called by init. Shouldn't be used with -c or -l.
|
||||
-l
|
||||
Make the command a login shell: a "-" is prepended to the argv[0]
|
||||
when command is executed.
|
||||
-v
|
||||
Verbose.
|
||||
-w
|
||||
Wait for command to complete. If -w and -s are used together,
|
||||
switch back to the controlling terminal when the command completes.
|
||||
|
||||
bbox:
|
||||
-u: not implemented
|
||||
-f: always in effect
|
||||
-l: not implemented, ignored
|
||||
-v: ignored
|
||||
-ws: does NOT switch back
|
||||
*/
|
||||
|
||||
/* Helper: does this fd understand VT_xxx? */
|
||||
static int not_vt_fd(int fd)
|
||||
{
|
||||
char vtname[sizeof(VC_FORMAT) + 2];
|
||||
struct vt_stat vtstat;
|
||||
return ioctl(fd, VT_GETSTATE, &vtstat); /* !0: error, it's not VT fd */
|
||||
}
|
||||
|
||||
if (argc < 3)
|
||||
bb_show_usage();
|
||||
/* Helper: get a fd suitable for VT_xxx */
|
||||
static int get_vt_fd(void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
/* check for illegal vt number: < 1 or > 63 */
|
||||
sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63));
|
||||
/* Do we, by chance, already have it? */
|
||||
for (fd = 0; fd < 3; fd++)
|
||||
if (!not_vt_fd(fd))
|
||||
return fd;
|
||||
/* _only_ O_NONBLOCK: ask for neither read nor write perms */
|
||||
/*FIXME: use? device_open(DEV_CONSOLE,0); */
|
||||
fd = open(DEV_CONSOLE, O_NONBLOCK);
|
||||
if (fd >= 0 && !not_vt_fd(fd))
|
||||
return fd;
|
||||
bb_error_msg_and_die("can't find open VT");
|
||||
}
|
||||
|
||||
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
|
||||
/* grab new one */
|
||||
close(0);
|
||||
static int find_free_vtno(void)
|
||||
{
|
||||
int vtno;
|
||||
int fd = get_vt_fd();
|
||||
|
||||
errno = 0;
|
||||
/*xfunc_error_retval = 3; - do we need compat? */
|
||||
if (ioctl(fd, VT_OPENQRY, &vtno) != 0 || vtno <= 0)
|
||||
bb_perror_msg_and_die("can't find open VT");
|
||||
// Not really needed, grep for DAEMON_ONLY_SANITIZE
|
||||
// if (fd > 2)
|
||||
// close(fd);
|
||||
return vtno;
|
||||
}
|
||||
|
||||
/* vfork scares gcc, it generates bigger code.
|
||||
* Keep it away from main program.
|
||||
* TODO: move to libbb; or adapt existing libbb's spawn().
|
||||
*/
|
||||
static NOINLINE void vfork_child(char **argv)
|
||||
{
|
||||
if (vfork() == 0) {
|
||||
/* CHILD */
|
||||
/* Try to make this VT our controlling tty */
|
||||
setsid(); /* lose old ctty */
|
||||
ioctl(STDIN_FILENO, TIOCSCTTY, 0 /* 0: don't forcibly steal */);
|
||||
//bb_error_msg("our sid %d", getsid(0));
|
||||
//bb_error_msg("our pgrp %d", getpgrp());
|
||||
//bb_error_msg("VT's sid %d", tcgetsid(0));
|
||||
//bb_error_msg("VT's pgrp %d", tcgetpgrp(0));
|
||||
BB_EXECVP(argv[0], argv);
|
||||
bb_perror_msg_and_die("exec %s", argv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
int openvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int openvt_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
char vtname[sizeof(VC_FORMAT) + sizeof(int)*3];
|
||||
struct vt_stat vtstat;
|
||||
char *str_c;
|
||||
int vtno;
|
||||
int flags;
|
||||
enum {
|
||||
OPT_c = (1 << 0),
|
||||
OPT_w = (1 << 1),
|
||||
OPT_s = (1 << 2),
|
||||
OPT_l = (1 << 3),
|
||||
OPT_f = (1 << 4),
|
||||
OPT_v = (1 << 5),
|
||||
};
|
||||
|
||||
/* "+" - stop on first non-option */
|
||||
flags = getopt32(argv, "+c:wslfv", &str_c);
|
||||
argv += optind;
|
||||
|
||||
if (flags & OPT_c) {
|
||||
/* Check for illegal vt number: < 1 or > 63 */
|
||||
vtno = xatou_range(str_c, 1, 63);
|
||||
} else {
|
||||
vtno = find_free_vtno();
|
||||
}
|
||||
|
||||
/* Grab new VT */
|
||||
sprintf(vtname, VC_FORMAT, vtno);
|
||||
/* (Try to) clean up stray open fds above fd 2 */
|
||||
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS | DAEMON_ONLY_SANITIZE, NULL);
|
||||
close(STDIN_FILENO);
|
||||
/*setsid(); - BAD IDEA: after we exit, child is SIGHUPed... */
|
||||
xopen(vtname, O_RDWR);
|
||||
xdup2(0, STDOUT_FILENO);
|
||||
xdup2(0, STDERR_FILENO);
|
||||
xioctl(STDIN_FILENO, VT_GETSTATE, &vtstat);
|
||||
|
||||
if (flags & OPT_s) {
|
||||
console_make_active(STDIN_FILENO, vtno);
|
||||
}
|
||||
|
||||
if (!argv[0]) {
|
||||
argv--;
|
||||
argv[0] = getenv("SHELL");
|
||||
if (!argv[0])
|
||||
argv[0] = (char *) DEFAULT_SHELL;
|
||||
/*argv[1] = NULL; - already is */
|
||||
}
|
||||
|
||||
xdup2(STDIN_FILENO, STDOUT_FILENO);
|
||||
xdup2(STDIN_FILENO, STDERR_FILENO);
|
||||
|
||||
#ifdef BLOAT
|
||||
{
|
||||
/* Handle -l (login shell) option */
|
||||
const char *prog = argv[0];
|
||||
if (flags & OPT_l)
|
||||
argv[0] = xasprintf("-%s", argv[0]);
|
||||
}
|
||||
#endif
|
||||
|
||||
argv += 2;
|
||||
BB_EXECVP(argv[0], argv);
|
||||
_exit(1);
|
||||
vfork_child(argv);
|
||||
if (flags & OPT_w) {
|
||||
/* We have only one child, wait for it */
|
||||
safe_waitpid(-1, NULL, 0); /* loops on EINTR */
|
||||
if (flags & OPT_s) {
|
||||
console_make_active(STDIN_FILENO, vtstat.v_active);
|
||||
// Compat: even with -c N (try to) disallocate:
|
||||
// # /usr/app/kbd-1.12/bin/openvt -f -c 9 -ws sleep 5
|
||||
// openvt: could not deallocate console 9
|
||||
xioctl(STDIN_FILENO, VT_DISALLOCATE, (void*)(ptrdiff_t)vtno);
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -26,7 +26,7 @@ int reset_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
if (isatty(0) && isatty(1)) {
|
||||
if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
|
||||
/* See 'man 4 console_codes' for details:
|
||||
* "ESC c" -- Reset
|
||||
* "ESC ( K" -- Select user mapping
|
||||
|
||||
@@ -17,7 +17,7 @@ static void
|
||||
onintr(int sig ATTRIBUTE_UNUSED)
|
||||
{
|
||||
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int resize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
|
||||
+13
-20
@@ -3,41 +3,34 @@
|
||||
* setconsole.c - redirect system console output
|
||||
*
|
||||
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
|
||||
* Copyright (C) 2008 Bernhard Fischer
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include "libbb.h"
|
||||
|
||||
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
static const char setconsole_longopts[] ALIGN1 =
|
||||
"reset\0" No_argument "r"
|
||||
;
|
||||
#endif
|
||||
|
||||
#define OPT_SETCONS_RESET 1
|
||||
|
||||
int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setconsole_main(int argc, char **argv)
|
||||
int setconsole_main(int ATTRIBUTE_UNUSED argc, char **argv)
|
||||
{
|
||||
unsigned long flags;
|
||||
const char *device = CURRENT_TTY;
|
||||
bool reset;
|
||||
|
||||
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
static const char setconsole_longopts[] ALIGN1 =
|
||||
"reset\0" No_argument "r"
|
||||
;
|
||||
applet_long_options = setconsole_longopts;
|
||||
#endif
|
||||
flags = getopt32(argv, "r");
|
||||
/* at most one non-option argument */
|
||||
opt_complementary = "?1";
|
||||
reset = getopt32(argv, "r");
|
||||
|
||||
if (argc - optind > 1)
|
||||
bb_show_usage();
|
||||
|
||||
if (argc - optind == 1) {
|
||||
if (flags & OPT_SETCONS_RESET)
|
||||
bb_show_usage();
|
||||
device = argv[optind];
|
||||
argv += 1 + reset;
|
||||
if (*argv) {
|
||||
device = *argv;
|
||||
} else {
|
||||
if (flags & OPT_SETCONS_RESET)
|
||||
if (reset)
|
||||
device = DEV_CONSOLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,15 +17,14 @@ int setlogcons_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
struct {
|
||||
char fn;
|
||||
char subarg;
|
||||
} arg;
|
||||
|
||||
arg.fn = 11; /* redirect kernel messages */
|
||||
arg.subarg = 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);
|
||||
|
||||
xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+6
-2
@@ -30,6 +30,7 @@ lib-$(CONFIG_DOS2UNIX) += dos2unix.o
|
||||
lib-$(CONFIG_DU) += du.o
|
||||
lib-$(CONFIG_ECHO) += echo.o
|
||||
lib-$(CONFIG_ASH) += echo.o # used by ash
|
||||
lib-$(CONFIG_HUSH) += echo.o # used by hush
|
||||
lib-$(CONFIG_ENV) += env.o
|
||||
lib-$(CONFIG_EXPR) += expr.o
|
||||
lib-$(CONFIG_EXPAND) += expand.o
|
||||
@@ -53,6 +54,7 @@ lib-$(CONFIG_NOHUP) += nohup.o
|
||||
lib-$(CONFIG_OD) += od.o
|
||||
lib-$(CONFIG_PRINTENV) += printenv.o
|
||||
lib-$(CONFIG_PRINTF) += printf.o
|
||||
lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o
|
||||
lib-$(CONFIG_PWD) += pwd.o
|
||||
lib-$(CONFIG_READLINK) += readlink.o
|
||||
lib-$(CONFIG_REALPATH) += realpath.o
|
||||
@@ -70,8 +72,10 @@ lib-$(CONFIG_SYNC) += sync.o
|
||||
lib-$(CONFIG_TAC) += tac.o
|
||||
lib-$(CONFIG_TAIL) += tail.o
|
||||
lib-$(CONFIG_TEE) += tee.o
|
||||
lib-$(CONFIG_TEST) += test.o
|
||||
lib-$(CONFIG_ASH) += test.o # used by ash
|
||||
lib-$(CONFIG_TEST) += test.o test_ptr_hack.o
|
||||
lib-$(CONFIG_ASH) += test.o test_ptr_hack.o # used by ash
|
||||
lib-$(CONFIG_HUSH) += test.o test_ptr_hack.o # used by hush
|
||||
lib-$(CONFIG_MSH) += test.o test_ptr_hack.o # used by msh
|
||||
lib-$(CONFIG_TOUCH) += touch.o
|
||||
lib-$(CONFIG_TR) += tr.o
|
||||
lib-$(CONFIG_TRUE) += true.o
|
||||
|
||||
@@ -37,15 +37,16 @@ int basename_main(int argc, char **argv)
|
||||
/* It should strip slash: /abc/def/ -> def */
|
||||
s = bb_get_last_path_component_strip(*++argv);
|
||||
|
||||
m = strlen(s);
|
||||
if (*++argv) {
|
||||
n = strlen(*argv);
|
||||
m = strlen(s);
|
||||
if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) {
|
||||
s[m-n] = '\0';
|
||||
m -= n;
|
||||
/*s[m] = '\0'; - redundant */
|
||||
}
|
||||
}
|
||||
|
||||
puts(s);
|
||||
|
||||
return fflush(stdout);
|
||||
/* puts(s) will do, but we can do without stdio this way: */
|
||||
s[m++] = '\n';
|
||||
return full_write(STDOUT_FILENO, s, m) != (ssize_t)m;
|
||||
}
|
||||
+1
-1
@@ -179,7 +179,7 @@ int cal_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
fflush_stdout_and_exit(0);
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -61,7 +61,6 @@ static int fileAction(const char *fileName, struct stat *statbuf,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int chown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int chown_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ int cksum_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
|
||||
#define read_buf bb_common_bufsiz1
|
||||
while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 0) {
|
||||
cp = read_buf;
|
||||
cp = (uint8_t *) read_buf;
|
||||
length += bytes_read;
|
||||
do {
|
||||
crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *cp++];
|
||||
|
||||
+13
-11
@@ -37,25 +37,27 @@ int cp_main(int argc, char **argv)
|
||||
OPT_r = 1 << (sizeof(FILEUTILS_CP_OPTSTR)),
|
||||
OPT_P = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+1),
|
||||
OPT_H = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+2),
|
||||
OPT_L = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+3),
|
||||
};
|
||||
|
||||
// Need at least two arguments
|
||||
// Soft- and hardlinking don't mix
|
||||
// Soft- and hardlinking doesn't mix
|
||||
// -P and -d are the same (-P is POSIX, -d is GNU)
|
||||
// -r and -R are the same
|
||||
// -R (and therefore -r) switches on -d (coreutils does this)
|
||||
// -R (and therefore -r) turns on -d (coreutils does this)
|
||||
// -a = -pdR
|
||||
opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR";
|
||||
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPHL");
|
||||
opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR:HL";
|
||||
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPH");
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */
|
||||
/* Default behavior of cp is to dereference, so we don't have to do
|
||||
* anything special when we are given -L.
|
||||
* The behavior of -H is *almost* like -L, but not quite, so let's
|
||||
* just ignore it too for fun.
|
||||
if (flags & OPT_L) ...
|
||||
flags ^= FILEUTILS_DEREFERENCE; /* the sense of this flag was reversed */
|
||||
/* coreutils 6.9 compat:
|
||||
* by default, "cp" derefs symlinks (creates regular dest files),
|
||||
* but "cp -R" does not. We switch off deref if -r or -R (see above).
|
||||
* However, "cp -RL" must still deref symlinks: */
|
||||
if (flags & FILEUTILS_DEREF_SOFTLINK) /* -L */
|
||||
flags |= FILEUTILS_DEREFERENCE;
|
||||
/* The behavior of -H is *almost* like -L, but not quite, so let's
|
||||
* just ignore it too for fun. TODO.
|
||||
if (flags & OPT_H) ... // deref command-line params only
|
||||
*/
|
||||
|
||||
|
||||
+5
-5
@@ -51,7 +51,7 @@ static void cut_file(FILE *file, char delim)
|
||||
unsigned int linenum = 0; /* keep these zero-based to be consistent */
|
||||
|
||||
/* go through every line in the file */
|
||||
while ((line = xmalloc_getline(file)) != NULL) {
|
||||
while ((line = xmalloc_fgetline(file)) != NULL) {
|
||||
|
||||
/* set up a list so we can keep track of what's been printed */
|
||||
char * printed = xzalloc(strlen(line) * sizeof(char));
|
||||
@@ -64,7 +64,7 @@ static void cut_file(FILE *file, char delim)
|
||||
/* print the chars specified in each cut list */
|
||||
for (; cl_pos < nlists; cl_pos++) {
|
||||
spos = cut_lists[cl_pos].startpos;
|
||||
while (spos < strlen(line)) {
|
||||
while (spos < (int)strlen(line)) {
|
||||
if (!printed[spos]) {
|
||||
printed[spos] = 'X';
|
||||
putchar(line[spos]);
|
||||
@@ -80,12 +80,12 @@ static void cut_file(FILE *file, char delim)
|
||||
|
||||
/* get out if we have no more lists to process or if the lines
|
||||
* are lower than what we're interested in */
|
||||
if (linenum < spos || cl_pos >= nlists)
|
||||
if (((int)linenum < spos) || (cl_pos >= nlists))
|
||||
goto next_line;
|
||||
|
||||
/* if the line we're looking for is lower than the one we were
|
||||
* passed, it means we displayed it already, so move on */
|
||||
while (spos < linenum) {
|
||||
while (spos < (int)linenum) {
|
||||
spos++;
|
||||
/* go to the next list if we're at the end of this one */
|
||||
if (spos > cut_lists[cl_pos].endpos
|
||||
@@ -97,7 +97,7 @@ static void cut_file(FILE *file, char delim)
|
||||
spos = cut_lists[cl_pos].startpos;
|
||||
/* get out if the current line is lower than the one
|
||||
* we just became interested in */
|
||||
if (linenum < spos)
|
||||
if ((int)linenum < spos)
|
||||
goto next_line;
|
||||
}
|
||||
}
|
||||
|
||||
+108
-106
@@ -39,131 +39,135 @@ static void maybe_set_utc(int opt)
|
||||
}
|
||||
|
||||
int date_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int date_main(int argc, char **argv)
|
||||
int date_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
time_t tm;
|
||||
struct tm tm_time;
|
||||
time_t tm;
|
||||
unsigned opt;
|
||||
int ifmt = -1;
|
||||
char *date_str = NULL;
|
||||
char *date_fmt = NULL;
|
||||
char *filename = NULL;
|
||||
char *isofmt_arg;
|
||||
char *hintfmt_arg;
|
||||
char *date_str;
|
||||
char *fmt_dt2str;
|
||||
char *fmt_str2dt;
|
||||
char *filename;
|
||||
char *isofmt_arg = NULL;
|
||||
|
||||
opt_complementary = "d--s:s--d"
|
||||
USE_FEATURE_DATE_ISOFMT(":R--I:I--R");
|
||||
opt = getopt32(argv, "Rs:ud:r:"
|
||||
USE_FEATURE_DATE_ISOFMT("I::D:"),
|
||||
&date_str, &date_str, &filename
|
||||
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg));
|
||||
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt));
|
||||
argv += optind;
|
||||
maybe_set_utc(opt);
|
||||
|
||||
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_TIMESPEC)) {
|
||||
if (!isofmt_arg) {
|
||||
ifmt = 0; /* default is date */
|
||||
} else {
|
||||
static const char *const isoformats[] = {
|
||||
"date", "hours", "minutes", "seconds"
|
||||
};
|
||||
|
||||
for (ifmt = 0; ifmt < 4; ifmt++)
|
||||
if (!strcmp(isofmt_arg, isoformats[ifmt]))
|
||||
goto found;
|
||||
/* parse error */
|
||||
bb_show_usage();
|
||||
found: ;
|
||||
ifmt = 0; /* default is date */
|
||||
if (isofmt_arg) {
|
||||
static const char isoformats[] ALIGN1 =
|
||||
"date\0""hours\0""minutes\0""seconds\0";
|
||||
ifmt = index_in_strings(isoformats, isofmt_arg);
|
||||
if (ifmt < 0)
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX, date_fmt == NULL from this always */
|
||||
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+')) {
|
||||
date_fmt = &argv[optind][1]; /* Skip over the '+' */
|
||||
} else if (date_str == NULL) {
|
||||
opt |= DATE_OPT_SET;
|
||||
date_str = argv[optind];
|
||||
fmt_dt2str = NULL;
|
||||
if (argv[0] && argv[0][0] == '+') {
|
||||
fmt_dt2str = &argv[0][1]; /* Skip over the '+' */
|
||||
argv++;
|
||||
}
|
||||
if (!(opt & (DATE_OPT_SET | DATE_OPT_DATE))) {
|
||||
opt |= DATE_OPT_SET;
|
||||
date_str = argv[0]; /* can be NULL */
|
||||
if (date_str)
|
||||
argv++;
|
||||
}
|
||||
if (*argv)
|
||||
bb_show_usage();
|
||||
|
||||
/* Now we have parsed all the information except the date format
|
||||
which depends on whether the clock is being set or read */
|
||||
|
||||
if (filename) {
|
||||
if (opt & DATE_OPT_REFERENCE) {
|
||||
struct stat statbuf;
|
||||
xstat(filename, &statbuf);
|
||||
tm = statbuf.st_mtime;
|
||||
} else
|
||||
time(&tm);
|
||||
memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
|
||||
/* Zero out fields - take her back to midnight! */
|
||||
|
||||
/* If date string is given, update tm_time, and maybe set date */
|
||||
if (date_str != NULL) {
|
||||
/* Zero out fields - take her back to midnight! */
|
||||
tm_time.tm_sec = 0;
|
||||
tm_time.tm_min = 0;
|
||||
tm_time.tm_hour = 0;
|
||||
|
||||
/* Process any date input to UNIX time since 1 Jan 1970 */
|
||||
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_HINT)) {
|
||||
strptime(date_str, hintfmt_arg, &tm_time);
|
||||
} else if (strchr(date_str, ':') != NULL) {
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
if (strptime(date_str, fmt_str2dt, &tm_time) == NULL)
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
} else {
|
||||
char end = '\0';
|
||||
const char *last_colon = strrchr(date_str, ':');
|
||||
|
||||
if (sscanf(date_str, "%d:%d:%d", &tm_time.tm_hour, &tm_time.tm_min,
|
||||
&tm_time.tm_sec) == 3) {
|
||||
/* no adjustments needed */
|
||||
} else if (sscanf(date_str, "%d:%d", &tm_time.tm_hour,
|
||||
&tm_time.tm_min) == 2) {
|
||||
/* no adjustments needed */
|
||||
} else if (sscanf(date_str, "%d.%d-%d:%d:%d", &tm_time.tm_mon,
|
||||
&tm_time.tm_mday, &tm_time.tm_hour,
|
||||
&tm_time.tm_min, &tm_time.tm_sec) == 5) {
|
||||
/* Adjust dates from 1-12 to 0-11 */
|
||||
tm_time.tm_mon -= 1;
|
||||
} else if (sscanf(date_str, "%d.%d-%d:%d", &tm_time.tm_mon,
|
||||
&tm_time.tm_mday,
|
||||
&tm_time.tm_hour, &tm_time.tm_min) == 4) {
|
||||
/* Adjust dates from 1-12 to 0-11 */
|
||||
tm_time.tm_mon -= 1;
|
||||
} else if (sscanf(date_str, "%d.%d.%d-%d:%d:%d", &tm_time.tm_year,
|
||||
if (last_colon != NULL) {
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
|
||||
if (sscanf(date_str, "%u:%u%c",
|
||||
&tm_time.tm_hour,
|
||||
&tm_time.tm_min,
|
||||
&end) >= 2) {
|
||||
/* no adjustments needed */
|
||||
} else if (sscanf(date_str, "%u.%u-%u:%u%c",
|
||||
&tm_time.tm_mon, &tm_time.tm_mday,
|
||||
&tm_time.tm_hour, &tm_time.tm_min,
|
||||
&tm_time.tm_sec) == 6) {
|
||||
tm_time.tm_year -= 1900; /* Adjust years */
|
||||
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
} else if (sscanf(date_str, "%d.%d.%d-%d:%d", &tm_time.tm_year,
|
||||
&end) >= 4) {
|
||||
/* Adjust dates from 1-12 to 0-11 */
|
||||
tm_time.tm_mon -= 1;
|
||||
} else if (sscanf(date_str, "%u.%u.%u-%u:%u%c", &tm_time.tm_year,
|
||||
&tm_time.tm_mon, &tm_time.tm_mday,
|
||||
&tm_time.tm_hour, &tm_time.tm_min) == 5) {
|
||||
tm_time.tm_year -= 1900; /* Adjust years */
|
||||
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
} else {
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
}
|
||||
} else {
|
||||
int nr;
|
||||
char *cp;
|
||||
|
||||
nr = sscanf(date_str, "%2d%2d%2d%2d%d", &tm_time.tm_mon,
|
||||
&tm_time.tm_mday, &tm_time.tm_hour, &tm_time.tm_min,
|
||||
&tm_time.tm_year);
|
||||
|
||||
if (nr < 4 || nr > 5) {
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
}
|
||||
|
||||
cp = strchr(date_str, '.');
|
||||
if (cp) {
|
||||
nr = sscanf(cp + 1, "%2d", &tm_time.tm_sec);
|
||||
if (nr != 1) {
|
||||
&tm_time.tm_hour, &tm_time.tm_min,
|
||||
&end) >= 5) {
|
||||
tm_time.tm_year -= 1900; /* Adjust years */
|
||||
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
} else if (sscanf(date_str, "%u-%u-%u %u:%u%c", &tm_time.tm_year,
|
||||
&tm_time.tm_mon, &tm_time.tm_mday,
|
||||
&tm_time.tm_hour, &tm_time.tm_min,
|
||||
&end) >= 5) {
|
||||
tm_time.tm_year -= 1900; /* Adjust years */
|
||||
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
//TODO: coreutils 6.9 also accepts "YYYY-MM-DD HH" (no minutes)
|
||||
} else {
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
}
|
||||
if (end == ':') {
|
||||
if (sscanf(last_colon + 1, "%u%c", &tm_time.tm_sec, &end) == 1)
|
||||
end = '\0';
|
||||
/* else end != NUL and we error out */
|
||||
}
|
||||
} else {
|
||||
if (sscanf(date_str, "%2u%2u%2u%2u%u%c", &tm_time.tm_mon,
|
||||
&tm_time.tm_mday, &tm_time.tm_hour, &tm_time.tm_min,
|
||||
&tm_time.tm_year, &end) < 4)
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
if (tm_time.tm_year >= 1900) {
|
||||
tm_time.tm_year -= 1900;
|
||||
}
|
||||
/* adjust date */
|
||||
tm_time.tm_mon -= 1;
|
||||
if (end == '.') {
|
||||
if (sscanf(strchr(date_str, '.') + 1, "%u%c",
|
||||
&tm_time.tm_sec, &end) == 1)
|
||||
end = '\0';
|
||||
/* else end != NUL and we error out */
|
||||
}
|
||||
}
|
||||
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
if (tm_time.tm_year >= 1900) {
|
||||
tm_time.tm_year -= 1900;
|
||||
if (end != '\0') {
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
}
|
||||
/* adjust date */
|
||||
tm_time.tm_mon -= 1;
|
||||
}
|
||||
|
||||
/* Correct any day of week and day of year etc. fields */
|
||||
tm_time.tm_isdst = -1; /* Be sure to recheck dst. */
|
||||
tm = mktime(&tm_time);
|
||||
@@ -181,55 +185,53 @@ int date_main(int argc, char **argv)
|
||||
/* Display output */
|
||||
|
||||
/* Deal with format string */
|
||||
|
||||
if (date_fmt == NULL) {
|
||||
if (fmt_dt2str == NULL) {
|
||||
int i;
|
||||
date_fmt = xzalloc(32);
|
||||
fmt_dt2str = xzalloc(32);
|
||||
if (ENABLE_FEATURE_DATE_ISOFMT && ifmt >= 0) {
|
||||
strcpy(date_fmt, "%Y-%m-%d");
|
||||
strcpy(fmt_dt2str, "%Y-%m-%d");
|
||||
if (ifmt > 0) {
|
||||
i = 8;
|
||||
date_fmt[i++] = 'T';
|
||||
date_fmt[i++] = '%';
|
||||
date_fmt[i++] = 'H';
|
||||
fmt_dt2str[i++] = 'T';
|
||||
fmt_dt2str[i++] = '%';
|
||||
fmt_dt2str[i++] = 'H';
|
||||
if (ifmt > 1) {
|
||||
date_fmt[i++] = ':';
|
||||
date_fmt[i++] = '%';
|
||||
date_fmt[i++] = 'M';
|
||||
}
|
||||
if (ifmt > 2) {
|
||||
date_fmt[i++] = ':';
|
||||
date_fmt[i++] = '%';
|
||||
date_fmt[i++] = 'S';
|
||||
fmt_dt2str[i++] = ':';
|
||||
fmt_dt2str[i++] = '%';
|
||||
fmt_dt2str[i++] = 'M';
|
||||
if (ifmt > 2) {
|
||||
fmt_dt2str[i++] = ':';
|
||||
fmt_dt2str[i++] = '%';
|
||||
fmt_dt2str[i++] = 'S';
|
||||
}
|
||||
}
|
||||
format_utc:
|
||||
date_fmt[i++] = '%';
|
||||
date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
|
||||
fmt_dt2str[i++] = '%';
|
||||
fmt_dt2str[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
|
||||
}
|
||||
} else if (opt & DATE_OPT_RFC2822) {
|
||||
/* Undo busybox.c for date -R */
|
||||
if (ENABLE_LOCALE_SUPPORT)
|
||||
setlocale(LC_TIME, "C");
|
||||
strcpy(date_fmt, "%a, %d %b %Y %H:%M:%S ");
|
||||
strcpy(fmt_dt2str, "%a, %d %b %Y %H:%M:%S ");
|
||||
i = 22;
|
||||
goto format_utc;
|
||||
} else /* default case */
|
||||
date_fmt = (char*)"%a %b %e %H:%M:%S %Z %Y";
|
||||
fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y";
|
||||
}
|
||||
|
||||
#define date_buf bb_common_bufsiz1
|
||||
if (*date_fmt == '\0') {
|
||||
if (*fmt_dt2str == '\0') {
|
||||
/* With no format string, just print a blank line */
|
||||
date_buf[0] = '\0';
|
||||
} else {
|
||||
/* Handle special conversions */
|
||||
|
||||
if (strncmp(date_fmt, "%f", 2) == 0) {
|
||||
date_fmt = (char*)"%Y.%m.%d-%H:%M:%S";
|
||||
if (strncmp(fmt_dt2str, "%f", 2) == 0) {
|
||||
fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S";
|
||||
}
|
||||
|
||||
/* Generate output string */
|
||||
strftime(date_buf, sizeof(date_buf), date_fmt, &tm_time);
|
||||
strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time);
|
||||
}
|
||||
puts(date_buf);
|
||||
|
||||
|
||||
+89
-63
@@ -65,7 +65,7 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
|
||||
ssize_t n = full_write_or_warn(buf, len, filename);
|
||||
if (n < 0)
|
||||
return 1;
|
||||
if (n == obs)
|
||||
if ((size_t)n == obs)
|
||||
G.out_full++;
|
||||
else if (n) /* > 0 */
|
||||
G.out_part++;
|
||||
@@ -79,23 +79,31 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
|
||||
#endif
|
||||
|
||||
int dd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int dd_main(int argc, char **argv)
|
||||
int dd_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
enum {
|
||||
FLAG_SYNC = 1 << 0,
|
||||
FLAG_NOERROR = 1 << 1,
|
||||
FLAG_NOTRUNC = 1 << 2,
|
||||
FLAG_TWOBUFS = 1 << 3,
|
||||
FLAG_COUNT = 1 << 4,
|
||||
/* Must be in the same order as OP_conv_XXX! */
|
||||
/* (see "flags |= (1 << what)" below) */
|
||||
FLAG_NOTRUNC = 1 << 0,
|
||||
FLAG_SYNC = 1 << 1,
|
||||
FLAG_NOERROR = 1 << 2,
|
||||
FLAG_FSYNC = 1 << 3,
|
||||
/* end of conv flags */
|
||||
FLAG_TWOBUFS = 1 << 4,
|
||||
FLAG_COUNT = 1 << 5,
|
||||
};
|
||||
static const char keywords[] ALIGN1 =
|
||||
"bs=\0""count=\0""seek=\0""skip=\0""if=\0""of=\0"
|
||||
"bs\0""count\0""seek\0""skip\0""if\0""of\0"
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
"ibs=\0""obs=\0""conv=\0""notrunc\0""sync\0""noerror\0"
|
||||
"ibs\0""obs\0""conv\0"
|
||||
#endif
|
||||
;
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
static const char conv_words[] ALIGN1 =
|
||||
"notrunc\0""sync\0""noerror\0""fsync\0";
|
||||
#endif
|
||||
enum {
|
||||
OP_bs = 1,
|
||||
OP_bs = 0,
|
||||
OP_count,
|
||||
OP_seek,
|
||||
OP_skip,
|
||||
@@ -105,9 +113,23 @@ int dd_main(int argc, char **argv)
|
||||
OP_ibs,
|
||||
OP_obs,
|
||||
OP_conv,
|
||||
OP_conv_notrunc,
|
||||
/* Must be in the same order as FLAG_XXX! */
|
||||
OP_conv_notrunc = 0,
|
||||
OP_conv_sync,
|
||||
OP_conv_noerror,
|
||||
OP_conv_fsync,
|
||||
/* Unimplemented conv=XXX: */
|
||||
//nocreat do not create the output file
|
||||
//excl fail if the output file already exists
|
||||
//fdatasync physically write output file data before finishing
|
||||
//swab swap every pair of input bytes
|
||||
//lcase change upper case to lower case
|
||||
//ucase change lower case to upper case
|
||||
//block pad newline-terminated records with spaces to cbs-size
|
||||
//unblock replace trailing spaces in cbs-size records with newline
|
||||
//ascii from EBCDIC to ASCII
|
||||
//ebcdic from ASCII to EBCDIC
|
||||
//ibm from ASCII to alternate EBCDIC
|
||||
#endif
|
||||
};
|
||||
int exitcode = EXIT_FAILURE;
|
||||
@@ -138,85 +160,85 @@ int dd_main(int argc, char **argv)
|
||||
signal_SA_RESTART_empty_mask(SIGUSR1, dd_output_status);
|
||||
#endif
|
||||
|
||||
for (n = 1; n < argc; n++) {
|
||||
smalluint key_len;
|
||||
smalluint what;
|
||||
char *key;
|
||||
for (n = 1; argv[n]; n++) {
|
||||
int what;
|
||||
char *val;
|
||||
char *arg = argv[n];
|
||||
|
||||
//XXX:FIXME: we reject plain "dd --" This would cost ~20 bytes, so..
|
||||
//if (*arg == '-' && *++arg == '-' && !*++arg) continue;
|
||||
key = strstr(arg, "=");
|
||||
if (key == NULL)
|
||||
#if ENABLE_DESKTOP
|
||||
/* "dd --". NB: coreutils 6.9 will complain if they see
|
||||
* more than one of them. We wouldn't. */
|
||||
if (arg[0] == '-' && arg[1] == '-' && arg[2] == '\0')
|
||||
continue;
|
||||
#endif
|
||||
val = strchr(arg, '=');
|
||||
if (val == NULL)
|
||||
bb_show_usage();
|
||||
key_len = key - arg + 1;
|
||||
key = xstrndup(arg, key_len);
|
||||
what = index_in_strings(keywords, key) + 1;
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(key);
|
||||
if (what == 0)
|
||||
*val = '\0';
|
||||
what = index_in_strings(keywords, arg);
|
||||
if (what < 0)
|
||||
bb_show_usage();
|
||||
arg += key_len;
|
||||
/* *val = '='; - to preserve ps listing? */
|
||||
val++;
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (what == OP_ibs) {
|
||||
/* Must fit into positive ssize_t */
|
||||
ibs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
continue;
|
||||
ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_obs) {
|
||||
obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
continue;
|
||||
obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_conv) {
|
||||
while (1) {
|
||||
/* find ',', replace them with NUL so we can use arg for
|
||||
/* find ',', replace them with NUL so we can use val for
|
||||
* index_in_strings() without copying.
|
||||
* We rely on arg being non-null, else strchr would fault.
|
||||
* We rely on val being non-null, else strchr would fault.
|
||||
*/
|
||||
key = strchr(arg, ',');
|
||||
if (key)
|
||||
*key = '\0';
|
||||
what = index_in_strings(keywords, arg) + 1;
|
||||
if (what < OP_conv_notrunc)
|
||||
bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv");
|
||||
if (what == OP_conv_notrunc)
|
||||
flags |= FLAG_NOTRUNC;
|
||||
if (what == OP_conv_sync)
|
||||
flags |= FLAG_SYNC;
|
||||
if (what == OP_conv_noerror)
|
||||
flags |= FLAG_NOERROR;
|
||||
if (!key) /* no ',' left, so this was the last specifier */
|
||||
arg = strchr(val, ',');
|
||||
if (arg)
|
||||
*arg = '\0';
|
||||
what = index_in_strings(conv_words, val);
|
||||
if (what < 0)
|
||||
bb_error_msg_and_die(bb_msg_invalid_arg, val, "conv");
|
||||
flags |= (1 << what);
|
||||
if (!arg) /* no ',' left, so this was the last specifier */
|
||||
break;
|
||||
arg = key + 1; /* skip this keyword and ',' */
|
||||
/* *arg = ','; - to preserve ps listing? */
|
||||
val = arg + 1; /* skip this keyword and ',' */
|
||||
}
|
||||
continue;
|
||||
continue; /* we trashed 'what', can't fall through */
|
||||
}
|
||||
#endif
|
||||
if (what == OP_bs) {
|
||||
ibs = obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
continue;
|
||||
ibs = obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
/*continue;*/
|
||||
}
|
||||
/* These can be large: */
|
||||
if (what == OP_count) {
|
||||
flags |= FLAG_COUNT;
|
||||
count = XATOU_SFX(arg, dd_suffixes);
|
||||
continue;
|
||||
count = XATOU_SFX(val, dd_suffixes);
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_seek) {
|
||||
seek = XATOU_SFX(arg, dd_suffixes);
|
||||
continue;
|
||||
seek = XATOU_SFX(val, dd_suffixes);
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_skip) {
|
||||
skip = XATOU_SFX(arg, dd_suffixes);
|
||||
continue;
|
||||
skip = XATOU_SFX(val, dd_suffixes);
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_if) {
|
||||
infile = arg;
|
||||
continue;
|
||||
infile = val;
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_of)
|
||||
outfile = arg;
|
||||
}
|
||||
if (what == OP_of) {
|
||||
outfile = val;
|
||||
/*continue;*/
|
||||
}
|
||||
} /* end of "for (argv[n])" */
|
||||
|
||||
//XXX:FIXME for huge ibs or obs, malloc'ing them isn't the brightest idea ever
|
||||
ibuf = obuf = xmalloc(ibs);
|
||||
if (ibs != obs) {
|
||||
@@ -290,7 +312,7 @@ int dd_main(int argc, char **argv)
|
||||
while (n) {
|
||||
size_t d = obs - oc;
|
||||
|
||||
if (d > n)
|
||||
if (d > (size_t)n)
|
||||
d = n;
|
||||
memcpy(obuf + oc, tmp, d);
|
||||
n -= d;
|
||||
@@ -304,13 +326,17 @@ int dd_main(int argc, char **argv)
|
||||
}
|
||||
} else if (write_and_stats(ibuf, n, obs, outfile))
|
||||
goto out_status;
|
||||
|
||||
if (flags & FLAG_FSYNC) {
|
||||
if (fsync(ofd) < 0)
|
||||
goto die_outfile;
|
||||
}
|
||||
}
|
||||
|
||||
if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
|
||||
w = full_write_or_warn(obuf, oc, outfile);
|
||||
if (w < 0) goto out_status;
|
||||
if (w > 0)
|
||||
G.out_part++;
|
||||
if (w > 0) G.out_part++;
|
||||
}
|
||||
if (close(ifd) < 0) {
|
||||
die_infile:
|
||||
|
||||
+18
-15
@@ -24,24 +24,27 @@ static void convert(char *fn, int conv_type)
|
||||
{
|
||||
FILE *in, *out;
|
||||
int i;
|
||||
char *name_buf = name_buf; /* for compiler */
|
||||
char *temp_fn = temp_fn; /* for compiler */
|
||||
char *resolved_fn = resolved_fn;
|
||||
|
||||
in = stdin;
|
||||
out = stdout;
|
||||
if (fn != NULL) {
|
||||
in = xfopen(fn, "r");
|
||||
/*
|
||||
The file is then created with mode read/write and
|
||||
permissions 0666 for glibc 2.0.6 and earlier or
|
||||
0600 for glibc 2.0.7 and later.
|
||||
*/
|
||||
name_buf = xasprintf("%sXXXXXX", fn);
|
||||
i = mkstemp(name_buf);
|
||||
struct stat st;
|
||||
|
||||
resolved_fn = xmalloc_follow_symlinks(fn);
|
||||
if (resolved_fn == NULL)
|
||||
bb_simple_perror_msg_and_die(fn);
|
||||
in = xfopen(resolved_fn, "r");
|
||||
fstat(fileno(in), &st);
|
||||
|
||||
temp_fn = xasprintf("%sXXXXXX", resolved_fn);
|
||||
i = mkstemp(temp_fn);
|
||||
if (i == -1
|
||||
|| fchmod(i, 0600) == -1
|
||||
|| fchmod(i, st.st_mode) == -1
|
||||
|| !(out = fdopen(i, "w+"))
|
||||
) {
|
||||
bb_perror_nomsg_and_die();
|
||||
bb_simple_perror_msg_and_die(temp_fn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,12 +59,12 @@ static void convert(char *fn, int conv_type)
|
||||
|
||||
if (fn != NULL) {
|
||||
if (fclose(in) < 0 || fclose(out) < 0) {
|
||||
unlink(name_buf);
|
||||
unlink(temp_fn);
|
||||
bb_perror_nomsg_and_die();
|
||||
}
|
||||
// TODO: destroys symlinks. See how passwd handles this
|
||||
xrename(name_buf, fn);
|
||||
free(name_buf);
|
||||
xrename(temp_fn, resolved_fn);
|
||||
free(temp_fn);
|
||||
free(resolved_fn);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-7
@@ -27,10 +27,8 @@
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
/* argc is unused, but removing it precludes compiler from
|
||||
* using call -> jump optimization */
|
||||
/* NB: can be used by shell even if not enabled as applet */
|
||||
|
||||
int echo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int echo_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
const char *arg;
|
||||
@@ -110,15 +108,19 @@ int echo_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
}
|
||||
#if !ENABLE_FEATURE_FANCY_ECHO
|
||||
/* SUSv3 specifies that octal escapes must begin with '0'. */
|
||||
if ( (((unsigned char)*arg) - '1') >= 7)
|
||||
if ( ((int)(unsigned char)(*arg) - '0') >= 8) /* '8' or bigger */
|
||||
#endif
|
||||
{
|
||||
/* Since SUSv3 mandates a first digit of 0, 4-digit octals
|
||||
* of the form \0### are accepted. */
|
||||
if (*arg == '0' && ((unsigned char)(arg[1]) - '0') < 8) {
|
||||
arg++;
|
||||
if (*arg == '0') {
|
||||
/* NB: don't turn "...\0" into "...\" */
|
||||
if (arg[1] && ((unsigned char)(arg[1]) - '0') < 8) {
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
/* bb_process_escape_sequence can handle nul correctly */
|
||||
/* bb_process_escape_sequence handles NUL correctly
|
||||
* ("...\" case). */
|
||||
c = bb_process_escape_sequence(&arg);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-4
@@ -29,7 +29,6 @@
|
||||
* - use xfunc_error_retval
|
||||
*/
|
||||
|
||||
#include <getopt.h> /* struct option */
|
||||
#include "libbb.h"
|
||||
|
||||
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
|
||||
@@ -63,8 +62,7 @@ int env_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
environ = cleanenv;
|
||||
} else {
|
||||
while (unset_env) {
|
||||
unsetenv(unset_env->data);
|
||||
unset_env = unset_env->link;
|
||||
unsetenv(llist_pop(&unset_env));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +84,7 @@ int env_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
puts(*ep);
|
||||
}
|
||||
|
||||
fflush_stdout_and_exit(0);
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ static void expand(FILE *file, unsigned tab_size, unsigned opt)
|
||||
char *line;
|
||||
char *ptr;
|
||||
int convert;
|
||||
int pos;
|
||||
unsigned pos;
|
||||
|
||||
/* Increment tab_size by 1 locally.*/
|
||||
tab_size++;
|
||||
@@ -80,7 +80,7 @@ static void unexpand(FILE *file, unsigned int tab_size, unsigned opt)
|
||||
int convert;
|
||||
int pos;
|
||||
int i = 0;
|
||||
int column = 0;
|
||||
unsigned column = 0;
|
||||
|
||||
while ((line = xmalloc_fgets(file)) != NULL) {
|
||||
convert = 1;
|
||||
|
||||
+84
-87
@@ -28,13 +28,6 @@
|
||||
#include "libbb.h"
|
||||
#include "xregex.h"
|
||||
|
||||
/* The kinds of value we can have. */
|
||||
enum valtype {
|
||||
integer,
|
||||
string
|
||||
};
|
||||
typedef enum valtype TYPE;
|
||||
|
||||
#if ENABLE_EXPR_MATH_SUPPORT_64
|
||||
typedef int64_t arith_t;
|
||||
|
||||
@@ -51,10 +44,16 @@ typedef long arith_t;
|
||||
|
||||
/* TODO: use bb_strtol[l]? It's easier to check for errors... */
|
||||
|
||||
/* The kinds of value we can have. */
|
||||
enum {
|
||||
INTEGER,
|
||||
STRING
|
||||
};
|
||||
|
||||
/* A value is.... */
|
||||
struct valinfo {
|
||||
TYPE type; /* Which kind. */
|
||||
union { /* The value itself. */
|
||||
smallint type; /* Which kind. */
|
||||
union { /* The value itself. */
|
||||
arith_t i;
|
||||
char *s;
|
||||
} u;
|
||||
@@ -77,8 +76,9 @@ static VALUE *int_value(arith_t i)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
v = xmalloc(sizeof(VALUE));
|
||||
v->type = integer;
|
||||
v = xzalloc(sizeof(VALUE));
|
||||
if (INTEGER) /* otherwise xzaaloc did it already */
|
||||
v->type = INTEGER;
|
||||
v->u.i = i;
|
||||
return v;
|
||||
}
|
||||
@@ -89,46 +89,47 @@ static VALUE *str_value(const char *s)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
v = xmalloc(sizeof(VALUE));
|
||||
v->type = string;
|
||||
v = xzalloc(sizeof(VALUE));
|
||||
if (STRING) /* otherwise xzaaloc did it already */
|
||||
v->type = STRING;
|
||||
v->u.s = xstrdup(s);
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Free VALUE V, including structure components. */
|
||||
|
||||
static void freev(VALUE * v)
|
||||
static void freev(VALUE *v)
|
||||
{
|
||||
if (v->type == string)
|
||||
if (v->type == STRING)
|
||||
free(v->u.s);
|
||||
free(v);
|
||||
}
|
||||
|
||||
/* Return nonzero if V is a null-string or zero-number. */
|
||||
|
||||
static int null(VALUE * v)
|
||||
static int null(VALUE *v)
|
||||
{
|
||||
if (v->type == integer)
|
||||
if (v->type == INTEGER)
|
||||
return v->u.i == 0;
|
||||
/* string: */
|
||||
/* STRING: */
|
||||
return v->u.s[0] == '\0' || LONE_CHAR(v->u.s, '0');
|
||||
}
|
||||
|
||||
/* Coerce V to a string value (can't fail). */
|
||||
/* Coerce V to a STRING value (can't fail). */
|
||||
|
||||
static void tostring(VALUE * v)
|
||||
static void tostring(VALUE *v)
|
||||
{
|
||||
if (v->type == integer) {
|
||||
if (v->type == INTEGER) {
|
||||
v->u.s = xasprintf("%" PF_REZ "d", PF_REZ_TYPE v->u.i);
|
||||
v->type = string;
|
||||
v->type = STRING;
|
||||
}
|
||||
}
|
||||
|
||||
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
|
||||
/* Coerce V to an INTEGER value. Return 1 on success, 0 on failure. */
|
||||
|
||||
static bool toarith(VALUE * v)
|
||||
static bool toarith(VALUE *v)
|
||||
{
|
||||
if (v->type == string) {
|
||||
if (v->type == STRING) {
|
||||
arith_t i;
|
||||
char *e;
|
||||
|
||||
@@ -139,50 +140,54 @@ static bool toarith(VALUE * v)
|
||||
return 0;
|
||||
free(v->u.s);
|
||||
v->u.i = i;
|
||||
v->type = integer;
|
||||
v->type = INTEGER;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return nonzero if the next token matches STR exactly.
|
||||
/* Return str[0]+str[1] if the next token matches STR exactly.
|
||||
STR must not be NULL. */
|
||||
|
||||
static bool nextarg(const char *str)
|
||||
static int nextarg(const char *str)
|
||||
{
|
||||
if (*G.args == NULL)
|
||||
if (*G.args == NULL || strcmp(*G.args, str) != 0)
|
||||
return 0;
|
||||
return strcmp(*G.args, str) == 0;
|
||||
return (unsigned char)str[0] + (unsigned char)str[1];
|
||||
}
|
||||
|
||||
/* The comparison operator handling functions. */
|
||||
|
||||
static int cmp_common(VALUE * l, VALUE * r, int op)
|
||||
static int cmp_common(VALUE *l, VALUE *r, int op)
|
||||
{
|
||||
int cmpval;
|
||||
arith_t ll, rr;
|
||||
|
||||
if (l->type == string || r->type == string) {
|
||||
ll = l->u.i;
|
||||
rr = r->u.i;
|
||||
if (l->type == STRING || r->type == STRING) {
|
||||
tostring(l);
|
||||
tostring(r);
|
||||
cmpval = strcmp(l->u.s, r->u.s);
|
||||
} else
|
||||
cmpval = l->u.i - r->u.i;
|
||||
ll = strcmp(l->u.s, r->u.s);
|
||||
rr = 0;
|
||||
}
|
||||
/* calculating ll - rr and checking the result is prone to overflows.
|
||||
* We'll do it differently: */
|
||||
if (op == '<')
|
||||
return cmpval < 0;
|
||||
if (op == ('L' + 'E'))
|
||||
return cmpval <= 0;
|
||||
if (op == '=')
|
||||
return cmpval == 0;
|
||||
if (op == '!')
|
||||
return cmpval != 0;
|
||||
return ll < rr;
|
||||
if (op == ('<' + '='))
|
||||
return ll <= rr;
|
||||
if (op == '=' || (op == '=' + '='))
|
||||
return ll == rr;
|
||||
if (op == '!' + '=')
|
||||
return ll != rr;
|
||||
if (op == '>')
|
||||
return cmpval > 0;
|
||||
return ll > rr;
|
||||
/* >= */
|
||||
return cmpval >= 0;
|
||||
return ll >= rr;
|
||||
}
|
||||
|
||||
/* The arithmetic operator handling functions. */
|
||||
|
||||
static arith_t arithmetic_common(VALUE * l, VALUE * r, int op)
|
||||
static arith_t arithmetic_common(VALUE *l, VALUE *r, int op)
|
||||
{
|
||||
arith_t li, ri;
|
||||
|
||||
@@ -190,25 +195,24 @@ static arith_t arithmetic_common(VALUE * l, VALUE * r, int op)
|
||||
bb_error_msg_and_die("non-numeric argument");
|
||||
li = l->u.i;
|
||||
ri = r->u.i;
|
||||
if ((op == '/' || op == '%') && ri == 0)
|
||||
bb_error_msg_and_die("division by zero");
|
||||
if (op == '+')
|
||||
return li + ri;
|
||||
else if (op == '-')
|
||||
if (op == '-')
|
||||
return li - ri;
|
||||
else if (op == '*')
|
||||
if (op == '*')
|
||||
return li * ri;
|
||||
else if (op == '/')
|
||||
if (ri == 0)
|
||||
bb_error_msg_and_die("division by zero");
|
||||
if (op == '/')
|
||||
return li / ri;
|
||||
else
|
||||
return li % ri;
|
||||
return li % ri;
|
||||
}
|
||||
|
||||
/* Do the : operator.
|
||||
SV is the VALUE for the lhs (the string),
|
||||
PV is the VALUE for the rhs (the pattern). */
|
||||
|
||||
static VALUE *docolon(VALUE * sv, VALUE * pv)
|
||||
static VALUE *docolon(VALUE *sv, VALUE *pv)
|
||||
{
|
||||
VALUE *v;
|
||||
regex_t re_buffer;
|
||||
@@ -230,14 +234,16 @@ of a basic regular expression is not portable; it is being ignored", pv->u.s);
|
||||
|
||||
/* expr uses an anchored pattern match, so check that there was a
|
||||
* match and that the match starts at offset 0. */
|
||||
if (regexec(&re_buffer, sv->u.s, NMATCH, re_regs, 0) != REG_NOMATCH &&
|
||||
re_regs[0].rm_so == 0) {
|
||||
if (regexec(&re_buffer, sv->u.s, NMATCH, re_regs, 0) != REG_NOMATCH
|
||||
&& re_regs[0].rm_so == 0
|
||||
) {
|
||||
/* Were \(...\) used? */
|
||||
if (re_buffer.re_nsub > 0) {
|
||||
sv->u.s[re_regs[1].rm_eo] = '\0';
|
||||
v = str_value(sv->u.s + re_regs[1].rm_so);
|
||||
} else
|
||||
} else {
|
||||
v = int_value(re_regs[0].rm_eo);
|
||||
}
|
||||
} else {
|
||||
/* Match failed -- return the right kind of null. */
|
||||
if (re_buffer.re_nsub > 0)
|
||||
@@ -327,7 +333,7 @@ static VALUE *eval6(void)
|
||||
v = str_value("");
|
||||
else {
|
||||
v = xmalloc(sizeof(VALUE));
|
||||
v->type = string;
|
||||
v->type = STRING;
|
||||
v->u.s = xstrndup(l->u.s + i1->u.i - 1, i2->u.i);
|
||||
}
|
||||
freev(l);
|
||||
@@ -367,14 +373,11 @@ static VALUE *eval4(void)
|
||||
|
||||
l = eval5();
|
||||
while (1) {
|
||||
if (nextarg("*"))
|
||||
op = '*';
|
||||
else if (nextarg("/"))
|
||||
op = '/';
|
||||
else if (nextarg("%"))
|
||||
op = '%';
|
||||
else
|
||||
return l;
|
||||
op = nextarg("*");
|
||||
if (!op) { op = nextarg("/");
|
||||
if (!op) { op = nextarg("%");
|
||||
if (!op) return l;
|
||||
}}
|
||||
G.args++;
|
||||
r = eval5();
|
||||
val = arithmetic_common(l, r, op);
|
||||
@@ -394,12 +397,11 @@ static VALUE *eval3(void)
|
||||
|
||||
l = eval4();
|
||||
while (1) {
|
||||
if (nextarg("+"))
|
||||
op = '+';
|
||||
else if (nextarg("-"))
|
||||
op = '-';
|
||||
else
|
||||
return l;
|
||||
op = nextarg("+");
|
||||
if (!op) {
|
||||
op = nextarg("-");
|
||||
if (!op) return l;
|
||||
}
|
||||
G.args++;
|
||||
r = eval4();
|
||||
val = arithmetic_common(l, r, op);
|
||||
@@ -419,20 +421,15 @@ static VALUE *eval2(void)
|
||||
|
||||
l = eval3();
|
||||
while (1) {
|
||||
if (nextarg("<"))
|
||||
op = '<';
|
||||
else if (nextarg("<="))
|
||||
op = 'L' + 'E';
|
||||
else if (nextarg("=") || nextarg("=="))
|
||||
op = '=';
|
||||
else if (nextarg("!="))
|
||||
op = '!';
|
||||
else if (nextarg(">="))
|
||||
op = 'G' + 'E';
|
||||
else if (nextarg(">"))
|
||||
op = '>';
|
||||
else
|
||||
return l;
|
||||
op = nextarg("<");
|
||||
if (!op) { op = nextarg("<=");
|
||||
if (!op) { op = nextarg("=");
|
||||
if (!op) { op = nextarg("==");
|
||||
if (!op) { op = nextarg("!=");
|
||||
if (!op) { op = nextarg(">=");
|
||||
if (!op) { op = nextarg(">");
|
||||
if (!op) return l;
|
||||
}}}}}}
|
||||
G.args++;
|
||||
r = eval3();
|
||||
toarith(l);
|
||||
@@ -498,7 +495,7 @@ int expr_main(int argc, char **argv)
|
||||
if (*G.args)
|
||||
bb_error_msg_and_die("syntax error");
|
||||
|
||||
if (v->type == integer)
|
||||
if (v->type == INTEGER)
|
||||
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
|
||||
else
|
||||
puts(v->u.s);
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/false.html */
|
||||
/* http://www.opengroup.org/onlinepubs/000095399/utilities/false.html */
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
|
||||
@@ -9,9 +9,6 @@
|
||||
* owner/group, will probably modify bb_make_directory(...)
|
||||
*/
|
||||
|
||||
#include <libgen.h>
|
||||
#include <getopt.h> /* struct option */
|
||||
|
||||
#include "libbb.h"
|
||||
#include "libcoreutils/coreutils.h"
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@
|
||||
#ifndef COREUTILS_H
|
||||
#define COREUTILS_H 1
|
||||
|
||||
#if __GNUC_PREREQ(4,1)
|
||||
# pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
|
||||
typedef int (*stat_func)(const char *fn, struct stat *ps);
|
||||
|
||||
int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf);
|
||||
@@ -13,4 +17,8 @@ int cp_mv_stat(const char *fn, struct stat *fn_stat);
|
||||
|
||||
mode_t getopt_mk_fifo_nod(char **argv);
|
||||
|
||||
#if __GNUC_PREREQ(4,1)
|
||||
# pragma GCC visibility pop
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+87
-63
@@ -29,9 +29,12 @@
|
||||
* 1. requires lstat (BSD) - how do you do it without?
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include "libbb.h"
|
||||
|
||||
#if ENABLE_FEATURE_ASSUME_UNICODE
|
||||
#include <wchar.h>
|
||||
#endif
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
@@ -115,18 +118,6 @@ SPLIT_SUBDIR = 2,
|
||||
#define ATTR(mode) ("\00\00\01\00\01\00\01\00"\
|
||||
"\00\00\01\00\01\00\00\01" [TYPEINDEX(mode)])
|
||||
|
||||
/* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
|
||||
#if ENABLE_FEATURE_LS_COLOR
|
||||
static smallint show_color;
|
||||
/* long option entry used only for --color, which has no short option
|
||||
* equivalent */
|
||||
static const char ls_color_opt[] ALIGN1 =
|
||||
"color\0" Optional_argument "\xff" /* no short equivalent */
|
||||
;
|
||||
#else
|
||||
enum { show_color = 0 };
|
||||
#endif
|
||||
|
||||
/*
|
||||
* a directory entry and its stat info are stored here
|
||||
*/
|
||||
@@ -138,25 +129,68 @@ struct dnode { /* the basic node */
|
||||
USE_SELINUX(security_context_t sid;)
|
||||
struct dnode *next; /* point at the next node */
|
||||
};
|
||||
typedef struct dnode dnode_t;
|
||||
|
||||
static struct dnode **list_dir(const char *);
|
||||
static struct dnode **dnalloc(int);
|
||||
static int list_single(struct dnode *);
|
||||
static int list_single(const struct dnode *);
|
||||
|
||||
static unsigned all_fmt;
|
||||
|
||||
struct globals {
|
||||
#if ENABLE_FEATURE_LS_COLOR
|
||||
smallint show_color;
|
||||
#endif
|
||||
smallint exit_code;
|
||||
unsigned all_fmt;
|
||||
#if ENABLE_FEATURE_AUTOWIDTH
|
||||
static unsigned tabstops = COLUMN_GAP;
|
||||
static unsigned terminal_width = TERMINAL_WIDTH;
|
||||
unsigned tabstops; // = COLUMN_GAP;
|
||||
unsigned terminal_width; // = TERMINAL_WIDTH;
|
||||
#endif
|
||||
#if ENABLE_FEATURE_LS_TIMESTAMPS
|
||||
/* Do time() just once. Saves one syscall per file for "ls -l" */
|
||||
time_t current_time_t;
|
||||
#endif
|
||||
};
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#if ENABLE_FEATURE_LS_COLOR
|
||||
#define show_color (G.show_color )
|
||||
#else
|
||||
enum { show_color = 0 };
|
||||
#endif
|
||||
#define exit_code (G.exit_code )
|
||||
#define all_fmt (G.all_fmt )
|
||||
#if ENABLE_FEATURE_AUTOWIDTH
|
||||
#define tabstops (G.tabstops )
|
||||
#define terminal_width (G.terminal_width)
|
||||
#else
|
||||
enum {
|
||||
tabstops = COLUMN_GAP,
|
||||
terminal_width = TERMINAL_WIDTH,
|
||||
};
|
||||
#endif
|
||||
#define current_time_t (G.current_time_t)
|
||||
/* memset: we have to zero it out because of NOEXEC */
|
||||
#define INIT_G() do { \
|
||||
memset(&G, 0, sizeof(G)); \
|
||||
USE_FEATURE_AUTOWIDTH(tabstops = COLUMN_GAP;) \
|
||||
USE_FEATURE_AUTOWIDTH(terminal_width = TERMINAL_WIDTH;) \
|
||||
USE_FEATURE_LS_TIMESTAMPS(time(¤t_time_t);) \
|
||||
} while (0)
|
||||
|
||||
|
||||
#if ENABLE_FEATURE_ASSUME_UNICODE
|
||||
/* libbb candidate */
|
||||
static size_t mbstrlen(const char *string)
|
||||
{
|
||||
size_t width = mbsrtowcs(NULL /*dest*/, &string,
|
||||
MAXINT(size_t) /*len*/, NULL /*state*/);
|
||||
if (width == (size_t)-1)
|
||||
return strlen(string);
|
||||
return width;
|
||||
}
|
||||
#else
|
||||
#define mbstrlen(string) strlen(string)
|
||||
#endif
|
||||
|
||||
static int status = EXIT_SUCCESS;
|
||||
|
||||
static struct dnode *my_stat(const char *fullname, const char *name, int force_follow)
|
||||
{
|
||||
@@ -172,7 +206,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
|
||||
#endif
|
||||
if (stat(fullname, &dstat)) {
|
||||
bb_simple_perror_msg(fullname);
|
||||
status = EXIT_FAILURE;
|
||||
exit_code = EXIT_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
@@ -183,7 +217,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
|
||||
#endif
|
||||
if (lstat(fullname, &dstat)) {
|
||||
bb_simple_perror_msg(fullname);
|
||||
status = EXIT_FAILURE;
|
||||
exit_code = EXIT_FAILURE;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -396,7 +430,7 @@ static void showfiles(struct dnode **dn, int nfiles)
|
||||
} else {
|
||||
/* find the longest file name, use that as the column width */
|
||||
for (i = 0; i < nfiles; i++) {
|
||||
int len = strlen(dn[i]->name);
|
||||
int len = mbstrlen(dn[i]->name);
|
||||
if (column_width < len)
|
||||
column_width = len;
|
||||
}
|
||||
@@ -495,7 +529,7 @@ static struct dnode **list_dir(const char *path)
|
||||
nfiles = 0;
|
||||
dir = warn_opendir(path);
|
||||
if (dir == NULL) {
|
||||
status = EXIT_FAILURE;
|
||||
exit_code = EXIT_FAILURE;
|
||||
return NULL; /* could not open the dir */
|
||||
}
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
@@ -539,13 +573,7 @@ static struct dnode **list_dir(const char *path)
|
||||
}
|
||||
|
||||
|
||||
#if ENABLE_FEATURE_LS_TIMESTAMPS
|
||||
/* Do time() just once. Saves one syscall per file for "ls -l" */
|
||||
/* Initialized in main() */
|
||||
static time_t current_time_t;
|
||||
#endif
|
||||
|
||||
static int list_single(struct dnode *dn)
|
||||
static int list_single(const struct dnode *dn)
|
||||
{
|
||||
int i, column = 0;
|
||||
|
||||
@@ -659,7 +687,12 @@ static int list_single(struct dnode *dn)
|
||||
fgcolor(info.st_mode));
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_FEATURE_ASSUME_UNICODE
|
||||
printf("%s", dn->name);
|
||||
column += mbstrlen(dn->name);
|
||||
#else
|
||||
column += printf("%s", dn->name);
|
||||
#endif
|
||||
if (show_color) {
|
||||
printf("\033[0m");
|
||||
}
|
||||
@@ -702,6 +735,7 @@ static int list_single(struct dnode *dn)
|
||||
return column;
|
||||
}
|
||||
|
||||
|
||||
/* "[-]Cadil1", POSIX mandated options, busybox always supports */
|
||||
/* "[-]gnsx", POSIX non-mandated options, busybox always supports */
|
||||
/* "[-]Ak" GNU options, busybox always supports */
|
||||
@@ -780,11 +814,18 @@ static const unsigned opt_flags[] = {
|
||||
};
|
||||
|
||||
|
||||
/* THIS IS A "SAFE" APPLET, main() MAY BE CALLED INTERNALLY FROM SHELL */
|
||||
/* BE CAREFUL! */
|
||||
/* colored LS support by JaWi, janwillem.janssen@lxtreme.nl */
|
||||
#if ENABLE_FEATURE_LS_COLOR
|
||||
/* long option entry used only for --color, which has no short option
|
||||
* equivalent */
|
||||
static const char ls_color_opt[] ALIGN1 =
|
||||
"color\0" Optional_argument "\xff" /* no short equivalent */
|
||||
;
|
||||
#endif
|
||||
|
||||
|
||||
int ls_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int ls_main(int argc, char **argv)
|
||||
int ls_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
struct dnode **dnd;
|
||||
struct dnode **dnf;
|
||||
@@ -792,18 +833,13 @@ int ls_main(int argc, char **argv)
|
||||
struct dnode *dn;
|
||||
struct dnode *cur;
|
||||
unsigned opt;
|
||||
int nfiles = 0;
|
||||
int nfiles;
|
||||
int dnfiles;
|
||||
int dndirs;
|
||||
int oi;
|
||||
int ac;
|
||||
int i;
|
||||
char **av;
|
||||
USE_FEATURE_LS_COLOR(char *color_opt;)
|
||||
|
||||
#if ENABLE_FEATURE_LS_TIMESTAMPS
|
||||
time(¤t_time_t);
|
||||
#endif
|
||||
INIT_G();
|
||||
|
||||
all_fmt = LIST_SHORT |
|
||||
(ENABLE_FEATURE_LS_SORTFILES * (SORT_NAME | SORT_FORWARD));
|
||||
@@ -884,39 +920,27 @@ int ls_main(int argc, char **argv)
|
||||
if (!(all_fmt & STYLE_MASK))
|
||||
all_fmt |= (isatty(STDOUT_FILENO) ? STYLE_COLUMNS : STYLE_SINGLE);
|
||||
|
||||
/*
|
||||
* when there are no cmd line args we have to supply a default "." arg.
|
||||
* we will create a second argv array, "av" that will hold either
|
||||
* our created "." arg, or the real cmd line args. The av array
|
||||
* just holds the pointers- we don't move the date the pointers
|
||||
* point to.
|
||||
*/
|
||||
ac = argc - optind; /* how many cmd line args are left */
|
||||
if (ac < 1) {
|
||||
static const char *const dotdir[] = { "." };
|
||||
argv += optind;
|
||||
if (!argv[0])
|
||||
*--argv = (char*)".";
|
||||
|
||||
av = (char **) dotdir;
|
||||
ac = 1;
|
||||
} else {
|
||||
av = argv + optind;
|
||||
}
|
||||
|
||||
/* now, everything is in the av array */
|
||||
if (ac > 1)
|
||||
all_fmt |= DISP_DIRNAME; /* 2 or more items? label directories */
|
||||
if (argv[1])
|
||||
all_fmt |= DISP_DIRNAME; /* 2 or more items? label directories */
|
||||
|
||||
/* stuff the command line file names into a dnode array */
|
||||
dn = NULL;
|
||||
for (oi = 0; oi < ac; oi++) {
|
||||
nfiles = 0;
|
||||
do {
|
||||
/* ls w/o -l follows links on command line */
|
||||
cur = my_stat(av[oi], av[oi], !(all_fmt & STYLE_LONG));
|
||||
cur = my_stat(*argv, *argv, !(all_fmt & STYLE_LONG));
|
||||
argv++;
|
||||
if (!cur)
|
||||
continue;
|
||||
cur->allocated = 0;
|
||||
cur->next = dn;
|
||||
dn = cur;
|
||||
nfiles++;
|
||||
}
|
||||
} while (*argv);
|
||||
|
||||
/* now that we know how many files there are
|
||||
* allocate memory for an array to hold dnode pointers
|
||||
@@ -951,5 +975,5 @@ int ls_main(int argc, char **argv)
|
||||
}
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
dfree(dnp, nfiles);
|
||||
return status;
|
||||
return exit_code;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ static unsigned char *hash_bin_to_hex(unsigned char *hash_value,
|
||||
/* xzalloc zero-terminates */
|
||||
char *hex_value = xzalloc((hash_length * 2) + 1);
|
||||
bin2hex(hex_value, (char*)hash_value, hash_length);
|
||||
return hex_value;
|
||||
return (unsigned char *)hex_value;
|
||||
}
|
||||
|
||||
static uint8_t *hash_file(const char *filename, hash_algo_t hash_algo)
|
||||
@@ -115,7 +115,7 @@ int md5_sha1_sum_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
|
||||
pre_computed_stream = xfopen_stdin(argv[0]);
|
||||
|
||||
while ((line = xmalloc_getline(pre_computed_stream)) != NULL) {
|
||||
while ((line = xmalloc_fgetline(pre_computed_stream)) != NULL) {
|
||||
char *filename_ptr;
|
||||
|
||||
count_total++;
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
/* Nov 28, 2006 Yoshinori Sato <ysato@users.sourceforge.jp>: Add SELinux Support.
|
||||
*/
|
||||
|
||||
#include <getopt.h> /* struct option */
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
+5
-5
@@ -13,10 +13,6 @@
|
||||
* Size reduction and improved error checking.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <getopt.h> /* struct option */
|
||||
#include "libbb.h"
|
||||
#include "libcoreutils/coreutils.h"
|
||||
|
||||
@@ -75,7 +71,8 @@ int mv_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
DO_MOVE:
|
||||
if (dest_exists && !(flags & OPT_FILEUTILS_FORCE)
|
||||
if (dest_exists
|
||||
&& !(flags & OPT_FILEUTILS_FORCE)
|
||||
&& ((access(dest, W_OK) < 0 && isatty(0))
|
||||
|| (flags & OPT_FILEUTILS_INTERACTIVE))
|
||||
) {
|
||||
@@ -112,6 +109,9 @@ int mv_main(int argc, char **argv)
|
||||
goto RET_1;
|
||||
}
|
||||
}
|
||||
/* FILEUTILS_RECUR also prevents nasties like
|
||||
* "read from device and write contents to dst"
|
||||
* instead of "create same device node" */
|
||||
copy_flag = FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS;
|
||||
#if ENABLE_SELINUX
|
||||
copy_flag |= FILEUTILS_PRESERVE_SECURITY_CONTEXT;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
/* This one provides -t (busybox's own build script needs it) */
|
||||
#include "od_bloaty.c"
|
||||
#else
|
||||
#include <getopt.h>
|
||||
|
||||
#include "dump.h"
|
||||
|
||||
|
||||
+11
-15
@@ -50,7 +50,6 @@ diff -u -a std bbox >bbox.diff || { echo Different!; sleep 1; }
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include <getopt.h>
|
||||
|
||||
#define assert(a) ((void)0)
|
||||
|
||||
@@ -509,10 +508,10 @@ check_and_close(void)
|
||||
}
|
||||
|
||||
/* If S points to a single valid modern od format string, put
|
||||
a description of that format in *TSPEC, make *NEXT point at the
|
||||
character following the just-decoded format (if *NEXT is non-NULL),
|
||||
and return zero. For example, if S were "d4afL"
|
||||
*NEXT would be set to "afL" and *TSPEC would be
|
||||
a description of that format in *TSPEC, return pointer to
|
||||
character following the just-decoded format.
|
||||
For example, if S were "d4afL", we will return a rtp to "afL"
|
||||
and *TSPEC would be
|
||||
{
|
||||
fmt = SIGNED_DECIMAL;
|
||||
size = INT or LONG; (whichever integral_type_size[4] resolves to)
|
||||
@@ -522,9 +521,8 @@ check_and_close(void)
|
||||
S_ORIG is solely for reporting errors. It should be the full format
|
||||
string argument. */
|
||||
|
||||
static void
|
||||
decode_one_format(const char *s_orig, const char *s, const char **next,
|
||||
struct tspec *tspec)
|
||||
static const char *
|
||||
decode_one_format(const char *s_orig, const char *s, struct tspec *tspec)
|
||||
{
|
||||
enum size_spec size_spec;
|
||||
unsigned size;
|
||||
@@ -537,7 +535,6 @@ decode_one_format(const char *s_orig, const char *s, const char **next,
|
||||
unsigned field_width = 0;
|
||||
int pos;
|
||||
|
||||
assert(tspec != NULL);
|
||||
|
||||
switch (*s) {
|
||||
case 'd':
|
||||
@@ -563,13 +560,14 @@ decode_one_format(const char *s_orig, const char *s, const char **next,
|
||||
s = end;
|
||||
}
|
||||
} else {
|
||||
static const uint8_t CSIL_sizeof[] = {
|
||||
static const uint8_t CSIL_sizeof[4] = {
|
||||
sizeof(char),
|
||||
sizeof(short),
|
||||
sizeof(int),
|
||||
sizeof(long),
|
||||
};
|
||||
size = CSIL_sizeof[p - CSIL];
|
||||
s++; /* skip C/S/I/L */
|
||||
}
|
||||
|
||||
#define ISPEC_TO_FORMAT(Spec, Min_format, Long_format, Max_format) \
|
||||
@@ -717,8 +715,7 @@ decode_one_format(const char *s_orig, const char *s, const char **next,
|
||||
if (tspec->hexl_mode_trailer)
|
||||
s++;
|
||||
|
||||
if (next != NULL)
|
||||
*next = s;
|
||||
return s;
|
||||
}
|
||||
|
||||
/* Decode the modern od format string S. Append the decoded
|
||||
@@ -734,7 +731,7 @@ decode_format_string(const char *s)
|
||||
struct tspec tspec;
|
||||
const char *next;
|
||||
|
||||
decode_one_format(s_orig, s, &next, &tspec);
|
||||
next = decode_one_format(s_orig, s, &tspec);
|
||||
|
||||
assert(s != next);
|
||||
s = next;
|
||||
@@ -1284,8 +1281,7 @@ int od_main(int argc, char **argv)
|
||||
if (opt & OPT_o) decode_format_string("o2");
|
||||
//if (opt & OPT_t)...
|
||||
while (lst_t) {
|
||||
decode_format_string(lst_t->data);
|
||||
lst_t = lst_t->link;
|
||||
decode_format_string(llist_pop(&lst_t));
|
||||
}
|
||||
if (opt & OPT_v) verbose = 1;
|
||||
if (opt & OPT_x) decode_format_string("x2");
|
||||
|
||||
@@ -29,5 +29,5 @@ int printenv_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
fflush_stdout_and_exit(0);
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
+64
-57
@@ -107,28 +107,28 @@ static void print_esc_string(char *str)
|
||||
}
|
||||
}
|
||||
|
||||
static void print_direc(char *start, size_t length, int field_width, int precision,
|
||||
static void print_direc(char *format, unsigned fmt_length,
|
||||
int field_width, int precision,
|
||||
const char *argument)
|
||||
{
|
||||
char *p; /* Null-terminated copy of % directive. */
|
||||
char saved;
|
||||
|
||||
p = xmalloc((unsigned) (length + 1));
|
||||
strncpy(p, start, length);
|
||||
p[length] = 0;
|
||||
saved = format[fmt_length];
|
||||
format[fmt_length] = '\0';
|
||||
|
||||
switch (p[length - 1]) {
|
||||
switch (format[fmt_length - 1]) {
|
||||
case 'd':
|
||||
case 'i':
|
||||
if (field_width < 0) {
|
||||
if (precision < 0)
|
||||
printf(p, my_xstrtol(argument));
|
||||
printf(format, my_xstrtol(argument));
|
||||
else
|
||||
printf(p, precision, my_xstrtol(argument));
|
||||
printf(format, precision, my_xstrtol(argument));
|
||||
} else {
|
||||
if (precision < 0)
|
||||
printf(p, field_width, my_xstrtol(argument));
|
||||
printf(format, field_width, my_xstrtol(argument));
|
||||
else
|
||||
printf(p, field_width, precision, my_xstrtol(argument));
|
||||
printf(format, field_width, precision, my_xstrtol(argument));
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
@@ -137,14 +137,14 @@ static void print_direc(char *start, size_t length, int field_width, int precisi
|
||||
case 'X':
|
||||
if (field_width < 0) {
|
||||
if (precision < 0)
|
||||
printf(p, my_xstrtoul(argument));
|
||||
printf(format, my_xstrtoul(argument));
|
||||
else
|
||||
printf(p, precision, my_xstrtoul(argument));
|
||||
printf(format, precision, my_xstrtoul(argument));
|
||||
} else {
|
||||
if (precision < 0)
|
||||
printf(p, field_width, my_xstrtoul(argument));
|
||||
printf(format, field_width, my_xstrtoul(argument));
|
||||
else
|
||||
printf(p, field_width, precision, my_xstrtoul(argument));
|
||||
printf(format, field_width, precision, my_xstrtoul(argument));
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
@@ -154,51 +154,48 @@ static void print_direc(char *start, size_t length, int field_width, int precisi
|
||||
case 'G':
|
||||
if (field_width < 0) {
|
||||
if (precision < 0)
|
||||
printf(p, my_xstrtod(argument));
|
||||
printf(format, my_xstrtod(argument));
|
||||
else
|
||||
printf(p, precision, my_xstrtod(argument));
|
||||
printf(format, precision, my_xstrtod(argument));
|
||||
} else {
|
||||
if (precision < 0)
|
||||
printf(p, field_width, my_xstrtod(argument));
|
||||
printf(format, field_width, my_xstrtod(argument));
|
||||
else
|
||||
printf(p, field_width, precision, my_xstrtod(argument));
|
||||
printf(format, field_width, precision, my_xstrtod(argument));
|
||||
}
|
||||
break;
|
||||
case 'c':
|
||||
printf(p, *argument);
|
||||
printf(format, *argument);
|
||||
break;
|
||||
case 's':
|
||||
if (field_width < 0) {
|
||||
if (precision < 0)
|
||||
printf(p, argument);
|
||||
printf(format, argument);
|
||||
else
|
||||
printf(p, precision, argument);
|
||||
printf(format, precision, argument);
|
||||
} else {
|
||||
if (precision < 0)
|
||||
printf(p, field_width, argument);
|
||||
printf(format, field_width, argument);
|
||||
else
|
||||
printf(p, field_width, precision, argument);
|
||||
printf(format, field_width, precision, argument);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
free(p);
|
||||
format[fmt_length] = saved;
|
||||
}
|
||||
|
||||
/* Print the text in FORMAT, using ARGV (with ARGC elements) for
|
||||
arguments to any '%' directives.
|
||||
Return the number of elements of ARGV used. */
|
||||
|
||||
static int print_formatted(char *format, int argc, char **argv)
|
||||
/* Print the text in FORMAT, using ARGV for arguments to any '%' directives.
|
||||
Return advanced ARGV. */
|
||||
static char **print_formatted(char *f, char **argv)
|
||||
{
|
||||
int save_argc = argc; /* Preserve original value. */
|
||||
char *f; /* Pointer into 'format'. */
|
||||
char *direc_start; /* Start of % directive. */
|
||||
size_t direc_length; /* Length of % directive. */
|
||||
unsigned direc_length; /* Length of % directive. */
|
||||
int field_width; /* Arg to first '*', or -1 if none. */
|
||||
int precision; /* Arg to second '*', or -1 if none. */
|
||||
char **saved_argv = argv;
|
||||
|
||||
for (f = format; *f; ++f) {
|
||||
for (; *f; ++f) {
|
||||
switch (*f) {
|
||||
case '%':
|
||||
direc_start = f++;
|
||||
@@ -209,10 +206,9 @@ static int print_formatted(char *format, int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
if (*f == 'b') {
|
||||
if (argc > 0) {
|
||||
if (*argv) {
|
||||
print_esc_string(*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -223,10 +219,9 @@ static int print_formatted(char *format, int argc, char **argv)
|
||||
if (*f == '*') {
|
||||
++f;
|
||||
++direc_length;
|
||||
if (argc > 0) {
|
||||
if (*argv) {
|
||||
field_width = my_xstrtoul(*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
} else
|
||||
field_width = 0;
|
||||
} else {
|
||||
@@ -241,10 +236,9 @@ static int print_formatted(char *format, int argc, char **argv)
|
||||
if (*f == '*') {
|
||||
++f;
|
||||
++direc_length;
|
||||
if (argc > 0) {
|
||||
if (*argv) {
|
||||
precision = my_xstrtoul(*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
} else
|
||||
precision = 0;
|
||||
} else
|
||||
@@ -262,18 +256,18 @@ static int print_formatted(char *format, int argc, char **argv)
|
||||
fprintf(stderr, "%%%c: invalid directive", *f);
|
||||
*/
|
||||
++direc_length;
|
||||
if (argc > 0) {
|
||||
if (*argv) {
|
||||
print_direc(direc_start, direc_length, field_width,
|
||||
precision, *argv);
|
||||
++argv;
|
||||
--argc;
|
||||
} else
|
||||
print_direc(direc_start, direc_length, field_width,
|
||||
precision, "");
|
||||
break;
|
||||
case '\\':
|
||||
if (*++f == 'c')
|
||||
exit(0);
|
||||
if (*++f == 'c') {
|
||||
return saved_argv; /* causes main() to exit */
|
||||
}
|
||||
bb_putchar(bb_process_escape_sequence((const char **)&f));
|
||||
f--;
|
||||
break;
|
||||
@@ -282,32 +276,45 @@ static int print_formatted(char *format, int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
return save_argc - argc;
|
||||
return argv;
|
||||
}
|
||||
|
||||
int printf_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int printf_main(int argc, char **argv)
|
||||
int printf_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
char *format;
|
||||
int args_used;
|
||||
char **argv2;
|
||||
|
||||
if (argc <= 1 || argv[1][0] == '-') {
|
||||
/* We must check that stdout is not closed.
|
||||
* The reason for this is highly non-obvious. printf_main is used from shell.
|
||||
* Shell must correctly handle 'printf "%s" foo'
|
||||
* if stdout is closed. With stdio, output gets shoveled into
|
||||
* stdout buffer, and even fflush cannot clear it out. It seems that
|
||||
* even if libc receives EBADF on write attempts, it feels determined
|
||||
* to output data no matter what. So it will try later,
|
||||
* and possibly will clobber future output. Not good. */
|
||||
if (dup2(1, 1) != 1)
|
||||
return -1;
|
||||
|
||||
/* bash builtin errors out on "printf '-%s-\n' foo",
|
||||
* coreutils-6.9 works. Both work with "printf -- '-%s-\n' foo".
|
||||
* We will mimic coreutils. */
|
||||
if (argv[1] && argv[1][0] == '-' && argv[1][1] == '-' && argv[1][2] == '\0')
|
||||
argv++;
|
||||
if (!argv[1])
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
format = argv[1];
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
argv2 = argv + 2;
|
||||
|
||||
do {
|
||||
args_used = print_formatted(format, argc, argv);
|
||||
argc -= args_used;
|
||||
argv += args_used;
|
||||
} while (args_used > 0 && argc > 0);
|
||||
argv = argv2;
|
||||
argv2 = print_formatted(format, argv);
|
||||
} while (argv2 != argv && *argv2);
|
||||
|
||||
/* if (argc > 0)
|
||||
/* coreutils compat (bash doesn't do this):
|
||||
if (*argv)
|
||||
fprintf(stderr, "excess args ignored");
|
||||
*/
|
||||
*/
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
* Licensed under GPL v2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include "libbb.h"
|
||||
|
||||
int readlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
|
||||
+5
-6
@@ -59,7 +59,8 @@ static struct sort_key {
|
||||
|
||||
static char *get_key(char *str, struct sort_key *key, int flags)
|
||||
{
|
||||
int start = 0, end = 0, len, i, j;
|
||||
int start = 0, end = 0, len, j;
|
||||
unsigned i;
|
||||
|
||||
/* Special case whole string, so we don't have to make a copy */
|
||||
if (key->range[0] == 1 && !key->range[1] && !key->range[2] && !key->range[3]
|
||||
@@ -150,9 +151,9 @@ static struct sort_key *add_key(void)
|
||||
#define GET_LINE(fp) \
|
||||
((option_mask32 & FLAG_z) \
|
||||
? bb_get_chunk_from_file(fp, NULL) \
|
||||
: xmalloc_getline(fp))
|
||||
: xmalloc_fgetline(fp))
|
||||
#else
|
||||
#define GET_LINE(fp) xmalloc_getline(fp)
|
||||
#define GET_LINE(fp) xmalloc_fgetline(fp)
|
||||
#endif
|
||||
|
||||
/* Iterate through keys list and perform comparisons */
|
||||
@@ -313,7 +314,7 @@ int sort_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
0
|
||||
};
|
||||
struct sort_key *key = add_key();
|
||||
char *str_k = lst_k->data;
|
||||
char *str_k = llist_pop(&lst_k);
|
||||
const char *temp2;
|
||||
|
||||
i = 0; /* i==0 before comma, 1 after (-k3,6) */
|
||||
@@ -343,8 +344,6 @@ int sort_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
str_k++;
|
||||
}
|
||||
}
|
||||
/* leaking lst_k... */
|
||||
lst_k = lst_k->link;
|
||||
}
|
||||
#endif
|
||||
/* global b strips leading and trailing spaces */
|
||||
|
||||
+2
-2
@@ -98,7 +98,7 @@ int split_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
}
|
||||
|
||||
while (1) {
|
||||
bytes_read = safe_read(0, read_buffer, READ_BUFFER_SIZE);
|
||||
bytes_read = safe_read(STDIN_FILENO, read_buffer, READ_BUFFER_SIZE);
|
||||
if (!bytes_read)
|
||||
break;
|
||||
if (bytes_read < 0)
|
||||
@@ -130,7 +130,7 @@ int split_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
xwrite(1, src, to_write);
|
||||
xwrite(STDOUT_FILENO, src, to_write);
|
||||
bytes_read -= to_write;
|
||||
src += to_write;
|
||||
} while (bytes_read);
|
||||
|
||||
+5
-6
@@ -627,11 +627,10 @@ struct globals {
|
||||
char buf[10];
|
||||
};
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define INIT_G() \
|
||||
do { \
|
||||
G.device_name = bb_msg_standard_input; \
|
||||
G.max_col = 80; \
|
||||
} while (0)
|
||||
#define INIT_G() do { \
|
||||
G.device_name = bb_msg_standard_input; \
|
||||
G.max_col = 80; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Return a string that is the printable representation of character CH */
|
||||
@@ -710,7 +709,7 @@ static void wrapf(const char *message, ...)
|
||||
{
|
||||
char buf[128];
|
||||
va_list args;
|
||||
int buflen;
|
||||
unsigned buflen;
|
||||
|
||||
va_start(args, message);
|
||||
buflen = vsnprintf(buf, sizeof(buf), message, args);
|
||||
|
||||
+14
-17
@@ -92,7 +92,8 @@ int tail_main(int argc, char **argv)
|
||||
size_t tailbufsize;
|
||||
int taillen = 0;
|
||||
int newlines_seen = 0;
|
||||
int nfiles, nread, nwrite, seen, i, opt;
|
||||
int nfiles, nread, nwrite, i, opt;
|
||||
unsigned seen;
|
||||
|
||||
int *fds;
|
||||
char *s, *buf;
|
||||
@@ -163,8 +164,6 @@ int tail_main(int argc, char **argv)
|
||||
fmt = header_fmt + 1; /* Skip header leading newline on first output. */
|
||||
i = 0;
|
||||
do {
|
||||
off_t current;
|
||||
|
||||
if (nfiles > header_threshhold) {
|
||||
tail_xprint_header(fmt, argv[i]);
|
||||
fmt = header_fmt;
|
||||
@@ -173,19 +172,17 @@ int tail_main(int argc, char **argv)
|
||||
/* Optimizing count-bytes case if the file is seekable.
|
||||
* Beware of backing up too far.
|
||||
* Also we exclude files with size 0 (because of /proc/xxx) */
|
||||
current = lseek(fds[i], 0, SEEK_END);
|
||||
if (current > 0) {
|
||||
if (!from_top) {
|
||||
if (COUNT_BYTES && !from_top) {
|
||||
off_t current = lseek(fds[i], 0, SEEK_END);
|
||||
if (current > 0) {
|
||||
if (count == 0)
|
||||
continue; /* showing zero lines is easy :) */
|
||||
if (COUNT_BYTES) {
|
||||
current -= count;
|
||||
if (current < 0)
|
||||
current = 0;
|
||||
xlseek(fds[i], current, SEEK_SET);
|
||||
bb_copyfd_size(fds[i], STDOUT_FILENO, count);
|
||||
continue;
|
||||
}
|
||||
current -= count;
|
||||
if (current < 0)
|
||||
current = 0;
|
||||
xlseek(fds[i], current, SEEK_SET);
|
||||
bb_copyfd_size(fds[i], STDOUT_FILENO, count);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +211,7 @@ int tail_main(int argc, char **argv)
|
||||
} else if (count) {
|
||||
if (COUNT_BYTES) {
|
||||
taillen += nread;
|
||||
if (taillen > count) {
|
||||
if (taillen > (int)count) {
|
||||
memmove(tailbuf, tailbuf + taillen - count, count);
|
||||
taillen = count;
|
||||
}
|
||||
@@ -229,7 +226,7 @@ int tail_main(int argc, char **argv)
|
||||
}
|
||||
} while (k);
|
||||
|
||||
if (newlines_seen + newlines_in_buf < count) {
|
||||
if (newlines_seen + newlines_in_buf < (int)count) {
|
||||
newlines_seen += newlines_in_buf;
|
||||
taillen += nread;
|
||||
} else {
|
||||
@@ -247,7 +244,7 @@ int tail_main(int argc, char **argv)
|
||||
memmove(tailbuf, s, taillen);
|
||||
newlines_seen = count - extra;
|
||||
}
|
||||
if (tailbufsize < taillen + BUFSIZ) {
|
||||
if (tailbufsize < (size_t)taillen + BUFSIZ) {
|
||||
tailbufsize = taillen + BUFSIZ;
|
||||
tailbuf = xrealloc(tailbuf, tailbufsize);
|
||||
}
|
||||
|
||||
+7
-8
@@ -159,7 +159,7 @@ typedef int arith_t;
|
||||
|
||||
|
||||
/* We try to minimize both static and stack usage. */
|
||||
struct statics {
|
||||
struct test_statics {
|
||||
char **t_wp;
|
||||
const struct t_op *t_wp_op;
|
||||
gid_t *group_array;
|
||||
@@ -167,11 +167,10 @@ struct statics {
|
||||
jmp_buf leaving;
|
||||
};
|
||||
|
||||
/* Make it reside in writable memory, yet make compiler understand
|
||||
* that it is not going to change. */
|
||||
static struct statics *const ptr_to_statics __attribute__ ((section (".data")));
|
||||
/* See test_ptr_hack.c */
|
||||
extern struct test_statics *const test_ptr_to_statics;
|
||||
|
||||
#define S (*ptr_to_statics)
|
||||
#define S (*test_ptr_to_statics)
|
||||
#define t_wp (S.t_wp )
|
||||
#define t_wp_op (S.t_wp_op )
|
||||
#define group_array (S.group_array )
|
||||
@@ -179,11 +178,11 @@ static struct statics *const ptr_to_statics __attribute__ ((section (".data")));
|
||||
#define leaving (S.leaving )
|
||||
|
||||
#define INIT_S() do { \
|
||||
(*(struct statics**)&ptr_to_statics) = xzalloc(sizeof(S)); \
|
||||
(*(struct test_statics**)&test_ptr_to_statics) = xzalloc(sizeof(S)); \
|
||||
barrier(); \
|
||||
} while (0)
|
||||
#define DEINIT_S() do { \
|
||||
free(ptr_to_statics); \
|
||||
free(test_ptr_to_statics); \
|
||||
} while (0)
|
||||
|
||||
static arith_t primary(enum token n);
|
||||
@@ -413,7 +412,7 @@ static int test_eaccess(char *path, int mode)
|
||||
static int filstat(char *nm, enum token mode)
|
||||
{
|
||||
struct stat s;
|
||||
int i = i; /* gcc 3.x thinks it can be used uninitialized */
|
||||
unsigned i = i; /* gcc 3.x thinks it can be used uninitialized */
|
||||
|
||||
if (mode == FILSYM) {
|
||||
#ifdef S_IFLNK
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (C) 2008 by Denys Vlasenko <vda.linux@googlemail.com>
|
||||
*
|
||||
* Licensed under GPLv2, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
struct test_statics;
|
||||
|
||||
#ifndef GCC_COMBINE
|
||||
|
||||
/* We cheat here. It is declared as const ptr in libbb.h,
|
||||
* but here we make it live in R/W memory */
|
||||
struct test_statics *test_ptr_to_statics;
|
||||
|
||||
#else
|
||||
|
||||
/* gcc -combine will see through and complain */
|
||||
/* Using alternative method which is more likely to break
|
||||
* on weird architectures, compilers, linkers and so on */
|
||||
struct test_statics *const test_ptr_to_statics __attribute__ ((section (".data")));
|
||||
|
||||
#endif
|
||||
+3
-3
@@ -208,8 +208,8 @@ int tr_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
if (*argv) {
|
||||
if (argv[0][0] == '\0')
|
||||
bb_error_msg_and_die("STRING2 cannot be empty");
|
||||
output_length = expand(*argv, output);
|
||||
map(vector, tr_buf, input_length, output, output_length);
|
||||
output_length = expand(*argv, (char *)output);
|
||||
map(vector, (unsigned char *)tr_buf, input_length, output, output_length);
|
||||
}
|
||||
for (i = 0; i < input_length; i++)
|
||||
invec[(unsigned char)tr_buf[i]] = TRUE;
|
||||
@@ -219,7 +219,7 @@ int tr_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
|
||||
for (;;) {
|
||||
/* If we're out of input, flush output and read more input. */
|
||||
if (in_index == read_chars) {
|
||||
if ((ssize_t)in_index == read_chars) {
|
||||
if (out_index) {
|
||||
xwrite(STDOUT_FILENO, (char *)output, out_index);
|
||||
out_index = 0;
|
||||
|
||||
+19
-22
@@ -17,7 +17,7 @@
|
||||
-m, --machine sun
|
||||
-a, --all SunOS rocky8 4.0 sun
|
||||
|
||||
The default behavior is equivalent to `-s'.
|
||||
The default behavior is equivalent to '-s'.
|
||||
|
||||
David MacKenzie <djm@gnu.ai.mit.edu> */
|
||||
|
||||
@@ -39,47 +39,43 @@ typedef struct {
|
||||
} uname_info_t;
|
||||
|
||||
static const char options[] ALIGN1 = "snrvmpa";
|
||||
static const unsigned short utsname_offset[] ALIGN2 = {
|
||||
offsetof(uname_info_t,name.sysname),
|
||||
offsetof(uname_info_t,name.nodename),
|
||||
offsetof(uname_info_t,name.release),
|
||||
offsetof(uname_info_t,name.version),
|
||||
offsetof(uname_info_t,name.machine),
|
||||
offsetof(uname_info_t,processor)
|
||||
static const unsigned short utsname_offset[] = {
|
||||
offsetof(uname_info_t, name.sysname),
|
||||
offsetof(uname_info_t, name.nodename),
|
||||
offsetof(uname_info_t, name.release),
|
||||
offsetof(uname_info_t, name.version),
|
||||
offsetof(uname_info_t, name.machine),
|
||||
offsetof(uname_info_t, processor)
|
||||
};
|
||||
|
||||
int uname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int uname_main(int argc, char **argv)
|
||||
int uname_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
uname_info_t uname_info;
|
||||
#if defined(__sparc__) && defined(__linux__)
|
||||
char *fake_sparc = getenv("FAKE_SPARC");
|
||||
#endif
|
||||
const unsigned short int *delta;
|
||||
const unsigned short *delta;
|
||||
char toprint;
|
||||
|
||||
toprint = getopt32(argv, options);
|
||||
|
||||
if (argc != optind) {
|
||||
if (argv[optind]) { /* coreutils-6.9 compat */
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if (toprint & (1 << 6)) {
|
||||
if (toprint & (1 << 6)) { /* -a => all opts on */
|
||||
toprint = 0x3f;
|
||||
}
|
||||
|
||||
if (toprint == 0) {
|
||||
toprint = 1; /* sysname */
|
||||
if (toprint == 0) { /* no opts => -s (sysname) */
|
||||
toprint = 1;
|
||||
}
|
||||
|
||||
if (uname(&uname_info.name) == -1) {
|
||||
bb_error_msg_and_die("cannot get system name");
|
||||
}
|
||||
uname(&uname_info.name); /* never fails */
|
||||
|
||||
#if defined(__sparc__) && defined(__linux__)
|
||||
if ((fake_sparc != NULL)
|
||||
&& ((fake_sparc[0] == 'y')
|
||||
|| (fake_sparc[0] == 'Y'))) {
|
||||
if (fake_sparc && (fake_sparc[0] | 0x20) == 'y') {
|
||||
strcpy(uname_info.name.machine, "sparc");
|
||||
}
|
||||
#endif
|
||||
@@ -89,7 +85,8 @@ int uname_main(int argc, char **argv)
|
||||
delta = utsname_offset;
|
||||
do {
|
||||
if (toprint & 1) {
|
||||
printf(((char *)(&uname_info)) + *delta);
|
||||
/* printf would not be safe here */
|
||||
fputs((char *)(&uname_info) + *delta, stdout);
|
||||
if (toprint > 1) {
|
||||
bb_putchar(' ');
|
||||
}
|
||||
@@ -98,5 +95,5 @@ int uname_main(int argc, char **argv)
|
||||
} while (toprint >>= 1);
|
||||
bb_putchar('\n');
|
||||
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS); /* coreutils-6.9 compat */
|
||||
}
|
||||
+12
-13
@@ -12,8 +12,6 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
static const char uniq_opts[] ALIGN1 = "cdu" "f:s:" "cdu\0\1\2\4";
|
||||
|
||||
static FILE *xgetoptfile_uniq_s(char **argv, int read0write2)
|
||||
{
|
||||
const char *n;
|
||||
@@ -31,9 +29,11 @@ int uniq_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
FILE *in, *out;
|
||||
unsigned long dups, skip_fields, skip_chars, i;
|
||||
const char *s0, *e0, *s1, *e1, *input_filename;
|
||||
unsigned long dups;
|
||||
unsigned skip_fields, skip_chars, max_chars;
|
||||
unsigned opt;
|
||||
unsigned i;
|
||||
|
||||
enum {
|
||||
OPT_c = 0x1,
|
||||
@@ -41,15 +41,14 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
OPT_u = 0x4,
|
||||
OPT_f = 0x8,
|
||||
OPT_s = 0x10,
|
||||
OPT_w = 0x20,
|
||||
};
|
||||
|
||||
skip_fields = skip_chars = 0;
|
||||
max_chars = -1;
|
||||
|
||||
opt = getopt32(argv, "cduf:s:", &s0, &s1);
|
||||
if (opt & OPT_f)
|
||||
skip_fields = xatoul(s0);
|
||||
if (opt & OPT_s)
|
||||
skip_chars = xatoul(s1);
|
||||
opt_complementary = "f+:s+:w+";
|
||||
opt = getopt32(argv, "cduf:s:w:", &skip_fields, &skip_chars, &max_chars);
|
||||
argv += optind;
|
||||
|
||||
input_filename = *argv;
|
||||
@@ -63,7 +62,7 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
s1 = e1 = NULL; /* prime the pump */
|
||||
s1 = e1 = NULL; /* prime the pump */
|
||||
|
||||
do {
|
||||
s0 = s1;
|
||||
@@ -71,7 +70,7 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
dups = 0;
|
||||
|
||||
/* gnu uniq ignores newlines */
|
||||
while ((s1 = xmalloc_getline(in)) != NULL) {
|
||||
while ((s1 = xmalloc_fgetline(in)) != NULL) {
|
||||
e1 = s1;
|
||||
for (i = skip_fields; i; i--) {
|
||||
e1 = skip_whitespace(e1);
|
||||
@@ -81,16 +80,16 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
++e1;
|
||||
}
|
||||
|
||||
if (!s0 || strcmp(e0, e1)) {
|
||||
if (!s0 || strncmp(e0, e1, max_chars)) {
|
||||
break;
|
||||
}
|
||||
|
||||
++dups; /* Note: Testing for overflow seems excessive. */
|
||||
++dups; /* note: testing for overflow seems excessive. */
|
||||
}
|
||||
|
||||
if (s0) {
|
||||
if (!(opt & (OPT_d << !!dups))) { /* (if dups, opt & OPT_e) */
|
||||
fprintf(out, "\0%d " + (opt & 1), dups + 1);
|
||||
fprintf(out, "\0%ld " + (opt & 1), dups + 1); /* 1 == OPT_c */
|
||||
fprintf(out, "%s\n", s0);
|
||||
}
|
||||
free((void *)s0);
|
||||
|
||||
@@ -18,7 +18,7 @@ static void read_stduu(FILE *src_stream, FILE *dst_stream)
|
||||
{
|
||||
char *line;
|
||||
|
||||
while ((line = xmalloc_getline(src_stream)) != NULL) {
|
||||
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
|
||||
int encoded_len, str_len;
|
||||
char *line_ptr, *dst;
|
||||
|
||||
@@ -151,7 +151,7 @@ int uudecode_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
src_stream = xfopen_stdin(*argv);
|
||||
|
||||
/* Search for the start of the encoding */
|
||||
while ((line = xmalloc_getline(src_stream)) != NULL) {
|
||||
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
|
||||
void (*decode_fn_ptr)(FILE * src, FILE * dst);
|
||||
char *line_ptr;
|
||||
FILE *dst_stream;
|
||||
|
||||
+5
-1
@@ -56,16 +56,20 @@ int who_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
printf("USER TTY IDLE TIME HOST\n");
|
||||
while ((ut = getutent()) != NULL) {
|
||||
if (ut->ut_user[0] && (opt || ut->ut_type == USER_PROCESS)) {
|
||||
time_t tmp;
|
||||
/* ut->ut_line is device name of tty - "/dev/" */
|
||||
name = concat_path_file("/dev", ut->ut_line);
|
||||
str6[0] = '?';
|
||||
str6[1] = '\0';
|
||||
if (stat(name, &st) == 0)
|
||||
idle_string(str6, st.st_atime);
|
||||
/* manpages say ut_tv.tv_sec *is* time_t,
|
||||
* but some systems have it wrong */
|
||||
tmp = ut->ut_tv.tv_sec;
|
||||
/* 15 chars for time: Nov 10 19:33:20 */
|
||||
printf("%-10s %-8s %-9s %-15.15s %s\n",
|
||||
ut->ut_user, ut->ut_line, str6,
|
||||
ctime(&(ut->ut_tv.tv_sec)) + 4, ut->ut_host);
|
||||
ctime(&tmp) + 4, ut->ut_host);
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(name);
|
||||
}
|
||||
|
||||
+30
-11
@@ -9,34 +9,53 @@
|
||||
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
||||
*/
|
||||
|
||||
/* Coreutils 6.12 man page says:
|
||||
* mktemp [OPTION]... [TEMPLATE]
|
||||
* Create a temporary file or directory, safely, and print its name. If
|
||||
* TEMPLATE is not specified, use tmp.XXXXXXXXXX.
|
||||
* -d, --directory
|
||||
* create a directory, not a file
|
||||
* -q, --quiet
|
||||
* suppress diagnostics about file/dir-creation failure
|
||||
* -u, --dry-run
|
||||
* do not create anything; merely print a name (unsafe)
|
||||
* --tmpdir[=DIR]
|
||||
* interpret TEMPLATE relative to DIR. If DIR is not specified,
|
||||
* use $TMPDIR if set, else /tmp. With this option, TEMPLATE must
|
||||
* not be an absolute name. Unlike with -t, TEMPLATE may contain
|
||||
* slashes, but even here, mktemp still creates only the final com-
|
||||
* ponent.
|
||||
* -p DIR use DIR as a prefix; implies -t [deprecated]
|
||||
* -t interpret TEMPLATE as a single file name component, relative to
|
||||
* a directory: $TMPDIR, if set; else the directory specified via
|
||||
* -p; else /tmp [deprecated]
|
||||
*/
|
||||
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
int mktemp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int mktemp_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
// -d Make a directory instead of a file
|
||||
// -q Fail silently if an error occurs [bbox: ignored]
|
||||
// -t Generate a path rooted in temporary directory
|
||||
// -p DIR Use DIR as a temporary directory (implies -t)
|
||||
const char *path;
|
||||
char *chp;
|
||||
unsigned flags;
|
||||
unsigned opt;
|
||||
|
||||
opt_complementary = "=1"; /* exactly one arg */
|
||||
flags = getopt32(argv, "dqtp:", &path);
|
||||
chp = argv[optind];
|
||||
opt_complementary = "?1"; /* 1 argument max */
|
||||
opt = getopt32(argv, "dqtp:", &path);
|
||||
chp = argv[optind] ? argv[optind] : xstrdup("tmp.XXXXXX");
|
||||
|
||||
if (flags & (4|8)) { /* -t and/or -p */
|
||||
if (opt & (4|8)) { /* -t and/or -p */
|
||||
const char *dir = getenv("TMPDIR");
|
||||
if (dir && *dir != '\0')
|
||||
path = dir;
|
||||
else if (!(flags & 8)) /* No -p */
|
||||
else if (!(opt & 8)) /* no -p */
|
||||
path = "/tmp/";
|
||||
/* else path comes from -p DIR */
|
||||
chp = concat_path_file(path, chp);
|
||||
}
|
||||
|
||||
if (flags & 1) { /* -d */
|
||||
if (opt & 1) { /* -d */
|
||||
if (mkdtemp(chp) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
} else {
|
||||
|
||||
@@ -30,8 +30,6 @@
|
||||
* -u MASK umask. Set the umask of the program executed to MASK.
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
struct globals {
|
||||
@@ -44,7 +42,7 @@ struct globals {
|
||||
#define cur (G.cur )
|
||||
#define cmd (G.cmd )
|
||||
|
||||
enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(struct globals)) / sizeof(cmd[0]) };
|
||||
enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 };
|
||||
|
||||
enum {
|
||||
OPT_r = (1 << 0),
|
||||
@@ -132,9 +130,7 @@ int run_parts_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
|
||||
n = 1;
|
||||
while (arg_list && n < NUM_CMD) {
|
||||
cmd[n] = arg_list->data;
|
||||
arg_list = arg_list->link;
|
||||
n++;
|
||||
cmd[n++] = llist_pop(&arg_list);
|
||||
}
|
||||
/* cmd[n] = NULL; - is already zeroed out */
|
||||
|
||||
|
||||
+186
-102
@@ -8,10 +8,54 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
/* NB: we have a problem here with /proc/NN/exe usage, similar to
|
||||
* one fixed in killall/pidof */
|
||||
/*
|
||||
This is how it is supposed to work:
|
||||
|
||||
start-stop-daemon [OPTIONS] [--start|--stop] [[--] arguments...]
|
||||
|
||||
One (only) of these must be given:
|
||||
-S,--start Start
|
||||
-K,--stop Stop
|
||||
|
||||
Search for matching processes.
|
||||
If --stop is given, stop all matching processes (by sending a signal).
|
||||
If --start is given, start a new process unless a matching process was found.
|
||||
|
||||
Options controlling process matching
|
||||
(if multiple conditions are specified, all must match):
|
||||
-u,--user USERNAME|UID Only consider this user's processes
|
||||
-n,--name PROCESS_NAME Look for processes by matching PROCESS_NAME
|
||||
with comm field in /proc/$PID/stat.
|
||||
Only basename is compared:
|
||||
"ntpd" == "./ntpd" == "/path/to/ntpd".
|
||||
[TODO: can PROCESS_NAME be a full pathname? Should we require full match then
|
||||
with /proc/$PID/exe or argv[0] (comm can't be matched, it never contains path)]
|
||||
-x,--exec EXECUTABLE Look for processes that were started with this
|
||||
command in /proc/$PID/cmdline.
|
||||
Unlike -n, we match against the full path:
|
||||
"ntpd" != "./ntpd" != "/path/to/ntpd"
|
||||
-p,--pidfile PID_FILE Look for processes with PID from this file
|
||||
|
||||
Options which are valid for --start only:
|
||||
-x,--exec EXECUTABLE Program to run (1st arg of execvp). Mandatory.
|
||||
-a,--startas NAME argv[0] (defaults to EXECUTABLE)
|
||||
-b,--background Put process into background
|
||||
-N,--nicelevel N Add N to process' nice level
|
||||
-c,--chuid USER[:[GRP]] Change to specified user [and group]
|
||||
-m,--make-pidfile Write PID to the pidfile
|
||||
(both -m and -p must be given!)
|
||||
|
||||
Options which are valid for --stop only:
|
||||
-s,--signal SIG Signal to send (default:TERM)
|
||||
-t,--test Exit with status 0 if process is found
|
||||
(we don't actually start or stop daemons)
|
||||
|
||||
Misc options:
|
||||
-o,--oknodo Exit with status 0 if nothing is done
|
||||
-q,--quiet Quiet
|
||||
-v,--verbose Verbose
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
/* Override ENABLE_FEATURE_PIDFILE */
|
||||
@@ -23,6 +67,26 @@ struct pid_list {
|
||||
pid_t pid;
|
||||
};
|
||||
|
||||
enum {
|
||||
CTX_STOP = (1 << 0),
|
||||
CTX_START = (1 << 1),
|
||||
OPT_BACKGROUND = (1 << 2), // -b
|
||||
OPT_QUIET = (1 << 3), // -q
|
||||
OPT_TEST = (1 << 4), // -t
|
||||
OPT_MAKEPID = (1 << 5), // -m
|
||||
OPT_a = (1 << 6), // -a
|
||||
OPT_n = (1 << 7), // -n
|
||||
OPT_s = (1 << 8), // -s
|
||||
OPT_u = (1 << 9), // -u
|
||||
OPT_c = (1 << 10), // -c
|
||||
OPT_x = (1 << 11), // -x
|
||||
OPT_p = (1 << 12), // -p
|
||||
OPT_OKNODO = (1 << 13) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -o
|
||||
OPT_VERBOSE = (1 << 14) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -v
|
||||
OPT_NICELEVEL = (1 << 15) * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -N
|
||||
};
|
||||
#define QUIET (option_mask32 & OPT_QUIET)
|
||||
#define TEST (option_mask32 & OPT_TEST)
|
||||
|
||||
struct globals {
|
||||
struct pid_list *found;
|
||||
@@ -31,7 +95,6 @@ struct globals {
|
||||
char *execname;
|
||||
char *pidfile;
|
||||
int user_id;
|
||||
smallint quiet;
|
||||
smallint signal_nr;
|
||||
};
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
@@ -41,77 +104,93 @@ struct globals {
|
||||
#define execname (G.execname )
|
||||
#define pidfile (G.pidfile )
|
||||
#define user_id (G.user_id )
|
||||
#define quiet (G.quiet )
|
||||
#define signal_nr (G.signal_nr )
|
||||
#define INIT_G() \
|
||||
do { \
|
||||
user_id = -1; \
|
||||
signal_nr = 15; \
|
||||
} while (0)
|
||||
#define INIT_G() do { \
|
||||
user_id = -1; \
|
||||
signal_nr = 15; \
|
||||
} while (0)
|
||||
|
||||
|
||||
static int pid_is_exec(pid_t pid, const char *name)
|
||||
#ifdef OLDER_VERSION_OF_X
|
||||
/* -x,--exec EXECUTABLE
|
||||
* Look for processes with matching /proc/$PID/exe.
|
||||
* Match is performed using device+inode.
|
||||
*/
|
||||
static int pid_is_exec(pid_t pid)
|
||||
{
|
||||
struct stat st;
|
||||
char buf[sizeof("/proc//exe") + sizeof(int)*3];
|
||||
char *execbuf;
|
||||
int n;
|
||||
|
||||
sprintf(buf, "/proc/%u/exe", pid);
|
||||
n = strlen(name) + 1;
|
||||
execbuf = xzalloc(n + 1);
|
||||
readlink(buf, execbuf, n);
|
||||
/* if readlink fails because link target is longer than strlen(name),
|
||||
* execbuf still contains "", and strcmp will return !0. */
|
||||
n = strcmp(execbuf, name);
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(execbuf);
|
||||
return !n; /* nonzero (true) if execbuf == name */
|
||||
sprintf(buf, "/proc/%u/exe", (unsigned)pid);
|
||||
if (stat(buf, &st) < 0)
|
||||
return 0;
|
||||
if (st.st_dev == execstat.st_dev
|
||||
&& st.st_ino == execstat.st_ino)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int pid_is_exec(pid_t pid)
|
||||
{
|
||||
ssize_t bytes;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
sprintf(buf, "/proc/%u/cmdline", (unsigned)pid);
|
||||
bytes = open_read_close(buf, buf, sizeof(buf) - 1);
|
||||
if (bytes > 0) {
|
||||
buf[bytes] = '\0';
|
||||
return strcmp(buf, execname) == 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int pid_is_user(int pid, int uid)
|
||||
static int pid_is_name(pid_t pid)
|
||||
{
|
||||
/* /proc/PID/stat is "PID (comm_15_bytes_max) ..." */
|
||||
char buf[32]; /* should be enough */
|
||||
char *p, *pe;
|
||||
|
||||
sprintf(buf, "/proc/%u/stat", (unsigned)pid);
|
||||
if (open_read_close(buf, buf, sizeof(buf) - 1) < 0)
|
||||
return 0;
|
||||
buf[sizeof(buf) - 1] = '\0'; /* paranoia */
|
||||
p = strchr(buf, '(');
|
||||
if (!p)
|
||||
return 0;
|
||||
pe = strrchr(++p, ')');
|
||||
if (!pe)
|
||||
return 0;
|
||||
*pe = '\0';
|
||||
/* we require comm to match and to not be truncated */
|
||||
/* in Linux, if comm is 15 chars, it may be a truncated
|
||||
* name, so we don't allow that to match */
|
||||
if (strlen(p) >= COMM_LEN - 1) /* COMM_LEN is 16 */
|
||||
return 0;
|
||||
return strcmp(p, cmdname) == 0;
|
||||
}
|
||||
|
||||
static int pid_is_user(int pid)
|
||||
{
|
||||
struct stat sb;
|
||||
char buf[sizeof("/proc/") + sizeof(int)*3];
|
||||
|
||||
sprintf(buf, "/proc/%u", pid);
|
||||
sprintf(buf, "/proc/%u", (unsigned)pid);
|
||||
if (stat(buf, &sb) != 0)
|
||||
return 0;
|
||||
return (sb.st_uid == uid);
|
||||
}
|
||||
|
||||
static int pid_is_cmd(pid_t pid, const char *name)
|
||||
{
|
||||
char fname[sizeof("/proc//stat") + sizeof(int)*3];
|
||||
char *buf;
|
||||
int r = 0;
|
||||
|
||||
sprintf(fname, "/proc/%u/stat", pid);
|
||||
buf = xmalloc_open_read_close(fname, NULL);
|
||||
if (buf) {
|
||||
char *p = strchr(buf, '(');
|
||||
if (p) {
|
||||
char *pe = strrchr(++p, ')');
|
||||
if (pe) {
|
||||
*pe = '\0';
|
||||
r = !strcmp(p, name);
|
||||
}
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
return r;
|
||||
return (sb.st_uid == (uid_t)user_id);
|
||||
}
|
||||
|
||||
static void check(int pid)
|
||||
{
|
||||
struct pid_list *p;
|
||||
|
||||
if (execname && !pid_is_exec(pid, execname)) {
|
||||
if (execname && !pid_is_exec(pid)) {
|
||||
return;
|
||||
}
|
||||
if (userspec && !pid_is_user(pid, user_id)) {
|
||||
if (cmdname && !pid_is_name(pid)) {
|
||||
return;
|
||||
}
|
||||
if (cmdname && !pid_is_cmd(pid, cmdname)) {
|
||||
if (userspec && !pid_is_user(pid)) {
|
||||
return;
|
||||
}
|
||||
p = xmalloc(sizeof(*p));
|
||||
@@ -148,9 +227,17 @@ static void do_procinit(void)
|
||||
procdir = xopendir("/proc");
|
||||
|
||||
pid = 0;
|
||||
while ((entry = readdir(procdir)) != NULL) {
|
||||
while (1) {
|
||||
errno = 0; /* clear any previous error */
|
||||
entry = readdir(procdir);
|
||||
// TODO: this check is too generic, it's better
|
||||
// to check for exact errno(s) which mean that we got stale entry
|
||||
if (errno) /* Stale entry, process has died after opendir */
|
||||
continue;
|
||||
if (!entry) /* EOF, no more entries */
|
||||
break;
|
||||
pid = bb_strtou(entry->d_name, NULL, 10);
|
||||
if (errno)
|
||||
if (errno) /* NaN */
|
||||
continue;
|
||||
check(pid);
|
||||
}
|
||||
@@ -165,40 +252,39 @@ static int do_stop(void)
|
||||
struct pid_list *p;
|
||||
int killed = 0;
|
||||
|
||||
do_procinit();
|
||||
|
||||
if (cmdname) {
|
||||
if (ENABLE_FEATURE_CLEAN_UP) what = xstrdup(cmdname);
|
||||
if (!ENABLE_FEATURE_CLEAN_UP) what = cmdname;
|
||||
} else if (execname) {
|
||||
if (ENABLE_FEATURE_CLEAN_UP) what = xstrdup(execname);
|
||||
if (!ENABLE_FEATURE_CLEAN_UP) what = execname;
|
||||
} else if (pidfile)
|
||||
} else if (pidfile) {
|
||||
what = xasprintf("process in pidfile '%s'", pidfile);
|
||||
else if (userspec)
|
||||
} else if (userspec) {
|
||||
what = xasprintf("process(es) owned by '%s'", userspec);
|
||||
else
|
||||
} else {
|
||||
bb_error_msg_and_die("internal error, please report");
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
if (!quiet)
|
||||
if (!QUIET)
|
||||
printf("no %s found; none killed\n", what);
|
||||
killed = -1;
|
||||
goto ret;
|
||||
}
|
||||
for (p = found; p; p = p->next) {
|
||||
if (kill(p->pid, signal_nr) == 0) {
|
||||
p->pid = - p->pid;
|
||||
if (TEST || kill(p->pid, signal_nr) == 0) {
|
||||
killed++;
|
||||
} else {
|
||||
bb_perror_msg("warning: killing process %u", p->pid);
|
||||
p->pid = 0;
|
||||
bb_perror_msg("warning: killing process %u", (unsigned)p->pid);
|
||||
}
|
||||
}
|
||||
if (!quiet && killed) {
|
||||
if (!QUIET && killed) {
|
||||
printf("stopped %s (pid", what);
|
||||
for (p = found; p; p = p->next)
|
||||
if (p->pid < 0)
|
||||
printf(" %u", - p->pid);
|
||||
if (p->pid)
|
||||
printf(" %u", (unsigned)p->pid);
|
||||
puts(")");
|
||||
}
|
||||
ret:
|
||||
@@ -213,6 +299,7 @@ static const char start_stop_daemon_longopts[] ALIGN1 =
|
||||
"start\0" No_argument "S"
|
||||
"background\0" No_argument "b"
|
||||
"quiet\0" No_argument "q"
|
||||
"test\0" No_argument "t"
|
||||
"make-pidfile\0" No_argument "m"
|
||||
#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
|
||||
"oknodo\0" No_argument "o"
|
||||
@@ -232,31 +319,16 @@ static const char start_stop_daemon_longopts[] ALIGN1 =
|
||||
;
|
||||
#endif
|
||||
|
||||
enum {
|
||||
CTX_STOP = 0x1,
|
||||
CTX_START = 0x2,
|
||||
OPT_BACKGROUND = 0x4, // -b
|
||||
OPT_QUIET = 0x8, // -q
|
||||
OPT_MAKEPID = 0x10, // -m
|
||||
OPT_a = 0x20, // -a
|
||||
OPT_n = 0x40, // -n
|
||||
OPT_s = 0x80, // -s
|
||||
OPT_u = 0x100, // -u
|
||||
OPT_c = 0x200, // -c
|
||||
OPT_x = 0x400, // -x
|
||||
OPT_p = 0x800, // -p
|
||||
OPT_OKNODO = 0x1000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -o
|
||||
OPT_VERBOSE = 0x2000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -v
|
||||
OPT_NICELEVEL = 0x4000 * ENABLE_FEATURE_START_STOP_DAEMON_FANCY, // -N
|
||||
};
|
||||
|
||||
int start_stop_daemon_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int start_stop_daemon_main(int argc, char **argv)
|
||||
int start_stop_daemon_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
unsigned opt;
|
||||
char *signame;
|
||||
char *startas;
|
||||
char *chuid;
|
||||
#ifdef OLDER_VERSION_OF_X
|
||||
struct stat execstat;
|
||||
#endif
|
||||
#if ENABLE_FEATURE_START_STOP_DAEMON_FANCY
|
||||
// char *retry_arg = NULL;
|
||||
// int retries = -1;
|
||||
@@ -269,9 +341,14 @@ int start_stop_daemon_main(int argc, char **argv)
|
||||
applet_long_options = start_stop_daemon_longopts;
|
||||
#endif
|
||||
|
||||
/* Check required one context option was given */
|
||||
opt_complementary = "K:S:K--S:S--K:m?p:K?xpun:S?xa";
|
||||
opt = getopt32(argv, "KSbqma:n:s:u:c:x:p:"
|
||||
/* -K or -S is required; they are mutually exclusive */
|
||||
/* -p is required if -m is given */
|
||||
/* -xpun (at least one) is required if -K is given */
|
||||
/* -xa (at least one) is required if -S is given */
|
||||
/* -q turns off -v */
|
||||
opt_complementary = "K:S:K--S:S--K:m?p:K?xpun:S?xa"
|
||||
USE_FEATURE_START_STOP_DAEMON_FANCY("q-v");
|
||||
opt = getopt32(argv, "KSbqtma:n:s:u:c:x:p:"
|
||||
USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:"),
|
||||
// USE_FEATURE_START_STOP_DAEMON_FANCY("ovN:R:"),
|
||||
&startas, &cmdname, &signame, &userspec, &chuid, &execname, &pidfile
|
||||
@@ -279,8 +356,6 @@ int start_stop_daemon_main(int argc, char **argv)
|
||||
// USE_FEATURE_START_STOP_DAEMON_FANCY(,&retry_arg)
|
||||
);
|
||||
|
||||
quiet = (opt & OPT_QUIET) && !(opt & OPT_VERBOSE);
|
||||
|
||||
if (opt & OPT_s) {
|
||||
signal_nr = get_signum(signame);
|
||||
if (signal_nr < 0) bb_show_usage();
|
||||
@@ -288,12 +363,14 @@ int start_stop_daemon_main(int argc, char **argv)
|
||||
|
||||
if (!(opt & OPT_a))
|
||||
startas = execname;
|
||||
if (!execname) /* in case -a is given and -x is not */
|
||||
execname = startas;
|
||||
|
||||
// USE_FEATURE_START_STOP_DAEMON_FANCY(
|
||||
// if (retry_arg)
|
||||
// retries = xatoi_u(retry_arg);
|
||||
// )
|
||||
argc -= optind;
|
||||
//argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (userspec) {
|
||||
@@ -301,23 +378,31 @@ int start_stop_daemon_main(int argc, char **argv)
|
||||
if (errno)
|
||||
user_id = xuname2uid(userspec);
|
||||
}
|
||||
/* Both start and stop need to know current processes */
|
||||
do_procinit();
|
||||
|
||||
if (opt & CTX_STOP) {
|
||||
int i = do_stop();
|
||||
return (opt & OPT_OKNODO) ? 0 : (i <= 0);
|
||||
}
|
||||
|
||||
do_procinit();
|
||||
|
||||
if (found) {
|
||||
if (!quiet)
|
||||
printf("%s already running\n%d\n", execname, found->pid);
|
||||
if (!QUIET)
|
||||
printf("%s is already running\n%u\n", execname, (unsigned)found->pid);
|
||||
return !(opt & OPT_OKNODO);
|
||||
}
|
||||
|
||||
#ifdef OLDER_VERSION_OF_X
|
||||
if (execname)
|
||||
xstat(execname, &execstat);
|
||||
#endif
|
||||
|
||||
*--argv = startas;
|
||||
if (opt & OPT_BACKGROUND) {
|
||||
#if BB_MMU
|
||||
bb_daemonize(0);
|
||||
bb_daemonize(DAEMON_DEVNULL_STDIO + DAEMON_CLOSE_EXTRA_FDS);
|
||||
/* DAEMON_DEVNULL_STDIO is superfluous -
|
||||
* it's always done by bb_daemonize() */
|
||||
#else
|
||||
pid_t pid = vfork();
|
||||
if (pid < 0) /* error */
|
||||
@@ -326,21 +411,20 @@ int start_stop_daemon_main(int argc, char **argv)
|
||||
/* parent */
|
||||
/* why _exit? the child may have changed the stack,
|
||||
* so "return 0" may do bad things */
|
||||
_exit(0);
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
/* child */
|
||||
/* Child */
|
||||
setsid(); /* detach from controlling tty */
|
||||
/* Redirect stdio to /dev/null, close extra FDs.
|
||||
* We do not actually daemonize because of DAEMON_ONLY_SANITIZE */
|
||||
bb_daemonize_or_rexec(
|
||||
DAEMON_DEVNULL_STDIO
|
||||
bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO
|
||||
+ DAEMON_CLOSE_EXTRA_FDS
|
||||
+ DAEMON_ONLY_SANITIZE,
|
||||
NULL /* argv, unused */ );
|
||||
#endif
|
||||
}
|
||||
if (opt & OPT_MAKEPID) {
|
||||
/* user wants _us_ to make the pidfile */
|
||||
/* User wants _us_ to make the pidfile */
|
||||
write_pidfile(pidfile);
|
||||
}
|
||||
if (opt & OPT_c) {
|
||||
@@ -358,6 +442,6 @@ int start_stop_daemon_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
execv(startas, argv);
|
||||
execvp(startas, argv);
|
||||
bb_perror_msg_and_die("cannot start %s", startas);
|
||||
}
|
||||
+52
-12
@@ -13,30 +13,69 @@
|
||||
#include "libbb.h"
|
||||
|
||||
int which_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int which_main(int argc, char **argv)
|
||||
int which_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
USE_DESKTOP(int opt;)
|
||||
int status = EXIT_SUCCESS;
|
||||
char *path;
|
||||
char *p;
|
||||
|
||||
if (argc <= 1 || argv[1][0] == '-') {
|
||||
bb_show_usage();
|
||||
opt_complementary = "-1"; /* at least one argument */
|
||||
USE_DESKTOP(opt =) getopt32(argv, "a");
|
||||
argv += optind;
|
||||
|
||||
/* This matches what is seen on e.g. ubuntu.
|
||||
* "which" there is a shell script. */
|
||||
path = getenv("PATH");
|
||||
if (!path) {
|
||||
path = (char*)bb_PATH_root_path;
|
||||
putenv(path);
|
||||
path += 5; /* skip "PATH=" */
|
||||
}
|
||||
|
||||
/* This matches what is seen on e.g. ubuntu
|
||||
* "which" there is a shell script */
|
||||
if (!getenv("PATH")) {
|
||||
putenv((char*)bb_PATH_root_path);
|
||||
}
|
||||
do {
|
||||
#if ENABLE_DESKTOP
|
||||
/* Much bloat just to support -a */
|
||||
if (strchr(*argv, '/')) {
|
||||
if (execable_file(*argv)) {
|
||||
puts(*argv);
|
||||
continue;
|
||||
}
|
||||
status = EXIT_FAILURE;
|
||||
} else {
|
||||
char *path2 = xstrdup(path);
|
||||
char *tmp = path2;
|
||||
|
||||
while (--argc > 0) {
|
||||
argv++;
|
||||
p = find_execable(*argv, &tmp);
|
||||
if (!p)
|
||||
status = EXIT_FAILURE;
|
||||
else {
|
||||
print:
|
||||
puts(p);
|
||||
free(p);
|
||||
if (opt) {
|
||||
/* -a: show matches in all PATH components */
|
||||
if (tmp) {
|
||||
p = find_execable(*argv, &tmp);
|
||||
if (p)
|
||||
goto print;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(path2);
|
||||
}
|
||||
#else
|
||||
/* Just ignoring -a */
|
||||
if (strchr(*argv, '/')) {
|
||||
if (execable_file(*argv)) {
|
||||
puts(*argv);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
p = find_execable(*argv);
|
||||
char *path2 = xstrdup(path);
|
||||
char *tmp = path2;
|
||||
p = find_execable(*argv, &tmp);
|
||||
free(path2);
|
||||
if (p) {
|
||||
puts(p);
|
||||
free(p);
|
||||
@@ -44,7 +83,8 @@ int which_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
} while (*(++argv) != NULL);
|
||||
|
||||
fflush_stdout_and_exit(status);
|
||||
}
|
||||
@@ -17,7 +17,7 @@ your embedded systems. To create a working system, just add some device
|
||||
nodes in /dev, a few configuration files in /etc, and a Linux kernel.</p>
|
||||
|
||||
<p>BusyBox is maintained by
|
||||
<a href="mailto:vda.linux@googlemail.com">Denis Vlasenko</a>,
|
||||
<a href="mailto:vda.linux@googlemail.com">Denys Vlasenko</a>,
|
||||
and licensed under the <a href="/license.html">GNU GENERAL PUBLIC LICENSE</a>
|
||||
version 2.</p>
|
||||
|
||||
|
||||
@@ -14,6 +14,9 @@ Also there are patches on top of latest bug fix release.
|
||||
<p>
|
||||
Latest releases and patch directories for each branch:
|
||||
<br>
|
||||
<a href=http://busybox.net/downloads/busybox-1.10.1.tar.bz2>1.10.1</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.10.1/>patches</a>,
|
||||
<br>
|
||||
<a href=http://busybox.net/downloads/busybox-1.9.2.tar.bz2>1.9.2</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.9.2/>patches</a>,
|
||||
<br>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<br>
|
||||
Mail all comments, insults, suggestions and bribes to
|
||||
<br>
|
||||
Denis Vlasenko <a href="mailto:vda.linux@googlemail.com">vda.linux@googlemail.com</a><br>
|
||||
Denys Vlasenko <a href="mailto:vda.linux@googlemail.com">vda.linux@googlemail.com</a><br>
|
||||
</font>
|
||||
</td>
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<ul>
|
||||
<li><a href="/cgi-bin/viewcvs.cgi/trunk/busybox/">Browse Source</a></li>
|
||||
<li><a href="subversion.html">Source Control</a></li>
|
||||
<li><a href="/downloads/patches/recent.html">Recent Changes</a></li>
|
||||
<!--li><a href="/downloads/patches/recent.html">Recent Changes</a></li-->
|
||||
<li><a href="lists.html">Mailing Lists</a></li>
|
||||
<li><a href="http://bugs.busybox.net/">Bug Tracking</a></li>
|
||||
</ul>
|
||||
@@ -79,12 +79,13 @@
|
||||
<ul>
|
||||
<li><a href="http://busybox.net/~landley">Rob</a></li>
|
||||
<li><a href="http://busybox.net/~aldot">Bernhard</a></li>
|
||||
<li><a href="http://busybox.net/~vda">Denis</a>
|
||||
<br>-<a href=http://busybox.net/~vda/mboot/>mboot</a>
|
||||
<br>-<a href=http://busybox.net/~vda/linld/>linld</a>
|
||||
<br>-<a href=http://busybox.net/~vda/init_vs_runsv.html>init must die</a>
|
||||
<br>-<a href=http://busybox.net/~vda/no_ifup.txt>no ifup</a>
|
||||
<br>-<a href=http://busybox.net/~vda/unscd/>unscd</a>
|
||||
<li><a href="http://busybox.net/~vda">Denys</a>
|
||||
<br>- <a href=http://busybox.net/~vda/resume/denys_vlasenko.htm>resume</a>
|
||||
<br>- <a href=http://busybox.net/~vda/mboot/>mboot</a>
|
||||
<br>- <a href=http://busybox.net/~vda/linld/>linld</a>
|
||||
<br>- <a href=http://busybox.net/~vda/init_vs_runsv.html>init must die</a>
|
||||
<br>- <a href=http://busybox.net/~vda/no_ifup.txt>no ifup</a>
|
||||
<br>- <a href=http://busybox.net/~vda/unscd/>unscd</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
+60
-801
@@ -1,6 +1,63 @@
|
||||
<!--#include file="header.html" -->
|
||||
|
||||
<ul>
|
||||
<li><b>12 June 2008 -- Sponsors!</b>
|
||||
<p>We want to thank the following companies which are providing support
|
||||
for BusyBox project:
|
||||
<ul>
|
||||
<li>AOE media, a <a href=http://www.aoemedia.com/typo3-development.html>
|
||||
TYPO3 development agency</a> contributes financially.
|
||||
<p>
|
||||
<li><a href=http://www.analog.com/en/>Analog Devices, Inc.</a> provided
|
||||
a <a href=http://docs.blackfin.uclinux.org/doku.php?id=bf537_quick_start>
|
||||
Blackfin development board</a> free of charge.
|
||||
<a href=http://www.analog.com/blackfin>Blackfin<a>
|
||||
is a NOMMU processor, and its availability for testing is invaluable.
|
||||
If you are an embedded device developer,
|
||||
please note that Analog Devices has entire Linux distribution available
|
||||
for download for this board. Visit
|
||||
<a href=http://blackfin.uclinux.org/>http://blackfin.uclinux.org/</a>
|
||||
for more information.
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<li><b>5 June 2008 -- BusyBox 1.10.3 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.10.3.tar.bz2>BusyBox 1.10.3</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_10_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.10.3/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
<p>
|
||||
Bugfix-only release for 1.10.x branch. It contains fixes for dnsd, fuser, hush,
|
||||
ip, mdev and syslogd.
|
||||
<p>
|
||||
<a href=http://busybox.net/~vda/HOWTO/i486-linux-uclibc/HOWTO.txt>
|
||||
How to build static busybox for i486-linux-uclibc</a>
|
||||
<p>
|
||||
The email address gpl@busybox.net is the recommended way to contact
|
||||
the Software Freedom Law Center to report BusyBox license violations.
|
||||
</p>
|
||||
|
||||
<li><b>8 May 2008 -- BusyBox 1.10.2 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.10.2.tar.bz2>BusyBox 1.10.2</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_10_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.10.2/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
<p>
|
||||
Bugfix-only release for 1.10.x branch. It contains fixes for echo, httpd, pidof,
|
||||
start-stop-daemon, tar, taskset, tab completion in shells, build system.
|
||||
<p>Please note that mdev was backported from current svn trunk. Please
|
||||
report if you encounter any problems with it.
|
||||
</p>
|
||||
|
||||
<li><b>19 April 2008 -- BusyBox 1.10.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.10.1.tar.bz2>BusyBox 1.10.1</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_10_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.10.1/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
<p>
|
||||
Bugfix-only release for 1.10.x branch. It contains fixes for
|
||||
fuser, init, less, nameif, tail, taskset, tcpudp, top, udhcp.
|
||||
|
||||
<li><b>21 March 2008 -- BusyBox 1.10.0 (unstable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.10.0.tar.bz2>BusyBox 1.10.0</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_10_stable/>svn</a>,
|
||||
@@ -134,7 +191,7 @@ iproute_list_or_flush 3680 readhere 2308
|
||||
<li>tail: fix "tail -c 20 /dev/huge_disk" (was taking ages)
|
||||
<li>tar: compat: handle tarballs with only one zero block at the end
|
||||
<li>tar: autodetection of gz/bz2 compressed tarballs. Closes bug 992
|
||||
<li>tar: real support for -p. By Natanael Copa <natanael.copa at gmail.com>
|
||||
<li>tar: real support for -p. By Natanael Copa <natanael.copa at gmail.com>
|
||||
<li>tcpudp: narrow down time window where we have no wildcard socket
|
||||
<li>telnetd: use login always, not "sometimes login, sometimes shell"
|
||||
<li>test: fix mishandling of "test ! arg1 op arg2 more args"
|
||||
@@ -152,11 +209,11 @@ iproute_list_or_flush 3680 readhere 2308
|
||||
<li>unzip: handle short reads correctly
|
||||
<li>vi: many fixes
|
||||
<li>zcip: don't chdir to root
|
||||
<li>zcip: open ARP socket before openlog (else we can thrash syslog socket)
|
||||
<li>zcip: open ARP socket before openlog (else we can trash syslog socket)
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<li><b>21 March 2008 -- BusyBox stable releases</b>
|
||||
<li><b>21 March 2008 -- BusyBox old stable releases</b>
|
||||
<p>
|
||||
Bugfix-only releases for four past branches. Links to locations
|
||||
for future hot patches are in parentheses.
|
||||
@@ -178,804 +235,6 @@ iproute_list_or_flush 3680 readhere 2308
|
||||
the Software Freedom Law Center to report BusyBox license violations.
|
||||
</p>
|
||||
|
||||
<li><b>12 February 2008 -- BusyBox 1.9.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.9.1.tar.bz2>BusyBox 1.9.1</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_9_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.9.1/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to fsck,
|
||||
iproute, mdev, mkswap, msh, nameif, stty, test, zcip.</p>
|
||||
<p>hush has `command` expansion re-enabled for NOMMU, although it is
|
||||
inherently unsafe (by virtue of NOMMU's use of vfork instead of fork).
|
||||
The plan is to make this less likely to bite people in future versions.</p>
|
||||
</li>
|
||||
|
||||
<li><b>24 December 2007 -- BusyBox 1.9.0 (unstable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.9.0.tar.bz2>BusyBox 1.9.0</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_9_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.9.0/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>Sizes of busybox-1.8.2 and busybox-1.9.0 (with almost full config, static uclibc build):<pre>
|
||||
text data bss dec hex filename
|
||||
792796 978 9724 803498 c42aa busybox-1.8.2
|
||||
783803 683 7508 791994 c15ba busybox-1.9.0
|
||||
</pre>
|
||||
<p>Top 10 stack users:<pre>
|
||||
busybox-1.8.2: busybox-1.9.0:
|
||||
input_tab 10428 echo_dg 4116
|
||||
umount_main 8252 bb_full_fd_action 4112
|
||||
rtnl_talk 8240 discard_dg 4096
|
||||
xrtnl_dump_filter 8240 echo_stream 4096
|
||||
sendMTFValues 5316 discard_stream 4096
|
||||
mainSort 4700 find_list_entry2 4096
|
||||
mkfs_minix_main 4288 readlink_main 4096
|
||||
grave 4260 ipaddr_list_or_flush 3900
|
||||
unix_do_one 4156 iproute_list_or_flush 3680
|
||||
parse_prompt 4132 insmod_main 3152
|
||||
</pre>
|
||||
|
||||
<p>lash is deleted from this release. hush can be configured down to almost
|
||||
the same size, but it is significantly less buggy. It even works
|
||||
on NOMMU machines (interactive mode and backticks are not working on NOMMU,
|
||||
though). "lash" applet is still available, but it runs hush.
|
||||
|
||||
<p>init has some changes in this release, please report if it causes
|
||||
problems for you.
|
||||
|
||||
<p>Changes since previous release:
|
||||
<ul>
|
||||
<li>Build system improvements
|
||||
<li>Testsuite additions
|
||||
<li>Stack size reductions, code size reductions, data/bss reductions
|
||||
<li>An option to prefer IPv4 address if host has both
|
||||
<li>New applets: hd, sestatus
|
||||
<li>Removed applets: lash
|
||||
<li>hush: fixed a few bugs, wired up echo and test to be builtins
|
||||
<li>init: simplify forking of children
|
||||
<li>getty: special handling of '#' and '@' is removed
|
||||
<li>[su]login: sanitize environment if called by non-root
|
||||
<li>udhcpc: support "bad" servers which send oversized packets
|
||||
(Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>)
|
||||
<li>udhcpc: -O option allows to specify which options to ask for
|
||||
(Stefan Hellermann <stefan at the2masters.de>)
|
||||
<li>udhcpc: optionally check whether given IP is really free (by ARP ping)
|
||||
(Jonas Danielsson <jonas.danielsson at axis.com>)
|
||||
<li>vi: now handles files with unlimited line length
|
||||
<li>vi: speedup for huge line lengths
|
||||
<li>vi: Del key works
|
||||
<li>sed: support GNUism '\t'
|
||||
<li>cp/mv/install: optionally use bigger buffer for bulk copying
|
||||
<li>line editing: don't eat stack like crazy
|
||||
<li>passwd: follows symlinked /etc/passwd
|
||||
<li>renice: accepts priority with +N too
|
||||
<li>netstat: wide output mode
|
||||
<li>nameif: extended matching (Nico Erfurth <masta at perlgolf.de>)
|
||||
<li>test: become NOFORK applet
|
||||
<li>find: -iname (Alexander Griesser <alexander.griesser at lkh-vil.or.at>)
|
||||
<li>df: -i option (show inode info) (Pascal Bellard <pascal.bellard at ads-lu.com>)
|
||||
<li>hexdump: -R option (Pascal Bellard <pascal.bellard at ads-lu.com>)
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<li><b>23 November 2007 -- BusyBox 1.8.2 (stable), BusyBox 1.7.4 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.8.2.tar.bz2>BusyBox 1.8.2</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.8.2/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.7.4.tar.bz2>BusyBox 1.7.4</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.7.4/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>These are bugfix-only releases.
|
||||
1.8.2 contains fixes for inetd, lash, tar, tr, and build system.
|
||||
1.7.4 contains a fix for inetd.</p>
|
||||
</li>
|
||||
|
||||
<li><b>9 November 2007 -- BusyBox 1.8.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.8.1.tar.bz2>BusyBox 1.8.1</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.8.1/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to login (PAM), modprobe, syslogd, telnetd, unzip.</p>
|
||||
</li>
|
||||
|
||||
<li><b>4 November 2007 -- BusyBox 1.8.0 (unstable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.8.0.tar.bz2>BusyBox 1.8.0</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.8.0/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>Note: this is probably the very last release with lash. It will be dropped. Please migrate to hush.
|
||||
|
||||
<p>Applets which had many changes since 1.7.x:
|
||||
<p>httpd:
|
||||
<ul>
|
||||
<li>does not clear environment, CGIs will see all environment variables which were set for httpd
|
||||
<li>fix bug where we were trying to read more POSTDATA than content-length
|
||||
<li>fix trivial bug (spotted by Alex Landau)
|
||||
<li>optional support for partial downloads
|
||||
<li>simplified CGI i/o loop (now it looks good to me)
|
||||
<li>small auth and IPv6 fixes (Kim B. Heino <Kim.Heino at bluegiga.com>)
|
||||
<li>support for proxying connection to other http server (by Alex Landau <landau_alex at yahoo.com>)
|
||||
</ul>
|
||||
|
||||
<p>top:
|
||||
<ul>
|
||||
<li>TOPMEM feature - 's(how sizes)' command
|
||||
<li>don't wait before final bailout (try top -b -n1)
|
||||
<li>fix for command line wrapping
|
||||
</ul>
|
||||
|
||||
<p>Build system improvements: libbusybox mode restored (it was lost in transition to new makefiles).
|
||||
|
||||
<p>Code and data size in comparison with 1.7.3:<pre>
|
||||
Equivalent .config, i386 uclibc static builds:
|
||||
text data bss dec hex filename
|
||||
768123 1055 10768 779946 be6aa busybox-1.7.3/busybox
|
||||
759693 974 9420 770087 bc027 busybox-1.8.0/busybox</pre>
|
||||
|
||||
<p>New applets:
|
||||
<ul>
|
||||
<li>microcom: new applet by Vladimir Dronnikov <dronnikov at gmail.ru>
|
||||
<li>kbd_mode: new applet by Loic Grenie <loic.grenie at gmail.com>
|
||||
<li>bzip2: port bzip2 1.0.4 to busybox, 9 kb of code
|
||||
<li>pgrep, pkill: new applets by Loic Grenie <loic.grenie at gmail.com>
|
||||
<li>setsebool: new applet (Yuichi Nakamura <ynakam at hitachisoft.jp>)
|
||||
</ul>
|
||||
|
||||
<p>Other changes since previous release (abridged):
|
||||
<ul>
|
||||
<li>cp: -r and -R imply -d (coreutils compat)
|
||||
<li>cp: detect and prevent infinite recursion
|
||||
<li>cp: make it a bit closer to POSIX, but still refuse to open and overwrite symbolic link
|
||||
<li>hdparm: reduce possibility of numeric overflow in -T
|
||||
<li>hdparm: simplify timing measurement
|
||||
<li>wget: -O FILE is allowed to overwrite existing file (compat)
|
||||
<li>wget: allow dots in header field names
|
||||
<li>telnetd: add -K option to close sessions as soon as child exits
|
||||
<li>telnetd: don't SIGKILL child when closing the session, kernel will send SIGHUP for us
|
||||
<li>ed: large cleanup, add line editing
|
||||
<li>hush: feeble attempt at making it more NOMMU-friendly
|
||||
<li>hush: fix glob()
|
||||
<li>hush: stop doing manual accounting of open fd's, kernel can do it for us
|
||||
<li>adduser: implement -S and fix uid selection
|
||||
<li>ash: fix prompt expansion (Natanael Copa <natanael.copa at gmail.com>)
|
||||
<li>ash: revert "cat | jobs" fix, it causes more problems than good
|
||||
<li>find: fix -xdev behavior in the presence of two or more nested mount points
|
||||
<li>grep: fix grep -F -e str1 -e str2 (was matching str2 only)
|
||||
<li>grep: optimization: stop on first -e match
|
||||
<li>gunzip: support concatenated gz files
|
||||
<li>inetd: fix bug 1562 "inetd does not set argv[0] properly" (fix by Ilya Panfilov)
|
||||
<li>install: 'support' (by ignoring) -v and -b
|
||||
<li>install: fix bug in "install -c file dir" (tried to copy dir into dir too)
|
||||
<li>ip: tunnel parameter parsing fix by Jean Wolter <jw5 at os.inf.tu-dresden.de>
|
||||
<li>isrv: use monotonic_sec
|
||||
<li>less: make 'f' key page forward
|
||||
<li>libiproute: add missing break statements
|
||||
<li>load_policy: update (Yuichi Nakamura <ynakam at hitachisoft.jp>)
|
||||
<li>logger: fix a problem of losing all argv except first
|
||||
<li>login: do reject wrong passwords with PAM auth
|
||||
<li>losetup: support -f (Loic Grenie <loic.grenie at gmail.com>)
|
||||
<li>fdisk: make fdisk compile on libc without llseek64
|
||||
<li>libbb: by popular request allow PATH to be customized at build time
|
||||
<li>mkswap: selinux support by KaiGai Kohei <kaigai at ak.jp.nec.com>
|
||||
<li>mount: allow (and ignore) -i
|
||||
<li>mount: ignore NFS bg option on NOMMU machines
|
||||
<li>mount: mount helpers support (by Vladimir Dronnikov <dronnikov at gmail.ru>)
|
||||
<li>passwd: handle Ctrl-C, restore termios on Ctrl-C
|
||||
<li>passwd: SELinux support by KaiGai Kohei <kaigai at ak.jp.nec.com>
|
||||
<li>ping: make -I ethN work too (-I addr already worked)
|
||||
<li>ps: fix RSS parsing (rss field in /proc/PID/stat is in pages, not bytes)
|
||||
<li>read_line_input: fix it to not do any fancy editing if echoing is disabled
|
||||
<li>run_parts: make it sort executables by name (required by API)
|
||||
<li>runsv: do not use clock_gettime if !MONOTONIC_CLOCK
|
||||
<li>runsvdir: fix "linear wait time" bug
|
||||
<li>sulogin: remove alarm handling, it is redundant there
|
||||
<li>svlogd: compat: svlogd -tt should timestamp stderr too
|
||||
<li>syslogd: bail out if you see null read from Unix socket
|
||||
<li>syslogd: do not need to poll(), we can just block in read()
|
||||
<li>tail: work correctly on /proc files (Kazuo TAKADA <kztakada at sm.sony.co.jp>)
|
||||
<li>tar + gzip/bzip2/etc: support NOMMU machines (by Alex Landau <landau_alex at yahoo.com>)
|
||||
<li>tar: strip leading '/' BEFORE memorizing hardlink's name
|
||||
<li>tftp: fix infinite retry bug
|
||||
<li>umount: support (by ignoring) -i; style fixes
|
||||
<li>unzip: fix endianness bugs
|
||||
<li>vi: don't wait 50 ms before reading ESC sequences
|
||||
<li>watchdog: allow millisecond spec (-t 250ms)
|
||||
<li>zcip: fix unaligned trap on ARM
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
</li>
|
||||
|
||||
<li><b>4 November 2007 -- BusyBox 1.7.3 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.7.3.tar.bz2>BusyBox 1.7.3</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.7.3/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to ash, httpd, inetd, iptun, logger, login, tail.</p>
|
||||
</li>
|
||||
|
||||
<li><b>30 September 2007 -- BusyBox 1.7.2 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.7.2.tar.bz2>BusyBox 1.7.2</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.7.2/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to install, find, login, httpd, runsvdir, chcon, setfiles, fdisk and line editing.</p>
|
||||
</li>
|
||||
|
||||
<li><b>16 September 2007 -- BusyBox 1.7.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.7.1.tar.bz2>BusyBox 1.7.1</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.7.1/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to cp, runsv, tar, busybox --install and build system.</p>
|
||||
</li>
|
||||
|
||||
<li><b>24 August 2007 -- BusyBox 1.7.0 (unstable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.7.0.tar.bz2>BusyBox 1.7.0</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.7.0/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>Applets which had many changes since 1.6.x:
|
||||
<p>httpd:
|
||||
<ul>
|
||||
<li>works in standalone mode on NOMMU machines now (partly by Alex Landau <landau_alex at yahoo.com>)
|
||||
<li>indexer example is rewritten in C
|
||||
<li>optional support for error pages (by Pierre Metras <genepi at sympatico.ca>)
|
||||
<li>stop reading headers using 1-byte reads
|
||||
<li>new option -v[v]: prints client addresses, HTTP codes returned, URLs
|
||||
<li>extended -p PORT to -p [IP[v6]:]PORT
|
||||
<li>sendfile support (by Pierre Metras <genepi at sympatico.ca>)
|
||||
<li>add support for Status: CGI header
|
||||
<li>fix CGI handling bug (we were closing wrong fd)
|
||||
<li>CGI I/O loop still doesn't look 100% ok to me...
|
||||
</ul>
|
||||
|
||||
<p>udhcp[cd]:
|
||||
<ul>
|
||||
<li>add -f "foreground" and -S "syslog" options
|
||||
<li>fixed "ifupdown + udhcpc_without_pidfile_creation" bug
|
||||
<li>new config option "Rewrite the lease file at every new acknowledge" (Mats Erik Andersson <mats at blue2net.com> (Blue2Net AB))
|
||||
<li>consistently treat server_config.start/end IPs as host-order
|
||||
<li>fix IP parsing for 64bit machines
|
||||
<li>fix unsafe hton macro usage in read_opt()
|
||||
<li>do not chdir to / when daemonizing
|
||||
</ul>
|
||||
|
||||
<p>top, ps, killall, pidof:
|
||||
<ul>
|
||||
<li>simpler loadavg processing
|
||||
<li>truncate usernames to 8 chars
|
||||
<li>fix non-CONFIG_DESKTOP ps -ww (by rockeychu)
|
||||
<li>improve /proc/PID/cmdinfo reading code
|
||||
<li>use cmdline, not comm field (fixes problems with re-execed applets showing as processes with name "exe", and not being found by pidof/killall by applet name)
|
||||
<li>reduce CPU usage in decimal conversion (optional) (corresponding speedup on kernel side is accepted in mainline Linux kernel, yay!)
|
||||
<li>make percentile (0.1%) calculations configurable
|
||||
<li>add config option and code for global CPU% display
|
||||
<li>reorder columns, so that [P]PIDs are together and VSZ/%MEM are together - makes more sense
|
||||
</ul>
|
||||
|
||||
<p>Build system improvements: doesn't link against libraries we don't need,
|
||||
generates verbose link output and map file, allows for custom link
|
||||
scripts (useful for removing extra padding, among other things).
|
||||
|
||||
<p>Code and data size in comparison with 1.6.1:<pre>
|
||||
Equivalent .config, i386 glibc dynamic builds:
|
||||
text data bss dec hex filename
|
||||
672671 2768 16808 692247 a9017 busybox-1.6.1/busybox
|
||||
662948 2660 13528 679136 a5ce0 busybox-1.7.0/busybox
|
||||
662783 2631 13416 678830 a5bae busybox-1.7.0/busybox.customld
|
||||
|
||||
Same .config built against static uclibc:
|
||||
765021 1059 11020 777100 bdb8c busybox-1.7.0/busybox_uc</pre>
|
||||
|
||||
<p>Code/data shrink done in applets: crond, hdparm, dd, cal, od, nc, expr, uuencode,
|
||||
test, slattach, diff, ping, tr, syslogd, hwclock, zcip, find, pidof, ash, uudecode,
|
||||
runit/*, in libbb.
|
||||
|
||||
<p>New applets:
|
||||
<ul>
|
||||
<li>pscan, expand, unexpand (from Tito <farmatito at tiscali.it>)
|
||||
<li>setfiles, restorecon (by Yuichi Nakamura <ynakam at hitachisoft.jp>)
|
||||
<li>chpasswd (by Alexander Shishkin <virtuoso at slind.org>)
|
||||
<li>slattach, ttysize
|
||||
</ul>
|
||||
|
||||
<p>Unfortunately, not much work is done on shells. This was mostly stalled
|
||||
by lack of time (read: laziness) on my part to learn how to adapt existing
|
||||
qemu-runnable image for a NOMMU architechture (available on qemu website)
|
||||
for local testing of cross-compiled busybox on my machine.
|
||||
|
||||
<p>Other changes since previous release (abridged):
|
||||
<ul>
|
||||
<li>addgroup: disallow addgroup -g num user group; make -g 0 work (Tito <farmatito at tiscali.it>)
|
||||
<li>adduser: close /etc/{passwd,shadow} before calling passwd etc. Spotted by Natanael Copa <natanael.copa at gmail.com>
|
||||
<li>arping: -i should be -I, fixed
|
||||
<li>ash: make "jobs | cat" work like in bash (was giving empty output)
|
||||
<li>ash: recognize -l as --login equivalent; do not recognize +-login
|
||||
<li>ash: fix buglet in DEBUG code (Nguyen Thai Ngoc Duy <pclouds at gmail.com>)
|
||||
<li>ash: fix SEGV if type has zero parameters
|
||||
<li>awk: fix -F 'regex' bug (miscounted fields if last field is empty)
|
||||
<li>catv: catv without arguments was trying to use environ as argv (Alex Landau <landau_alex at yahoo.com>)
|
||||
<li>catv: don't die on open error (emit warning)
|
||||
<li>chown/chgrp: completely match coreutils 6.8 wrt symlink handling
|
||||
<li>correct_password: do not print "no shadow passwd..." message
|
||||
<li>crond: don't start sendmail with absolute path, don't report obsolete version (report true bbox version)
|
||||
<li>dd: fix bug where we assume count=INT_MAX when count is unspecified
|
||||
<li>devfsd: sanitization by Tito <farmatito at tiscali.it>
|
||||
<li>echo: fix non-fancy echo
|
||||
<li>fdisk: make it work with big disks (read: typical today's disks) even if CONFIG_LFS is unset
|
||||
<li>find: -context support for SELinux (KaiGai Kohei <kaigai at kaigai.gr.jp>)
|
||||
<li>find: add conditional support for -maxdepth and -regex, make -size match GNU find
|
||||
<li>find: fix build failure on certain configs (found by Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>)
|
||||
<li>fsck_minix: make it print bb version, not it's own (outdated/irrelevant) one
|
||||
<li>grep: implement -m MAX_MATCHES, fix buglets with context printing
|
||||
<li>grep: fix selection done by FEATURE_GREP_EGREP_ALIAS (Maxime Bizon <mbizon at freebox.fr> (Freebox))
|
||||
<li>hush: add missing dependencies (Maxime Bizon <mbizon at freebox.fr> (Freebox))
|
||||
<li>hush: fix read builtin to not read ahead past EOL and to not use insane amounts of stack
|
||||
<li>ifconfig: make it work with ifaces with interface no. > 255
|
||||
<li>ifup/ifdown: make location of ifstate configurable
|
||||
<li>ifupdown: make netmask parsing smaller and more strict (was accepting 255.0.255.0, 255.1234.0.0 etc...)
|
||||
<li>install: fix -s (strip) option, fix install a b /a/link/to/dir
|
||||
<li>libbb: consolidate ARRAY_SIZE macro (Walter Harms <wharms at bfs.de>)
|
||||
<li>libbb: make /etc/network parsing configurable. -200 bytes when off
|
||||
<li>libbb: nuke BB_GETOPT_ERROR, always die if there are mutually exclusive options
|
||||
<li>libbb: xioctl and friends by Tito <farmatito at tiscali.it>
|
||||
<li>login: optional support for PAM
|
||||
<li>login: make /etc/nologin support configurable (-240 bytes)
|
||||
<li>login: ask passwords even for wrong usernames
|
||||
<li>md5_sha1_sum: fix mishandling when run as /bin/md5sum
|
||||
<li>mdev: add support for firmware loading
|
||||
<li>mdev: work even when CONFIG_SYSFS_DEPRECATED in kernel is off
|
||||
<li>modprobe: add scanning of /lib/modules/`uname -r`/modules.symbols (by Yann E. MORIN <yann.morin.1998 at anciens.enib.fr>)
|
||||
<li>more: fixes by Tristan Schmelcher <tpkschme at engmail.uwaterloo.ca>
|
||||
<li>nc: make connecting to IPv4 from IPv6-enabled hosts easier (was requiring -s local_addr)
|
||||
<li>passwd: fix bug "updating shadow even if user's record is in passwd"
|
||||
<li>patch: fix -p -1 handling
|
||||
<li>patch: fix bad line ending handling (Nguyen Thai Ngoc Duy <pclouds at gmail.com>)
|
||||
<li>ping: display roundtrip times with 1/1000th of ms, not 1/10 ms precision.
|
||||
<li>ping: fix incorrect handling of -I (Iouri Kharon <bc-info at styx.cabel.net>)
|
||||
<li>ping: fix non-fancy ping6
|
||||
<li>printenv: fix "printenv VAR1 VAR2" bug (spotted by Kalyanatejaswi Balabhadrapatruni <kalyanatejaswi at yahoo.co.in>)
|
||||
<li>ps: fix -Z (by Yuichi Nakamura <ynakam at hitachisoft.jp>)
|
||||
<li>rpm: add optional support for bz2 data. +50 bytes of code
|
||||
<li>rpm: fix bogus "package is not installed" case
|
||||
<li>sed: fix 'q' command handling (by Nguyen Thai Ngoc Duy <pclouds at gmail.com>)
|
||||
<li>start_stop_daemon: NOMMU fixes by Alex Landau <landau_alex at yahoo.com>
|
||||
<li>stat: fix option -Z SEGV
|
||||
<li>strings: strings a b was processing a twice, fix that
|
||||
<li>svlogd: fix timestamping, do not warn if config is missing
|
||||
<li>syslogd, logread: get rid of head pointer, fix logread bug in the process
|
||||
<li>syslogd: do not convert tabs to ^I, set syslog IPC buffer to mode 0644
|
||||
<li>tar: improve OLDGNU compat, make old SUN compat configurable
|
||||
<li>test: fix testing primary expressions like '"-u" = "-u"'
|
||||
<li>uudecode: fix to base64 decode by Jorgen Cederlof <jcz at google.com>
|
||||
<li>vi: multiple fixes by Natanael Copa <natanael.copa at gmail.com>
|
||||
<li>wget: fix bug in base64 encoding (bug 1404). +10 bytes
|
||||
<li>wget: lift 256 chars limitation on terminal width
|
||||
<li>wget, zcip: use monotonic_sec instead of gettimeofday
|
||||
</ul>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>30 June 2007 -- BusyBox 1.6.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.6.1.tar.bz2>BusyBox 1.6.1</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_6_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.6.1/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to echo, hush, and wget.</p>
|
||||
</li>
|
||||
|
||||
<li><b>1 June 2007 -- BusyBox 1.6.0 (unstable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.6.0.tar.bz2>BusyBox 1.6.0</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_6_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.6.0/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>Since this is a x.x.0 release, it probably does not deserve "stable"
|
||||
label. Please help making 1.6.1 stable by testing 1.6.0.</p>
|
||||
<p>Note that hush shell had many changes and (hopefully) is much improved now,
|
||||
but there is a possibility that it regressed in some obscure cases. Please
|
||||
report any such cases.</p>
|
||||
<p>lash users please note: lash is going to be deprecated in busybox 1.7.0
|
||||
and removed in the more distant future. Please migrate to hush.</p>
|
||||
<p><a href=http://busybox.net/~vda/mem_usage-1.6.0.txt>Memory usage has decreased, but we can do better still</a></p>
|
||||
<p>Other changes since previous release:
|
||||
<ul>
|
||||
<li>NOFORK: audit small applets and mark some of them as NOFORK. Put big scary warnings in relevant places
|
||||
<li>NOFORK: factor out NOFORK/NOEXEC code from find. Use NOFORK/NOEXEC in find and xargs
|
||||
<li>NOFORK: remove potential xmalloc from NOFORK path in bb_full_fd_action
|
||||
<li>NOMMU: random fixes; compressed --help now works for NOMMU
|
||||
<li>SELinux: load_policy applet
|
||||
<li>[u]mount: extend -t option (Roy Marples <uberlord at gentoo.org>)
|
||||
<li>addgroup: clean up, fix adding users to existing groups and make it optional (Tito)
|
||||
<li>adduser: don't bomb out if shadow password file doesn't exist (from Tito <farmatito at tiscali.it>)
|
||||
<li>applet.c: do not even try to read config if run by real root; fix suid config handling
|
||||
<li>ash: fix infinite loop on exit if tty is not there anymore
|
||||
<li>ash: fix kill -l (by Mats Erik Andersson <mats.andersson64 at comhem.se>)
|
||||
<li>ash: implement type -p, costs less than 10 bytes (patch by Mats Erik Andersson <mats.andersson64 at comhem.se>)
|
||||
<li>awk: don't segfault on printf(%*s). Closes bug 1337
|
||||
<li>awk: guard against empty environment
|
||||
<li>awk: some 'lineno' vars were shorts, made them ints (code got smaller)
|
||||
<li>cat: stop using stdio.h opens
|
||||
<li>config system: clarify PREFER_APPLETS/SH_STANDALONE effects in help text
|
||||
<li>cryptpw: new applet (by Thomas Lundquist <lists at zelow.no>)
|
||||
<li>cttyhack: new applet
|
||||
<li>dd: NOEXEC fix; fix skip= parse error (spotted by Dirk Clemens <develop at cle-mens.de>)
|
||||
<li>deluser: add optional support for removing users from groups (by Tito <farmatito at tiscali.it>)
|
||||
<li>diff: fix SEGV (NULL deref) in diff -N
|
||||
<li>diff: fix segfault on empty dirs (Peter Korsgaard <peter.korsgaard at barco.com>)
|
||||
<li>dnsd: fix several buglets, make smaller; openlog(), so that applet's name is logged
|
||||
<li>dpkg: run_package_script() returns 0 if all ok and non-zero if failure. The result code was checked incorrectly in two places. (from Kim B. Heino <Kim.Heino at bluegiga.com>)
|
||||
<li>dpkg: use bitfields which are a bit closer to typical short/char. Code size -800 bytes
|
||||
<li>dumpleases: getopt32()-ization (from Mats Erik Andersson <mats.andersson64 at comhem.se>)
|
||||
<li>e2fsprogs: stop using statics in chattr. Minor code shrinkage (-130 bytes)
|
||||
<li>ether-wake: close bug 1317. Reorder fuctions to avoid forward refs while at it
|
||||
<li>ether-wake: save a few more bytes of code
|
||||
<li>find: -group, -depth (Natanael Copa <natanael.copa at gmail.com>)
|
||||
<li>find: add support for -delete, -path (by Natanael Copa)
|
||||
<li>find: fix -prune. Add big comment about it
|
||||
<li>find: improve usage text (Natanael Copa <natanael.copa at gmail.com>)
|
||||
<li>find: missed 'static' on const data; size and prune were mixed up; use index_in_str_array
|
||||
<li>find: un-DESKTOPize (Kai Schwenzfeier <niteblade at gmx.net>)
|
||||
<li>find_root_device: teach to deal with /dev/ subdirs (by Kirill K. Smirnov <lich at math.spbu.ru>)
|
||||
<li>find_root_device: use lstat - don't follow links
|
||||
<li>getopt32: fix llist_t options ordering. llist_rev is now unused
|
||||
<li>getopt: use getopt32 for option parsing - inspired by patch by Mats Erik Andersson <mats.andersson64 at comhem.se>
|
||||
<li>hdparm: fix multisector mode setting (from Toni Mirabete <amirabete at catix.cat>)
|
||||
<li>hdparm: make -T -t code smaller (-194 bytes), and output prettier
|
||||
<li>ifupdown: make it possible to use DHCP clients different from udhcp
|
||||
<li>ifupdown: reread state file before rewriting it. Fixes "ifup started another ifup" state corruption bug. Patch by Natanael Copa <natanael.copa at gmail.com>
|
||||
<li>ifupdown: small optimization (avoid doing useless work if we are not going to update state file)
|
||||
<li>ip: fix compilation if FEATURE_TR_CLASSES is off
|
||||
<li>ip: mv ip*_main into ip.c; use a dispatcher to save on needless duplication. Saves a minor 12b
|
||||
<li>ip: rewrite the ip applet to be less bloaty. Convert to index_in_(sub)str_array()
|
||||
<li>ip: set the scope properly. Thanks to Jean Wolter
|
||||
<li>iplink: shrink iplink; sanitize libiproute a bit (-916 bytes)
|
||||
<li>iproute: shrink a bit (-200 bytes)
|
||||
<li>kill: know much more signals; make code smaller; use common code for kill applet and ash kill builtin
|
||||
<li>klogd: remove dependency on syslogd
|
||||
<li>lash: "forking" applets are actually can be treated the same way as "non-forked". Also save a bit of space on trailing NULL array elements.
|
||||
<li>lash: fix kill buglet (didn't properly recognize ESRCH)
|
||||
<li>lash: make -c work; crush buffer overrun and free of non-malloced ptr (from Mats Erik Andersson <mats.andersson64 at comhem.se>)
|
||||
<li>lash: recognize and use NOFORK applets
|
||||
<li>less: fix case when regex search finds nothing; fix very obscure memory corruption bug; fix less <HUGEFILE + [End] busy loop
|
||||
<li>libbb: add xsendto, xunlink, xpipe
|
||||
<li>libbb: fix segfault in reset_ino_dev_hashtable() when *hashtable was NULL
|
||||
<li>libbb: make pidfile writing configurable
|
||||
<li>libbb: make xsocket die with address family printed (if VERBOSE_RESOLUTION_ERRORS=y)
|
||||
<li>libbb: rework NOMMU helper API so that it makes more sense and easier to use
|
||||
<li>libiproute: audit callgraph, shortcut error paths into die() functions
|
||||
<li>lineedit: do not try to open NULL history file
|
||||
<li>lineedit: nuke two unused variables and code which sets them
|
||||
<li>login: remove setpgrp call (makes it work from shell prompt again); sanitize stdio descriptors (we are suid, need to be careful!)
|
||||
<li>login: shrink login and set_environment by ~100 bytes
|
||||
<li>mount: fix incorrect usage of strtok (inadvertently used NULL sometimes)
|
||||
<li>mount: fix mounting of symlinks (mount from util-linux allows that)
|
||||
<li>msh: data/bss reduction (more than 9k of it); fix "underscore bug" (a_b=1111 didn't work); fix obscure case with backticks and closed fd 1
|
||||
<li>nc: port nc 1.10 to busybox
|
||||
<li>netstat: fix for bogus state value for raw sockets
|
||||
<li>netstat: introduce -W: wide, ipv6-friendly output; shrink by ~500 bytes
|
||||
<li>nmeter: should die if stdout doesn't like him anymore
|
||||
<li>patch: do not try to delete same file twice
|
||||
<li>ping: fix wrong sign extension of packet id (bug 1373)
|
||||
<li>ps: add -o tty and -o rss support; make a bit smaller; work around libc bug: printf("%.*s\n", MAX_INT, buffer)
|
||||
<li>run_parts: rewrite
|
||||
<li>run_parts: do not check path portion of a name for "bad chars". Needed for ifupdown. Patch by Gabriel L. Somlo <somlo at cmu.edu>
|
||||
<li>sed: fix escaped newlines in -f
|
||||
<li>split: new applet
|
||||
<li>stat: remove superfluous bss user (flags) and manually unswitch some areas
|
||||
<li>stty: fix option parsing bug (spotted by Sascha Hauer <s.hauer at pengutronix.de>)
|
||||
<li>svlogd: fix 'SEGV on uninitialized data' and make it honor TERM
|
||||
<li>tail: fix SEGV on "tail -N"
|
||||
<li>ipsvd: tcpsvd,udpsvd are new applets, GPL-ed 'clones' of Dan Bernstein's tcpserver. Author: Gerrit Pape <pape at smarden.org>, http://smarden.sunsite.dk/ipsvd/
|
||||
<li>test: close bug 1371; plug a memory leak; code size reduction
|
||||
<li>tftp: code diet, and I think retransmits were broken
|
||||
<li>tr: fix bug where we did not reject invalid classes like '[[:alpha'. debloat while at it
|
||||
<li>udhcp: MAC_BCAST_ADDR and blank_chaddr are in fact constant, move to rodata; use pipe instead of socketpair
|
||||
<li>udhcp[cd]: stop using atexit magic fir pidfile removal; stop deleting our own pidfile if we daemonize
|
||||
<li>xargs: shrink code, ~80 bytes; simplify word list management
|
||||
<li>zcip: make it work on NOMMU (+ improve NOMMU support machinery)
|
||||
</ul>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>20 May 2007 -- BusyBox 1.5.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.5.1.tar.bz2>BusyBox 1.5.1</a>.
|
||||
(<a href=http://busybox.net/downloads/fixes-1.5.1/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to hdparm, hush, ifupdown, ps
|
||||
and sed.</p>
|
||||
</li>
|
||||
|
||||
<li><b>23 March 2007 -- BusyBox 1.5.0 (unstable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.5.0.tar.bz2>BusyBox 1.5.0</a>.
|
||||
(<a href=http://busybox.net/downloads/fixes-1.5.0/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>Since this is a x.x.0 release, it probably does not deserve "stable"
|
||||
label. Please help making 1.5.1 stable by testing 1.5.0.</p>
|
||||
<p>Notable changes since previous release:
|
||||
<ul>
|
||||
<li>find: added support for -user, -not, fixed -mtime, -mmin, -perm
|
||||
<li>[de]archivers: merge common logic into one module
|
||||
<li>ping[6]: unified code for both
|
||||
<li>less: regex search improved
|
||||
<li>ash: more readable code, testsuite added
|
||||
<li>sed: several very obscure bugs fixed
|
||||
<li>chown: -H, -L, -P support (required by POSIX)
|
||||
<li>tar: handle (broken) checksums a-la Sun; tar restores mode again
|
||||
<li>grep: implement -w, "implement" -a and -I by ignoring them
|
||||
<li>cp: more sane behavior when overwriting existing files
|
||||
<li>init: stop doing silly things with the console (-400 bytes)
|
||||
<li>httpd: make httpd usable for NOMMU CPUs; fix POSTDATA handling bugs
|
||||
<li>httpd: run interpreter for configured file extensions in any dir,
|
||||
not only in /cgi-bin/
|
||||
<li>chrt: new applet
|
||||
<li>SELinux: SELinux-related code and -Z option added to several applets,
|
||||
new SELinux-specific applets: chcon, runcon.
|
||||
<li>Build system: produces link map, uses -Wwrite-strings to catch
|
||||
improper usage of string constants.
|
||||
<li>Data and bss section usage audited and reduced - should help NOMMU
|
||||
targets.
|
||||
<li>Applets with bug fixes: gunzip, vi, syslogd, dpkg, ls, adjtimex, resize,
|
||||
sv, printf, diff, awk, sort, dpkg, diff, tftp
|
||||
<li>Applets with usability improvements: swapon, more, ifup/ifdown, hwclock,
|
||||
udhcpd, start_stop_daemon, cmp
|
||||
<li>Applets with code cleaned up: telnet, fdisk, fsck_minix, mkfs_minix,
|
||||
syslogd, swapon, runsv, svlogd, klogd
|
||||
</ul>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>18 March 2007 -- BusyBox 1.4.2 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.4.2.tar.bz2>BusyBox 1.4.2</a>.
|
||||
</p>
|
||||
|
||||
<p>This release includes only trivial fixes accumulated since 1.4.1.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>25 January 2007 -- BusyBox 1.4.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.4.1.tar.bz2>BusyBox 1.4.1</a>.
|
||||
(<a href=http://busybox.net/downloads/fixes-1.4.1/>patches</a>)</p>
|
||||
|
||||
<p>This release includes only trivial fixes accumulated since 1.4.0.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>20 January 2007 -- BusyBox 1.4.0 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.4.0.tar.bz2>BusyBox 1.4.0</a>.
|
||||
(<a href=http://busybox.net/downloads/fixes-1.4.0/>patches</a>)</p>
|
||||
|
||||
<p>Since this is a x.x.0 release, it probably is a bit less "stable"
|
||||
than usual.</p>
|
||||
<p>Changes since previous release:
|
||||
<ul>
|
||||
<li>e2fsprogs are mostly removed from busybox. Some smaller parts remain,
|
||||
the rest of it sits disabled in e2fsprogs/old_e2fsprogs/*, because
|
||||
it's too bloated. Really. I'm afraid it's about the only way we can
|
||||
ever get e2fsprogs cleaned up.
|
||||
<li>less: many improvements. Now can display binary files
|
||||
(although I expect it to have trouble with displays where 8bit chars
|
||||
don't have 1-to-1 char/glyph relationship). Regexp search is not buggy
|
||||
anymore. Less does not read entire input up-front. Reads input
|
||||
as it appears (yay!). Works rather nice as man pager. I recommend it
|
||||
for general use now.
|
||||
<li>IPv6: generic support is in place, many networking applets are
|
||||
upgraded to be IPv6 capable. Probably some work remains, but it is
|
||||
already much better than what we had previously.
|
||||
<li>arp: new applet (thanks to Eric Spakman).
|
||||
<li>fakeidentd: non-forking standalone server part was taking ~90%
|
||||
of the applet. Factored it out (in fact, rewrote it).
|
||||
<li>syslogd: mostly rewritten.
|
||||
<li>decompress_unzip, gzip: sanitized a bit.
|
||||
<li>sed: better hadling of NULs
|
||||
<li>httpd: stop adding our own "Content-type:" to CGI output
|
||||
<li>chown: user.grp works again.
|
||||
<li>minor bugfixes to: passwd, date, tftp, start_stop_daemon, tar,
|
||||
ps, ifupdown, time, su, stty, awk, ping[6], sort,...
|
||||
</ul>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>20 January 2007 -- BusyBox 1.3.2 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.3.2.tar.bz2>BusyBox 1.3.2</a>.</p>
|
||||
|
||||
<p>This release includes only one trivial fix accumulated since 1.3.1
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>27 December 2006 -- BusyBox 1.3.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.3.1.tar.bz2>BusyBox 1.3.1</a>.
|
||||
(<a href=http://busybox.net/downloads/fixes-1.3.1/>patches</a>)</p>
|
||||
|
||||
<p>Closing 2006 with new release. It includes only trivial fixes accumulated since 1.3.0
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>14 December 2006 -- BusyBox 1.3.0 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.3.0.tar.bz2>BusyBox 1.3.0</a>.
|
||||
(<a href=http://busybox.net/downloads/fixes-1.3.0/>patches</a>)</p>
|
||||
|
||||
<p>This release has CONFIG_DESKTOP option which enables features
|
||||
needed for busybox usage on desktop machine. For example, find, chmod
|
||||
and chown get several less frequently used options, od is significantly
|
||||
bigger but matches GNU coreutils, etc. Intended to eventually make
|
||||
busybox a viable alternative for "standard" utilities for slightly
|
||||
adventurous desktop users.
|
||||
<p>Changes since previous release:
|
||||
<ul>
|
||||
<li>find: taking many more of standard options
|
||||
<li>ps: POSIX-compliant -o implemented
|
||||
<li>cp: added -s, -l
|
||||
<li>grep: added -r, fixed -h
|
||||
<li>watch: make it exec child like standard one does (was totally
|
||||
incompatible)
|
||||
<li>tar: fix limitations which were preventing bbox tar usage
|
||||
on big directories: long names and linknames, pax headers
|
||||
(Linux kernel tarballs have that). Fixed a number of obscure bugs.
|
||||
Raised max file limit (now 64Gb). Security fixes (/../ attacks).
|
||||
<li>httpd: added -i (inetd), -f (foreground), support for
|
||||
directory indexer CGI (example is included), bugfixes.
|
||||
<li>telnetd: fixed/improved IPv6 support, inetd+standalone support,
|
||||
other fixes. Useful IPv6 stuff factored out into libbb.
|
||||
<li>runit/*: new applets adapted from http://smarden.sunsite.dk/runit/
|
||||
(these are my personal favorite small-and-beautiful toys)
|
||||
<li>minor bugfixes to: login, dd, mount, umount, chmod, chown, ln, udhcp,
|
||||
fdisk, ifconfig, sort, tee, mkswap, wget, insmod.
|
||||
</ul>
|
||||
<p>Note that GnuPG key used to sign this release is different.
|
||||
1.2.2.1 is also signed post-factum now. Sorry for the mess.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>29 October 2006 -- BusyBox 1.2.2.1 (fix)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.2.2.1.tar.bz2>BusyBox 1.2.2.1</a>.</p>
|
||||
|
||||
<p>Added compile-time warning that static linking against glibc
|
||||
produces buggy executables.
|
||||
</li>
|
||||
|
||||
<li><b>24 October 2006 -- BusyBox 1.2.2 (stable)</b>
|
||||
<p>It's a bit overdue, but
|
||||
<a href=http://busybox.net/downloads/busybox-1.2.2.tar.bz2>here is
|
||||
BusyBox 1.2.2</a>.</p>
|
||||
|
||||
<p>This release has dozens of fixes backported from the ongoing development
|
||||
branch. There are a couple of bugfixes to sed, two fixes to documentation
|
||||
generation (BusyBox.html shouldn't have USE() macros in it anymore), fix
|
||||
umount to report the right errno on failure and to umount block devices by
|
||||
name with newer kernels, fix mount to handle symlinks properly, make mdev
|
||||
delete device nodes when called for hotplug remove, fix a segfault
|
||||
in traceroute, a minor portability fix to md5sum option parsing, a build
|
||||
fix for httpd with old gccs, an options parsing tweak to hdparm, make test
|
||||
fail gracefully when getgroups() returns -1, fix a race condition in
|
||||
modprobe when two instances run at once (hotplug does this), make "tar xf
|
||||
foo.tar dir/dir" extract all subdirectories, make our getty initialize the
|
||||
terminal more like mingetty, an selinux build fix, an endianness fix in
|
||||
ping6, fix for zcip defending addresses, clean up some global variables in
|
||||
gzip to save memory, fix sulogin -tNNN, a help text tweak, several warning
|
||||
fixes and build fixes, fixup dnsd a bit, and a partridge in a pear tree.</p>
|
||||
|
||||
<p>As <a href=http://lwn.net/Articles/202106/>Linux Weekly News noted</a>,
|
||||
this is my (Rob's) last release of BusyBox. The new maintainer is Denis
|
||||
Vlasenko, I'm off to do <a href=http://landley.net/code>other things</a>.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>29 September 2006 -- New license email address.</b>
|
||||
<p>The email address gpl@busybox.net is now the recommended way to contact
|
||||
the Software Freedom Law Center to report BusyBox license violations.</p>
|
||||
|
||||
<li><b>31 July 2006 -- BusyBox 1.2.1 (stable)</b>
|
||||
<p>Since nobody seems to have objected too loudly over the weekend, I
|
||||
might as well point you all at
|
||||
<a href="http://busybox.net/downloads/busybox-1.2.1.tar.bz2">Busybox
|
||||
1.2.1</a>, a bugfix-only release with no new features.</p>
|
||||
|
||||
<p>It has three shell fixes (two to lash: going "var=value" without
|
||||
saying "export" should now work, plus a missing null pointer check, and
|
||||
one to ash when redirecting output to a file that fills up.) Fix three
|
||||
embarassing thinkos in the new dmesg command. Two build tweaks
|
||||
(dependencies for the compressed usage messages and running make in the
|
||||
libbb subdirectory). One fix to tar so it can extract git-generated
|
||||
tarballs (rather than barfing on the pax extensions). And a partridge
|
||||
in a pear... Ahem.</p>
|
||||
|
||||
<p>But wait, there's more! A passwd changing fix so an empty
|
||||
gecos field doesn't trigger a false objection that the new passwd contains
|
||||
the gecos field. Make all our setuid() and setgid() calls check the return
|
||||
value in case somebody's using per-process resource limits that prevent
|
||||
a user from having too many processes (and thus prevent a process from
|
||||
switching away from root, in which case the process will now _die_ rather
|
||||
than continue with root privileges). A fix to adduser to make sure that
|
||||
/etc/group gets updated. And a fix to modprobe to look for modules.conf
|
||||
in the right place on 2.6 kernels.</p>
|
||||
|
||||
<li><b>30 June 2006 -- BusyBox 1.2.0</b>
|
||||
<p>The -devel branch has been stabilized and the result is
|
||||
<a href="http://busybox.net/downloads/busybox-1.2.0.tar.bz2">Busybox
|
||||
1.2.0</a>. Lots of stuff changed, I need to work up a decent changelog
|
||||
over the weekend.</p>
|
||||
|
||||
<p>I'm still experimenting with how long is best for the development
|
||||
cycle, and since we've got some largeish projects queued up I'm going to
|
||||
try a longer one. Expect 1.3.0 in December. (Expect 1.2.1 any time
|
||||
we fix enough bugs. :)</p>
|
||||
|
||||
<p>Update: Here are <a href="http://busybox.net/downloads/busybox-1.2.0.fixes.patch">the first few bug fixes</a> that will go into 1.2.1.</p>
|
||||
|
||||
<li><b>17 May 2006 -- BusyBox 1.1.3 (stable)</b>
|
||||
<p><a href="http://busybox.net/downloads/busybox-1.1.3.tar.bz2">BusyBox
|
||||
1.1.3</a> is another bugfix release. It makes passwd use salt, fixes a
|
||||
memory freeing bug in ls, fixes "build all sources at once" mode, makes
|
||||
mount -a not abort on the first failure, fixes msh so ctrl-c doesn't kill
|
||||
background processes, makes patch work with patch hunks that don't have a
|
||||
timestamp, make less's text search a lot more robust (the old one could
|
||||
segfault), and fixes readlink -f when built against uClibc.</p>
|
||||
|
||||
<p>Expect 1.2.0 sometime next month, which won't be a bugfix release.</p>
|
||||
|
||||
<li><b>10 April 2006 -- BusyBox 1.1.2 (stable)</b>
|
||||
<p>You can now download <a href="http://busybox.net/downloads/busybox-1.1.2.tar.bz2">BusyBox 1.1.2</a>, a bug fix release consisting of 11 patches
|
||||
backported from the development branch: Some build fixes, several fixes
|
||||
for mount and nfsmount, a fix for insmod on big endian systems, a fix for
|
||||
find -xdev, and a fix for comm. Check the file "changelog" in the tarball
|
||||
for more info.</p>
|
||||
|
||||
<p>The next new development release (1.2.0) is slated for June. A 1.1.3
|
||||
will be released before then if more bug fixes crop up. (The new plan is
|
||||
to have a 1.x.0 new development release every 3 months, with 1.x.y stable
|
||||
bugfix only releases based on that as appropriate.)</p>
|
||||
|
||||
<li><b>27 March 2006 -- Software Freedom Law Center representing BusyBox and uClibc</b>
|
||||
<p>One issue Erik Andersen wanted to resolve when handing off BusyBox
|
||||
maintainership to Rob Landley was license enforcement. BusyBox and
|
||||
uClibc's existing license enforcement efforts (pro-bono representation
|
||||
by Erik's father's law firm, and the
|
||||
<a href="http://www.busybox.net/shame.html">Hall of Shame</a>), haven't
|
||||
scaled to match the popularity of the projects. So we put our heads
|
||||
together and did the obvious thing: ask Pamela Jones of
|
||||
<a href="http://www.groklaw.net">Groklaw</a> for suggestions. She
|
||||
referred us to the fine folks at softwarefreedom.org.</p>
|
||||
|
||||
<p>As a result, we're pleased to announce that the
|
||||
<a href="http://www.softwarefreedom.org">Software Freedom Law Center</a>
|
||||
has agreed to represent BusyBox and uClibc. We join a number of other
|
||||
free and open source software projects (such as
|
||||
<a href="http://lwn.net/Articles/141806/">X.org</a>,
|
||||
<a href="http://lwn.net/Articles/135413/">Wine</a>, and
|
||||
<a href="http://plone.org/foundation/newsitems/software-freedom-law-center-support/">Plone</a>
|
||||
in being represented by a fairly cool bunch of lawyers, which is not a
|
||||
phrase you get to use every day.</p>
|
||||
|
||||
<li><b>22 March 2006 -- BusyBox 1.1.1</b>
|
||||
<p>The new maintainer is Rob Landley, and the new release is <a href="http://busybox.net/downloads/busybox-1.1.1.tar.bz2">BusyBox 1.1.1</a>. Expect a "what's new" document in a few days. (Also, Erik and I have have another announcement pending...)</p>
|
||||
<p>Update: Rather than put out an endless stream of 1.1.1.x releases,
|
||||
the various small fixes have been collected together into a
|
||||
<a href="http://busybox.net/downloads/busybox-1.1.1.fixes.patch">patch</a>,
|
||||
and new fixes will be appended to that as needed. Expect 1.1.2 around
|
||||
June.</p>
|
||||
</li>
|
||||
<li><b>11 January 2006 -- 1.1.0 is out</b>
|
||||
<p>The new stable release is
|
||||
<a href="http://www.busybox.net/downloads/busybox-1.1.0.tar.bz2">BusyBox
|
||||
1.1.0</a>. It has a number of improvements, including several new applets.
|
||||
(It also has <a href="http://www.busybox.net/lists/busybox/2006-January/017733.html">a few rough spots</a>,
|
||||
but we're trying out a "release early, release often" strategy to see how
|
||||
that works. Expect 1.1.1 sometime in March.)</p>
|
||||
|
||||
<li><b>Old News</b><p>
|
||||
<a href="/oldnews.html">Click here to read older news</a>
|
||||
|
||||
@@ -2,6 +2,805 @@
|
||||
|
||||
|
||||
<ul>
|
||||
<li><b>12 February 2008 -- BusyBox 1.9.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.9.1.tar.bz2>BusyBox 1.9.1</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_9_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.9.1/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to fsck,
|
||||
iproute, mdev, mkswap, msh, nameif, stty, test, zcip.</p>
|
||||
<p>hush has `command` expansion re-enabled for NOMMU, although it is
|
||||
inherently unsafe (by virtue of NOMMU's use of vfork instead of fork).
|
||||
The plan is to make this less likely to bite people in future versions.</p>
|
||||
</li>
|
||||
|
||||
<li><b>24 December 2007 -- BusyBox 1.9.0 (unstable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.9.0.tar.bz2>BusyBox 1.9.0</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_9_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.9.0/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>Sizes of busybox-1.8.2 and busybox-1.9.0 (with almost full config, static uclibc build):<pre>
|
||||
text data bss dec hex filename
|
||||
792796 978 9724 803498 c42aa busybox-1.8.2
|
||||
783803 683 7508 791994 c15ba busybox-1.9.0
|
||||
</pre>
|
||||
<p>Top 10 stack users:<pre>
|
||||
busybox-1.8.2: busybox-1.9.0:
|
||||
input_tab 10428 echo_dg 4116
|
||||
umount_main 8252 bb_full_fd_action 4112
|
||||
rtnl_talk 8240 discard_dg 4096
|
||||
xrtnl_dump_filter 8240 echo_stream 4096
|
||||
sendMTFValues 5316 discard_stream 4096
|
||||
mainSort 4700 find_list_entry2 4096
|
||||
mkfs_minix_main 4288 readlink_main 4096
|
||||
grave 4260 ipaddr_list_or_flush 3900
|
||||
unix_do_one 4156 iproute_list_or_flush 3680
|
||||
parse_prompt 4132 insmod_main 3152
|
||||
</pre>
|
||||
|
||||
<p>lash is deleted from this release. hush can be configured down to almost
|
||||
the same size, but it is significantly less buggy. It even works
|
||||
on NOMMU machines (interactive mode and backticks are not working on NOMMU,
|
||||
though). "lash" applet is still available, but it runs hush.
|
||||
|
||||
<p>init has some changes in this release, please report if it causes
|
||||
problems for you.
|
||||
|
||||
<p>Changes since previous release:
|
||||
<ul>
|
||||
<li>Build system improvements
|
||||
<li>Testsuite additions
|
||||
<li>Stack size reductions, code size reductions, data/bss reductions
|
||||
<li>An option to prefer IPv4 address if host has both
|
||||
<li>New applets: hd, sestatus
|
||||
<li>Removed applets: lash
|
||||
<li>hush: fixed a few bugs, wired up echo and test to be builtins
|
||||
<li>init: simplify forking of children
|
||||
<li>getty: special handling of '#' and '@' is removed
|
||||
<li>[su]login: sanitize environment if called by non-root
|
||||
<li>udhcpc: support "bad" servers which send oversized packets
|
||||
(Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>)
|
||||
<li>udhcpc: -O option allows to specify which options to ask for
|
||||
(Stefan Hellermann <stefan at the2masters.de>)
|
||||
<li>udhcpc: optionally check whether given IP is really free (by ARP ping)
|
||||
(Jonas Danielsson <jonas.danielsson at axis.com>)
|
||||
<li>vi: now handles files with unlimited line length
|
||||
<li>vi: speedup for huge line lengths
|
||||
<li>vi: Del key works
|
||||
<li>sed: support GNUism '\t'
|
||||
<li>cp/mv/install: optionally use bigger buffer for bulk copying
|
||||
<li>line editing: don't eat stack like crazy
|
||||
<li>passwd: follows symlinked /etc/passwd
|
||||
<li>renice: accepts priority with +N too
|
||||
<li>netstat: wide output mode
|
||||
<li>nameif: extended matching (Nico Erfurth <masta at perlgolf.de>)
|
||||
<li>test: become NOFORK applet
|
||||
<li>find: -iname (Alexander Griesser <alexander.griesser at lkh-vil.or.at>)
|
||||
<li>df: -i option (show inode info) (Pascal Bellard <pascal.bellard at ads-lu.com>)
|
||||
<li>hexdump: -R option (Pascal Bellard <pascal.bellard at ads-lu.com>)
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<li><b>23 November 2007 -- BusyBox 1.8.2 (stable), BusyBox 1.7.4 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.8.2.tar.bz2>BusyBox 1.8.2</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.8.2/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.7.4.tar.bz2>BusyBox 1.7.4</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.7.4/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>These are bugfix-only releases.
|
||||
1.8.2 contains fixes for inetd, lash, tar, tr, and build system.
|
||||
1.7.4 contains a fix for inetd.</p>
|
||||
</li>
|
||||
|
||||
<li><b>9 November 2007 -- BusyBox 1.8.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.8.1.tar.bz2>BusyBox 1.8.1</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.8.1/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to login (PAM), modprobe, syslogd, telnetd, unzip.</p>
|
||||
</li>
|
||||
|
||||
<li><b>4 November 2007 -- BusyBox 1.8.0 (unstable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.8.0.tar.bz2>BusyBox 1.8.0</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_8_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.8.0/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>Note: this is probably the very last release with lash. It will be dropped. Please migrate to hush.
|
||||
|
||||
<p>Applets which had many changes since 1.7.x:
|
||||
<p>httpd:
|
||||
<ul>
|
||||
<li>does not clear environment, CGIs will see all environment variables which were set for httpd
|
||||
<li>fix bug where we were trying to read more POSTDATA than content-length
|
||||
<li>fix trivial bug (spotted by Alex Landau)
|
||||
<li>optional support for partial downloads
|
||||
<li>simplified CGI i/o loop (now it looks good to me)
|
||||
<li>small auth and IPv6 fixes (Kim B. Heino <Kim.Heino at bluegiga.com>)
|
||||
<li>support for proxying connection to other http server (by Alex Landau <landau_alex at yahoo.com>)
|
||||
</ul>
|
||||
|
||||
<p>top:
|
||||
<ul>
|
||||
<li>TOPMEM feature - 's(how sizes)' command
|
||||
<li>don't wait before final bailout (try top -b -n1)
|
||||
<li>fix for command line wrapping
|
||||
</ul>
|
||||
|
||||
<p>Build system improvements: libbusybox mode restored (it was lost in transition to new makefiles).
|
||||
|
||||
<p>Code and data size in comparison with 1.7.3:<pre>
|
||||
Equivalent .config, i386 uclibc static builds:
|
||||
text data bss dec hex filename
|
||||
768123 1055 10768 779946 be6aa busybox-1.7.3/busybox
|
||||
759693 974 9420 770087 bc027 busybox-1.8.0/busybox</pre>
|
||||
|
||||
<p>New applets:
|
||||
<ul>
|
||||
<li>microcom: new applet by Vladimir Dronnikov <dronnikov at gmail.ru>
|
||||
<li>kbd_mode: new applet by Loic Grenie <loic.grenie at gmail.com>
|
||||
<li>bzip2: port bzip2 1.0.4 to busybox, 9 kb of code
|
||||
<li>pgrep, pkill: new applets by Loic Grenie <loic.grenie at gmail.com>
|
||||
<li>setsebool: new applet (Yuichi Nakamura <ynakam at hitachisoft.jp>)
|
||||
</ul>
|
||||
|
||||
<p>Other changes since previous release (abridged):
|
||||
<ul>
|
||||
<li>cp: -r and -R imply -d (coreutils compat)
|
||||
<li>cp: detect and prevent infinite recursion
|
||||
<li>cp: make it a bit closer to POSIX, but still refuse to open and overwrite symbolic link
|
||||
<li>hdparm: reduce possibility of numeric overflow in -T
|
||||
<li>hdparm: simplify timing measurement
|
||||
<li>wget: -O FILE is allowed to overwrite existing file (compat)
|
||||
<li>wget: allow dots in header field names
|
||||
<li>telnetd: add -K option to close sessions as soon as child exits
|
||||
<li>telnetd: don't SIGKILL child when closing the session, kernel will send SIGHUP for us
|
||||
<li>ed: large cleanup, add line editing
|
||||
<li>hush: feeble attempt at making it more NOMMU-friendly
|
||||
<li>hush: fix glob()
|
||||
<li>hush: stop doing manual accounting of open fd's, kernel can do it for us
|
||||
<li>adduser: implement -S and fix uid selection
|
||||
<li>ash: fix prompt expansion (Natanael Copa <natanael.copa at gmail.com>)
|
||||
<li>ash: revert "cat | jobs" fix, it causes more problems than good
|
||||
<li>find: fix -xdev behavior in the presence of two or more nested mount points
|
||||
<li>grep: fix grep -F -e str1 -e str2 (was matching str2 only)
|
||||
<li>grep: optimization: stop on first -e match
|
||||
<li>gunzip: support concatenated gz files
|
||||
<li>inetd: fix bug 1562 "inetd does not set argv[0] properly" (fix by Ilya Panfilov)
|
||||
<li>install: 'support' (by ignoring) -v and -b
|
||||
<li>install: fix bug in "install -c file dir" (tried to copy dir into dir too)
|
||||
<li>ip: tunnel parameter parsing fix by Jean Wolter <jw5 at os.inf.tu-dresden.de>
|
||||
<li>isrv: use monotonic_sec
|
||||
<li>less: make 'f' key page forward
|
||||
<li>libiproute: add missing break statements
|
||||
<li>load_policy: update (Yuichi Nakamura <ynakam at hitachisoft.jp>)
|
||||
<li>logger: fix a problem of losing all argv except first
|
||||
<li>login: do reject wrong passwords with PAM auth
|
||||
<li>losetup: support -f (Loic Grenie <loic.grenie at gmail.com>)
|
||||
<li>fdisk: make fdisk compile on libc without llseek64
|
||||
<li>libbb: by popular request allow PATH to be customized at build time
|
||||
<li>mkswap: selinux support by KaiGai Kohei <kaigai at ak.jp.nec.com>
|
||||
<li>mount: allow (and ignore) -i
|
||||
<li>mount: ignore NFS bg option on NOMMU machines
|
||||
<li>mount: mount helpers support (by Vladimir Dronnikov <dronnikov at gmail.ru>)
|
||||
<li>passwd: handle Ctrl-C, restore termios on Ctrl-C
|
||||
<li>passwd: SELinux support by KaiGai Kohei <kaigai at ak.jp.nec.com>
|
||||
<li>ping: make -I ethN work too (-I addr already worked)
|
||||
<li>ps: fix RSS parsing (rss field in /proc/PID/stat is in pages, not bytes)
|
||||
<li>read_line_input: fix it to not do any fancy editing if echoing is disabled
|
||||
<li>run_parts: make it sort executables by name (required by API)
|
||||
<li>runsv: do not use clock_gettime if !MONOTONIC_CLOCK
|
||||
<li>runsvdir: fix "linear wait time" bug
|
||||
<li>sulogin: remove alarm handling, it is redundant there
|
||||
<li>svlogd: compat: svlogd -tt should timestamp stderr too
|
||||
<li>syslogd: bail out if you see null read from Unix socket
|
||||
<li>syslogd: do not need to poll(), we can just block in read()
|
||||
<li>tail: work correctly on /proc files (Kazuo TAKADA <kztakada at sm.sony.co.jp>)
|
||||
<li>tar + gzip/bzip2/etc: support NOMMU machines (by Alex Landau <landau_alex at yahoo.com>)
|
||||
<li>tar: strip leading '/' BEFORE memorizing hardlink's name
|
||||
<li>tftp: fix infinite retry bug
|
||||
<li>umount: support (by ignoring) -i; style fixes
|
||||
<li>unzip: fix endianness bugs
|
||||
<li>vi: don't wait 50 ms before reading ESC sequences
|
||||
<li>watchdog: allow millisecond spec (-t 250ms)
|
||||
<li>zcip: fix unaligned trap on ARM
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
</li>
|
||||
|
||||
<li><b>4 November 2007 -- BusyBox 1.7.3 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.7.3.tar.bz2>BusyBox 1.7.3</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.7.3/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to ash, httpd, inetd, iptun, logger, login, tail.</p>
|
||||
</li>
|
||||
|
||||
<li><b>30 September 2007 -- BusyBox 1.7.2 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.7.2.tar.bz2>BusyBox 1.7.2</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.7.2/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to install, find, login, httpd, runsvdir, chcon, setfiles, fdisk and line editing.</p>
|
||||
</li>
|
||||
|
||||
<li><b>16 September 2007 -- BusyBox 1.7.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.7.1.tar.bz2>BusyBox 1.7.1</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.7.1/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to cp, runsv, tar, busybox --install and build system.</p>
|
||||
</li>
|
||||
|
||||
<li><b>24 August 2007 -- BusyBox 1.7.0 (unstable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.7.0.tar.bz2>BusyBox 1.7.0</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_7_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.7.0/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>Applets which had many changes since 1.6.x:
|
||||
<p>httpd:
|
||||
<ul>
|
||||
<li>works in standalone mode on NOMMU machines now (partly by Alex Landau <landau_alex at yahoo.com>)
|
||||
<li>indexer example is rewritten in C
|
||||
<li>optional support for error pages (by Pierre Metras <genepi at sympatico.ca>)
|
||||
<li>stop reading headers using 1-byte reads
|
||||
<li>new option -v[v]: prints client addresses, HTTP codes returned, URLs
|
||||
<li>extended -p PORT to -p [IP[v6]:]PORT
|
||||
<li>sendfile support (by Pierre Metras <genepi at sympatico.ca>)
|
||||
<li>add support for Status: CGI header
|
||||
<li>fix CGI handling bug (we were closing wrong fd)
|
||||
<li>CGI I/O loop still doesn't look 100% ok to me...
|
||||
</ul>
|
||||
|
||||
<p>udhcp[cd]:
|
||||
<ul>
|
||||
<li>add -f "foreground" and -S "syslog" options
|
||||
<li>fixed "ifupdown + udhcpc_without_pidfile_creation" bug
|
||||
<li>new config option "Rewrite the lease file at every new acknowledge" (Mats Erik Andersson <mats at blue2net.com> (Blue2Net AB))
|
||||
<li>consistently treat server_config.start/end IPs as host-order
|
||||
<li>fix IP parsing for 64bit machines
|
||||
<li>fix unsafe hton macro usage in read_opt()
|
||||
<li>do not chdir to / when daemonizing
|
||||
</ul>
|
||||
|
||||
<p>top, ps, killall, pidof:
|
||||
<ul>
|
||||
<li>simpler loadavg processing
|
||||
<li>truncate usernames to 8 chars
|
||||
<li>fix non-CONFIG_DESKTOP ps -ww (by rockeychu)
|
||||
<li>improve /proc/PID/cmdinfo reading code
|
||||
<li>use cmdline, not comm field (fixes problems with re-execed applets showing as processes with name "exe", and not being found by pidof/killall by applet name)
|
||||
<li>reduce CPU usage in decimal conversion (optional) (corresponding speedup on kernel side is accepted in mainline Linux kernel, yay!)
|
||||
<li>make percentile (0.1%) calculations configurable
|
||||
<li>add config option and code for global CPU% display
|
||||
<li>reorder columns, so that [P]PIDs are together and VSZ/%MEM are together - makes more sense
|
||||
</ul>
|
||||
|
||||
<p>Build system improvements: doesn't link against libraries we don't need,
|
||||
generates verbose link output and map file, allows for custom link
|
||||
scripts (useful for removing extra padding, among other things).
|
||||
|
||||
<p>Code and data size in comparison with 1.6.1:<pre>
|
||||
Equivalent .config, i386 glibc dynamic builds:
|
||||
text data bss dec hex filename
|
||||
672671 2768 16808 692247 a9017 busybox-1.6.1/busybox
|
||||
662948 2660 13528 679136 a5ce0 busybox-1.7.0/busybox
|
||||
662783 2631 13416 678830 a5bae busybox-1.7.0/busybox.customld
|
||||
|
||||
Same .config built against static uclibc:
|
||||
765021 1059 11020 777100 bdb8c busybox-1.7.0/busybox_uc</pre>
|
||||
|
||||
<p>Code/data shrink done in applets: crond, hdparm, dd, cal, od, nc, expr, uuencode,
|
||||
test, slattach, diff, ping, tr, syslogd, hwclock, zcip, find, pidof, ash, uudecode,
|
||||
runit/*, in libbb.
|
||||
|
||||
<p>New applets:
|
||||
<ul>
|
||||
<li>pscan, expand, unexpand (from Tito <farmatito at tiscali.it>)
|
||||
<li>setfiles, restorecon (by Yuichi Nakamura <ynakam at hitachisoft.jp>)
|
||||
<li>chpasswd (by Alexander Shishkin <virtuoso at slind.org>)
|
||||
<li>slattach, ttysize
|
||||
</ul>
|
||||
|
||||
<p>Unfortunately, not much work is done on shells. This was mostly stalled
|
||||
by lack of time (read: laziness) on my part to learn how to adapt existing
|
||||
qemu-runnable image for a NOMMU architechture (available on qemu website)
|
||||
for local testing of cross-compiled busybox on my machine.
|
||||
|
||||
<p>Other changes since previous release (abridged):
|
||||
<ul>
|
||||
<li>addgroup: disallow addgroup -g num user group; make -g 0 work (Tito <farmatito at tiscali.it>)
|
||||
<li>adduser: close /etc/{passwd,shadow} before calling passwd etc. Spotted by Natanael Copa <natanael.copa at gmail.com>
|
||||
<li>arping: -i should be -I, fixed
|
||||
<li>ash: make "jobs | cat" work like in bash (was giving empty output)
|
||||
<li>ash: recognize -l as --login equivalent; do not recognize +-login
|
||||
<li>ash: fix buglet in DEBUG code (Nguyen Thai Ngoc Duy <pclouds at gmail.com>)
|
||||
<li>ash: fix SEGV if type has zero parameters
|
||||
<li>awk: fix -F 'regex' bug (miscounted fields if last field is empty)
|
||||
<li>catv: catv without arguments was trying to use environ as argv (Alex Landau <landau_alex at yahoo.com>)
|
||||
<li>catv: don't die on open error (emit warning)
|
||||
<li>chown/chgrp: completely match coreutils 6.8 wrt symlink handling
|
||||
<li>correct_password: do not print "no shadow passwd..." message
|
||||
<li>crond: don't start sendmail with absolute path, don't report obsolete version (report true bbox version)
|
||||
<li>dd: fix bug where we assume count=INT_MAX when count is unspecified
|
||||
<li>devfsd: sanitization by Tito <farmatito at tiscali.it>
|
||||
<li>echo: fix non-fancy echo
|
||||
<li>fdisk: make it work with big disks (read: typical today's disks) even if CONFIG_LFS is unset
|
||||
<li>find: -context support for SELinux (KaiGai Kohei <kaigai at kaigai.gr.jp>)
|
||||
<li>find: add conditional support for -maxdepth and -regex, make -size match GNU find
|
||||
<li>find: fix build failure on certain configs (found by Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn at axis.com>)
|
||||
<li>fsck_minix: make it print bb version, not it's own (outdated/irrelevant) one
|
||||
<li>grep: implement -m MAX_MATCHES, fix buglets with context printing
|
||||
<li>grep: fix selection done by FEATURE_GREP_EGREP_ALIAS (Maxime Bizon <mbizon at freebox.fr> (Freebox))
|
||||
<li>hush: add missing dependencies (Maxime Bizon <mbizon at freebox.fr> (Freebox))
|
||||
<li>hush: fix read builtin to not read ahead past EOL and to not use insane amounts of stack
|
||||
<li>ifconfig: make it work with ifaces with interface no. > 255
|
||||
<li>ifup/ifdown: make location of ifstate configurable
|
||||
<li>ifupdown: make netmask parsing smaller and more strict (was accepting 255.0.255.0, 255.1234.0.0 etc...)
|
||||
<li>install: fix -s (strip) option, fix install a b /a/link/to/dir
|
||||
<li>libbb: consolidate ARRAY_SIZE macro (Walter Harms <wharms at bfs.de>)
|
||||
<li>libbb: make /etc/network parsing configurable. -200 bytes when off
|
||||
<li>libbb: nuke BB_GETOPT_ERROR, always die if there are mutually exclusive options
|
||||
<li>libbb: xioctl and friends by Tito <farmatito at tiscali.it>
|
||||
<li>login: optional support for PAM
|
||||
<li>login: make /etc/nologin support configurable (-240 bytes)
|
||||
<li>login: ask passwords even for wrong usernames
|
||||
<li>md5_sha1_sum: fix mishandling when run as /bin/md5sum
|
||||
<li>mdev: add support for firmware loading
|
||||
<li>mdev: work even when CONFIG_SYSFS_DEPRECATED in kernel is off
|
||||
<li>modprobe: add scanning of /lib/modules/`uname -r`/modules.symbols (by Yann E. MORIN <yann.morin.1998 at anciens.enib.fr>)
|
||||
<li>more: fixes by Tristan Schmelcher <tpkschme at engmail.uwaterloo.ca>
|
||||
<li>nc: make connecting to IPv4 from IPv6-enabled hosts easier (was requiring -s local_addr)
|
||||
<li>passwd: fix bug "updating shadow even if user's record is in passwd"
|
||||
<li>patch: fix -p -1 handling
|
||||
<li>patch: fix bad line ending handling (Nguyen Thai Ngoc Duy <pclouds at gmail.com>)
|
||||
<li>ping: display roundtrip times with 1/1000th of ms, not 1/10 ms precision.
|
||||
<li>ping: fix incorrect handling of -I (Iouri Kharon <bc-info at styx.cabel.net>)
|
||||
<li>ping: fix non-fancy ping6
|
||||
<li>printenv: fix "printenv VAR1 VAR2" bug (spotted by Kalyanatejaswi Balabhadrapatruni <kalyanatejaswi at yahoo.co.in>)
|
||||
<li>ps: fix -Z (by Yuichi Nakamura <ynakam at hitachisoft.jp>)
|
||||
<li>rpm: add optional support for bz2 data. +50 bytes of code
|
||||
<li>rpm: fix bogus "package is not installed" case
|
||||
<li>sed: fix 'q' command handling (by Nguyen Thai Ngoc Duy <pclouds at gmail.com>)
|
||||
<li>start_stop_daemon: NOMMU fixes by Alex Landau <landau_alex at yahoo.com>
|
||||
<li>stat: fix option -Z SEGV
|
||||
<li>strings: strings a b was processing a twice, fix that
|
||||
<li>svlogd: fix timestamping, do not warn if config is missing
|
||||
<li>syslogd, logread: get rid of head pointer, fix logread bug in the process
|
||||
<li>syslogd: do not convert tabs to ^I, set syslog IPC buffer to mode 0644
|
||||
<li>tar: improve OLDGNU compat, make old SUN compat configurable
|
||||
<li>test: fix testing primary expressions like '"-u" = "-u"'
|
||||
<li>uudecode: fix to base64 decode by Jorgen Cederlof <jcz at google.com>
|
||||
<li>vi: multiple fixes by Natanael Copa <natanael.copa at gmail.com>
|
||||
<li>wget: fix bug in base64 encoding (bug 1404). +10 bytes
|
||||
<li>wget: lift 256 chars limitation on terminal width
|
||||
<li>wget, zcip: use monotonic_sec instead of gettimeofday
|
||||
</ul>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>30 June 2007 -- BusyBox 1.6.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.6.1.tar.bz2>BusyBox 1.6.1</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_6_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.6.1/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to echo, hush, and wget.</p>
|
||||
</li>
|
||||
|
||||
<li><b>1 June 2007 -- BusyBox 1.6.0 (unstable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.6.0.tar.bz2>BusyBox 1.6.0</a>.
|
||||
(<a href=http://busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_6_stable/>svn</a>,
|
||||
<a href=http://busybox.net/downloads/fixes-1.6.0/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>Since this is a x.x.0 release, it probably does not deserve "stable"
|
||||
label. Please help making 1.6.1 stable by testing 1.6.0.</p>
|
||||
<p>Note that hush shell had many changes and (hopefully) is much improved now,
|
||||
but there is a possibility that it regressed in some obscure cases. Please
|
||||
report any such cases.</p>
|
||||
<p>lash users please note: lash is going to be deprecated in busybox 1.7.0
|
||||
and removed in the more distant future. Please migrate to hush.</p>
|
||||
<p><a href=http://busybox.net/~vda/mem_usage-1.6.0.txt>Memory usage has decreased, but we can do better still</a></p>
|
||||
<p>Other changes since previous release:
|
||||
<ul>
|
||||
<li>NOFORK: audit small applets and mark some of them as NOFORK. Put big scary warnings in relevant places
|
||||
<li>NOFORK: factor out NOFORK/NOEXEC code from find. Use NOFORK/NOEXEC in find and xargs
|
||||
<li>NOFORK: remove potential xmalloc from NOFORK path in bb_full_fd_action
|
||||
<li>NOMMU: random fixes; compressed --help now works for NOMMU
|
||||
<li>SELinux: load_policy applet
|
||||
<li>[u]mount: extend -t option (Roy Marples <uberlord at gentoo.org>)
|
||||
<li>addgroup: clean up, fix adding users to existing groups and make it optional (Tito)
|
||||
<li>adduser: don't bomb out if shadow password file doesn't exist (from Tito <farmatito at tiscali.it>)
|
||||
<li>applet.c: do not even try to read config if run by real root; fix suid config handling
|
||||
<li>ash: fix infinite loop on exit if tty is not there anymore
|
||||
<li>ash: fix kill -l (by Mats Erik Andersson <mats.andersson64 at comhem.se>)
|
||||
<li>ash: implement type -p, costs less than 10 bytes (patch by Mats Erik Andersson <mats.andersson64 at comhem.se>)
|
||||
<li>awk: don't segfault on printf(%*s). Closes bug 1337
|
||||
<li>awk: guard against empty environment
|
||||
<li>awk: some 'lineno' vars were shorts, made them ints (code got smaller)
|
||||
<li>cat: stop using stdio.h opens
|
||||
<li>config system: clarify PREFER_APPLETS/SH_STANDALONE effects in help text
|
||||
<li>cryptpw: new applet (by Thomas Lundquist <lists at zelow.no>)
|
||||
<li>cttyhack: new applet
|
||||
<li>dd: NOEXEC fix; fix skip= parse error (spotted by Dirk Clemens <develop at cle-mens.de>)
|
||||
<li>deluser: add optional support for removing users from groups (by Tito <farmatito at tiscali.it>)
|
||||
<li>diff: fix SEGV (NULL deref) in diff -N
|
||||
<li>diff: fix segfault on empty dirs (Peter Korsgaard <peter.korsgaard at barco.com>)
|
||||
<li>dnsd: fix several buglets, make smaller; openlog(), so that applet's name is logged
|
||||
<li>dpkg: run_package_script() returns 0 if all ok and non-zero if failure. The result code was checked incorrectly in two places. (from Kim B. Heino <Kim.Heino at bluegiga.com>)
|
||||
<li>dpkg: use bitfields which are a bit closer to typical short/char. Code size -800 bytes
|
||||
<li>dumpleases: getopt32()-ization (from Mats Erik Andersson <mats.andersson64 at comhem.se>)
|
||||
<li>e2fsprogs: stop using statics in chattr. Minor code shrinkage (-130 bytes)
|
||||
<li>ether-wake: close bug 1317. Reorder fuctions to avoid forward refs while at it
|
||||
<li>ether-wake: save a few more bytes of code
|
||||
<li>find: -group, -depth (Natanael Copa <natanael.copa at gmail.com>)
|
||||
<li>find: add support for -delete, -path (by Natanael Copa)
|
||||
<li>find: fix -prune. Add big comment about it
|
||||
<li>find: improve usage text (Natanael Copa <natanael.copa at gmail.com>)
|
||||
<li>find: missed 'static' on const data; size and prune were mixed up; use index_in_str_array
|
||||
<li>find: un-DESKTOPize (Kai Schwenzfeier <niteblade at gmx.net>)
|
||||
<li>find_root_device: teach to deal with /dev/ subdirs (by Kirill K. Smirnov <lich at math.spbu.ru>)
|
||||
<li>find_root_device: use lstat - don't follow links
|
||||
<li>getopt32: fix llist_t options ordering. llist_rev is now unused
|
||||
<li>getopt: use getopt32 for option parsing - inspired by patch by Mats Erik Andersson <mats.andersson64 at comhem.se>
|
||||
<li>hdparm: fix multisector mode setting (from Toni Mirabete <amirabete at catix.cat>)
|
||||
<li>hdparm: make -T -t code smaller (-194 bytes), and output prettier
|
||||
<li>ifupdown: make it possible to use DHCP clients different from udhcp
|
||||
<li>ifupdown: reread state file before rewriting it. Fixes "ifup started another ifup" state corruption bug. Patch by Natanael Copa <natanael.copa at gmail.com>
|
||||
<li>ifupdown: small optimization (avoid doing useless work if we are not going to update state file)
|
||||
<li>ip: fix compilation if FEATURE_TR_CLASSES is off
|
||||
<li>ip: mv ip*_main into ip.c; use a dispatcher to save on needless duplication. Saves a minor 12b
|
||||
<li>ip: rewrite the ip applet to be less bloaty. Convert to index_in_(sub)str_array()
|
||||
<li>ip: set the scope properly. Thanks to Jean Wolter
|
||||
<li>iplink: shrink iplink; sanitize libiproute a bit (-916 bytes)
|
||||
<li>iproute: shrink a bit (-200 bytes)
|
||||
<li>kill: know much more signals; make code smaller; use common code for kill applet and ash kill builtin
|
||||
<li>klogd: remove dependency on syslogd
|
||||
<li>lash: "forking" applets are actually can be treated the same way as "non-forked". Also save a bit of space on trailing NULL array elements.
|
||||
<li>lash: fix kill buglet (didn't properly recognize ESRCH)
|
||||
<li>lash: make -c work; crush buffer overrun and free of non-malloced ptr (from Mats Erik Andersson <mats.andersson64 at comhem.se>)
|
||||
<li>lash: recognize and use NOFORK applets
|
||||
<li>less: fix case when regex search finds nothing; fix very obscure memory corruption bug; fix less <HUGEFILE + [End] busy loop
|
||||
<li>libbb: add xsendto, xunlink, xpipe
|
||||
<li>libbb: fix segfault in reset_ino_dev_hashtable() when *hashtable was NULL
|
||||
<li>libbb: make pidfile writing configurable
|
||||
<li>libbb: make xsocket die with address family printed (if VERBOSE_RESOLUTION_ERRORS=y)
|
||||
<li>libbb: rework NOMMU helper API so that it makes more sense and easier to use
|
||||
<li>libiproute: audit callgraph, shortcut error paths into die() functions
|
||||
<li>lineedit: do not try to open NULL history file
|
||||
<li>lineedit: nuke two unused variables and code which sets them
|
||||
<li>login: remove setpgrp call (makes it work from shell prompt again); sanitize stdio descriptors (we are suid, need to be careful!)
|
||||
<li>login: shrink login and set_environment by ~100 bytes
|
||||
<li>mount: fix incorrect usage of strtok (inadvertently used NULL sometimes)
|
||||
<li>mount: fix mounting of symlinks (mount from util-linux allows that)
|
||||
<li>msh: data/bss reduction (more than 9k of it); fix "underscore bug" (a_b=1111 didn't work); fix obscure case with backticks and closed fd 1
|
||||
<li>nc: port nc 1.10 to busybox
|
||||
<li>netstat: fix for bogus state value for raw sockets
|
||||
<li>netstat: introduce -W: wide, ipv6-friendly output; shrink by ~500 bytes
|
||||
<li>nmeter: should die if stdout doesn't like him anymore
|
||||
<li>patch: do not try to delete same file twice
|
||||
<li>ping: fix wrong sign extension of packet id (bug 1373)
|
||||
<li>ps: add -o tty and -o rss support; make a bit smaller; work around libc bug: printf("%.*s\n", MAX_INT, buffer)
|
||||
<li>run_parts: rewrite
|
||||
<li>run_parts: do not check path portion of a name for "bad chars". Needed for ifupdown. Patch by Gabriel L. Somlo <somlo at cmu.edu>
|
||||
<li>sed: fix escaped newlines in -f
|
||||
<li>split: new applet
|
||||
<li>stat: remove superfluous bss user (flags) and manually unswitch some areas
|
||||
<li>stty: fix option parsing bug (spotted by Sascha Hauer <s.hauer at pengutronix.de>)
|
||||
<li>svlogd: fix 'SEGV on uninitialized data' and make it honor TERM
|
||||
<li>tail: fix SEGV on "tail -N"
|
||||
<li>ipsvd: tcpsvd,udpsvd are new applets, GPL-ed 'clones' of Dan Bernstein's tcpserver. Author: Gerrit Pape <pape at smarden.org>, http://smarden.sunsite.dk/ipsvd/
|
||||
<li>test: close bug 1371; plug a memory leak; code size reduction
|
||||
<li>tftp: code diet, and I think retransmits were broken
|
||||
<li>tr: fix bug where we did not reject invalid classes like '[[:alpha'. debloat while at it
|
||||
<li>udhcp: MAC_BCAST_ADDR and blank_chaddr are in fact constant, move to rodata; use pipe instead of socketpair
|
||||
<li>udhcp[cd]: stop using atexit magic fir pidfile removal; stop deleting our own pidfile if we daemonize
|
||||
<li>xargs: shrink code, ~80 bytes; simplify word list management
|
||||
<li>zcip: make it work on NOMMU (+ improve NOMMU support machinery)
|
||||
</ul>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>20 May 2007 -- BusyBox 1.5.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.5.1.tar.bz2>BusyBox 1.5.1</a>.
|
||||
(<a href=http://busybox.net/downloads/fixes-1.5.1/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>This is a bugfix-only release, with fixes to hdparm, hush, ifupdown, ps
|
||||
and sed.</p>
|
||||
</li>
|
||||
|
||||
<li><b>23 March 2007 -- BusyBox 1.5.0 (unstable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.5.0.tar.bz2>BusyBox 1.5.0</a>.
|
||||
(<a href=http://busybox.net/downloads/fixes-1.5.0/>patches</a>,
|
||||
<a href=http://busybox.net/fix.html>how to add a patch</a>)</p>
|
||||
|
||||
<p>Since this is a x.x.0 release, it probably does not deserve "stable"
|
||||
label. Please help making 1.5.1 stable by testing 1.5.0.</p>
|
||||
<p>Notable changes since previous release:
|
||||
<ul>
|
||||
<li>find: added support for -user, -not, fixed -mtime, -mmin, -perm
|
||||
<li>[de]archivers: merge common logic into one module
|
||||
<li>ping[6]: unified code for both
|
||||
<li>less: regex search improved
|
||||
<li>ash: more readable code, testsuite added
|
||||
<li>sed: several very obscure bugs fixed
|
||||
<li>chown: -H, -L, -P support (required by POSIX)
|
||||
<li>tar: handle (broken) checksums a-la Sun; tar restores mode again
|
||||
<li>grep: implement -w, "implement" -a and -I by ignoring them
|
||||
<li>cp: more sane behavior when overwriting existing files
|
||||
<li>init: stop doing silly things with the console (-400 bytes)
|
||||
<li>httpd: make httpd usable for NOMMU CPUs; fix POSTDATA handling bugs
|
||||
<li>httpd: run interpreter for configured file extensions in any dir,
|
||||
not only in /cgi-bin/
|
||||
<li>chrt: new applet
|
||||
<li>SELinux: SELinux-related code and -Z option added to several applets,
|
||||
new SELinux-specific applets: chcon, runcon.
|
||||
<li>Build system: produces link map, uses -Wwrite-strings to catch
|
||||
improper usage of string constants.
|
||||
<li>Data and bss section usage audited and reduced - should help NOMMU
|
||||
targets.
|
||||
<li>Applets with bug fixes: gunzip, vi, syslogd, dpkg, ls, adjtimex, resize,
|
||||
sv, printf, diff, awk, sort, dpkg, diff, tftp
|
||||
<li>Applets with usability improvements: swapon, more, ifup/ifdown, hwclock,
|
||||
udhcpd, start_stop_daemon, cmp
|
||||
<li>Applets with code cleaned up: telnet, fdisk, fsck_minix, mkfs_minix,
|
||||
syslogd, swapon, runsv, svlogd, klogd
|
||||
</ul>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>18 March 2007 -- BusyBox 1.4.2 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.4.2.tar.bz2>BusyBox 1.4.2</a>.
|
||||
</p>
|
||||
|
||||
<p>This release includes only trivial fixes accumulated since 1.4.1.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>25 January 2007 -- BusyBox 1.4.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.4.1.tar.bz2>BusyBox 1.4.1</a>.
|
||||
(<a href=http://busybox.net/downloads/fixes-1.4.1/>patches</a>)</p>
|
||||
|
||||
<p>This release includes only trivial fixes accumulated since 1.4.0.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>20 January 2007 -- BusyBox 1.4.0 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.4.0.tar.bz2>BusyBox 1.4.0</a>.
|
||||
(<a href=http://busybox.net/downloads/fixes-1.4.0/>patches</a>)</p>
|
||||
|
||||
<p>Since this is a x.x.0 release, it probably is a bit less "stable"
|
||||
than usual.</p>
|
||||
<p>Changes since previous release:
|
||||
<ul>
|
||||
<li>e2fsprogs are mostly removed from busybox. Some smaller parts remain,
|
||||
the rest of it sits disabled in e2fsprogs/old_e2fsprogs/*, because
|
||||
it's too bloated. Really. I'm afraid it's about the only way we can
|
||||
ever get e2fsprogs cleaned up.
|
||||
<li>less: many improvements. Now can display binary files
|
||||
(although I expect it to have trouble with displays where 8bit chars
|
||||
don't have 1-to-1 char/glyph relationship). Regexp search is not buggy
|
||||
anymore. Less does not read entire input up-front. Reads input
|
||||
as it appears (yay!). Works rather nice as man pager. I recommend it
|
||||
for general use now.
|
||||
<li>IPv6: generic support is in place, many networking applets are
|
||||
upgraded to be IPv6 capable. Probably some work remains, but it is
|
||||
already much better than what we had previously.
|
||||
<li>arp: new applet (thanks to Eric Spakman).
|
||||
<li>fakeidentd: non-forking standalone server part was taking ~90%
|
||||
of the applet. Factored it out (in fact, rewrote it).
|
||||
<li>syslogd: mostly rewritten.
|
||||
<li>decompress_unzip, gzip: sanitized a bit.
|
||||
<li>sed: better hadling of NULs
|
||||
<li>httpd: stop adding our own "Content-type:" to CGI output
|
||||
<li>chown: user.grp works again.
|
||||
<li>minor bugfixes to: passwd, date, tftp, start_stop_daemon, tar,
|
||||
ps, ifupdown, time, su, stty, awk, ping[6], sort,...
|
||||
</ul>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>20 January 2007 -- BusyBox 1.3.2 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.3.2.tar.bz2>BusyBox 1.3.2</a>.</p>
|
||||
|
||||
<p>This release includes only one trivial fix accumulated since 1.3.1
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>27 December 2006 -- BusyBox 1.3.1 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.3.1.tar.bz2>BusyBox 1.3.1</a>.
|
||||
(<a href=http://busybox.net/downloads/fixes-1.3.1/>patches</a>)</p>
|
||||
|
||||
<p>Closing 2006 with new release. It includes only trivial fixes accumulated since 1.3.0
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>14 December 2006 -- BusyBox 1.3.0 (stable)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.3.0.tar.bz2>BusyBox 1.3.0</a>.
|
||||
(<a href=http://busybox.net/downloads/fixes-1.3.0/>patches</a>)</p>
|
||||
|
||||
<p>This release has CONFIG_DESKTOP option which enables features
|
||||
needed for busybox usage on desktop machine. For example, find, chmod
|
||||
and chown get several less frequently used options, od is significantly
|
||||
bigger but matches GNU coreutils, etc. Intended to eventually make
|
||||
busybox a viable alternative for "standard" utilities for slightly
|
||||
adventurous desktop users.
|
||||
<p>Changes since previous release:
|
||||
<ul>
|
||||
<li>find: taking many more of standard options
|
||||
<li>ps: POSIX-compliant -o implemented
|
||||
<li>cp: added -s, -l
|
||||
<li>grep: added -r, fixed -h
|
||||
<li>watch: make it exec child like standard one does (was totally
|
||||
incompatible)
|
||||
<li>tar: fix limitations which were preventing bbox tar usage
|
||||
on big directories: long names and linknames, pax headers
|
||||
(Linux kernel tarballs have that). Fixed a number of obscure bugs.
|
||||
Raised max file limit (now 64Gb). Security fixes (/../ attacks).
|
||||
<li>httpd: added -i (inetd), -f (foreground), support for
|
||||
directory indexer CGI (example is included), bugfixes.
|
||||
<li>telnetd: fixed/improved IPv6 support, inetd+standalone support,
|
||||
other fixes. Useful IPv6 stuff factored out into libbb.
|
||||
<li>runit/*: new applets adapted from http://smarden.sunsite.dk/runit/
|
||||
(these are my personal favorite small-and-beautiful toys)
|
||||
<li>minor bugfixes to: login, dd, mount, umount, chmod, chown, ln, udhcp,
|
||||
fdisk, ifconfig, sort, tee, mkswap, wget, insmod.
|
||||
</ul>
|
||||
<p>Note that GnuPG key used to sign this release is different.
|
||||
1.2.2.1 is also signed post-factum now. Sorry for the mess.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>29 October 2006 -- BusyBox 1.2.2.1 (fix)</b>
|
||||
<p><a href=http://busybox.net/downloads/busybox-1.2.2.1.tar.bz2>BusyBox 1.2.2.1</a>.</p>
|
||||
|
||||
<p>Added compile-time warning that static linking against glibc
|
||||
produces buggy executables.
|
||||
</li>
|
||||
|
||||
<li><b>24 October 2006 -- BusyBox 1.2.2 (stable)</b>
|
||||
<p>It's a bit overdue, but
|
||||
<a href=http://busybox.net/downloads/busybox-1.2.2.tar.bz2>here is
|
||||
BusyBox 1.2.2</a>.</p>
|
||||
|
||||
<p>This release has dozens of fixes backported from the ongoing development
|
||||
branch. There are a couple of bugfixes to sed, two fixes to documentation
|
||||
generation (BusyBox.html shouldn't have USE() macros in it anymore), fix
|
||||
umount to report the right errno on failure and to umount block devices by
|
||||
name with newer kernels, fix mount to handle symlinks properly, make mdev
|
||||
delete device nodes when called for hotplug remove, fix a segfault
|
||||
in traceroute, a minor portability fix to md5sum option parsing, a build
|
||||
fix for httpd with old gccs, an options parsing tweak to hdparm, make test
|
||||
fail gracefully when getgroups() returns -1, fix a race condition in
|
||||
modprobe when two instances run at once (hotplug does this), make "tar xf
|
||||
foo.tar dir/dir" extract all subdirectories, make our getty initialize the
|
||||
terminal more like mingetty, an selinux build fix, an endianness fix in
|
||||
ping6, fix for zcip defending addresses, clean up some global variables in
|
||||
gzip to save memory, fix sulogin -tNNN, a help text tweak, several warning
|
||||
fixes and build fixes, fixup dnsd a bit, and a partridge in a pear tree.</p>
|
||||
|
||||
<p>As <a href=http://lwn.net/Articles/202106/>Linux Weekly News noted</a>,
|
||||
this is my (Rob's) last release of BusyBox. The new maintainer is Denis
|
||||
Vlasenko, I'm off to do <a href=http://landley.net/code>other things</a>.
|
||||
</p>
|
||||
</li>
|
||||
|
||||
<li><b>29 September 2006 -- New license email address.</b>
|
||||
<p>The email address gpl@busybox.net is now the recommended way to contact
|
||||
the Software Freedom Law Center to report BusyBox license violations.</p>
|
||||
|
||||
<li><b>31 July 2006 -- BusyBox 1.2.1 (stable)</b>
|
||||
<p>Since nobody seems to have objected too loudly over the weekend, I
|
||||
might as well point you all at
|
||||
<a href="http://busybox.net/downloads/busybox-1.2.1.tar.bz2">Busybox
|
||||
1.2.1</a>, a bugfix-only release with no new features.</p>
|
||||
|
||||
<p>It has three shell fixes (two to lash: going "var=value" without
|
||||
saying "export" should now work, plus a missing null pointer check, and
|
||||
one to ash when redirecting output to a file that fills up.) Fix three
|
||||
embarassing thinkos in the new dmesg command. Two build tweaks
|
||||
(dependencies for the compressed usage messages and running make in the
|
||||
libbb subdirectory). One fix to tar so it can extract git-generated
|
||||
tarballs (rather than barfing on the pax extensions). And a partridge
|
||||
in a pear... Ahem.</p>
|
||||
|
||||
<p>But wait, there's more! A passwd changing fix so an empty
|
||||
gecos field doesn't trigger a false objection that the new passwd contains
|
||||
the gecos field. Make all our setuid() and setgid() calls check the return
|
||||
value in case somebody's using per-process resource limits that prevent
|
||||
a user from having too many processes (and thus prevent a process from
|
||||
switching away from root, in which case the process will now _die_ rather
|
||||
than continue with root privileges). A fix to adduser to make sure that
|
||||
/etc/group gets updated. And a fix to modprobe to look for modules.conf
|
||||
in the right place on 2.6 kernels.</p>
|
||||
|
||||
<li><b>30 June 2006 -- BusyBox 1.2.0</b>
|
||||
<p>The -devel branch has been stabilized and the result is
|
||||
<a href="http://busybox.net/downloads/busybox-1.2.0.tar.bz2">Busybox
|
||||
1.2.0</a>. Lots of stuff changed, I need to work up a decent changelog
|
||||
over the weekend.</p>
|
||||
|
||||
<p>I'm still experimenting with how long is best for the development
|
||||
cycle, and since we've got some largeish projects queued up I'm going to
|
||||
try a longer one. Expect 1.3.0 in December. (Expect 1.2.1 any time
|
||||
we fix enough bugs. :)</p>
|
||||
|
||||
<p>Update: Here are <a href="http://busybox.net/downloads/busybox-1.2.0.fixes.patch">the first few bug fixes</a> that will go into 1.2.1.</p>
|
||||
|
||||
<li><b>17 May 2006 -- BusyBox 1.1.3 (stable)</b>
|
||||
<p><a href="http://busybox.net/downloads/busybox-1.1.3.tar.bz2">BusyBox
|
||||
1.1.3</a> is another bugfix release. It makes passwd use salt, fixes a
|
||||
memory freeing bug in ls, fixes "build all sources at once" mode, makes
|
||||
mount -a not abort on the first failure, fixes msh so ctrl-c doesn't kill
|
||||
background processes, makes patch work with patch hunks that don't have a
|
||||
timestamp, make less's text search a lot more robust (the old one could
|
||||
segfault), and fixes readlink -f when built against uClibc.</p>
|
||||
|
||||
<p>Expect 1.2.0 sometime next month, which won't be a bugfix release.</p>
|
||||
|
||||
<li><b>10 April 2006 -- BusyBox 1.1.2 (stable)</b>
|
||||
<p>You can now download <a href="http://busybox.net/downloads/busybox-1.1.2.tar.bz2">BusyBox 1.1.2</a>, a bug fix release consisting of 11 patches
|
||||
backported from the development branch: Some build fixes, several fixes
|
||||
for mount and nfsmount, a fix for insmod on big endian systems, a fix for
|
||||
find -xdev, and a fix for comm. Check the file "changelog" in the tarball
|
||||
for more info.</p>
|
||||
|
||||
<p>The next new development release (1.2.0) is slated for June. A 1.1.3
|
||||
will be released before then if more bug fixes crop up. (The new plan is
|
||||
to have a 1.x.0 new development release every 3 months, with 1.x.y stable
|
||||
bugfix only releases based on that as appropriate.)</p>
|
||||
|
||||
<li><b>27 March 2006 -- Software Freedom Law Center representing BusyBox and uClibc</b>
|
||||
<p>One issue Erik Andersen wanted to resolve when handing off BusyBox
|
||||
maintainership to Rob Landley was license enforcement. BusyBox and
|
||||
uClibc's existing license enforcement efforts (pro-bono representation
|
||||
by Erik's father's law firm, and the
|
||||
<a href="http://www.busybox.net/shame.html">Hall of Shame</a>), haven't
|
||||
scaled to match the popularity of the projects. So we put our heads
|
||||
together and did the obvious thing: ask Pamela Jones of
|
||||
<a href="http://www.groklaw.net">Groklaw</a> for suggestions. She
|
||||
referred us to the fine folks at softwarefreedom.org.</p>
|
||||
|
||||
<p>As a result, we're pleased to announce that the
|
||||
<a href="http://www.softwarefreedom.org">Software Freedom Law Center</a>
|
||||
has agreed to represent BusyBox and uClibc. We join a number of other
|
||||
free and open source software projects (such as
|
||||
<a href="http://lwn.net/Articles/141806/">X.org</a>,
|
||||
<a href="http://lwn.net/Articles/135413/">Wine</a>, and
|
||||
<a href="http://plone.org/foundation/newsitems/software-freedom-law-center-support/">Plone</a>
|
||||
in being represented by a fairly cool bunch of lawyers, which is not a
|
||||
phrase you get to use every day.</p>
|
||||
|
||||
<li><b>22 March 2006 -- BusyBox 1.1.1</b>
|
||||
<p>The new maintainer is Rob Landley, and the new release is <a href="http://busybox.net/downloads/busybox-1.1.1.tar.bz2">BusyBox 1.1.1</a>. Expect a "what's new" document in a few days. (Also, Erik and I have have another announcement pending...)</p>
|
||||
<p>Update: Rather than put out an endless stream of 1.1.1.x releases,
|
||||
the various small fixes have been collected together into a
|
||||
<a href="http://busybox.net/downloads/busybox-1.1.1.fixes.patch">patch</a>,
|
||||
and new fixes will be appended to that as needed. Expect 1.1.2 around
|
||||
June.</p>
|
||||
</li>
|
||||
<li><b>11 January 2006 -- 1.1.0 is out</b>
|
||||
<p>The new stable release is
|
||||
<a href="http://www.busybox.net/downloads/busybox-1.1.0.tar.bz2">BusyBox
|
||||
1.1.0</a>. It has a number of improvements, including several new applets.
|
||||
(It also has <a href="http://www.busybox.net/lists/busybox/2006-January/017733.html">a few rough spots</a>,
|
||||
but we're trying out a "release early, release often" strategy to see how
|
||||
that works. Expect 1.1.1 sometime in March.)</p>
|
||||
|
||||
<li><b>31 October 2005 -- 1.1.0-pre1</b>
|
||||
<p>The development branch of busybox is stable enough for wider testing, so
|
||||
you can now
|
||||
|
||||
@@ -12,52 +12,61 @@ Everybody loves to look at screenshots, so here is a live action screenshot of B
|
||||
font-family: monospace; font-size: smaller;" width="100">
|
||||
|
||||
$ busybox
|
||||
BusyBox v1.8.0 (2007-11-04 15:42:38 GMT) multi-call binary
|
||||
Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others.
|
||||
Licensed under GPLv2. See source distribution for full notice.
|
||||
BusyBox v1.10.1 (2008-04-24 11:30:07 CEST) multi-call binary
|
||||
Copyright (C) 1998-2007 Erik Andersen, Rob Landley, Denys Vlasenko
|
||||
and others. Licensed under GPLv2.
|
||||
See source distribution for full notice.
|
||||
|
||||
Usage: busybox [function] [arguments]...
|
||||
or: [function] [arguments]...
|
||||
or: function [arguments]...
|
||||
|
||||
BusyBox is a multi-call binary that combines many common Unix
|
||||
utilities into a single executable. Most people will create a
|
||||
link to busybox for each function they wish to use and BusyBox
|
||||
will act like whatever it was invoked as!
|
||||
BusyBox is a multi-call binary that combines many common Unix
|
||||
utilities into a single executable. Most people will create a
|
||||
link to busybox for each function they wish to use and BusyBox
|
||||
will act like whatever it was invoked as!
|
||||
|
||||
Currently defined functions:
|
||||
[, [[, addgroup, adduser, adjtimex, ar, arp, arping, ash,
|
||||
awk, basename, bunzip2, bzcat, bzip2, cal, cat, catv, chattr,
|
||||
chgrp, chmod, chown, chpasswd, chpst, chroot, chrt, chvt,
|
||||
cksum, clear, cmp, comm, cp, cpio, crond, crontab, cryptpw,
|
||||
cut, date, dc, dd, deallocvt, delgroup, deluser, df, dhcprelay,
|
||||
diff, dirname, dmesg, dnsd, dos2unix, dpkg, du, dumpkmap,
|
||||
dumpleases, echo, ed, egrep, eject, env, envdir, envuidgid,
|
||||
expand, expr, fakeidentd, false, fbset, fdflush, fdformat,
|
||||
fdisk, fgrep, find, fold, free, freeramdisk, fsck, fsck.minix,
|
||||
ftpget, ftpput, fuser, getopt, getty, grep, gunzip, gzip,
|
||||
hdparm, head, hexdump, hostid, hostname, httpd, hush, hwclock,
|
||||
id, ifconfig, inetd, insmod, install, ip, ipaddr, ipcalc,
|
||||
ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kbd_mode,
|
||||
kill, killall, killall5, klogd, lash, last, length, less,
|
||||
linux32, linux64, ln, loadfont, loadkmap, logger, login, logname,
|
||||
logread, losetup, ls, lsattr, lsmod, lzmacat, md5sum, mdev,
|
||||
mesg, microcom, mkdir, mkfifo, mkfs.minix, mknod, mkswap,
|
||||
mktemp, modprobe, more, mount, mountpoint, msh, mt, mv, nameif,
|
||||
nc, netstat, nice, nmeter, nohup, nslookup, od, openvt, passwd,
|
||||
patch, pgrep, pidof, ping, ping6, pipe_progress, pivot_root,
|
||||
pkill, printenv, printf, ps, pscan, pwd, raidautorun, rdate,
|
||||
readlink, readprofile, realpath, renice, reset, resize, rm,
|
||||
rmdir, rmmod, route, rpm, rpm2cpio, run-parts, runlevel, runsv,
|
||||
runsvdir, rx, sed, seq, setarch, setconsole, setkeycodes,
|
||||
setlogcons, setsid, setuidgid, sha1sum, slattach, sleep, softlimit,
|
||||
sort, split, start-stop-daemon, stat, strings, stty, su, sulogin,
|
||||
sum, sv, svlogd, swapoff, swapon, switch_root, sync, sysctl,
|
||||
syslogd, tail, tar, tcpsvd, tee, telnet, telnetd, test, tftp,
|
||||
time, top, touch, tr, traceroute, true, tty, ttysize, udhcpc,
|
||||
udhcpd, udpsvd, umount, uname, uncompress, unexpand, uniq,
|
||||
unix2dos, unlzma, unzip, uptime, usleep, uudecode, uuencode,
|
||||
vconfig, vi, vlock, watch, watchdog, wc, wget, which, who,
|
||||
whoami, xargs, yes, zcat, zcip
|
||||
[, [[, addgroup, adduser, adjtimex, ar, arp, arping, ash,
|
||||
awk, basename, bbconfig, brctl, bunzip2, bzcat, bzip2,
|
||||
cal, cat, catv, chat, chattr, chcon, chgrp, chmod, chown,
|
||||
chpasswd, chpst, chroot, chrt, chvt, cksum, clear, cmp,
|
||||
comm, cp, cpio, crond, crontab, cryptpw, cttyhack, cut,
|
||||
date, dc, dd, deallocvt, delgroup, deluser, devfsd, df,
|
||||
dhcprelay, diff, dirname, dmesg, dnsd, dos2unix, dpkg,
|
||||
dpkg-deb, du, dumpkmap, dumpleases, echo, ed, egrep, eject,
|
||||
env, envdir, envuidgid, ether-wake, expand, expr, fakeidentd,
|
||||
false, fbset, fdflush, fdformat, fdisk, fetchmail, fgrep,
|
||||
find, findfs, fold, free, freeramdisk, fsck, fsck.minix,
|
||||
ftpget, ftpput, fuser, getenforce, getopt, getsebool,
|
||||
getty, grep, gunzip, gzip, halt, hd, hdparm, head, hexdump,
|
||||
hostid, hostname, httpd, hush, hwclock, id, ifconfig,
|
||||
ifdown, ifenslave, ifup, inetd, init, insmod, install,
|
||||
ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule,
|
||||
iptunnel, kbd_mode, kill, killall, killall5, klogd, lash,
|
||||
last, length, less, linux32, linux64, linuxrc, ln, load_policy,
|
||||
loadfont, loadkmap, logger, login, logname, logread, losetup,
|
||||
lpd, lpq, lpr, ls, lsattr, lsmod, lzmacat, makedevs, matchpathcon,
|
||||
md5sum, mdev, mesg, microcom, mkdir, mkfifo, mkfs.minix,
|
||||
mknod, mkswap, mktemp, modprobe, more, mount, mountpoint,
|
||||
msh, mt, mv, nameif, nc, netstat, nice, nmeter, nohup,
|
||||
nslookup, od, openvt, passwd, patch, pgrep, pidof, ping,
|
||||
ping6, pipe_progress, pivot_root, pkill, poweroff, printenv,
|
||||
printf, ps, pscan, pwd, raidautorun, rdate, readahead,
|
||||
readlink, readprofile, realpath, reboot, renice, reset,
|
||||
resize, restorecon, rm, rmdir, rmmod, route, rpm, rpm2cpio,
|
||||
rtcwake, run-parts, runcon, runlevel, runsv, runsvdir,
|
||||
rx, script, sed, selinuxenabled, sendmail, seq, sestatus,
|
||||
setarch, setconsole, setenforce, setfiles, setkeycodes,
|
||||
setlogcons, setsebool, setsid, setuidgid, sha1sum, slattach,
|
||||
sleep, softlimit, sort, split, start-stop-daemon, stat,
|
||||
strings, stty, su, sulogin, sum, sv, svlogd, swapoff,
|
||||
swapon, switch_root, sync, sysctl, syslogd, tac, tail,
|
||||
tar, taskset, tcpsvd, tee, telnet, telnetd, test, tftp,
|
||||
tftpd, time, top, touch, tr, traceroute, true, tty, ttysize,
|
||||
udhcpc, udhcpd, udpsvd, umount, uname, uncompress, unexpand,
|
||||
uniq, unix2dos, unlzma, unzip, uptime, usleep, uudecode,
|
||||
uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget,
|
||||
which, who, whoami, xargs, yes, zcat, zcip
|
||||
|
||||
$ <span style="text-decoration:blink;">_</span>
|
||||
|
||||
|
||||
@@ -12,24 +12,41 @@ project, consider these fine companies!</p>
|
||||
OSU OSL kindly provides hosting for BusyBox and uClibc.
|
||||
</li>
|
||||
|
||||
<li><a href="http://www.codepoet-consulting.com">Codepoet Consulting</a><br>
|
||||
Custom Linux, embedded Linux, BusyBox, and uClibc development.
|
||||
</li>
|
||||
|
||||
<li>AOE media, a <a href=http://www.aoemedia.com/typo3-development.html>
|
||||
TYPO3 development agency</a> contributes financially.
|
||||
</li>
|
||||
|
||||
<li><a href=http://www.analog.com/en/>Analog Devices, Inc.</a> provided
|
||||
a <a href=http://docs.blackfin.uclinux.org/doku.php?id=bf537_quick_start>
|
||||
Blackfin development board</a> free of charge.
|
||||
<a href=http://www.analog.com/blackfin>Blackfin<a>
|
||||
is a NOMMU processor, and its availability for testing is invaluable.
|
||||
If you are an embedded device developer,
|
||||
please note that Analog Devices has entire Linux distribution available
|
||||
for download for this board. Visit
|
||||
<a href=http://blackfin.uclinux.org/>http://blackfin.uclinux.org/</a>
|
||||
for more information.
|
||||
</li>
|
||||
|
||||
<li><a href="http://www.timesys.com">TimeSys</a><br>
|
||||
Embedded Linux development, cross-compilers, real-time, KGDB, tsrpm and cygwin.
|
||||
</li>
|
||||
|
||||
<li><a href="http://www.penguru.net">Penguru Consulting</a><br>
|
||||
Custom development for embedded Linux systems and multimedia platforms
|
||||
Custom development for embedded Linux systems and multimedia platforms.
|
||||
</li>
|
||||
|
||||
<li><a href="http://opensource.se/">opensource.se</a><br>
|
||||
Embedded open source consulting in Europe.
|
||||
</li>
|
||||
|
||||
<li><a href="http://www.codepoet-consulting.com">Codepoet Consulting</a><br>
|
||||
Custom Linux, embedded Linux, BusyBox, and uClibc development.
|
||||
</li>
|
||||
|
||||
<li><a href="http://www.timesys.com">TimeSys</a><br>
|
||||
Embedded Linux development, cross-compilers, real-time, KGDB, tsrpm and cygwin.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p>If you wish to be a sponsor, or if you have already contributed and would
|
||||
like your name added here, email <a href="mailto:rob@landley.net">Rob</a>.</p>
|
||||
like your name added here, email <a href="mailto:vda.linux@gmail.com">Denys</a>.</p>
|
||||
|
||||
<!--#include file="footer.html" -->
|
||||
+9
-3
@@ -15,13 +15,20 @@ require sysfs support in the kernel and have it mounted at /sys. For dynamic
|
||||
updates, you also need to have hotplugging enabled in your kernel.
|
||||
|
||||
Here's a typical code snippet from the init script:
|
||||
[0] mount -t proc proc /proc
|
||||
[1] mount -t sysfs sysfs /sys
|
||||
[2] echo /bin/mdev > /proc/sys/kernel/hotplug
|
||||
[3] mdev -s
|
||||
|
||||
Alternatively, without procfs the above becomes:
|
||||
[1] mount -t sysfs sysfs /sys
|
||||
[2] sysctl -w kernel.hotplug=/bin/mdev
|
||||
[3] mdev -s
|
||||
|
||||
|
||||
Of course, a more "full" setup would entail executing this before the previous
|
||||
code snippet:
|
||||
[4] mount -t tmpfs mdev /dev
|
||||
[4] mount -t tmpfs -o size=64k,mode=0755 tmpfs /dev
|
||||
[5] mkdir /dev/pts
|
||||
[6] mount -t devpts devpts /dev/pts
|
||||
|
||||
@@ -87,5 +94,4 @@ properly initialize a device. Place all such firmware files into the
|
||||
/lib/firmware/ directory. At runtime, the kernel will invoke mdev with the
|
||||
filename of the firmware which mdev will load out of /lib/firmware/ and into
|
||||
the kernel via the sysfs interface. The exact filename is hardcoded in the
|
||||
kernel, so look there if you need to want to know what to name the file in
|
||||
userspace.
|
||||
kernel, so look there if you need to know how to name the file in userspace.
|
||||
@@ -192,7 +192,7 @@ static const char e2attr_flags_lname[] =
|
||||
"Top_of_Directory_Hierarchies" "\0"
|
||||
/* Another trailing NUL is added by compiler */;
|
||||
|
||||
void print_flags(FILE *f, unsigned long flags, unsigned options)
|
||||
void print_e2flags(FILE *f, unsigned long flags, unsigned options)
|
||||
{
|
||||
const uint32_t *fv;
|
||||
const char *fn;
|
||||
|
||||
@@ -9,6 +9,10 @@
|
||||
/* Constants and structures */
|
||||
#include "e2fs_defs.h"
|
||||
|
||||
#if __GNUC_PREREQ(4,1)
|
||||
# pragma GCC visibility push(hidden)
|
||||
#endif
|
||||
|
||||
/* Iterate a function on each entry of a directory */
|
||||
int iterate_on_dir(const char *dir_name,
|
||||
int (*func)(const char *, struct dirent *, void *),
|
||||
@@ -27,7 +31,7 @@ int fgetsetflags(const char *name, unsigned long *get_flags, unsigned long set_f
|
||||
/* Must be 1 for compatibility with `int long_format'. */
|
||||
#define PFOPT_LONG 1
|
||||
/* Print file attributes on an ext2 file system */
|
||||
void print_flags(FILE *f, unsigned long flags, unsigned options);
|
||||
void print_e2flags(FILE *f, unsigned long flags, unsigned options);
|
||||
|
||||
extern const uint32_t e2attr_flags_value[];
|
||||
extern const char e2attr_flags_sname[];
|
||||
@@ -41,3 +45,7 @@ extern const char e2attr_flags_sname[];
|
||||
#define e2attr_flags_value_chattr (&e2attr_flags_value[1])
|
||||
#define e2attr_flags_sname_chattr (&e2attr_flags_sname[1])
|
||||
#endif
|
||||
|
||||
#if __GNUC_PREREQ(4,1)
|
||||
# pragma GCC visibility pop
|
||||
#endif
|
||||
+1
-1
@@ -391,7 +391,7 @@ static void load_fs_info(const char *filename)
|
||||
}
|
||||
while (1) {
|
||||
int r;
|
||||
char *buf = xmalloc_getline(f);
|
||||
char *buf = xmalloc_fgetline(f);
|
||||
if (!buf) break;
|
||||
r = parse_fstab_line(buf, &fs);
|
||||
free(buf);
|
||||
|
||||
+2
-2
@@ -45,10 +45,10 @@ static void list_attributes(const char *name)
|
||||
|
||||
if (option_mask32 & OPT_PF_LONG) {
|
||||
printf("%-28s ", name);
|
||||
print_flags(stdout, fsflags, PFOPT_LONG);
|
||||
print_e2flags(stdout, fsflags, PFOPT_LONG);
|
||||
bb_putchar('\n');
|
||||
} else {
|
||||
print_flags(stdout, fsflags, 0);
|
||||
print_e2flags(stdout, fsflags, 0);
|
||||
printf(" %s\n", name);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#define EXT3_FEATURE_INCOMPAT_EXTENTS 0x0040
|
||||
#endif
|
||||
|
||||
/* `options' for print_flags() */
|
||||
/* `options' for print_e2flags() */
|
||||
|
||||
#define PFOPT_LONG 1 /* Must be 1 for compatibility with `int long_format'. */
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ static char *string_copy(const char *s)
|
||||
|
||||
if (!s)
|
||||
return 0;
|
||||
ret = strdup(s);
|
||||
ret = xstrdup(s);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,10 +56,10 @@ static void list_attributes(const char *name)
|
||||
|
||||
if (flags & OPT_PF_LONG) {
|
||||
printf("%-28s ", name);
|
||||
print_flags(stdout, fsflags, PFOPT_LONG);
|
||||
print_e2flags(stdout, fsflags, PFOPT_LONG);
|
||||
bb_putchar('\n');
|
||||
} else {
|
||||
print_flags(stdout, fsflags, 0);
|
||||
print_e2flags(stdout, fsflags, 0);
|
||||
printf(" %s\n", name);
|
||||
}
|
||||
|
||||
|
||||
+24
-30
@@ -676,16 +676,11 @@ static char nextchar(char **s)
|
||||
return c;
|
||||
}
|
||||
|
||||
static int ALWAYS_INLINE isalnum_(int c)
|
||||
static ALWAYS_INLINE int isalnum_(int c)
|
||||
{
|
||||
return (isalnum(c) || c == '_');
|
||||
}
|
||||
|
||||
static FILE *afopen(const char *path, const char *mode)
|
||||
{
|
||||
return (*path == '-' && *(path+1) == '\0') ? stdin : xfopen(path, mode);
|
||||
}
|
||||
|
||||
/* -------- working with variables (set/get/copy/etc) -------- */
|
||||
|
||||
static xhash *iamarray(var *v)
|
||||
@@ -1682,7 +1677,7 @@ static void hashwalk_init(var *v, xhash *array)
|
||||
{
|
||||
char **w;
|
||||
hash_item *hi;
|
||||
int i;
|
||||
unsigned i;
|
||||
|
||||
if (v->type & VF_WALK)
|
||||
free(v->x.walker);
|
||||
@@ -1996,7 +1991,7 @@ static var *exec_builtin(node *op, var *res)
|
||||
}
|
||||
|
||||
nargs = i;
|
||||
if (nargs < (info >> 30))
|
||||
if ((uint32_t)nargs < (info >> 30))
|
||||
syntax_error(EMSG_TOO_FEW_ARGS);
|
||||
|
||||
switch (info & OPNMASK) {
|
||||
@@ -2740,7 +2735,7 @@ static rstream *next_input_file(void)
|
||||
ind = getvar_s(incvar(intvar[ARGIND]));
|
||||
fname = getvar_s(findvar(iamarray(intvar[ARGV]), ind));
|
||||
if (fname && *fname && !is_assignment(fname))
|
||||
F = afopen(fname, "r");
|
||||
F = xfopen_stdin(fname);
|
||||
}
|
||||
} while (!F);
|
||||
|
||||
@@ -2757,8 +2752,9 @@ int awk_main(int argc, char **argv)
|
||||
{
|
||||
unsigned opt;
|
||||
char *opt_F, *opt_W;
|
||||
llist_t *opt_v = NULL;
|
||||
int i, j, flen;
|
||||
llist_t *list_v = NULL;
|
||||
llist_t *list_f = NULL;
|
||||
int i, j;
|
||||
var *v;
|
||||
var tv;
|
||||
char **envp;
|
||||
@@ -2816,35 +2812,33 @@ int awk_main(int argc, char **argv)
|
||||
*s1 = '=';
|
||||
}
|
||||
}
|
||||
opt_complementary = "v::";
|
||||
opt = getopt32(argv, "F:v:f:W:", &opt_F, &opt_v, &g_progname, &opt_W);
|
||||
opt_complementary = "v::f::"; /* -v and -f can occur multiple times */
|
||||
opt = getopt32(argv, "F:v:f:W:", &opt_F, &list_v, &list_f, &opt_W);
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
if (opt & 0x1)
|
||||
setvar_s(intvar[FS], opt_F); // -F
|
||||
while (opt_v) { /* -v */
|
||||
if (!is_assignment(llist_pop(&opt_v)))
|
||||
while (list_v) { /* -v */
|
||||
if (!is_assignment(llist_pop(&list_v)))
|
||||
bb_show_usage();
|
||||
}
|
||||
if (opt & 0x4) { // -f
|
||||
char *s = s; /* die, gcc, die */
|
||||
FILE *from_file = afopen(g_progname, "r");
|
||||
/* one byte is reserved for some trick in next_token */
|
||||
if (fseek(from_file, 0, SEEK_END) == 0) {
|
||||
flen = ftell(from_file);
|
||||
s = xmalloc(flen + 4);
|
||||
fseek(from_file, 0, SEEK_SET);
|
||||
i = 1 + fread(s + 1, 1, flen, from_file);
|
||||
} else {
|
||||
if (list_f) { /* -f */
|
||||
do {
|
||||
char *s = NULL;
|
||||
FILE *from_file;
|
||||
|
||||
g_progname = llist_pop(&list_f);
|
||||
from_file = xfopen_stdin(g_progname);
|
||||
/* one byte is reserved for some trick in next_token */
|
||||
for (i = j = 1; j > 0; i += j) {
|
||||
s = xrealloc(s, i + 4096);
|
||||
j = fread(s + i, 1, 4094, from_file);
|
||||
}
|
||||
}
|
||||
s[i] = '\0';
|
||||
fclose(from_file);
|
||||
parse_program(s + 1);
|
||||
free(s);
|
||||
s[i] = '\0';
|
||||
fclose(from_file);
|
||||
parse_program(s + 1);
|
||||
free(s);
|
||||
} while (list_f);
|
||||
} else { // no -f: take program from 1st parameter
|
||||
if (!argc)
|
||||
bb_show_usage();
|
||||
|
||||
+299
-233
File diff suppressed because it is too large.
Load diff
+131
-136
@@ -119,7 +119,7 @@ int ed_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
static void doCommands(void)
|
||||
{
|
||||
const char *cp;
|
||||
char *endbuf, *newname, buf[USERSIZE];
|
||||
char *endbuf, buf[USERSIZE];
|
||||
int len, num1, num2;
|
||||
smallint have1, have2;
|
||||
|
||||
@@ -168,162 +168,157 @@ static void doCommands(void)
|
||||
num2 = num1;
|
||||
|
||||
switch (*cp++) {
|
||||
case 'a':
|
||||
addLines(num1 + 1);
|
||||
break;
|
||||
case 'a':
|
||||
addLines(num1 + 1);
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
deleteLines(num1, num2);
|
||||
addLines(num1);
|
||||
break;
|
||||
case 'c':
|
||||
deleteLines(num1, num2);
|
||||
addLines(num1);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
deleteLines(num1, num2);
|
||||
break;
|
||||
case 'd':
|
||||
deleteLines(num1, num2);
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
if (*cp && !isblank(*cp)) {
|
||||
bb_error_msg("bad file command");
|
||||
break;
|
||||
}
|
||||
cp = skip_blank(cp);
|
||||
if (*cp == '\0') {
|
||||
if (fileName)
|
||||
printf("\"%s\"\n", fileName);
|
||||
else
|
||||
printf("No file name\n");
|
||||
break;
|
||||
}
|
||||
newname = strdup(cp);
|
||||
if (newname == NULL) {
|
||||
bb_error_msg("no memory for file name");
|
||||
break;
|
||||
}
|
||||
free(fileName);
|
||||
fileName = newname;
|
||||
case 'f':
|
||||
if (*cp && !isblank(*cp)) {
|
||||
bb_error_msg("bad file command");
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
addLines(num1);
|
||||
}
|
||||
cp = skip_blank(cp);
|
||||
if (*cp == '\0') {
|
||||
if (fileName)
|
||||
printf("\"%s\"\n", fileName);
|
||||
else
|
||||
printf("No file name\n");
|
||||
break;
|
||||
}
|
||||
free(fileName);
|
||||
fileName = xstrdup(cp);
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
cp = skip_blank(cp);
|
||||
if ((*cp < 'a') || (*cp > 'z') || cp[1]) {
|
||||
bb_error_msg("bad mark name");
|
||||
break;
|
||||
}
|
||||
marks[*cp - 'a'] = num2;
|
||||
case 'i':
|
||||
addLines(num1);
|
||||
break;
|
||||
|
||||
case 'k':
|
||||
cp = skip_blank(cp);
|
||||
if ((*cp < 'a') || (*cp > 'z') || cp[1]) {
|
||||
bb_error_msg("bad mark name");
|
||||
break;
|
||||
}
|
||||
marks[*cp - 'a'] = num2;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
printLines(num1, num2, TRUE);
|
||||
case 'l':
|
||||
printLines(num1, num2, TRUE);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
printLines(num1, num2, FALSE);
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
cp = skip_blank(cp);
|
||||
if (have1 || *cp) {
|
||||
bb_error_msg("bad quit command");
|
||||
break;
|
||||
}
|
||||
if (!dirty)
|
||||
return;
|
||||
len = read_line_input("Really quit? ", buf, 16, NULL);
|
||||
/* read error/EOF - no way to continue */
|
||||
if (len < 0)
|
||||
return;
|
||||
cp = skip_blank(buf);
|
||||
if ((*cp | 0x20) == 'y') /* Y or y */
|
||||
return;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
printLines(num1, num2, FALSE);
|
||||
case 'r':
|
||||
if (*cp && !isblank(*cp)) {
|
||||
bb_error_msg("bad read command");
|
||||
break;
|
||||
|
||||
case 'q':
|
||||
cp = skip_blank(cp);
|
||||
if (have1 || *cp) {
|
||||
bb_error_msg("bad quit command");
|
||||
break;
|
||||
}
|
||||
if (!dirty)
|
||||
return;
|
||||
len = read_line_input("Really quit? ", buf, 16, NULL);
|
||||
/* read error/EOF - no way to continue */
|
||||
if (len < 0)
|
||||
return;
|
||||
cp = skip_blank(buf);
|
||||
if ((*cp | 0x20) == 'y') /* Y or y */
|
||||
return;
|
||||
}
|
||||
cp = skip_blank(cp);
|
||||
if (*cp == '\0') {
|
||||
bb_error_msg("no file name");
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
if (*cp && !isblank(*cp)) {
|
||||
bb_error_msg("bad read command");
|
||||
break;
|
||||
}
|
||||
cp = skip_blank(cp);
|
||||
if (*cp == '\0') {
|
||||
bb_error_msg("no file name");
|
||||
break;
|
||||
}
|
||||
if (!have1)
|
||||
num1 = lastNum;
|
||||
if (readLines(cp, num1 + 1))
|
||||
break;
|
||||
if (fileName == NULL)
|
||||
fileName = strdup(cp);
|
||||
}
|
||||
if (!have1)
|
||||
num1 = lastNum;
|
||||
if (readLines(cp, num1 + 1))
|
||||
break;
|
||||
if (fileName == NULL)
|
||||
fileName = xstrdup(cp);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
subCommand(cp, num1, num2);
|
||||
case 's':
|
||||
subCommand(cp, num1, num2);
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
if (*cp && !isblank(*cp)) {
|
||||
bb_error_msg("bad write command");
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
if (*cp && !isblank(*cp)) {
|
||||
bb_error_msg("bad write command");
|
||||
break;
|
||||
}
|
||||
cp = skip_blank(cp);
|
||||
if (!have1) {
|
||||
num1 = 1;
|
||||
num2 = lastNum;
|
||||
}
|
||||
if (*cp == '\0')
|
||||
cp = fileName;
|
||||
if (cp == NULL) {
|
||||
bb_error_msg("no file name specified");
|
||||
break;
|
||||
}
|
||||
writeLines(cp, num1, num2);
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
switch (*cp) {
|
||||
case '-':
|
||||
printLines(curNum - 21, curNum, FALSE);
|
||||
break;
|
||||
case '.':
|
||||
printLines(curNum - 11, curNum + 10, FALSE);
|
||||
break;
|
||||
default:
|
||||
printLines(curNum, curNum + 21, FALSE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case '.':
|
||||
if (have1) {
|
||||
bb_error_msg("no arguments allowed");
|
||||
break;
|
||||
}
|
||||
printLines(curNum, curNum, FALSE);
|
||||
}
|
||||
cp = skip_blank(cp);
|
||||
if (!have1) {
|
||||
num1 = 1;
|
||||
num2 = lastNum;
|
||||
}
|
||||
if (*cp == '\0')
|
||||
cp = fileName;
|
||||
if (cp == NULL) {
|
||||
bb_error_msg("no file name specified");
|
||||
break;
|
||||
}
|
||||
writeLines(cp, num1, num2);
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
switch (*cp) {
|
||||
case '-':
|
||||
if (setCurNum(curNum - 1))
|
||||
printLines(curNum, curNum, FALSE);
|
||||
printLines(curNum - 21, curNum, FALSE);
|
||||
break;
|
||||
|
||||
case '=':
|
||||
printf("%d\n", num1);
|
||||
case '.':
|
||||
printLines(curNum - 11, curNum + 10, FALSE);
|
||||
break;
|
||||
case '\0':
|
||||
if (have1) {
|
||||
printLines(num2, num2, FALSE);
|
||||
break;
|
||||
}
|
||||
if (setCurNum(curNum + 1))
|
||||
printLines(curNum, curNum, FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
bb_error_msg("unimplemented command");
|
||||
printLines(curNum, curNum + 21, FALSE);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case '.':
|
||||
if (have1) {
|
||||
bb_error_msg("no arguments allowed");
|
||||
break;
|
||||
}
|
||||
printLines(curNum, curNum, FALSE);
|
||||
break;
|
||||
|
||||
case '-':
|
||||
if (setCurNum(curNum - 1))
|
||||
printLines(curNum, curNum, FALSE);
|
||||
break;
|
||||
|
||||
case '=':
|
||||
printf("%d\n", num1);
|
||||
break;
|
||||
case '\0':
|
||||
if (have1) {
|
||||
printLines(num2, num2, FALSE);
|
||||
break;
|
||||
}
|
||||
if (setCurNum(curNum + 1))
|
||||
printLines(curNum, curNum, FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
bb_error_msg("unimplemented command");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -830,7 +825,7 @@ static int printLines(int num1, int num2, int expandFlag)
|
||||
|
||||
while (num1 <= num2) {
|
||||
if (!expandFlag) {
|
||||
write(1, lp->data, lp->len);
|
||||
write(STDOUT_FILENO, lp->data, lp->len);
|
||||
setCurNum(num1++);
|
||||
lp = lp->next;
|
||||
continue;
|
||||
|
||||
+135
-152
@@ -19,253 +19,236 @@
|
||||
* - Reject file isnt saved
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
static unsigned int copy_lines(FILE *src_stream, FILE *dest_stream, const unsigned int lines_count)
|
||||
static unsigned copy_lines(FILE *src_stream, FILE *dst_stream, unsigned lines_count)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
while (src_stream && (i < lines_count)) {
|
||||
while (src_stream && lines_count) {
|
||||
char *line;
|
||||
line = xmalloc_fgets(src_stream);
|
||||
if (line == NULL) {
|
||||
break;
|
||||
}
|
||||
if (fputs(line, dest_stream) == EOF) {
|
||||
if (fputs(line, dst_stream) == EOF) {
|
||||
bb_perror_msg_and_die("error writing to new file");
|
||||
}
|
||||
free(line);
|
||||
|
||||
i++;
|
||||
lines_count--;
|
||||
}
|
||||
return i;
|
||||
return lines_count;
|
||||
}
|
||||
|
||||
/* If patch_level is -1 it will remove all directory names
|
||||
* char *line must be greater than 4 chars
|
||||
* returns NULL if the file doesnt exist or error
|
||||
* returns malloc'ed filename
|
||||
* NB: frees 1st argument!
|
||||
*/
|
||||
|
||||
static char *extract_filename(char *line, int patch_level)
|
||||
static char *extract_filename(char *line, int patch_level, const char *pat)
|
||||
{
|
||||
char *temp, *filename_start_ptr = line + 4;
|
||||
int i;
|
||||
char *temp = NULL, *filename_start_ptr = line + 4;
|
||||
|
||||
/* Terminate string at end of source filename */
|
||||
temp = strchrnul(filename_start_ptr, '\t');
|
||||
*temp = '\0';
|
||||
if (strncmp(line, pat, 4) == 0) {
|
||||
/* Terminate string at end of source filename */
|
||||
line[strcspn(line,"\t\n\r")] = '\0';
|
||||
|
||||
/* Skip over (patch_level) number of leading directories */
|
||||
if (patch_level == -1)
|
||||
patch_level = INT_MAX;
|
||||
for (i = 0; i < patch_level; i++) {
|
||||
temp = strchr(filename_start_ptr, '/');
|
||||
if (!temp)
|
||||
break;
|
||||
filename_start_ptr = temp + 1;
|
||||
/* Skip over (patch_level) number of leading directories */
|
||||
while (patch_level--) {
|
||||
temp = strchr(filename_start_ptr, '/');
|
||||
if (!temp)
|
||||
break;
|
||||
filename_start_ptr = temp + 1;
|
||||
}
|
||||
temp = xstrdup(filename_start_ptr);
|
||||
}
|
||||
|
||||
return xstrdup(filename_start_ptr);
|
||||
free(line);
|
||||
return temp;
|
||||
}
|
||||
|
||||
int patch_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int patch_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
{
|
||||
int patch_level = -1;
|
||||
char *patch_line;
|
||||
int ret;
|
||||
FILE *patch_file = NULL;
|
||||
struct stat saved_stat;
|
||||
|
||||
char *patch_line;
|
||||
FILE *patch_file;
|
||||
int patch_level;
|
||||
int ret = 0;
|
||||
char plus = '+';
|
||||
|
||||
xfunc_error_retval = 2;
|
||||
{
|
||||
char *p, *i;
|
||||
ret = getopt32(argv, "p:i:", &p, &i);
|
||||
if (ret & 1)
|
||||
patch_level = xatol_range(p, -1, USHRT_MAX);
|
||||
if (ret & 2) {
|
||||
patch_file = xfopen(i, "r");
|
||||
} else {
|
||||
patch_file = stdin;
|
||||
}
|
||||
ret = 0;
|
||||
const char *p = "-1";
|
||||
const char *i = "-"; /* compat */
|
||||
if (getopt32(argv, "p:i:R", &p, &i) & 4)
|
||||
plus = '-';
|
||||
patch_level = xatoi(p); /* can be negative! */
|
||||
patch_file = xfopen_stdin(i);
|
||||
}
|
||||
|
||||
patch_line = xmalloc_getline(patch_file);
|
||||
patch_line = xmalloc_fgetline(patch_file);
|
||||
while (patch_line) {
|
||||
FILE *src_stream;
|
||||
FILE *dst_stream;
|
||||
char *original_filename;
|
||||
//char *old_filename;
|
||||
char *new_filename;
|
||||
char *backup_filename;
|
||||
unsigned int src_cur_line = 1;
|
||||
unsigned int dest_cur_line = 0;
|
||||
unsigned int dest_beg_line;
|
||||
unsigned int bad_hunk_count = 0;
|
||||
unsigned int hunk_count = 0;
|
||||
char copy_trailing_lines_flag = 0;
|
||||
unsigned src_cur_line = 1;
|
||||
unsigned dst_cur_line = 0;
|
||||
unsigned dst_beg_line;
|
||||
unsigned bad_hunk_count = 0;
|
||||
unsigned hunk_count = 0;
|
||||
smallint copy_trailing_lines_flag = 0;
|
||||
|
||||
/* Skip everything upto the "---" marker
|
||||
* No need to parse the lines "Only in <dir>", and "diff <args>"
|
||||
*/
|
||||
while (patch_line && strncmp(patch_line, "--- ", 4) != 0) {
|
||||
free(patch_line);
|
||||
patch_line = xmalloc_getline(patch_file);
|
||||
}
|
||||
/* FIXME: patch_line NULL check?? */
|
||||
do {
|
||||
/* Extract the filename used before the patch was generated */
|
||||
new_filename = extract_filename(patch_line, patch_level, "--- ");
|
||||
// was old_filename above
|
||||
patch_line = xmalloc_fgetline(patch_file);
|
||||
if (!patch_line) goto quit;
|
||||
} while (!new_filename);
|
||||
free(new_filename); // "source" filename is irrelevant
|
||||
|
||||
/* Extract the filename used before the patch was generated */
|
||||
original_filename = extract_filename(patch_line, patch_level);
|
||||
free(patch_line);
|
||||
|
||||
patch_line = xmalloc_getline(patch_file);
|
||||
/* FIXME: NULL check?? */
|
||||
if (strncmp(patch_line, "+++ ", 4) != 0) {
|
||||
ret = 2;
|
||||
bb_error_msg("invalid patch");
|
||||
continue;
|
||||
new_filename = extract_filename(patch_line, patch_level, "+++ ");
|
||||
if (!new_filename) {
|
||||
bb_error_msg_and_die("invalid patch");
|
||||
}
|
||||
new_filename = extract_filename(patch_line, patch_level);
|
||||
free(patch_line);
|
||||
|
||||
/* Get access rights from the file to be patched, -1 file does not exist */
|
||||
if (stat(new_filename, &saved_stat)) {
|
||||
char *line_ptr;
|
||||
/* Create leading directories */
|
||||
line_ptr = strrchr(new_filename, '/');
|
||||
if (line_ptr) {
|
||||
*line_ptr = '\0';
|
||||
|
||||
/* Get access rights from the file to be patched */
|
||||
if (stat(new_filename, &saved_stat) != 0) {
|
||||
char *slash = strrchr(new_filename, '/');
|
||||
if (slash) {
|
||||
/* Create leading directories */
|
||||
*slash = '\0';
|
||||
bb_make_directory(new_filename, -1, FILEUTILS_RECUR);
|
||||
*line_ptr = '/';
|
||||
*slash = '/';
|
||||
}
|
||||
dst_stream = xfopen(new_filename, "w+");
|
||||
backup_filename = NULL;
|
||||
} else {
|
||||
backup_filename = xmalloc(strlen(new_filename) + 6);
|
||||
strcpy(backup_filename, new_filename);
|
||||
strcat(backup_filename, ".orig");
|
||||
xrename(new_filename, backup_filename);
|
||||
dst_stream = xfopen(new_filename, "w");
|
||||
fchmod(fileno(dst_stream), saved_stat.st_mode);
|
||||
}
|
||||
|
||||
if ((backup_filename == NULL) || stat(original_filename, &saved_stat)) {
|
||||
src_stream = NULL;
|
||||
saved_stat.st_mode = 0644;
|
||||
} else {
|
||||
if (strcmp(original_filename, new_filename) == 0) {
|
||||
src_stream = xfopen(backup_filename, "r");
|
||||
} else {
|
||||
src_stream = xfopen(original_filename, "r");
|
||||
}
|
||||
backup_filename = xasprintf("%s.orig", new_filename);
|
||||
xrename(new_filename, backup_filename);
|
||||
src_stream = xfopen(backup_filename, "r");
|
||||
}
|
||||
dst_stream = xfopen(new_filename, "w");
|
||||
fchmod(fileno(dst_stream), saved_stat.st_mode);
|
||||
|
||||
printf("patching file %s\n", new_filename);
|
||||
|
||||
/* Handle each hunk */
|
||||
/* Handle all hunks for this file */
|
||||
patch_line = xmalloc_fgets(patch_file);
|
||||
while (patch_line) {
|
||||
unsigned int count;
|
||||
unsigned int src_beg_line;
|
||||
unsigned int unused;
|
||||
unsigned int hunk_offset_start = 0;
|
||||
int hunk_error = 0;
|
||||
unsigned count;
|
||||
unsigned src_beg_line;
|
||||
unsigned hunk_offset_start;
|
||||
unsigned src_last_line = 1;
|
||||
unsigned dst_last_line = 1;
|
||||
|
||||
/* This bit should be improved */
|
||||
if ((sscanf(patch_line, "@@ -%d,%d +%d,%d @@", &src_beg_line, &unused, &dest_beg_line, &unused) != 4) &&
|
||||
(sscanf(patch_line, "@@ -%d,%d +%d @@", &src_beg_line, &unused, &dest_beg_line) != 3) &&
|
||||
(sscanf(patch_line, "@@ -%d +%d,%d @@", &src_beg_line, &dest_beg_line, &unused) != 3)) {
|
||||
if ((sscanf(patch_line, "@@ -%d,%d +%d,%d", &src_beg_line, &src_last_line, &dst_beg_line, &dst_last_line) < 3)
|
||||
&& (sscanf(patch_line, "@@ -%d +%d,%d", &src_beg_line, &dst_beg_line, &dst_last_line) < 2)
|
||||
) {
|
||||
/* No more hunks for this file */
|
||||
break;
|
||||
}
|
||||
free(patch_line);
|
||||
if (plus != '+') {
|
||||
/* reverse patch */
|
||||
unsigned tmp = src_last_line;
|
||||
src_last_line = dst_last_line;
|
||||
dst_last_line = tmp;
|
||||
tmp = src_beg_line;
|
||||
src_beg_line = dst_beg_line;
|
||||
dst_beg_line = tmp;
|
||||
}
|
||||
hunk_count++;
|
||||
|
||||
if (src_beg_line && dest_beg_line) {
|
||||
if (src_beg_line && dst_beg_line) {
|
||||
/* Copy unmodified lines upto start of hunk */
|
||||
/* src_beg_line will be 0 if its a new file */
|
||||
/* src_beg_line will be 0 if it's a new file */
|
||||
count = src_beg_line - src_cur_line;
|
||||
if (copy_lines(src_stream, dst_stream, count) != count) {
|
||||
if (copy_lines(src_stream, dst_stream, count)) {
|
||||
bb_error_msg_and_die("bad src file");
|
||||
}
|
||||
src_cur_line += count;
|
||||
dest_cur_line += count;
|
||||
dst_cur_line += count;
|
||||
copy_trailing_lines_flag = 1;
|
||||
}
|
||||
hunk_offset_start = src_cur_line;
|
||||
src_last_line += hunk_offset_start = src_cur_line;
|
||||
dst_last_line += dst_cur_line;
|
||||
|
||||
while ((patch_line = xmalloc_fgets(patch_file)) != NULL) {
|
||||
if ((*patch_line == '-') || (*patch_line == ' ')) {
|
||||
while (1) {
|
||||
free(patch_line);
|
||||
patch_line = xmalloc_fgets(patch_file);
|
||||
if (patch_line == NULL)
|
||||
break; /* EOF */
|
||||
if ((*patch_line != '-') && (*patch_line != '+')
|
||||
&& (*patch_line != ' ')
|
||||
) {
|
||||
break; /* End of hunk */
|
||||
}
|
||||
if (*patch_line != plus) { /* '-' or ' ' */
|
||||
char *src_line = NULL;
|
||||
if (src_cur_line == src_last_line)
|
||||
break;
|
||||
if (src_stream) {
|
||||
src_line = xmalloc_fgets(src_stream);
|
||||
if (!src_line) {
|
||||
hunk_error++;
|
||||
break;
|
||||
} else {
|
||||
if (src_line) {
|
||||
int diff = strcmp(src_line, patch_line + 1);
|
||||
src_cur_line++;
|
||||
free(src_line);
|
||||
if (diff)
|
||||
src_line = NULL;
|
||||
}
|
||||
if (strcmp(src_line, patch_line + 1) != 0) {
|
||||
bb_error_msg("hunk #%d FAILED at %d", hunk_count, hunk_offset_start);
|
||||
hunk_error++;
|
||||
free(patch_line);
|
||||
/* Probably need to find next hunk, etc... */
|
||||
/* but for now we just bail out */
|
||||
patch_line = NULL;
|
||||
break;
|
||||
}
|
||||
free(src_line);
|
||||
}
|
||||
if (*patch_line == ' ') {
|
||||
fputs(patch_line + 1, dst_stream);
|
||||
dest_cur_line++;
|
||||
if (!src_line) {
|
||||
bb_error_msg("hunk #%u FAILED at %u", hunk_count, hunk_offset_start);
|
||||
bad_hunk_count++;
|
||||
break;
|
||||
}
|
||||
if (*patch_line != ' ') { /* '-' */
|
||||
continue;
|
||||
}
|
||||
} else if (*patch_line == '+') {
|
||||
fputs(patch_line + 1, dst_stream);
|
||||
dest_cur_line++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
free(patch_line);
|
||||
}
|
||||
if (hunk_error) {
|
||||
bad_hunk_count++;
|
||||
}
|
||||
}
|
||||
if (dst_cur_line == dst_last_line)
|
||||
break;
|
||||
fputs(patch_line + 1, dst_stream);
|
||||
dst_cur_line++;
|
||||
} /* end of while loop handling one hunk */
|
||||
} /* end of while loop handling one file */
|
||||
|
||||
/* Cleanup last patched file */
|
||||
if (copy_trailing_lines_flag) {
|
||||
copy_lines(src_stream, dst_stream, -1);
|
||||
copy_lines(src_stream, dst_stream, (unsigned)(-1));
|
||||
}
|
||||
if (src_stream) {
|
||||
fclose(src_stream);
|
||||
}
|
||||
if (dst_stream) {
|
||||
fclose(dst_stream);
|
||||
}
|
||||
fclose(dst_stream);
|
||||
if (bad_hunk_count) {
|
||||
if (!ret) {
|
||||
ret = 1;
|
||||
}
|
||||
bb_error_msg("%d out of %d hunk FAILED", bad_hunk_count, hunk_count);
|
||||
ret = 1;
|
||||
bb_error_msg("%u out of %u hunk FAILED", bad_hunk_count, hunk_count);
|
||||
} else {
|
||||
/* It worked, we can remove the backup */
|
||||
if (backup_filename) {
|
||||
unlink(backup_filename);
|
||||
}
|
||||
if ((dest_cur_line == 0) || (dest_beg_line == 0)) {
|
||||
if ((dst_cur_line == 0) || (dst_beg_line == 0)) {
|
||||
/* The new patched file is empty, remove it */
|
||||
xunlink(new_filename);
|
||||
if (strcmp(new_filename, original_filename) != 0)
|
||||
xunlink(original_filename);
|
||||
// /* old_filename and new_filename may be the same file */
|
||||
// unlink(old_filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(backup_filename);
|
||||
//free(old_filename);
|
||||
free(new_filename);
|
||||
} /* end of "while there are patch lines" */
|
||||
quit:
|
||||
/* 0 = SUCCESS
|
||||
* 1 = Some hunks failed
|
||||
* 2 = More serious problems
|
||||
* 2 = More serious problems (exited earlier)
|
||||
*/
|
||||
return ret;
|
||||
}
|
||||
+8
-10
@@ -628,7 +628,7 @@ static int do_subst_command(sed_cmd_t *sed_cmd, char **line)
|
||||
{
|
||||
char *oldline = *line;
|
||||
int altered = 0;
|
||||
int match_count = 0;
|
||||
unsigned match_count = 0;
|
||||
regex_t *current_regex;
|
||||
|
||||
/* Handle empty regex. */
|
||||
@@ -665,7 +665,9 @@ static int do_subst_command(sed_cmd_t *sed_cmd, char **line)
|
||||
|
||||
/* If we aren't interested in this match, output old line to
|
||||
end of match and continue */
|
||||
if (sed_cmd->which_match && sed_cmd->which_match != match_count) {
|
||||
if (sed_cmd->which_match
|
||||
&& (sed_cmd->which_match != match_count)
|
||||
) {
|
||||
for (i = 0; i < G.regmatch[0].rm_eo; i++)
|
||||
pipe_putc(*oldline++);
|
||||
continue;
|
||||
@@ -1028,7 +1030,7 @@ static void process_files(void)
|
||||
if (rfile) {
|
||||
char *line;
|
||||
|
||||
while ((line = xmalloc_getline(rfile))
|
||||
while ((line = xmalloc_fgetline(rfile))
|
||||
!= NULL)
|
||||
append(line);
|
||||
xprint_and_close_file(rfile);
|
||||
@@ -1265,21 +1267,17 @@ int sed_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
if (opt & 0x2) G.regex_type |= REG_EXTENDED; // -r
|
||||
//if (opt & 0x4) G.be_quiet++; // -n
|
||||
while (opt_e) { // -e
|
||||
add_cmd_block(opt_e->data);
|
||||
opt_e = opt_e->link;
|
||||
/* we leak opt_e here... */
|
||||
add_cmd_block(llist_pop(&opt_e));
|
||||
}
|
||||
while (opt_f) { // -f
|
||||
char *line;
|
||||
FILE *cmdfile;
|
||||
cmdfile = xfopen(opt_f->data, "r");
|
||||
while ((line = xmalloc_getline(cmdfile)) != NULL) {
|
||||
cmdfile = xfopen(llist_pop(&opt_f), "r");
|
||||
while ((line = xmalloc_fgetline(cmdfile)) != NULL) {
|
||||
add_cmd(line);
|
||||
free(line);
|
||||
}
|
||||
fclose(cmdfile);
|
||||
opt_f = opt_f->link;
|
||||
/* we leak opt_f here... */
|
||||
}
|
||||
/* if we didn't get a pattern from -e or -f, use argv[0] */
|
||||
if (!(opt & 0x18)) {
|
||||
|
||||
+214
-183
@@ -112,11 +112,19 @@ enum {
|
||||
S_END_ALNUM = 5, // used in skip_thing() for moving "dot"
|
||||
};
|
||||
|
||||
|
||||
/* vi.c expects chars to be unsigned. */
|
||||
/* busybox build system provides that, but it's better */
|
||||
/* to audit and fix the source */
|
||||
|
||||
static smallint vi_setops;
|
||||
struct globals {
|
||||
/* many references - keep near the top of globals */
|
||||
char *text, *end; // pointers to the user data in memory
|
||||
char *dot; // where all the action takes place
|
||||
int text_size; // size of the allocated buffer
|
||||
|
||||
/* the rest */
|
||||
smallint vi_setops;
|
||||
#define VI_AUTOINDENT 1
|
||||
#define VI_SHOWMATCH 2
|
||||
#define VI_IGNORECASE 4
|
||||
@@ -127,83 +135,76 @@ static smallint vi_setops;
|
||||
/* indicate error with beep or flash */
|
||||
#define err_method (vi_setops & VI_ERR_METHOD)
|
||||
|
||||
|
||||
static smallint editing; // >0 while we are editing a file
|
||||
// [code audit says "can be 0 or 1 only"]
|
||||
static smallint cmd_mode; // 0=command 1=insert 2=replace
|
||||
static smallint file_modified; // buffer contents changed
|
||||
static smallint last_file_modified = -1;
|
||||
static int fn_start; // index of first cmd line file name
|
||||
static int save_argc; // how many file names on cmd line
|
||||
static int cmdcnt; // repetition count
|
||||
static int rows, columns; // the terminal screen is this size
|
||||
static int crow, ccol; // cursor is on Crow x Ccol
|
||||
static int offset; // chars scrolled off the screen to the left
|
||||
static char *status_buffer; // mesages to the user
|
||||
#define STATUS_BUFFER_LEN 200
|
||||
static int have_status_msg; // is default edit status needed?
|
||||
// [don't make smallint!]
|
||||
static int last_status_cksum; // hash of current status line
|
||||
static char *current_filename; // current file name
|
||||
//static char *text, *end; // pointers to the user data in memory
|
||||
static char *screen; // pointer to the virtual screen buffer
|
||||
static int screensize; // and its size
|
||||
static char *screenbegin; // index into text[], of top line on the screen
|
||||
//static char *dot; // where all the action takes place
|
||||
static int tabstop;
|
||||
static char erase_char; // the users erase character
|
||||
static char last_input_char; // last char read from user
|
||||
static char last_forward_char; // last char searched for with 'f'
|
||||
|
||||
#if ENABLE_FEATURE_VI_READONLY
|
||||
//static smallint vi_readonly, readonly;
|
||||
static smallint readonly_mode = 0;
|
||||
smallint readonly_mode;
|
||||
#define SET_READONLY_FILE(flags) ((flags) |= 0x01)
|
||||
#define SET_READONLY_MODE(flags) ((flags) |= 0x02)
|
||||
#define UNSET_READONLY_FILE(flags) ((flags) &= 0xfe)
|
||||
#else
|
||||
#define readonly_mode 0
|
||||
#define SET_READONLY_FILE(flags)
|
||||
#define SET_READONLY_MODE(flags)
|
||||
#define UNSET_READONLY_FILE(flags)
|
||||
#define SET_READONLY_FILE(flags) ((void)0)
|
||||
#define SET_READONLY_MODE(flags) ((void)0)
|
||||
#define UNSET_READONLY_FILE(flags) ((void)0)
|
||||
#endif
|
||||
|
||||
smallint editing; // >0 while we are editing a file
|
||||
// [code audit says "can be 0, 1 or 2 only"]
|
||||
smallint cmd_mode; // 0=command 1=insert 2=replace
|
||||
int file_modified; // buffer contents changed (counter, not flag!)
|
||||
int last_file_modified; // = -1;
|
||||
int fn_start; // index of first cmd line file name
|
||||
int save_argc; // how many file names on cmd line
|
||||
int cmdcnt; // repetition count
|
||||
unsigned rows, columns; // the terminal screen is this size
|
||||
int crow, ccol; // cursor is on Crow x Ccol
|
||||
int offset; // chars scrolled off the screen to the left
|
||||
int have_status_msg; // is default edit status needed?
|
||||
// [don't make smallint!]
|
||||
int last_status_cksum; // hash of current status line
|
||||
char *current_filename;
|
||||
char *screenbegin; // index into text[], of top line on the screen
|
||||
char *screen; // pointer to the virtual screen buffer
|
||||
int screensize; // and its size
|
||||
int tabstop;
|
||||
char erase_char; // the users erase character
|
||||
char last_input_char; // last char read from user
|
||||
char last_forward_char; // last char searched for with 'f'
|
||||
|
||||
#if ENABLE_FEATURE_VI_DOT_CMD
|
||||
static smallint adding2q; // are we currently adding user input to q
|
||||
static char *last_modifying_cmd; // [MAX_INPUT_LEN] last modifying cmd for "."
|
||||
static smallint lmc_len; // length of last_modifying_cmd
|
||||
static char *ioq, *ioq_start; // pointer to string for get_one_char to "read"
|
||||
smallint adding2q; // are we currently adding user input to q
|
||||
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
|
||||
static int last_row; // where the cursor was last moved to
|
||||
int last_row; // where the cursor was last moved to
|
||||
#endif
|
||||
#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME
|
||||
static int my_pid;
|
||||
int my_pid;
|
||||
#endif
|
||||
#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
|
||||
static char *modifying_cmds; // cmds that modify text[]
|
||||
char *modifying_cmds; // cmds that modify text[]
|
||||
#endif
|
||||
#if ENABLE_FEATURE_VI_SEARCH
|
||||
static char *last_search_pattern; // last pattern from a '/' or '?' search
|
||||
char *last_search_pattern; // last pattern from a '/' or '?' search
|
||||
#endif
|
||||
int chars_to_parse;
|
||||
/* former statics */
|
||||
#if ENABLE_FEATURE_VI_YANKMARK
|
||||
char *edit_file__cur_line;
|
||||
#endif
|
||||
int refresh__old_offset;
|
||||
int format_edit_status__tot;
|
||||
|
||||
/* Moving biggest data to malloced space... */
|
||||
struct globals {
|
||||
/* many references - keep near the top of globals */
|
||||
char *text, *end; // pointers to the user data in memory
|
||||
char *dot; // where all the action takes place
|
||||
int text_size; // size of the allocated buffer
|
||||
/* a few references only */
|
||||
#if ENABLE_FEATURE_VI_YANKMARK
|
||||
int YDreg, Ureg; // default delete register and orig line for "U"
|
||||
char *reg[28]; // named register a-z, "D", and "U" 0-25,26,27
|
||||
char *mark[28]; // user marks points somewhere in text[]- a-z and previous context ''
|
||||
char *context_start, *context_end;
|
||||
#endif
|
||||
/* a few references only */
|
||||
#if ENABLE_FEATURE_VI_USE_SIGNALS
|
||||
sigjmp_buf restart; // catch_sig()
|
||||
sigjmp_buf restart; // catch_sig()
|
||||
#endif
|
||||
struct termios term_orig, term_vi; // remember what the cooked mode was
|
||||
struct termios term_orig, term_vi; // remember what the cooked mode was
|
||||
#if ENABLE_FEATURE_VI_COLON
|
||||
char *initial_cmds[3]; // currently 2 entries, NULL terminated
|
||||
#endif
|
||||
@@ -214,6 +215,12 @@ struct globals {
|
||||
#else
|
||||
char readbuffer[32];
|
||||
#endif
|
||||
#define STATUS_BUFFER_LEN 200
|
||||
char status_buffer[STATUS_BUFFER_LEN]; // messages to the user
|
||||
#if ENABLE_FEATURE_VI_DOT_CMD
|
||||
char last_modifying_cmd[MAX_INPUT_LEN]; // last modifying cmd for "."
|
||||
#endif
|
||||
char get_input_line__buf[MAX_INPUT_LEN]; /* former static */
|
||||
|
||||
char scr_out_buf[MAX_SCR_COLS + MAX_TABSTOP * 2];
|
||||
};
|
||||
@@ -223,6 +230,50 @@ struct globals {
|
||||
#define end (G.end )
|
||||
#define dot (G.dot )
|
||||
#define reg (G.reg )
|
||||
|
||||
#define vi_setops (G.vi_setops )
|
||||
#define editing (G.editing )
|
||||
#define cmd_mode (G.cmd_mode )
|
||||
#define file_modified (G.file_modified )
|
||||
#define last_file_modified (G.last_file_modified )
|
||||
#define fn_start (G.fn_start )
|
||||
#define save_argc (G.save_argc )
|
||||
#define cmdcnt (G.cmdcnt )
|
||||
#define rows (G.rows )
|
||||
#define columns (G.columns )
|
||||
#define crow (G.crow )
|
||||
#define ccol (G.ccol )
|
||||
#define offset (G.offset )
|
||||
#define status_buffer (G.status_buffer )
|
||||
#define have_status_msg (G.have_status_msg )
|
||||
#define last_status_cksum (G.last_status_cksum )
|
||||
#define current_filename (G.current_filename )
|
||||
#define screen (G.screen )
|
||||
#define screensize (G.screensize )
|
||||
#define screenbegin (G.screenbegin )
|
||||
#define tabstop (G.tabstop )
|
||||
#define erase_char (G.erase_char )
|
||||
#define last_input_char (G.last_input_char )
|
||||
#define last_forward_char (G.last_forward_char )
|
||||
#if ENABLE_FEATURE_VI_READONLY
|
||||
#define readonly_mode (G.readonly_mode )
|
||||
#else
|
||||
#define readonly_mode 0
|
||||
#endif
|
||||
#define adding2q (G.adding2q )
|
||||
#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 modifying_cmds (G.modifying_cmds )
|
||||
#define last_search_pattern (G.last_search_pattern)
|
||||
#define chars_to_parse (G.chars_to_parse )
|
||||
|
||||
#define edit_file__cur_line (G.edit_file__cur_line)
|
||||
#define refresh__old_offset (G.refresh__old_offset)
|
||||
#define format_edit_status__tot (G.format_edit_status__tot)
|
||||
|
||||
#define YDreg (G.YDreg )
|
||||
#define Ureg (G.Ureg )
|
||||
#define mark (G.mark )
|
||||
@@ -234,10 +285,15 @@ struct globals {
|
||||
#define initial_cmds (G.initial_cmds )
|
||||
#define readbuffer (G.readbuffer )
|
||||
#define scr_out_buf (G.scr_out_buf )
|
||||
#define last_modifying_cmd (G.last_modifying_cmd )
|
||||
#define get_input_line__buf (G.get_input_line__buf)
|
||||
|
||||
#define INIT_G() do { \
|
||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
||||
last_file_modified = -1; \
|
||||
} while (0)
|
||||
|
||||
|
||||
static int init_text_buffer(char *); // init from file or create new
|
||||
static void edit_file(char *); // edit one file
|
||||
static void do_cmd(char); // execute a command
|
||||
@@ -355,22 +411,15 @@ int vi_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int vi_main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
RESERVE_CONFIG_BUFFER(STATUS_BUFFER, STATUS_BUFFER_LEN);
|
||||
|
||||
INIT_G();
|
||||
|
||||
#if ENABLE_FEATURE_VI_USE_SIGNALS || ENABLE_FEATURE_VI_CRASHME
|
||||
my_pid = getpid();
|
||||
#endif
|
||||
|
||||
INIT_G();
|
||||
|
||||
#if ENABLE_FEATURE_VI_CRASHME
|
||||
srand((long) my_pid);
|
||||
#endif
|
||||
|
||||
status_buffer = STATUS_BUFFER;
|
||||
last_status_cksum = 0;
|
||||
text = NULL;
|
||||
|
||||
#ifdef NO_SUCH_APPLET_YET
|
||||
/* If we aren't "vi", we are "view" */
|
||||
if (ENABLE_FEATURE_VI_READONLY && applet_name[2]) {
|
||||
@@ -379,9 +428,6 @@ int vi_main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
vi_setops = VI_AUTOINDENT | VI_SHOWMATCH | VI_IGNORECASE;
|
||||
#if ENABLE_FEATURE_VI_YANKMARK
|
||||
memset(reg, 0, sizeof(reg)); // init the yank regs
|
||||
#endif
|
||||
#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
|
||||
modifying_cmds = (char *) "aAcCdDiIJoOpPrRsxX<>~"; // cmds modifying text[]
|
||||
#endif
|
||||
@@ -417,9 +463,8 @@ int vi_main(int argc, char **argv)
|
||||
case 'H':
|
||||
show_help();
|
||||
/* fall through */
|
||||
|
||||
default:
|
||||
bb_show_usage();
|
||||
bb_show_usage();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -451,9 +496,7 @@ static int init_text_buffer(char *fn)
|
||||
|
||||
/* allocate/reallocate text buffer */
|
||||
free(text);
|
||||
text_size = size * 2;
|
||||
if (text_size < 10240)
|
||||
text_size = 10240; // have a minimum size for new files
|
||||
text_size = size + 10240;
|
||||
screenbegin = dot = end = text = xzalloc(text_size);
|
||||
|
||||
if (fn != current_filename) {
|
||||
@@ -479,15 +522,14 @@ static int init_text_buffer(char *fn)
|
||||
|
||||
static void edit_file(char *fn)
|
||||
{
|
||||
#if ENABLE_FEATURE_VI_YANKMARK
|
||||
#define cur_line edit_file__cur_line
|
||||
#endif
|
||||
char c;
|
||||
int size;
|
||||
|
||||
#if ENABLE_FEATURE_VI_USE_SIGNALS
|
||||
int sig;
|
||||
#endif
|
||||
#if ENABLE_FEATURE_VI_YANKMARK
|
||||
static char *cur_line;
|
||||
#endif
|
||||
|
||||
editing = 1; // 0 = exit, 1 = one file, 2 = multiple files
|
||||
rawmode();
|
||||
@@ -581,7 +623,7 @@ static void edit_file(char *fn)
|
||||
// These are commands that change text[].
|
||||
// Remember the input for the "." command
|
||||
if (!adding2q && ioq_start == NULL
|
||||
&& strchr(modifying_cmds, c)
|
||||
&& c != '\0' && strchr(modifying_cmds, c)
|
||||
) {
|
||||
start_new_cmd_q(c);
|
||||
}
|
||||
@@ -603,9 +645,10 @@ static void edit_file(char *fn)
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
place_cursor(rows, 0, FALSE); // go to bottom of screen
|
||||
clear_to_eol(); // Erase to end of line
|
||||
place_cursor(rows - 1, 0, FALSE); // go to bottom of screen
|
||||
clear_to_eol(); // erase to end of line
|
||||
cookmode();
|
||||
#undef cur_line
|
||||
}
|
||||
|
||||
//----- The Colon commands -------------------------------------
|
||||
@@ -1081,7 +1124,7 @@ static void colon(char *buf)
|
||||
}
|
||||
#endif /* FEATURE_VI_SEARCH */
|
||||
} else if (strncasecmp(cmd, "version", i) == 0) { // show software version
|
||||
status_line("%s", BB_VER " " BB_BT);
|
||||
status_line(BB_VER " " BB_BT);
|
||||
} else if (strncasecmp(cmd, "write", i) == 0 // write text to file
|
||||
|| strncasecmp(cmd, "wq", i) == 0
|
||||
|| strncasecmp(cmd, "wn", i) == 0
|
||||
@@ -1231,9 +1274,8 @@ static void sync_cursor(char *d, int *row, int *col)
|
||||
// handle tabs like real vi
|
||||
if (d == tp && cmd_mode) {
|
||||
break;
|
||||
} else {
|
||||
co = next_tabstop(co);
|
||||
}
|
||||
co = next_tabstop(co);
|
||||
} else if ((unsigned char)*tp < ' ' || *tp == 0x7f) {
|
||||
co++; // display as ^X, use 2 columns
|
||||
}
|
||||
@@ -1283,7 +1325,7 @@ static char *begin_line(char *p) // return pointer to first char cur line
|
||||
return p;
|
||||
}
|
||||
|
||||
static char *end_line(char *p) // return pointer to NL of cur line line
|
||||
static char *end_line(char *p) // return pointer to NL of cur line
|
||||
{
|
||||
if (p < end - 1) {
|
||||
p = memchr(p, '\n', end - p - 1);
|
||||
@@ -1305,7 +1347,7 @@ static char *dollar_line(char *p) // return pointer to just before NL line
|
||||
static char *prev_line(char *p) // return pointer first char prev line
|
||||
{
|
||||
p = begin_line(p); // goto begining of cur line
|
||||
if (p[-1] == '\n' && p > text)
|
||||
if (p > text && p[-1] == '\n')
|
||||
p--; // step to prev line
|
||||
p = begin_line(p); // goto begining of prev line
|
||||
return p;
|
||||
@@ -1314,7 +1356,7 @@ static char *prev_line(char *p) // return pointer first char prev line
|
||||
static char *next_line(char *p) // return pointer first char next line
|
||||
{
|
||||
p = end_line(p);
|
||||
if (*p == '\n' && p < end - 1)
|
||||
if (p < end - 1 && *p == '\n')
|
||||
p++; // step to next line
|
||||
return p;
|
||||
}
|
||||
@@ -1497,7 +1539,7 @@ static char *new_screen(int ro, int co)
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_VI_SEARCH
|
||||
static int mycmp(const char * s1, const char * s2, int len)
|
||||
static int mycmp(const char *s1, const char *s2, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1509,7 +1551,7 @@ static int mycmp(const char * s1, const char * s2, int len)
|
||||
}
|
||||
|
||||
// search for pattern starting at p
|
||||
static char *char_search(char * p, const char * pat, int dir, int range)
|
||||
static char *char_search(char *p, const char *pat, int dir, int range)
|
||||
{
|
||||
#ifndef REGEX_SEARCH
|
||||
char *start, *stop;
|
||||
@@ -1602,7 +1644,7 @@ static char *char_search(char * p, const char * pat, int dir, int range)
|
||||
}
|
||||
#endif /* FEATURE_VI_SEARCH */
|
||||
|
||||
static char *char_insert(char * p, char c) // insert the char c at 'p'
|
||||
static char *char_insert(char *p, char c) // insert the char c at 'p'
|
||||
{
|
||||
if (c == 22) { // Is this an ctrl-V?
|
||||
p = stupid_insert(p, '^'); // use ^ to indicate literal next
|
||||
@@ -1611,7 +1653,7 @@ static char *char_insert(char * p, char c) // insert the char c at 'p'
|
||||
c = get_one_char();
|
||||
*p = c;
|
||||
p++;
|
||||
file_modified++; // has the file been modified
|
||||
file_modified++;
|
||||
} else if (c == 27) { // Is this an ESC?
|
||||
cmd_mode = 0;
|
||||
cmdcnt = 0;
|
||||
@@ -1651,18 +1693,15 @@ static char *char_insert(char * p, char c) // insert the char c at 'p'
|
||||
return p;
|
||||
}
|
||||
|
||||
static char *stupid_insert(char * p, char c) // stupidly insert the char c at 'p'
|
||||
static char *stupid_insert(char *p, char c) // stupidly insert the char c at 'p'
|
||||
{
|
||||
p = text_hole_make(p, 1);
|
||||
if (p != 0) {
|
||||
*p = c;
|
||||
file_modified++; // has the file been modified
|
||||
p++;
|
||||
}
|
||||
return p;
|
||||
*p = c;
|
||||
//file_modified++; - done by text_hole_make()
|
||||
return p + 1;
|
||||
}
|
||||
|
||||
static int find_range(char ** start, char ** stop, char c)
|
||||
static int find_range(char **start, char **stop, char c)
|
||||
{
|
||||
char *save_dot, *p, *q, *t;
|
||||
int cnt, multiline = 0;
|
||||
@@ -1718,7 +1757,7 @@ static int find_range(char ** start, char ** stop, char c)
|
||||
p = t;
|
||||
}
|
||||
|
||||
// backward char movements don't include start position
|
||||
// backward char movements don't include start position
|
||||
if (q > p && strchr("^0bBh\b\177", c)) q--;
|
||||
|
||||
multiline = 0;
|
||||
@@ -1735,7 +1774,7 @@ static int find_range(char ** start, char ** stop, char c)
|
||||
return multiline;
|
||||
}
|
||||
|
||||
static int st_test(char * p, int type, int dir, char * tested)
|
||||
static int st_test(char *p, int type, int dir, char *tested)
|
||||
{
|
||||
char c, c0, ci;
|
||||
int test, inc;
|
||||
@@ -1769,7 +1808,7 @@ static int st_test(char * p, int type, int dir, char * tested)
|
||||
return test;
|
||||
}
|
||||
|
||||
static char *skip_thing(char * p, int linecnt, int dir, int type)
|
||||
static char *skip_thing(char *p, int linecnt, int dir, int type)
|
||||
{
|
||||
char c;
|
||||
|
||||
@@ -1787,7 +1826,7 @@ static char *skip_thing(char * p, int linecnt, int dir, int type)
|
||||
}
|
||||
|
||||
// find matching char of pair () [] {}
|
||||
static char *find_pair(char * p, const char c)
|
||||
static char *find_pair(char *p, const char c)
|
||||
{
|
||||
char match, *q;
|
||||
int dir, level;
|
||||
@@ -1840,31 +1879,29 @@ static void showmatching(char *p)
|
||||
#endif /* FEATURE_VI_SETOPTS */
|
||||
|
||||
// open a hole in text[]
|
||||
static char *text_hole_make(char * p, int size) // at "p", make a 'size' byte hole
|
||||
static char *text_hole_make(char *p, int size) // at "p", make a 'size' byte hole
|
||||
{
|
||||
char *src, *dest;
|
||||
int cnt;
|
||||
|
||||
if (size <= 0)
|
||||
goto thm0;
|
||||
src = p;
|
||||
dest = p + size;
|
||||
cnt = end - src; // the rest of buffer
|
||||
if ( ((end + size) >= (text + text_size)) // TODO: realloc here
|
||||
|| memmove(dest, src, cnt) != dest) {
|
||||
status_line_bold("can't create room for new characters");
|
||||
p = NULL;
|
||||
goto thm0;
|
||||
}
|
||||
memset(p, ' ', size); // clear new hole
|
||||
return p;
|
||||
end += size; // adjust the new END
|
||||
file_modified++; // has the file been modified
|
||||
thm0:
|
||||
if (end >= (text + text_size)) {
|
||||
char *new_text;
|
||||
text_size += end - (text + text_size) + 10240;
|
||||
new_text = xrealloc(text, text_size);
|
||||
screenbegin = new_text + (screenbegin - text);
|
||||
dot = new_text + (dot - text);
|
||||
end = new_text + (end - text);
|
||||
p = new_text + (p - text);
|
||||
text = new_text;
|
||||
}
|
||||
memmove(p + size, p, end - size - p);
|
||||
memset(p, ' ', size); // clear new hole
|
||||
file_modified++;
|
||||
return p;
|
||||
}
|
||||
|
||||
// close a hole in text[]
|
||||
static char *text_hole_delete(char * p, char * q) // delete "p" through "q", inclusive
|
||||
static char *text_hole_delete(char *p, char *q) // delete "p" through "q", inclusive
|
||||
{
|
||||
char *src, *dest;
|
||||
int cnt, hole_size;
|
||||
@@ -1885,16 +1922,14 @@ static char *text_hole_delete(char * p, char * q) // delete "p" through "q", inc
|
||||
goto thd0;
|
||||
if (src >= end)
|
||||
goto thd_atend; // just delete the end of the buffer
|
||||
if (memmove(dest, src, cnt) != dest) {
|
||||
status_line_bold("can't delete the character");
|
||||
}
|
||||
memmove(dest, src, cnt);
|
||||
thd_atend:
|
||||
end = end - hole_size; // adjust the new END
|
||||
if (dest >= end)
|
||||
dest = end - 1; // make sure dest in below end-1
|
||||
if (end <= text)
|
||||
dest = end = text; // keep pointers valid
|
||||
file_modified++; // has the file been modified
|
||||
file_modified++;
|
||||
thd0:
|
||||
return dest;
|
||||
}
|
||||
@@ -1902,7 +1937,7 @@ static char *text_hole_delete(char * p, char * q) // delete "p" through "q", inc
|
||||
// copy text into register, then delete text.
|
||||
// if dist <= 0, do not include, or go past, a NewLine
|
||||
//
|
||||
static char *yank_delete(char * start, char * stop, int dist, int yf)
|
||||
static char *yank_delete(char *start, char *stop, int dist, int yf)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@@ -1973,12 +2008,10 @@ static void show_help(void)
|
||||
static void start_new_cmd_q(char c)
|
||||
{
|
||||
// get buffer for new cmd
|
||||
if (!last_modifying_cmd)
|
||||
last_modifying_cmd = xzalloc(MAX_INPUT_LEN);
|
||||
// if there is a current cmd count put it in the buffer first
|
||||
if (cmdcnt > 0)
|
||||
if (cmdcnt > 0) {
|
||||
lmc_len = sprintf(last_modifying_cmd, "%d%c", cmdcnt, c);
|
||||
else { // just save char c onto queue
|
||||
} else { // just save char c onto queue
|
||||
last_modifying_cmd[0] = c;
|
||||
lmc_len = 1;
|
||||
}
|
||||
@@ -1997,27 +2030,26 @@ static void end_cmd_q(void)
|
||||
#if ENABLE_FEATURE_VI_YANKMARK \
|
||||
|| (ENABLE_FEATURE_VI_COLON && ENABLE_FEATURE_VI_SEARCH) \
|
||||
|| ENABLE_FEATURE_VI_CRASHME
|
||||
static char *string_insert(char * p, char * s) // insert the string at 'p'
|
||||
static char *string_insert(char *p, char *s) // insert the string at 'p'
|
||||
{
|
||||
int cnt, i;
|
||||
|
||||
i = strlen(s);
|
||||
if (text_hole_make(p, i)) {
|
||||
strncpy(p, s, i);
|
||||
for (cnt = 0; *s != '\0'; s++) {
|
||||
if (*s == '\n')
|
||||
cnt++;
|
||||
}
|
||||
#if ENABLE_FEATURE_VI_YANKMARK
|
||||
status_line("Put %d lines (%d chars) from [%c]", cnt, i, what_reg());
|
||||
#endif
|
||||
text_hole_make(p, i);
|
||||
strncpy(p, s, i);
|
||||
for (cnt = 0; *s != '\0'; s++) {
|
||||
if (*s == '\n')
|
||||
cnt++;
|
||||
}
|
||||
#if ENABLE_FEATURE_VI_YANKMARK
|
||||
status_line("Put %d lines (%d chars) from [%c]", cnt, i, what_reg());
|
||||
#endif
|
||||
return p;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_VI_YANKMARK
|
||||
static char *text_yank(char * p, char * q, int dest) // copy text into a register
|
||||
static char *text_yank(char *p, char *q, int dest) // copy text into a register
|
||||
{
|
||||
char *t;
|
||||
int cnt;
|
||||
@@ -2164,8 +2196,6 @@ static int mysleep(int hund) // sleep for 'h' 1/100 seconds
|
||||
return safe_poll(pfd, 1, hund*10) > 0;
|
||||
}
|
||||
|
||||
static int chars_to_parse;
|
||||
|
||||
//----- IO Routines --------------------------------------------
|
||||
static char readit(void) // read (maybe cursor) key from stdin
|
||||
{
|
||||
@@ -2217,18 +2247,20 @@ static char readit(void) // read (maybe cursor) key from stdin
|
||||
|
||||
fflush(stdout);
|
||||
n = chars_to_parse;
|
||||
// get input from User- are there already input chars in Q?
|
||||
// get input from User - are there already input chars in Q?
|
||||
if (n <= 0) {
|
||||
// the Q is empty, wait for a typed char
|
||||
n = safe_read(0, readbuffer, sizeof(readbuffer));
|
||||
if (n < 0) {
|
||||
if (errno == EBADF || errno == EFAULT || errno == EINVAL
|
||||
|| errno == EIO)
|
||||
editing = 0; // want to exit
|
||||
errno = 0;
|
||||
again:
|
||||
n = safe_read(STDIN_FILENO, readbuffer, sizeof(readbuffer));
|
||||
if (n <= 0) {
|
||||
place_cursor(rows - 1, 0, FALSE); // go to bottom of screen
|
||||
clear_to_eol(); // erase to end of line
|
||||
cookmode(); // terminal to "cooked"
|
||||
bb_error_msg_and_die("can't read user input");
|
||||
}
|
||||
if (n <= 0)
|
||||
return 0; // error
|
||||
/* elsewhere we can get very confused by NULs */
|
||||
if (readbuffer[0] == '\0')
|
||||
goto again;
|
||||
if (readbuffer[0] == 27) {
|
||||
// This is an ESC char. Is this Esc sequence?
|
||||
// Could be bare Esc key. See if there are any
|
||||
@@ -2239,9 +2271,11 @@ static char readit(void) // read (maybe cursor) key from stdin
|
||||
pfd[0].events = POLLIN;
|
||||
// keep reading while there are input chars, and room in buffer
|
||||
// for a complete ESC sequence (assuming 8 chars is enough)
|
||||
while (safe_poll(pfd, 1, 0) > 0 && n <= (sizeof(readbuffer) - 8)) {
|
||||
while ((safe_poll(pfd, 1, 0) > 0)
|
||||
&& ((size_t)n <= (sizeof(readbuffer) - 8))
|
||||
) {
|
||||
// read the rest of the ESC string
|
||||
int r = safe_read(0, readbuffer + n, sizeof(readbuffer) - n);
|
||||
int r = safe_read(STDIN_FILENO, readbuffer + n, sizeof(readbuffer) - n);
|
||||
if (r > 0)
|
||||
n += r;
|
||||
}
|
||||
@@ -2298,13 +2332,11 @@ static char get_one_char(void)
|
||||
} else {
|
||||
// adding STDIN chars to q
|
||||
c = readit(); // get the users input
|
||||
if (last_modifying_cmd != NULL) {
|
||||
if (lmc_len >= MAX_INPUT_LEN - 1) {
|
||||
status_line_bold("last_modifying_cmd overrun");
|
||||
} else {
|
||||
// add new char to q
|
||||
last_modifying_cmd[lmc_len++] = c;
|
||||
}
|
||||
if (lmc_len >= MAX_INPUT_LEN - 1) {
|
||||
status_line_bold("last_modifying_cmd overrun");
|
||||
} else {
|
||||
// add new char to q
|
||||
last_modifying_cmd[lmc_len++] = c;
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -2316,13 +2348,12 @@ static char get_one_char(void)
|
||||
// Get input line (uses "status line" area)
|
||||
static char *get_input_line(const char *prompt)
|
||||
{
|
||||
static char *buf; // [MAX_INPUT_LEN]
|
||||
// char [MAX_INPUT_LEN]
|
||||
#define buf get_input_line__buf
|
||||
|
||||
char c;
|
||||
int i;
|
||||
|
||||
if (!buf) buf = xmalloc(MAX_INPUT_LEN);
|
||||
|
||||
strcpy(buf, prompt);
|
||||
last_status_cksum = 0; // force status update
|
||||
place_cursor(rows - 1, 0, FALSE); // go to Status line, bottom of screen
|
||||
@@ -2348,6 +2379,7 @@ static char *get_input_line(const char *prompt)
|
||||
}
|
||||
refresh(FALSE);
|
||||
return buf;
|
||||
#undef buf
|
||||
}
|
||||
|
||||
static int file_size(const char *fn) // what is the byte size of "fn"
|
||||
@@ -2361,7 +2393,7 @@ static int file_size(const char *fn) // what is the byte size of "fn"
|
||||
return cnt;
|
||||
}
|
||||
|
||||
static int file_insert(const char * fn, char *p
|
||||
static int file_insert(const char *fn, char *p
|
||||
USE_FEATURE_VI_READONLY(, int update_ro_status))
|
||||
{
|
||||
int cnt = -1;
|
||||
@@ -2373,18 +2405,11 @@ static int file_insert(const char * fn, char *p
|
||||
status_line_bold("\"%s\" %s", fn, strerror(errno));
|
||||
goto fi0;
|
||||
}
|
||||
if ((statbuf.st_mode & S_IFREG) == 0) {
|
||||
if (!S_ISREG(statbuf.st_mode)) {
|
||||
// This is not a regular file
|
||||
status_line_bold("\"%s\" Not a regular file", fn);
|
||||
goto fi0;
|
||||
}
|
||||
/* // this check is done by open()
|
||||
if ((statbuf.st_mode & (S_IRUSR | S_IRGRP | S_IROTH)) == 0) {
|
||||
// dont have any read permissions
|
||||
status_line_bold("\"%s\" Not readable", fn);
|
||||
goto fi0;
|
||||
}
|
||||
*/
|
||||
if (p < text || p > end) {
|
||||
status_line_bold("Trying to insert file outside of memory");
|
||||
goto fi0;
|
||||
@@ -2398,8 +2423,6 @@ static int file_insert(const char * fn, char *p
|
||||
}
|
||||
size = statbuf.st_size;
|
||||
p = text_hole_make(p, size);
|
||||
if (p == NULL)
|
||||
goto fi0;
|
||||
cnt = safe_read(fd, p, size);
|
||||
if (cnt < 0) {
|
||||
status_line_bold("\"%s\" %s", fn, strerror(errno));
|
||||
@@ -2427,8 +2450,7 @@ static int file_insert(const char * fn, char *p
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
static int file_write(char * fn, char * first, char * last)
|
||||
static int file_write(char *fn, char *first, char *last)
|
||||
{
|
||||
int fd, cnt, charcnt;
|
||||
|
||||
@@ -2437,14 +2459,19 @@ static int file_write(char * fn, char * first, char * last)
|
||||
return -2;
|
||||
}
|
||||
charcnt = 0;
|
||||
fd = open(fn, (O_WRONLY | O_CREAT | O_TRUNC), 0666);
|
||||
/* By popular request we do not open file with O_TRUNC,
|
||||
* but instead ftruncate() it _after_ successful write.
|
||||
* Might reduce amount of data lost on power fail etc.
|
||||
*/
|
||||
fd = open(fn, (O_WRONLY | O_CREAT), 0666);
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
cnt = last - first + 1;
|
||||
charcnt = full_write(fd, first, cnt);
|
||||
ftruncate(fd, charcnt);
|
||||
if (charcnt == cnt) {
|
||||
// good write
|
||||
//file_modified = FALSE; // the file has not been modified
|
||||
//file_modified = FALSE;
|
||||
} else {
|
||||
charcnt = 0;
|
||||
}
|
||||
@@ -2694,8 +2721,10 @@ static void not_implemented(const char *s)
|
||||
// show file status on status line
|
||||
static int format_edit_status(void)
|
||||
{
|
||||
static int tot;
|
||||
static const char cmd_mode_indicator[] ALIGN1 = "-IR-";
|
||||
|
||||
#define tot format_edit_status__tot
|
||||
|
||||
int cur, percent, ret, trunc_at;
|
||||
|
||||
// file_modified is now a counter rather than a flag. this
|
||||
@@ -2746,13 +2775,14 @@ static int format_edit_status(void)
|
||||
return ret; /* it all fit */
|
||||
|
||||
return trunc_at; /* had to truncate */
|
||||
#undef tot
|
||||
}
|
||||
|
||||
//----- Force refresh of all Lines -----------------------------
|
||||
static void redraw(int full_screen)
|
||||
{
|
||||
place_cursor(0, 0, FALSE); // put cursor in correct place
|
||||
clear_to_eos(); // tel terminal to erase display
|
||||
clear_to_eos(); // tell terminal to erase display
|
||||
screen_erase(); // erase the internal screen buffer
|
||||
last_status_cksum = 0; // force status update
|
||||
refresh(full_screen); // this will redraw the entire display
|
||||
@@ -2824,13 +2854,13 @@ static char* format_line(char *src /*, int li*/)
|
||||
//
|
||||
static void refresh(int full_screen)
|
||||
{
|
||||
static int old_offset;
|
||||
#define old_offset refresh__old_offset
|
||||
|
||||
int li, changed;
|
||||
char *tp, *sp; // pointer into text[] and screen[]
|
||||
|
||||
if (ENABLE_FEATURE_VI_WIN_RESIZE) {
|
||||
int c = columns, r = rows;
|
||||
unsigned c = columns, r = rows;
|
||||
get_terminal_width_height(0, &columns, &rows);
|
||||
if (rows > MAX_SCR_ROWS) rows = MAX_SCR_ROWS;
|
||||
if (columns > MAX_SCR_COLS) columns = MAX_SCR_COLS;
|
||||
@@ -2912,6 +2942,7 @@ static void refresh(int full_screen)
|
||||
place_cursor(crow, ccol, TRUE);
|
||||
|
||||
old_offset = offset;
|
||||
#undef old_offset
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
@@ -3269,7 +3300,7 @@ static void do_cmd(char c)
|
||||
case '.': // .- repeat the last modifying command
|
||||
// Stuff the last_modifying_cmd back into stdin
|
||||
// and let it be re-executed.
|
||||
if (last_modifying_cmd != NULL && lmc_len > 0) {
|
||||
if (lmc_len > 0) {
|
||||
last_modifying_cmd[lmc_len] = 0;
|
||||
ioq = ioq_start = xstrdup(last_modifying_cmd);
|
||||
}
|
||||
@@ -3743,7 +3774,7 @@ static void do_cmd(char c)
|
||||
c1 = get_one_char(); // get the replacement char
|
||||
if (*dot != '\n') {
|
||||
*dot = c1;
|
||||
file_modified++; // has the file been modified
|
||||
file_modified++;
|
||||
}
|
||||
end_cmd_q(); // stop adding to q
|
||||
break;
|
||||
@@ -3788,10 +3819,10 @@ static void do_cmd(char c)
|
||||
} // repeat cnt
|
||||
if (islower(*dot)) {
|
||||
*dot = toupper(*dot);
|
||||
file_modified++; // has the file been modified
|
||||
file_modified++;
|
||||
} else if (isupper(*dot)) {
|
||||
*dot = tolower(*dot);
|
||||
file_modified++; // has the file been modified
|
||||
file_modified++;
|
||||
}
|
||||
dot_right();
|
||||
end_cmd_q(); // stop adding to q
|
||||
@@ -4028,7 +4059,7 @@ static void crash_test()
|
||||
printf("\n\n%d: \'%c\' %s\n\n\n%s[Hit return to continue]%s",
|
||||
totalcmds, last_input_char, msg, SOs, SOn);
|
||||
fflush(stdout);
|
||||
while (safe_read(0, d, 1) > 0) {
|
||||
while (safe_read(STDIN_FILENO, d, 1) > 0) {
|
||||
if (d[0] == '\n' || d[0] == '\r')
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Simple depmod, use to generate modprobe.conf
|
||||
#
|
||||
# Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
|
||||
#
|
||||
# Licensed under GPLv2
|
||||
#
|
||||
|
||||
local BASE="${1:-/usr/lib/modules}"
|
||||
|
||||
find "$BASE" -name '*.ko.gz' | while read I ; do
|
||||
N=`basename "$I" '.ko.gz'`
|
||||
echo -n "@$N"
|
||||
zcat "$I" | strings | grep '^depends=' | sed -e 's/^depends=$//' -e 's/^depends=/,/' -e 's/,/ @/g'
|
||||
done | awk '
|
||||
{
|
||||
# modules which has no dependencies are resolved
|
||||
if ( NF == 1 ) { res[$1] = ""; next }
|
||||
# others have to be resolved based on those which already resolved
|
||||
i = $1; $1 = ""; deps[i] = $0; ++ndeps
|
||||
}
|
||||
END {
|
||||
# resolve implicit dependencies
|
||||
while ( ndeps ) for (mod in deps) {
|
||||
if ( index(deps[mod], "@") > 0 ) {
|
||||
$0 = deps[mod]
|
||||
for ( i=1; i<=NF; ++i ) {
|
||||
if ( substr($i,1,1) == "@" ) {
|
||||
if ( $i in res ) {
|
||||
$i = res[$i] " " substr($i,2)
|
||||
}
|
||||
}
|
||||
}
|
||||
deps[mod] = $0
|
||||
} else {
|
||||
res[mod] = deps[mod]
|
||||
delete deps[mod]
|
||||
--ndeps
|
||||
}
|
||||
}
|
||||
|
||||
# output dependencies in modules.dep format
|
||||
for ( mod in res ) {
|
||||
$0 = res[mod]
|
||||
s = ""
|
||||
delete a
|
||||
for ( i=1; i<=NF; ++i ) {
|
||||
if ( ! ($i in a) ) {
|
||||
a[$i] = $i
|
||||
s = " ," $i s
|
||||
}
|
||||
}
|
||||
print "," substr(mod,2) ":" s
|
||||
}
|
||||
}
|
||||
' | sort | sed -r -e "s!,([^,: ]*)!/usr/lib/modules/\\1.ko.gz!g"
|
||||
Loaded 100 of 453 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user