Compare commits
518
Commits
1_20_2
...
1_22_stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28dd64a0e1 | ||
|
|
5698ff9323 | ||
|
|
d9e0c438e1 | ||
|
|
a2dd4ee0e8 | ||
|
|
7625811d25 | ||
|
|
198b02f7dd | ||
|
|
61be8e46a8 | ||
|
|
e83e1c50f2 | ||
|
|
e85e260e47 | ||
|
|
c9d87bed8e | ||
|
|
80a068d741 | ||
|
|
e9355c4326 | ||
|
|
4967a41ba1 | ||
|
|
4b26f82c78 | ||
|
|
3ac1e0d753 | ||
|
|
9f4f60183b | ||
|
|
22bb81fa85 | ||
|
|
0b3a38b9f5 | ||
|
|
777be10ebe | ||
|
|
6c46eed6e9 | ||
|
|
a14958c69d | ||
|
|
cb1dc1d1d1 | ||
|
|
327f550669 | ||
|
|
9b2a9f0210 | ||
|
|
1a7256ac38 | ||
|
|
72745632a1 | ||
|
|
df0d2cd837 | ||
|
|
deb0769b26 | ||
|
|
259b3c047a | ||
|
|
8bd810bd27 | ||
|
|
d9fc4d8f92 | ||
|
|
195c436f84 | ||
|
|
760fc6debc | ||
|
|
cffe28ef87 | ||
|
|
4d8ad381ab | ||
|
|
924a179cb7 | ||
|
|
26ad256bd0 | ||
|
|
71f6c1aa43 | ||
|
|
bd0e221620 | ||
|
|
2635369a92 | ||
|
|
0545e3b69a | ||
|
|
dd1d8ab506 | ||
|
|
1cbc642bed | ||
|
|
ebfa9b5aa1 | ||
|
|
8b59b2c13e | ||
|
|
6ef7729112 | ||
|
|
9c1c605b1a | ||
|
|
f6beef63c6 | ||
|
|
ac21687309 | ||
|
|
36184a487d | ||
|
|
66620fa626 | ||
|
|
73225b6d6e | ||
|
|
f200f732f4 | ||
|
|
cd0936be36 | ||
|
|
d3092c99ae | ||
|
|
087843a65b | ||
|
|
afa63b2dcd | ||
|
|
5e63776212 | ||
|
|
b1489f97e0 | ||
|
|
140f4e3511 | ||
|
|
1d39e33d46 | ||
|
|
80f8cdf04a | ||
|
|
200c1c46f4 | ||
|
|
b541d1fcbd | ||
|
|
8d3efaf35e | ||
|
|
b21bc80c76 | ||
|
|
18b461925c | ||
|
|
17f4aca556 | ||
|
|
c44539fcd3 | ||
|
|
a82e32d9ce | ||
|
|
9d46a7a9a4 | ||
|
|
af0cdeedc6 | ||
|
|
2d576e2a22 | ||
|
|
af4f0e48ec | ||
|
|
28a209466f | ||
|
|
64938011f3 | ||
|
|
840ef17f63 | ||
|
|
5117eff6f9 | ||
|
|
eba5faec67 | ||
|
|
d074b416f8 | ||
|
|
730e4d8b52 | ||
|
|
7985bc109e | ||
|
|
1d30b3f1f6 | ||
|
|
5906a5c26c | ||
|
|
932e233a49 | ||
|
|
cd256e1c40 | ||
|
|
3eab2b7675 | ||
|
|
054f3eb784 | ||
|
|
a6ed6a3148 | ||
|
|
d7ea34ee71 | ||
|
|
32ed30d96b | ||
|
|
fbe250db76 | ||
|
|
b5352078a7 | ||
|
|
a613aa1b4c | ||
|
|
2a053a2430 | ||
|
|
dc57294485 | ||
|
|
a407cf74cc | ||
|
|
d6ae4fb446 | ||
|
|
deebdf59b5 | ||
|
|
1b9ac21166 | ||
|
|
0ff0b320a2 | ||
|
|
1b57fe108f | ||
|
|
f3114a3bd0 | ||
|
|
90e9cfd218 | ||
|
|
4502bb1f21 | ||
|
|
5b9910f0a4 | ||
|
|
e66a56de23 | ||
|
|
7a18043a96 | ||
|
|
8395bd3f52 | ||
|
|
b941316ae5 | ||
|
|
4b1896cd2c | ||
|
|
ec2bef11a7 | ||
|
|
9f07af6156 | ||
|
|
d2e07bc16c | ||
|
|
73fbe9dc86 | ||
|
|
fc364ba9e3 | ||
|
|
6761d7da83 | ||
|
|
9ae6d79307 | ||
|
|
456687fff1 | ||
|
|
8c7fcbd752 | ||
|
|
a5e6c6cd3b | ||
|
|
543efd7b4b | ||
|
|
aadb485bd0 | ||
|
|
adc30b4cf9 | ||
|
|
985345d002 | ||
|
|
da331d779c | ||
|
|
cc1c9ca6f8 | ||
|
|
9369634167 | ||
|
|
a060a1ad96 | ||
|
|
e418b2e7bb | ||
|
|
15d0a860e9 | ||
|
|
3b45801dc6 | ||
|
|
982e87f2fb | ||
|
|
bfa6ed1bf4 | ||
|
|
79c618c411 | ||
|
|
d0bc708cb5 | ||
|
|
05965cbb75 | ||
|
|
2ead5316b4 | ||
|
|
2641426187 | ||
|
|
fd3ac96c0f | ||
|
|
ffeeb7a96c | ||
|
|
ca54b662e7 | ||
|
|
ad546ec606 | ||
|
|
9078633fee | ||
|
|
7801148a81 | ||
|
|
688a7e3f04 | ||
|
|
c19be75d57 | ||
|
|
b855460adc | ||
|
|
b0e9b72915 | ||
|
|
26cd90c7fd | ||
|
|
1390a010b6 | ||
|
|
5e87e8aebb | ||
|
|
a7ecbed56b | ||
|
|
9b58fe9c0b | ||
|
|
25ce3ee9f3 | ||
|
|
c72b43c2f0 | ||
|
|
0dacb68e1a | ||
|
|
e95738f635 | ||
|
|
d87fcd4888 | ||
|
|
40ab27a225 | ||
|
|
e93d15613e | ||
|
|
d8f6d8c627 | ||
|
|
2301d127a2 | ||
|
|
4f9fc1e5f5 | ||
|
|
6651e42609 | ||
|
|
cd8eece88e | ||
|
|
3e7ecb179b | ||
|
|
ea267d518f | ||
|
|
1bf560e9c3 | ||
|
|
16614e9bab | ||
|
|
e9b3fcc3e4 | ||
|
|
f798ba9717 | ||
|
|
65bdf0b737 | ||
|
|
f86404f773 | ||
|
|
173aa78bcf | ||
|
|
26a7e2ecbf | ||
|
|
59f46676a9 | ||
|
|
4928e9f7d0 | ||
|
|
879f008a8f | ||
|
|
d66eb9042d | ||
|
|
1f5e81f8f8 | ||
|
|
f6205c6ab7 | ||
|
|
fea2588021 | ||
|
|
5a7e3376b7 | ||
|
|
07c5987498 | ||
|
|
5ffdd1d981 | ||
|
|
d99ef636f6 | ||
|
|
b6dc13c2d3 | ||
|
|
9cb1e2f86b | ||
|
|
f958425451 | ||
|
|
ae0cf2a9d7 | ||
|
|
e9581b673c | ||
|
|
b443a3780d | ||
|
|
c133fa66f3 | ||
|
|
6db5f679a2 | ||
|
|
5fc0585c01 | ||
|
|
aa94130f74 | ||
|
|
414db791d0 | ||
|
|
e0a6ab698f | ||
|
|
6782f48ccb | ||
|
|
c3cf1e30a3 | ||
|
|
ff463a885d | ||
|
|
abbc478f1c | ||
|
|
f76fd17d74 | ||
|
|
041baf2720 | ||
|
|
264f37363d | ||
|
|
d96ffda62e | ||
|
|
3beab83e4f | ||
|
|
d35cbad0ef | ||
|
|
2df1c64f38 | ||
|
|
e306c11367 | ||
|
|
2c0508b4fa | ||
|
|
8172d054db | ||
|
|
1d14569a66 | ||
|
|
8f2cb7ab26 | ||
|
|
6c852bfcad | ||
|
|
2c24806bf4 | ||
|
|
ef6747e290 | ||
|
|
80a38ca11c | ||
|
|
85daa67bc2 | ||
|
|
c608731e78 | ||
|
|
a42f530e03 | ||
|
|
e82bfef839 | ||
|
|
4a732220e9 | ||
|
|
236f222cde | ||
|
|
a8ba0a0d0c | ||
|
|
06ad964ae6 | ||
|
|
95e99e5271 | ||
|
|
14285d14a5 | ||
|
|
7c6f2d4207 | ||
|
|
4424dfd69b | ||
|
|
c56d12505b | ||
|
|
091f831424 | ||
|
|
88b532d59a | ||
|
|
4ef1439c59 | ||
|
|
aeb717aa5e | ||
|
|
9e7c002182 | ||
|
|
cb5aa725df | ||
|
|
257a77568a | ||
|
|
4a600f8777 | ||
|
|
45dc96c8a6 | ||
|
|
0d61dcd641 | ||
|
|
af4a07a244 | ||
|
|
7b5d5c1bdb | ||
|
|
e3f5b73ad0 | ||
|
|
b79a0fef99 | ||
|
|
7991d45446 | ||
|
|
1b49c25e0a | ||
|
|
af9e70b8cb | ||
|
|
445e7543e8 | ||
|
|
bca5c556c4 | ||
|
|
9bbf6b98c4 | ||
|
|
93b51819cf | ||
|
|
507f6ea6d2 | ||
|
|
a2d04e0702 | ||
|
|
c09fd27c0a | ||
|
|
2fe5fed2df | ||
|
|
08e28e806d | ||
|
|
920c1baab7 | ||
|
|
fb03663619 | ||
|
|
41655438c6 | ||
|
|
8e96efa323 | ||
|
|
f2d8478e56 | ||
|
|
577235dee8 | ||
|
|
7794c21daf | ||
|
|
216e952fb8 | ||
|
|
47f8558eee | ||
|
|
ed954b6855 | ||
|
|
efd0698f74 | ||
|
|
5d1c599d76 | ||
|
|
de6f148006 | ||
|
|
a14f319805 | ||
|
|
bc0ffc0e97 | ||
|
|
1e43a381b2 | ||
|
|
0496e824a5 | ||
|
|
f59d563399 | ||
|
|
46031da862 | ||
|
|
380c8a0763 | ||
|
|
433757413f | ||
|
|
c3045edec2 | ||
|
|
a1ae2b75a7 | ||
|
|
efb800439f | ||
|
|
aada3126a7 | ||
|
|
b967e42b77 | ||
|
|
18714d8460 | ||
|
|
9056fcecbf | ||
|
|
3a7b2417f9 | ||
|
|
04f296b28a | ||
|
|
e3e321682c | ||
|
|
5bce135e36 | ||
|
|
9fed24c031 | ||
|
|
39b8fb41c5 | ||
|
|
40b97fb31e | ||
|
|
1961aea305 | ||
|
|
3305c008ed | ||
|
|
40c6da433f | ||
|
|
af0255f496 | ||
|
|
8e6a1ea825 | ||
|
|
d4d4f3528e | ||
|
|
2aec773688 | ||
|
|
10f5f9b10d | ||
|
|
cf5731bcbd | ||
|
|
1bd5ca2f53 | ||
|
|
272d85cc85 | ||
|
|
b5fc51198b | ||
|
|
ba76b7a40b | ||
|
|
06af569f44 | ||
|
|
a8816dafc4 | ||
|
|
6e29d07417 | ||
|
|
04ac6e03c3 | ||
|
|
03b614739b | ||
|
|
6be6f3bfec | ||
|
|
17d4436424 | ||
|
|
ee3bc70cea | ||
|
|
243e733001 | ||
|
|
bf99807657 | ||
|
|
9b7ebfe644 | ||
|
|
778794d1dd | ||
|
|
6aab061d2d | ||
|
|
f474dfa681 | ||
|
|
64406a92a0 | ||
|
|
0cfba07fcd | ||
|
|
4609f477c7 | ||
|
|
31dc8603ee | ||
|
|
2f5b5beb28 | ||
|
|
81fa999540 | ||
|
|
2cfcc9e9d7 | ||
|
|
9980707efc | ||
|
|
9daf33fc52 | ||
|
|
7c4b13e019 | ||
|
|
5d78355d5a | ||
|
|
5ca853e5da | ||
|
|
20c5e5a626 | ||
|
|
e4f0f26bad | ||
|
|
5368fe541c | ||
|
|
406ea15e2c | ||
|
|
970aa6b5bd | ||
|
|
8fb3ab528e | ||
|
|
8e7312e12f | ||
|
|
5b7f50f372 | ||
|
|
ac4100e103 | ||
|
|
a55df27936 | ||
|
|
07a54e21dd | ||
|
|
6830ade6aa | ||
|
|
30a8652fbf | ||
|
|
60cb48ca50 | ||
|
|
b8173b603f | ||
|
|
b7841cf7b9 | ||
|
|
90801dadfa | ||
|
|
6928d9f049 | ||
|
|
6967578728 | ||
|
|
5218515508 | ||
|
|
07b419dbcb | ||
|
|
a58f7b7d2f | ||
|
|
cd776cf967 | ||
|
|
d189b598b4 | ||
|
|
3917fa32dc | ||
|
|
fb499c5752 | ||
|
|
a38f9faa9f | ||
|
|
12677acf0a | ||
|
|
393c395ca5 | ||
|
|
4d5955e9ec | ||
|
|
a8461173ba | ||
|
|
c71547ccfc | ||
|
|
4ba6c5d3ba | ||
|
|
e4b9451413 | ||
|
|
3f21044f20 | ||
|
|
a803bfa0f0 | ||
|
|
11181335f9 | ||
|
|
d2d5049c1d | ||
|
|
5694afd72a | ||
|
|
67dc7b21ca | ||
|
|
3aeb870b22 | ||
|
|
98f6b2d399 | ||
|
|
da0200a1e5 | ||
|
|
eab343e7e1 | ||
|
|
8dc6d1a813 | ||
|
|
fd77ea505e | ||
|
|
32711c4141 | ||
|
|
d527588882 | ||
|
|
f47ce07b26 | ||
|
|
1c7a58dfb8 | ||
|
|
d109798882 | ||
|
|
b2320370be | ||
|
|
9371043698 | ||
|
|
225cc1327a | ||
|
|
c4f2d997a4 | ||
|
|
73a1990897 | ||
|
|
06a98e32ae | ||
|
|
0b4980c252 | ||
|
|
ffe03f04cb | ||
|
|
42be921d48 | ||
|
|
2fb8d0dee9 | ||
|
|
3c62bbae94 | ||
|
|
0ffd63ca9a | ||
|
|
57f07bfcb2 | ||
|
|
aca464ddac | ||
|
|
6d463de46b | ||
|
|
2dc1a97272 | ||
|
|
9e71e3cea5 | ||
|
|
50157f3dec | ||
|
|
c439851438 | ||
|
|
d1d794fd48 | ||
|
|
9b80b903c7 | ||
|
|
b7812ce0f7 | ||
|
|
168f87c531 | ||
|
|
5f10fdf1dd | ||
|
|
c5a9fa2d2a | ||
|
|
8019b3a7ae | ||
|
|
11f2c0d4f8 | ||
|
|
405dafffbb | ||
|
|
a0fd4a789c | ||
|
|
41f7885f06 | ||
|
|
9c55143bbf | ||
|
|
45c35e9de0 | ||
|
|
dba7094d62 | ||
|
|
6567edd10b | ||
|
|
4919565c15 | ||
|
|
2ffd710656 | ||
|
|
ca81a93722 | ||
|
|
293c94564c | ||
|
|
0e941d5427 | ||
|
|
5cfb818181 | ||
|
|
71045cc819 | ||
|
|
d3a42391b1 | ||
|
|
32f774cd34 | ||
|
|
e565383fd5 | ||
|
|
37a79c092e | ||
|
|
dbed6c4b46 | ||
|
|
df8066a78c | ||
|
|
e1db338a51 | ||
|
|
3bb858765e | ||
|
|
566a313a7f | ||
|
|
b5c7220e7b | ||
|
|
5345b8db8b | ||
|
|
c5fe9f7b72 | ||
|
|
9ad8979ff1 | ||
|
|
ea664dde87 | ||
|
|
440a509849 | ||
|
|
d52c9510fd | ||
|
|
6ebb2b6b24 | ||
|
|
a396ade9f8 | ||
|
|
c9a13116a4 | ||
|
|
9ee4266490 | ||
|
|
1d7ad7a022 | ||
|
|
2bc495e4c4 | ||
|
|
dac8e79a19 | ||
|
|
e3e0d2b812 | ||
|
|
9b78e14dfb | ||
|
|
aacd448601 | ||
|
|
e0a6004ce8 | ||
|
|
6144124aac | ||
|
|
c5b01016e6 | ||
|
|
604499e5a9 | ||
|
|
bf146b8610 | ||
|
|
f5abc78579 | ||
|
|
ac42e3de90 | ||
|
|
6979325592 | ||
|
|
772f17a843 | ||
|
|
ac164dd2a7 | ||
|
|
70fc8c17e2 | ||
|
|
588e284f53 | ||
|
|
39f82d4309 | ||
|
|
0ccae4d8b3 | ||
|
|
d3dff879f0 | ||
|
|
04b52892ed | ||
|
|
4125a6b630 | ||
|
|
0a393cf7da | ||
|
|
93c32f2dd2 | ||
|
|
605f2641d8 | ||
|
|
c9677ed83c | ||
|
|
bd01f22986 | ||
|
|
3645195377 | ||
|
|
a1ec841913 | ||
|
|
64f763b42a | ||
|
|
49b8e72012 | ||
|
|
52de9c7141 | ||
|
|
cfc212cdff | ||
|
|
f451b2cfe0 | ||
|
|
37ca36a711 | ||
|
|
ba1d561d76 | ||
|
|
84406e459b | ||
|
|
c35545a100 | ||
|
|
21f6fbf545 | ||
|
|
21f620f6e5 | ||
|
|
085b293338 | ||
|
|
02112d8ae3 | ||
|
|
dfc2473b9e | ||
|
|
6e9284db78 | ||
|
|
25cb5aae2b | ||
|
|
aaf827203d | ||
|
|
0446104137 | ||
|
|
b6beada5a1 | ||
|
|
ea57f51819 | ||
|
|
8d11854678 | ||
|
|
516530c932 | ||
|
|
7c8aa2b47c | ||
|
|
0133921726 | ||
|
|
be1cfeea2e | ||
|
|
4a6a56c778 | ||
|
|
02b8b9b014 | ||
|
|
a5ee090e86 | ||
|
|
f1f8fcaad5 | ||
|
|
3698ed1ca1 | ||
|
|
8c3439554a | ||
|
|
44642d1ec1 | ||
|
|
556ac3633c | ||
|
|
3da46c8163 | ||
|
|
d133144d41 | ||
|
|
576b1d3c41 | ||
|
|
0c62f20454 | ||
|
|
deee356a62 | ||
|
|
9d75370238 | ||
|
|
eced0c78a5 | ||
|
|
b84dafb5e5 | ||
|
|
e39afe1fbd | ||
|
|
3a9365e273 | ||
|
|
b9d494453d |
No files matched your search
@@ -161,12 +161,13 @@ config UNICODE_USING_LOCALE
|
||||
Internal implementation is smaller.
|
||||
|
||||
config FEATURE_CHECK_UNICODE_IN_ENV
|
||||
bool "Check $LANG environment variable"
|
||||
bool "Check $LC_ALL, $LC_CTYPE and $LANG environment variables"
|
||||
default n
|
||||
depends on UNICODE_SUPPORT && !UNICODE_USING_LOCALE
|
||||
help
|
||||
With this option on, Unicode support is activated
|
||||
only if LANG variable has the value of the form "xxxx.utf8"
|
||||
only if locale-related variables have the value of the form
|
||||
"xxxx.utf8"
|
||||
|
||||
Otherwise, Unicode support will be always enabled and active.
|
||||
|
||||
@@ -310,7 +311,18 @@ config FEATURE_PIDFILE
|
||||
default y
|
||||
help
|
||||
This option makes some applets (e.g. crond, syslogd, inetd) write
|
||||
a pidfile in /var/run. Some applications rely on them.
|
||||
a pidfile at the configured PID_FILE_PATH. It has no effect
|
||||
on applets which require pidfiles to run.
|
||||
|
||||
config PID_FILE_PATH
|
||||
string "Path to directory for pidfile"
|
||||
default "/var/run"
|
||||
depends on FEATURE_PIDFILE
|
||||
help
|
||||
This is the default path where pidfiles are created. Applets which
|
||||
allow you to set the pidfile path on the command line will override
|
||||
this value. The option has no effect on applets that require you to
|
||||
specify a pidfile path.
|
||||
|
||||
config FEATURE_SUID
|
||||
bool "Support for SUID/SGID handling"
|
||||
@@ -321,7 +333,7 @@ config FEATURE_SUID
|
||||
root-level operations even when run by ordinary users
|
||||
(for example, mounting of user mounts in fstab needs this).
|
||||
|
||||
Busybox will automatically drop priviledges for applets
|
||||
Busybox will automatically drop privileges for applets
|
||||
that don't need root access.
|
||||
|
||||
If you are really paranoid and don't want to do this, build two
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 20
|
||||
SUBLEVEL = 0
|
||||
PATCHLEVEL = 22
|
||||
SUBLEVEL = 1
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
@@ -297,6 +297,7 @@ NM = $(CROSS_COMPILE)nm
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
OBJCOPY = $(CROSS_COMPILE)objcopy
|
||||
OBJDUMP = $(CROSS_COMPILE)objdump
|
||||
PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
|
||||
AWK = awk
|
||||
GENKSYMS = scripts/genksyms/genksyms
|
||||
DEPMOD = /sbin/depmod
|
||||
|
||||
+10
-1
@@ -3,7 +3,12 @@
|
||||
# ==========================================================================
|
||||
|
||||
busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h include/applets.h
|
||||
$(Q)-$(SHELL) $^ >$@
|
||||
$(Q)-$(SHELL) $^ > $@
|
||||
|
||||
busybox.cfg.suid: $(srctree)/applets/busybox.mksuid $(objtree)/include/autoconf.h include/applets.h
|
||||
$(Q)-SUID="yes" $(SHELL) $^ > $@
|
||||
busybox.cfg.nosuid: $(srctree)/applets/busybox.mksuid $(objtree)/include/autoconf.h include/applets.h
|
||||
$(Q)-SUID="DROP" $(SHELL) $^ > $@
|
||||
|
||||
.PHONY: install
|
||||
ifeq ($(CONFIG_INSTALL_APPLET_SYMLINKS),y)
|
||||
@@ -68,6 +73,10 @@ release: distclean
|
||||
-name .git \
|
||||
-print \
|
||||
-exec rm -r -f {} \; ; \
|
||||
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
|
||||
-name .gitignore \
|
||||
-print \
|
||||
-exec rm -f {} \; ; \
|
||||
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
|
||||
-name .\#* \
|
||||
-print \
|
||||
|
||||
+15
-1
@@ -25,6 +25,7 @@ CFLAGS += $(call cc-option,-Wstrict-prototypes,)
|
||||
CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
|
||||
CFLAGS += $(call cc-option,-Wunused-function -Wunused-value,)
|
||||
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
|
||||
CFLAGS += $(call cc-option,-Wno-format-security,)
|
||||
# warn about C99 declaration after statement
|
||||
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
|
||||
# If you want to add more -Wsomething above, make sure that it is
|
||||
@@ -52,6 +53,9 @@ CFLAGS += $(call cc-option,-fno-builtin-strlen -finline-limit=0 -fomit-frame-poi
|
||||
CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
|
||||
CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
|
||||
CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
|
||||
# Defeat .eh_frame bloat (gcc 4.6.3 x86-32 defconfig: 20% smaller busybox binary):
|
||||
CFLAGS += $(call cc-option,-fno-unwind-tables,)
|
||||
CFLAGS += $(call cc-option,-fno-asynchronous-unwind-tables,)
|
||||
|
||||
# FIXME: These warnings are at least partially to be concerned about and should
|
||||
# be fixed..
|
||||
@@ -74,6 +78,12 @@ ARCH_FPIC ?= -fpic
|
||||
ARCH_FPIE ?= -fpie
|
||||
ARCH_PIE ?= -pie
|
||||
|
||||
# Usage: $(eval $(call pkg_check_modules,VARIABLE-PREFIX,MODULES))
|
||||
define pkg_check_modules
|
||||
$(1)_CFLAGS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --cflags $(2))
|
||||
$(1)_LIBS := $(shell $(PKG_CONFIG) $(PKG_CONFIG_FLAGS) --libs $(2))
|
||||
endef
|
||||
|
||||
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
|
||||
# on i386: 14% smaller libbusybox.so
|
||||
# (code itself is 9% bigger, we save on relocs/PLT/GOT)
|
||||
@@ -85,6 +95,7 @@ endif
|
||||
|
||||
ifeq ($(CONFIG_STATIC),y)
|
||||
CFLAGS_busybox += -static
|
||||
PKG_CONFIG_FLAGS += --static
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PIE),y)
|
||||
@@ -127,7 +138,10 @@ LDLIBS += pam pam_misc pthread
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SELINUX),y)
|
||||
LDLIBS += selinux sepol
|
||||
SELINUX_PC_MODULES = libselinux libsepol
|
||||
$(eval $(call pkg_check_modules,SELINUX,$(SELINUX_PC_MODULES)))
|
||||
CPPFLAGS += $(SELINUX_CFLAGS)
|
||||
LDLIBS += $(if $(SELINUX_LIBS),$(SELINUX_LIBS:-l%=%),$(SELINUX_PC_MODULES:lib%=%))
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EFENCE),y)
|
||||
|
||||
@@ -127,20 +127,6 @@ patch
|
||||
|
||||
And while we're at it, a new patch filename quoting format is apparently
|
||||
coming soon: http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
|
||||
---
|
||||
stty / catv
|
||||
stty's visible() function and catv's guts are identical. Merge them into
|
||||
an appropriate libbb function.
|
||||
---
|
||||
struct suffix_mult
|
||||
Several duplicate users of: grep -r "1024\*1024" * -B2 -A1
|
||||
Merge to a single size_suffixes[] in libbb.
|
||||
Users: head tail od_bloaty hexdump and (partially as it wouldn't hurt) svlogd
|
||||
---
|
||||
tail
|
||||
./busybox tail -f foo.c~ TODO
|
||||
should not print fmt=header_fmt for subsequent date >> TODO; i.e. only
|
||||
fmt+ if another (not the current) file did change
|
||||
|
||||
Architectural issues:
|
||||
|
||||
@@ -233,8 +219,6 @@ Minor stuff:
|
||||
---
|
||||
See grep -r strtod
|
||||
Alot of duplication that wants cleanup.
|
||||
---
|
||||
in_ether duplicated in network/{interface,ifconfig}.c
|
||||
---
|
||||
unify progress_meter. wget, flash_eraseall, pipe_progress, fbsplash, setfiles.
|
||||
---
|
||||
|
||||
@@ -53,7 +53,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int ofs;
|
||||
unsigned MAX_APPLET_NAME_LEN = 1;
|
||||
// unsigned MAX_APPLET_NAME_LEN = 1;
|
||||
|
||||
qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name);
|
||||
|
||||
@@ -89,8 +89,8 @@ int main(int argc, char **argv)
|
||||
printf("const char applet_names[] ALIGN1 = \"\"\n");
|
||||
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);
|
||||
// if (MAX_APPLET_NAME_LEN < strlen(applets[i].name))
|
||||
// MAX_APPLET_NAME_LEN = strlen(applets[i].name);
|
||||
}
|
||||
printf(";\n\n");
|
||||
|
||||
@@ -130,8 +130,8 @@ int main(int argc, char **argv)
|
||||
printf("};\n");
|
||||
#endif
|
||||
//printf("#endif /* SKIP_definitions */\n");
|
||||
printf("\n");
|
||||
printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
|
||||
// printf("\n");
|
||||
// printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
|
||||
|
||||
if (argv[2]) {
|
||||
char line_old[80];
|
||||
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
#!/bin/sh
|
||||
# Make list of configuration variables regarding suid handling
|
||||
|
||||
# input $1: full path to autoconf.h
|
||||
# input $2: full path to applets.h
|
||||
# input $3: full path to .config
|
||||
# output (stdout): list of CONFIG_ that do or may require suid
|
||||
|
||||
# If the environment variable SUID is not set or set to DROP,
|
||||
# lists all config options that do not require suid permissions.
|
||||
# Otherwise, lists all config options for applets that DO or MAY require
|
||||
# suid permissions.
|
||||
|
||||
# Maintainer: Bernhard Reutner-Fischer
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-include/autoconf.h}
|
||||
APPLETS_H=${2:-include/applets.h}
|
||||
DOT_CONFIG=${3:-.config}
|
||||
|
||||
case ${SUID:-DROP} in
|
||||
[dD][rR][oO][pP]) USE="DROP" ;;
|
||||
*) USE="suid" ;;
|
||||
esac
|
||||
|
||||
$HOSTCC -E -DMAKE_SUID -include $CONFIG_H $APPLETS_H |
|
||||
awk -v USE=${USE} '
|
||||
/^SUID[ \t]/{
|
||||
if (USE == "DROP") {
|
||||
if ($2 != "BB_SUID_DROP") next
|
||||
} else {
|
||||
if ($2 == "BB_SUID_DROP") next
|
||||
}
|
||||
cfg = $NF
|
||||
gsub("\"", "", cfg)
|
||||
cfg = substr(cfg, 8)
|
||||
s[i++] = "CONFIG_" cfg
|
||||
s[i++] = "CONFIG_FEATURE_" cfg "_.*"
|
||||
}
|
||||
END{
|
||||
while (getline < ARGV[2]) {
|
||||
for (j in s) {
|
||||
if ($0 ~ "^" s[j] "=y$") {
|
||||
sub(/=.*/, "")
|
||||
print
|
||||
if (s[j] !~ /\*$/) delete s[j] # can drop this applet now
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
' - $DOT_CONFIG
|
||||
|
||||
@@ -14,7 +14,7 @@ const char *applet_name;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
applet_name = argv[0];
|
||||
return APPLET_main(argc,argv);
|
||||
return APPLET_main(argc, argv);
|
||||
}
|
||||
|
||||
void bb_show_usage(void)
|
||||
|
||||
@@ -10,20 +10,20 @@ test "$SED" || SED=sed
|
||||
test "$DD" || DD=dd
|
||||
|
||||
# Some people were bitten by their system lacking a (proper) od
|
||||
od -v -t x1 </dev/null >/dev/null
|
||||
od -v -b </dev/null >/dev/null
|
||||
if test $? != 0; then
|
||||
echo 'od tool is not installed or cannot accept "-v -t x1" options'
|
||||
echo 'od tool is not installed or cannot accept "-v -b" options'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec >"$target.$$"
|
||||
|
||||
echo '#define UNPACKED_USAGE "" \'
|
||||
"$loc/usage" | od -v -t x1 \
|
||||
"$loc/usage" | od -v -b \
|
||||
| $SED -e 's/^[^ ]*//' \
|
||||
-e 's/ //g' \
|
||||
-e '/^$/d' \
|
||||
-e 's/\(..\)/\\x\1/g' \
|
||||
-e 's/\(...\)/\\\1/g' \
|
||||
-e 's/^/"/' \
|
||||
-e 's/$/" \\/'
|
||||
echo ''
|
||||
@@ -39,11 +39,11 @@ echo '#define PACKED_USAGE \'
|
||||
## -e '/^$/d' \
|
||||
## -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
|
||||
## -e 's/$/ \\/'
|
||||
"$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -t x1 \
|
||||
"$loc/usage" | bzip2 -1 | $DD bs=2 skip=1 2>/dev/null | od -v -b \
|
||||
| $SED -e 's/^[^ ]*//' \
|
||||
-e 's/ //g' \
|
||||
-e '/^$/d' \
|
||||
-e 's/\(..\)/0x\1,/g' \
|
||||
-e 's/\(...\)/0\1,/g' \
|
||||
-e 's/$/ \\/'
|
||||
echo ''
|
||||
|
||||
|
||||
+1
-349
@@ -5,8 +5,6 @@
|
||||
|
||||
menu "Archival Utilities"
|
||||
|
||||
INSERT
|
||||
|
||||
config FEATURE_SEAMLESS_XZ
|
||||
bool "Make tar, rpm, modprobe etc understand .xz data"
|
||||
default y
|
||||
@@ -37,352 +35,6 @@ config FEATURE_SEAMLESS_Z
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .Z data.
|
||||
|
||||
config AR
|
||||
bool "ar"
|
||||
default n # needs to be improved to be able to replace binutils ar
|
||||
help
|
||||
ar is an archival utility program used to create, modify, and
|
||||
extract contents from archives. An archive is a single file holding
|
||||
a collection of other files in a structure that makes it possible to
|
||||
retrieve the original individual files (called archive members).
|
||||
The original files' contents, mode (permissions), timestamp, owner,
|
||||
and group are preserved in the archive, and can be restored on
|
||||
extraction.
|
||||
|
||||
The stored filename is limited to 15 characters. (for more information
|
||||
see long filename support).
|
||||
ar has 60 bytes of overheads for every stored file.
|
||||
|
||||
This implementation of ar can extract archives, it cannot create or
|
||||
modify them.
|
||||
On an x86 system, the ar applet adds about 1K.
|
||||
|
||||
Unless you have a specific application which requires ar, you should
|
||||
probably say N here.
|
||||
|
||||
config FEATURE_AR_LONG_FILENAMES
|
||||
bool "Support for long filenames (not needed for debs)"
|
||||
default y
|
||||
depends on AR
|
||||
help
|
||||
By default the ar format can only store the first 15 characters
|
||||
of the filename, this option removes that limitation.
|
||||
It supports the GNU ar long filename method which moves multiple long
|
||||
filenames into a the data section of a new ar entry.
|
||||
|
||||
config FEATURE_AR_CREATE
|
||||
bool "Support archive creation"
|
||||
default y
|
||||
depends on AR
|
||||
help
|
||||
This enables archive creation (-c and -r) with busybox ar.
|
||||
|
||||
config BUNZIP2
|
||||
bool "bunzip2"
|
||||
default y
|
||||
help
|
||||
bunzip2 is a compression utility using the Burrows-Wheeler block
|
||||
sorting text compression algorithm, and Huffman coding. Compression
|
||||
is generally considerably better than that achieved by more
|
||||
conventional LZ77/LZ78-based compressors, and approaches the
|
||||
performance of the PPM family of statistical compressors.
|
||||
|
||||
Unless you have a specific application which requires bunzip2, you
|
||||
should probably say N here.
|
||||
|
||||
config BZIP2
|
||||
bool "bzip2"
|
||||
default y
|
||||
help
|
||||
bzip2 is a compression utility using the Burrows-Wheeler block
|
||||
sorting text compression algorithm, and Huffman coding. Compression
|
||||
is generally considerably better than that achieved by more
|
||||
conventional LZ77/LZ78-based compressors, and approaches the
|
||||
performance of the PPM family of statistical compressors.
|
||||
|
||||
Unless you have a specific application which requires bzip2, you
|
||||
should probably say N here.
|
||||
|
||||
config CPIO
|
||||
bool "cpio"
|
||||
default y
|
||||
help
|
||||
cpio is an archival utility program used to create, modify, and
|
||||
extract contents from archives.
|
||||
cpio has 110 bytes of overheads for every stored file.
|
||||
|
||||
This implementation of cpio can extract cpio archives created in the
|
||||
"newc" or "crc" format, it cannot create or modify them.
|
||||
|
||||
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 y
|
||||
depends on CPIO
|
||||
help
|
||||
This implementation of cpio can create cpio archives in the "newc"
|
||||
format only.
|
||||
|
||||
config FEATURE_CPIO_P
|
||||
bool "Support for passthrough mode"
|
||||
default y
|
||||
depends on FEATURE_CPIO_O
|
||||
help
|
||||
Passthrough mode. Rarely used.
|
||||
|
||||
config DPKG
|
||||
bool "dpkg"
|
||||
default n
|
||||
select FEATURE_SEAMLESS_GZ
|
||||
help
|
||||
dpkg is a medium-level tool to install, build, remove and manage
|
||||
Debian packages.
|
||||
|
||||
This implementation of dpkg has a number of limitations,
|
||||
you should use the official dpkg if possible.
|
||||
|
||||
config DPKG_DEB
|
||||
bool "dpkg_deb"
|
||||
default n
|
||||
select FEATURE_SEAMLESS_GZ
|
||||
help
|
||||
dpkg-deb unpacks and provides information about Debian archives.
|
||||
|
||||
This implementation of dpkg-deb cannot pack archives.
|
||||
|
||||
Unless you have a specific application which requires dpkg-deb,
|
||||
say N here.
|
||||
|
||||
config FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
bool "Extract only (-x)"
|
||||
default n
|
||||
depends on DPKG_DEB
|
||||
help
|
||||
This reduces dpkg-deb to the equivalent of
|
||||
"ar -p <deb> data.tar.gz | tar -zx". However it saves space as none
|
||||
of the extra dpkg-deb, ar or tar options are needed, they are linked
|
||||
to internally.
|
||||
|
||||
config GUNZIP
|
||||
bool "gunzip"
|
||||
default y
|
||||
help
|
||||
gunzip is used to decompress archives created by gzip.
|
||||
You can use the `-t' option to test the integrity of
|
||||
an archive, without decompressing it.
|
||||
|
||||
config GZIP
|
||||
bool "gzip"
|
||||
default y
|
||||
help
|
||||
gzip is used to compress files.
|
||||
It's probably the most widely used UNIX compression program.
|
||||
|
||||
config FEATURE_GZIP_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default y
|
||||
depends on GZIP && LONG_OPTS
|
||||
help
|
||||
Enable use of long options, increases size by about 106 Bytes
|
||||
|
||||
config GZIP_FAST
|
||||
int "Trade memory for gzip speed (0:small,slow - 2:fast,big)"
|
||||
default 0
|
||||
range 0 2
|
||||
depends on GZIP
|
||||
help
|
||||
Enable big memory options for gzip.
|
||||
0: small buffers, small hash-tables
|
||||
1: larger buffers, larger hash-tables
|
||||
2: larger buffers, largest hash-tables
|
||||
Larger models may give slightly better compression
|
||||
|
||||
config LZOP
|
||||
bool "lzop"
|
||||
default y
|
||||
help
|
||||
Lzop compression/decompresion.
|
||||
|
||||
config LZOP_COMPR_HIGH
|
||||
bool "lzop compression levels 7,8,9 (not very useful)"
|
||||
default n
|
||||
depends on LZOP
|
||||
help
|
||||
High levels (7,8,9) of lzop compression. These levels
|
||||
are actually slower than gzip at equivalent compression ratios
|
||||
and take up 3.2K of code.
|
||||
|
||||
config RPM2CPIO
|
||||
bool "rpm2cpio"
|
||||
default y
|
||||
help
|
||||
Converts a RPM file into a CPIO archive.
|
||||
|
||||
config RPM
|
||||
bool "rpm"
|
||||
default y
|
||||
help
|
||||
Mini RPM applet - queries and extracts RPM packages.
|
||||
|
||||
config TAR
|
||||
bool "tar"
|
||||
default y
|
||||
help
|
||||
tar is an archiving program. It's commonly used with gzip to
|
||||
create compressed archives. It's probably the most widely used
|
||||
UNIX archive program.
|
||||
|
||||
config FEATURE_TAR_CREATE
|
||||
bool "Enable archive creation"
|
||||
default y
|
||||
depends on TAR
|
||||
help
|
||||
If you enable this option you'll be able to create
|
||||
tar archives using the `-c' option.
|
||||
|
||||
config FEATURE_TAR_AUTODETECT
|
||||
bool "Autodetect compressed tarballs"
|
||||
default y
|
||||
depends on TAR && (FEATURE_SEAMLESS_Z || FEATURE_SEAMLESS_GZ || FEATURE_SEAMLESS_BZ2 || FEATURE_SEAMLESS_LZMA || FEATURE_SEAMLESS_XZ)
|
||||
help
|
||||
With this option tar can automatically detect compressed
|
||||
tarballs. Currently it works only on files (not pipes etc).
|
||||
|
||||
config FEATURE_TAR_FROM
|
||||
bool "Enable -X (exclude from) and -T (include from) options)"
|
||||
default y
|
||||
depends on TAR
|
||||
help
|
||||
If you enable this option you'll be able to specify
|
||||
a list of files to include or exclude from an archive.
|
||||
|
||||
config FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
bool "Support for old tar header format"
|
||||
default y
|
||||
depends on TAR || DPKG
|
||||
help
|
||||
This option is required to unpack archives created in
|
||||
the old GNU format; help to kill this old format by
|
||||
repacking your ancient archives with the new format.
|
||||
|
||||
config FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
bool "Enable untarring of tarballs with checksums produced by buggy Sun tar"
|
||||
default y
|
||||
depends on TAR || DPKG
|
||||
help
|
||||
This option is required to unpack archives created by some old
|
||||
version of Sun's tar (it was calculating checksum using signed
|
||||
arithmetic). It is said to be fixed in newer Sun tar, but "old"
|
||||
tarballs still exist.
|
||||
|
||||
config FEATURE_TAR_GNU_EXTENSIONS
|
||||
bool "Support for GNU tar extensions (long filenames)"
|
||||
default y
|
||||
depends on TAR || DPKG
|
||||
help
|
||||
With this option busybox supports GNU long filenames and
|
||||
linknames.
|
||||
|
||||
config FEATURE_TAR_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default y
|
||||
depends on TAR && LONG_OPTS
|
||||
help
|
||||
Enable use of long options, increases size by about 400 Bytes
|
||||
|
||||
config FEATURE_TAR_TO_COMMAND
|
||||
bool "Support for writing to an external program"
|
||||
default y
|
||||
depends on TAR && FEATURE_TAR_LONG_OPTIONS
|
||||
help
|
||||
If you enable this option you'll be able to instruct tar to send
|
||||
the contents of each extracted file to the standard input of an
|
||||
external program.
|
||||
|
||||
config FEATURE_TAR_UNAME_GNAME
|
||||
bool "Enable use of user and group names"
|
||||
default y
|
||||
depends on TAR
|
||||
help
|
||||
Enables use of user and group names in tar. This affects contents
|
||||
listings (-t) and preserving permissions when unpacking (-p).
|
||||
+200 bytes.
|
||||
|
||||
config FEATURE_TAR_NOPRESERVE_TIME
|
||||
bool "Enable -m (do not preserve time) option"
|
||||
default y
|
||||
depends on TAR
|
||||
help
|
||||
With this option busybox supports GNU tar -m
|
||||
(do not preserve time) option.
|
||||
|
||||
config FEATURE_TAR_SELINUX
|
||||
bool "Support for extracting SELinux labels"
|
||||
default n
|
||||
depends on TAR && SELINUX
|
||||
help
|
||||
With this option busybox supports restoring SELinux labels
|
||||
when extracting files from tar archives.
|
||||
|
||||
config UNCOMPRESS
|
||||
bool "uncompress"
|
||||
default n
|
||||
help
|
||||
uncompress is used to decompress archives created by compress.
|
||||
Not much used anymore, replaced by gzip/gunzip.
|
||||
|
||||
config UNLZMA
|
||||
bool "unlzma"
|
||||
default y
|
||||
help
|
||||
unlzma is a compression utility using the Lempel-Ziv-Markov chain
|
||||
compression algorithm, and range coding. Compression
|
||||
is generally considerably better than that achieved by the bzip2
|
||||
compressors.
|
||||
|
||||
The BusyBox unlzma applet is limited to decompression only.
|
||||
On an x86 system, this applet adds about 4K.
|
||||
|
||||
config FEATURE_LZMA_FAST
|
||||
bool "Optimize unlzma for speed"
|
||||
default n
|
||||
depends on UNLZMA
|
||||
help
|
||||
This option reduces decompression time by about 25% at the cost of
|
||||
a 1K bigger binary.
|
||||
|
||||
config LZMA
|
||||
bool "Provide lzma alias which supports only unpacking"
|
||||
default y
|
||||
depends on UNLZMA
|
||||
help
|
||||
Enable this option if you want commands like "lzma -d" to work.
|
||||
IOW: you'll get lzma applet, but it will always require -d option.
|
||||
|
||||
config UNXZ
|
||||
bool "unxz"
|
||||
default y
|
||||
help
|
||||
unxz is a unlzma successor.
|
||||
|
||||
config XZ
|
||||
bool "Provide xz alias which supports only unpacking"
|
||||
default y
|
||||
depends on UNXZ
|
||||
help
|
||||
Enable this option if you want commands like "xz -d" to work.
|
||||
IOW: you'll get xz applet, but it will always require -d option.
|
||||
|
||||
config UNZIP
|
||||
bool "unzip"
|
||||
default y
|
||||
help
|
||||
unzip will list or extract files from a ZIP archive,
|
||||
commonly found on DOS/WIN systems. The default behavior
|
||||
(with no options) is to extract the archive into the
|
||||
current directory. Use the `-d' option to extract to a
|
||||
directory of your choice.
|
||||
INSERT
|
||||
|
||||
endmenu
|
||||
@@ -9,22 +9,3 @@ libs-y += libarchive/
|
||||
lib-y:=
|
||||
|
||||
INSERT
|
||||
|
||||
lib-$(CONFIG_AR) += ar.o
|
||||
lib-$(CONFIG_CPIO) += cpio.o
|
||||
lib-$(CONFIG_DPKG) += dpkg.o
|
||||
lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o
|
||||
lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o
|
||||
lib-$(CONFIG_RPM) += rpm.o
|
||||
lib-$(CONFIG_TAR) += tar.o
|
||||
lib-$(CONFIG_UNZIP) += unzip.o
|
||||
|
||||
lib-$(CONFIG_LZOP) += lzop.o bbunzip.o
|
||||
lib-$(CONFIG_GZIP) += gzip.o bbunzip.o
|
||||
lib-$(CONFIG_BZIP2) += bzip2.o bbunzip.o
|
||||
|
||||
lib-$(CONFIG_UNXZ) += bbunzip.o
|
||||
lib-$(CONFIG_UNLZMA) += bbunzip.o
|
||||
lib-$(CONFIG_BUNZIP2) += bbunzip.o
|
||||
lib-$(CONFIG_GUNZIP) += bbunzip.o
|
||||
lib-$(CONFIG_UNCOMPRESS) += bbunzip.o
|
||||
@@ -17,6 +17,49 @@
|
||||
* http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
|
||||
*/
|
||||
|
||||
//config:config AR
|
||||
//config: bool "ar"
|
||||
//config: default n # needs to be improved to be able to replace binutils ar
|
||||
//config: help
|
||||
//config: ar is an archival utility program used to create, modify, and
|
||||
//config: extract contents from archives. An archive is a single file holding
|
||||
//config: a collection of other files in a structure that makes it possible to
|
||||
//config: retrieve the original individual files (called archive members).
|
||||
//config: The original files' contents, mode (permissions), timestamp, owner,
|
||||
//config: and group are preserved in the archive, and can be restored on
|
||||
//config: extraction.
|
||||
//config:
|
||||
//config: The stored filename is limited to 15 characters. (for more information
|
||||
//config: see long filename support).
|
||||
//config: ar has 60 bytes of overheads for every stored file.
|
||||
//config:
|
||||
//config: This implementation of ar can extract archives, it cannot create or
|
||||
//config: modify them.
|
||||
//config: On an x86 system, the ar applet adds about 1K.
|
||||
//config:
|
||||
//config: Unless you have a specific application which requires ar, you should
|
||||
//config: probably say N here.
|
||||
//config:
|
||||
//config:config FEATURE_AR_LONG_FILENAMES
|
||||
//config: bool "Support for long filenames (not needed for debs)"
|
||||
//config: default y
|
||||
//config: depends on AR
|
||||
//config: help
|
||||
//config: By default the ar format can only store the first 15 characters
|
||||
//config: of the filename, this option removes that limitation.
|
||||
//config: It supports the GNU ar long filename method which moves multiple long
|
||||
//config: filenames into a the data section of a new ar entry.
|
||||
//config:
|
||||
//config:config FEATURE_AR_CREATE
|
||||
//config: bool "Support archive creation"
|
||||
//config: default y
|
||||
//config: depends on AR
|
||||
//config: help
|
||||
//config: This enables archive creation (-c and -r) with busybox ar.
|
||||
|
||||
//applet:IF_AR(APPLET(ar, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
//kbuild:lib-$(CONFIG_AR) += ar.o
|
||||
|
||||
//usage:#define ar_trivial_usage
|
||||
//usage: "[-o] [-v] [-p] [-t] [-x] ARCHIVE FILES"
|
||||
//usage:#define ar_full_usage "\n\n"
|
||||
|
||||
+165
-44
@@ -7,13 +7,19 @@
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
/* lzop_main() uses bbunpack(), need this: */
|
||||
//kbuild:lib-$(CONFIG_LZOP) += bbunzip.o
|
||||
|
||||
/* Note: must be kept in sync with archival/lzop.c */
|
||||
enum {
|
||||
OPT_STDOUT = 1 << 0,
|
||||
OPT_FORCE = 1 << 1,
|
||||
/* only some decompressors: */
|
||||
OPT_VERBOSE = 1 << 2,
|
||||
OPT_DECOMPRESS = 1 << 3,
|
||||
OPT_TEST = 1 << 4,
|
||||
OPT_QUIET = 1 << 3,
|
||||
OPT_DECOMPRESS = 1 << 4,
|
||||
OPT_TEST = 1 << 5,
|
||||
SEAMLESS_MAGIC = (1 << 31) * SEAMLESS_COMPRESSION,
|
||||
};
|
||||
|
||||
static
|
||||
@@ -39,7 +45,7 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
IF_DESKTOP(long long) int status;
|
||||
IF_DESKTOP(long long) int status = 0;
|
||||
char *filename, *new_name;
|
||||
smallint exitcode = 0;
|
||||
transformer_aux_data_t aux;
|
||||
@@ -54,13 +60,27 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
|
||||
/* Open src */
|
||||
if (filename) {
|
||||
if (stat(filename, &stat_buf) != 0) {
|
||||
bb_simple_perror_msg(filename);
|
||||
if (!(option_mask32 & SEAMLESS_MAGIC)) {
|
||||
if (stat(filename, &stat_buf) != 0) {
|
||||
err_name:
|
||||
bb_simple_perror_msg(filename);
|
||||
err:
|
||||
exitcode = 1;
|
||||
goto free_name;
|
||||
exitcode = 1;
|
||||
goto free_name;
|
||||
}
|
||||
if (open_to_or_warn(STDIN_FILENO, filename, O_RDONLY, 0))
|
||||
goto err;
|
||||
} else {
|
||||
/* "clever zcat" with FILE */
|
||||
int fd = open_zipped(filename);
|
||||
if (fd < 0)
|
||||
goto err_name;
|
||||
xmove_fd(fd, STDIN_FILENO);
|
||||
}
|
||||
if (open_to_or_warn(STDIN_FILENO, filename, O_RDONLY, 0))
|
||||
} else
|
||||
if (option_mask32 & SEAMLESS_MAGIC) {
|
||||
/* "clever zcat" on stdin */
|
||||
if (setup_unzip_on_fd(STDIN_FILENO, /*fail_if_not_detected*/ 0))
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -68,7 +88,7 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
if (option_mask32 & (OPT_STDOUT|OPT_TEST)) {
|
||||
if (option_mask32 & OPT_TEST)
|
||||
if (open_to_or_warn(STDOUT_FILENO, bb_dev_null, O_WRONLY, 0))
|
||||
goto err;
|
||||
xfunc_die();
|
||||
filename = NULL;
|
||||
}
|
||||
|
||||
@@ -93,23 +113,32 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
}
|
||||
|
||||
/* Check that the input is sane */
|
||||
if (isatty(STDIN_FILENO) && (option_mask32 & OPT_FORCE) == 0) {
|
||||
if (!(option_mask32 & OPT_FORCE) && isatty(STDIN_FILENO)) {
|
||||
bb_error_msg_and_die("compressed data not read from terminal, "
|
||||
"use -f to force it");
|
||||
}
|
||||
|
||||
init_transformer_aux_data(&aux);
|
||||
aux.check_signature = 1;
|
||||
status = unpacker(&aux);
|
||||
if (status < 0)
|
||||
exitcode = 1;
|
||||
if (!(option_mask32 & SEAMLESS_MAGIC)) {
|
||||
init_transformer_aux_data(&aux);
|
||||
aux.check_signature = 1;
|
||||
status = unpacker(&aux);
|
||||
if (status < 0)
|
||||
exitcode = 1;
|
||||
} else {
|
||||
if (bb_copyfd_eof(STDIN_FILENO, STDOUT_FILENO) < 0)
|
||||
/* Disk full, tty closed, etc. No point in continuing */
|
||||
xfunc_die();
|
||||
}
|
||||
|
||||
if (!(option_mask32 & OPT_STDOUT))
|
||||
xclose(STDOUT_FILENO); /* with error check! */
|
||||
|
||||
if (filename) {
|
||||
char *del = new_name;
|
||||
|
||||
if (status >= 0) {
|
||||
unsigned new_name_len;
|
||||
|
||||
/* TODO: restore other things? */
|
||||
if (aux.mtime != 0) {
|
||||
struct timeval times[2];
|
||||
@@ -123,22 +152,29 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
utimes(new_name, times); /* ignoring errors */
|
||||
}
|
||||
|
||||
/* Delete _compressed_ file */
|
||||
if (ENABLE_DESKTOP)
|
||||
new_name_len = strlen(new_name);
|
||||
/* Restore source filename (unless tgz -> tar case) */
|
||||
if (new_name == filename) {
|
||||
new_name_len = strlen(filename);
|
||||
filename[new_name_len] = '.';
|
||||
}
|
||||
/* Extreme bloat for gunzip compat */
|
||||
/* Some users do want this info... */
|
||||
if (ENABLE_DESKTOP && (option_mask32 & OPT_VERBOSE)) {
|
||||
unsigned percent = status
|
||||
? ((uoff_t)stat_buf.st_size * 100u / (unsigned long long)status)
|
||||
: 0;
|
||||
fprintf(stderr, "%s: %u%% - replaced with %.*s\n",
|
||||
filename,
|
||||
100u - percent,
|
||||
new_name_len, new_name
|
||||
);
|
||||
}
|
||||
/* Delete _source_ file */
|
||||
del = filename;
|
||||
/* restore extension (unless tgz -> tar case) */
|
||||
if (new_name == filename)
|
||||
filename[strlen(filename)] = '.';
|
||||
}
|
||||
xunlink(del);
|
||||
|
||||
#if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */
|
||||
/* Extreme bloat for gunzip compat */
|
||||
if (ENABLE_DESKTOP && (option_mask32 & OPT_VERBOSE) && status >= 0) {
|
||||
fprintf(stderr, "%s: %u%% - replaced with %s\n",
|
||||
filename, (unsigned)(stat_buf.st_size*100 / (status+1)), new_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
free_name:
|
||||
if (new_name != filename)
|
||||
free(new_name);
|
||||
@@ -172,7 +208,6 @@ char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext)
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
//usage:#define uncompress_trivial_usage
|
||||
//usage: "[-cf] [FILE]..."
|
||||
//usage:#define uncompress_full_usage "\n\n"
|
||||
@@ -180,6 +215,15 @@ char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext)
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Overwrite"
|
||||
|
||||
//config:config UNCOMPRESS
|
||||
//config: bool "uncompress"
|
||||
//config: default n
|
||||
//config: help
|
||||
//config: uncompress is used to decompress archives created by compress.
|
||||
//config: Not much used anymore, replaced by gzip/gunzip.
|
||||
|
||||
//applet:IF_UNCOMPRESS(APPLET(uncompress, BB_DIR_BIN, BB_SUID_DROP))
|
||||
//kbuild:lib-$(CONFIG_UNCOMPRESS) += bbunzip.o
|
||||
#if ENABLE_UNCOMPRESS
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_uncompress(transformer_aux_data_t *aux)
|
||||
@@ -220,11 +264,7 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv)
|
||||
* Portions of the lzw code are derived from the public domain 'compress'
|
||||
* written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies,
|
||||
* Ken Turkowski, Dave Mack and Peter Jannesen.
|
||||
*
|
||||
* See the license_msg below and the file COPYING for the software license.
|
||||
* See the file algorithm.doc for the compression algorithms and file formats.
|
||||
*/
|
||||
|
||||
//usage:#define gunzip_trivial_usage
|
||||
//usage: "[-cft] [FILE]..."
|
||||
//usage:#define gunzip_full_usage "\n\n"
|
||||
@@ -241,10 +281,22 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv)
|
||||
//usage: "-rw-rw-r-- 1 andersen andersen 1761280 Apr 14 17:47 /tmp/BusyBox-0.43.tar\n"
|
||||
//usage:
|
||||
//usage:#define zcat_trivial_usage
|
||||
//usage: "FILE"
|
||||
//usage: "[FILE]..."
|
||||
//usage:#define zcat_full_usage "\n\n"
|
||||
//usage: "Decompress to stdout"
|
||||
|
||||
//config:config GUNZIP
|
||||
//config: bool "gunzip"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: gunzip is used to decompress archives created by gzip.
|
||||
//config: You can use the `-t' option to test the integrity of
|
||||
//config: an archive, without decompressing it.
|
||||
|
||||
//applet:IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP))
|
||||
//applet:IF_GUNZIP(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat))
|
||||
//kbuild:lib-$(CONFIG_GZIP) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_GUNZIP) += bbunzip.o
|
||||
#if ENABLE_GUNZIP
|
||||
static
|
||||
char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM)
|
||||
@@ -292,11 +344,15 @@ IF_DESKTOP(long long) int FAST_FUNC unpack_gunzip(transformer_aux_data_t *aux)
|
||||
int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cfvdtn");
|
||||
getopt32(argv, "cfvqdtn");
|
||||
argv += optind;
|
||||
/* if called as zcat */
|
||||
|
||||
/* If called as zcat...
|
||||
* Normally, "zcat" is just "gunzip -c".
|
||||
* But if seamless magic is enabled, then we are much more clever.
|
||||
*/
|
||||
if (applet_name[1] == 'c')
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
option_mask32 |= OPT_STDOUT | SEAMLESS_MAGIC;
|
||||
|
||||
return bbunpack(argv, unpack_gunzip, make_new_name_gunzip, /*unused:*/ NULL);
|
||||
}
|
||||
@@ -316,11 +372,27 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage:#define bzcat_trivial_usage
|
||||
//usage: "FILE"
|
||||
//usage: "[FILE]..."
|
||||
//usage:#define bzcat_full_usage "\n\n"
|
||||
//usage: "Decompress to stdout"
|
||||
|
||||
//config:config BUNZIP2
|
||||
//config: bool "bunzip2"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: bunzip2 is a compression utility using the Burrows-Wheeler block
|
||||
//config: sorting text compression algorithm, and Huffman coding. Compression
|
||||
//config: is generally considerably better than that achieved by more
|
||||
//config: conventional LZ77/LZ78-based compressors, and approaches the
|
||||
//config: performance of the PPM family of statistical compressors.
|
||||
//config:
|
||||
//config: Unless you have a specific application which requires bunzip2, you
|
||||
//config: should probably say N here.
|
||||
|
||||
//applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
//applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat))
|
||||
//kbuild:lib-$(CONFIG_BZIP2) += bbunzip.o
|
||||
//kbuild:lib-$(CONFIG_BUNZIP2) += bbunzip.o
|
||||
#if ENABLE_BUNZIP2
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(transformer_aux_data_t *aux)
|
||||
@@ -330,7 +402,7 @@ IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(transformer_aux_data_t *aux)
|
||||
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cfvdt");
|
||||
getopt32(argv, "cfvqdt");
|
||||
argv += optind;
|
||||
if (applet_name[2] == 'c') /* bzcat */
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
@@ -348,7 +420,6 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
*
|
||||
* Licensed under GPLv2, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
//usage:#define unlzma_trivial_usage
|
||||
//usage: "[-cf] [FILE]..."
|
||||
//usage:#define unlzma_full_usage "\n\n"
|
||||
@@ -365,7 +436,7 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
//usage: "\n -f Force"
|
||||
//usage:
|
||||
//usage:#define lzcat_trivial_usage
|
||||
//usage: "FILE"
|
||||
//usage: "[FILE]..."
|
||||
//usage:#define lzcat_full_usage "\n\n"
|
||||
//usage: "Decompress to stdout"
|
||||
//usage:
|
||||
@@ -385,10 +456,42 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
//usage: "\n -f Force"
|
||||
//usage:
|
||||
//usage:#define xzcat_trivial_usage
|
||||
//usage: "FILE"
|
||||
//usage: "[FILE]..."
|
||||
//usage:#define xzcat_full_usage "\n\n"
|
||||
//usage: "Decompress to stdout"
|
||||
|
||||
//config:config UNLZMA
|
||||
//config: bool "unlzma"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: unlzma is a compression utility using the Lempel-Ziv-Markov chain
|
||||
//config: compression algorithm, and range coding. Compression
|
||||
//config: is generally considerably better than that achieved by the bzip2
|
||||
//config: compressors.
|
||||
//config:
|
||||
//config: The BusyBox unlzma applet is limited to decompression only.
|
||||
//config: On an x86 system, this applet adds about 4K.
|
||||
//config:
|
||||
//config:config FEATURE_LZMA_FAST
|
||||
//config: bool "Optimize unlzma for speed"
|
||||
//config: default n
|
||||
//config: depends on UNLZMA
|
||||
//config: help
|
||||
//config: This option reduces decompression time by about 25% at the cost of
|
||||
//config: a 1K bigger binary.
|
||||
//config:
|
||||
//config:config LZMA
|
||||
//config: bool "Provide lzma alias which supports only unpacking"
|
||||
//config: default y
|
||||
//config: depends on UNLZMA
|
||||
//config: help
|
||||
//config: Enable this option if you want commands like "lzma -d" to work.
|
||||
//config: IOW: you'll get lzma applet, but it will always require -d option.
|
||||
|
||||
//applet:IF_UNLZMA(APPLET(unlzma, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
//applet:IF_UNLZMA(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat))
|
||||
//applet:IF_LZMA(APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma))
|
||||
//kbuild:lib-$(CONFIG_UNLZMA) += bbunzip.o
|
||||
#if ENABLE_UNLZMA
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma(transformer_aux_data_t *aux)
|
||||
@@ -398,7 +501,7 @@ IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma(transformer_aux_data_t *aux)
|
||||
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int unlzma_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
IF_LZMA(int opts =) getopt32(argv, "cfvdt");
|
||||
IF_LZMA(int opts =) getopt32(argv, "cfvqdt");
|
||||
# if ENABLE_LZMA
|
||||
/* lzma without -d or -t? */
|
||||
if (applet_name[2] == 'm' && !(opts & (OPT_DECOMPRESS|OPT_TEST)))
|
||||
@@ -414,6 +517,24 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv)
|
||||
#endif
|
||||
|
||||
|
||||
//config:config UNXZ
|
||||
//config: bool "unxz"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: unxz is a unlzma successor.
|
||||
//config:
|
||||
//config:config XZ
|
||||
//config: bool "Provide xz alias which supports only unpacking"
|
||||
//config: default y
|
||||
//config: depends on UNXZ
|
||||
//config: help
|
||||
//config: Enable this option if you want commands like "xz -d" to work.
|
||||
//config: IOW: you'll get xz applet, but it will always require -d option.
|
||||
|
||||
//applet:IF_UNXZ(APPLET(unxz, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
//applet:IF_UNXZ(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat))
|
||||
//applet:IF_XZ(APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz))
|
||||
//kbuild:lib-$(CONFIG_UNXZ) += bbunzip.o
|
||||
#if ENABLE_UNXZ
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_unxz(transformer_aux_data_t *aux)
|
||||
@@ -423,7 +544,7 @@ IF_DESKTOP(long long) int FAST_FUNC unpack_unxz(transformer_aux_data_t *aux)
|
||||
int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int unxz_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
IF_XZ(int opts =) getopt32(argv, "cfvdt");
|
||||
IF_XZ(int opts =) getopt32(argv, "cfvqdt");
|
||||
# if ENABLE_XZ
|
||||
/* xz without -d or -t? */
|
||||
if (applet_name[2] == '\0' && !(opts & (OPT_DECOMPRESS|OPT_TEST)))
|
||||
|
||||
@@ -7,6 +7,22 @@
|
||||
* about bzip2 library code.
|
||||
*/
|
||||
|
||||
//config:config BZIP2
|
||||
//config: bool "bzip2"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: bzip2 is a compression utility using the Burrows-Wheeler block
|
||||
//config: sorting text compression algorithm, and Huffman coding. Compression
|
||||
//config: is generally considerably better than that achieved by more
|
||||
//config: conventional LZ77/LZ78-based compressors, and approaches the
|
||||
//config: performance of the PPM family of statistical compressors.
|
||||
//config:
|
||||
//config: Unless you have a specific application which requires bzip2, you
|
||||
//config: should probably say N here.
|
||||
|
||||
//applet:IF_BZIP2(APPLET(bzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
//kbuild:lib-$(CONFIG_BZIP2) += bzip2.o
|
||||
|
||||
//usage:#define bzip2_trivial_usage
|
||||
//usage: "[OPTIONS] [FILE]..."
|
||||
//usage:#define bzip2_full_usage "\n\n"
|
||||
|
||||
+47
-16
@@ -9,11 +9,42 @@
|
||||
* Limitations:
|
||||
* Doesn't check CRC's
|
||||
* Only supports new ASCII and CRC formats
|
||||
*
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
//config:config CPIO
|
||||
//config: bool "cpio"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: cpio is an archival utility program used to create, modify, and
|
||||
//config: extract contents from archives.
|
||||
//config: cpio has 110 bytes of overheads for every stored file.
|
||||
//config:
|
||||
//config: This implementation of cpio can extract cpio archives created in the
|
||||
//config: "newc" or "crc" format, it cannot create or modify them.
|
||||
//config:
|
||||
//config: Unless you have a specific application which requires cpio, you
|
||||
//config: should probably say N here.
|
||||
//config:
|
||||
//config:config FEATURE_CPIO_O
|
||||
//config: bool "Support for archive creation"
|
||||
//config: default y
|
||||
//config: depends on CPIO
|
||||
//config: help
|
||||
//config: This implementation of cpio can create cpio archives in the "newc"
|
||||
//config: format only.
|
||||
//config:
|
||||
//config:config FEATURE_CPIO_P
|
||||
//config: bool "Support for passthrough mode"
|
||||
//config: default y
|
||||
//config: depends on FEATURE_CPIO_O
|
||||
//config: help
|
||||
//config: Passthrough mode. Rarely used.
|
||||
|
||||
//applet:IF_CPIO(APPLET(cpio, BB_DIR_BIN, BB_SUID_DROP))
|
||||
//kbuild:lib-$(CONFIG_CPIO) += cpio.o
|
||||
|
||||
//usage:#define cpio_trivial_usage
|
||||
//usage: "[-dmvu] [-F FILE]" IF_FEATURE_CPIO_O(" [-H newc]")
|
||||
//usage: " [-ti"IF_FEATURE_CPIO_O("o")"]" IF_FEATURE_CPIO_P(" [-p DIR]")
|
||||
@@ -253,24 +284,24 @@ static NOINLINE int cpio_o(void)
|
||||
}
|
||||
|
||||
bytes += printf("070701"
|
||||
"%08X%08X%08X%08X%08X%08X%08X"
|
||||
"%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */
|
||||
"%08X%08X%08X%08X%08X%08X%08X"
|
||||
"%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */
|
||||
/* strlen+1: */ "%08X"
|
||||
/* chksum: */ "00000000" /* (only for "070702" files) */
|
||||
/* name,NUL: */ "%s%c",
|
||||
(unsigned)(uint32_t) st.st_ino,
|
||||
(unsigned)(uint32_t) st.st_mode,
|
||||
(unsigned)(uint32_t) st.st_uid,
|
||||
(unsigned)(uint32_t) st.st_gid,
|
||||
(unsigned)(uint32_t) st.st_nlink,
|
||||
(unsigned)(uint32_t) st.st_mtime,
|
||||
(unsigned)(uint32_t) st.st_size,
|
||||
(unsigned)(uint32_t) major(st.st_dev),
|
||||
(unsigned)(uint32_t) minor(st.st_dev),
|
||||
(unsigned)(uint32_t) major(st.st_rdev),
|
||||
(unsigned)(uint32_t) minor(st.st_rdev),
|
||||
(unsigned)(strlen(name) + 1),
|
||||
name, '\0');
|
||||
(unsigned)(uint32_t) st.st_ino,
|
||||
(unsigned)(uint32_t) st.st_mode,
|
||||
(unsigned)(uint32_t) st.st_uid,
|
||||
(unsigned)(uint32_t) st.st_gid,
|
||||
(unsigned)(uint32_t) st.st_nlink,
|
||||
(unsigned)(uint32_t) st.st_mtime,
|
||||
(unsigned)(uint32_t) st.st_size,
|
||||
(unsigned)(uint32_t) major(st.st_dev),
|
||||
(unsigned)(uint32_t) minor(st.st_dev),
|
||||
(unsigned)(uint32_t) major(st.st_rdev),
|
||||
(unsigned)(uint32_t) minor(st.st_rdev),
|
||||
(unsigned)(strlen(name) + 1),
|
||||
name, '\0');
|
||||
bytes = cpio_pad4(bytes);
|
||||
|
||||
if (st.st_size) {
|
||||
|
||||
+26
-9
@@ -14,7 +14,6 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
/*
|
||||
* known difference between busybox dpkg and the official dpkg that i don't
|
||||
* consider important, its worth keeping a note of differences anyway, just to
|
||||
@@ -25,9 +24,22 @@
|
||||
*
|
||||
* bugs that need to be fixed
|
||||
* - (unknown, please let me know when you find any)
|
||||
*
|
||||
*/
|
||||
|
||||
//config:config DPKG
|
||||
//config: bool "dpkg"
|
||||
//config: default n
|
||||
//config: select FEATURE_SEAMLESS_GZ
|
||||
//config: help
|
||||
//config: dpkg is a medium-level tool to install, build, remove and manage
|
||||
//config: Debian packages.
|
||||
//config:
|
||||
//config: This implementation of dpkg has a number of limitations,
|
||||
//config: you should use the official dpkg if possible.
|
||||
|
||||
//applet:IF_DPKG(APPLET(dpkg, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
//kbuild:lib-$(CONFIG_DPKG) += dpkg.o
|
||||
|
||||
//usage:#define dpkg_trivial_usage
|
||||
//usage: "[-ilCPru] [-F OPT] PACKAGE"
|
||||
//usage:#define dpkg_full_usage "\n\n"
|
||||
@@ -1026,8 +1038,8 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
|
||||
if (package_edge->type == EDGE_CONFLICTS) {
|
||||
const unsigned package_num =
|
||||
search_package_hashtable(package_edge->name,
|
||||
package_edge->version,
|
||||
package_edge->operator);
|
||||
package_edge->version,
|
||||
package_edge->operator);
|
||||
int result = 0;
|
||||
if (package_hashtable[package_num] != NULL) {
|
||||
status_num = search_status_hashtable(name_hashtable[package_hashtable[package_num]->name]);
|
||||
@@ -1114,7 +1126,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
|
||||
*/
|
||||
if (root_of_alternatives && package_edge->type != root_of_alternatives->type - 1)
|
||||
bb_error_msg_and_die("fatal error, package dependencies corrupt: %d != %d - 1",
|
||||
package_edge->type, root_of_alternatives->type);
|
||||
package_edge->type, root_of_alternatives->type);
|
||||
|
||||
if (package_hashtable[package_num] != NULL)
|
||||
result = !package_satisfies_dependency(package_num, package_edge->type);
|
||||
@@ -1665,20 +1677,25 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
archive_handle = init_archive_deb_ar(deb_file->filename);
|
||||
init_archive_deb_data(archive_handle);
|
||||
archive_handle->dpkg__sub_archive->accept = conffile_list;
|
||||
/* Why ARCHIVE_REMEMBER_NAMES?
|
||||
* We want names collected in ->passed list even if conffile_list
|
||||
* is NULL (otherwise get_header_tar may optimize name saving out):
|
||||
*/
|
||||
archive_handle->dpkg__sub_archive->ah_flags |= ARCHIVE_REMEMBER_NAMES | ARCHIVE_UNLINK_OLD;
|
||||
archive_handle->dpkg__sub_archive->filter = filter_rename_config;
|
||||
archive_handle->dpkg__sub_archive->action_data = data_extract_all_prefix;
|
||||
archive_handle->dpkg__sub_archive->dpkg__buffer = (char*)"/"; /* huh? */
|
||||
archive_handle->dpkg__sub_archive->ah_flags |= ARCHIVE_UNLINK_OLD;
|
||||
unpack_ar_archive(archive_handle);
|
||||
|
||||
/* Create the list file */
|
||||
list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list");
|
||||
out_stream = xfopen_for_write(list_filename);
|
||||
archive_handle->dpkg__sub_archive->passed = llist_rev(archive_handle->dpkg__sub_archive->passed);
|
||||
while (archive_handle->dpkg__sub_archive->passed) {
|
||||
char *filename = llist_pop(&archive_handle->dpkg__sub_archive->passed);
|
||||
/* the leading . has been stripped by data_extract_all_prefix already */
|
||||
fputs(archive_handle->dpkg__sub_archive->passed->data, out_stream);
|
||||
fputc('\n', out_stream);
|
||||
archive_handle->dpkg__sub_archive->passed = archive_handle->dpkg__sub_archive->passed->link;
|
||||
fprintf(out_stream, "%s\n", filename);
|
||||
free(filename);
|
||||
}
|
||||
fclose(out_stream);
|
||||
|
||||
|
||||
+26
-1
@@ -5,8 +5,33 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
//config:config DPKG_DEB
|
||||
//config: bool "dpkg_deb"
|
||||
//config: default n
|
||||
//config: select FEATURE_SEAMLESS_GZ
|
||||
//config: help
|
||||
//config: dpkg-deb unpacks and provides information about Debian archives.
|
||||
//config:
|
||||
//config: This implementation of dpkg-deb cannot pack archives.
|
||||
//config:
|
||||
//config: Unless you have a specific application which requires dpkg-deb,
|
||||
//config: say N here.
|
||||
//config:
|
||||
//config:config FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
//config: bool "Extract only (-x)"
|
||||
//config: default n
|
||||
//config: depends on DPKG_DEB
|
||||
//config: help
|
||||
//config: This reduces dpkg-deb to the equivalent of
|
||||
//config: "ar -p <deb> data.tar.gz | tar -zx". However it saves space as none
|
||||
//config: of the extra dpkg-deb, ar or tar options are needed, they are linked
|
||||
//config: to internally.
|
||||
|
||||
//applet:IF_DPKG_DEB(APPLET_ODDNAME(dpkg-deb, dpkg_deb, BB_DIR_USR_BIN, BB_SUID_DROP, dpkg_deb))
|
||||
//kbuild:lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o
|
||||
|
||||
//usage:#define dpkg_deb_trivial_usage
|
||||
//usage: "[-cefxX] FILE [argument"
|
||||
//usage: "[-cefxX] FILE [argument]"
|
||||
//usage:#define dpkg_deb_full_usage "\n\n"
|
||||
//usage: "Perform actions on Debian packages (.debs)\n"
|
||||
//usage: "\n -c List contents of filesystem tree"
|
||||
|
||||
+37
-10
@@ -15,7 +15,6 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
/* big objects in bss:
|
||||
* 00000020 b bl_count
|
||||
* 00000074 b base_length
|
||||
@@ -31,7 +30,6 @@
|
||||
* 00000480 b static_ltree
|
||||
* 000008f4 b dyn_ltree
|
||||
*/
|
||||
|
||||
/* TODO: full support for -v for DESKTOP
|
||||
* "/usr/bin/gzip -v a bogus aa" should say:
|
||||
a: 85.1% -- replaced with a.gz
|
||||
@@ -39,6 +37,35 @@ gzip: bogus: No such file or directory
|
||||
aa: 85.1% -- replaced with aa.gz
|
||||
*/
|
||||
|
||||
//config:config GZIP
|
||||
//config: bool "gzip"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: gzip is used to compress files.
|
||||
//config: It's probably the most widely used UNIX compression program.
|
||||
//config:
|
||||
//config:config FEATURE_GZIP_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on GZIP && LONG_OPTS
|
||||
//config: help
|
||||
//config: Enable use of long options, increases size by about 106 Bytes
|
||||
//config:
|
||||
//config:config GZIP_FAST
|
||||
//config: int "Trade memory for gzip speed (0:small,slow - 2:fast,big)"
|
||||
//config: default 0
|
||||
//config: range 0 2
|
||||
//config: depends on GZIP
|
||||
//config: help
|
||||
//config: Enable big memory options for gzip.
|
||||
//config: 0: small buffers, small hash-tables
|
||||
//config: 1: larger buffers, larger hash-tables
|
||||
//config: 2: larger buffers, largest hash-tables
|
||||
//config: Larger models may give slightly better compression
|
||||
|
||||
//applet:IF_GZIP(APPLET(gzip, BB_DIR_BIN, BB_SUID_DROP))
|
||||
//kbuild:lib-$(CONFIG_GZIP) += gzip.o
|
||||
|
||||
//usage:#define gzip_trivial_usage
|
||||
//usage: "[-cfd] [FILE]..."
|
||||
//usage:#define gzip_full_usage "\n\n"
|
||||
@@ -1179,7 +1206,7 @@ static void gen_codes(ct_data * tree, int max_code)
|
||||
* must be all ones.
|
||||
*/
|
||||
Assert(code + G2.bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1,
|
||||
"inconsistent bit counts");
|
||||
"inconsistent bit counts");
|
||||
Tracev((stderr, "\ngen_codes: max_code %d ", max_code));
|
||||
|
||||
for (n = 0; n <= max_code; n++) {
|
||||
@@ -1527,9 +1554,9 @@ static int ct_tally(int dist, int lc)
|
||||
}
|
||||
out_length >>= 3;
|
||||
Trace((stderr,
|
||||
"\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ",
|
||||
G2.last_lit, G2.last_dist, in_length, out_length,
|
||||
100L - out_length * 100L / in_length));
|
||||
"\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ",
|
||||
G2.last_lit, G2.last_dist, in_length, out_length,
|
||||
100L - out_length * 100L / in_length));
|
||||
if (G2.last_dist < G2.last_lit / 2 && out_length < in_length / 2)
|
||||
return 1;
|
||||
}
|
||||
@@ -1621,9 +1648,9 @@ static ulg flush_block(char *buf, ulg stored_len, int eof)
|
||||
static_lenb = (G2.static_len + 3 + 7) >> 3;
|
||||
|
||||
Trace((stderr,
|
||||
"\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ",
|
||||
opt_lenb, G2.opt_len, static_lenb, G2.static_len, stored_len,
|
||||
G2.last_lit, G2.last_dist));
|
||||
"\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ",
|
||||
opt_lenb, G2.opt_len, static_lenb, G2.static_len, stored_len,
|
||||
G2.last_lit, G2.last_dist));
|
||||
|
||||
if (static_lenb <= opt_lenb)
|
||||
opt_lenb = static_lenb;
|
||||
@@ -1661,7 +1688,7 @@ static ulg flush_block(char *buf, ulg stored_len, int eof)
|
||||
} else {
|
||||
send_bits((DYN_TREES << 1) + eof, 3);
|
||||
send_all_trees(G2.l_desc.max_code + 1, G2.d_desc.max_code + 1,
|
||||
max_blindex + 1);
|
||||
max_blindex + 1);
|
||||
compress_block((ct_data *) G2.dyn_ltree, (ct_data *) G2.dyn_dtree);
|
||||
G2.compressed_len += 3 + G2.opt_len;
|
||||
}
|
||||
|
||||
@@ -38,31 +38,45 @@ DPKG_FILES:= \
|
||||
|
||||
INSERT
|
||||
|
||||
lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
|
||||
lib-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
|
||||
lib-$(CONFIG_UNLZMA) += decompress_unlzma.o
|
||||
lib-$(CONFIG_UNXZ) += decompress_unxz.o
|
||||
lib-$(CONFIG_CPIO) += get_header_cpio.o
|
||||
lib-$(CONFIG_DPKG) += $(DPKG_FILES)
|
||||
lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
|
||||
lib-$(CONFIG_GUNZIP) += decompress_gunzip.o
|
||||
lib-$(CONFIG_RPM2CPIO) += decompress_gunzip.o get_header_cpio.o
|
||||
lib-$(CONFIG_RPM) += open_transformer.o decompress_gunzip.o get_header_cpio.o
|
||||
|
||||
lib-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
|
||||
lib-$(CONFIG_CPIO) += get_header_cpio.o
|
||||
lib-$(CONFIG_TAR) += get_header_tar.o
|
||||
lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_UNZIP) += decompress_gunzip.o
|
||||
lib-$(CONFIG_FEATURE_TAR_TO_COMMAND) += data_extract_to_command.o
|
||||
lib-$(CONFIG_LZOP) += lzo1x_1.o lzo1x_1o.o lzo1x_d.o
|
||||
lib-$(CONFIG_LZOP_COMPR_HIGH) += lzo1x_9x.o
|
||||
lib-$(CONFIG_BUNZIP2) += open_transformer.o decompress_bunzip2.o
|
||||
lib-$(CONFIG_UNLZMA) += open_transformer.o decompress_unlzma.o
|
||||
lib-$(CONFIG_UNXZ) += open_transformer.o decompress_unxz.o
|
||||
lib-$(CONFIG_GUNZIP) += open_transformer.o decompress_gunzip.o
|
||||
lib-$(CONFIG_UNCOMPRESS) += open_transformer.o decompress_uncompress.o
|
||||
lib-$(CONFIG_UNZIP) += open_transformer.o decompress_gunzip.o
|
||||
lib-$(CONFIG_RPM2CPIO) += open_transformer.o decompress_gunzip.o get_header_cpio.o
|
||||
lib-$(CONFIG_RPM) += open_transformer.o decompress_gunzip.o get_header_cpio.o
|
||||
|
||||
lib-$(CONFIG_GZIP) += open_transformer.o
|
||||
lib-$(CONFIG_BZIP2) += open_transformer.o
|
||||
lib-$(CONFIG_LZOP) += open_transformer.o
|
||||
lib-$(CONFIG_MAN) += open_transformer.o
|
||||
lib-$(CONFIG_SETFONT) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_2_4_MODULES) += open_transformer.o
|
||||
lib-$(CONFIG_MODINFO) += open_transformer.o
|
||||
lib-$(CONFIG_INSMOD) += open_transformer.o
|
||||
lib-$(CONFIG_DEPMOD) += open_transformer.o
|
||||
lib-$(CONFIG_RMMOD) += open_transformer.o
|
||||
lib-$(CONFIG_LSMOD) += open_transformer.o
|
||||
lib-$(CONFIG_MODPROBE) += open_transformer.o
|
||||
lib-$(CONFIG_MODPROBE_SMALL) += open_transformer.o
|
||||
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_Z) += open_transformer.o decompress_uncompress.o
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_GZ) += open_transformer.o decompress_gunzip.o
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_BZ2) += open_transformer.o decompress_bunzip2.o
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_LZMA) += open_transformer.o decompress_unlzma.o
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_XZ) += open_transformer.o decompress_unxz.o
|
||||
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
|
||||
lib-$(CONFIG_FEATURE_COMPRESS_BBCONFIG) += decompress_bunzip2.o
|
||||
lib-$(CONFIG_FEATURE_TAR_TO_COMMAND) += data_extract_to_command.o
|
||||
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += open_transformer.o decompress_bunzip2.o
|
||||
lib-$(CONFIG_FEATURE_COMPRESS_BBCONFIG) += open_transformer.o decompress_bunzip2.o
|
||||
|
||||
ifneq ($(lib-y),)
|
||||
lib-y += $(COMMON_FILES)
|
||||
|
||||
@@ -249,7 +249,7 @@ void generateMTFValues(EState* s)
|
||||
static NOINLINE
|
||||
void sendMTFValues(EState* s)
|
||||
{
|
||||
int32_t v, t, i, j, gs, ge, totc, bt, bc, iter;
|
||||
int32_t v, t, i, j, gs, ge, bt, bc, iter;
|
||||
int32_t nSelectors, alphaSize, minLen, maxLen, selCtr;
|
||||
int32_t nGroups;
|
||||
|
||||
@@ -345,7 +345,6 @@ void sendMTFValues(EState* s)
|
||||
}
|
||||
#endif
|
||||
nSelectors = 0;
|
||||
totc = 0;
|
||||
gs = 0;
|
||||
while (1) {
|
||||
/*--- Set group start & end marks. --*/
|
||||
@@ -411,7 +410,6 @@ void sendMTFValues(EState* s)
|
||||
bt = t;
|
||||
}
|
||||
}
|
||||
totc += bc;
|
||||
fave[bt]++;
|
||||
s->selector[nSelectors] = bt;
|
||||
nSelectors++;
|
||||
@@ -501,14 +499,14 @@ void sendMTFValues(EState* s)
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (sizeof(long) <= 4) {
|
||||
inUse16 = inUse16*2 +
|
||||
((*(uint32_t*)&(s->inUse[i * 16 + 0])
|
||||
| *(uint32_t*)&(s->inUse[i * 16 + 4])
|
||||
| *(uint32_t*)&(s->inUse[i * 16 + 8])
|
||||
| *(uint32_t*)&(s->inUse[i * 16 + 12])) != 0);
|
||||
((*(bb__aliased_uint32_t*)&(s->inUse[i * 16 + 0])
|
||||
| *(bb__aliased_uint32_t*)&(s->inUse[i * 16 + 4])
|
||||
| *(bb__aliased_uint32_t*)&(s->inUse[i * 16 + 8])
|
||||
| *(bb__aliased_uint32_t*)&(s->inUse[i * 16 + 12])) != 0);
|
||||
} else { /* Our CPU can do better */
|
||||
inUse16 = inUse16*2 +
|
||||
((*(uint64_t*)&(s->inUse[i * 16 + 0])
|
||||
| *(uint64_t*)&(s->inUse[i * 16 + 8])) != 0);
|
||||
((*(bb__aliased_uint64_t*)&(s->inUse[i * 16 + 0])
|
||||
| *(bb__aliased_uint64_t*)&(s->inUse[i * 16 + 8])) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,15 +106,28 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
switch (file_header->mode & S_IFMT) {
|
||||
case S_IFREG: {
|
||||
/* Regular file */
|
||||
char *dst_name;
|
||||
int flags = O_WRONLY | O_CREAT | O_EXCL;
|
||||
if (archive_handle->ah_flags & ARCHIVE_O_TRUNC)
|
||||
flags = O_WRONLY | O_CREAT | O_TRUNC;
|
||||
dst_fd = xopen3(file_header->name,
|
||||
dst_name = file_header->name;
|
||||
#ifdef ARCHIVE_REPLACE_VIA_RENAME
|
||||
if (archive_handle->ah_flags & ARCHIVE_REPLACE_VIA_RENAME)
|
||||
/* rpm-style temp file name */
|
||||
dst_name = xasprintf("%s;%x", dst_name, (int)getpid());
|
||||
#endif
|
||||
dst_fd = xopen3(dst_name,
|
||||
flags,
|
||||
file_header->mode
|
||||
);
|
||||
bb_copyfd_exact_size(archive_handle->src_fd, dst_fd, file_header->size);
|
||||
close(dst_fd);
|
||||
#ifdef ARCHIVE_REPLACE_VIA_RENAME
|
||||
if (archive_handle->ah_flags & ARCHIVE_REPLACE_VIA_RENAME) {
|
||||
xrename(dst_name, file_header->name);
|
||||
free(dst_name);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case S_IFDIR:
|
||||
|
||||
@@ -103,7 +103,7 @@ void FAST_FUNC data_extract_to_command(archive_handle_t *archive_handle)
|
||||
archive_handle->tar__to_command_shell,
|
||||
"-c",
|
||||
archive_handle->tar__to_command,
|
||||
NULL);
|
||||
(char *)0);
|
||||
bb_perror_msg_and_die("can't execute '%s'", archive_handle->tar__to_command_shell);
|
||||
}
|
||||
close(p[0]);
|
||||
|
||||
@@ -42,6 +42,12 @@
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
|
||||
#if 0
|
||||
# define dbg(...) bb_error_msg(__VA_ARGS__)
|
||||
#else
|
||||
# define dbg(...) ((void)0)
|
||||
#endif
|
||||
|
||||
/* Constants for Huffman coding */
|
||||
#define MAX_GROUPS 6
|
||||
#define GROUP_SIZE 50 /* 64 would have been more efficient */
|
||||
@@ -52,13 +58,13 @@
|
||||
|
||||
/* Status return values */
|
||||
#define RETVAL_OK 0
|
||||
#define RETVAL_LAST_BLOCK (-1)
|
||||
#define RETVAL_NOT_BZIP_DATA (-2)
|
||||
#define RETVAL_UNEXPECTED_INPUT_EOF (-3)
|
||||
#define RETVAL_SHORT_WRITE (-4)
|
||||
#define RETVAL_DATA_ERROR (-5)
|
||||
#define RETVAL_OUT_OF_MEMORY (-6)
|
||||
#define RETVAL_OBSOLETE_INPUT (-7)
|
||||
#define RETVAL_LAST_BLOCK (dbg("%d", __LINE__), -1)
|
||||
#define RETVAL_NOT_BZIP_DATA (dbg("%d", __LINE__), -2)
|
||||
#define RETVAL_UNEXPECTED_INPUT_EOF (dbg("%d", __LINE__), -3)
|
||||
#define RETVAL_SHORT_WRITE (dbg("%d", __LINE__), -4)
|
||||
#define RETVAL_DATA_ERROR (dbg("%d", __LINE__), -5)
|
||||
#define RETVAL_OUT_OF_MEMORY (dbg("%d", __LINE__), -6)
|
||||
#define RETVAL_OBSOLETE_INPUT (dbg("%d", __LINE__), -7)
|
||||
|
||||
/* Other housekeeping constants */
|
||||
#define IOBUF_SIZE 4096
|
||||
@@ -440,7 +446,11 @@ static int get_next_block(bunzip_data *bd)
|
||||
literal used is the one at the head of the mtfSymbol array.) */
|
||||
if (runPos != 0) {
|
||||
uint8_t tmp_byte;
|
||||
if (dbufCount + runCnt >= dbufSize) return RETVAL_DATA_ERROR;
|
||||
if (dbufCount + runCnt > dbufSize) {
|
||||
dbg("dbufCount:%d+runCnt:%d %d > dbufSize:%d RETVAL_DATA_ERROR",
|
||||
dbufCount, runCnt, dbufCount + runCnt, dbufSize);
|
||||
return RETVAL_DATA_ERROR;
|
||||
}
|
||||
tmp_byte = symToByte[mtfSymbol[0]];
|
||||
byteCount[tmp_byte] += runCnt;
|
||||
while (--runCnt >= 0) dbuf[dbufCount++] = (uint32_t)tmp_byte;
|
||||
@@ -808,7 +818,6 @@ static char *const bunzip_errors[] = {
|
||||
/* Dumb little test thing, decompress stdin to stdout */
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
|
||||
int i = unpack_bz2_stream(0, 1);
|
||||
|
||||
@@ -293,8 +293,8 @@ static unsigned fill_bitbuffer(STATE_PARAM unsigned bitbuffer, unsigned *current
|
||||
* m: maximum lookup bits, returns actual
|
||||
*/
|
||||
static int huft_build(const unsigned *b, const unsigned n,
|
||||
const unsigned s, const unsigned short *d,
|
||||
const unsigned char *e, huft_t **t, unsigned *m)
|
||||
const unsigned s, const unsigned short *d,
|
||||
const unsigned char *e, huft_t **t, unsigned *m)
|
||||
{
|
||||
unsigned a; /* counter for codes of length k */
|
||||
unsigned c[BMAX + 1]; /* bit length count table */
|
||||
@@ -336,7 +336,7 @@ static int huft_build(const unsigned *b, const unsigned n,
|
||||
}
|
||||
|
||||
/* Find minimum and maximum length, bound *m by those */
|
||||
for (j = 1; (c[j] == 0) && (j <= BMAX); j++)
|
||||
for (j = 1; (j <= BMAX) && (c[j] == 0); j++)
|
||||
continue;
|
||||
k = j; /* minimum code length */
|
||||
for (i = BMAX; (c[i] == 0) && i; i--)
|
||||
|
||||
@@ -78,7 +78,6 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
IF_DESKTOP(long long total_written = 0;)
|
||||
IF_DESKTOP(long long) int retval = -1;
|
||||
unsigned char *stackp;
|
||||
long code;
|
||||
int finchar;
|
||||
long oldcode;
|
||||
long incode;
|
||||
@@ -143,8 +142,10 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
/* As above, initialize the first 256 entries in the table. */
|
||||
/*clear_tab_prefixof(); - done by xzalloc */
|
||||
|
||||
for (code = 255; code >= 0; --code) {
|
||||
tab_suffixof(code) = (unsigned char) code;
|
||||
{
|
||||
int i;
|
||||
for (i = 255; i >= 0; --i)
|
||||
tab_suffixof(i) = (unsigned char) i;
|
||||
}
|
||||
|
||||
do {
|
||||
@@ -175,6 +176,8 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
(insize << 3) - (n_bits - 1));
|
||||
|
||||
while (inbits > posbits) {
|
||||
long code;
|
||||
|
||||
if (free_ent > maxcode) {
|
||||
posbits =
|
||||
((posbits - 1) +
|
||||
@@ -191,13 +194,12 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
}
|
||||
{
|
||||
unsigned char *p = &inbuf[posbits >> 3];
|
||||
|
||||
code = ((((long) (p[0])) | ((long) (p[1]) << 8) |
|
||||
((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
|
||||
code = ((p[0]
|
||||
| ((long) (p[1]) << 8)
|
||||
| ((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
|
||||
}
|
||||
posbits += n_bits;
|
||||
|
||||
|
||||
if (oldcode == -1) {
|
||||
if (code >= 256)
|
||||
bb_error_msg_and_die("corrupted data"); /* %ld", code); */
|
||||
@@ -226,15 +228,16 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
/* Special case for KwKwK string. */
|
||||
if (code >= free_ent) {
|
||||
if (code > free_ent) {
|
||||
/*
|
||||
unsigned char *p;
|
||||
|
||||
posbits -= n_bits;
|
||||
p = &inbuf[posbits >> 3];
|
||||
|
||||
bb_error_msg
|
||||
("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)",
|
||||
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
|
||||
(posbits & 07));
|
||||
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
|
||||
(posbits & 07));
|
||||
*/
|
||||
bb_error_msg("corrupted data");
|
||||
goto err;
|
||||
}
|
||||
@@ -244,7 +247,7 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
}
|
||||
|
||||
/* Generate output characters in reverse order */
|
||||
while ((long) code >= (long) 256) {
|
||||
while (code >= 256) {
|
||||
if (stackp <= &htabof(0))
|
||||
bb_error_msg_and_die("corrupted data");
|
||||
*--stackp = tab_suffixof(code);
|
||||
@@ -285,11 +288,10 @@ unpack_Z_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
}
|
||||
|
||||
/* Generate the new entry. */
|
||||
code = free_ent;
|
||||
if (code < maxmaxcode) {
|
||||
tab_prefixof(code) = (unsigned short) oldcode;
|
||||
tab_suffixof(code) = (unsigned char) finchar;
|
||||
free_ent = code + 1;
|
||||
if (free_ent < maxmaxcode) {
|
||||
tab_prefixof(free_ent) = (unsigned short) oldcode;
|
||||
tab_suffixof(free_ent) = (unsigned char) finchar;
|
||||
free_ent++;
|
||||
}
|
||||
|
||||
/* Remember previous code. */
|
||||
|
||||
@@ -45,16 +45,16 @@ typedef struct {
|
||||
#define RC_MODEL_TOTAL_BITS 11
|
||||
|
||||
|
||||
/* Called twice: once at startup (LZMA_FAST only) and once in rc_normalize() */
|
||||
static size_inline void rc_read(rc_t *rc)
|
||||
/* Called once in rc_do_normalize() */
|
||||
static void rc_read(rc_t *rc)
|
||||
{
|
||||
int buffer_size = safe_read(rc->fd, RC_BUFFER, RC_BUFFER_SIZE);
|
||||
//TODO: return -1 instead
|
||||
//This will make unlzma delete broken unpacked file on unpack errors
|
||||
if (buffer_size <= 0)
|
||||
bb_error_msg_and_die("unexpected EOF");
|
||||
rc->ptr = RC_BUFFER;
|
||||
rc->buffer_end = RC_BUFFER + buffer_size;
|
||||
rc->ptr = RC_BUFFER;
|
||||
}
|
||||
|
||||
/* Called twice, but one callsite is in speed_inline'd rc_is_bit_1() */
|
||||
@@ -65,6 +65,12 @@ static void rc_do_normalize(rc_t *rc)
|
||||
rc->range <<= 8;
|
||||
rc->code = (rc->code << 8) | *rc->ptr++;
|
||||
}
|
||||
static ALWAYS_INLINE void rc_normalize(rc_t *rc)
|
||||
{
|
||||
if (rc->range < (1 << RC_TOP_BITS)) {
|
||||
rc_do_normalize(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/* Called once */
|
||||
static ALWAYS_INLINE rc_t* rc_init(int fd) /*, int buffer_size) */
|
||||
@@ -78,15 +84,9 @@ static ALWAYS_INLINE rc_t* rc_init(int fd) /*, int buffer_size) */
|
||||
/* rc->ptr = rc->buffer_end; */
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
#if ENABLE_FEATURE_LZMA_FAST
|
||||
if (rc->ptr >= rc->buffer_end)
|
||||
rc_read(rc);
|
||||
rc->code = (rc->code << 8) | *rc->ptr++;
|
||||
#else
|
||||
rc_do_normalize(rc);
|
||||
#endif
|
||||
}
|
||||
rc->range = 0xFFFFFFFF;
|
||||
rc->range = 0xffffffff;
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -96,13 +96,6 @@ static ALWAYS_INLINE void rc_free(rc_t *rc)
|
||||
free(rc);
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void rc_normalize(rc_t *rc)
|
||||
{
|
||||
if (rc->range < (1 << RC_TOP_BITS)) {
|
||||
rc_do_normalize(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/* rc_is_bit_1 is called 9 times */
|
||||
static speed_inline int rc_is_bit_1(rc_t *rc, uint16_t *p)
|
||||
{
|
||||
@@ -120,7 +113,7 @@ static speed_inline int rc_is_bit_1(rc_t *rc, uint16_t *p)
|
||||
}
|
||||
|
||||
/* Called 4 times in unlzma loop */
|
||||
static speed_inline int rc_get_bit(rc_t *rc, uint16_t *p, int *symbol)
|
||||
static ALWAYS_INLINE int rc_get_bit(rc_t *rc, uint16_t *p, int *symbol)
|
||||
{
|
||||
int ret = rc_is_bit_1(rc, p);
|
||||
*symbol = *symbol * 2 + ret;
|
||||
|
||||
@@ -30,8 +30,8 @@ static uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc)
|
||||
/* We use arch-optimized unaligned accessors */
|
||||
#define get_unaligned_le32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_LE32(v); })
|
||||
#define get_unaligned_be32(buf) ({ uint32_t v; move_from_unaligned32(v, buf); SWAP_BE32(v); })
|
||||
#define put_unaligned_le32(val, buf) move_to_unaligned16(buf, SWAP_LE32(val))
|
||||
#define put_unaligned_be32(val, buf) move_to_unaligned16(buf, SWAP_BE32(val))
|
||||
#define put_unaligned_le32(val, buf) move_to_unaligned32(buf, SWAP_LE32(val))
|
||||
#define put_unaligned_be32(val, buf) move_to_unaligned32(buf, SWAP_BE32(val))
|
||||
|
||||
#include "unxz/xz_dec_bcj.c"
|
||||
#include "unxz/xz_dec_lzma2.c"
|
||||
@@ -40,6 +40,7 @@ static uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc)
|
||||
IF_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_xz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
{
|
||||
enum xz_ret xz_result;
|
||||
struct xz_buf iobuf;
|
||||
struct xz_dec *state;
|
||||
unsigned char *membuf;
|
||||
@@ -63,9 +64,8 @@ unpack_xz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
/* Limit memory usage to about 64 MiB. */
|
||||
state = xz_dec_init(XZ_DYNALLOC, 64*1024*1024);
|
||||
|
||||
xz_result = X_OK;
|
||||
while (1) {
|
||||
enum xz_ret r;
|
||||
|
||||
if (iobuf.in_pos == iobuf.in_size) {
|
||||
int rd = safe_read(src_fd, membuf, BUFSIZ);
|
||||
if (rd < 0) {
|
||||
@@ -73,28 +73,57 @@ unpack_xz_stream(transformer_aux_data_t *aux, int src_fd, int dst_fd)
|
||||
total = -1;
|
||||
break;
|
||||
}
|
||||
if (rd == 0 && xz_result == XZ_STREAM_END)
|
||||
break;
|
||||
iobuf.in_size = rd;
|
||||
iobuf.in_pos = 0;
|
||||
}
|
||||
if (xz_result == XZ_STREAM_END) {
|
||||
/*
|
||||
* Try to start decoding next concatenated stream.
|
||||
* Stream padding must always be a multiple of four
|
||||
* bytes to preserve four-byte alignment. To keep the
|
||||
* code slightly smaller, we aren't as strict here as
|
||||
* the .xz spec requires. We just skip all zero-bytes
|
||||
* without checking the alignment and thus can accept
|
||||
* files that aren't valid, e.g. the XZ utils test
|
||||
* files bad-0pad-empty.xz and bad-0catpad-empty.xz.
|
||||
*/
|
||||
do {
|
||||
if (membuf[iobuf.in_pos] != 0) {
|
||||
xz_dec_reset(state);
|
||||
goto do_run;
|
||||
}
|
||||
iobuf.in_pos++;
|
||||
} while (iobuf.in_pos < iobuf.in_size);
|
||||
}
|
||||
do_run:
|
||||
// bb_error_msg(">in pos:%d size:%d out pos:%d size:%d",
|
||||
// iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size);
|
||||
r = xz_dec_run(state, &iobuf);
|
||||
xz_result = xz_dec_run(state, &iobuf);
|
||||
// bb_error_msg("<in pos:%d size:%d out pos:%d size:%d r:%d",
|
||||
// iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size, r);
|
||||
// iobuf.in_pos, iobuf.in_size, iobuf.out_pos, iobuf.out_size, xz_result);
|
||||
if (iobuf.out_pos) {
|
||||
xwrite(dst_fd, iobuf.out, iobuf.out_pos);
|
||||
IF_DESKTOP(total += iobuf.out_pos;)
|
||||
iobuf.out_pos = 0;
|
||||
}
|
||||
if (r == XZ_STREAM_END) {
|
||||
break;
|
||||
if (xz_result == XZ_STREAM_END) {
|
||||
/*
|
||||
* Can just "break;" here, if not for concatenated
|
||||
* .xz streams.
|
||||
* Checking for padding may require buffer
|
||||
* replenishment. Can't do it here.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
if (r != XZ_OK && r != XZ_UNSUPPORTED_CHECK) {
|
||||
if (xz_result != XZ_OK && xz_result != XZ_UNSUPPORTED_CHECK) {
|
||||
bb_error_msg("corrupted data");
|
||||
total = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
xz_dec_end(state);
|
||||
free(membuf);
|
||||
|
||||
|
||||
@@ -24,11 +24,13 @@ char FAST_FUNC filter_accept_reject_list(archive_handle_t *archive_handle)
|
||||
if (reject_entry) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
accept_entry = find_list_entry2(archive_handle->accept, key);
|
||||
|
||||
/* Fail if an accept list was specified and the key wasnt in there */
|
||||
if ((accept_entry == NULL) && archive_handle->accept) {
|
||||
return EXIT_FAILURE;
|
||||
if (archive_handle->accept) {
|
||||
accept_entry = find_list_entry2(archive_handle->accept, key);
|
||||
if (!accept_entry) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* Accepted */
|
||||
|
||||
@@ -8,11 +8,19 @@
|
||||
#include "bb_archive.h"
|
||||
#include "ar.h"
|
||||
|
||||
static unsigned read_num(const char *str, int base)
|
||||
/* WARNING: Clobbers str[len], so fields must be read in reverse order! */
|
||||
static unsigned read_num(char *str, int base, int len)
|
||||
{
|
||||
int err;
|
||||
|
||||
/* ar fields are fixed length text strings (padded with spaces).
|
||||
* Ensure bb_strtou doesn't read past the field in case the full
|
||||
* width is used. */
|
||||
str[len] = 0;
|
||||
|
||||
/* This code works because
|
||||
* on misformatted numbers bb_strtou returns all-ones */
|
||||
int err = bb_strtou(str, NULL, base);
|
||||
err = bb_strtou(str, NULL, base);
|
||||
if (err == -1)
|
||||
bb_error_msg_and_die("invalid ar header");
|
||||
return err;
|
||||
@@ -51,11 +59,13 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
|
||||
if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n')
|
||||
bb_error_msg_and_die("invalid ar header");
|
||||
|
||||
/* FIXME: more thorough routine would be in order here
|
||||
* (we have something like that in tar)
|
||||
* but for now we are lax. */
|
||||
ar.formatted.magic[0] = '\0'; /* else 4G-2 file will have size="4294967294`\n..." */
|
||||
typed->size = size = read_num(ar.formatted.size, 10);
|
||||
/*
|
||||
* Note that the fields MUST be read in reverse order as
|
||||
* read_num() clobbers the next byte after the field!
|
||||
* Order is: name, date, uid, gid, mode, size, magic.
|
||||
*/
|
||||
typed->size = size = read_num(ar.formatted.size, 10,
|
||||
sizeof(ar.formatted.size));
|
||||
|
||||
/* special filenames have '/' as the first character */
|
||||
if (ar.formatted.name[0] == '/') {
|
||||
@@ -87,10 +97,10 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
|
||||
* long filename pseudo file. Thus we decode the rest
|
||||
* after dealing with long filename pseudo file.
|
||||
*/
|
||||
typed->mode = read_num(ar.formatted.mode, 8);
|
||||
typed->mtime = read_num(ar.formatted.date, 10);
|
||||
typed->uid = read_num(ar.formatted.uid, 10);
|
||||
typed->gid = read_num(ar.formatted.gid, 10);
|
||||
typed->mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode));
|
||||
typed->gid = read_num(ar.formatted.gid, 10, sizeof(ar.formatted.gid));
|
||||
typed->uid = read_num(ar.formatted.uid, 10, sizeof(ar.formatted.uid));
|
||||
typed->mtime = read_num(ar.formatted.date, 10, sizeof(ar.formatted.date));
|
||||
|
||||
#if ENABLE_FEATURE_AR_LONG_FILENAMES
|
||||
if (ar.formatted.name[0] == '/') {
|
||||
@@ -98,7 +108,8 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
|
||||
|
||||
/* The number after the '/' indicates the offset in the ar data section
|
||||
* (saved in ar_long_names) that conatains the real filename */
|
||||
long_offset = read_num(&ar.formatted.name[1], 10);
|
||||
long_offset = read_num(&ar.formatted.name[1], 10,
|
||||
sizeof(ar.formatted.name) - 1);
|
||||
if (long_offset >= ar_long_name_size) {
|
||||
bb_error_msg_and_die("can't resolve long filename");
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ static unsigned long long getOctal(char *str, int len)
|
||||
first >>= 1; /* now 7th bit = 6th bit */
|
||||
v = first; /* sign-extend 8 bits to 64 */
|
||||
while (--len != 0)
|
||||
v = (v << 8) + (unsigned char) *str++;
|
||||
v = (v << 8) + (uint8_t) *++str;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
@@ -198,13 +198,13 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
* the message and we don't check whether we indeed
|
||||
* saw zero block directly before this. */
|
||||
if (i == 0) {
|
||||
xfunc_error_retval = 0;
|
||||
short_read:
|
||||
bb_error_msg_and_die("short read");
|
||||
bb_error_msg("short read");
|
||||
/* this merely signals end of archive, not exit(1): */
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (i != 512) {
|
||||
IF_FEATURE_TAR_AUTODETECT(goto autodetect;)
|
||||
goto short_read;
|
||||
bb_error_msg_and_die("short read");
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -221,10 +221,10 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
*/
|
||||
while (full_read(archive_handle->src_fd, &tar, 512) == 512)
|
||||
continue;
|
||||
return EXIT_FAILURE;
|
||||
return EXIT_FAILURE; /* "end of archive" */
|
||||
}
|
||||
archive_handle->tar__end = 1;
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_SUCCESS; /* "decoded one header" */
|
||||
}
|
||||
archive_handle->tar__end = 0;
|
||||
|
||||
@@ -452,9 +452,11 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
if (cp)
|
||||
*cp = '\0';
|
||||
archive_handle->action_data(archive_handle);
|
||||
if (archive_handle->accept || archive_handle->reject)
|
||||
if (archive_handle->accept || archive_handle->reject
|
||||
|| (archive_handle->ah_flags & ARCHIVE_REMEMBER_NAMES)
|
||||
) {
|
||||
llist_add_to(&archive_handle->passed, file_header->name);
|
||||
else /* Caller isn't interested in list of unpacked files */
|
||||
} else /* Caller isn't interested in list of unpacked files */
|
||||
free(file_header->name);
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
@@ -469,5 +471,5 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
free(file_header->tar__uname);
|
||||
free(file_header->tar__gname);
|
||||
#endif
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_SUCCESS; /* "decoded one header" */
|
||||
}
|
||||
@@ -76,11 +76,13 @@
|
||||
# define TEST_IP (ip < ip_end)
|
||||
# define NEED_IP(x) \
|
||||
if ((unsigned)(ip_end - ip) < (unsigned)(x)) goto input_overrun
|
||||
# define TEST_IV(x) if ((x) > (unsigned)0 - (511)) goto input_overrun
|
||||
|
||||
# undef TEST_OP /* don't need both of the tests here */
|
||||
# define TEST_OP 1
|
||||
# define NEED_OP(x) \
|
||||
if ((unsigned)(op_end - op) < (unsigned)(x)) goto output_overrun
|
||||
# define TEST_OV(x) if ((x) > (unsigned)0 - (511)) goto output_overrun
|
||||
|
||||
#define HAVE_ANY_OP 1
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ typedef struct {
|
||||
( ((0x9f5f * ((((b[p]<<5)^b[p+1])<<5) ^ b[p+2])) >> 5) & (SWD_HSIZE-1) )
|
||||
|
||||
#if defined(LZO_UNALIGNED_OK_2)
|
||||
# define HEAD2(b,p) (* (uint16_t *) &(b[p]))
|
||||
# define HEAD2(b,p) (* (bb__aliased_uint16_t *) &(b[p]))
|
||||
#else
|
||||
# define HEAD2(b,p) (b[p] ^ ((unsigned)b[p+1]<<8))
|
||||
#endif
|
||||
@@ -466,7 +466,6 @@ static int find_match(lzo1x_999_t *c, lzo_swd_p s,
|
||||
}
|
||||
|
||||
s->m_len = 1;
|
||||
s->m_len = 1;
|
||||
#ifdef SWD_BEST_OFF
|
||||
if (s->use_best_off)
|
||||
memset(s->best_pos, 0, sizeof(s->best_pos));
|
||||
@@ -644,7 +643,7 @@ static int len_of_coded_match(unsigned m_len, unsigned m_off, unsigned lit)
|
||||
|
||||
|
||||
static int min_gain(unsigned ahead, unsigned lit1,
|
||||
unsigned lit2, int l1, int l2, int l3)
|
||||
unsigned lit2, int l1, int l2, int l3)
|
||||
{
|
||||
int lazy_match_min_gain = 0;
|
||||
|
||||
@@ -673,7 +672,7 @@ static int min_gain(unsigned ahead, unsigned lit1,
|
||||
#if defined(SWD_BEST_OFF)
|
||||
|
||||
static void better_match(const lzo_swd_p swd,
|
||||
unsigned *m_len, unsigned *m_off)
|
||||
unsigned *m_len, unsigned *m_off)
|
||||
{
|
||||
if (*m_len <= M2_MIN_LEN)
|
||||
return;
|
||||
@@ -914,8 +913,8 @@ int lzo1x_999_compress_level(const uint8_t *in, unsigned in_len,
|
||||
|
||||
compression_level -= 7;
|
||||
return lzo1x_999_compress_internal(in, in_len, out, out_len, wrkmem,
|
||||
c[compression_level].good_length,
|
||||
c[compression_level].max_lazy,
|
||||
c[compression_level].max_chain,
|
||||
c[compression_level].use_best_off);
|
||||
c[compression_level].good_length,
|
||||
c[compression_level].max_lazy,
|
||||
c[compression_level].max_chain,
|
||||
c[compression_level].use_best_off);
|
||||
}
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
The LZO library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
The LZO library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
@@ -92,6 +92,7 @@ int lzo1x_decompress_safe(const uint8_t* in, unsigned in_len,
|
||||
ip++;
|
||||
NEED_IP(1);
|
||||
}
|
||||
TEST_IV(t);
|
||||
t += 15 + *ip++;
|
||||
}
|
||||
/* copy literals */
|
||||
@@ -224,6 +225,7 @@ int lzo1x_decompress_safe(const uint8_t* in, unsigned in_len,
|
||||
ip++;
|
||||
NEED_IP(1);
|
||||
}
|
||||
TEST_IV(t);
|
||||
t += 31 + *ip++;
|
||||
}
|
||||
#if defined(COPY_DICT)
|
||||
@@ -265,6 +267,7 @@ int lzo1x_decompress_safe(const uint8_t* in, unsigned in_len,
|
||||
ip++;
|
||||
NEED_IP(1);
|
||||
}
|
||||
TEST_IV(t);
|
||||
t += 7 + *ip++;
|
||||
}
|
||||
#if defined(COPY_DICT)
|
||||
|
||||
@@ -34,6 +34,7 @@ void check_errors_in_children(int signo)
|
||||
if (!signo) {
|
||||
/* block waiting for any child */
|
||||
if (wait(&status) < 0)
|
||||
//FIXME: check EINTR?
|
||||
return; /* probably there are no children */
|
||||
goto check_status;
|
||||
}
|
||||
@@ -41,14 +42,18 @@ void check_errors_in_children(int signo)
|
||||
/* Wait for any child without blocking */
|
||||
for (;;) {
|
||||
if (wait_any_nohang(&status) < 0)
|
||||
//FIXME: check EINTR?
|
||||
/* wait failed?! I'm confused... */
|
||||
return;
|
||||
check_status:
|
||||
if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
|
||||
/*if (WIFEXITED(status) && WEXITSTATUS(status) == 0)*/
|
||||
/* On Linux, the above can be checked simply as: */
|
||||
if (status == 0)
|
||||
/* this child exited with 0 */
|
||||
continue;
|
||||
/* Cannot happen?
|
||||
if (!WIFSIGNALED(status) && !WIFEXITED(status)) ???; */
|
||||
/* Cannot happen:
|
||||
if (!WIFSIGNALED(status) && !WIFEXITED(status)) ???;
|
||||
*/
|
||||
bb_got_signal = 1;
|
||||
}
|
||||
}
|
||||
@@ -74,16 +79,17 @@ void FAST_FUNC open_transformer(int fd, const char *transform_prog)
|
||||
// FIXME: error check?
|
||||
#if BB_MMU
|
||||
{
|
||||
IF_DESKTOP(long long) int r;
|
||||
transformer_aux_data_t aux;
|
||||
init_transformer_aux_data(&aux);
|
||||
aux.check_signature = check_signature;
|
||||
transformer(&aux, fd, fd_pipe.wr);
|
||||
r = transformer(&aux, fd, fd_pipe.wr);
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(fd_pipe.wr); /* send EOF */
|
||||
close(fd);
|
||||
}
|
||||
/* must be _exit! bug was actually seen here */
|
||||
_exit(EXIT_SUCCESS);
|
||||
_exit(/*error if:*/ r < 0);
|
||||
}
|
||||
#else
|
||||
{
|
||||
@@ -176,27 +182,26 @@ int FAST_FUNC setup_unzip_on_fd(int fd, int fail_if_not_detected)
|
||||
|
||||
int FAST_FUNC open_zipped(const char *fname)
|
||||
{
|
||||
char *sfx;
|
||||
int fd;
|
||||
|
||||
fd = open(fname, O_RDONLY);
|
||||
if (fd < 0)
|
||||
return fd;
|
||||
|
||||
sfx = strrchr(fname, '.');
|
||||
if (sfx) {
|
||||
sfx++;
|
||||
if (ENABLE_FEATURE_SEAMLESS_LZMA && strcmp(sfx, "lzma") == 0)
|
||||
/* .lzma has no header/signature, just trust it */
|
||||
if (ENABLE_FEATURE_SEAMLESS_LZMA) {
|
||||
/* .lzma has no header/signature, can only detect it by extension */
|
||||
char *sfx = strrchr(fname, '.');
|
||||
if (sfx && strcmp(sfx+1, "lzma") == 0) {
|
||||
open_transformer_with_sig(fd, unpack_lzma_stream, "unlzma");
|
||||
else
|
||||
if ((ENABLE_FEATURE_SEAMLESS_GZ && strcmp(sfx, "gz") == 0)
|
||||
|| (ENABLE_FEATURE_SEAMLESS_BZ2 && strcmp(sfx, "bz2") == 0)
|
||||
|| (ENABLE_FEATURE_SEAMLESS_XZ && strcmp(sfx, "xz") == 0)
|
||||
) {
|
||||
setup_unzip_on_fd(fd, /*fail_if_not_detected:*/ 1);
|
||||
return fd;
|
||||
}
|
||||
}
|
||||
if ((ENABLE_FEATURE_SEAMLESS_GZ)
|
||||
|| (ENABLE_FEATURE_SEAMLESS_BZ2)
|
||||
|| (ENABLE_FEATURE_SEAMLESS_XZ)
|
||||
) {
|
||||
setup_unzip_on_fd(fd, /*fail_if_not_detected:*/ 1);
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ XZ Embedded
|
||||
|
||||
XZ Embedded was written for use in the Linux kernel, but the code can
|
||||
be easily used in other environments too, including regular userspace
|
||||
applications.
|
||||
applications. See userspace/xzminidec.c for an example program.
|
||||
|
||||
This README contains information that is useful only when the copy
|
||||
of XZ Embedded isn't part of the Linux kernel tree. You should also
|
||||
@@ -55,7 +55,7 @@ Compiler requirements
|
||||
code is modified not to support large files, which needs some more
|
||||
care than just using 32-bit integer instead of 64-bit).
|
||||
|
||||
If you use GCC, try to use a recent version. For example, on x86,
|
||||
If you use GCC, try to use a recent version. For example, on x86-32,
|
||||
xz_dec_lzma2.c compiled with GCC 3.3.6 is 15-25 % slower than when
|
||||
compiled with GCC 4.3.3.
|
||||
|
||||
@@ -93,7 +93,7 @@ BCJ filter support
|
||||
them always #defined doesn't hurt either.
|
||||
|
||||
#define Instruction set BCJ filter endianness
|
||||
XZ_DEC_X86 x86 or x86-64 Little endian only
|
||||
XZ_DEC_X86 x86-32 or x86-64 Little endian only
|
||||
XZ_DEC_POWERPC PowerPC Big endian only
|
||||
XZ_DEC_IA64 Itanium (IA-64) Big or little endian
|
||||
XZ_DEC_ARM ARM Little endian only
|
||||
|
||||
@@ -19,6 +19,10 @@
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* In Linux, this is used to make extern functions static when needed. */
|
||||
#ifndef XZ_EXTERN
|
||||
# define XZ_EXTERN extern
|
||||
@@ -70,7 +74,7 @@ enum xz_mode {
|
||||
* @XZ_UNSUPPORTED_CHECK: Integrity check type is not supported. Decoding
|
||||
* is still possible in multi-call mode by simply
|
||||
* calling xz_dec_run() again.
|
||||
* NOTE: This return value is used only if
|
||||
* Note that this return value is used only if
|
||||
* XZ_DEC_ANY_CHECK was defined at build time,
|
||||
* which is not used in the kernel. Unsupported
|
||||
* check types return XZ_OPTIONS_ERROR if
|
||||
@@ -105,7 +109,7 @@ enum xz_mode {
|
||||
* stream that is truncated or otherwise corrupt.
|
||||
*
|
||||
* In single-call mode, XZ_BUF_ERROR is returned only when the output buffer
|
||||
* is too small, or the compressed input is corrupt in a way that makes the
|
||||
* is too small or the compressed input is corrupt in a way that makes the
|
||||
* decoder produce more output than the caller expected. When it is
|
||||
* (relatively) clear that the compressed input is truncated, XZ_DATA_ERROR
|
||||
* is used instead of XZ_BUF_ERROR.
|
||||
@@ -207,8 +211,8 @@ XZ_EXTERN struct xz_dec * XZ_FUNC xz_dec_init(
|
||||
* The possible return values depend on build options and operation mode.
|
||||
* See enum xz_ret for details.
|
||||
*
|
||||
* NOTE: If an error occurs in single-call mode (return value is not
|
||||
* XZ_STREAM_END), b->in_pos and b->out_pos are not modified, and the
|
||||
* Note that if an error occurs in single-call mode (return value is not
|
||||
* XZ_STREAM_END), b->in_pos and b->out_pos are not modified and the
|
||||
* contents of the output buffer from b->out[b->out_pos] onward are
|
||||
* undefined. This is true even after XZ_BUF_ERROR, because with some filter
|
||||
* chains, there may be a second pass over the output buffer, and this pass
|
||||
@@ -268,4 +272,9 @@ XZ_EXTERN void XZ_FUNC xz_crc32_init(void);
|
||||
XZ_EXTERN uint32_t XZ_FUNC xz_crc32(
|
||||
const uint8_t *buf, size_t size, uint32_t crc);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -77,10 +77,13 @@ struct xz_dec_bcj {
|
||||
|
||||
#ifdef XZ_DEC_X86
|
||||
/*
|
||||
* This is macro used to test the most significant byte of a memory address
|
||||
* This is used to test the most significant byte of a memory address
|
||||
* in an x86 instruction.
|
||||
*/
|
||||
#define bcj_x86_test_msbyte(b) ((b) == 0x00 || (b) == 0xFF)
|
||||
static inline int bcj_x86_test_msbyte(uint8_t b)
|
||||
{
|
||||
return b == 0x00 || b == 0xFF;
|
||||
}
|
||||
|
||||
static noinline_for_stack size_t XZ_FUNC bcj_x86(
|
||||
struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
||||
@@ -443,8 +446,12 @@ XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_bcj_run(struct xz_dec_bcj *s,
|
||||
* next filter in the chain. Apply the BCJ filter on the new data
|
||||
* in the output buffer. If everything cannot be filtered, copy it
|
||||
* to temp and rewind the output buffer position accordingly.
|
||||
*
|
||||
* This needs to be always run when temp.size == 0 to handle a special
|
||||
* case where the output buffer is full and the next filter has no
|
||||
* more output coming but hasn't returned XZ_STREAM_END yet.
|
||||
*/
|
||||
if (s->temp.size < b->out_size - b->out_pos) {
|
||||
if (s->temp.size < b->out_size - b->out_pos || s->temp.size == 0) {
|
||||
out_start = b->out_pos;
|
||||
memcpy(b->out + b->out_pos, s->temp.buf, s->temp.size);
|
||||
b->out_pos += s->temp.size;
|
||||
@@ -467,16 +474,25 @@ XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_bcj_run(struct xz_dec_bcj *s,
|
||||
s->temp.size = b->out_pos - out_start;
|
||||
b->out_pos -= s->temp.size;
|
||||
memcpy(s->temp.buf, b->out + b->out_pos, s->temp.size);
|
||||
|
||||
/*
|
||||
* If there wasn't enough input to the next filter to fill
|
||||
* the output buffer with unfiltered data, there's no point
|
||||
* to try decoding more data to temp.
|
||||
*/
|
||||
if (b->out_pos + s->temp.size < b->out_size)
|
||||
return XZ_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we have unfiltered data in temp, try to fill by decoding more
|
||||
* data from the next filter. Apply the BCJ filter on temp. Then we
|
||||
* hopefully can fill the actual output buffer by copying filtered
|
||||
* data from temp. A mix of filtered and unfiltered data may be left
|
||||
* in temp; it will be taken care on the next call to this function.
|
||||
* We have unfiltered data in temp. If the output buffer isn't full
|
||||
* yet, try to fill the temp buffer by decoding more data from the
|
||||
* next filter. Apply the BCJ filter on temp. Then we hopefully can
|
||||
* fill the actual output buffer by copying filtered data from temp.
|
||||
* A mix of filtered and unfiltered data may be left in temp; it will
|
||||
* be taken care on the next call to this function.
|
||||
*/
|
||||
if (s->temp.size > 0) {
|
||||
if (b->out_pos < b->out_size) {
|
||||
/* Make b->out{,_pos,_size} temporarily point to s->temp. */
|
||||
s->out = b->out;
|
||||
s->out_pos = b->out_pos;
|
||||
|
||||
@@ -407,7 +407,6 @@ static void XZ_FUNC dict_uncompressed(
|
||||
|
||||
b->out_pos += copy_size;
|
||||
b->in_pos += copy_size;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -972,6 +971,9 @@ XZ_EXTERN NOINLINE enum xz_ret XZ_FUNC xz_dec_lzma2_run(
|
||||
*/
|
||||
tmp = b->in[b->in_pos++];
|
||||
|
||||
if (tmp == 0x00)
|
||||
return XZ_STREAM_END;
|
||||
|
||||
if (tmp >= 0xE0 || tmp == 0x01) {
|
||||
s->lzma2.need_props = true;
|
||||
s->lzma2.need_dict_reset = false;
|
||||
@@ -1004,9 +1006,6 @@ XZ_EXTERN NOINLINE enum xz_ret XZ_FUNC xz_dec_lzma2_run(
|
||||
lzma_reset(s);
|
||||
}
|
||||
} else {
|
||||
if (tmp == 0x00)
|
||||
return XZ_STREAM_END;
|
||||
|
||||
if (tmp > 0x02)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
|
||||
@@ -25,15 +25,20 @@
|
||||
|
||||
#define STREAM_HEADER_SIZE 12
|
||||
|
||||
#define HEADER_MAGIC "\3757zXZ\0"
|
||||
#define HEADER_MAGIC "\3757zXZ"
|
||||
#define HEADER_MAGIC_SIZE 6
|
||||
|
||||
#define FOOTER_MAGIC "YZ"
|
||||
#define FOOTER_MAGIC_SIZE 2
|
||||
|
||||
/*
|
||||
* Variable-length integer can hold a 63-bit unsigned integer, or a special
|
||||
* value to indicate that the value is unknown.
|
||||
* Variable-length integer can hold a 63-bit unsigned integer or a special
|
||||
* value indicating that the value is unknown.
|
||||
*
|
||||
* Experimental: vli_type can be defined to uint32_t to save a few bytes
|
||||
* in code size (no effect on speed). Doing so limits the uncompressed and
|
||||
* compressed size of the file to less than 256 MiB and may also weaken
|
||||
* error detection slightly.
|
||||
*/
|
||||
typedef uint64_t vli_type;
|
||||
|
||||
|
||||
+42
-20
@@ -14,7 +14,7 @@
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
@@ -25,6 +25,26 @@
|
||||
"Minimalized" for busybox by Alain Knaff
|
||||
*/
|
||||
|
||||
//config:config LZOP
|
||||
//config: bool "lzop"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Lzop compression/decompresion.
|
||||
//config:
|
||||
//config:config LZOP_COMPR_HIGH
|
||||
//config: bool "lzop compression levels 7,8,9 (not very useful)"
|
||||
//config: default n
|
||||
//config: depends on LZOP
|
||||
//config: help
|
||||
//config: High levels (7,8,9) of lzop compression. These levels
|
||||
//config: are actually slower than gzip at equivalent compression ratios
|
||||
//config: and take up 3.2K of code.
|
||||
|
||||
//applet:IF_LZOP(APPLET(lzop, BB_DIR_BIN, BB_SUID_DROP))
|
||||
//applet:IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat))
|
||||
//applet:IF_LZOP(APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop))
|
||||
//kbuild:lib-$(CONFIG_LZOP) += lzop.o
|
||||
|
||||
//usage:#define lzop_trivial_usage
|
||||
//usage: "[-cfvd123456789CF] [FILE]..."
|
||||
//usage:#define lzop_full_usage "\n\n"
|
||||
@@ -116,7 +136,7 @@ static NOINLINE int lzo1x_optimize(uint8_t *in, unsigned in_len,
|
||||
unsigned nl;
|
||||
unsigned long o_m1_a = 0, o_m1_b = 0, o_m2 = 0, o_m3_a = 0, o_m3_b = 0;
|
||||
|
||||
// LZO_UNUSED(wrkmem);
|
||||
// LZO_UNUSED(wrkmem);
|
||||
|
||||
*out_len = 0;
|
||||
|
||||
@@ -346,11 +366,11 @@ static NOINLINE int lzo1x_optimize(uint8_t *in, unsigned in_len,
|
||||
return LZO_E_EOF_NOT_FOUND;
|
||||
|
||||
eof_found:
|
||||
// LZO_UNUSED(o_m1_a); LZO_UNUSED(o_m1_b); LZO_UNUSED(o_m2);
|
||||
// LZO_UNUSED(o_m3_a); LZO_UNUSED(o_m3_b);
|
||||
// LZO_UNUSED(o_m1_a); LZO_UNUSED(o_m1_b); LZO_UNUSED(o_m2);
|
||||
// LZO_UNUSED(o_m3_a); LZO_UNUSED(o_m3_b);
|
||||
*out_len = pd(op, out);
|
||||
return (ip == ip_end ? LZO_E_OK :
|
||||
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
|
||||
(ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
|
||||
}
|
||||
|
||||
/**********************************************************************/
|
||||
@@ -436,25 +456,27 @@ struct globals {
|
||||
//#define LZOP_VERSION_STRING "1.01"
|
||||
//#define LZOP_VERSION_DATE "Apr 27th 2003"
|
||||
|
||||
#define OPTION_STRING "cfvdt123456789CF"
|
||||
#define OPTION_STRING "cfvqdt123456789CF"
|
||||
|
||||
/* Note: must be kept in sync with archival/bbunzip.c */
|
||||
enum {
|
||||
OPT_STDOUT = (1 << 0),
|
||||
OPT_FORCE = (1 << 1),
|
||||
OPT_VERBOSE = (1 << 2),
|
||||
OPT_DECOMPRESS = (1 << 3),
|
||||
OPT_TEST = (1 << 4),
|
||||
OPT_1 = (1 << 5),
|
||||
OPT_2 = (1 << 6),
|
||||
OPT_3 = (1 << 7),
|
||||
OPT_4 = (1 << 8),
|
||||
OPT_5 = (1 << 9),
|
||||
OPT_6 = (1 << 10),
|
||||
OPT_789 = (7 << 11),
|
||||
OPT_7 = (1 << 11),
|
||||
OPT_8 = (1 << 12),
|
||||
OPT_C = (1 << 14),
|
||||
OPT_F = (1 << 15),
|
||||
OPT_QUIET = (1 << 3),
|
||||
OPT_DECOMPRESS = (1 << 4),
|
||||
OPT_TEST = (1 << 5),
|
||||
OPT_1 = (1 << 6),
|
||||
OPT_2 = (1 << 7),
|
||||
OPT_3 = (1 << 8),
|
||||
OPT_4 = (1 << 9),
|
||||
OPT_5 = (1 << 10),
|
||||
OPT_6 = (1 << 11),
|
||||
OPT_789 = (7 << 12),
|
||||
OPT_7 = (1 << 13),
|
||||
OPT_8 = (1 << 14),
|
||||
OPT_C = (1 << 15),
|
||||
OPT_F = (1 << 16),
|
||||
};
|
||||
|
||||
/**********************************************************************/
|
||||
@@ -1093,7 +1115,7 @@ int lzop_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (applet_name[4] == 'c')
|
||||
option_mask32 |= (OPT_STDOUT | OPT_DECOMPRESS);
|
||||
/* unlzop? */
|
||||
if (applet_name[0] == 'u')
|
||||
if (applet_name[4] == 'o')
|
||||
option_mask32 |= OPT_DECOMPRESS;
|
||||
|
||||
global_crc32_table = crc32_filltable(NULL, 0);
|
||||
|
||||
+162
-152
@@ -7,6 +7,15 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
//config:config RPM
|
||||
//config: bool "rpm"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Mini RPM applet - queries and extracts RPM packages.
|
||||
|
||||
//applet:IF_RPM(APPLET(rpm, BB_DIR_BIN, BB_SUID_DROP))
|
||||
//kbuild:lib-$(CONFIG_RPM) += rpm.o
|
||||
|
||||
//usage:#define rpm_trivial_usage
|
||||
//usage: "-i PACKAGE.rpm; rpm -qp[ildc] PACKAGE.rpm"
|
||||
//usage:#define rpm_full_usage "\n\n"
|
||||
@@ -14,10 +23,10 @@
|
||||
//usage: "\nCommands:"
|
||||
//usage: "\n -i Install package"
|
||||
//usage: "\n -qp Query package"
|
||||
//usage: "\n -i Show information"
|
||||
//usage: "\n -l List contents"
|
||||
//usage: "\n -d List documents"
|
||||
//usage: "\n -c List config files"
|
||||
//usage: "\n -qpi Show information"
|
||||
//usage: "\n -qpl List contents"
|
||||
//usage: "\n -qpd List documents"
|
||||
//usage: "\n -qpc List config files"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
@@ -79,136 +88,13 @@ typedef struct {
|
||||
uint32_t count; /* 4 byte count */
|
||||
} rpm_index;
|
||||
|
||||
static void *map;
|
||||
static rpm_index **mytags;
|
||||
static int tagcount;
|
||||
|
||||
static void extract_cpio(int fd, const char *source_rpm);
|
||||
static rpm_index **rpm_gettags(int fd, int *num_tags);
|
||||
static int bsearch_rpmtag(const void *key, const void *item);
|
||||
static char *rpm_getstr(int tag, int itemindex);
|
||||
static int rpm_getint(int tag, int itemindex);
|
||||
static int rpm_getcount(int tag);
|
||||
static void fileaction_dobackup(char *filename, int fileref);
|
||||
static void fileaction_setowngrp(char *filename, int fileref);
|
||||
static void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref));
|
||||
|
||||
int rpm_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int rpm_main(int argc, char **argv)
|
||||
{
|
||||
int opt = 0, func = 0, rpm_fd, offset;
|
||||
const int pagesize = getpagesize();
|
||||
|
||||
while ((opt = getopt(argc, argv, "iqpldc")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i': /* First arg: Install mode, with q: Information */
|
||||
if (!func) func = rpm_install;
|
||||
else func |= rpm_query_info;
|
||||
break;
|
||||
case 'q': /* First arg: Query mode */
|
||||
if (func) bb_show_usage();
|
||||
func = rpm_query;
|
||||
break;
|
||||
case 'p': /* Query a package */
|
||||
func |= rpm_query_package;
|
||||
break;
|
||||
case 'l': /* List files in a package */
|
||||
func |= rpm_query_list;
|
||||
break;
|
||||
case 'd': /* List doc files in a package (implies list) */
|
||||
func |= rpm_query_list;
|
||||
func |= rpm_query_list_doc;
|
||||
break;
|
||||
case 'c': /* List config files in a package (implies list) */
|
||||
func |= rpm_query_list;
|
||||
func |= rpm_query_list_config;
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
argv += optind;
|
||||
//argc -= optind;
|
||||
if (!argv[0]) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
while (*argv) {
|
||||
const char *source_rpm;
|
||||
|
||||
rpm_fd = xopen(*argv++, O_RDONLY);
|
||||
mytags = rpm_gettags(rpm_fd, &tagcount);
|
||||
if (!mytags)
|
||||
bb_error_msg_and_die("error reading rpm header");
|
||||
offset = xlseek(rpm_fd, 0, SEEK_CUR);
|
||||
/* Mimimum is one page */
|
||||
map = mmap(0, offset > pagesize ? (offset + offset % pagesize) : pagesize, PROT_READ, MAP_PRIVATE, rpm_fd, 0);
|
||||
|
||||
source_rpm = rpm_getstr(TAG_SOURCERPM, 0);
|
||||
|
||||
if (func & rpm_install) {
|
||||
/* Backup any config files */
|
||||
loop_through_files(TAG_BASENAMES, fileaction_dobackup);
|
||||
/* Extact the archive */
|
||||
extract_cpio(rpm_fd, source_rpm);
|
||||
/* Set the correct file uid/gid's */
|
||||
loop_through_files(TAG_BASENAMES, fileaction_setowngrp);
|
||||
}
|
||||
else if ((func & (rpm_query|rpm_query_package)) == (rpm_query|rpm_query_package)) {
|
||||
if (!(func & (rpm_query_info|rpm_query_list))) {
|
||||
/* If just a straight query, just give package name */
|
||||
printf("%s-%s-%s\n", rpm_getstr(TAG_NAME, 0), rpm_getstr(TAG_VERSION, 0), rpm_getstr(TAG_RELEASE, 0));
|
||||
}
|
||||
if (func & rpm_query_info) {
|
||||
/* Do the nice printout */
|
||||
time_t bdate_time;
|
||||
struct tm *bdate_ptm;
|
||||
char bdatestring[50];
|
||||
const char *p;
|
||||
|
||||
p = rpm_getstr(TAG_PREFIXS, 0);
|
||||
if (!p) p = "(not relocateable)";
|
||||
printf("Name : %-29sRelocations: %s\n", rpm_getstr(TAG_NAME, 0), p);
|
||||
p = rpm_getstr(TAG_VENDOR, 0);
|
||||
if (!p) p = "(none)";
|
||||
printf("Version : %-34sVendor: %s\n", rpm_getstr(TAG_VERSION, 0), p);
|
||||
bdate_time = rpm_getint(TAG_BUILDTIME, 0);
|
||||
bdate_ptm = localtime(&bdate_time);
|
||||
strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate_ptm);
|
||||
printf("Release : %-30sBuild Date: %s\n", rpm_getstr(TAG_RELEASE, 0), bdatestring);
|
||||
printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstr(TAG_BUILDHOST, 0));
|
||||
printf("Group : %-30sSource RPM: %s\n", rpm_getstr(TAG_GROUP, 0), source_rpm);
|
||||
printf("Size : %-33dLicense: %s\n", rpm_getint(TAG_SIZE, 0), rpm_getstr(TAG_LICENSE, 0));
|
||||
printf("URL : %s\n", rpm_getstr(TAG_URL, 0));
|
||||
printf("Summary : %s\n", rpm_getstr(TAG_SUMMARY, 0));
|
||||
printf("Description :\n%s\n", rpm_getstr(TAG_DESCRIPTION, 0));
|
||||
}
|
||||
if (func & rpm_query_list) {
|
||||
int count, it, flags;
|
||||
count = rpm_getcount(TAG_BASENAMES);
|
||||
for (it = 0; it < count; it++) {
|
||||
flags = rpm_getint(TAG_FILEFLAGS, it);
|
||||
switch (func & (rpm_query_list_doc|rpm_query_list_config)) {
|
||||
case rpm_query_list_doc:
|
||||
if (!(flags & RPMFILE_DOC)) continue;
|
||||
break;
|
||||
case rpm_query_list_config:
|
||||
if (!(flags & RPMFILE_CONFIG)) continue;
|
||||
break;
|
||||
case rpm_query_list_doc|rpm_query_list_config:
|
||||
if (!(flags & (RPMFILE_CONFIG|RPMFILE_DOC))) continue;
|
||||
break;
|
||||
}
|
||||
printf("%s%s\n",
|
||||
rpm_getstr(TAG_DIRNAMES, rpm_getint(TAG_DIRINDEXES, it)),
|
||||
rpm_getstr(TAG_BASENAMES, it));
|
||||
}
|
||||
}
|
||||
}
|
||||
free(mytags);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
struct globals {
|
||||
void *map;
|
||||
rpm_index **mytags;
|
||||
int tagcount;
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define INIT_G() do { } while (0)
|
||||
|
||||
static void extract_cpio(int fd, const char *source_rpm)
|
||||
{
|
||||
@@ -231,8 +117,8 @@ static void extract_cpio(int fd, const char *source_rpm)
|
||||
/* compat: overwrite existing files.
|
||||
* try "rpm -i foo.src.rpm" few times in a row -
|
||||
* standard rpm will not complain.
|
||||
* (TODO? real rpm creates "file;1234" and then renames it) */
|
||||
| ARCHIVE_UNLINK_OLD;
|
||||
*/
|
||||
| ARCHIVE_REPLACE_VIA_RENAME;
|
||||
archive_handle->src_fd = fd;
|
||||
/*archive_handle->offset = 0; - init_handle() did it */
|
||||
|
||||
@@ -294,7 +180,7 @@ static int bsearch_rpmtag(const void *key, const void *item)
|
||||
static int rpm_getcount(int tag)
|
||||
{
|
||||
rpm_index **found;
|
||||
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
found = bsearch(&tag, G.mytags, G.tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found)
|
||||
return 0;
|
||||
return found[0]->count;
|
||||
@@ -303,7 +189,7 @@ static int rpm_getcount(int tag)
|
||||
static char *rpm_getstr(int tag, int itemindex)
|
||||
{
|
||||
rpm_index **found;
|
||||
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
found = bsearch(&tag, G.mytags, G.tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found[0]->count)
|
||||
return NULL;
|
||||
if (found[0]->type == RPM_STRING_TYPE
|
||||
@@ -311,7 +197,7 @@ static char *rpm_getstr(int tag, int itemindex)
|
||||
|| found[0]->type == RPM_STRING_ARRAY_TYPE
|
||||
) {
|
||||
int n;
|
||||
char *tmpstr = (char *) map + found[0]->offset;
|
||||
char *tmpstr = (char *) G.map + found[0]->offset;
|
||||
for (n = 0; n < itemindex; n++)
|
||||
tmpstr = tmpstr + strlen(tmpstr) + 1;
|
||||
return tmpstr;
|
||||
@@ -322,32 +208,25 @@ static char *rpm_getstr(int tag, int itemindex)
|
||||
static int rpm_getint(int tag, int itemindex)
|
||||
{
|
||||
rpm_index **found;
|
||||
int *tmpint; /* NB: using int8_t* would be easier to code */
|
||||
char *tmpint;
|
||||
|
||||
/* gcc throws warnings here when sizeof(void*)!=sizeof(int) ...
|
||||
* it's ok to ignore it because tag won't be used as a pointer */
|
||||
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
found = bsearch(&tag, G.mytags, G.tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found[0]->count)
|
||||
return -1;
|
||||
|
||||
tmpint = (int *) ((char *) map + found[0]->offset);
|
||||
|
||||
tmpint = (char *) G.map + found[0]->offset;
|
||||
if (found[0]->type == RPM_INT32_TYPE) {
|
||||
tmpint = (int *) ((char *) tmpint + itemindex*4);
|
||||
/*return ntohl(*tmpint);*/
|
||||
/* int can be != int32_t */
|
||||
tmpint += itemindex*4;
|
||||
return ntohl(*(int32_t*)tmpint);
|
||||
}
|
||||
if (found[0]->type == RPM_INT16_TYPE) {
|
||||
tmpint = (int *) ((char *) tmpint + itemindex*2);
|
||||
/* ??? read int, and THEN ntohs() it?? */
|
||||
/*return ntohs(*tmpint);*/
|
||||
tmpint += itemindex*2;
|
||||
return ntohs(*(int16_t*)tmpint);
|
||||
}
|
||||
if (found[0]->type == RPM_INT8_TYPE) {
|
||||
tmpint = (int *) ((char *) tmpint + itemindex);
|
||||
/* ??? why we don't read byte here??? */
|
||||
/*return ntohs(*tmpint);*/
|
||||
tmpint += itemindex;
|
||||
return *(int8_t*)tmpint;
|
||||
}
|
||||
return -1;
|
||||
@@ -392,3 +271,134 @@ static void loop_through_files(int filetag, void (*fileaction)(char *filename, i
|
||||
free(filename);
|
||||
}
|
||||
}
|
||||
|
||||
int rpm_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int rpm_main(int argc, char **argv)
|
||||
{
|
||||
int opt, func = 0;
|
||||
const unsigned pagesize = getpagesize();
|
||||
|
||||
while ((opt = getopt(argc, argv, "iqpldc")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i': /* First arg: Install mode, with q: Information */
|
||||
if (!func) func = rpm_install;
|
||||
else func |= rpm_query_info;
|
||||
break;
|
||||
case 'q': /* First arg: Query mode */
|
||||
if (func) bb_show_usage();
|
||||
func = rpm_query;
|
||||
break;
|
||||
case 'p': /* Query a package */
|
||||
func |= rpm_query_package;
|
||||
break;
|
||||
case 'l': /* List files in a package */
|
||||
func |= rpm_query_list;
|
||||
break;
|
||||
case 'd': /* List doc files in a package (implies list) */
|
||||
func |= rpm_query_list;
|
||||
func |= rpm_query_list_doc;
|
||||
break;
|
||||
case 'c': /* List config files in a package (implies list) */
|
||||
func |= rpm_query_list;
|
||||
func |= rpm_query_list_config;
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
argv += optind;
|
||||
//argc -= optind;
|
||||
if (!argv[0]) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
while (*argv) {
|
||||
int rpm_fd;
|
||||
unsigned mapsize;
|
||||
const char *source_rpm;
|
||||
|
||||
rpm_fd = xopen(*argv++, O_RDONLY);
|
||||
G.mytags = rpm_gettags(rpm_fd, &G.tagcount);
|
||||
if (!G.mytags)
|
||||
bb_error_msg_and_die("error reading rpm header");
|
||||
mapsize = xlseek(rpm_fd, 0, SEEK_CUR);
|
||||
mapsize = (mapsize + pagesize) & -(int)pagesize;
|
||||
/* Some NOMMU systems prefer MAP_PRIVATE over MAP_SHARED */
|
||||
G.map = mmap(0, mapsize, PROT_READ, MAP_PRIVATE, rpm_fd, 0);
|
||||
//FIXME: error check?
|
||||
|
||||
source_rpm = rpm_getstr(TAG_SOURCERPM, 0);
|
||||
|
||||
if (func & rpm_install) {
|
||||
/* Backup any config files */
|
||||
loop_through_files(TAG_BASENAMES, fileaction_dobackup);
|
||||
/* Extact the archive */
|
||||
extract_cpio(rpm_fd, source_rpm);
|
||||
/* Set the correct file uid/gid's */
|
||||
loop_through_files(TAG_BASENAMES, fileaction_setowngrp);
|
||||
}
|
||||
else if ((func & (rpm_query|rpm_query_package)) == (rpm_query|rpm_query_package)) {
|
||||
if (!(func & (rpm_query_info|rpm_query_list))) {
|
||||
/* If just a straight query, just give package name */
|
||||
printf("%s-%s-%s\n", rpm_getstr(TAG_NAME, 0), rpm_getstr(TAG_VERSION, 0), rpm_getstr(TAG_RELEASE, 0));
|
||||
}
|
||||
if (func & rpm_query_info) {
|
||||
/* Do the nice printout */
|
||||
time_t bdate_time;
|
||||
struct tm *bdate_ptm;
|
||||
char bdatestring[50];
|
||||
const char *p;
|
||||
|
||||
printf("%-12s: %s\n", "Name" , rpm_getstr(TAG_NAME, 0));
|
||||
/* TODO compat: add "Epoch" here */
|
||||
printf("%-12s: %s\n", "Version" , rpm_getstr(TAG_VERSION, 0));
|
||||
printf("%-12s: %s\n", "Release" , rpm_getstr(TAG_RELEASE, 0));
|
||||
/* add "Architecture" */
|
||||
printf("%-12s: %s\n", "Install Date", "(not installed)");
|
||||
printf("%-12s: %s\n", "Group" , rpm_getstr(TAG_GROUP, 0));
|
||||
printf("%-12s: %d\n", "Size" , rpm_getint(TAG_SIZE, 0));
|
||||
printf("%-12s: %s\n", "License" , rpm_getstr(TAG_LICENSE, 0));
|
||||
/* add "Signature" */
|
||||
printf("%-12s: %s\n", "Source RPM" , source_rpm ? source_rpm : "(none)");
|
||||
bdate_time = rpm_getint(TAG_BUILDTIME, 0);
|
||||
bdate_ptm = localtime(&bdate_time);
|
||||
strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate_ptm);
|
||||
printf("%-12s: %s\n", "Build Date" , bdatestring);
|
||||
printf("%-12s: %s\n", "Build Host" , rpm_getstr(TAG_BUILDHOST, 0));
|
||||
p = rpm_getstr(TAG_PREFIXS, 0);
|
||||
printf("%-12s: %s\n", "Relocations" , p ? p : "(not relocatable)");
|
||||
/* add "Packager" */
|
||||
p = rpm_getstr(TAG_VENDOR, 0);
|
||||
printf("%-12s: %s\n", "Vendor" , p ? p : "(none)");
|
||||
printf("%-12s: %s\n", "URL" , rpm_getstr(TAG_URL, 0));
|
||||
printf("%-12s: %s\n", "Summary" , rpm_getstr(TAG_SUMMARY, 0));
|
||||
printf("Description :\n%s\n", rpm_getstr(TAG_DESCRIPTION, 0));
|
||||
}
|
||||
if (func & rpm_query_list) {
|
||||
int count, it, flags;
|
||||
count = rpm_getcount(TAG_BASENAMES);
|
||||
for (it = 0; it < count; it++) {
|
||||
flags = rpm_getint(TAG_FILEFLAGS, it);
|
||||
switch (func & (rpm_query_list_doc|rpm_query_list_config)) {
|
||||
case rpm_query_list_doc:
|
||||
if (!(flags & RPMFILE_DOC)) continue;
|
||||
break;
|
||||
case rpm_query_list_config:
|
||||
if (!(flags & RPMFILE_CONFIG)) continue;
|
||||
break;
|
||||
case rpm_query_list_doc|rpm_query_list_config:
|
||||
if (!(flags & (RPMFILE_CONFIG|RPMFILE_DOC))) continue;
|
||||
break;
|
||||
}
|
||||
printf("%s%s\n",
|
||||
rpm_getstr(TAG_DIRNAMES, rpm_getint(TAG_DIRINDEXES, it)),
|
||||
rpm_getstr(TAG_BASENAMES, it));
|
||||
}
|
||||
}
|
||||
}
|
||||
munmap(G.map, mapsize);
|
||||
free(G.mytags);
|
||||
close(rpm_fd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -7,6 +7,15 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
//config:config RPM2CPIO
|
||||
//config: bool "rpm2cpio"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: Converts a RPM file into a CPIO archive.
|
||||
|
||||
//applet:IF_RPM2CPIO(APPLET(rpm2cpio, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
//kbuild:lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o
|
||||
|
||||
//usage:#define rpm2cpio_trivial_usage
|
||||
//usage: "package.rpm"
|
||||
//usage:#define rpm2cpio_full_usage "\n\n"
|
||||
|
||||
+149
-24
@@ -22,7 +22,6 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
/* TODO: security with -C DESTDIR option can be enhanced.
|
||||
* Consider tar file created via:
|
||||
* $ tar cvf bug.tar anything.txt
|
||||
@@ -42,6 +41,109 @@
|
||||
* This doesn't feel right, and IIRC GNU tar doesn't do that.
|
||||
*/
|
||||
|
||||
//config:config TAR
|
||||
//config: bool "tar"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: tar is an archiving program. It's commonly used with gzip to
|
||||
//config: create compressed archives. It's probably the most widely used
|
||||
//config: UNIX archive program.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_CREATE
|
||||
//config: bool "Enable archive creation"
|
||||
//config: default y
|
||||
//config: depends on TAR
|
||||
//config: help
|
||||
//config: If you enable this option you'll be able to create
|
||||
//config: tar archives using the `-c' option.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_AUTODETECT
|
||||
//config: bool "Autodetect compressed tarballs"
|
||||
//config: default y
|
||||
//config: depends on TAR && (FEATURE_SEAMLESS_Z || FEATURE_SEAMLESS_GZ || FEATURE_SEAMLESS_BZ2 || FEATURE_SEAMLESS_LZMA || FEATURE_SEAMLESS_XZ)
|
||||
//config: help
|
||||
//config: With this option tar can automatically detect compressed
|
||||
//config: tarballs. Currently it works only on files (not pipes etc).
|
||||
//config:
|
||||
//config:config FEATURE_TAR_FROM
|
||||
//config: bool "Enable -X (exclude from) and -T (include from) options)"
|
||||
//config: default y
|
||||
//config: depends on TAR
|
||||
//config: help
|
||||
//config: If you enable this option you'll be able to specify
|
||||
//config: a list of files to include or exclude from an archive.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
//config: bool "Support for old tar header format"
|
||||
//config: default y
|
||||
//config: depends on TAR || DPKG
|
||||
//config: help
|
||||
//config: This option is required to unpack archives created in
|
||||
//config: the old GNU format; help to kill this old format by
|
||||
//config: repacking your ancient archives with the new format.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
//config: bool "Enable untarring of tarballs with checksums produced by buggy Sun tar"
|
||||
//config: default y
|
||||
//config: depends on TAR || DPKG
|
||||
//config: help
|
||||
//config: This option is required to unpack archives created by some old
|
||||
//config: version of Sun's tar (it was calculating checksum using signed
|
||||
//config: arithmetic). It is said to be fixed in newer Sun tar, but "old"
|
||||
//config: tarballs still exist.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_GNU_EXTENSIONS
|
||||
//config: bool "Support for GNU tar extensions (long filenames)"
|
||||
//config: default y
|
||||
//config: depends on TAR || DPKG
|
||||
//config: help
|
||||
//config: With this option busybox supports GNU long filenames and
|
||||
//config: linknames.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_LONG_OPTIONS
|
||||
//config: bool "Enable long options"
|
||||
//config: default y
|
||||
//config: depends on TAR && LONG_OPTS
|
||||
//config: help
|
||||
//config: Enable use of long options, increases size by about 400 Bytes
|
||||
//config:
|
||||
//config:config FEATURE_TAR_TO_COMMAND
|
||||
//config: bool "Support for writing to an external program"
|
||||
//config: default y
|
||||
//config: depends on TAR && FEATURE_TAR_LONG_OPTIONS
|
||||
//config: help
|
||||
//config: If you enable this option you'll be able to instruct tar to send
|
||||
//config: the contents of each extracted file to the standard input of an
|
||||
//config: external program.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_UNAME_GNAME
|
||||
//config: bool "Enable use of user and group names"
|
||||
//config: default y
|
||||
//config: depends on TAR
|
||||
//config: help
|
||||
//config: Enables use of user and group names in tar. This affects contents
|
||||
//config: listings (-t) and preserving permissions when unpacking (-p).
|
||||
//config: +200 bytes.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_NOPRESERVE_TIME
|
||||
//config: bool "Enable -m (do not preserve time) option"
|
||||
//config: default y
|
||||
//config: depends on TAR
|
||||
//config: help
|
||||
//config: With this option busybox supports GNU tar -m
|
||||
//config: (do not preserve time) option.
|
||||
//config:
|
||||
//config:config FEATURE_TAR_SELINUX
|
||||
//config: bool "Support for extracting SELinux labels"
|
||||
//config: default n
|
||||
//config: depends on TAR && SELINUX
|
||||
//config: help
|
||||
//config: With this option busybox supports restoring SELinux labels
|
||||
//config: when extracting files from tar archives.
|
||||
|
||||
//applet:IF_TAR(APPLET(tar, BB_DIR_BIN, BB_SUID_DROP))
|
||||
//kbuild:lib-$(CONFIG_TAR) += tar.o
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
@@ -60,8 +162,8 @@
|
||||
|
||||
#if !ENABLE_FEATURE_SEAMLESS_GZ && !ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
/* Do not pass gzip flag to writeTarFile() */
|
||||
#define writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude, gzip) \
|
||||
writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude)
|
||||
#define writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude, gzip) \
|
||||
writeTarFile(tar_fd, verboseFlag, recurseFlags, include, exclude)
|
||||
#endif
|
||||
|
||||
|
||||
@@ -333,13 +435,13 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
|
||||
&& (filesize <= 0x3fffffffffffffffffffffffLL)
|
||||
#endif
|
||||
) {
|
||||
/* GNU tar uses "base-256 encoding" for very large numbers.
|
||||
* Encoding is binary, with highest bit always set as a marker
|
||||
* and sign in next-highest bit:
|
||||
* 80 00 .. 00 - zero
|
||||
* bf ff .. ff - largest positive number
|
||||
* ff ff .. ff - minus 1
|
||||
* c0 00 .. 00 - smallest negative number
|
||||
/* GNU tar uses "base-256 encoding" for very large numbers.
|
||||
* Encoding is binary, with highest bit always set as a marker
|
||||
* and sign in next-highest bit:
|
||||
* 80 00 .. 00 - zero
|
||||
* bf ff .. ff - largest positive number
|
||||
* ff ff .. ff - minus 1
|
||||
* c0 00 .. 00 - smallest negative number
|
||||
*/
|
||||
char *p8 = header.size + sizeof(header.size);
|
||||
do {
|
||||
@@ -567,7 +669,7 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip)
|
||||
xmove_fd(gzipDataPipe.rd, 0);
|
||||
xmove_fd(tar_fd, 1);
|
||||
/* exec gzip/bzip2 program/applet */
|
||||
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
|
||||
BB_EXECLP(zip_exec, zip_exec, "-f", (char *)0);
|
||||
vfork_exec_errno = errno;
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -598,7 +700,7 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip)
|
||||
|
||||
/* gcc 4.2.1 inlines it, making code bigger */
|
||||
static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
|
||||
int dereferenceFlag, const llist_t *include,
|
||||
int recurseFlags, const llist_t *include,
|
||||
const llist_t *exclude, int gzip)
|
||||
{
|
||||
int errorFlag = FALSE;
|
||||
@@ -621,8 +723,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
|
||||
|
||||
/* Read the directory/files and iterate over them one at a time */
|
||||
while (include) {
|
||||
if (!recursive_action(include->data, ACTION_RECURSE |
|
||||
(dereferenceFlag ? ACTION_FOLLOWLINKS : 0),
|
||||
if (!recursive_action(include->data, recurseFlags,
|
||||
writeFileToTarball, writeFileToTarball, &tbInfo, 0)
|
||||
) {
|
||||
errorFlag = TRUE;
|
||||
@@ -662,7 +763,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
|
||||
}
|
||||
#else
|
||||
int writeTarFile(int tar_fd, int verboseFlag,
|
||||
int dereferenceFlag, const llist_t *include,
|
||||
int recurseFlags, const llist_t *include,
|
||||
const llist_t *exclude, int gzip);
|
||||
#endif /* FEATURE_TAR_CREATE */
|
||||
|
||||
@@ -680,20 +781,19 @@ static llist_t *append_file_list_to_list(llist_t *list)
|
||||
char *cp = last_char_is(line, '/');
|
||||
if (cp > line)
|
||||
*cp = '\0';
|
||||
llist_add_to(&newlist, line);
|
||||
llist_add_to_end(&newlist, line);
|
||||
}
|
||||
fclose(src_stream);
|
||||
}
|
||||
return newlist;
|
||||
}
|
||||
#else
|
||||
# define append_file_list_to_list(x) 0
|
||||
#endif
|
||||
|
||||
//usage:#define tar_trivial_usage
|
||||
//usage: "-[" IF_FEATURE_TAR_CREATE("c") "xt"
|
||||
//usage: IF_FEATURE_SEAMLESS_Z("Z")
|
||||
//usage: IF_FEATURE_SEAMLESS_GZ("z")
|
||||
//usage: IF_FEATURE_SEAMLESS_XZ("J")
|
||||
//usage: IF_FEATURE_SEAMLESS_BZ2("j")
|
||||
//usage: IF_FEATURE_SEAMLESS_LZMA("a")
|
||||
//usage: IF_FEATURE_TAR_CREATE("h")
|
||||
@@ -720,6 +820,9 @@ static llist_t *append_file_list_to_list(llist_t *list)
|
||||
//usage: IF_FEATURE_SEAMLESS_GZ(
|
||||
//usage: "\n z (De)compress using gzip"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_SEAMLESS_XZ(
|
||||
//usage: "\n J (De)compress using xz"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_SEAMLESS_BZ2(
|
||||
//usage: "\n j (De)compress using bzip2"
|
||||
//usage: )
|
||||
@@ -749,6 +852,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
|
||||
// o no-same-owner
|
||||
// p same-permissions
|
||||
// k keep-old
|
||||
// no-recursion
|
||||
// numeric-owner
|
||||
// no-same-permissions
|
||||
// overwrite
|
||||
@@ -765,9 +869,11 @@ enum {
|
||||
IF_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,)
|
||||
IF_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,)
|
||||
IF_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,)
|
||||
IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) // 16th bit
|
||||
IF_FEATURE_SEAMLESS_XZ( OPTBIT_XZ ,) // 16th bit
|
||||
IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,)
|
||||
IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,)
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||
OPTBIT_NORECURSION,
|
||||
IF_FEATURE_TAR_TO_COMMAND(OPTBIT_2COMMAND ,)
|
||||
OPTBIT_NUMERIC_OWNER,
|
||||
OPTBIT_NOPRESERVE_PERM,
|
||||
@@ -789,14 +895,16 @@ enum {
|
||||
OPT_INCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T
|
||||
OPT_EXCLUDE_FROM = IF_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
|
||||
OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
|
||||
OPT_XZ = IF_FEATURE_SEAMLESS_XZ( (1 << OPTBIT_XZ )) + 0, // J
|
||||
OPT_COMPRESS = IF_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z
|
||||
OPT_NOPRESERVE_TIME = IF_FEATURE_TAR_NOPRESERVE_TIME((1 << OPTBIT_NOPRESERVE_TIME)) + 0, // m
|
||||
OPT_NORECURSION = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NORECURSION )) + 0, // no-recursion
|
||||
OPT_2COMMAND = IF_FEATURE_TAR_TO_COMMAND( (1 << OPTBIT_2COMMAND )) + 0, // to-command
|
||||
OPT_NUMERIC_OWNER = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NUMERIC_OWNER )) + 0, // numeric-owner
|
||||
OPT_NOPRESERVE_PERM = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_NOPRESERVE_PERM)) + 0, // no-same-permissions
|
||||
OPT_OVERWRITE = IF_FEATURE_TAR_LONG_OPTIONS((1 << OPTBIT_OVERWRITE )) + 0, // overwrite
|
||||
|
||||
OPT_ANY_COMPRESS = (OPT_BZIP2 | OPT_LZMA | OPT_GZIP | OPT_COMPRESS),
|
||||
OPT_ANY_COMPRESS = (OPT_BZIP2 | OPT_LZMA | OPT_GZIP | OPT_XZ | OPT_COMPRESS),
|
||||
};
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||
static const char tar_longopts[] ALIGN1 =
|
||||
@@ -829,12 +937,16 @@ static const char tar_longopts[] ALIGN1 =
|
||||
# if ENABLE_FEATURE_SEAMLESS_GZ
|
||||
"gzip\0" No_argument "z"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_SEAMLESS_XZ
|
||||
"xz\0" No_argument "J"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_SEAMLESS_Z
|
||||
"compress\0" No_argument "Z"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_NOPRESERVE_TIME
|
||||
"touch\0" No_argument "m"
|
||||
# endif
|
||||
"no-recursion\0" No_argument "\xfa"
|
||||
# if ENABLE_FEATURE_TAR_TO_COMMAND
|
||||
"to-command\0" Required_argument "\xfb"
|
||||
# endif
|
||||
@@ -921,6 +1033,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
IF_FEATURE_SEAMLESS_LZMA("a" )
|
||||
IF_FEATURE_TAR_FROM( "T:X:")
|
||||
IF_FEATURE_SEAMLESS_GZ( "z" )
|
||||
IF_FEATURE_SEAMLESS_XZ( "J" )
|
||||
IF_FEATURE_SEAMLESS_Z( "Z" )
|
||||
IF_FEATURE_TAR_NOPRESERVE_TIME("m")
|
||||
, &base_dir // -C dir
|
||||
@@ -1050,7 +1163,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
zipMode = 2;
|
||||
#endif
|
||||
/* NB: writeTarFile() closes tar_handle->src_fd */
|
||||
return writeTarFile(tar_handle->src_fd, verboseFlag, opt & OPT_DEREFERENCE,
|
||||
return writeTarFile(tar_handle->src_fd, verboseFlag,
|
||||
(opt & OPT_DEREFERENCE ? ACTION_FOLLOWLINKS : 0)
|
||||
| (opt & OPT_NORECURSION ? 0 : ACTION_RECURSE),
|
||||
tar_handle->accept,
|
||||
tar_handle->reject, zipMode);
|
||||
}
|
||||
@@ -1071,6 +1186,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (opt & OPT_LZMA)
|
||||
USE_FOR_MMU(xformer = unpack_lzma_stream;)
|
||||
USE_FOR_NOMMU(xformer_prog = "unlzma";)
|
||||
if (opt & OPT_XZ)
|
||||
USE_FOR_MMU(xformer = unpack_xz_stream;)
|
||||
USE_FOR_NOMMU(xformer_prog = "unxz";)
|
||||
|
||||
open_transformer_with_sig(tar_handle->src_fd, xformer, xformer_prog);
|
||||
/* Can't lseek over pipes */
|
||||
@@ -1078,8 +1196,14 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
/*tar_handle->offset = 0; - already is */
|
||||
}
|
||||
|
||||
/* Zero processed headers (== empty file) is not a valid tarball.
|
||||
* We (ab)use bb_got_signal as exitcode here,
|
||||
* because check_errors_in_children() uses _it_ as error indicator.
|
||||
*/
|
||||
bb_got_signal = EXIT_FAILURE;
|
||||
|
||||
while (get_header_tar(tar_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
bb_got_signal = EXIT_SUCCESS; /* saw at least one header, good */
|
||||
|
||||
/* Check that every file that should have been extracted was */
|
||||
while (tar_handle->accept) {
|
||||
@@ -1095,8 +1219,9 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
close(tar_handle->src_fd);
|
||||
|
||||
if (SEAMLESS_COMPRESSION || OPT_COMPRESS) {
|
||||
/* Set bb_got_signal to 1 if a child died with !0 exitcode */
|
||||
check_errors_in_children(0);
|
||||
return bb_got_signal;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
return bb_got_signal;
|
||||
}
|
||||
+150
-103
@@ -9,27 +9,38 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
/* For reference see
|
||||
* http://www.pkware.com/company/standards/appnote/
|
||||
* http://www.info-zip.org/pub/infozip/doc/appnote-iz-latest.zip
|
||||
*/
|
||||
|
||||
/* TODO
|
||||
*
|
||||
* TODO
|
||||
* Zip64 + other methods
|
||||
*/
|
||||
|
||||
//config:config UNZIP
|
||||
//config: bool "unzip"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: unzip will list or extract files from a ZIP archive,
|
||||
//config: commonly found on DOS/WIN systems. The default behavior
|
||||
//config: (with no options) is to extract the archive into the
|
||||
//config: current directory. Use the `-d' option to extract to a
|
||||
//config: directory of your choice.
|
||||
|
||||
//applet:IF_UNZIP(APPLET(unzip, BB_DIR_USR_BIN, BB_SUID_DROP))
|
||||
//kbuild:lib-$(CONFIG_UNZIP) += unzip.o
|
||||
|
||||
//usage:#define unzip_trivial_usage
|
||||
//usage: "[-opts[modifiers]] FILE[.zip] [LIST] [-x XLIST] [-d DIR]"
|
||||
//usage: "[-lnopq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]"
|
||||
//usage:#define unzip_full_usage "\n\n"
|
||||
//usage: "Extract files from ZIP archives\n"
|
||||
//usage: "\n -l List archive contents (with -q for short form)"
|
||||
//usage: "\n -n Never overwrite files (default)"
|
||||
//usage: "Extract FILEs from ZIP archive\n"
|
||||
//usage: "\n -l List contents (with -q for short form)"
|
||||
//usage: "\n -n Never overwrite files (default: ask)"
|
||||
//usage: "\n -o Overwrite"
|
||||
//usage: "\n -p Send output to stdout"
|
||||
//usage: "\n -p Print to stdout"
|
||||
//usage: "\n -q Quiet"
|
||||
//usage: "\n -x XLST Exclude these files"
|
||||
//usage: "\n -d DIR Extract files into DIR"
|
||||
//usage: "\n -x FILE Exclude FILEs"
|
||||
//usage: "\n -d DIR Extract into DIR"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "bb_archive.h"
|
||||
@@ -163,7 +174,17 @@ enum { zip_fd = 3 };
|
||||
|
||||
#if ENABLE_DESKTOP
|
||||
|
||||
#define PEEK_FROM_END 16384
|
||||
/* Seen in the wild:
|
||||
* Self-extracting PRO2K3XP_32.exe contains 19078464 byte zip archive,
|
||||
* where CDE was nearly 48 kbytes before EOF.
|
||||
* (Surprisingly, it also apparently has *another* CDE structure
|
||||
* closer to the end, with bogus cdf_offset).
|
||||
* To make extraction work, bumped PEEK_FROM_END from 16k to 64k.
|
||||
*/
|
||||
#define PEEK_FROM_END (64*1024)
|
||||
|
||||
/* This value means that we failed to find CDF */
|
||||
#define BAD_CDF_OFFSET ((uint32_t)0xffffffff)
|
||||
|
||||
/* NB: does not preserve file position! */
|
||||
static uint32_t find_cdf_offset(void)
|
||||
@@ -180,6 +201,7 @@ static uint32_t find_cdf_offset(void)
|
||||
xlseek(zip_fd, end, SEEK_SET);
|
||||
full_read(zip_fd, buf, PEEK_FROM_END);
|
||||
|
||||
cde_header.formatted.cdf_offset = BAD_CDF_OFFSET;
|
||||
p = buf;
|
||||
while (p <= buf + PEEK_FROM_END - CDE_HEADER_LEN - 4) {
|
||||
if (*p != 'P') {
|
||||
@@ -195,11 +217,17 @@ static uint32_t find_cdf_offset(void)
|
||||
/* we found CDE! */
|
||||
memcpy(cde_header.raw, p + 1, CDE_HEADER_LEN);
|
||||
FIX_ENDIANNESS_CDE(cde_header);
|
||||
free(buf);
|
||||
return cde_header.formatted.cdf_offset;
|
||||
/*
|
||||
* I've seen .ZIP files with seemingly valid CDEs
|
||||
* where cdf_offset points past EOF - ??
|
||||
* Ignore such CDEs:
|
||||
*/
|
||||
if (cde_header.formatted.cdf_offset < end + (p - buf))
|
||||
break;
|
||||
cde_header.formatted.cdf_offset = BAD_CDF_OFFSET;
|
||||
}
|
||||
//free(buf);
|
||||
bb_error_msg_and_die("can't find file table");
|
||||
free(buf);
|
||||
return cde_header.formatted.cdf_offset;
|
||||
};
|
||||
|
||||
static uint32_t read_next_cdf(uint32_t cdf_offset, cdf_header_t *cdf_ptr)
|
||||
@@ -211,13 +239,15 @@ static uint32_t read_next_cdf(uint32_t cdf_offset, cdf_header_t *cdf_ptr)
|
||||
if (!cdf_offset)
|
||||
cdf_offset = find_cdf_offset();
|
||||
|
||||
xlseek(zip_fd, cdf_offset + 4, SEEK_SET);
|
||||
xread(zip_fd, cdf_ptr->raw, CDF_HEADER_LEN);
|
||||
FIX_ENDIANNESS_CDF(*cdf_ptr);
|
||||
cdf_offset += 4 + CDF_HEADER_LEN
|
||||
+ cdf_ptr->formatted.file_name_length
|
||||
+ cdf_ptr->formatted.extra_field_length
|
||||
+ cdf_ptr->formatted.file_comment_length;
|
||||
if (cdf_offset != BAD_CDF_OFFSET) {
|
||||
xlseek(zip_fd, cdf_offset + 4, SEEK_SET);
|
||||
xread(zip_fd, cdf_ptr->raw, CDF_HEADER_LEN);
|
||||
FIX_ENDIANNESS_CDF(*cdf_ptr);
|
||||
cdf_offset += 4 + CDF_HEADER_LEN
|
||||
+ cdf_ptr->formatted.file_name_length
|
||||
+ cdf_ptr->formatted.extra_field_length
|
||||
+ cdf_ptr->formatted.file_comment_length;
|
||||
}
|
||||
|
||||
xlseek(zip_fd, org, SEEK_SET);
|
||||
return cdf_offset;
|
||||
@@ -226,8 +256,9 @@ static uint32_t read_next_cdf(uint32_t cdf_offset, cdf_header_t *cdf_ptr)
|
||||
|
||||
static void unzip_skip(off_t skip)
|
||||
{
|
||||
if (lseek(zip_fd, skip, SEEK_CUR) == (off_t)-1)
|
||||
bb_copyfd_exact_size(zip_fd, -1, skip);
|
||||
if (skip != 0)
|
||||
if (lseek(zip_fd, skip, SEEK_CUR) == (off_t)-1)
|
||||
bb_copyfd_exact_size(zip_fd, -1, skip);
|
||||
}
|
||||
|
||||
static void unzip_create_leading_dirs(const char *fn)
|
||||
@@ -267,6 +298,14 @@ static void unzip_extract(zip_header_t *zip_header, int dst_fd)
|
||||
}
|
||||
}
|
||||
|
||||
static void my_fgets80(char *buf80)
|
||||
{
|
||||
fflush_all();
|
||||
if (!fgets(buf80, 80, stdin)) {
|
||||
bb_perror_msg_and_die("can't read standard input");
|
||||
}
|
||||
}
|
||||
|
||||
int unzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int unzip_main(int argc, char **argv)
|
||||
{
|
||||
@@ -277,6 +316,7 @@ int unzip_main(int argc, char **argv)
|
||||
IF_NOT_DESKTOP(const) smallint verbose = 0;
|
||||
smallint listing = 0;
|
||||
smallint overwrite = O_PROMPT;
|
||||
smallint x_opt_seen;
|
||||
#if ENABLE_DESKTOP
|
||||
uint32_t cdf_offset;
|
||||
#endif
|
||||
@@ -290,8 +330,7 @@ int unzip_main(int argc, char **argv)
|
||||
llist_t *zreject = NULL;
|
||||
char *base_dir = NULL;
|
||||
int i, opt;
|
||||
int opt_range = 0;
|
||||
char key_buf[80];
|
||||
char key_buf[80]; /* must match size used by my_fgets80 */
|
||||
struct stat stat_buf;
|
||||
|
||||
/* -q, -l and -v: UnZip 5.52 of 28 February 2005, by Info-ZIP:
|
||||
@@ -335,81 +374,81 @@ int unzip_main(int argc, char **argv)
|
||||
* 204372 1 file
|
||||
*/
|
||||
|
||||
x_opt_seen = 0;
|
||||
/* '-' makes getopt return 1 for non-options */
|
||||
while ((opt = getopt(argc, argv, "-d:lnopqxv")) != -1) {
|
||||
switch (opt_range) {
|
||||
case 0: /* Options */
|
||||
switch (opt) {
|
||||
case 'l': /* List */
|
||||
listing = 1;
|
||||
break;
|
||||
switch (opt) {
|
||||
case 'd': /* Extract to base directory */
|
||||
base_dir = optarg;
|
||||
break;
|
||||
|
||||
case 'n': /* Never overwrite existing files */
|
||||
overwrite = O_NEVER;
|
||||
break;
|
||||
case 'l': /* List */
|
||||
listing = 1;
|
||||
break;
|
||||
|
||||
case 'o': /* Always overwrite existing files */
|
||||
overwrite = O_ALWAYS;
|
||||
break;
|
||||
case 'n': /* Never overwrite existing files */
|
||||
overwrite = O_NEVER;
|
||||
break;
|
||||
|
||||
case 'p': /* Extract files to stdout and fall through to set verbosity */
|
||||
dst_fd = STDOUT_FILENO;
|
||||
case 'o': /* Always overwrite existing files */
|
||||
overwrite = O_ALWAYS;
|
||||
break;
|
||||
|
||||
case 'q': /* Be quiet */
|
||||
quiet++;
|
||||
break;
|
||||
case 'p': /* Extract files to stdout and fall through to set verbosity */
|
||||
dst_fd = STDOUT_FILENO;
|
||||
|
||||
case 'v': /* Verbose list */
|
||||
IF_DESKTOP(verbose++;)
|
||||
listing = 1;
|
||||
break;
|
||||
case 'q': /* Be quiet */
|
||||
quiet++;
|
||||
break;
|
||||
|
||||
case 1: /* The zip file */
|
||||
case 'v': /* Verbose list */
|
||||
IF_DESKTOP(verbose++;)
|
||||
listing = 1;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
x_opt_seen = 1;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (!src_fn) {
|
||||
/* The zip file */
|
||||
/* +5: space for ".zip" and NUL */
|
||||
src_fn = xmalloc(strlen(optarg) + 5);
|
||||
strcpy(src_fn, optarg);
|
||||
opt_range++;
|
||||
break;
|
||||
|
||||
default:
|
||||
bb_show_usage();
|
||||
} else if (!x_opt_seen) {
|
||||
/* Include files */
|
||||
llist_add_to(&zaccept, optarg);
|
||||
} else {
|
||||
/* Exclude files */
|
||||
llist_add_to(&zreject, optarg);
|
||||
}
|
||||
break;
|
||||
|
||||
case 1: /* Include files */
|
||||
if (opt == 1) {
|
||||
llist_add_to(&zaccept, optarg);
|
||||
break;
|
||||
}
|
||||
if (opt == 'd') {
|
||||
base_dir = optarg;
|
||||
opt_range += 2;
|
||||
break;
|
||||
}
|
||||
if (opt == 'x') {
|
||||
opt_range++;
|
||||
break;
|
||||
}
|
||||
bb_show_usage();
|
||||
|
||||
case 2 : /* Exclude files */
|
||||
if (opt == 1) {
|
||||
llist_add_to(&zreject, optarg);
|
||||
break;
|
||||
}
|
||||
if (opt == 'd') { /* Extract to base directory */
|
||||
base_dir = optarg;
|
||||
opt_range++;
|
||||
break;
|
||||
}
|
||||
/* fall through */
|
||||
|
||||
default:
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (src_fn == NULL) {
|
||||
#ifndef __GLIBC__
|
||||
/*
|
||||
* This code is needed for non-GNU getopt
|
||||
* which doesn't understand "-" in option string.
|
||||
* The -x option won't work properly in this case:
|
||||
* "unzip a.zip q -x w e" will be interpreted as
|
||||
* "unzip a.zip q w e -x" = "unzip a.zip q w e"
|
||||
*/
|
||||
argv += optind;
|
||||
if (argv[0]) {
|
||||
/* +5: space for ".zip" and NUL */
|
||||
src_fn = xmalloc(strlen(argv[0]) + 5);
|
||||
strcpy(src_fn, argv[0]);
|
||||
while (*++argv)
|
||||
llist_add_to(&zaccept, *argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!src_fn) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
@@ -420,17 +459,20 @@ int unzip_main(int argc, char **argv)
|
||||
if (overwrite == O_PROMPT)
|
||||
overwrite = O_NEVER;
|
||||
} else {
|
||||
static const char extn[][5] = {"", ".zip", ".ZIP"};
|
||||
int orig_src_fn_len = strlen(src_fn);
|
||||
int src_fd = -1;
|
||||
static const char extn[][5] = { ".zip", ".ZIP" };
|
||||
char *ext = src_fn + strlen(src_fn);
|
||||
int src_fd;
|
||||
|
||||
for (i = 0; (i < 3) && (src_fd == -1); i++) {
|
||||
strcpy(src_fn + orig_src_fn_len, extn[i]);
|
||||
i = 0;
|
||||
for (;;) {
|
||||
src_fd = open(src_fn, O_RDONLY);
|
||||
}
|
||||
if (src_fd == -1) {
|
||||
src_fn[orig_src_fn_len] = '\0';
|
||||
bb_error_msg_and_die("can't open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
|
||||
if (src_fd >= 0)
|
||||
break;
|
||||
if (++i > 2) {
|
||||
*ext = '\0';
|
||||
bb_error_msg_and_die("can't open %s[.zip]", src_fn);
|
||||
}
|
||||
strcpy(ext, extn[i - 1]);
|
||||
}
|
||||
xmove_fd(src_fd, zip_fd);
|
||||
}
|
||||
@@ -517,21 +559,31 @@ int unzip_main(int argc, char **argv)
|
||||
bb_error_msg_and_die("zip flag 1 (encryption) is not supported");
|
||||
}
|
||||
|
||||
{
|
||||
if (cdf_offset != BAD_CDF_OFFSET) {
|
||||
cdf_header_t cdf_header;
|
||||
cdf_offset = read_next_cdf(cdf_offset, &cdf_header);
|
||||
/*
|
||||
* Note: cdf_offset can become BAD_CDF_OFFSET after the above call.
|
||||
*/
|
||||
if (zip_header.formatted.zip_flags & SWAP_LE16(0x0008)) {
|
||||
/* 0x0008 - streaming. [u]cmpsize can be reliably gotten
|
||||
* only from Central Directory. See unzip_doc.txt */
|
||||
* only from Central Directory. See unzip_doc.txt
|
||||
*/
|
||||
zip_header.formatted.crc32 = cdf_header.formatted.crc32;
|
||||
zip_header.formatted.cmpsize = cdf_header.formatted.cmpsize;
|
||||
zip_header.formatted.ucmpsize = cdf_header.formatted.ucmpsize;
|
||||
}
|
||||
if ((cdf_header.formatted.version_made_by >> 8) == 3) {
|
||||
/* this archive is created on Unix */
|
||||
/* This archive is created on Unix */
|
||||
dir_mode = file_mode = (cdf_header.formatted.external_file_attributes >> 16);
|
||||
}
|
||||
}
|
||||
if (cdf_offset == BAD_CDF_OFFSET
|
||||
&& (zip_header.formatted.zip_flags & SWAP_LE16(0x0008))
|
||||
) {
|
||||
/* If it's a streaming zip, we _require_ CDF */
|
||||
bb_error_msg_and_die("can't find file table");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Read filename */
|
||||
@@ -596,7 +648,7 @@ int unzip_main(int argc, char **argv)
|
||||
printf(" creating: %s\n", dst_fn);
|
||||
}
|
||||
unzip_create_leading_dirs(dst_fn);
|
||||
if (bb_make_directory(dst_fn, dir_mode, 0)) {
|
||||
if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) {
|
||||
xfunc_die();
|
||||
}
|
||||
} else {
|
||||
@@ -621,10 +673,7 @@ int unzip_main(int argc, char **argv)
|
||||
i = 'y';
|
||||
} else {
|
||||
printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
|
||||
fflush_all();
|
||||
if (!fgets(key_buf, sizeof(key_buf), stdin)) {
|
||||
bb_perror_msg_and_die("can't read input");
|
||||
}
|
||||
my_fgets80(key_buf);
|
||||
i = key_buf[0];
|
||||
}
|
||||
} else { /* File is not regular file */
|
||||
@@ -665,9 +714,7 @@ int unzip_main(int argc, char **argv)
|
||||
case 'r':
|
||||
/* Prompt for new name */
|
||||
printf("new name: ");
|
||||
if (!fgets(key_buf, sizeof(key_buf), stdin)) {
|
||||
bb_perror_msg_and_die("can't read input");
|
||||
}
|
||||
my_fgets80(key_buf);
|
||||
free(dst_fn);
|
||||
dst_fn = xstrdup(key_buf);
|
||||
chomp(dst_fn);
|
||||
|
||||
@@ -341,7 +341,6 @@ CONFIG_FEATURE_VI_READONLY=y
|
||||
CONFIG_FEATURE_VI_SETOPTS=y
|
||||
CONFIG_FEATURE_VI_SET=y
|
||||
CONFIG_FEATURE_VI_WIN_RESIZE=y
|
||||
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
|
||||
CONFIG_FEATURE_ALLOW_EXEC=y
|
||||
|
||||
#
|
||||
|
||||
@@ -346,7 +346,6 @@ CONFIG_FEATURE_VI_MAX_LEN=0
|
||||
# CONFIG_FEATURE_VI_SET is not set
|
||||
# CONFIG_FEATURE_VI_WIN_RESIZE is not set
|
||||
# CONFIG_FEATURE_VI_ASK_TERMINAL is not set
|
||||
# CONFIG_FEATURE_VI_OPTIMIZE_CURSOR is not set
|
||||
# CONFIG_FEATURE_ALLOW_EXEC is not set
|
||||
|
||||
#
|
||||
|
||||
@@ -358,7 +358,6 @@ CONFIG_FEATURE_VI_READONLY=y
|
||||
CONFIG_FEATURE_VI_SETOPTS=y
|
||||
CONFIG_FEATURE_VI_SET=y
|
||||
CONFIG_FEATURE_VI_WIN_RESIZE=y
|
||||
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
|
||||
CONFIG_FEATURE_ALLOW_EXEC=y
|
||||
|
||||
#
|
||||
|
||||
@@ -363,7 +363,6 @@ CONFIG_FEATURE_VI_MAX_LEN=0
|
||||
# CONFIG_FEATURE_VI_SET is not set
|
||||
# CONFIG_FEATURE_VI_WIN_RESIZE is not set
|
||||
# CONFIG_FEATURE_VI_ASK_TERMINAL is not set
|
||||
# CONFIG_FEATURE_VI_OPTIMIZE_CURSOR is not set
|
||||
# CONFIG_AWK is not set
|
||||
# CONFIG_FEATURE_AWK_LIBM is not set
|
||||
CONFIG_CMP=y
|
||||
|
||||
@@ -386,7 +386,6 @@ CONFIG_FEATURE_VI_SETOPTS=y
|
||||
CONFIG_FEATURE_VI_SET=y
|
||||
CONFIG_FEATURE_VI_WIN_RESIZE=y
|
||||
CONFIG_FEATURE_VI_ASK_TERMINAL=y
|
||||
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
|
||||
CONFIG_AWK=y
|
||||
CONFIG_FEATURE_AWK_LIBM=y
|
||||
CONFIG_CMP=y
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.20.0.git
|
||||
# Fri Mar 2 16:53:26 2012
|
||||
# Busybox version: 1.21.0.git
|
||||
# Mon May 28 21:51:18 2012
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
@@ -20,11 +20,11 @@ CONFIG_PLATFORM_LINUX=y
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
# CONFIG_SHOW_USAGE is not set
|
||||
# CONFIG_FEATURE_VERBOSE_USAGE is not set
|
||||
# CONFIG_FEATURE_COMPRESS_USAGE is not set
|
||||
# CONFIG_FEATURE_INSTALLER is not set
|
||||
# CONFIG_INSTALL_NO_USR is not set
|
||||
CONFIG_SHOW_USAGE=y
|
||||
CONFIG_FEATURE_VERBOSE_USAGE=y
|
||||
CONFIG_FEATURE_COMPRESS_USAGE=y
|
||||
CONFIG_FEATURE_INSTALLER=y
|
||||
CONFIG_INSTALL_NO_USR=y
|
||||
# CONFIG_LOCALE_SUPPORT is not set
|
||||
# CONFIG_UNICODE_SUPPORT is not set
|
||||
# CONFIG_UNICODE_USING_LOCALE is not set
|
||||
@@ -36,7 +36,7 @@ CONFIG_LAST_SUPPORTED_WCHAR=0
|
||||
# CONFIG_UNICODE_BIDI_SUPPORT is not set
|
||||
# CONFIG_UNICODE_NEUTRAL_TABLE is not set
|
||||
# CONFIG_UNICODE_PRESERVE_BROKEN is not set
|
||||
# CONFIG_LONG_OPTS is not set
|
||||
CONFIG_LONG_OPTS=y
|
||||
# CONFIG_FEATURE_DEVPTS is not set
|
||||
# CONFIG_FEATURE_CLEAN_UP is not set
|
||||
# CONFIG_FEATURE_UTMP is not set
|
||||
@@ -67,7 +67,6 @@ CONFIG_EXTRA_CFLAGS="-DANDROID -D__ANDROID__ -DSK_RELEASE -nostdlib -march=armv7
|
||||
CONFIG_EXTRA_LDFLAGS="-Xlinker -z -Xlinker muldefs -nostdlib -Bdynamic -Xlinker -dynamic-linker -Xlinker /system/bin/linker -Xlinker -z -Xlinker nocopyreloc -Xlinker --no-undefined ${SYSROOT}/usr/lib/crtbegin_dynamic.o ${SYSROOT}/usr/lib/crtend_android.o"
|
||||
CONFIG_EXTRA_LDLIBS="dl m c gcc"
|
||||
|
||||
|
||||
#
|
||||
# Debugging Options
|
||||
#
|
||||
@@ -112,7 +111,7 @@ CONFIG_FEATURE_EDITING_HISTORY=0
|
||||
# CONFIG_FEATURE_EDITING_FANCY_PROMPT is not set
|
||||
# CONFIG_FEATURE_EDITING_ASK_TERMINAL is not set
|
||||
# CONFIG_FEATURE_NON_POSIX_CP is not set
|
||||
# CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set
|
||||
CONFIG_FEATURE_VERBOSE_CP_MESSAGE=y
|
||||
CONFIG_FEATURE_COPYBUF_KB=4
|
||||
# CONFIG_FEATURE_SKIP_ROOTFS is not set
|
||||
# CONFIG_MONOTONIC_SYSCALL is not set
|
||||
@@ -239,7 +238,7 @@ CONFIG_FEATURE_LS_RECURSIVE=y
|
||||
CONFIG_FEATURE_LS_SORTFILES=y
|
||||
CONFIG_FEATURE_LS_TIMESTAMPS=y
|
||||
CONFIG_FEATURE_LS_USERNAME=y
|
||||
# CONFIG_FEATURE_LS_COLOR is not set
|
||||
CONFIG_FEATURE_LS_COLOR=y
|
||||
# CONFIG_FEATURE_LS_COLOR_IS_DEFAULT is not set
|
||||
CONFIG_MD5SUM=y
|
||||
CONFIG_MKDIR=y
|
||||
@@ -372,7 +371,6 @@ CONFIG_FEATURE_VI_SETOPTS=y
|
||||
CONFIG_FEATURE_VI_SET=y
|
||||
CONFIG_FEATURE_VI_WIN_RESIZE=y
|
||||
CONFIG_FEATURE_VI_ASK_TERMINAL=y
|
||||
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
|
||||
CONFIG_AWK=y
|
||||
CONFIG_FEATURE_AWK_LIBM=y
|
||||
CONFIG_CMP=y
|
||||
@@ -516,7 +514,7 @@ CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
|
||||
# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
|
||||
# CONFIG_FEATURE_MODUTILS_ALIAS is not set
|
||||
# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
|
||||
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
|
||||
CONFIG_DEFAULT_MODULES_DIR="/system/lib/modules"
|
||||
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
|
||||
|
||||
#
|
||||
@@ -647,8 +645,8 @@ CONFIG_SETSERIAL=y
|
||||
# CONFIG_UBIRSVOL is not set
|
||||
# CONFIG_UBIUPDATEVOL is not set
|
||||
# CONFIG_ADJTIMEX is not set
|
||||
# CONFIG_BBCONFIG is not set
|
||||
# CONFIG_FEATURE_COMPRESS_BBCONFIG is not set
|
||||
CONFIG_BBCONFIG=y
|
||||
CONFIG_FEATURE_COMPRESS_BBCONFIG=y
|
||||
CONFIG_BEEP=y
|
||||
CONFIG_FEATURE_BEEP_FREQ=4000
|
||||
CONFIG_FEATURE_BEEP_LENGTH_MS=30
|
||||
@@ -883,6 +881,7 @@ CONFIG_SENDMAIL=y
|
||||
# Process Utilities
|
||||
#
|
||||
CONFIG_IOSTAT=y
|
||||
CONFIG_LSOF=y
|
||||
CONFIG_MPSTAT=y
|
||||
CONFIG_NMETER=y
|
||||
CONFIG_PMAP=y
|
||||
|
||||
@@ -363,7 +363,6 @@ CONFIG_FEATURE_VI_SETOPTS=y
|
||||
CONFIG_FEATURE_VI_SET=y
|
||||
CONFIG_FEATURE_VI_WIN_RESIZE=y
|
||||
CONFIG_FEATURE_VI_ASK_TERMINAL=y
|
||||
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
|
||||
CONFIG_AWK=y
|
||||
CONFIG_FEATURE_AWK_LIBM=y
|
||||
CONFIG_CMP=y
|
||||
|
||||
@@ -367,7 +367,6 @@ CONFIG_FEATURE_VI_SETOPTS=y
|
||||
CONFIG_FEATURE_VI_SET=y
|
||||
CONFIG_FEATURE_VI_WIN_RESIZE=y
|
||||
CONFIG_FEATURE_VI_ASK_TERMINAL=y
|
||||
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
|
||||
CONFIG_FEATURE_ALLOW_EXEC=y
|
||||
|
||||
#
|
||||
|
||||
+23
-14
@@ -36,47 +36,56 @@ int dumpkmap_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
RESERVE_CONFIG_BUFFER(flags, MAX_NR_KEYMAPS);
|
||||
#define flags bb_common_bufsiz1
|
||||
|
||||
/* When user accidentally runs "dumpkmap FILE"
|
||||
* instead of "dumpkmap >FILE", we'd dump binary stuff to tty.
|
||||
* Let's prevent it: */
|
||||
* Let's prevent it:
|
||||
*/
|
||||
if (argv[1])
|
||||
bb_show_usage();
|
||||
/* bb_warn_ignoring_args(argv[1]);*/
|
||||
|
||||
fd = get_console_fd_or_die();
|
||||
|
||||
#if 0
|
||||
write(STDOUT_FILENO, "bkeymap", 7);
|
||||
|
||||
/* Here we want to set everything to 0 except for indexes:
|
||||
* [0-2] [4-6] [8-10] [12] */
|
||||
memset(flags, 0x00, MAX_NR_KEYMAPS);
|
||||
* [0-2] [4-6] [8-10] [12]
|
||||
*/
|
||||
/*memset(flags, 0x00, MAX_NR_KEYMAPS); - already is */
|
||||
memset(flags, 0x01, 13);
|
||||
flags[3] = flags[7] = flags[11] = 0;
|
||||
|
||||
/* dump flags */
|
||||
write(STDOUT_FILENO, flags, MAX_NR_KEYMAPS);
|
||||
#define flags7 flags
|
||||
#else
|
||||
/* Same effect */
|
||||
/* 0 1 2 3 4 5 6 7 8 9 a b c=12 */
|
||||
memcpy(flags, "bkeymap\1\1\1\0\1\1\1\0\1\1\1\0\1",
|
||||
/* Can use sizeof, or sizeof-1. sizeof is even, using that */
|
||||
/****/ sizeof("bkeymap\1\1\1\0\1\1\1\0\1\1\1\0\1")
|
||||
);
|
||||
write(STDOUT_FILENO, flags, 7 + MAX_NR_KEYMAPS);
|
||||
#define flags7 (flags + 7)
|
||||
#endif
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
for (i = 0; i < 13; i++) {
|
||||
if (flags7[i]) {
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
if (!ioctl_or_perror(fd, KDGKBENT, &ke,
|
||||
"ioctl failed with %s, %s, %p",
|
||||
(char *)&ke.kb_index,
|
||||
(char *)&ke.kb_table,
|
||||
&ke.kb_value)
|
||||
"ioctl(KDGKBENT{%d,%d}) failed",
|
||||
j, i)
|
||||
) {
|
||||
write(STDOUT_FILENO, (void*)&ke.kb_value, 2);
|
||||
write(STDOUT_FILENO, &ke.kb_value, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(fd);
|
||||
RELEASE_CONFIG_BUFFER(flags);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -229,7 +229,7 @@ static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize,
|
||||
}
|
||||
|
||||
/* Note: after PIO_UNIMAPCLR and before PIO_UNIMAP
|
||||
this printf did not work on many kernels */
|
||||
* this printf did not work on many kernels */
|
||||
|
||||
advice.advised_hashsize = 0;
|
||||
advice.advised_hashstep = 0;
|
||||
|
||||
@@ -48,6 +48,7 @@ int loadkmap_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (argv[1])
|
||||
bb_show_usage();
|
||||
/* bb_warn_ignoring_args(argv[1]); */
|
||||
|
||||
fd = get_console_fd_or_die();
|
||||
/* or maybe:
|
||||
opt = getopt32(argv, "C:", &tty_name);
|
||||
@@ -61,14 +62,24 @@ int loadkmap_main(int argc UNUSED_PARAM, char **argv)
|
||||
xread(STDIN_FILENO, flags, MAX_NR_KEYMAPS);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
xread(STDIN_FILENO, ibuff, NR_KEYS * sizeof(uint16_t));
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
ke.kb_value = ibuff[j];
|
||||
ioctl(fd, KDSKBENT, &ke);
|
||||
}
|
||||
if (flags[i] != 1)
|
||||
continue;
|
||||
xread(STDIN_FILENO, ibuff, NR_KEYS * sizeof(uint16_t));
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
ke.kb_value = ibuff[j];
|
||||
/*
|
||||
* Note: table[idx:0] can contain special value
|
||||
* K_ALLOCATED (marks allocated tables in kernel).
|
||||
* dumpkmap saves the value as-is; but attempts
|
||||
* to load it here fail, since it isn't a valid
|
||||
* key value: it is K(KT_SPEC,126) == 2<<8 + 126,
|
||||
* whereas last valid KT_SPEC is
|
||||
* K_BARENUMLOCK == K(KT_SPEC,19).
|
||||
* So far we just ignore these errors:
|
||||
*/
|
||||
ioctl(fd, KDSKBENT, &ke);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,10 @@ int setlogcons_main(int argc UNUSED_PARAM, char **argv)
|
||||
struct {
|
||||
char fn;
|
||||
char subarg;
|
||||
} arg = { 11, /* redirect kernel messages */
|
||||
0 /* to specified console (current as default) */
|
||||
};
|
||||
} arg = {
|
||||
11, /* redirect kernel messages */
|
||||
0 /* to specified console (current as default) */
|
||||
};
|
||||
|
||||
if (argv[1])
|
||||
arg.subarg = xatou_range(argv[1], 0, 63);
|
||||
|
||||
@@ -514,6 +514,12 @@ config SHA512SUM
|
||||
help
|
||||
Compute and check SHA512 message digest
|
||||
|
||||
config SHA3SUM
|
||||
bool "sha3sum"
|
||||
default y
|
||||
help
|
||||
Compute and check SHA3 (512-bit) message digest
|
||||
|
||||
config SLEEP
|
||||
bool "sleep"
|
||||
default y
|
||||
@@ -766,13 +772,13 @@ config FEATURE_HUMAN_READABLE
|
||||
help
|
||||
Allow df, du, and ls to have human readable output.
|
||||
|
||||
comment "Common options for md5sum, sha1sum, sha256sum, sha512sum"
|
||||
depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM
|
||||
comment "Common options for md5sum, sha1sum, sha256sum, sha512sum, sha3sum"
|
||||
depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM || SHA3SUM
|
||||
|
||||
config FEATURE_MD5_SHA1_SUM_CHECK
|
||||
bool "Enable -c, -s and -w options"
|
||||
default y
|
||||
depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM
|
||||
depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM || SHA3SUM
|
||||
help
|
||||
Enabling the -c options allows files to be checked
|
||||
against pre-calculated hash values.
|
||||
|
||||
@@ -35,7 +35,6 @@ lib-$(CONFIG_EXPAND) += expand.o
|
||||
lib-$(CONFIG_FALSE) += false.o
|
||||
lib-$(CONFIG_FOLD) += fold.o
|
||||
lib-$(CONFIG_FSYNC) += fsync.o
|
||||
lib-$(CONFIG_HEAD) += head.o
|
||||
lib-$(CONFIG_INSTALL) += install.o
|
||||
#lib-$(CONFIG_LENGTH) += length.o
|
||||
lib-$(CONFIG_LN) += ln.o
|
||||
@@ -62,6 +61,7 @@ lib-$(CONFIG_SEQ) += seq.o
|
||||
lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
|
||||
lib-$(CONFIG_SHA256SUM) += md5_sha1_sum.o
|
||||
lib-$(CONFIG_SHA512SUM) += md5_sha1_sum.o
|
||||
lib-$(CONFIG_SHA3SUM) += md5_sha1_sum.o
|
||||
lib-$(CONFIG_SLEEP) += sleep.o
|
||||
lib-$(CONFIG_SPLIT) += split.o
|
||||
lib-$(CONFIG_SORT) += sort.o
|
||||
@@ -70,7 +70,6 @@ lib-$(CONFIG_STTY) += stty.o
|
||||
lib-$(CONFIG_SUM) += sum.o
|
||||
lib-$(CONFIG_SYNC) += sync.o
|
||||
lib-$(CONFIG_TAC) += tac.o
|
||||
lib-$(CONFIG_TAIL) += tail.o
|
||||
lib-$(CONFIG_TEE) += tee.o
|
||||
lib-$(CONFIG_TRUE) += true.o
|
||||
lib-$(CONFIG_TTY) += tty.o
|
||||
|
||||
+9
-8
@@ -43,7 +43,7 @@ static const unsigned char days_in_month[] ALIGN1 = {
|
||||
};
|
||||
|
||||
static const unsigned char sep1752[] ALIGN1 = {
|
||||
1, 2, 14, 15, 16,
|
||||
1, 2, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23,
|
||||
24, 25, 26, 27, 28, 29, 30
|
||||
};
|
||||
@@ -165,10 +165,10 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
|
||||
char lineout[30];
|
||||
|
||||
day_array(month, year, dp);
|
||||
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
|
||||
len = sprintf(lineout, "%s %u", month_names[month - 1], year);
|
||||
printf("%*s%s\n%s\n",
|
||||
((7*julian + WEEK_LEN) - len) / 2, "",
|
||||
lineout, day_headings);
|
||||
((7*julian + WEEK_LEN) - len) / 2, "",
|
||||
lineout, day_headings);
|
||||
for (row = 0; row < 6; row++) {
|
||||
build_row(lineout, dp)[0] = '\0';
|
||||
dp += 7;
|
||||
@@ -181,10 +181,11 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
sprintf(lineout, "%u", year);
|
||||
center(lineout,
|
||||
(WEEK_LEN * 3 + HEAD_SEP * 2)
|
||||
+ julian * (J_WEEK_LEN * 2 + HEAD_SEP
|
||||
- (WEEK_LEN * 3 + HEAD_SEP * 2)),
|
||||
0);
|
||||
(WEEK_LEN * 3 + HEAD_SEP * 2)
|
||||
+ julian * (J_WEEK_LEN * 2 + HEAD_SEP
|
||||
- (WEEK_LEN * 3 + HEAD_SEP * 2)),
|
||||
0
|
||||
);
|
||||
puts("\n"); /* two \n's */
|
||||
for (i = 0; i < 12; i++) {
|
||||
day_array(i + 1, year, days[i]);
|
||||
|
||||
+20
-23
@@ -25,14 +25,23 @@ int catv_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
int fd;
|
||||
unsigned flags;
|
||||
|
||||
flags = getopt32(argv, "etv");
|
||||
unsigned opts;
|
||||
#define CATV_OPT_e (1<<0)
|
||||
#define CATV_OPT_t (1<<1)
|
||||
#define CATV_OPT_v (1<<2)
|
||||
flags ^= CATV_OPT_v;
|
||||
typedef char BUG_const_mismatch[
|
||||
CATV_OPT_e == VISIBLE_ENDLINE && CATV_OPT_t == VISIBLE_SHOW_TABS
|
||||
? 1 : -1
|
||||
];
|
||||
|
||||
opts = getopt32(argv, "etv");
|
||||
argv += optind;
|
||||
#if 0 /* These consts match, we can just pass "opts" to visible() */
|
||||
if (opts & CATV_OPT_e)
|
||||
flags |= VISIBLE_ENDLINE;
|
||||
if (opts & CATV_OPT_t)
|
||||
flags |= VISIBLE_SHOW_TABS;
|
||||
#endif
|
||||
|
||||
/* Read from stdin if there's nothing else to do. */
|
||||
if (!argv[0])
|
||||
@@ -50,29 +59,17 @@ int catv_main(int argc UNUSED_PARAM, char **argv)
|
||||
res = read(fd, read_buf, COMMON_BUFSIZE);
|
||||
if (res < 0)
|
||||
retval = EXIT_FAILURE;
|
||||
if (res < 1)
|
||||
if (res <= 0)
|
||||
break;
|
||||
for (i = 0; i < res; i++) {
|
||||
unsigned char c = read_buf[i];
|
||||
|
||||
if (c > 126 && (flags & CATV_OPT_v)) {
|
||||
if (c == 127) {
|
||||
printf("^?");
|
||||
continue;
|
||||
}
|
||||
printf("M-");
|
||||
c -= 128;
|
||||
if (opts & CATV_OPT_v) {
|
||||
putchar(c);
|
||||
} else {
|
||||
char buf[sizeof("M-^c")];
|
||||
visible(c, buf, opts);
|
||||
fputs(buf, stdout);
|
||||
}
|
||||
if (c < 32) {
|
||||
if (c == 10) {
|
||||
if (flags & CATV_OPT_e)
|
||||
bb_putchar('$');
|
||||
} else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) {
|
||||
printf("^%c", c+'@');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
bb_putchar(c);
|
||||
}
|
||||
}
|
||||
if (ENABLE_FEATURE_CLEAN_UP && fd)
|
||||
|
||||
+2
-2
@@ -126,8 +126,8 @@ int chown_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* This matches coreutils behavior (almost - see below) */
|
||||
param.chown_func = chown;
|
||||
if (OPT_NODEREF
|
||||
/* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */
|
||||
IF_DESKTOP( || (opt & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
|
||||
/* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */
|
||||
IF_DESKTOP( || (opt & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
|
||||
) {
|
||||
param.chown_func = lchown;
|
||||
}
|
||||
|
||||
+1
-1
@@ -212,7 +212,7 @@ int cut_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (opt & CUT_OPT_SUPPRESS_FLGS) {
|
||||
bb_error_msg_and_die
|
||||
("suppressing non-delimited lines makes sense%s",
|
||||
_op_on_field);
|
||||
_op_on_field);
|
||||
}
|
||||
if (delim != '\t') {
|
||||
bb_error_msg_and_die
|
||||
|
||||
+76
-35
@@ -30,10 +30,10 @@
|
||||
//usage: "\n conv=noerror Continue after read errors"
|
||||
//usage: "\n conv=sync Pad blocks with zeros"
|
||||
//usage: "\n conv=fsync Physically write data out before finishing"
|
||||
//usage: "\n conv=swab Swap every pair of bytes"
|
||||
//usage: )
|
||||
//usage: "\n"
|
||||
//usage: "\nNumbers may be suffixed by c (x1), w (x2), b (x512), kD (x1000), k (x1024),"
|
||||
//usage: "\nMD (x1000000), M (x1048576), GD (x1000000000) or G (x1073741824)"
|
||||
//usage: "\nN may be suffixed by c (1), w (2), b (512), kD (1000), k (1024), MD, M, GD, G"
|
||||
//usage:
|
||||
//usage:#define dd_example_usage
|
||||
//usage: "$ dd if=/dev/zero of=/dev/ram1 bs=1M count=4\n"
|
||||
@@ -151,13 +151,14 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
enum {
|
||||
/* 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,
|
||||
FLAG_NOTRUNC = (1 << 0) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_SYNC = (1 << 1) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_NOERROR = (1 << 2) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_FSYNC = (1 << 3) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_SWAB = (1 << 4) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
/* end of conv flags */
|
||||
FLAG_TWOBUFS = 1 << 4,
|
||||
FLAG_COUNT = 1 << 5,
|
||||
FLAG_TWOBUFS = (1 << 5) * ENABLE_FEATURE_DD_IBS_OBS,
|
||||
FLAG_COUNT = 1 << 6,
|
||||
};
|
||||
static const char keywords[] ALIGN1 =
|
||||
"bs\0""count\0""seek\0""skip\0""if\0""of\0"
|
||||
@@ -167,7 +168,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
;
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
static const char conv_words[] ALIGN1 =
|
||||
"notrunc\0""sync\0""noerror\0""fsync\0";
|
||||
"notrunc\0""sync\0""noerror\0""fsync\0""swab\0";
|
||||
#endif
|
||||
enum {
|
||||
OP_bs = 0,
|
||||
@@ -185,11 +186,11 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
OP_conv_sync,
|
||||
OP_conv_noerror,
|
||||
OP_conv_fsync,
|
||||
OP_conv_swab,
|
||||
/* 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
|
||||
@@ -197,22 +198,33 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
//ascii from EBCDIC to ASCII
|
||||
//ebcdic from ASCII to EBCDIC
|
||||
//ibm from ASCII to alternate EBCDIC
|
||||
/* Partially implemented: */
|
||||
//swab swap every pair of input bytes: will abort on non-even reads
|
||||
#endif
|
||||
};
|
||||
int exitcode = EXIT_FAILURE;
|
||||
size_t ibs = 512, obs = 512;
|
||||
ssize_t n, w;
|
||||
char *ibuf, *obuf;
|
||||
/* And these are all zeroed at once! */
|
||||
smallint exitcode = EXIT_FAILURE;
|
||||
int i;
|
||||
size_t ibs = 512;
|
||||
char *ibuf;
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
size_t obs = 512;
|
||||
char *obuf;
|
||||
#else
|
||||
# define obs ibs
|
||||
# define obuf ibuf
|
||||
#endif
|
||||
/* These are all zeroed at once! */
|
||||
struct {
|
||||
int flags;
|
||||
size_t oc;
|
||||
ssize_t prev_read_size; /* for detecting swab failure */
|
||||
off_t count;
|
||||
off_t seek, skip;
|
||||
const char *infile, *outfile;
|
||||
} Z;
|
||||
#define flags (Z.flags )
|
||||
#define oc (Z.oc )
|
||||
#define prev_read_size (Z.prev_read_size)
|
||||
#define count (Z.count )
|
||||
#define seek (Z.seek )
|
||||
#define skip (Z.skip )
|
||||
@@ -223,10 +235,10 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
INIT_G();
|
||||
//fflush_all(); - is this needed because of NOEXEC?
|
||||
|
||||
for (n = 1; argv[n]; n++) {
|
||||
for (i = 1; argv[i]; i++) {
|
||||
int what;
|
||||
char *val;
|
||||
char *arg = argv[n];
|
||||
char *arg = argv[i];
|
||||
|
||||
#if ENABLE_DESKTOP
|
||||
/* "dd --". NB: coreutils 6.9 will complain if they see
|
||||
@@ -255,6 +267,7 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
if (what == OP_conv) {
|
||||
while (1) {
|
||||
int n;
|
||||
/* find ',', replace them with NUL so we can use val for
|
||||
* index_in_strings() without copying.
|
||||
* We rely on val being non-null, else strchr would fault.
|
||||
@@ -262,20 +275,21 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
arg = strchr(val, ',');
|
||||
if (arg)
|
||||
*arg = '\0';
|
||||
what = index_in_strings(conv_words, val);
|
||||
if (what < 0)
|
||||
n = index_in_strings(conv_words, val);
|
||||
if (n < 0)
|
||||
bb_error_msg_and_die(bb_msg_invalid_arg, val, "conv");
|
||||
flags |= (1 << what);
|
||||
flags |= (1 << n);
|
||||
if (!arg) /* no ',' left, so this was the last specifier */
|
||||
break;
|
||||
/* *arg = ','; - to preserve ps listing? */
|
||||
val = arg + 1; /* skip this keyword and ',' */
|
||||
}
|
||||
continue; /* we trashed 'what', can't fall through */
|
||||
/*continue;*/
|
||||
}
|
||||
#endif
|
||||
if (what == OP_bs) {
|
||||
ibs = obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
obs = ibs;
|
||||
/*continue;*/
|
||||
}
|
||||
/* These can be large: */
|
||||
@@ -300,14 +314,17 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
outfile = val;
|
||||
/*continue;*/
|
||||
}
|
||||
} /* end of "for (argv[n])" */
|
||||
} /* end of "for (argv[i])" */
|
||||
|
||||
//XXX:FIXME for huge ibs or obs, malloc'ing them isn't the brightest idea ever
|
||||
ibuf = obuf = xmalloc(ibs);
|
||||
ibuf = xmalloc(ibs);
|
||||
obuf = ibuf;
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (ibs != obs) {
|
||||
flags |= FLAG_TWOBUFS;
|
||||
obuf = xmalloc(obs);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_DD_SIGNAL_HANDLING
|
||||
signal_SA_RESTART_empty_mask(SIGUSR1, dd_output_status);
|
||||
@@ -316,12 +333,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
G.begin_time_us = monotonic_us();
|
||||
#endif
|
||||
|
||||
if (infile != NULL)
|
||||
if (infile) {
|
||||
xmove_fd(xopen(infile, O_RDONLY), ifd);
|
||||
else {
|
||||
} else {
|
||||
infile = bb_msg_standard_input;
|
||||
}
|
||||
if (outfile != NULL) {
|
||||
if (outfile) {
|
||||
int oflag = O_WRONLY | O_CREAT;
|
||||
|
||||
if (!seek && !(flags & FLAG_NOTRUNC))
|
||||
@@ -346,13 +363,13 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
if (skip) {
|
||||
if (lseek(ifd, skip * ibs, SEEK_CUR) < 0) {
|
||||
while (skip-- > 0) {
|
||||
n = safe_read(ifd, ibuf, ibs);
|
||||
do {
|
||||
ssize_t n = safe_read(ifd, ibuf, ibs);
|
||||
if (n < 0)
|
||||
goto die_infile;
|
||||
if (n == 0)
|
||||
break;
|
||||
}
|
||||
} while (--skip != 0);
|
||||
}
|
||||
}
|
||||
if (seek) {
|
||||
@@ -361,6 +378,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
|
||||
while (!(flags & FLAG_COUNT) || (G.in_full + G.in_part != count)) {
|
||||
ssize_t n;
|
||||
|
||||
n = safe_read(ifd, ibuf, ibs);
|
||||
if (n == 0)
|
||||
break;
|
||||
@@ -375,6 +394,27 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
* conv=noerror just ignores input bad blocks */
|
||||
n = 0;
|
||||
}
|
||||
if (flags & FLAG_SWAB) {
|
||||
uint16_t *p16;
|
||||
ssize_t n2;
|
||||
|
||||
/* Our code allows only last read to be odd-sized */
|
||||
if (prev_read_size & 1)
|
||||
bb_error_msg_and_die("can't swab %lu byte buffer",
|
||||
(unsigned long)prev_read_size);
|
||||
prev_read_size = n;
|
||||
|
||||
/* If n is odd, last byte is not swapped:
|
||||
* echo -n "qwe" | dd conv=swab
|
||||
* prints "wqe".
|
||||
*/
|
||||
p16 = (void*) ibuf;
|
||||
n2 = (n >> 1);
|
||||
while (--n2 >= 0) {
|
||||
*p16 = bswap_16(*p16);
|
||||
p16++;
|
||||
}
|
||||
}
|
||||
if ((size_t)n == ibs)
|
||||
G.in_full++;
|
||||
else {
|
||||
@@ -401,8 +441,10 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
oc = 0;
|
||||
}
|
||||
}
|
||||
} else if (write_and_stats(ibuf, n, obs, outfile))
|
||||
goto out_status;
|
||||
} else {
|
||||
if (write_and_stats(ibuf, n, obs, outfile))
|
||||
goto out_status;
|
||||
}
|
||||
|
||||
if (flags & FLAG_FSYNC) {
|
||||
if (fsync(ofd) < 0)
|
||||
@@ -411,9 +453,8 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
|
||||
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 (write_and_stats(obuf, oc, obs, outfile))
|
||||
goto out_status;
|
||||
}
|
||||
if (close(ifd) < 0) {
|
||||
die_infile:
|
||||
|
||||
+4
-4
@@ -110,9 +110,9 @@ int df_main(int argc UNUSED_PARAM, char **argv)
|
||||
df_disp_hr = xatoul_range(chp, 1, ULONG_MAX); /* disallow 0 */
|
||||
|
||||
/* From the manpage of df from coreutils-6.10:
|
||||
Disk space is shown in 1K blocks by default, unless the environment
|
||||
variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
|
||||
*/
|
||||
* Disk space is shown in 1K blocks by default, unless the environment
|
||||
* variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
|
||||
*/
|
||||
if (getenv("POSIXLY_CORRECT")) /* TODO - a new libbb function? */
|
||||
df_disp_hr = 512;
|
||||
|
||||
@@ -221,7 +221,7 @@ int df_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
#else
|
||||
if (printf("\n%-20s" + 1, device) > 20 && !(opt & OPT_POSIX))
|
||||
printf("\n%-20s", "");
|
||||
printf("\n%-20s", "");
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_HUMAN_READABLE
|
||||
|
||||
@@ -89,6 +89,10 @@ struct globals {
|
||||
#define INIT_G() do { } while (0)
|
||||
|
||||
|
||||
/* FIXME? coreutils' du rounds sizes up:
|
||||
* for example, 1025k file is shown as "2" by du -m.
|
||||
* We round to nearest.
|
||||
*/
|
||||
static void print(unsigned long long size, const char *filename)
|
||||
{
|
||||
/* TODO - May not want to defer error checking here. */
|
||||
|
||||
+3
-10
@@ -78,11 +78,7 @@ static void expand(FILE *file, unsigned tab_size, unsigned opt)
|
||||
unsigned len;
|
||||
*ptr = '\0';
|
||||
# if ENABLE_UNICODE_SUPPORT
|
||||
{
|
||||
uni_stat_t uni_stat;
|
||||
printable_string(&uni_stat, ptr_strbeg);
|
||||
len = uni_stat.unicode_width;
|
||||
}
|
||||
len = unicode_strwidth(ptr_strbeg);
|
||||
# else
|
||||
len = ptr - ptr_strbeg;
|
||||
# endif
|
||||
@@ -138,12 +134,9 @@ static void unexpand(FILE *file, unsigned tab_size, unsigned opt)
|
||||
printf("%*s%.*s", len, "", n, ptr);
|
||||
# if ENABLE_UNICODE_SUPPORT
|
||||
{
|
||||
char c;
|
||||
uni_stat_t uni_stat;
|
||||
c = ptr[n];
|
||||
char c = ptr[n];
|
||||
ptr[n] = '\0';
|
||||
printable_string(&uni_stat, ptr);
|
||||
len = uni_stat.unicode_width;
|
||||
len = unicode_strwidth(ptr);
|
||||
ptr[n] = c;
|
||||
}
|
||||
# else
|
||||
|
||||
+130
-27
@@ -11,6 +11,8 @@
|
||||
/* BB_AUDIT GNU compatible -c, -q, and -v options in 'fancy' configuration. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/head.html */
|
||||
|
||||
//kbuild:lib-$(CONFIG_HEAD) += head.o
|
||||
|
||||
//usage:#define head_trivial_usage
|
||||
//usage: "[OPTIONS] [FILE]..."
|
||||
//usage:#define head_full_usage "\n\n"
|
||||
@@ -18,7 +20,8 @@
|
||||
//usage: "With more than one FILE, precede each with a filename header.\n"
|
||||
//usage: "\n -n N[kbm] Print first N lines"
|
||||
//usage: IF_FEATURE_FANCY_HEAD(
|
||||
//usage: "\n -c N[kbm] Print first N bytes"
|
||||
//usage: "\n -n -N[kbm] Print all except N last lines"
|
||||
//usage: "\n -c [-]N[kbm] Print first N bytes"
|
||||
//usage: "\n -q Never print headers"
|
||||
//usage: "\n -v Always print headers"
|
||||
//usage: )
|
||||
@@ -34,6 +37,110 @@
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
#if !ENABLE_FEATURE_FANCY_HEAD
|
||||
# define print_first_N(fp,count,bytes) print_first_N(fp,count)
|
||||
#endif
|
||||
static void
|
||||
print_first_N(FILE *fp, unsigned long count, bool count_bytes)
|
||||
{
|
||||
#if !ENABLE_FEATURE_FANCY_HEAD
|
||||
const int count_bytes = 0;
|
||||
#endif
|
||||
while (count) {
|
||||
int c = getc(fp);
|
||||
if (c == EOF)
|
||||
break;
|
||||
if (count_bytes || (c == '\n'))
|
||||
--count;
|
||||
putchar(c);
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_FANCY_HEAD
|
||||
static void
|
||||
print_except_N_last_bytes(FILE *fp, unsigned count)
|
||||
{
|
||||
unsigned char *circle = xmalloc(++count);
|
||||
unsigned head = 0;
|
||||
for(;;) {
|
||||
int c;
|
||||
c = getc(fp);
|
||||
if (c == EOF)
|
||||
goto ret;
|
||||
circle[head++] = c;
|
||||
if (head == count)
|
||||
break;
|
||||
}
|
||||
for (;;) {
|
||||
int c;
|
||||
if (head == count)
|
||||
head = 0;
|
||||
putchar(circle[head]);
|
||||
c = getc(fp);
|
||||
if (c == EOF)
|
||||
goto ret;
|
||||
circle[head] = c;
|
||||
head++;
|
||||
}
|
||||
ret:
|
||||
free(circle);
|
||||
}
|
||||
|
||||
static void
|
||||
print_except_N_last_lines(FILE *fp, unsigned count)
|
||||
{
|
||||
char **circle = xzalloc((++count) * sizeof(circle[0]));
|
||||
unsigned head = 0;
|
||||
for(;;) {
|
||||
char *c;
|
||||
c = xmalloc_fgets(fp);
|
||||
if (!c)
|
||||
goto ret;
|
||||
circle[head++] = c;
|
||||
if (head == count)
|
||||
break;
|
||||
}
|
||||
for (;;) {
|
||||
char *c;
|
||||
if (head == count)
|
||||
head = 0;
|
||||
fputs(circle[head], stdout);
|
||||
c = xmalloc_fgets(fp);
|
||||
if (!c)
|
||||
goto ret;
|
||||
free(circle[head]);
|
||||
circle[head++] = c;
|
||||
}
|
||||
ret:
|
||||
head = 0;
|
||||
for(;;) {
|
||||
free(circle[head++]);
|
||||
if (head == count)
|
||||
break;
|
||||
}
|
||||
free(circle);
|
||||
}
|
||||
#else
|
||||
/* Must never be called */
|
||||
void print_except_N_last_bytes(FILE *fp, unsigned count);
|
||||
void print_except_N_last_lines(FILE *fp, unsigned count);
|
||||
#endif
|
||||
|
||||
#if !ENABLE_FEATURE_FANCY_HEAD
|
||||
# define eat_num(negative_N,p) eat_num(p)
|
||||
#endif
|
||||
static unsigned long
|
||||
eat_num(bool *negative_N, const char *p)
|
||||
{
|
||||
#if ENABLE_FEATURE_FANCY_HEAD
|
||||
if (*p == '-') {
|
||||
*negative_N = 1;
|
||||
p++;
|
||||
}
|
||||
#endif
|
||||
return xatoul_sfx(p, bkm_suffixes);
|
||||
}
|
||||
|
||||
static const char head_opts[] ALIGN1 =
|
||||
"n:"
|
||||
#if ENABLE_FEATURE_FANCY_HEAD
|
||||
@@ -41,29 +148,25 @@ static const char head_opts[] ALIGN1 =
|
||||
#endif
|
||||
;
|
||||
|
||||
static const struct suffix_mult head_suffixes[] = {
|
||||
{ "b", 512 },
|
||||
{ "k", 1024 },
|
||||
{ "m", 1024*1024 },
|
||||
{ "", 0 }
|
||||
};
|
||||
|
||||
#define header_fmt_str "\n==> %s <==\n"
|
||||
|
||||
int head_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int head_main(int argc, char **argv)
|
||||
{
|
||||
unsigned long count = 10;
|
||||
unsigned long i;
|
||||
#if ENABLE_FEATURE_FANCY_HEAD
|
||||
int count_bytes = 0;
|
||||
int header_threshhold = 1;
|
||||
bool count_bytes = 0;
|
||||
bool negative_N = 0;
|
||||
#else
|
||||
# define header_threshhold 1
|
||||
# define count_bytes 0
|
||||
# define negative_N 0
|
||||
#endif
|
||||
FILE *fp;
|
||||
const char *fmt;
|
||||
char *p;
|
||||
int opt;
|
||||
int c;
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
|
||||
@@ -73,7 +176,7 @@ int head_main(int argc, char **argv)
|
||||
) {
|
||||
--argc;
|
||||
++argv;
|
||||
p = (*argv) + 1;
|
||||
p = argv[0] + 1;
|
||||
goto GET_COUNT;
|
||||
}
|
||||
#endif
|
||||
@@ -97,7 +200,7 @@ int head_main(int argc, char **argv)
|
||||
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
|
||||
GET_COUNT:
|
||||
#endif
|
||||
count = xatoul_sfx(p, head_suffixes);
|
||||
count = eat_num(&negative_N, p);
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
@@ -110,19 +213,17 @@ int head_main(int argc, char **argv)
|
||||
*--argv = (char*)"-";
|
||||
|
||||
fmt = header_fmt_str + 1;
|
||||
#if ENABLE_FEATURE_FANCY_HEAD
|
||||
if (argc <= header_threshhold) {
|
||||
#if ENABLE_FEATURE_FANCY_HEAD
|
||||
header_threshhold = 0;
|
||||
}
|
||||
#else
|
||||
if (argc <= 1) {
|
||||
fmt += 11; /* "" */
|
||||
}
|
||||
/* Now define some things here to avoid #ifdefs in the code below.
|
||||
* These should optimize out of the if conditions below. */
|
||||
#define header_threshhold 1
|
||||
#define count_bytes 0
|
||||
#endif
|
||||
}
|
||||
if (negative_N) {
|
||||
if (count >= INT_MAX / sizeof(char*))
|
||||
bb_error_msg("count is too big: %lu", count);
|
||||
}
|
||||
|
||||
do {
|
||||
fp = fopen_or_warn_stdin(*argv);
|
||||
@@ -133,18 +234,20 @@ int head_main(int argc, char **argv)
|
||||
if (header_threshhold) {
|
||||
printf(fmt, *argv);
|
||||
}
|
||||
i = count;
|
||||
while (i && ((c = getc(fp)) != EOF)) {
|
||||
if (count_bytes || (c == '\n')) {
|
||||
--i;
|
||||
if (negative_N) {
|
||||
if (count_bytes) {
|
||||
print_except_N_last_bytes(fp, count);
|
||||
} else {
|
||||
print_except_N_last_lines(fp, count);
|
||||
}
|
||||
putchar(c);
|
||||
} else {
|
||||
print_first_N(fp, count, count_bytes);
|
||||
}
|
||||
die_if_ferror_stdout();
|
||||
if (fclose_if_not_stdin(fp)) {
|
||||
bb_simple_perror_msg(*argv);
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
die_if_ferror_stdout();
|
||||
} else {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
+2
-1
@@ -36,7 +36,8 @@ int hostid_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
printf("%08lx\n", gethostid());
|
||||
/* POSIX says gethostid returns a "32-bit identifier" */
|
||||
printf("%08x\n", (unsigned)(uint32_t)gethostid());
|
||||
|
||||
return fflush_all();
|
||||
}
|
||||
+2
-4
@@ -64,12 +64,10 @@
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
#if !ENABLE_USE_BB_PWD_GRP
|
||||
#if defined(__UCLIBC_MAJOR__) && (__UCLIBC_MAJOR__ == 0)
|
||||
#if (__UCLIBC_MINOR__ < 9) || (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 30)
|
||||
#if defined(__UCLIBC__) && UCLIBC_VERSION < KERNEL_VERSION(0, 9, 30)
|
||||
#error "Sorry, you need at least uClibc version 0.9.30 for id applet to build"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
enum {
|
||||
PRINT_REAL = (1 << 0),
|
||||
@@ -174,7 +172,7 @@ int id_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* Don't allow -n -r -nr -ug -rug -nug -rnug -uZ -gZ -GZ*/
|
||||
/* Don't allow more than one username */
|
||||
opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG"
|
||||
IF_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
|
||||
IF_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
|
||||
opt = getopt32(argv, "rnugG" IF_SELINUX("Z"));
|
||||
}
|
||||
|
||||
|
||||
+22
-6
@@ -20,6 +20,8 @@
|
||||
//usage: "\n -n Don't dereference symlinks - treat like normal file"
|
||||
//usage: "\n -b Make a backup of the target (if exists) before link operation"
|
||||
//usage: "\n -S suf Use suffix instead of ~ when making backup files"
|
||||
//usage: "\n -T 2nd arg must be a DIR"
|
||||
//usage: "\n -v Verbose"
|
||||
//usage:
|
||||
//usage:#define ln_example_usage
|
||||
//usage: "$ ln -s BusyBox /tmp/ls\n"
|
||||
@@ -31,11 +33,13 @@
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
#define LN_SYMLINK 1
|
||||
#define LN_FORCE 2
|
||||
#define LN_NODEREFERENCE 4
|
||||
#define LN_BACKUP 8
|
||||
#define LN_SUFFIX 16
|
||||
#define LN_SYMLINK (1 << 0)
|
||||
#define LN_FORCE (1 << 1)
|
||||
#define LN_NODEREFERENCE (1 << 2)
|
||||
#define LN_BACKUP (1 << 3)
|
||||
#define LN_SUFFIX (1 << 4)
|
||||
#define LN_VERBOSE (1 << 5)
|
||||
#define LN_LINKFILE (1 << 6)
|
||||
|
||||
int ln_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int ln_main(int argc, char **argv)
|
||||
@@ -50,10 +54,15 @@ int ln_main(int argc, char **argv)
|
||||
int (*link_func)(const char *, const char *);
|
||||
|
||||
opt_complementary = "-1"; /* min one arg */
|
||||
opts = getopt32(argv, "sfnbS:", &suffix);
|
||||
opts = getopt32(argv, "sfnbS:vT", &suffix);
|
||||
|
||||
last = argv[argc - 1];
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
|
||||
if ((opts & LN_LINKFILE) && argc > 2) {
|
||||
bb_error_msg_and_die("-T accepts 2 args max");
|
||||
}
|
||||
|
||||
if (!argv[1]) {
|
||||
/* "ln PATH/TO/FILE" -> "ln PATH/TO/FILE FILE" */
|
||||
@@ -72,6 +81,9 @@ int ln_main(int argc, char **argv)
|
||||
(opts & LN_NODEREFERENCE) ^ LN_NODEREFERENCE
|
||||
)
|
||||
) {
|
||||
if (opts & LN_LINKFILE) {
|
||||
bb_error_msg_and_die("'%s' is a directory", src);
|
||||
}
|
||||
src_name = xstrdup(*argv);
|
||||
src = concat_path_file(src, bb_get_last_path_component_strip(src_name));
|
||||
free(src_name);
|
||||
@@ -112,6 +124,10 @@ int ln_main(int argc, char **argv)
|
||||
link_func = symlink;
|
||||
}
|
||||
|
||||
if (opts & LN_VERBOSE) {
|
||||
printf("'%s' -> '%s'\n", src, *argv);
|
||||
}
|
||||
|
||||
if (link_func(*argv, src) != 0) {
|
||||
bb_simple_perror_msg(src);
|
||||
status = EXIT_FAILURE;
|
||||
|
||||
+2
-2
@@ -260,7 +260,7 @@ enum {
|
||||
|
||||
/* TODO: simple toggles may be stored as OPT_xxx bits instead */
|
||||
static const uint32_t opt_flags[] = {
|
||||
STYLE_COLUMNAR, /* C */
|
||||
STYLE_COLUMNAR, /* C */
|
||||
DISP_HIDDEN | DISP_DOT, /* a */
|
||||
DISP_NOLIST, /* d */
|
||||
LIST_INO, /* i */
|
||||
@@ -720,7 +720,7 @@ static struct dnode *my_stat(const char *fullname, const char *name, int force_f
|
||||
if ((option_mask32 & OPT_L) || force_follow) {
|
||||
#if ENABLE_SELINUX
|
||||
if (is_selinux_enabled()) {
|
||||
getfilecon(fullname, &cur->sid);
|
||||
getfilecon(fullname, &cur->sid);
|
||||
}
|
||||
#endif
|
||||
if (stat(fullname, &statbuf)) {
|
||||
|
||||
@@ -55,6 +55,16 @@
|
||||
//usage: "\n -s Don't output anything, status code shows success"
|
||||
//usage: "\n -w Warn about improperly formatted checksum lines"
|
||||
//usage: )
|
||||
//usage:
|
||||
//usage:#define sha3sum_trivial_usage
|
||||
//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK("[-c[sw]] ")"[FILE]..."
|
||||
//usage:#define sha3sum_full_usage "\n\n"
|
||||
//usage: "Print" IF_FEATURE_MD5_SHA1_SUM_CHECK(" or check") " SHA3-512 checksums"
|
||||
//usage: IF_FEATURE_MD5_SHA1_SUM_CHECK( "\n"
|
||||
//usage: "\n -c Check sums against list in FILEs"
|
||||
//usage: "\n -s Don't output anything, status code shows success"
|
||||
//usage: "\n -w Warn about improperly formatted checksum lines"
|
||||
//usage: )
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
@@ -65,6 +75,7 @@ enum {
|
||||
HASH_MD5 = 's', /* "md5>s<um" */
|
||||
HASH_SHA1 = '1',
|
||||
HASH_SHA256 = '2',
|
||||
HASH_SHA3 = '3',
|
||||
HASH_SHA512 = '5',
|
||||
};
|
||||
|
||||
@@ -86,6 +97,7 @@ static uint8_t *hash_file(const char *filename)
|
||||
{
|
||||
int src_fd, hash_len, count;
|
||||
union _ctx_ {
|
||||
sha3_ctx_t sha3;
|
||||
sha512_ctx_t sha512;
|
||||
sha256_ctx_t sha256;
|
||||
sha1_ctx_t sha1;
|
||||
@@ -124,6 +136,11 @@ static uint8_t *hash_file(const char *filename)
|
||||
update = (void*)sha512_hash;
|
||||
final = (void*)sha512_end;
|
||||
hash_len = 64;
|
||||
} else if (ENABLE_SHA3SUM && hash_algo == HASH_SHA3) {
|
||||
sha3_begin(&context.sha3);
|
||||
update = (void*)sha3_hash;
|
||||
final = (void*)sha3_end;
|
||||
hash_len = 64;
|
||||
} else {
|
||||
xfunc_die(); /* can't reach this */
|
||||
}
|
||||
@@ -134,7 +151,9 @@ static uint8_t *hash_file(const char *filename)
|
||||
update(&context, in_buf, count);
|
||||
}
|
||||
hash_value = NULL;
|
||||
if (count == 0) {
|
||||
if (count < 0)
|
||||
bb_perror_msg("can't read '%s'", filename);
|
||||
else /* count == 0 */ {
|
||||
final(&context, in_buf);
|
||||
hash_value = hash_bin_to_hex(in_buf, hash_len);
|
||||
}
|
||||
@@ -223,7 +242,7 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
if (count_failed && !(flags & FLAG_SILENT)) {
|
||||
bb_error_msg("WARNING: %d of %d computed checksums did NOT match",
|
||||
count_failed, count_total);
|
||||
count_failed, count_total);
|
||||
}
|
||||
fclose_if_not_stdin(pre_computed_stream);
|
||||
} else {
|
||||
|
||||
+2
-1
@@ -48,6 +48,7 @@ static const char mkdir_longopts[] ALIGN1 =
|
||||
#if ENABLE_SELINUX
|
||||
"context\0" Required_argument "Z"
|
||||
#endif
|
||||
"verbose\0" No_argument "v"
|
||||
;
|
||||
#endif
|
||||
|
||||
@@ -66,7 +67,7 @@ int mkdir_main(int argc UNUSED_PARAM, char **argv)
|
||||
#if ENABLE_FEATURE_MKDIR_LONG_OPTIONS
|
||||
applet_long_options = mkdir_longopts;
|
||||
#endif
|
||||
opt = getopt32(argv, "m:p" IF_SELINUX("Z:"), &smode IF_SELINUX(,&scontext));
|
||||
opt = getopt32(argv, "m:p" IF_SELINUX("Z:") "v", &smode IF_SELINUX(,&scontext));
|
||||
if (opt & 1) {
|
||||
mode_t mmode = 0777;
|
||||
if (!bb_parse_mode(smode, &mmode)) {
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ int mknod_main(int argc, char **argv)
|
||||
/* Autodetect what the system supports; these macros should
|
||||
* optimize out to two constants. */
|
||||
dev = makedev(xatoul_range(argv[2], 0, major(UINT_MAX)),
|
||||
xatoul_range(argv[3], 0, minor(UINT_MAX)));
|
||||
xatoul_range(argv[3], 0, minor(UINT_MAX)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-8
@@ -33,12 +33,13 @@ static const char mv_longopts[] ALIGN1 =
|
||||
"interactive\0" No_argument "i"
|
||||
"force\0" No_argument "f"
|
||||
"no-clobber\0" No_argument "n"
|
||||
"verbose\0" No_argument "v"
|
||||
;
|
||||
#endif
|
||||
|
||||
#define OPT_FILEUTILS_FORCE 1
|
||||
#define OPT_FILEUTILS_INTERACTIVE 2
|
||||
#define OPT_FILEUTILS_NOCLOBBER 4
|
||||
#define OPT_FORCE (1 << 0)
|
||||
#define OPT_INTERACTIVE (1 << 1)
|
||||
#define OPT_NOCLOBBER (1 << 2)
|
||||
|
||||
int mv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int mv_main(int argc, char **argv)
|
||||
@@ -56,9 +57,11 @@ int mv_main(int argc, char **argv)
|
||||
#endif
|
||||
/* Need at least two arguments.
|
||||
* If more than one of -f, -i, -n is specified , only the final one
|
||||
* takes effect (it unsets previous options). */
|
||||
* takes effect (it unsets previous options).
|
||||
* -v is accepted but ignored.
|
||||
*/
|
||||
opt_complementary = "-2:f-in:i-fn:n-fi";
|
||||
flags = getopt32(argv, "fin");
|
||||
flags = getopt32(argv, "finv");
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
last = argv[argc - 1];
|
||||
@@ -84,11 +87,11 @@ int mv_main(int argc, char **argv)
|
||||
|
||||
DO_MOVE:
|
||||
if (dest_exists) {
|
||||
if (flags & OPT_FILEUTILS_NOCLOBBER)
|
||||
if (flags & OPT_NOCLOBBER)
|
||||
goto RET_0;
|
||||
if (!(flags & OPT_FILEUTILS_FORCE)
|
||||
if (!(flags & OPT_FORCE)
|
||||
&& ((access(dest, W_OK) < 0 && isatty(0))
|
||||
|| (flags & OPT_FILEUTILS_INTERACTIVE))
|
||||
|| (flags & OPT_INTERACTIVE))
|
||||
) {
|
||||
if (fprintf(stderr, "mv: overwrite '%s'? ", dest) < 0) {
|
||||
goto RET_1; /* Ouch! fprintf failed! */
|
||||
|
||||
+6
-12
@@ -25,7 +25,7 @@
|
||||
|
||||
//usage:#if ENABLE_DESKTOP
|
||||
//usage:#define od_trivial_usage
|
||||
//usage: "[-abcdfhilovxs] [-t TYPE] [-A RADIX] [-N SIZE] [-j SKIP] [-S MINSTR] [-w WIDTH] [FILE...]"
|
||||
//usage: "[-abcdfhilovxs] [-t TYPE] [-A RADIX] [-N SIZE] [-j SKIP] [-S MINSTR] [-w WIDTH] [FILE]..."
|
||||
// We don't support:
|
||||
// ... [FILE] [[+]OFFSET[.][b]]
|
||||
// Support is buggy for:
|
||||
@@ -1021,12 +1021,12 @@ dump(off_t current_offset, off_t end_offset)
|
||||
l_c_m = get_lcm();
|
||||
|
||||
/* Make bytes_to_write the smallest multiple of l_c_m that
|
||||
is at least as large as n_bytes_read. */
|
||||
is at least as large as n_bytes_read. */
|
||||
bytes_to_write = l_c_m * ((n_bytes_read + l_c_m - 1) / l_c_m);
|
||||
|
||||
memset(block[idx] + n_bytes_read, 0, bytes_to_write - n_bytes_read);
|
||||
write_block(current_offset, bytes_to_write,
|
||||
block[idx ^ 1], block[idx]);
|
||||
block[idx ^ 1], block[idx]);
|
||||
current_offset += n_bytes_read;
|
||||
}
|
||||
|
||||
@@ -1166,12 +1166,6 @@ parse_old_offset(const char *s, off_t *offset)
|
||||
int od_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int od_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
static const struct suffix_mult bkm[] = {
|
||||
{ "b", 512 },
|
||||
{ "k", 1024 },
|
||||
{ "m", 1024*1024 },
|
||||
{ "", 0 }
|
||||
};
|
||||
#if ENABLE_LONG_OPTS
|
||||
static const char od_longopts[] ALIGN1 =
|
||||
"skip-bytes\0" Required_argument "j"
|
||||
@@ -1230,7 +1224,7 @@ int od_main(int argc UNUSED_PARAM, char **argv)
|
||||
address_pad_len_char = doxn_address_pad_len_char[pos];
|
||||
}
|
||||
if (opt & OPT_N) {
|
||||
max_bytes_to_format = xstrtooff_sfx(str_N, 0, bkm);
|
||||
max_bytes_to_format = xstrtooff_sfx(str_N, 0, bkm_suffixes);
|
||||
}
|
||||
if (opt & OPT_a) decode_format_string("a");
|
||||
if (opt & OPT_b) decode_format_string("oC");
|
||||
@@ -1239,7 +1233,7 @@ int od_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (opt & OPT_f) decode_format_string("fF");
|
||||
if (opt & OPT_h) decode_format_string("x2");
|
||||
if (opt & OPT_i) decode_format_string("d2");
|
||||
if (opt & OPT_j) n_bytes_to_skip = xstrtooff_sfx(str_j, 0, bkm);
|
||||
if (opt & OPT_j) n_bytes_to_skip = xstrtooff_sfx(str_j, 0, bkm_suffixes);
|
||||
if (opt & OPT_l) decode_format_string("d4");
|
||||
if (opt & OPT_o) decode_format_string("o2");
|
||||
while (lst_t) {
|
||||
@@ -1248,7 +1242,7 @@ int od_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (opt & OPT_x) decode_format_string("x2");
|
||||
if (opt & OPT_s) decode_format_string("d2");
|
||||
if (opt & OPT_S) {
|
||||
string_min = xstrtou_sfx(str_S, 0, bkm);
|
||||
string_min = xstrtou_sfx(str_S, 0, bkm_suffixes);
|
||||
}
|
||||
|
||||
// Bloat:
|
||||
|
||||
@@ -39,7 +39,10 @@
|
||||
* -q, --quiet, -s, --silent suppress most error messages
|
||||
* -v, --verbose report error messages
|
||||
*
|
||||
* bbox supports: -f -n -v (fully), -q -s (accepts but ignores)
|
||||
* bbox supports: -f (partially) -n -v (fully), -q -s (accepts but ignores)
|
||||
* Note: we export the -f flag, but our -f behaves like coreutils' -e.
|
||||
* Unfortunately, there isn't a C lib function we can leverage to get this
|
||||
* behavior which means we'd have to implement the full stack ourselves :(.
|
||||
*/
|
||||
|
||||
int readlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
|
||||
+5
-3
@@ -30,8 +30,9 @@
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
|
||||
#define PARENTS 0x01
|
||||
#define IGNORE_NON_EMPTY 0x02
|
||||
#define PARENTS (1 << 0)
|
||||
//efine VERBOSE (1 << 1) //accepted but ignored
|
||||
#define IGNORE_NON_EMPTY (1 << 2)
|
||||
|
||||
int rmdir_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int rmdir_main(int argc UNUSED_PARAM, char **argv)
|
||||
@@ -43,13 +44,14 @@ int rmdir_main(int argc UNUSED_PARAM, char **argv)
|
||||
#if ENABLE_FEATURE_RMDIR_LONG_OPTIONS
|
||||
static const char rmdir_longopts[] ALIGN1 =
|
||||
"parents\0" No_argument "p"
|
||||
"verbose\0" No_argument "v"
|
||||
/* Debian etch: many packages fail to be purged or installed
|
||||
* because they desperately want this option: */
|
||||
"ignore-fail-on-non-empty\0" No_argument "\xff"
|
||||
;
|
||||
applet_long_options = rmdir_longopts;
|
||||
#endif
|
||||
flags = getopt32(argv, "p");
|
||||
flags = getopt32(argv, "pv");
|
||||
argv += optind;
|
||||
|
||||
if (!*argv) {
|
||||
|
||||
+1
-1
@@ -219,7 +219,7 @@ static int compare_keys(const void *xarg, const void *yarg)
|
||||
y = get_key(*(char **)yarg, key, flags);
|
||||
#else
|
||||
/* This curly bracket serves no purpose but to match the nesting
|
||||
level of the for () loop we're not using */
|
||||
* level of the for () loop we're not using */
|
||||
{
|
||||
x = *(char **)xarg;
|
||||
y = *(char **)yarg;
|
||||
|
||||
+6
-5
@@ -23,17 +23,15 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
static const struct suffix_mult split_suffices[] = {
|
||||
#if ENABLE_FEATURE_SPLIT_FANCY
|
||||
static const struct suffix_mult split_suffixes[] = {
|
||||
{ "b", 512 },
|
||||
#endif
|
||||
{ "k", 1024 },
|
||||
{ "m", 1024*1024 },
|
||||
#if ENABLE_FEATURE_SPLIT_FANCY
|
||||
{ "g", 1024*1024*1024 },
|
||||
#endif
|
||||
{ "", 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Increment the suffix part of the filename.
|
||||
* Returns NULL if we are out of filenames.
|
||||
@@ -86,7 +84,10 @@ int split_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (opt & SPLIT_OPT_l)
|
||||
cnt = XATOOFF(count_p);
|
||||
if (opt & SPLIT_OPT_b) // FIXME: also needs XATOOFF
|
||||
cnt = xatoull_sfx(count_p, split_suffices);
|
||||
cnt = xatoull_sfx(count_p,
|
||||
IF_FEATURE_SPLIT_FANCY(split_suffixes)
|
||||
IF_NOT_FEATURE_SPLIT_FANCY(km_suffixes)
|
||||
);
|
||||
sfx = "x";
|
||||
|
||||
argv += optind;
|
||||
|
||||
+41
-29
@@ -99,9 +99,15 @@ static const char *file_type(const struct stat *st)
|
||||
if (S_ISFIFO(st->st_mode)) return "fifo";
|
||||
if (S_ISLNK(st->st_mode)) return "symbolic link";
|
||||
if (S_ISSOCK(st->st_mode)) return "socket";
|
||||
#ifdef S_TYPEISMQ
|
||||
if (S_TYPEISMQ(st)) return "message queue";
|
||||
#endif
|
||||
#ifdef S_TYPEISSEM
|
||||
if (S_TYPEISSEM(st)) return "semaphore";
|
||||
#endif
|
||||
#ifdef S_TYPEISSHM
|
||||
if (S_TYPEISSHM(st)) return "shared memory object";
|
||||
#endif
|
||||
#ifdef S_TYPEISTMO
|
||||
if (S_TYPEISTMO(st)) return "typed memory object";
|
||||
#endif
|
||||
@@ -121,7 +127,7 @@ static const char *human_time(time_t t)
|
||||
/*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/
|
||||
#define buf bb_common_bufsiz1
|
||||
|
||||
strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S.000000000", localtime(&t));
|
||||
strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof(buf), &t), ".000000000");
|
||||
return buf;
|
||||
#undef buf
|
||||
}
|
||||
@@ -436,7 +442,7 @@ static bool do_statfs(const char *filename, const char *format)
|
||||
: getfilecon(filename, &scontext)
|
||||
) < 0
|
||||
) {
|
||||
bb_perror_msg(filename);
|
||||
bb_simple_perror_msg(filename);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -549,7 +555,7 @@ static bool do_stat(const char *filename, const char *format)
|
||||
: getfilecon(filename, &scontext)
|
||||
) < 0
|
||||
) {
|
||||
bb_perror_msg(filename);
|
||||
bb_simple_perror_msg(filename);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -585,37 +591,43 @@ static bool do_stat(const char *filename, const char *format)
|
||||
# else
|
||||
if (option_mask32 & OPT_TERSE) {
|
||||
format = (option_mask32 & OPT_SELINUX ?
|
||||
"%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o %C\n":
|
||||
"%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o\n");
|
||||
"%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o %C\n"
|
||||
:
|
||||
"%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o\n"
|
||||
);
|
||||
} else {
|
||||
if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode)) {
|
||||
format = (option_mask32 & OPT_SELINUX ?
|
||||
" File: %N\n"
|
||||
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
||||
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
|
||||
" Device type: %t,%T\n"
|
||||
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
||||
" S_Context: %C\n"
|
||||
"Access: %x\n" "Modify: %y\n" "Change: %z\n":
|
||||
" File: %N\n"
|
||||
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
||||
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
|
||||
" Device type: %t,%T\n"
|
||||
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
||||
"Access: %x\n" "Modify: %y\n" "Change: %z\n");
|
||||
" File: %N\n"
|
||||
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
||||
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
|
||||
" Device type: %t,%T\n"
|
||||
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
||||
" S_Context: %C\n"
|
||||
"Access: %x\n" "Modify: %y\n" "Change: %z\n"
|
||||
:
|
||||
" File: %N\n"
|
||||
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
||||
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
|
||||
" Device type: %t,%T\n"
|
||||
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
||||
"Access: %x\n" "Modify: %y\n" "Change: %z\n"
|
||||
);
|
||||
} else {
|
||||
format = (option_mask32 & OPT_SELINUX ?
|
||||
" File: %N\n"
|
||||
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
||||
"Device: %Dh/%dd\tInode: %-10i Links: %h\n"
|
||||
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
||||
"S_Context: %C\n"
|
||||
"Access: %x\n" "Modify: %y\n" "Change: %z\n":
|
||||
" File: %N\n"
|
||||
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
||||
"Device: %Dh/%dd\tInode: %-10i Links: %h\n"
|
||||
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
||||
"Access: %x\n" "Modify: %y\n" "Change: %z\n");
|
||||
" File: %N\n"
|
||||
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
||||
"Device: %Dh/%dd\tInode: %-10i Links: %h\n"
|
||||
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
||||
"S_Context: %C\n"
|
||||
"Access: %x\n" "Modify: %y\n" "Change: %z\n"
|
||||
:
|
||||
" File: %N\n"
|
||||
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
||||
"Device: %Dh/%dd\tInode: %-10i Links: %h\n"
|
||||
"Access: (%04a/%10.10A) Uid: (%5u/%8U) Gid: (%5g/%8G)\n"
|
||||
"Access: %x\n" "Modify: %y\n" "Change: %z\n"
|
||||
);
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
+42
-63
@@ -246,10 +246,21 @@ enum speed_setting {
|
||||
|
||||
/* Which member(s) of 'struct termios' a mode uses */
|
||||
enum {
|
||||
/* Do NOT change the order or values, as mode_type_flag()
|
||||
* depends on them */
|
||||
control, input, output, local, combination
|
||||
};
|
||||
static tcflag_t *get_ptr_to_tcflag(unsigned type, const struct termios *mode)
|
||||
{
|
||||
static const uint8_t tcflag_offsets[] ALIGN1 = {
|
||||
offsetof(struct termios, c_cflag), /* control */
|
||||
offsetof(struct termios, c_iflag), /* input */
|
||||
offsetof(struct termios, c_oflag), /* output */
|
||||
offsetof(struct termios, c_lflag) /* local */
|
||||
};
|
||||
if (type <= local) {
|
||||
return (tcflag_t*) (((char*)mode) + tcflag_offsets[type]);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Flags for 'struct mode_info' */
|
||||
#define SANE_SET 1 /* Set in 'sane' mode */
|
||||
@@ -770,51 +781,6 @@ struct globals {
|
||||
G.max_col = 80; \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Return a string that is the printable representation of character CH */
|
||||
/* Adapted from 'cat' by Torbjorn Granlund */
|
||||
static const char *visible(unsigned ch)
|
||||
{
|
||||
char *bpout = G.buf;
|
||||
|
||||
if (ch == _POSIX_VDISABLE)
|
||||
return "<undef>";
|
||||
|
||||
if (ch >= 128) {
|
||||
ch -= 128;
|
||||
*bpout++ = 'M';
|
||||
*bpout++ = '-';
|
||||
}
|
||||
|
||||
if (ch < 32) {
|
||||
*bpout++ = '^';
|
||||
*bpout++ = ch + 64;
|
||||
} else if (ch < 127) {
|
||||
*bpout++ = ch;
|
||||
} else {
|
||||
*bpout++ = '^';
|
||||
*bpout++ = '?';
|
||||
}
|
||||
|
||||
*bpout = '\0';
|
||||
return G.buf;
|
||||
}
|
||||
|
||||
static tcflag_t *mode_type_flag(unsigned type, const struct termios *mode)
|
||||
{
|
||||
static const uint8_t tcflag_offsets[] ALIGN1 = {
|
||||
offsetof(struct termios, c_cflag), /* control */
|
||||
offsetof(struct termios, c_iflag), /* input */
|
||||
offsetof(struct termios, c_oflag), /* output */
|
||||
offsetof(struct termios, c_lflag) /* local */
|
||||
};
|
||||
|
||||
if (type <= local) {
|
||||
return (tcflag_t*) (((char*)mode) + tcflag_offsets[type]);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void set_speed_or_die(enum speed_setting type, const char *arg,
|
||||
struct termios *mode)
|
||||
{
|
||||
@@ -1042,6 +1008,7 @@ static void do_display(const struct termios *mode, int all)
|
||||
#endif
|
||||
|
||||
for (i = 0; i != CIDX_min; ++i) {
|
||||
char ch;
|
||||
/* If swtch is the same as susp, don't print both */
|
||||
#if VSWTCH == VSUSP
|
||||
if (i == CIDX_swtch)
|
||||
@@ -1055,8 +1022,12 @@ static void do_display(const struct termios *mode, int all)
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
wrapf("%s = %s;", nth_string(control_name, i),
|
||||
visible(mode->c_cc[control_info[i].offset]));
|
||||
ch = mode->c_cc[control_info[i].offset];
|
||||
if (ch == _POSIX_VDISABLE)
|
||||
strcpy(G.buf, "<undef>");
|
||||
else
|
||||
visible(ch, G.buf, 0);
|
||||
wrapf("%s = %s;", nth_string(control_name, i), G.buf);
|
||||
}
|
||||
#if VEOF == VMIN
|
||||
if ((mode->c_lflag & ICANON) == 0)
|
||||
@@ -1072,7 +1043,7 @@ static void do_display(const struct termios *mode, int all)
|
||||
prev_type = mode_info[i].type;
|
||||
}
|
||||
|
||||
bitsp = mode_type_flag(mode_info[i].type, mode);
|
||||
bitsp = get_ptr_to_tcflag(mode_info[i].type, mode);
|
||||
mask = mode_info[i].mask ? mode_info[i].mask : mode_info[i].bits;
|
||||
if ((*bitsp & mask) == mode_info[i].bits) {
|
||||
if (all || (mode_info[i].flags & SANE_UNSET))
|
||||
@@ -1091,7 +1062,6 @@ static void do_display(const struct termios *mode, int all)
|
||||
static void sane_mode(struct termios *mode)
|
||||
{
|
||||
int i;
|
||||
tcflag_t *bitsp;
|
||||
|
||||
for (i = 0; i < NUM_control_info; ++i) {
|
||||
#if VMIN == VEOF
|
||||
@@ -1102,14 +1072,17 @@ static void sane_mode(struct termios *mode)
|
||||
}
|
||||
|
||||
for (i = 0; i < NUM_mode_info; ++i) {
|
||||
tcflag_t val;
|
||||
tcflag_t *bitsp = get_ptr_to_tcflag(mode_info[i].type, mode);
|
||||
|
||||
if (!bitsp)
|
||||
continue;
|
||||
val = *bitsp & ~((unsigned long)mode_info[i].mask);
|
||||
if (mode_info[i].flags & SANE_SET) {
|
||||
bitsp = mode_type_flag(mode_info[i].type, mode);
|
||||
*bitsp = (*bitsp & ~((unsigned long)mode_info[i].mask))
|
||||
| mode_info[i].bits;
|
||||
} else if (mode_info[i].flags & SANE_UNSET) {
|
||||
bitsp = mode_type_flag(mode_info[i].type, mode);
|
||||
*bitsp = *bitsp & ~((unsigned long)mode_info[i].mask)
|
||||
& ~mode_info[i].bits;
|
||||
*bitsp = val | mode_info[i].bits;
|
||||
} else
|
||||
if (mode_info[i].flags & SANE_UNSET) {
|
||||
*bitsp = val & ~mode_info[i].bits;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1119,17 +1092,18 @@ static void set_mode(const struct mode_info *info, int reversed,
|
||||
{
|
||||
tcflag_t *bitsp;
|
||||
|
||||
bitsp = mode_type_flag(info->type, mode);
|
||||
bitsp = get_ptr_to_tcflag(info->type, mode);
|
||||
|
||||
if (bitsp) {
|
||||
tcflag_t val = *bitsp & ~info->mask;
|
||||
if (reversed)
|
||||
*bitsp = *bitsp & ~info->mask & ~info->bits;
|
||||
*bitsp = val & ~info->bits;
|
||||
else
|
||||
*bitsp = (*bitsp & ~info->mask) | info->bits;
|
||||
*bitsp = val | info->bits;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Combination mode */
|
||||
/* !bitsp - it's a "combination" mode */
|
||||
if (info == &mode_info[IDX_evenp] || info == &mode_info[IDX_parity]) {
|
||||
if (reversed)
|
||||
mode->c_cflag = (mode->c_cflag & ~PARENB & ~CSIZE) | CS8;
|
||||
@@ -1534,7 +1508,12 @@ int stty_main(int argc UNUSED_PARAM, char **argv)
|
||||
perror_on_device_and_die("%s");
|
||||
|
||||
if (memcmp(&mode, &new_mode, sizeof(mode)) != 0) {
|
||||
#if CIBAUD
|
||||
/*
|
||||
* I think the below chunk is not necessary on Linux.
|
||||
* If you are deleting it, also delete STTY_speed_was_set bit -
|
||||
* it is only ever checked here.
|
||||
*/
|
||||
#if 0 /* was "if CIBAUD" */
|
||||
/* SunOS 4.1.3 (at least) has the problem that after this sequence,
|
||||
tcgetattr (&m1); tcsetattr (&m1); tcgetattr (&m2);
|
||||
sometimes (m1 != m2). The only difference is in the four bits
|
||||
|
||||
+4
-4
@@ -70,9 +70,9 @@ static unsigned sum_file(const char *file, unsigned type)
|
||||
if (type >= SUM_SYSV) {
|
||||
r = (s & 0xffff) + ((s & 0xffffffff) >> 16);
|
||||
s = (r & 0xffff) + (r >> 16);
|
||||
printf("%d %llu %s\n", s, (total_bytes + 511) / 512, file);
|
||||
printf("%u %llu %s\n", s, (total_bytes + 511) / 512, file);
|
||||
} else
|
||||
printf("%05d %5llu %s\n", s, (total_bytes + 1023) / 1024, file);
|
||||
printf("%05u %5llu %s\n", s, (total_bytes + 1023) / 1024, file);
|
||||
return 1;
|
||||
#undef buf
|
||||
}
|
||||
@@ -94,8 +94,8 @@ int sum_main(int argc UNUSED_PARAM, char **argv)
|
||||
n = sum_file("-", type);
|
||||
} else {
|
||||
/* Need to print the name if either
|
||||
- more than one file given
|
||||
- doing sysv */
|
||||
* - more than one file given
|
||||
* - doing sysv */
|
||||
type += (argv[1] || type == SUM_SYSV);
|
||||
n = 1;
|
||||
do {
|
||||
|
||||
+22
-22
@@ -24,6 +24,8 @@
|
||||
* 7) lseek attempted when count==0 even if arg was +0 (from top)
|
||||
*/
|
||||
|
||||
//kbuild:lib-$(CONFIG_TAIL) += tail.o
|
||||
|
||||
//usage:#define tail_trivial_usage
|
||||
//usage: "[OPTIONS] [FILE]..."
|
||||
//usage:#define tail_full_usage "\n\n"
|
||||
@@ -34,14 +36,13 @@
|
||||
//usage: "\n -s SECONDS Wait SECONDS between reads with -f"
|
||||
//usage: )
|
||||
//usage: "\n -n N[kbm] Print last N lines"
|
||||
//usage: "\n -n +N[kbm] Start on Nth line and print the rest"
|
||||
//usage: IF_FEATURE_FANCY_TAIL(
|
||||
//usage: "\n -c N[kbm] Print last N bytes"
|
||||
//usage: "\n -c [+]N[kbm] Print last N bytes"
|
||||
//usage: "\n -q Never print headers"
|
||||
//usage: "\n -v Always print headers"
|
||||
//usage: "\n"
|
||||
//usage: "\nN may be suffixed by k (x1024), b (x512), or m (x1024^2)."
|
||||
//usage: "\nIf N starts with a '+', output begins with the Nth item from the start"
|
||||
//usage: "\nof each file, not from the end."
|
||||
//usage: )
|
||||
//usage:
|
||||
//usage:#define tail_example_usage
|
||||
@@ -50,13 +51,6 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
static const struct suffix_mult tail_suffixes[] = {
|
||||
{ "b", 512 },
|
||||
{ "k", 1024 },
|
||||
{ "m", 1024*1024 },
|
||||
{ "", 0 }
|
||||
};
|
||||
|
||||
struct globals {
|
||||
bool from_top;
|
||||
bool exitcode;
|
||||
@@ -73,15 +67,6 @@ static void tail_xprint_header(const char *fmt, const char *filename)
|
||||
static ssize_t tail_read(int fd, char *buf, size_t count)
|
||||
{
|
||||
ssize_t r;
|
||||
off_t current;
|
||||
struct stat sbuf;
|
||||
|
||||
/* /proc files report zero st_size, don't lseek them. */
|
||||
if (fstat(fd, &sbuf) == 0 && sbuf.st_size > 0) {
|
||||
current = lseek(fd, 0, SEEK_CUR);
|
||||
if (sbuf.st_size < current)
|
||||
xlseek(fd, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
r = full_read(fd, buf, count);
|
||||
if (r < 0) {
|
||||
@@ -102,7 +87,7 @@ static unsigned eat_num(const char *p)
|
||||
p++;
|
||||
G.from_top = 1;
|
||||
}
|
||||
return xatou_sfx(p, tail_suffixes);
|
||||
return xatou_sfx(p, bkm_suffixes);
|
||||
}
|
||||
|
||||
int tail_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
@@ -120,6 +105,7 @@ int tail_main(int argc, char **argv)
|
||||
|
||||
int *fds;
|
||||
const char *fmt;
|
||||
int prev_fd;
|
||||
|
||||
INIT_G();
|
||||
|
||||
@@ -324,6 +310,7 @@ int tail_main(int argc, char **argv)
|
||||
xwrite(STDOUT_FILENO, tailbuf, taillen);
|
||||
}
|
||||
} while (++i < nfiles);
|
||||
prev_fd = fds[i-1];
|
||||
|
||||
tailbuf = xrealloc(tailbuf, BUFSIZ);
|
||||
|
||||
@@ -367,10 +354,23 @@ int tail_main(int argc, char **argv)
|
||||
if (nfiles > header_threshhold) {
|
||||
fmt = header_fmt_str;
|
||||
}
|
||||
while ((nread = tail_read(fd, tailbuf, BUFSIZ)) > 0) {
|
||||
if (fmt) {
|
||||
for (;;) {
|
||||
/* tail -f keeps following files even if they are truncated */
|
||||
struct stat sbuf;
|
||||
/* /proc files report zero st_size, don't lseek them */
|
||||
if (fstat(fd, &sbuf) == 0 && sbuf.st_size > 0) {
|
||||
off_t current = lseek(fd, 0, SEEK_CUR);
|
||||
if (sbuf.st_size < current)
|
||||
xlseek(fd, 0, SEEK_SET);
|
||||
}
|
||||
|
||||
nread = tail_read(fd, tailbuf, BUFSIZ);
|
||||
if (nread <= 0)
|
||||
break;
|
||||
if (fmt && (fd != prev_fd)) {
|
||||
tail_xprint_header(fmt, filename);
|
||||
fmt = NULL;
|
||||
prev_fd = fd;
|
||||
}
|
||||
xwrite(STDOUT_FILENO, tailbuf, nread);
|
||||
}
|
||||
|
||||
+1
-1
@@ -610,7 +610,7 @@ static int test_eaccess(char *path, int mode)
|
||||
return 0;
|
||||
|
||||
/* Root can execute any file that has any one of the execute
|
||||
bits set. */
|
||||
* bits set. */
|
||||
if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
|
||||
return 0;
|
||||
}
|
||||
|
||||
+35
-4
@@ -26,6 +26,14 @@
|
||||
//config: touch is used to create or change the access and/or
|
||||
//config: modification timestamp of specified files.
|
||||
//config:
|
||||
//config:config FEATURE_TOUCH_NODEREF
|
||||
//config: bool "Add support for -h"
|
||||
//config: default y
|
||||
//config: depends on TOUCH
|
||||
//config: help
|
||||
//config: Enable touch to have the -h option.
|
||||
//config: This requires libc support for lutimes() function.
|
||||
//config:
|
||||
//config:config FEATURE_TOUCH_SUSV3
|
||||
//config: bool "Add support for SUSV3 features (-d -t -r)"
|
||||
//config: default y
|
||||
@@ -42,6 +50,9 @@
|
||||
//usage:#define touch_full_usage "\n\n"
|
||||
//usage: "Update the last-modified date on the given FILE[s]\n"
|
||||
//usage: "\n -c Don't create files"
|
||||
//usage: IF_FEATURE_TOUCH_NODEREF(
|
||||
//usage: "\n -h Don't follow links"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_TOUCH_SUSV3(
|
||||
//usage: "\n -d DT Date/time to use"
|
||||
//usage: "\n -t DT Date/time to use"
|
||||
@@ -65,6 +76,7 @@
|
||||
* parse STRING and use it instead of current time
|
||||
* -f (ignored, BSD compat)
|
||||
* -m change only the modification time
|
||||
* -h, --no-dereference
|
||||
* -r, --reference=FILE
|
||||
* use this file's times instead of current time
|
||||
* -t STAMP
|
||||
@@ -79,6 +91,13 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
||||
int fd;
|
||||
int status = EXIT_SUCCESS;
|
||||
int opts;
|
||||
enum {
|
||||
OPT_c = (1 << 0),
|
||||
OPT_r = (1 << 1) * ENABLE_FEATURE_TOUCH_SUSV3,
|
||||
OPT_d = (1 << 2) * ENABLE_FEATURE_TOUCH_SUSV3,
|
||||
OPT_t = (1 << 3) * ENABLE_FEATURE_TOUCH_SUSV3,
|
||||
OPT_h = (1 << 4) * ENABLE_FEATURE_TOUCH_NODEREF,
|
||||
};
|
||||
#if ENABLE_FEATURE_TOUCH_SUSV3
|
||||
# if ENABLE_LONG_OPTS
|
||||
static const char touch_longopts[] ALIGN1 =
|
||||
@@ -86,6 +105,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
||||
"no-create\0" No_argument "c"
|
||||
"reference\0" Required_argument "r"
|
||||
"date\0" Required_argument "d"
|
||||
IF_FEATURE_TOUCH_NODEREF("no-dereference\0" No_argument "h")
|
||||
;
|
||||
# endif
|
||||
char *reference_file = NULL;
|
||||
@@ -105,13 +125,13 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
||||
* accepted data format differs a bit between -d and -t.
|
||||
* We accept the same formats for both */
|
||||
opts = getopt32(argv, "c" IF_FEATURE_TOUCH_SUSV3("r:d:t:")
|
||||
IF_FEATURE_TOUCH_NODEREF("h")
|
||||
/*ignored:*/ "fma"
|
||||
IF_FEATURE_TOUCH_SUSV3(, &reference_file)
|
||||
IF_FEATURE_TOUCH_SUSV3(, &date_str)
|
||||
IF_FEATURE_TOUCH_SUSV3(, &date_str)
|
||||
);
|
||||
|
||||
opts &= 1; /* only -c bit is left */
|
||||
argv += optind;
|
||||
if (!*argv) {
|
||||
bb_show_usage();
|
||||
@@ -121,6 +141,10 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
||||
struct stat stbuf;
|
||||
xstat(reference_file, &stbuf);
|
||||
timebuf[1].tv_sec = timebuf[0].tv_sec = stbuf.st_mtime;
|
||||
/* Can use .st_mtim.tv_nsec
|
||||
* (or is it .st_mtimensec?? see date.c)
|
||||
* to set microseconds too.
|
||||
*/
|
||||
}
|
||||
|
||||
if (date_str) {
|
||||
@@ -141,9 +165,16 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
|
||||
do {
|
||||
if (utimes(*argv, (reference_file || date_str) ? timebuf : NULL) != 0) {
|
||||
if (errno == ENOENT) { /* no such file */
|
||||
if (opts) { /* creation is disabled, so ignore */
|
||||
int result;
|
||||
result = (
|
||||
#if ENABLE_FEATURE_TOUCH_NODEREF
|
||||
(opts & OPT_h) ? lutimes :
|
||||
#endif
|
||||
utimes)(*argv, (reference_file || date_str) ? timebuf : NULL);
|
||||
if (result != 0) {
|
||||
if (errno == ENOENT) { /* no such file? */
|
||||
if (opts & OPT_c) {
|
||||
/* Creation is disabled, so ignore */
|
||||
continue;
|
||||
}
|
||||
/* Try to create the file */
|
||||
|
||||
+19
-21
@@ -38,7 +38,7 @@
|
||||
//usage: "TEMPLATE must end with XXXXXX (e.g. [/dir/]nameXXXXXX).\n"
|
||||
//usage: "Without TEMPLATE, -t tmp.XXXXXX is assumed.\n"
|
||||
//usage: "\n -d Make directory, not file"
|
||||
////usage: "\n -q Fail silently on errors" - we ignore this opt
|
||||
//usage: "\n -q Fail silently on errors"
|
||||
//usage: "\n -t Prepend base directory name to TEMPLATE"
|
||||
//usage: "\n -p DIR Use DIR as a base directory (implies -t)"
|
||||
//usage: "\n -u Do not create anything; print a name"
|
||||
@@ -71,7 +71,6 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (!path || path[0] == '\0')
|
||||
path = "/tmp";
|
||||
|
||||
/* -q is ignored */
|
||||
opt_complementary = "?1"; /* 1 argument max */
|
||||
opts = getopt32(argv, "dqtp:u", &path);
|
||||
|
||||
@@ -83,33 +82,32 @@ int mktemp_main(int argc UNUSED_PARAM, char **argv)
|
||||
chp = xstrdup("tmp.XXXXXX");
|
||||
opts |= OPT_t;
|
||||
}
|
||||
|
||||
if (opts & OPT_u) {
|
||||
/* Remove (up to) 6 X's */
|
||||
unsigned len = strlen(chp);
|
||||
int cnt = len > 6 ? 6 : len;
|
||||
while (--cnt >= 0 && chp[--len] == 'X')
|
||||
chp[len] = '\0';
|
||||
|
||||
chp = tempnam(opts & (OPT_t|OPT_p) ? path : "./", chp);
|
||||
if (!chp)
|
||||
return EXIT_FAILURE;
|
||||
if (!(opts & (OPT_t|OPT_p)))
|
||||
chp += 2;
|
||||
goto ret;
|
||||
#if 0
|
||||
/* Don't allow directory separator in template */
|
||||
if ((opts & OPT_t) && bb_basename(chp) != chp) {
|
||||
errno = EINVAL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (opts & (OPT_t|OPT_p))
|
||||
chp = concat_path_file(path, chp);
|
||||
|
||||
if (opts & OPT_d) {
|
||||
if (opts & OPT_u) {
|
||||
chp = mktemp(chp);
|
||||
if (chp[0] == '\0')
|
||||
goto error;
|
||||
} else if (opts & OPT_d) {
|
||||
if (mkdtemp(chp) == NULL)
|
||||
return EXIT_FAILURE;
|
||||
goto error;
|
||||
} else {
|
||||
if (mkstemp(chp) < 0)
|
||||
return EXIT_FAILURE;
|
||||
goto error;
|
||||
}
|
||||
ret:
|
||||
puts(chp);
|
||||
return EXIT_SUCCESS;
|
||||
error:
|
||||
if (opts & OPT_q)
|
||||
return EXIT_FAILURE;
|
||||
/* don't use chp as it gets mangled in case of error */
|
||||
bb_perror_nomsg_and_die();
|
||||
}
|
||||
+31
-32
@@ -4,14 +4,13 @@
|
||||
*
|
||||
* Copyright (C) 2007 Bernhard Reutner-Fischer
|
||||
*
|
||||
* Based on a older version that was in busybox which was 1k big..
|
||||
* Based on a older version that was in busybox which was 1k big.
|
||||
* Copyright (C) 2001 by Emanuele Aina <emanuele.aina@tiscali.it>
|
||||
*
|
||||
* Based on the Debian run-parts program, version 1.15
|
||||
* Copyright (C) 1996 Jeff Noxon <jeff@router.patch.net>,
|
||||
* Copyright (C) 1996-1999 Guy Maor <maor@debian.org>
|
||||
*
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
||||
*/
|
||||
|
||||
@@ -19,26 +18,26 @@
|
||||
* attempt to write a program! :-) . */
|
||||
|
||||
/* This piece of code is heavily based on the original version of run-parts,
|
||||
* taken from debian-utils. I've only removed the long options and a the
|
||||
* taken from debian-utils. I've only removed the long options and the
|
||||
* report mode. As the original run-parts support only long options, I've
|
||||
* broken compatibility because the BusyBox policy doesn't allow them.
|
||||
* The supported options are:
|
||||
* -t test. Print the name of the files to be executed, without
|
||||
* execute them.
|
||||
* -a ARG argument. Pass ARG as an argument the program executed. It can
|
||||
* be repeated to pass multiple arguments.
|
||||
* -u MASK umask. Set the umask of the program executed to MASK.
|
||||
*/
|
||||
|
||||
//usage:#define run_parts_trivial_usage
|
||||
//usage: "[-t] "IF_FEATURE_RUN_PARTS_FANCY("[-l] ")"[-a ARG] [-u MASK] DIRECTORY"
|
||||
//usage: "[-a ARG]... [-u UMASK] "
|
||||
//usage: IF_FEATURE_RUN_PARTS_LONG_OPTIONS("[--reverse] [--test] [--exit-on-error] "IF_FEATURE_RUN_PARTS_FANCY("[--list] "))
|
||||
//usage: "DIRECTORY"
|
||||
//usage:#define run_parts_full_usage "\n\n"
|
||||
//usage: "Run a bunch of scripts in DIRECTORY\n"
|
||||
//usage: "\n -t Print what would be run, but don't actually run anything"
|
||||
//usage: "\n -a ARG Pass ARG as argument for every program"
|
||||
//usage: "\n -u MASK Set the umask to MASK before running every program"
|
||||
//usage: "\n -a ARG Pass ARG as argument to scripts"
|
||||
//usage: "\n -u UMASK Set UMASK before running scripts"
|
||||
//usage: IF_FEATURE_RUN_PARTS_LONG_OPTIONS(
|
||||
//usage: "\n --reverse Reverse execution order"
|
||||
//usage: "\n --test Dry run"
|
||||
//usage: "\n --exit-on-error Exit if a script exits with non-zero"
|
||||
//usage: IF_FEATURE_RUN_PARTS_FANCY(
|
||||
//usage: "\n -l Print names of all matching files even if they are not executable"
|
||||
//usage: "\n --list Print names of matching files even if they are not executable"
|
||||
//usage: )
|
||||
//usage: )
|
||||
//usage:
|
||||
//usage:#define run_parts_example_usage
|
||||
@@ -60,7 +59,7 @@
|
||||
struct globals {
|
||||
char **names;
|
||||
int cur;
|
||||
char *cmd[1];
|
||||
char *cmd[2 /* using 1 provokes compiler warning */];
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define names (G.names)
|
||||
@@ -71,19 +70,15 @@ struct globals {
|
||||
enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 };
|
||||
|
||||
enum {
|
||||
OPT_r = (1 << 0),
|
||||
OPT_a = (1 << 1),
|
||||
OPT_u = (1 << 2),
|
||||
OPT_t = (1 << 3),
|
||||
OPT_l = (1 << 4) * ENABLE_FEATURE_RUN_PARTS_FANCY,
|
||||
OPT_a = (1 << 0),
|
||||
OPT_u = (1 << 1),
|
||||
OPT_r = (1 << 2) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS,
|
||||
OPT_t = (1 << 3) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS,
|
||||
OPT_e = (1 << 4) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS,
|
||||
OPT_l = (1 << 5) * ENABLE_FEATURE_RUN_PARTS_LONG_OPTIONS
|
||||
* ENABLE_FEATURE_RUN_PARTS_FANCY,
|
||||
};
|
||||
|
||||
#if ENABLE_FEATURE_RUN_PARTS_FANCY
|
||||
#define list_mode (option_mask32 & OPT_l)
|
||||
#else
|
||||
#define list_mode 0
|
||||
#endif
|
||||
|
||||
/* Is this a valid filename (upper/lower alpha, digits,
|
||||
* underscores, and hyphens only?)
|
||||
*/
|
||||
@@ -111,7 +106,7 @@ static int FAST_FUNC act(const char *file, struct stat *statbuf, void *args UNUS
|
||||
if (depth == 2
|
||||
&& ( !(statbuf->st_mode & (S_IFREG | S_IFLNK))
|
||||
|| invalid_name(file)
|
||||
|| (!list_mode && access(file, X_OK) != 0))
|
||||
|| (!(option_mask32 & OPT_l) && access(file, X_OK) != 0))
|
||||
) {
|
||||
return SKIP;
|
||||
}
|
||||
@@ -127,11 +122,12 @@ static int FAST_FUNC act(const char *file, struct stat *statbuf, void *args UNUS
|
||||
static const char runparts_longopts[] ALIGN1 =
|
||||
"arg\0" Required_argument "a"
|
||||
"umask\0" Required_argument "u"
|
||||
"test\0" No_argument "t"
|
||||
#if ENABLE_FEATURE_RUN_PARTS_FANCY
|
||||
"list\0" No_argument "l"
|
||||
"reverse\0" No_argument "r"
|
||||
//TODO: "verbose\0" No_argument "v"
|
||||
"reverse\0" No_argument "\xf0"
|
||||
"test\0" No_argument "\xf1"
|
||||
"exit-on-error\0" No_argument "\xf2"
|
||||
#if ENABLE_FEATURE_RUN_PARTS_FANCY
|
||||
"list\0" No_argument "\xf3"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
@@ -151,7 +147,7 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
|
||||
#endif
|
||||
/* We require exactly one argument: the directory name */
|
||||
opt_complementary = "=1:a::";
|
||||
getopt32(argv, "ra:u:t"IF_FEATURE_RUN_PARTS_FANCY("l"), &arg_list, &umask_p);
|
||||
getopt32(argv, "a:u:", &arg_list, &umask_p);
|
||||
|
||||
umask(xstrtou_range(umask_p, 8, 0, 07777));
|
||||
|
||||
@@ -194,6 +190,9 @@ int run_parts_main(int argc UNUSED_PARAM, char **argv)
|
||||
bb_perror_msg("can't execute '%s'", name);
|
||||
else /* ret > 0 */
|
||||
bb_error_msg("%s exited with code %d", name, ret & 0xff);
|
||||
|
||||
if (option_mask32 & OPT_e)
|
||||
xfunc_die();
|
||||
}
|
||||
|
||||
return n;
|
||||
|
||||
@@ -138,13 +138,6 @@ less readable, use #defines:
|
||||
#define sector (G.sector)
|
||||
|
||||
|
||||
Word of caution
|
||||
|
||||
If applet doesn't use much of global data, converting it to use
|
||||
one of above methods is not worth the resulting code obfuscation.
|
||||
If you have less than ~300 bytes of global data - don't bother.
|
||||
|
||||
|
||||
Finding non-shared duplicated strings
|
||||
|
||||
strings busybox | sort | uniq -c | sort -nr
|
||||
@@ -224,6 +217,14 @@ Result (non-static busybox built against glibc):
|
||||
|
||||
Keeping code small
|
||||
|
||||
Use scripts/bloat-o-meter to check whether introduced changes
|
||||
didn't generate unnecessary bloat. This script needs unstripped binaries
|
||||
to generate a detailed report. To automate this, just use
|
||||
"make bloatcheck". It requires busybox_old binary to be present,
|
||||
use "make baseline" to generate it from unmodified source, or
|
||||
copy busybox_unstripped to busybox_old before modifying sources
|
||||
and rebuilding.
|
||||
|
||||
Set CONFIG_EXTRA_CFLAGS="-fno-inline-functions-called-once",
|
||||
produce "make bloatcheck", see the biggest auto-inlined functions.
|
||||
Now, set CONFIG_EXTRA_CFLAGS back to "", but add NOINLINE
|
||||
|
||||
+2
-2
@@ -51,9 +51,9 @@ device nodes if your system needs something more than the default root/root
|
||||
660 permissions.
|
||||
|
||||
The file has the format:
|
||||
[-]<device regex> <uid>:<gid> <permissions>
|
||||
[-][envmatch]<device regex> <uid>:<gid> <permissions>
|
||||
or
|
||||
@<maj[,min1[-min2]]> <uid>:<gid> <permissions>
|
||||
[envmatch]@<maj[,min1[-min2]]> <uid>:<gid> <permissions>
|
||||
or
|
||||
$envvar=<regex> <uid>:<gid> <permissions>
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
Some less-widely known details of TCP connections.
|
||||
|
||||
Properly closing the connection.
|
||||
|
||||
After this code sequence:
|
||||
|
||||
sock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
connect(sock, &remote, sizeof(remote));
|
||||
write(sock, buffer, 1000000);
|
||||
|
||||
a large block of data is only buffered by kernel, it can't be sent all at once.
|
||||
What will happen if we close the socket?
|
||||
|
||||
"A host MAY implement a 'half-duplex' TCP close sequence, so that
|
||||
an application that has called close() cannot continue to read
|
||||
data from the connection. If such a host issues a close() call
|
||||
while received data is still pending in TCP, or if new data is
|
||||
received after close() is called, its TCP SHOULD send a RST
|
||||
to show that data was lost."
|
||||
|
||||
IOW: if we just close(sock) now, kernel can reset the TCP connection
|
||||
(send RST packet).
|
||||
|
||||
This is problematic for two reasons: it discards some not-yet sent
|
||||
data, and it may be reported as error, not EOF, on peer's side.
|
||||
|
||||
What can be done about it?
|
||||
|
||||
Solution #1: block until sending is done:
|
||||
|
||||
/* When enabled, a close(2) or shutdown(2) will not return until
|
||||
* all queued messages for the socket have been successfully sent
|
||||
* or the linger timeout has been reached.
|
||||
*/
|
||||
struct linger {
|
||||
int l_onoff; /* linger active */
|
||||
int l_linger; /* how many seconds to linger for */
|
||||
} linger;
|
||||
linger.l_onoff = 1;
|
||||
linger.l_linger = SOME_NUM;
|
||||
setsockopt(sock, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger));
|
||||
close(sock);
|
||||
|
||||
Solution #2: tell kernel that you are done sending.
|
||||
This makes kernel send FIN after all data is written:
|
||||
|
||||
shutdown(sock, SHUT_WR);
|
||||
close(sock);
|
||||
|
||||
However, experiments on Linux 3.9.4 show that kernel can return from
|
||||
shutdown() and from close() before all data is sent,
|
||||
and if peer sends any data to us after this, kernel still responds with
|
||||
RST before all our data is sent.
|
||||
|
||||
In practice the protocol in use often does not allow peer to send
|
||||
such data to us, in which case this solution is acceptable.
|
||||
|
||||
Solution #3: if you know that peer is going to close its end after it sees
|
||||
our FIN (as EOF), it might be a good idea to perform a read after shutdown().
|
||||
When read finishes with 0-sized result, we conclude that peer received all
|
||||
the data, saw EOF, and closed its end.
|
||||
|
||||
However, this incurs small performance penalty (we run for a longer time)
|
||||
and requires safeguards (nonblocking reads, timeouts etc) against
|
||||
malicious peers which don't close the connection.
|
||||
|
||||
Solutions #1 and #2 can be combined:
|
||||
|
||||
/* ...set up struct linger... then: */
|
||||
setsockopt(sock, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger));
|
||||
shutdown(sock, SHUT_WR);
|
||||
/* At this point, kernel sent FIN packet, not RST, to the peer, */
|
||||
/* even if there is buffered read data from the peer. */
|
||||
close(sock);
|
||||
|
||||
Defeating Nagle.
|
||||
|
||||
Method #1: manually control whether partial sends are allowed:
|
||||
|
||||
This prevents partially filled packets being sent:
|
||||
|
||||
int state = 1;
|
||||
setsockopt(fd, IPPROTO_TCP, TCP_CORK, &state, sizeof(state));
|
||||
|
||||
and this forces last, partially filled packet (if any) to be sent:
|
||||
|
||||
int state = 0;
|
||||
setsockopt(fd, IPPROTO_TCP, TCP_CORK, &state, sizeof(state));
|
||||
|
||||
Method #2: make any write to immediately send data, even if it's partial:
|
||||
|
||||
int state = 1;
|
||||
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &state, sizeof(state));
|
||||
+2
-2
@@ -478,7 +478,7 @@ static int wait_one(int flags)
|
||||
instance_list = inst->next;
|
||||
if (verbose > 1)
|
||||
printf("Finished with %s (exit status %d)\n",
|
||||
inst->device, status);
|
||||
inst->device, status);
|
||||
num_running--;
|
||||
free_instance(inst);
|
||||
|
||||
@@ -844,7 +844,7 @@ static int check_all(void)
|
||||
if (verbose > 1)
|
||||
printf("--waiting-- (pass %d)\n", passno);
|
||||
status |= wait_many(pass_done ? FLAG_WAIT_ALL :
|
||||
FLAG_WAIT_ATLEAST_ONE);
|
||||
FLAG_WAIT_ATLEAST_ONE);
|
||||
if (pass_done) {
|
||||
if (verbose > 1)
|
||||
puts("----------------------------------");
|
||||
|
||||
@@ -179,8 +179,4 @@ extern int blkid_set_tag(blkid_dev dev, const char *name,
|
||||
extern blkid_dev blkid_new_dev(void);
|
||||
extern void blkid_free_dev(blkid_dev dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -115,7 +115,7 @@ int main(int argc, char** argv)
|
||||
argv[0], ret);
|
||||
exit(1);
|
||||
}
|
||||
if ((ret = blkid_probe_all(cache) < 0))
|
||||
if ((ret = blkid_probe_all(cache)) < 0)
|
||||
fprintf(stderr, "error probing devices\n");
|
||||
|
||||
blkid_put_cache(cache);
|
||||
|
||||
@@ -153,7 +153,7 @@ extern int optind;
|
||||
void usage(char *prog)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s [-f blkid_file] [-m debug_mask]\n", prog);
|
||||
fprintf(stderr, "\tList all devices and exit\n", prog);
|
||||
fprintf(stderr, "\tList all devices and exit\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ int main(int argc, char **argv)
|
||||
case 'm':
|
||||
blkid_debug_mask = strtoul (optarg, &tmp, 0);
|
||||
if (*tmp) {
|
||||
fprintf(stderr, "Invalid debug mask: %d\n",
|
||||
fprintf(stderr, "Invalid debug mask: %s\n",
|
||||
optarg);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ void blkid_read_cache(blkid_cache cache)
|
||||
continue;
|
||||
end = strlen(buf) - 1;
|
||||
/* Continue reading next line if it ends with a backslash */
|
||||
while (buf[end] == '\\' && end < sizeof(buf) - 2 &&
|
||||
while (end < sizeof(buf) - 2 && buf[end] == '\\' &&
|
||||
fgets(buf + end, sizeof(buf) - end, file)) {
|
||||
end = strlen(buf) - 1;
|
||||
lineno++;
|
||||
|
||||
@@ -356,7 +356,7 @@ void usage(char *prog)
|
||||
fprintf(stderr, "Usage: %s [-f blkid_file] [-m debug_mask] device "
|
||||
"[type value]\n",
|
||||
prog);
|
||||
fprintf(stderr, "\tList all tags for a device and exit\n", prog);
|
||||
fprintf(stderr, "\tList all tags for a device and exit\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -382,7 +382,7 @@ int main(int argc, char **argv)
|
||||
case 'm':
|
||||
blkid_debug_mask = strtoul (optarg, &tmp, 0);
|
||||
if (*tmp) {
|
||||
fprintf(stderr, "Invalid debug mask: %d\n",
|
||||
fprintf(stderr, "Invalid debug mask: %s\n",
|
||||
optarg);
|
||||
exit(1);
|
||||
}
|
||||
@@ -407,7 +407,7 @@ int main(int argc, char **argv)
|
||||
|
||||
dev = blkid_get_dev(cache, devname, flags);
|
||||
if (!dev) {
|
||||
fprintf(stderr, "%s: cannot find device in blkid cache\n");
|
||||
fprintf(stderr, "%s: cannot find device in blkid cache\n", devname);
|
||||
exit(1);
|
||||
}
|
||||
if (search_type) {
|
||||
|
||||
@@ -1050,7 +1050,7 @@ static errcode_t ea_refcount_create(int size, ext2_refcount_t *ret)
|
||||
refcount->size = size;
|
||||
bytes = (size_t) (size * sizeof(struct ea_refcount_el));
|
||||
#ifdef DEBUG
|
||||
printf("Refcount allocated %d entries, %d bytes.\n",
|
||||
printf("Refcount allocated %d entries, %lu bytes.\n",
|
||||
refcount->size, bytes);
|
||||
#endif
|
||||
retval = ext2fs_get_mem(bytes, &refcount->list);
|
||||
@@ -3424,7 +3424,7 @@ static void e2fsck_pass1(e2fsck_t ctx)
|
||||
continue;
|
||||
}
|
||||
if ((inode->i_links_count || inode->i_blocks ||
|
||||
inode->i_blocks || inode->i_block[0]) &&
|
||||
inode->i_block[0]) &&
|
||||
fix_problem(ctx, PR_1_JOURNAL_INODE_NOT_CLEAR,
|
||||
&pctx)) {
|
||||
memset(inode, 0, inode_size);
|
||||
@@ -12195,11 +12195,7 @@ static void swap_filesys(e2fsck_t ctx)
|
||||
void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
|
||||
const char *description)
|
||||
{
|
||||
void *ret;
|
||||
char buf[256];
|
||||
|
||||
ret = xzalloc(size);
|
||||
return ret;
|
||||
return xzalloc(size);
|
||||
}
|
||||
|
||||
static char *string_copy(const char *str, int len)
|
||||
|
||||
@@ -83,7 +83,7 @@ static int calc_reserved_gdt_blocks(ext2_filsys fs)
|
||||
if (rsv_gdb > EXT2_ADDR_PER_BLOCK(sb))
|
||||
rsv_gdb = EXT2_ADDR_PER_BLOCK(sb);
|
||||
#ifdef RES_GDT_DEBUG
|
||||
printf("max_blocks %lu, rsv_groups = %lu, rsv_gdb = %lu\n",
|
||||
printf("max_blocks %lu, rsv_groups = %lu, rsv_gdb = %u\n",
|
||||
max_blocks, rsv_groups, rsv_gdb);
|
||||
#endif
|
||||
|
||||
|
||||
Loaded 100 of 384 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user