Compare commits
544
Commits
1_16_stable
...
1_17_2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e891f30d3 | ||
|
|
5168bf2caa | ||
|
|
dc04439450 | ||
|
|
941fce89fa | ||
|
|
503a07cab2 | ||
|
|
b2d95147c9 | ||
|
|
3e5fa43b2f | ||
|
|
ee1f19b942 | ||
|
|
9297dbc9d2 | ||
|
|
08f0b784fd | ||
|
|
7e1bb4bc5c | ||
|
|
926031b764 | ||
|
|
243d1757d7 | ||
|
|
fd744519d1 | ||
|
|
21e8e8da64 | ||
|
|
7c1b2b5420 | ||
|
|
5c296de390 | ||
|
|
922f6f51db | ||
|
|
cd0f6b0c93 | ||
|
|
81199672be | ||
|
|
45f66167fe | ||
|
|
620e863ba2 | ||
|
|
fa5ea17b5f | ||
|
|
c03fb3cd7d | ||
|
|
ff37799dfe | ||
|
|
7d1201c5d7 | ||
|
|
1a3b0710f5 | ||
|
|
31c3dad851 | ||
|
|
fa1b3705a3 | ||
|
|
77cc2c5738 | ||
|
|
a73b87e934 | ||
|
|
1b14cdb27c | ||
|
|
f6464000ca | ||
|
|
1eaf7e76bf | ||
|
|
fd33e17a2b | ||
|
|
b768aeb164 | ||
|
|
52827e3ebc | ||
|
|
d0a8a0d312 | ||
|
|
894fa0ad62 | ||
|
|
63144be7ea | ||
|
|
1fcbff2fac | ||
|
|
918f444f90 | ||
|
|
8d444494ef | ||
|
|
1d72d43940 | ||
|
|
e69c5e2429 | ||
|
|
41ddd9f606 | ||
|
|
2b46fd49b1 | ||
|
|
51fa147c9b | ||
|
|
eff6d59343 | ||
|
|
a54985b279 | ||
|
|
a091d45c3b | ||
|
|
dd8adde386 | ||
|
|
da75f44844 | ||
|
|
1b8e2b0e76 | ||
|
|
64606c6d01 | ||
|
|
fc6f6e933c | ||
|
|
6d9c88ad98 | ||
|
|
adbbee46ad | ||
|
|
05a550b48a | ||
|
|
a8b594fda7 | ||
|
|
d2b738a6d2 | ||
|
|
ba73cfd284 | ||
|
|
91d7ee31f7 | ||
|
|
4a96617095 | ||
|
|
e15a6c82df | ||
|
|
134d0eb114 | ||
|
|
ebeac1685a | ||
|
|
0635ddd8f7 | ||
|
|
fdd7b566ec | ||
|
|
eb08b6ed5c | ||
|
|
020465218c | ||
|
|
e329089c62 | ||
|
|
c2c7aa4b0d | ||
|
|
8cd9f343e7 | ||
|
|
b87c17cd16 | ||
|
|
7df28bbb8f | ||
|
|
1ed2fb40c9 | ||
|
|
b76f18d331 | ||
|
|
eafc6956f6 | ||
|
|
f934a51c9b | ||
|
|
8f599f9a31 | ||
|
|
0f022c0565 | ||
|
|
5070124763 | ||
|
|
cd5aa5c5da | ||
|
|
9b814ca633 | ||
|
|
4ebdae3777 | ||
|
|
5b1dfe609c | ||
|
|
3b727ccb70 | ||
|
|
d86b4c3907 | ||
|
|
0cc25945d8 | ||
|
|
2f41e7ea57 | ||
|
|
3324c96335 | ||
|
|
4f731ce30e | ||
|
|
c37fecb86c | ||
|
|
237aecedab | ||
|
|
f7e929e795 | ||
|
|
1cd769a154 | ||
|
|
da3a956dda | ||
|
|
c28cafb18d | ||
|
|
7a4021deba | ||
|
|
aaa24e09f9 | ||
|
|
1613de85d9 | ||
|
|
d5fa1a0f49 | ||
|
|
d2d327db6d | ||
|
|
e2b41cfb4b | ||
|
|
53e2f38b69 | ||
|
|
aa30efcc07 | ||
|
|
ab60cd1382 | ||
|
|
7fdf5a88b4 | ||
|
|
d70e0e995e | ||
|
|
b68bba5649 | ||
|
|
729ecb87bf | ||
|
|
121fb9506b | ||
|
|
838e0dbda1 | ||
|
|
c62f229d45 | ||
|
|
b82b34e06d | ||
|
|
e3657dcdd6 | ||
|
|
c8aae0b2a0 | ||
|
|
19ced5c425 | ||
|
|
5f3303712e | ||
|
|
8aab0c95be | ||
|
|
2fd45c2cdb | ||
|
|
f2da16f451 | ||
|
|
d94332f2b6 | ||
|
|
87496aa081 | ||
|
|
f2177abe1d | ||
|
|
161bb8fa12 | ||
|
|
22bdf90334 | ||
|
|
2f32bf8be6 | ||
|
|
f0f9470061 | ||
|
|
6c5bf0d347 | ||
|
|
0e5ba0843b | ||
|
|
729ce47360 | ||
|
|
da929a95aa | ||
|
|
e4070cb0d7 | ||
|
|
6db1373295 | ||
|
|
6c2406ac86 | ||
|
|
8878c24c7d | ||
|
|
c46792492f | ||
|
|
bf5f99ffb2 | ||
|
|
79b3d42e13 | ||
|
|
08d8b3cee1 | ||
|
|
3e47cfec90 | ||
|
|
26b6ccf340 | ||
|
|
abb154ba02 | ||
|
|
ea8b252cb3 | ||
|
|
8837c5dec4 | ||
|
|
8376bfae58 | ||
|
|
b9542cb2ce | ||
|
|
716f3f612e | ||
|
|
11bcf4b224 | ||
|
|
39a04f71ca | ||
|
|
b8b72f02f0 | ||
|
|
e58c6e2e13 | ||
|
|
b7d19cc400 | ||
|
|
c88c1a0190 | ||
|
|
acaaca839a | ||
|
|
6948f210ed | ||
|
|
fb6c76cb6e | ||
|
|
d93f19e443 | ||
|
|
602ce69afb | ||
|
|
e04c867a21 | ||
|
|
8bcaa6a4e9 | ||
|
|
7bdfb7cbf0 | ||
|
|
eb29e91dc6 | ||
|
|
76c936f522 | ||
|
|
a3581409c2 | ||
|
|
ccb88a689e | ||
|
|
c5f30c0df8 | ||
|
|
cc4493a95c | ||
|
|
1b3549875c | ||
|
|
96913f9254 | ||
|
|
ab0e412937 | ||
|
|
d148e484db | ||
|
|
6faebfa663 | ||
|
|
49ee8393f4 | ||
|
|
fc2bb8f04f | ||
|
|
e98884b9be | ||
|
|
4e8ff73e20 | ||
|
|
ad7a5d436c | ||
|
|
a85b66e0f9 | ||
|
|
599ae1eb9f | ||
|
|
4f63c7931c | ||
|
|
9e07219c78 | ||
|
|
765b0eed3e | ||
|
|
fef9ee7072 | ||
|
|
8391c4800c | ||
|
|
2e48d536ce | ||
|
|
5ae8f1cdbe | ||
|
|
e85248afa2 | ||
|
|
8a33679694 | ||
|
|
1e811b1231 | ||
|
|
ddc62f64ba | ||
|
|
a6ad397ea9 | ||
|
|
7436950a75 | ||
|
|
3f78cec347 | ||
|
|
349ef96bb5 | ||
|
|
214b8ca3dc | ||
|
|
73e013fca7 | ||
|
|
a88585a931 | ||
|
|
e91bc53d0c | ||
|
|
4f2c59b267 | ||
|
|
4d8e5fdc1d | ||
|
|
53b513331a | ||
|
|
ee0775dd13 | ||
|
|
e3be7842be | ||
|
|
cddbb610cb | ||
|
|
131ed3bcc9 | ||
|
|
a0ec4f500c | ||
|
|
44c86ce5d7 | ||
|
|
b131ccec9c | ||
|
|
40477e2fdb | ||
|
|
2e068e725c | ||
|
|
dc1fd2e52a | ||
|
|
9f82d0be61 | ||
|
|
92510141e2 | ||
|
|
42c4b2e3b5 | ||
|
|
c7f95d23f6 | ||
|
|
238bf187ba | ||
|
|
51b4a9e2f1 | ||
|
|
5e2d572381 | ||
|
|
e66cf821cf | ||
|
|
a1db8b8415 | ||
|
|
0e81e488fd | ||
|
|
adc0e20892 | ||
|
|
82731b4b7a | ||
|
|
cd10dc40e4 | ||
|
|
bbf1aa1eaf | ||
|
|
1118d9b213 | ||
|
|
786cce1871 | ||
|
|
82dd14a510 | ||
|
|
ef215558fa | ||
|
|
3227d3f982 | ||
|
|
0f01b00d74 | ||
|
|
7c1ed9fbde | ||
|
|
9963fe36c2 | ||
|
|
27ff681cfa | ||
|
|
3015a1351a | ||
|
|
248c324f7c | ||
|
|
d9a3e89f50 | ||
|
|
26e2c1db0d | ||
|
|
b8909c52fe | ||
|
|
0b7412e66b | ||
|
|
748139332a | ||
|
|
0bb2980605 | ||
|
|
8806d64acd | ||
|
|
a29b055bf1 | ||
|
|
084e2284c7 | ||
|
|
b367bb2a62 | ||
|
|
c84c85ae34 | ||
|
|
5055a9f989 | ||
|
|
e82cf339e4 | ||
|
|
a2215b98f7 | ||
|
|
94043e8ad2 | ||
|
|
da1382410b | ||
|
|
78d035f796 | ||
|
|
c0211e907b | ||
|
|
bfa1b2e8e8 | ||
|
|
6334390aef | ||
|
|
8e3aff0ce0 | ||
|
|
e3d90a90d4 | ||
|
|
1602a5cdb9 | ||
|
|
ff0e875e02 | ||
|
|
572b9a3019 | ||
|
|
65ebbc54d3 | ||
|
|
7fb68f199f | ||
|
|
6774386d95 | ||
|
|
19afe848ec | ||
|
|
7b48eb4372 | ||
|
|
c7efd6441d | ||
|
|
c2345fa2d4 | ||
|
|
5dfd9c4dbc | ||
|
|
27653adc8b | ||
|
|
b8ba6b66f5 | ||
|
|
e7f1e5ca1d | ||
|
|
ff027d6f50 | ||
|
|
fe360480aa | ||
|
|
78abf88dcc | ||
|
|
43afd75ea8 | ||
|
|
fde3fb3009 | ||
|
|
0a2c793bd6 | ||
|
|
d2844fcb68 | ||
|
|
a659b81dfa | ||
|
|
25b10d97e6 | ||
|
|
6646de0214 | ||
|
|
3963d943f8 | ||
|
|
920185c69a | ||
|
|
0c1ba443c8 | ||
|
|
4640ccc399 | ||
|
|
9138817a27 | ||
|
|
05273daf6f | ||
|
|
5f94346f73 | ||
|
|
238c83bd82 | ||
|
|
5a7c72015c | ||
|
|
f2c16edf99 | ||
|
|
96a1833231 | ||
|
|
c175c46647 | ||
|
|
def4783a8a | ||
|
|
43b094b584 | ||
|
|
04cecd5e61 | ||
|
|
2bb651ae10 | ||
|
|
6f69f2dbc6 | ||
|
|
0358daf447 | ||
|
|
36dcf4e516 | ||
|
|
c2d413ba74 | ||
|
|
e6080a4d7e | ||
|
|
b9dd5ab6d9 | ||
|
|
351ef7188a | ||
|
|
375a8ef5ea | ||
|
|
0ecc116592 | ||
|
|
8597da1934 | ||
|
|
60f659f9d9 | ||
|
|
d7b5289209 | ||
|
|
125d0154e6 | ||
|
|
e69ad87802 | ||
|
|
02365a6ef7 | ||
|
|
823b636cd1 | ||
|
|
39601843d7 | ||
|
|
1854bc1aa2 | ||
|
|
64827a2e5d | ||
|
|
f8d8aa1cea | ||
|
|
87fb72032e | ||
|
|
6dbbac5d4f | ||
|
|
f6916dbed4 | ||
|
|
fcad7681f8 | ||
|
|
5ab6b0f563 | ||
|
|
d958e909cd | ||
|
|
5ea1de2235 | ||
|
|
37bc1eb5cd | ||
|
|
3a41611bc5 | ||
|
|
37f5bef63c | ||
|
|
4c721049c3 | ||
|
|
f8fcc184b6 | ||
|
|
290346948d | ||
|
|
4f3aa51f9d | ||
|
|
4836331924 | ||
|
|
c03602baa4 | ||
|
|
9c0ea86caa | ||
|
|
7379cd1ca1 | ||
|
|
fab288cf0b | ||
|
|
243ddcbc76 | ||
|
|
ccd1efc3c1 | ||
|
|
4a1884da53 | ||
|
|
8a659f6ff9 | ||
|
|
05d1a32192 | ||
|
|
8fc9e6a15d | ||
|
|
208d35d21f | ||
|
|
37201213ca | ||
|
|
b38af7bd31 | ||
|
|
5342c3f310 | ||
|
|
345e093c29 | ||
|
|
c897dfe011 | ||
|
|
8d22ca81c3 | ||
|
|
55301297d3 | ||
|
|
17fcd72add | ||
|
|
9e59e27cdf | ||
|
|
57dc3c7b4c | ||
|
|
84f6def072 | ||
|
|
2004fa1bc8 | ||
|
|
eab75f6049 | ||
|
|
3d43aed10c | ||
|
|
1d448cff65 | ||
|
|
3d0e7794eb | ||
|
|
fcb84c8bd2 | ||
|
|
603884b07e | ||
|
|
03f6ee28d6 | ||
|
|
4816fe9179 | ||
|
|
c8a2ab1023 | ||
|
|
406bd14416 | ||
|
|
9107b63a7f | ||
|
|
c2fdd41f5f | ||
|
|
fbedacfc8c | ||
|
|
35fdb1bc9c | ||
|
|
023a08f229 | ||
|
|
496d5bf4c6 | ||
|
|
19158a837d | ||
|
|
aa167556cd | ||
|
|
385b4562e3 | ||
|
|
968951fd0c | ||
|
|
1abc07dcca | ||
|
|
7724c766bd | ||
|
|
a8f6b99987 | ||
|
|
7e6add1dfc | ||
|
|
0454d9d6c3 | ||
|
|
eb03d08f34 | ||
|
|
3d9c69fb4f | ||
|
|
702f7d6c0b | ||
|
|
a14a9d73b1 | ||
|
|
651a2697f7 | ||
|
|
37a658c4c8 | ||
|
|
30ebd7bd78 | ||
|
|
1c3f117ca4 | ||
|
|
e283413395 | ||
|
|
6ef8def7cf | ||
|
|
1497484839 | ||
|
|
85dbf190c6 | ||
|
|
6b61629397 | ||
|
|
dde8bdcc5b | ||
|
|
8d1144565f | ||
|
|
501e35c474 | ||
|
|
6b24d5354b | ||
|
|
4f0408b5bc | ||
|
|
927e4bb644 | ||
|
|
53f72bb3f0 | ||
|
|
c7dc79e71d | ||
|
|
2e7aa92836 | ||
|
|
e5ce91b41b | ||
|
|
87fa216e1e | ||
|
|
0f62c4d065 | ||
|
|
a953987e77 | ||
|
|
8a7c166ab9 | ||
|
|
de9e772f46 | ||
|
|
777706cb23 | ||
|
|
77a2c51e79 | ||
|
|
bcda0042e2 | ||
|
|
892d4b6b3d | ||
|
|
8531d76a15 | ||
|
|
c5c006c10c | ||
|
|
98f1dc12f1 | ||
|
|
0c0f1767f0 | ||
|
|
46abfc0da1 | ||
|
|
8d4a8d195d | ||
|
|
d46c36c74e | ||
|
|
09b767250d | ||
|
|
820874ed38 | ||
|
|
535584c750 | ||
|
|
814da220a5 | ||
|
|
7cfec4b3e0 | ||
|
|
29f354e9d8 | ||
|
|
b76356b28e | ||
|
|
6eaeb7737d | ||
|
|
f9782ffc45 | ||
|
|
c6ba997978 | ||
|
|
7b81db1379 | ||
|
|
39fe4d1599 | ||
|
|
58f108eb33 | ||
|
|
b0a57abb79 | ||
|
|
6ebdf7aa7b | ||
|
|
da62b09ab1 | ||
|
|
90f19fa468 | ||
|
|
c9955f23a2 | ||
|
|
3cb60c3973 | ||
|
|
eae697fb93 | ||
|
|
d2b04050c0 | ||
|
|
f15620c377 | ||
|
|
41d8134511 | ||
|
|
79950a6bbe | ||
|
|
c77e478af4 | ||
|
|
8cb40361c0 | ||
|
|
f3c742f925 | ||
|
|
cbcc1236f8 | ||
|
|
4b1100edd8 | ||
|
|
44fbfa78ca | ||
|
|
917693b5b3 | ||
|
|
197202d435 | ||
|
|
9341fd2d30 | ||
|
|
5749328b56 | ||
|
|
88aa558e5c | ||
|
|
d2f7779671 | ||
|
|
3e26d4fa23 | ||
|
|
f6b29a2dc9 | ||
|
|
99069330a1 | ||
|
|
45cec1ee89 | ||
|
|
836f36333a | ||
|
|
1359e0d1b9 | ||
|
|
ca228fb16d | ||
|
|
26ffe81188 | ||
|
|
fd686a262f | ||
|
|
99709ab033 | ||
|
|
7e7728cd66 | ||
|
|
d03cd3be24 | ||
|
|
2e73d84c02 | ||
|
|
8031848938 | ||
|
|
64bb95a361 | ||
|
|
bf1d347964 | ||
|
|
b702d9aa5a | ||
|
|
43d9747f6e | ||
|
|
8ce1dc03c1 | ||
|
|
bef5711dab | ||
|
|
153fcaa6c1 | ||
|
|
7426920461 | ||
|
|
00ddd44cda | ||
|
|
2f8a46032d | ||
|
|
45e9792446 | ||
|
|
baab327719 | ||
|
|
5e7345770a | ||
|
|
bb169f4217 | ||
|
|
125c2d2690 | ||
|
|
0866b36900 | ||
|
|
80f4275629 | ||
|
|
81fe2b15f3 | ||
|
|
3fdba181c3 | ||
|
|
10544a8410 | ||
|
|
fb6e689554 | ||
|
|
73ccd0ca87 | ||
|
|
14a917eaab | ||
|
|
3205c24a82 | ||
|
|
eb255752c1 | ||
|
|
f16d7c4bdf | ||
|
|
343dfd7abe | ||
|
|
e66a09ba9c | ||
|
|
b55d652400 | ||
|
|
5fb38491e3 | ||
|
|
cb7edc2661 | ||
|
|
0cd445f4d1 | ||
|
|
6aca76d4d7 | ||
|
|
b741cd28d1 | ||
|
|
2f14263c40 | ||
|
|
3dbc5a9742 | ||
|
|
36659fda1f | ||
|
|
12ca080a1c | ||
|
|
98a4c7cf3d | ||
|
|
1821d188ca | ||
|
|
f111b67100 | ||
|
|
557deb1014 | ||
|
|
659507f84e | ||
|
|
baad6d889d | ||
|
|
bb1dcc9aab | ||
|
|
5b9b1365a0 | ||
|
|
4b061461d3 | ||
|
|
40e7d25aca | ||
|
|
4875e7148b | ||
|
|
698dca5805 | ||
|
|
c8e18ca12c | ||
|
|
e936c6d1c5 | ||
|
|
460f827644 | ||
|
|
b1edf20f18 | ||
|
|
40e4e88a28 | ||
|
|
344a44fbc5 | ||
|
|
3d5b606931 | ||
|
|
d8528b8e56 | ||
|
|
ed910c750d | ||
|
|
e17764c8fb | ||
|
|
ecd90fd488 | ||
|
|
a42524251e | ||
|
|
ac3645051c | ||
|
|
2edba21f4c | ||
|
|
083e172641 | ||
|
|
6b9f163353 | ||
|
|
17323a6245 | ||
|
|
2755f4e443 | ||
|
|
e57ea7edb6 | ||
|
|
ffc4bced95 | ||
|
|
e838779429 |
No files matched your search
@@ -6,6 +6,8 @@
|
||||
*.o.*
|
||||
*.a
|
||||
*.s
|
||||
Kbuild
|
||||
Config.in
|
||||
|
||||
#
|
||||
# Never ignore these
|
||||
|
||||
@@ -15,7 +15,7 @@ menu "General Configuration"
|
||||
|
||||
config DESKTOP
|
||||
bool "Enable options for full-blown desktop systems"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Enable options and features which are not essential.
|
||||
Select this only if you plan to use busybox on full-blown
|
||||
@@ -82,8 +82,8 @@ config SHOW_USAGE
|
||||
|
||||
config FEATURE_VERBOSE_USAGE
|
||||
bool "Show verbose applet usage messages"
|
||||
default n
|
||||
select SHOW_USAGE
|
||||
default y
|
||||
depends on SHOW_USAGE
|
||||
help
|
||||
All BusyBox applets will show more verbose help messages when
|
||||
busybox is invoked with --help. This will add a lot of text to the
|
||||
@@ -106,7 +106,7 @@ config FEATURE_COMPRESS_USAGE
|
||||
|
||||
config FEATURE_INSTALLER
|
||||
bool "Support --install [-s] to install applet links at runtime"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Enable 'busybox --install [-s]' support. This will allow you to use
|
||||
busybox at runtime to create hard links or symlinks for all the
|
||||
@@ -119,9 +119,9 @@ config LOCALE_SUPPORT
|
||||
Enable this if your system has locale support and you would like
|
||||
busybox to support locale settings.
|
||||
|
||||
config FEATURE_ASSUME_UNICODE
|
||||
config UNICODE_SUPPORT
|
||||
bool "Support Unicode"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This makes various applets aware that one byte is not
|
||||
one character on screen.
|
||||
@@ -131,16 +131,110 @@ config FEATURE_ASSUME_UNICODE
|
||||
Probably by the time when busybox will be fully Unicode-clean,
|
||||
other encodings will be mainly of historic interest.
|
||||
|
||||
config UNICODE_USING_LOCALE
|
||||
bool "Use libc routines for Unicode (else uses internal ones)"
|
||||
default n
|
||||
depends on UNICODE_SUPPORT && LOCALE_SUPPORT
|
||||
help
|
||||
With this option on, Unicode support is implemented using libc
|
||||
routines. Otherwise, internal implementation is used.
|
||||
Internal implementation is smaller.
|
||||
|
||||
config FEATURE_CHECK_UNICODE_IN_ENV
|
||||
bool "Check $LANG environment variable"
|
||||
default y
|
||||
depends on FEATURE_ASSUME_UNICODE && !LOCALE_SUPPORT
|
||||
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"
|
||||
|
||||
Otherwise, Unicode support will be always enabled and active.
|
||||
|
||||
config SUBST_WCHAR
|
||||
int "Character code to substitute unprintable characters with"
|
||||
depends on UNICODE_SUPPORT
|
||||
default 63
|
||||
help
|
||||
Typical values are 63 for '?' (works with any output device),
|
||||
30 for ASCII substitute control code,
|
||||
65533 (0xfffd) for Unicode replacement character.
|
||||
|
||||
config LAST_SUPPORTED_WCHAR
|
||||
int "Range of supported Unicode characters"
|
||||
depends on UNICODE_SUPPORT
|
||||
default 767
|
||||
help
|
||||
Any character with Unicode value bigger than this is assumed
|
||||
to be non-printable on output device. Many applets replace
|
||||
such chars with substitution character.
|
||||
|
||||
The idea is that many valid printable Unicode chars are
|
||||
nevertheless are not displayed correctly. Think about
|
||||
combining charachers, double-wide hieroglyphs, obscure
|
||||
characters in dozens of ancient scripts...
|
||||
Many terminals, terminal emulators, xterms etc will fail
|
||||
to handle them correctly. Choose the smallest value
|
||||
which suits your needs.
|
||||
|
||||
Typical values are:
|
||||
126 - ASCII only
|
||||
767 (0x2ff) - there are no combining chars in [0..767] range
|
||||
(the range includes Latin 1, Latin Ext. A and B),
|
||||
code is ~700 bytes smaller for this case.
|
||||
4351 (0x10ff) - there are no double-wide chars in [0..4351] range,
|
||||
code is ~300 bytes smaller for this case.
|
||||
12799 (0x31ff) - nearly all non-ideographic characters are
|
||||
available in [0..12799] range, including
|
||||
East Asian scripts like katakana, hiragana, hangul,
|
||||
bopomofo...
|
||||
0 - off, any valid printable Unicode character will be printed.
|
||||
|
||||
config UNICODE_COMBINING_WCHARS
|
||||
bool "Allow zero-width Unicode characters on output"
|
||||
default n
|
||||
depends on UNICODE_SUPPORT
|
||||
help
|
||||
With this option off, any Unicode char with width of 0
|
||||
is substituted on output.
|
||||
|
||||
config UNICODE_WIDE_WCHARS
|
||||
bool "Allow wide Unicode characters on output"
|
||||
default n
|
||||
depends on UNICODE_SUPPORT
|
||||
help
|
||||
With this option off, any Unicode char with width > 1
|
||||
is substituted on output.
|
||||
|
||||
config UNICODE_BIDI_SUPPORT
|
||||
bool "Bidirectional character-aware line input"
|
||||
default n
|
||||
depends on UNICODE_SUPPORT && !UNICODE_USING_LOCALE
|
||||
help
|
||||
With this option on, right-to-left Unicode characters
|
||||
are treated differently on input (e.g. cursor movement).
|
||||
|
||||
config UNICODE_NEUTRAL_TABLE
|
||||
bool "In bidi input, support non-ASCII neutral chars too"
|
||||
default n
|
||||
depends on UNICODE_BIDI_SUPPORT
|
||||
help
|
||||
In most cases it's enough to treat only ASCII non-letters
|
||||
(i.e. punctuation, numbers and space) as characters
|
||||
with neutral directionality.
|
||||
With this option on, more extensive (and bigger) table
|
||||
of neutral chars will be used.
|
||||
|
||||
config UNICODE_PRESERVE_BROKEN
|
||||
bool "Make it possible to enter sequences of chars which are not Unicode"
|
||||
default n
|
||||
depends on UNICODE_SUPPORT
|
||||
help
|
||||
With this option on, invalid UTF-8 bytes are not substituted
|
||||
with the selected substitution character.
|
||||
For example, this means that entering 'l', 's', ' ', 0xff, [Enter]
|
||||
at shell prompt will list file named 0xff (single char name
|
||||
with char value 255), not file named '?'.
|
||||
|
||||
config LONG_OPTS
|
||||
bool "Support for --long-options"
|
||||
default y
|
||||
@@ -170,16 +264,36 @@ config FEATURE_CLEAN_UP
|
||||
Don't enable this unless you have a really good reason to clean
|
||||
things up manually.
|
||||
|
||||
config FEATURE_UTMP
|
||||
bool "Support utmp file"
|
||||
default y
|
||||
help
|
||||
The file /var/run/utmp is used to track who is currently logged in.
|
||||
With this option on, certain applets (getty, login, telnetd etc)
|
||||
will create and delete entries there.
|
||||
"who" applet requires this option.
|
||||
|
||||
config FEATURE_WTMP
|
||||
bool "Support wtmp file"
|
||||
default y
|
||||
select FEATURE_UTMP
|
||||
help
|
||||
The file /var/run/wtmp is used to track when users have logged into
|
||||
and logged out of the system.
|
||||
With this option on, certain applets (getty, login, telnetd etc)
|
||||
will append new entries there.
|
||||
"last" applet requires this option.
|
||||
|
||||
config FEATURE_PIDFILE
|
||||
bool "Support writing pidfiles"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This option makes some applets (e.g. crond, syslogd, inetd) write
|
||||
a pidfile in /var/run. Some applications rely on them.
|
||||
|
||||
config FEATURE_SUID
|
||||
bool "Support for SUID/SGID handling"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
With this option you can install the busybox binary belonging
|
||||
to root with the suid bit set, and it will automatically drop
|
||||
@@ -196,7 +310,7 @@ config FEATURE_SUID
|
||||
|
||||
config FEATURE_SUID_CONFIG
|
||||
bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
|
||||
default n if FEATURE_SUID
|
||||
default y if FEATURE_SUID
|
||||
depends on FEATURE_SUID
|
||||
help
|
||||
Allow the SUID / SGID state of an applet to be determined at runtime
|
||||
@@ -415,7 +529,7 @@ config FEATURE_SHARED_BUSYBOX
|
||||
|
||||
config LFS
|
||||
bool "Build with Large File Support (for accessing files > 2 GB)"
|
||||
default n
|
||||
default y
|
||||
select FDISK_SUPPORT_LARGE_DISKS
|
||||
help
|
||||
If you want to build BusyBox with large file support, then enable
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 16
|
||||
SUBLEVEL = 0
|
||||
PATCHLEVEL = 17
|
||||
SUBLEVEL = 2
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
@@ -358,11 +358,16 @@ scripts_basic:
|
||||
# To avoid any implicit rule to kick in, define an empty command.
|
||||
scripts/basic/%: scripts_basic ;
|
||||
|
||||
# This target generates Kbuild's and Config.in's from *.c files
|
||||
PHONY += gen_build_files
|
||||
gen_build_files: $(wildcard $(srctree)/*/*.c) $(wildcard $(srctree)/*/*/*.c)
|
||||
$(Q)$(srctree)/scripts/gen_build_files.sh $(srctree) $(objtree)
|
||||
|
||||
# bbox: we have helpers in applets/
|
||||
# we depend on scripts_basic, since scripts/basic/fixdep
|
||||
# must be built before any other host prog
|
||||
PHONY += applets_dir
|
||||
applets_dir: scripts_basic
|
||||
applets_dir: scripts_basic gen_build_files
|
||||
$(Q)$(MAKE) $(build)=applets
|
||||
|
||||
applets/%: applets_dir ;
|
||||
@@ -428,7 +433,12 @@ ifeq ($(config-targets),1)
|
||||
-include $(srctree)/arch/$(ARCH)/Makefile
|
||||
export KBUILD_DEFCONFIG
|
||||
|
||||
config %config: scripts_basic outputmakefile FORCE
|
||||
config: scripts_basic outputmakefile gen_build_files FORCE
|
||||
$(Q)mkdir -p include
|
||||
$(Q)$(MAKE) $(build)=scripts/kconfig $@
|
||||
$(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
|
||||
|
||||
%config: scripts_basic outputmakefile gen_build_files FORCE
|
||||
$(Q)mkdir -p include
|
||||
$(Q)$(MAKE) $(build)=scripts/kconfig $@
|
||||
$(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
|
||||
@@ -441,9 +451,9 @@ else
|
||||
ifeq ($(KBUILD_EXTMOD),)
|
||||
# Additional helpers built in scripts/
|
||||
# Carefully list dependencies so we do not try to build scripts twice
|
||||
# in parrallel
|
||||
# in parallel
|
||||
PHONY += scripts
|
||||
scripts: scripts_basic include/config/MARKER
|
||||
scripts: gen_build_files scripts_basic include/config/MARKER
|
||||
$(Q)$(MAKE) $(build)=$(@)
|
||||
|
||||
scripts_basic: include/autoconf.h
|
||||
@@ -504,9 +514,11 @@ include $(srctree)/Makefile.flags
|
||||
# with it and forgot to run make oldconfig.
|
||||
# If kconfig.d is missing then we are probarly in a cleaned tree so
|
||||
# we execute the config step to be sure to catch updated Kconfig files
|
||||
include/autoconf.h: .kconfig.d .config
|
||||
include/autoconf.h: .kconfig.d .config $(wildcard $(srctree)/*/*.c) $(wildcard $(srctree)/*/*/*.c) | gen_build_files
|
||||
$(Q)$(MAKE) -f $(srctree)/Makefile silentoldconfig
|
||||
|
||||
include/usage.h: gen_build_files
|
||||
|
||||
else
|
||||
# Dummy target needed, because used as prerequisite
|
||||
include/autoconf.h: ;
|
||||
@@ -996,6 +1008,8 @@ $(mrproper-dirs):
|
||||
mrproper: clean archmrproper $(mrproper-dirs)
|
||||
$(call cmd,rmdirs)
|
||||
$(call cmd,rmfiles)
|
||||
@find -name Config.src | sed 's/.src$$/.in/' | xargs -r rm -f
|
||||
@find -name Kbuild.src | sed 's/.src$$//' | xargs -r rm -f
|
||||
|
||||
# distclean
|
||||
#
|
||||
@@ -1276,9 +1290,13 @@ endif
|
||||
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
|
||||
|
||||
# Modules
|
||||
/ %/: prepare scripts FORCE
|
||||
%/: prepare scripts FORCE
|
||||
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
|
||||
$(build)=$(build-dir)
|
||||
/: prepare scripts FORCE
|
||||
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
|
||||
$(build)=$(build-dir)
|
||||
|
||||
%.ko: prepare scripts FORCE
|
||||
$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
|
||||
$(build)=$(build-dir) $(@:.ko=.o)
|
||||
|
||||
+6
-2
@@ -2,7 +2,7 @@
|
||||
# Build system
|
||||
# ==========================================================================
|
||||
|
||||
busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h $(srctree)/include/applets.h
|
||||
busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h include/applets.h
|
||||
$(Q)-$(SHELL) $^ >$@
|
||||
|
||||
.PHONY: install
|
||||
@@ -64,6 +64,10 @@ release: distclean
|
||||
-name .svn \
|
||||
-print \
|
||||
-exec rm -r -f {} \; ; \
|
||||
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
|
||||
-name .git \
|
||||
-print \
|
||||
-exec rm -r -f {} \; ; \
|
||||
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
|
||||
-name .\#* \
|
||||
-print \
|
||||
@@ -114,7 +118,7 @@ disp_doc = $($(quiet)cmd_doc)
|
||||
# sed adds newlines after "Options:" etc,
|
||||
# this is needed in order to get good BusyBox.{1,txt,html}
|
||||
docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
|
||||
$(srctree)/include/usage.h \
|
||||
include/usage.h \
|
||||
$(srctree)/docs/busybox_footer.pod \
|
||||
applets/usage_pod
|
||||
$(disp_doc)
|
||||
|
||||
@@ -40,6 +40,7 @@ CFLAGS += $(call cc-option,-Werror,)
|
||||
## Classic *(off_t*)(void*)ptr does not work,
|
||||
## and I am unwilling to do crazy gcc specific ({ void *ppp = ...; })
|
||||
## stuff in macros. This would obfuscate the code too much.
|
||||
## Maybe try __attribute__((__may_alias__))?
|
||||
#CFLAGS += $(call cc-ifversion, -eq, 0404, -fno-strict-aliasing)
|
||||
endif
|
||||
# gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
|
||||
|
||||
@@ -66,7 +66,7 @@ Downloading the current source code:
|
||||
|
||||
You can browse the up to the minute source code and change history online.
|
||||
|
||||
http://www.busybox.net/cgi-bin/viewcvs.cgi/trunk/busybox/
|
||||
http://git.busybox.net/busybox/
|
||||
|
||||
Anonymous GIT access is available. For instructions, check out:
|
||||
|
||||
@@ -83,11 +83,11 @@ Downloading the current source code:
|
||||
what happened is the subversion changelog.
|
||||
|
||||
Note: if you want to compile busybox in a busybox environment you must
|
||||
select ENABLE_DESKTOP.
|
||||
select CONFIG_DESKTOP.
|
||||
|
||||
----------------
|
||||
|
||||
getting help:
|
||||
Getting help:
|
||||
|
||||
when you find you need help, you can check out the busybox mailing list
|
||||
archives at http://busybox.net/lists/busybox/ or even join
|
||||
@@ -95,7 +95,7 @@ getting help:
|
||||
|
||||
----------------
|
||||
|
||||
bugs:
|
||||
Bugs:
|
||||
|
||||
if you find bugs, please submit a detailed bug report to the busybox mailing
|
||||
list at busybox@busybox.net. a well-written bug report should include a
|
||||
@@ -194,6 +194,11 @@ Supported hardware:
|
||||
----------------
|
||||
|
||||
Please feed suggestions, bug reports, insults, and bribes back to the busybox
|
||||
maintainer:
|
||||
mailing list:
|
||||
|
||||
busybox@busybox.net
|
||||
|
||||
and/or maintainer:
|
||||
|
||||
Denys Vlasenko
|
||||
<vda.linux@googlemail.com>
|
||||
<vda.linux@googlemail.com>
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.15.0.svn
|
||||
# Fri Aug 21 00:13:18 2009
|
||||
# Busybox version: 1.16.0
|
||||
# Wed Jan 27 21:01:26 2010
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
@@ -14,6 +14,8 @@ CONFIG_HAVE_DOT_CONFIG=y
|
||||
#
|
||||
CONFIG_DESKTOP=y
|
||||
CONFIG_EXTRA_COMPAT=y
|
||||
CONFIG_INCLUDE_SUSv2=y
|
||||
# CONFIG_USE_PORTABLE_CODE is not set
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
@@ -22,7 +24,7 @@ CONFIG_FEATURE_VERBOSE_USAGE=y
|
||||
CONFIG_FEATURE_COMPRESS_USAGE=y
|
||||
CONFIG_FEATURE_INSTALLER=y
|
||||
# CONFIG_LOCALE_SUPPORT is not set
|
||||
# CONFIG_FEATURE_ASSUME_UNICODE is not set
|
||||
# CONFIG_UNICODE_SUPPORT is not set
|
||||
# CONFIG_FEATURE_CHECK_UNICODE_IN_ENV is not set
|
||||
CONFIG_LONG_OPTS=y
|
||||
CONFIG_FEATURE_DEVPTS=y
|
||||
@@ -59,7 +61,6 @@ CONFIG_EXTRA_CFLAGS=""
|
||||
CONFIG_NO_DEBUG_LIB=y
|
||||
# CONFIG_DMALLOC is not set
|
||||
# CONFIG_EFENCE is not set
|
||||
CONFIG_INCLUDE_SUSv2=y
|
||||
|
||||
#
|
||||
# Installation Options
|
||||
@@ -120,6 +121,7 @@ CONFIG_DPKG_DEB=y
|
||||
CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY=y
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_GZIP=y
|
||||
CONFIG_FEATURE_GZIP_LONG_OPTIONS=y
|
||||
CONFIG_LZOP=y
|
||||
CONFIG_LZOP_COMPR_HIGH=y
|
||||
CONFIG_RPM2CPIO=y
|
||||
@@ -133,6 +135,7 @@ CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY=y
|
||||
CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
|
||||
CONFIG_FEATURE_TAR_LONG_OPTIONS=y
|
||||
CONFIG_FEATURE_TAR_UNAME_GNAME=y
|
||||
CONFIG_FEATURE_TAR_NOPRESERVE_TIME=y
|
||||
CONFIG_UNCOMPRESS=y
|
||||
CONFIG_UNLZMA=y
|
||||
CONFIG_FEATURE_LZMA_FAST=y
|
||||
@@ -148,15 +151,19 @@ CONFIG_CATV=y
|
||||
CONFIG_CHGRP=y
|
||||
CONFIG_CHMOD=y
|
||||
CONFIG_CHOWN=y
|
||||
CONFIG_FEATURE_CHOWN_LONG_OPTIONS=y
|
||||
CONFIG_CHROOT=y
|
||||
CONFIG_CKSUM=y
|
||||
CONFIG_COMM=y
|
||||
CONFIG_CP=y
|
||||
CONFIG_FEATURE_CP_LONG_OPTIONS=y
|
||||
CONFIG_CUT=y
|
||||
CONFIG_DATE=y
|
||||
CONFIG_FEATURE_DATE_ISOFMT=y
|
||||
CONFIG_FEATURE_DATE_COMPAT=y
|
||||
CONFIG_DD=y
|
||||
CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
|
||||
CONFIG_FEATURE_DD_THIRD_STATUS_LINE=y
|
||||
CONFIG_FEATURE_DD_IBS_OBS=y
|
||||
CONFIG_DF=y
|
||||
CONFIG_FEATURE_DF_FANCY=y
|
||||
@@ -271,7 +278,7 @@ CONFIG_FEATURE_AUTOWIDTH=y
|
||||
CONFIG_FEATURE_HUMAN_READABLE=y
|
||||
|
||||
#
|
||||
# Common options for md5sum, sha1sum
|
||||
# Common options for md5sum, sha1sum, sha256sum, sha512sum
|
||||
#
|
||||
CONFIG_FEATURE_MD5_SHA1_SUM_CHECK=y
|
||||
|
||||
@@ -318,9 +325,8 @@ CONFIG_AWK=y
|
||||
CONFIG_FEATURE_AWK_LIBM=y
|
||||
CONFIG_CMP=y
|
||||
CONFIG_DIFF=y
|
||||
CONFIG_FEATURE_DIFF_BINARY=y
|
||||
CONFIG_FEATURE_DIFF_LONG_OPTIONS=y
|
||||
CONFIG_FEATURE_DIFF_DIR=y
|
||||
CONFIG_FEATURE_DIFF_MINIMAL=y
|
||||
CONFIG_ED=y
|
||||
CONFIG_PATCH=y
|
||||
CONFIG_SED=y
|
||||
@@ -364,6 +370,7 @@ CONFIG_FEATURE_FIND_DELETE=y
|
||||
CONFIG_FEATURE_FIND_PATH=y
|
||||
CONFIG_FEATURE_FIND_REGEX=y
|
||||
CONFIG_FEATURE_FIND_CONTEXT=y
|
||||
CONFIG_FEATURE_FIND_LINKS=y
|
||||
CONFIG_GREP=y
|
||||
CONFIG_FEATURE_GREP_EGREP_ALIAS=y
|
||||
CONFIG_FEATURE_GREP_FGREP_ALIAS=y
|
||||
@@ -453,6 +460,7 @@ CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
|
||||
# Options common to multiple modutils
|
||||
#
|
||||
# CONFIG_FEATURE_2_4_MODULES is not set
|
||||
CONFIG_FEATURE_INSMOD_TRY_MMAP=y
|
||||
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
|
||||
# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
|
||||
@@ -488,12 +496,14 @@ CONFIG_FEATURE_FDISK_ADVANCED=y
|
||||
CONFIG_FINDFS=y
|
||||
CONFIG_FREERAMDISK=y
|
||||
CONFIG_FSCK_MINIX=y
|
||||
CONFIG_MKFS_EXT2=y
|
||||
CONFIG_MKFS_MINIX=y
|
||||
|
||||
#
|
||||
# Minix filesystem support
|
||||
#
|
||||
CONFIG_FEATURE_MINIX2=y
|
||||
CONFIG_MKFS_REISER=y
|
||||
CONFIG_MKFS_VFAT=y
|
||||
CONFIG_GETOPT=y
|
||||
CONFIG_FEATURE_GETOPT_LONG=y
|
||||
@@ -506,6 +516,8 @@ CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS=y
|
||||
CONFIG_IPCRM=y
|
||||
CONFIG_IPCS=y
|
||||
CONFIG_LOSETUP=y
|
||||
CONFIG_LSPCI=y
|
||||
CONFIG_LSUSB=y
|
||||
CONFIG_MDEV=y
|
||||
CONFIG_FEATURE_MDEV_CONF=y
|
||||
CONFIG_FEATURE_MDEV_RENAME=y
|
||||
@@ -518,6 +530,7 @@ CONFIG_MORE=y
|
||||
CONFIG_FEATURE_USE_TERMIOS=y
|
||||
CONFIG_VOLUMEID=y
|
||||
CONFIG_FEATURE_VOLUMEID_EXT=y
|
||||
CONFIG_FEATURE_VOLUMEID_BTRFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_REISERFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_FAT=y
|
||||
CONFIG_FEATURE_VOLUMEID_HFS=y
|
||||
@@ -595,6 +608,7 @@ CONFIG_DEVMEM=y
|
||||
CONFIG_EJECT=y
|
||||
CONFIG_FEATURE_EJECT_SCSI=y
|
||||
CONFIG_FBSPLASH=y
|
||||
CONFIG_FLASHCP=y
|
||||
# CONFIG_FLASH_LOCK is not set
|
||||
# CONFIG_FLASH_UNLOCK is not set
|
||||
# CONFIG_FLASH_ERASEALL is not set
|
||||
@@ -638,6 +652,7 @@ CONFIG_TIME=y
|
||||
CONFIG_TIMEOUT=y
|
||||
CONFIG_TTYSIZE=y
|
||||
CONFIG_VOLNAME=y
|
||||
CONFIG_WALL=y
|
||||
CONFIG_WATCHDOG=y
|
||||
|
||||
#
|
||||
@@ -657,6 +672,7 @@ CONFIG_ETHER_WAKE=y
|
||||
CONFIG_FAKEIDENTD=y
|
||||
CONFIG_FTPD=y
|
||||
CONFIG_FEATURE_FTP_WRITE=y
|
||||
CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST=y
|
||||
CONFIG_FTPGET=y
|
||||
CONFIG_FTPPUT=y
|
||||
CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y
|
||||
@@ -722,6 +738,8 @@ CONFIG_NETSTAT=y
|
||||
CONFIG_FEATURE_NETSTAT_WIDE=y
|
||||
CONFIG_FEATURE_NETSTAT_PRG=y
|
||||
CONFIG_NSLOOKUP=y
|
||||
CONFIG_NTPD=y
|
||||
CONFIG_FEATURE_NTPD_SERVER=y
|
||||
CONFIG_PING=y
|
||||
CONFIG_PING6=y
|
||||
CONFIG_FEATURE_FANCY_PING=y
|
||||
@@ -733,13 +751,16 @@ CONFIG_FEATURE_TELNET_TTYPE=y
|
||||
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
|
||||
CONFIG_TELNETD=y
|
||||
CONFIG_FEATURE_TELNETD_STANDALONE=y
|
||||
CONFIG_FEATURE_TELNETD_INETD_WAIT=y
|
||||
CONFIG_TFTP=y
|
||||
CONFIG_TFTPD=y
|
||||
CONFIG_FEATURE_TFTP_GET=y
|
||||
CONFIG_FEATURE_TFTP_PUT=y
|
||||
CONFIG_FEATURE_TFTP_BLOCKSIZE=y
|
||||
CONFIG_FEATURE_TFTP_PROGRESS_BAR=y
|
||||
CONFIG_TFTP_DEBUG=y
|
||||
CONFIG_TRACEROUTE=y
|
||||
CONFIG_TRACEROUTE6=y
|
||||
CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
|
||||
CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE=y
|
||||
CONFIG_FEATURE_TRACEROUTE_USE_ICMP=y
|
||||
@@ -813,6 +834,7 @@ CONFIG_FEATURE_TOP_SMP_CPU=y
|
||||
CONFIG_FEATURE_TOP_DECIMALS=y
|
||||
CONFIG_FEATURE_TOP_SMP_PROCESS=y
|
||||
CONFIG_FEATURE_TOPMEM=y
|
||||
CONFIG_FEATURE_SHOW_THREADS=y
|
||||
CONFIG_UPTIME=y
|
||||
CONFIG_WATCH=y
|
||||
|
||||
@@ -881,6 +903,7 @@ CONFIG_HUSH_CASE=y
|
||||
CONFIG_HUSH_FUNCTIONS=y
|
||||
CONFIG_HUSH_LOCAL=y
|
||||
CONFIG_HUSH_EXPORT_N=y
|
||||
CONFIG_HUSH_RANDOM_SUPPORT=y
|
||||
CONFIG_LASH=y
|
||||
CONFIG_MSH=y
|
||||
CONFIG_SH_MATH_SUPPORT=y
|
||||
@@ -0,0 +1,929 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.17.0.git
|
||||
# Mon Jun 7 13:37:55 2010
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
#
|
||||
# Busybox Settings
|
||||
#
|
||||
|
||||
#
|
||||
# General Configuration
|
||||
#
|
||||
CONFIG_DESKTOP=y
|
||||
CONFIG_EXTRA_COMPAT=y
|
||||
CONFIG_INCLUDE_SUSv2=y
|
||||
# CONFIG_USE_PORTABLE_CODE is not set
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
CONFIG_SHOW_USAGE=y
|
||||
CONFIG_FEATURE_VERBOSE_USAGE=y
|
||||
# CONFIG_FEATURE_COMPRESS_USAGE is not set
|
||||
# CONFIG_FEATURE_INSTALLER is not set
|
||||
# CONFIG_LOCALE_SUPPORT is not set
|
||||
CONFIG_UNICODE_SUPPORT=y
|
||||
# CONFIG_UNICODE_USING_LOCALE is not set
|
||||
CONFIG_FEATURE_CHECK_UNICODE_IN_ENV=y
|
||||
CONFIG_SUBST_WCHAR=63
|
||||
CONFIG_LAST_SUPPORTED_WCHAR=65535
|
||||
CONFIG_UNICODE_COMBINING_WCHARS=y
|
||||
CONFIG_UNICODE_WIDE_WCHARS=y
|
||||
CONFIG_UNICODE_BIDI_SUPPORT=y
|
||||
# CONFIG_UNICODE_NEUTRAL_TABLE is not set
|
||||
CONFIG_UNICODE_PRESERVE_BROKEN=y
|
||||
CONFIG_LONG_OPTS=y
|
||||
CONFIG_FEATURE_DEVPTS=y
|
||||
# CONFIG_FEATURE_CLEAN_UP is not set
|
||||
CONFIG_FEATURE_UTMP=y
|
||||
CONFIG_FEATURE_WTMP=y
|
||||
CONFIG_FEATURE_PIDFILE=y
|
||||
# CONFIG_FEATURE_SUID is not set
|
||||
# CONFIG_FEATURE_SUID_CONFIG is not set
|
||||
# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
|
||||
# CONFIG_SELINUX is not set
|
||||
# CONFIG_FEATURE_PREFER_APPLETS is not set
|
||||
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
|
||||
# CONFIG_FEATURE_SYSLOG is not set
|
||||
# CONFIG_FEATURE_HAVE_RPC is not set
|
||||
|
||||
#
|
||||
# Build Options
|
||||
#
|
||||
CONFIG_STATIC=y
|
||||
# CONFIG_PIE is not set
|
||||
# CONFIG_NOMMU is not set
|
||||
# CONFIG_BUILD_LIBBUSYBOX is not set
|
||||
# CONFIG_FEATURE_INDIVIDUAL is not set
|
||||
# CONFIG_FEATURE_SHARED_BUSYBOX is not set
|
||||
CONFIG_LFS=y
|
||||
CONFIG_CROSS_COMPILER_PREFIX="i486-linux-uclibc-"
|
||||
CONFIG_EXTRA_CFLAGS=""
|
||||
|
||||
#
|
||||
# Debugging Options
|
||||
#
|
||||
# CONFIG_DEBUG is not set
|
||||
# CONFIG_DEBUG_PESSIMIZE is not set
|
||||
CONFIG_WERROR=y
|
||||
CONFIG_NO_DEBUG_LIB=y
|
||||
# CONFIG_DMALLOC is not set
|
||||
# CONFIG_EFENCE is not set
|
||||
|
||||
#
|
||||
# Installation Options
|
||||
#
|
||||
# CONFIG_INSTALL_NO_USR is not set
|
||||
CONFIG_INSTALL_APPLET_SYMLINKS=y
|
||||
# CONFIG_INSTALL_APPLET_HARDLINKS is not set
|
||||
# CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS is not set
|
||||
# CONFIG_INSTALL_APPLET_DONT is not set
|
||||
# CONFIG_INSTALL_SH_APPLET_SYMLINK is not set
|
||||
# CONFIG_INSTALL_SH_APPLET_HARDLINK is not set
|
||||
# CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER is not set
|
||||
CONFIG_PREFIX="./_install"
|
||||
|
||||
#
|
||||
# Busybox Library Tuning
|
||||
#
|
||||
CONFIG_PASSWORD_MINLEN=6
|
||||
CONFIG_MD5_SIZE_VS_SPEED=2
|
||||
CONFIG_FEATURE_FAST_TOP=y
|
||||
# CONFIG_FEATURE_ETC_NETWORKS is not set
|
||||
CONFIG_FEATURE_EDITING=y
|
||||
CONFIG_FEATURE_EDITING_MAX_LEN=1024
|
||||
CONFIG_FEATURE_EDITING_VI=y
|
||||
CONFIG_FEATURE_EDITING_HISTORY=15
|
||||
# CONFIG_FEATURE_EDITING_SAVEHISTORY is not set
|
||||
CONFIG_FEATURE_TAB_COMPLETION=y
|
||||
CONFIG_FEATURE_USERNAME_COMPLETION=y
|
||||
CONFIG_FEATURE_EDITING_FANCY_PROMPT=y
|
||||
CONFIG_FEATURE_EDITING_ASK_TERMINAL=y
|
||||
CONFIG_FEATURE_NON_POSIX_CP=y
|
||||
# CONFIG_FEATURE_VERBOSE_CP_MESSAGE is not set
|
||||
CONFIG_FEATURE_COPYBUF_KB=64
|
||||
CONFIG_MONOTONIC_SYSCALL=y
|
||||
# CONFIG_IOCTL_HEX2STR_ERROR is not set
|
||||
CONFIG_FEATURE_HWIB=y
|
||||
|
||||
#
|
||||
# Applets
|
||||
#
|
||||
|
||||
#
|
||||
# Archival Utilities
|
||||
#
|
||||
CONFIG_FEATURE_SEAMLESS_XZ=y
|
||||
CONFIG_FEATURE_SEAMLESS_LZMA=y
|
||||
CONFIG_FEATURE_SEAMLESS_BZ2=y
|
||||
CONFIG_FEATURE_SEAMLESS_GZ=y
|
||||
CONFIG_FEATURE_SEAMLESS_Z=y
|
||||
# CONFIG_AR is not set
|
||||
# CONFIG_FEATURE_AR_LONG_FILENAMES is not set
|
||||
# CONFIG_FEATURE_AR_CREATE is not set
|
||||
# CONFIG_BUNZIP2 is not set
|
||||
# CONFIG_BZIP2 is not set
|
||||
# CONFIG_CPIO is not set
|
||||
# CONFIG_FEATURE_CPIO_O is not set
|
||||
# CONFIG_FEATURE_CPIO_P is not set
|
||||
# CONFIG_DPKG is not set
|
||||
# CONFIG_DPKG_DEB is not set
|
||||
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
|
||||
# CONFIG_GUNZIP is not set
|
||||
# CONFIG_GZIP is not set
|
||||
# CONFIG_FEATURE_GZIP_LONG_OPTIONS is not set
|
||||
# CONFIG_LZOP is not set
|
||||
# CONFIG_LZOP_COMPR_HIGH is not set
|
||||
# CONFIG_RPM2CPIO is not set
|
||||
# CONFIG_RPM is not set
|
||||
# CONFIG_TAR is not set
|
||||
# CONFIG_FEATURE_TAR_CREATE is not set
|
||||
# CONFIG_FEATURE_TAR_AUTODETECT is not set
|
||||
# CONFIG_FEATURE_TAR_FROM is not set
|
||||
# CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY is not set
|
||||
# CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY is not set
|
||||
# CONFIG_FEATURE_TAR_GNU_EXTENSIONS is not set
|
||||
# CONFIG_FEATURE_TAR_LONG_OPTIONS is not set
|
||||
# CONFIG_FEATURE_TAR_UNAME_GNAME is not set
|
||||
# CONFIG_FEATURE_TAR_NOPRESERVE_TIME is not set
|
||||
# CONFIG_FEATURE_TAR_SELINUX is not set
|
||||
# CONFIG_UNCOMPRESS is not set
|
||||
# CONFIG_UNLZMA is not set
|
||||
# CONFIG_FEATURE_LZMA_FAST is not set
|
||||
# CONFIG_LZMA is not set
|
||||
# CONFIG_UNXZ is not set
|
||||
# CONFIG_XZ is not set
|
||||
# CONFIG_UNZIP is not set
|
||||
|
||||
#
|
||||
# Coreutils
|
||||
#
|
||||
CONFIG_BASENAME=y
|
||||
# CONFIG_CAT is not set
|
||||
# CONFIG_DATE is not set
|
||||
# CONFIG_FEATURE_DATE_ISOFMT is not set
|
||||
# CONFIG_FEATURE_DATE_NANO is not set
|
||||
# CONFIG_FEATURE_DATE_COMPAT is not set
|
||||
# CONFIG_TEST is not set
|
||||
# CONFIG_FEATURE_TEST_64 is not set
|
||||
# CONFIG_TR is not set
|
||||
# CONFIG_FEATURE_TR_CLASSES is not set
|
||||
# CONFIG_FEATURE_TR_EQUIV is not set
|
||||
# CONFIG_CAL is not set
|
||||
# CONFIG_CATV is not set
|
||||
# CONFIG_CHGRP is not set
|
||||
# CONFIG_CHMOD is not set
|
||||
# CONFIG_CHOWN is not set
|
||||
# CONFIG_FEATURE_CHOWN_LONG_OPTIONS is not set
|
||||
# CONFIG_CHROOT is not set
|
||||
# CONFIG_CKSUM is not set
|
||||
# CONFIG_COMM is not set
|
||||
# CONFIG_CP is not set
|
||||
# CONFIG_FEATURE_CP_LONG_OPTIONS is not set
|
||||
# CONFIG_CUT is not set
|
||||
# CONFIG_DD is not set
|
||||
# CONFIG_FEATURE_DD_SIGNAL_HANDLING is not set
|
||||
# CONFIG_FEATURE_DD_THIRD_STATUS_LINE is not set
|
||||
# CONFIG_FEATURE_DD_IBS_OBS is not set
|
||||
# CONFIG_DF is not set
|
||||
# CONFIG_FEATURE_DF_FANCY is not set
|
||||
# CONFIG_DIRNAME is not set
|
||||
# CONFIG_DOS2UNIX is not set
|
||||
# CONFIG_UNIX2DOS is not set
|
||||
# CONFIG_DU is not set
|
||||
# CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K is not set
|
||||
# CONFIG_ECHO is not set
|
||||
# CONFIG_FEATURE_FANCY_ECHO is not set
|
||||
# CONFIG_ENV is not set
|
||||
# CONFIG_FEATURE_ENV_LONG_OPTIONS is not set
|
||||
# CONFIG_EXPAND is not set
|
||||
# CONFIG_FEATURE_EXPAND_LONG_OPTIONS is not set
|
||||
# CONFIG_EXPR is not set
|
||||
# CONFIG_EXPR_MATH_SUPPORT_64 is not set
|
||||
CONFIG_FALSE=y
|
||||
# CONFIG_FOLD is not set
|
||||
# CONFIG_FSYNC is not set
|
||||
# CONFIG_HEAD is not set
|
||||
# CONFIG_FEATURE_FANCY_HEAD is not set
|
||||
# CONFIG_HOSTID is not set
|
||||
# CONFIG_ID is not set
|
||||
# CONFIG_INSTALL is not set
|
||||
# CONFIG_FEATURE_INSTALL_LONG_OPTIONS is not set
|
||||
# CONFIG_LENGTH is not set
|
||||
# CONFIG_LN is not set
|
||||
# CONFIG_LOGNAME is not set
|
||||
# CONFIG_LS is not set
|
||||
# CONFIG_FEATURE_LS_FILETYPES is not set
|
||||
# CONFIG_FEATURE_LS_FOLLOWLINKS is not set
|
||||
# CONFIG_FEATURE_LS_RECURSIVE is not set
|
||||
# CONFIG_FEATURE_LS_SORTFILES is not set
|
||||
# CONFIG_FEATURE_LS_TIMESTAMPS is not set
|
||||
# CONFIG_FEATURE_LS_USERNAME is not set
|
||||
# CONFIG_FEATURE_LS_COLOR is not set
|
||||
# CONFIG_FEATURE_LS_COLOR_IS_DEFAULT is not set
|
||||
# CONFIG_MD5SUM is not set
|
||||
# CONFIG_MKDIR is not set
|
||||
# CONFIG_FEATURE_MKDIR_LONG_OPTIONS is not set
|
||||
# CONFIG_MKFIFO is not set
|
||||
# CONFIG_MKNOD is not set
|
||||
# CONFIG_MV is not set
|
||||
# CONFIG_FEATURE_MV_LONG_OPTIONS is not set
|
||||
# CONFIG_NICE is not set
|
||||
# CONFIG_NOHUP is not set
|
||||
# CONFIG_OD is not set
|
||||
# CONFIG_PRINTENV is not set
|
||||
# CONFIG_PRINTF is not set
|
||||
# CONFIG_PWD is not set
|
||||
# CONFIG_READLINK is not set
|
||||
# CONFIG_FEATURE_READLINK_FOLLOW is not set
|
||||
# CONFIG_REALPATH is not set
|
||||
# CONFIG_RM is not set
|
||||
# CONFIG_RMDIR is not set
|
||||
# CONFIG_FEATURE_RMDIR_LONG_OPTIONS is not set
|
||||
# CONFIG_SEQ is not set
|
||||
# CONFIG_SHA1SUM is not set
|
||||
# CONFIG_SHA256SUM is not set
|
||||
# CONFIG_SHA512SUM is not set
|
||||
# CONFIG_SLEEP is not set
|
||||
# CONFIG_FEATURE_FANCY_SLEEP is not set
|
||||
# CONFIG_FEATURE_FLOAT_SLEEP is not set
|
||||
# CONFIG_SORT is not set
|
||||
# CONFIG_FEATURE_SORT_BIG is not set
|
||||
# CONFIG_SPLIT is not set
|
||||
# CONFIG_FEATURE_SPLIT_FANCY is not set
|
||||
# CONFIG_STAT is not set
|
||||
# CONFIG_FEATURE_STAT_FORMAT is not set
|
||||
# CONFIG_STTY is not set
|
||||
# CONFIG_SUM is not set
|
||||
# CONFIG_SYNC is not set
|
||||
# CONFIG_TAC is not set
|
||||
# CONFIG_TAIL is not set
|
||||
# CONFIG_FEATURE_FANCY_TAIL is not set
|
||||
# CONFIG_TEE is not set
|
||||
# CONFIG_FEATURE_TEE_USE_BLOCK_IO is not set
|
||||
# CONFIG_TOUCH is not set
|
||||
CONFIG_TRUE=y
|
||||
# CONFIG_TTY is not set
|
||||
# CONFIG_UNAME is not set
|
||||
# CONFIG_UNEXPAND is not set
|
||||
# CONFIG_FEATURE_UNEXPAND_LONG_OPTIONS is not set
|
||||
# CONFIG_UNIQ is not set
|
||||
# CONFIG_USLEEP is not set
|
||||
# CONFIG_UUDECODE is not set
|
||||
# CONFIG_UUENCODE is not set
|
||||
# CONFIG_WC is not set
|
||||
# CONFIG_FEATURE_WC_LARGE is not set
|
||||
# CONFIG_WHO is not set
|
||||
# CONFIG_WHOAMI is not set
|
||||
# CONFIG_YES is not set
|
||||
# CONFIG_FEATURE_PRESERVE_HARDLINKS is not set
|
||||
# CONFIG_FEATURE_AUTOWIDTH is not set
|
||||
# CONFIG_FEATURE_HUMAN_READABLE is not set
|
||||
# CONFIG_FEATURE_MD5_SHA1_SUM_CHECK is not set
|
||||
|
||||
#
|
||||
# Console Utilities
|
||||
#
|
||||
# CONFIG_CHVT is not set
|
||||
# CONFIG_FGCONSOLE is not set
|
||||
# CONFIG_CLEAR is not set
|
||||
# CONFIG_DEALLOCVT is not set
|
||||
# CONFIG_DUMPKMAP is not set
|
||||
# CONFIG_KBD_MODE is not set
|
||||
# CONFIG_LOADFONT is not set
|
||||
# CONFIG_LOADKMAP is not set
|
||||
# CONFIG_OPENVT is not set
|
||||
# CONFIG_RESET is not set
|
||||
# CONFIG_RESIZE is not set
|
||||
# CONFIG_FEATURE_RESIZE_PRINT is not set
|
||||
# CONFIG_SETCONSOLE is not set
|
||||
# CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS is not set
|
||||
# CONFIG_SETFONT is not set
|
||||
# CONFIG_FEATURE_SETFONT_TEXTUAL_MAP is not set
|
||||
CONFIG_DEFAULT_SETFONT_DIR=""
|
||||
# CONFIG_SETKEYCODES is not set
|
||||
# CONFIG_SETLOGCONS is not set
|
||||
# CONFIG_SHOWKEY is not set
|
||||
# CONFIG_FEATURE_LOADFONT_PSF2 is not set
|
||||
# CONFIG_FEATURE_LOADFONT_RAW is not set
|
||||
|
||||
#
|
||||
# Debian Utilities
|
||||
#
|
||||
# CONFIG_MKTEMP is not set
|
||||
CONFIG_PIPE_PROGRESS=y
|
||||
# CONFIG_RUN_PARTS is not set
|
||||
# CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS is not set
|
||||
# CONFIG_FEATURE_RUN_PARTS_FANCY is not set
|
||||
# CONFIG_START_STOP_DAEMON is not set
|
||||
# CONFIG_FEATURE_START_STOP_DAEMON_FANCY is not set
|
||||
# CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS is not set
|
||||
# CONFIG_WHICH is not set
|
||||
|
||||
#
|
||||
# Editors
|
||||
#
|
||||
# CONFIG_AWK is not set
|
||||
# CONFIG_FEATURE_AWK_LIBM is not set
|
||||
# CONFIG_CMP is not set
|
||||
# CONFIG_DIFF is not set
|
||||
# CONFIG_FEATURE_DIFF_LONG_OPTIONS is not set
|
||||
# CONFIG_FEATURE_DIFF_DIR is not set
|
||||
# CONFIG_ED is not set
|
||||
# CONFIG_PATCH is not set
|
||||
# CONFIG_SED is not set
|
||||
# CONFIG_VI is not set
|
||||
CONFIG_FEATURE_VI_MAX_LEN=0
|
||||
# CONFIG_FEATURE_VI_8BIT is not set
|
||||
# CONFIG_FEATURE_VI_COLON is not set
|
||||
# CONFIG_FEATURE_VI_YANKMARK is not set
|
||||
# CONFIG_FEATURE_VI_SEARCH is not set
|
||||
# CONFIG_FEATURE_VI_USE_SIGNALS is not set
|
||||
# CONFIG_FEATURE_VI_DOT_CMD is not set
|
||||
# CONFIG_FEATURE_VI_READONLY is not set
|
||||
# CONFIG_FEATURE_VI_SETOPTS is not set
|
||||
# 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
|
||||
|
||||
#
|
||||
# Finding Utilities
|
||||
#
|
||||
# CONFIG_FIND is not set
|
||||
# CONFIG_FEATURE_FIND_PRINT0 is not set
|
||||
# CONFIG_FEATURE_FIND_MTIME is not set
|
||||
# CONFIG_FEATURE_FIND_MMIN is not set
|
||||
# CONFIG_FEATURE_FIND_PERM is not set
|
||||
# CONFIG_FEATURE_FIND_TYPE is not set
|
||||
# CONFIG_FEATURE_FIND_XDEV is not set
|
||||
# CONFIG_FEATURE_FIND_MAXDEPTH is not set
|
||||
# CONFIG_FEATURE_FIND_NEWER is not set
|
||||
# CONFIG_FEATURE_FIND_INUM is not set
|
||||
# CONFIG_FEATURE_FIND_EXEC is not set
|
||||
# CONFIG_FEATURE_FIND_USER is not set
|
||||
# CONFIG_FEATURE_FIND_GROUP is not set
|
||||
# CONFIG_FEATURE_FIND_NOT is not set
|
||||
# CONFIG_FEATURE_FIND_DEPTH is not set
|
||||
# CONFIG_FEATURE_FIND_PAREN is not set
|
||||
# CONFIG_FEATURE_FIND_SIZE is not set
|
||||
# CONFIG_FEATURE_FIND_PRUNE is not set
|
||||
# CONFIG_FEATURE_FIND_DELETE is not set
|
||||
# CONFIG_FEATURE_FIND_PATH is not set
|
||||
# CONFIG_FEATURE_FIND_REGEX is not set
|
||||
# CONFIG_FEATURE_FIND_CONTEXT is not set
|
||||
# CONFIG_FEATURE_FIND_LINKS is not set
|
||||
# CONFIG_GREP is not set
|
||||
# CONFIG_FEATURE_GREP_EGREP_ALIAS is not set
|
||||
# CONFIG_FEATURE_GREP_FGREP_ALIAS is not set
|
||||
# CONFIG_FEATURE_GREP_CONTEXT is not set
|
||||
# CONFIG_XARGS is not set
|
||||
# CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION is not set
|
||||
# CONFIG_FEATURE_XARGS_SUPPORT_QUOTES is not set
|
||||
# CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT is not set
|
||||
# CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM is not set
|
||||
|
||||
#
|
||||
# Init Utilities
|
||||
#
|
||||
# CONFIG_INIT is not set
|
||||
# CONFIG_FEATURE_USE_INITTAB is not set
|
||||
# CONFIG_FEATURE_KILL_REMOVED is not set
|
||||
CONFIG_FEATURE_KILL_DELAY=0
|
||||
# CONFIG_FEATURE_INIT_SCTTY is not set
|
||||
# CONFIG_FEATURE_INIT_SYSLOG is not set
|
||||
# CONFIG_FEATURE_EXTRA_QUIET is not set
|
||||
# CONFIG_FEATURE_INIT_COREDUMPS is not set
|
||||
# CONFIG_FEATURE_INITRD is not set
|
||||
# CONFIG_HALT is not set
|
||||
# CONFIG_FEATURE_CALL_TELINIT is not set
|
||||
CONFIG_TELINIT_PATH=""
|
||||
# CONFIG_MESG is not set
|
||||
# CONFIG_BOOTCHARTD is not set
|
||||
|
||||
#
|
||||
# Login/Password Management Utilities
|
||||
#
|
||||
# CONFIG_FEATURE_SHADOWPASSWDS is not set
|
||||
# CONFIG_USE_BB_PWD_GRP is not set
|
||||
# CONFIG_USE_BB_SHADOW is not set
|
||||
# CONFIG_USE_BB_CRYPT is not set
|
||||
# CONFIG_USE_BB_CRYPT_SHA is not set
|
||||
# CONFIG_ADDGROUP is not set
|
||||
# CONFIG_FEATURE_ADDGROUP_LONG_OPTIONS is not set
|
||||
# CONFIG_FEATURE_ADDUSER_TO_GROUP is not set
|
||||
# CONFIG_DELGROUP is not set
|
||||
# CONFIG_FEATURE_DEL_USER_FROM_GROUP is not set
|
||||
# CONFIG_FEATURE_CHECK_NAMES is not set
|
||||
# CONFIG_ADDUSER is not set
|
||||
# CONFIG_FEATURE_ADDUSER_LONG_OPTIONS is not set
|
||||
CONFIG_FIRST_SYSTEM_ID=0
|
||||
CONFIG_LAST_SYSTEM_ID=0
|
||||
# CONFIG_DELUSER is not set
|
||||
# CONFIG_GETTY is not set
|
||||
# CONFIG_LOGIN is not set
|
||||
# CONFIG_PAM is not set
|
||||
# CONFIG_LOGIN_SCRIPTS is not set
|
||||
# CONFIG_FEATURE_NOLOGIN is not set
|
||||
# CONFIG_FEATURE_SECURETTY is not set
|
||||
# CONFIG_PASSWD is not set
|
||||
# CONFIG_FEATURE_PASSWD_WEAK_CHECK is not set
|
||||
# CONFIG_CRYPTPW is not set
|
||||
# CONFIG_CHPASSWD is not set
|
||||
# CONFIG_SU is not set
|
||||
# CONFIG_FEATURE_SU_SYSLOG is not set
|
||||
# CONFIG_FEATURE_SU_CHECKS_SHELLS is not set
|
||||
# CONFIG_SULOGIN is not set
|
||||
# CONFIG_VLOCK is not set
|
||||
|
||||
#
|
||||
# Linux Ext2 FS Progs
|
||||
#
|
||||
# CONFIG_CHATTR is not set
|
||||
# CONFIG_FSCK is not set
|
||||
# CONFIG_LSATTR is not set
|
||||
# CONFIG_TUNE2FS is not set
|
||||
|
||||
#
|
||||
# Linux Module Utilities
|
||||
#
|
||||
# CONFIG_MODINFO is not set
|
||||
# CONFIG_MODPROBE_SMALL is not set
|
||||
# CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE is not set
|
||||
# CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED is not set
|
||||
# CONFIG_INSMOD is not set
|
||||
# CONFIG_RMMOD is not set
|
||||
# CONFIG_LSMOD is not set
|
||||
# CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
|
||||
# CONFIG_MODPROBE is not set
|
||||
# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
|
||||
# CONFIG_DEPMOD is not set
|
||||
|
||||
#
|
||||
# Options common to multiple modutils
|
||||
#
|
||||
# CONFIG_FEATURE_2_4_MODULES is not set
|
||||
# CONFIG_FEATURE_INSMOD_TRY_MMAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
|
||||
# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
|
||||
# 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=""
|
||||
CONFIG_DEFAULT_DEPMOD_FILE=""
|
||||
|
||||
#
|
||||
# Linux System Utilities
|
||||
#
|
||||
# CONFIG_ACPID is not set
|
||||
# CONFIG_FEATURE_ACPID_COMPAT is not set
|
||||
# CONFIG_BLKID is not set
|
||||
# CONFIG_DMESG is not set
|
||||
# CONFIG_FEATURE_DMESG_PRETTY is not set
|
||||
# CONFIG_FBSET is not set
|
||||
# CONFIG_FEATURE_FBSET_FANCY is not set
|
||||
# CONFIG_FEATURE_FBSET_READMODE is not set
|
||||
# CONFIG_FDFLUSH is not set
|
||||
# CONFIG_FDFORMAT is not set
|
||||
# CONFIG_FDISK is not set
|
||||
CONFIG_FDISK_SUPPORT_LARGE_DISKS=y
|
||||
# CONFIG_FEATURE_FDISK_WRITABLE is not set
|
||||
# CONFIG_FEATURE_AIX_LABEL is not set
|
||||
# CONFIG_FEATURE_SGI_LABEL is not set
|
||||
# CONFIG_FEATURE_SUN_LABEL is not set
|
||||
# CONFIG_FEATURE_OSF_LABEL is not set
|
||||
# CONFIG_FEATURE_FDISK_ADVANCED is not set
|
||||
# CONFIG_FINDFS is not set
|
||||
# CONFIG_FLOCK is not set
|
||||
# CONFIG_FREERAMDISK is not set
|
||||
# CONFIG_FSCK_MINIX is not set
|
||||
# CONFIG_MKFS_EXT2 is not set
|
||||
# CONFIG_MKFS_MINIX is not set
|
||||
# CONFIG_FEATURE_MINIX2 is not set
|
||||
# CONFIG_MKFS_REISER is not set
|
||||
# CONFIG_MKFS_VFAT is not set
|
||||
# CONFIG_GETOPT is not set
|
||||
# CONFIG_FEATURE_GETOPT_LONG is not set
|
||||
# CONFIG_HEXDUMP is not set
|
||||
# CONFIG_FEATURE_HEXDUMP_REVERSE is not set
|
||||
# CONFIG_HD is not set
|
||||
# CONFIG_HWCLOCK is not set
|
||||
# CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS is not set
|
||||
# CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS is not set
|
||||
# CONFIG_IPCRM is not set
|
||||
# CONFIG_IPCS is not set
|
||||
# CONFIG_LOSETUP is not set
|
||||
# CONFIG_LSPCI is not set
|
||||
# CONFIG_LSUSB is not set
|
||||
# CONFIG_MDEV is not set
|
||||
# CONFIG_FEATURE_MDEV_CONF is not set
|
||||
# CONFIG_FEATURE_MDEV_RENAME is not set
|
||||
# CONFIG_FEATURE_MDEV_RENAME_REGEXP is not set
|
||||
# CONFIG_FEATURE_MDEV_EXEC is not set
|
||||
# CONFIG_FEATURE_MDEV_LOAD_FIRMWARE is not set
|
||||
# CONFIG_MKSWAP is not set
|
||||
# CONFIG_FEATURE_MKSWAP_UUID is not set
|
||||
# CONFIG_MORE is not set
|
||||
# CONFIG_FEATURE_USE_TERMIOS is not set
|
||||
CONFIG_VOLUMEID=y
|
||||
# CONFIG_FEATURE_VOLUMEID_EXT is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_BTRFS is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_REISERFS is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_FAT is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_HFS is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_JFS is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_XFS is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_NTFS is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_ISO9660 is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_UDF is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_LUKS is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_LINUXSWAP is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_CRAMFS is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_ROMFS is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_SYSV is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_OCFS2 is not set
|
||||
# CONFIG_FEATURE_VOLUMEID_LINUXRAID is not set
|
||||
# CONFIG_MOUNT is not set
|
||||
# CONFIG_FEATURE_MOUNT_FAKE is not set
|
||||
# CONFIG_FEATURE_MOUNT_VERBOSE is not set
|
||||
# CONFIG_FEATURE_MOUNT_HELPERS is not set
|
||||
# CONFIG_FEATURE_MOUNT_LABEL is not set
|
||||
# CONFIG_FEATURE_MOUNT_NFS is not set
|
||||
# CONFIG_FEATURE_MOUNT_CIFS is not set
|
||||
# CONFIG_FEATURE_MOUNT_FLAGS is not set
|
||||
# CONFIG_FEATURE_MOUNT_FSTAB is not set
|
||||
# CONFIG_PIVOT_ROOT is not set
|
||||
# CONFIG_RDATE is not set
|
||||
# CONFIG_RDEV is not set
|
||||
# CONFIG_READPROFILE is not set
|
||||
# CONFIG_RTCWAKE is not set
|
||||
# CONFIG_SCRIPT is not set
|
||||
# CONFIG_SCRIPTREPLAY is not set
|
||||
# CONFIG_SETARCH is not set
|
||||
# CONFIG_SWAPONOFF is not set
|
||||
# CONFIG_FEATURE_SWAPON_PRI is not set
|
||||
# CONFIG_SWITCH_ROOT is not set
|
||||
# CONFIG_UMOUNT is not set
|
||||
# CONFIG_FEATURE_UMOUNT_ALL is not set
|
||||
# CONFIG_FEATURE_MOUNT_LOOP is not set
|
||||
# CONFIG_FEATURE_MOUNT_LOOP_CREATE is not set
|
||||
# CONFIG_FEATURE_MTAB_SUPPORT is not set
|
||||
|
||||
#
|
||||
# Miscellaneous Utilities
|
||||
#
|
||||
# CONFIG_ADJTIMEX is not set
|
||||
CONFIG_BBCONFIG=y
|
||||
# CONFIG_BEEP is not set
|
||||
CONFIG_FEATURE_BEEP_FREQ=0
|
||||
CONFIG_FEATURE_BEEP_LENGTH_MS=0
|
||||
# CONFIG_CHAT is not set
|
||||
# CONFIG_FEATURE_CHAT_NOFAIL is not set
|
||||
# CONFIG_FEATURE_CHAT_TTY_HIFI is not set
|
||||
# CONFIG_FEATURE_CHAT_IMPLICIT_CR is not set
|
||||
# CONFIG_FEATURE_CHAT_SWALLOW_OPTS is not set
|
||||
# CONFIG_FEATURE_CHAT_SEND_ESCAPES is not set
|
||||
# CONFIG_FEATURE_CHAT_VAR_ABORT_LEN is not set
|
||||
# CONFIG_FEATURE_CHAT_CLR_ABORT is not set
|
||||
# CONFIG_CHRT is not set
|
||||
# CONFIG_CROND is not set
|
||||
# CONFIG_FEATURE_CROND_D is not set
|
||||
# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set
|
||||
CONFIG_FEATURE_CROND_DIR=""
|
||||
# CONFIG_CRONTAB is not set
|
||||
# CONFIG_DC is not set
|
||||
# CONFIG_FEATURE_DC_LIBM is not set
|
||||
# CONFIG_DEVFSD is not set
|
||||
# CONFIG_DEVFSD_MODLOAD is not set
|
||||
# CONFIG_DEVFSD_FG_NP is not set
|
||||
# CONFIG_DEVFSD_VERBOSE is not set
|
||||
# CONFIG_FEATURE_DEVFS is not set
|
||||
# CONFIG_DEVMEM is not set
|
||||
# CONFIG_EJECT is not set
|
||||
# CONFIG_FEATURE_EJECT_SCSI is not set
|
||||
# CONFIG_FBSPLASH is not set
|
||||
# CONFIG_FLASHCP is not set
|
||||
# CONFIG_FLASH_LOCK is not set
|
||||
# CONFIG_FLASH_UNLOCK is not set
|
||||
# CONFIG_FLASH_ERASEALL is not set
|
||||
# CONFIG_IONICE is not set
|
||||
# CONFIG_INOTIFYD is not set
|
||||
# CONFIG_LAST is not set
|
||||
# CONFIG_FEATURE_LAST_SMALL is not set
|
||||
# CONFIG_FEATURE_LAST_FANCY is not set
|
||||
# CONFIG_LESS is not set
|
||||
CONFIG_FEATURE_LESS_MAXLINES=0
|
||||
# CONFIG_FEATURE_LESS_BRACKETS is not set
|
||||
# CONFIG_FEATURE_LESS_FLAGS is not set
|
||||
# CONFIG_FEATURE_LESS_MARKS is not set
|
||||
# CONFIG_FEATURE_LESS_REGEXP is not set
|
||||
# CONFIG_FEATURE_LESS_WINCH is not set
|
||||
# CONFIG_FEATURE_LESS_DASHCMD is not set
|
||||
# CONFIG_FEATURE_LESS_LINENUMS is not set
|
||||
# CONFIG_HDPARM is not set
|
||||
# CONFIG_FEATURE_HDPARM_GET_IDENTITY is not set
|
||||
# CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF is not set
|
||||
# CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF is not set
|
||||
# CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET is not set
|
||||
# CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF is not set
|
||||
# CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA is not set
|
||||
# CONFIG_MAKEDEVS is not set
|
||||
# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
|
||||
# CONFIG_FEATURE_MAKEDEVS_TABLE is not set
|
||||
# CONFIG_MAN is not set
|
||||
# CONFIG_MICROCOM is not set
|
||||
# CONFIG_MOUNTPOINT is not set
|
||||
# CONFIG_MT is not set
|
||||
# CONFIG_RAIDAUTORUN is not set
|
||||
# CONFIG_READAHEAD is not set
|
||||
# CONFIG_RFKILL is not set
|
||||
# CONFIG_RUNLEVEL is not set
|
||||
# CONFIG_RX is not set
|
||||
# CONFIG_SETSID is not set
|
||||
# CONFIG_STRINGS is not set
|
||||
# CONFIG_TASKSET is not set
|
||||
# CONFIG_FEATURE_TASKSET_FANCY is not set
|
||||
# CONFIG_TIME is not set
|
||||
# CONFIG_TIMEOUT is not set
|
||||
# CONFIG_TTYSIZE is not set
|
||||
# CONFIG_VOLNAME is not set
|
||||
# CONFIG_WALL is not set
|
||||
# CONFIG_WATCHDOG is not set
|
||||
|
||||
#
|
||||
# Networking Utilities
|
||||
#
|
||||
# CONFIG_FEATURE_IPV6 is not set
|
||||
# CONFIG_FEATURE_UNIX_LOCAL is not set
|
||||
# CONFIG_FEATURE_PREFER_IPV4_ADDRESS is not set
|
||||
# CONFIG_VERBOSE_RESOLUTION_ERRORS is not set
|
||||
# CONFIG_ARP is not set
|
||||
# CONFIG_ARPING is not set
|
||||
# CONFIG_BRCTL is not set
|
||||
# CONFIG_FEATURE_BRCTL_FANCY is not set
|
||||
# CONFIG_FEATURE_BRCTL_SHOW is not set
|
||||
# CONFIG_DNSD is not set
|
||||
# CONFIG_ETHER_WAKE is not set
|
||||
# CONFIG_FAKEIDENTD is not set
|
||||
# CONFIG_FTPD is not set
|
||||
# CONFIG_FEATURE_FTP_WRITE is not set
|
||||
# CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST is not set
|
||||
# CONFIG_FTPGET is not set
|
||||
# CONFIG_FTPPUT is not set
|
||||
# CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS is not set
|
||||
# CONFIG_HOSTNAME is not set
|
||||
# CONFIG_HTTPD is not set
|
||||
# CONFIG_FEATURE_HTTPD_RANGES is not set
|
||||
# CONFIG_FEATURE_HTTPD_USE_SENDFILE is not set
|
||||
# CONFIG_FEATURE_HTTPD_SETUID is not set
|
||||
# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set
|
||||
# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set
|
||||
# CONFIG_FEATURE_HTTPD_CGI is not set
|
||||
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set
|
||||
# CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set
|
||||
# CONFIG_FEATURE_HTTPD_ENCODE_URL_STR is not set
|
||||
# CONFIG_FEATURE_HTTPD_ERROR_PAGES is not set
|
||||
# CONFIG_FEATURE_HTTPD_PROXY is not set
|
||||
# CONFIG_IFCONFIG is not set
|
||||
# CONFIG_FEATURE_IFCONFIG_STATUS is not set
|
||||
# CONFIG_FEATURE_IFCONFIG_SLIP is not set
|
||||
# CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ is not set
|
||||
# CONFIG_FEATURE_IFCONFIG_HW is not set
|
||||
# CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS is not set
|
||||
# CONFIG_IFENSLAVE is not set
|
||||
# CONFIG_IFPLUGD is not set
|
||||
# CONFIG_IFUPDOWN is not set
|
||||
CONFIG_IFUPDOWN_IFSTATE_PATH=""
|
||||
# CONFIG_FEATURE_IFUPDOWN_IP is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IPV4 is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IPV6 is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP is not set
|
||||
# CONFIG_INETD is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set
|
||||
# CONFIG_FEATURE_INETD_RPC is not set
|
||||
# CONFIG_IP is not set
|
||||
# CONFIG_FEATURE_IP_ADDRESS is not set
|
||||
# CONFIG_FEATURE_IP_LINK is not set
|
||||
# CONFIG_FEATURE_IP_ROUTE is not set
|
||||
# CONFIG_FEATURE_IP_TUNNEL is not set
|
||||
# CONFIG_FEATURE_IP_RULE is not set
|
||||
# CONFIG_FEATURE_IP_SHORT_FORMS is not set
|
||||
# CONFIG_FEATURE_IP_RARE_PROTOCOLS is not set
|
||||
# CONFIG_IPADDR is not set
|
||||
# CONFIG_IPLINK is not set
|
||||
# CONFIG_IPROUTE is not set
|
||||
# CONFIG_IPTUNNEL is not set
|
||||
# CONFIG_IPRULE is not set
|
||||
# CONFIG_IPCALC is not set
|
||||
# CONFIG_FEATURE_IPCALC_FANCY is not set
|
||||
# CONFIG_FEATURE_IPCALC_LONG_OPTIONS is not set
|
||||
# CONFIG_NAMEIF is not set
|
||||
# CONFIG_FEATURE_NAMEIF_EXTENDED is not set
|
||||
# CONFIG_NC is not set
|
||||
# CONFIG_NC_SERVER is not set
|
||||
# CONFIG_NC_EXTRA is not set
|
||||
# CONFIG_NETSTAT is not set
|
||||
# CONFIG_FEATURE_NETSTAT_WIDE is not set
|
||||
# CONFIG_FEATURE_NETSTAT_PRG is not set
|
||||
# CONFIG_NSLOOKUP is not set
|
||||
# CONFIG_NTPD is not set
|
||||
# CONFIG_FEATURE_NTPD_SERVER is not set
|
||||
# CONFIG_PING is not set
|
||||
# CONFIG_PING6 is not set
|
||||
# CONFIG_FEATURE_FANCY_PING is not set
|
||||
# CONFIG_PSCAN is not set
|
||||
# CONFIG_ROUTE is not set
|
||||
# CONFIG_SLATTACH is not set
|
||||
# CONFIG_TCPSVD is not set
|
||||
# CONFIG_TELNET is not set
|
||||
# CONFIG_FEATURE_TELNET_TTYPE is not set
|
||||
# CONFIG_FEATURE_TELNET_AUTOLOGIN is not set
|
||||
# CONFIG_TELNETD is not set
|
||||
# CONFIG_FEATURE_TELNETD_STANDALONE is not set
|
||||
# CONFIG_FEATURE_TELNETD_INETD_WAIT is not set
|
||||
# CONFIG_TFTP is not set
|
||||
# CONFIG_TFTPD is not set
|
||||
# CONFIG_FEATURE_TFTP_GET is not set
|
||||
# CONFIG_FEATURE_TFTP_PUT is not set
|
||||
# CONFIG_FEATURE_TFTP_BLOCKSIZE is not set
|
||||
# CONFIG_FEATURE_TFTP_PROGRESS_BAR is not set
|
||||
# CONFIG_TFTP_DEBUG is not set
|
||||
# CONFIG_TRACEROUTE is not set
|
||||
# CONFIG_TRACEROUTE6 is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
|
||||
# CONFIG_TUNCTL is not set
|
||||
# CONFIG_FEATURE_TUNCTL_UG is not set
|
||||
# CONFIG_UDHCPD is not set
|
||||
# CONFIG_DHCPRELAY is not set
|
||||
# CONFIG_DUMPLEASES is not set
|
||||
# CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY is not set
|
||||
CONFIG_DHCPD_LEASES_FILE=""
|
||||
# CONFIG_UDHCPC is not set
|
||||
# CONFIG_FEATURE_UDHCPC_ARPING is not set
|
||||
# CONFIG_FEATURE_UDHCP_PORT is not set
|
||||
CONFIG_UDHCP_DEBUG=0
|
||||
# CONFIG_FEATURE_UDHCP_RFC3397 is not set
|
||||
CONFIG_UDHCPC_DEFAULT_SCRIPT=""
|
||||
CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=0
|
||||
CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS=""
|
||||
# CONFIG_UDPSVD is not set
|
||||
# CONFIG_VCONFIG is not set
|
||||
# CONFIG_WGET is not set
|
||||
# CONFIG_FEATURE_WGET_STATUSBAR is not set
|
||||
# CONFIG_FEATURE_WGET_AUTHENTICATION is not set
|
||||
# CONFIG_FEATURE_WGET_LONG_OPTIONS is not set
|
||||
# CONFIG_ZCIP is not set
|
||||
|
||||
#
|
||||
# Print Utilities
|
||||
#
|
||||
# CONFIG_LPD is not set
|
||||
# CONFIG_LPR is not set
|
||||
# CONFIG_LPQ is not set
|
||||
|
||||
#
|
||||
# Mail Utilities
|
||||
#
|
||||
# CONFIG_MAKEMIME is not set
|
||||
CONFIG_FEATURE_MIME_CHARSET=""
|
||||
# CONFIG_POPMAILDIR is not set
|
||||
# CONFIG_FEATURE_POPMAILDIR_DELIVERY is not set
|
||||
# CONFIG_REFORMIME is not set
|
||||
# CONFIG_FEATURE_REFORMIME_COMPAT is not set
|
||||
# CONFIG_SENDMAIL is not set
|
||||
|
||||
#
|
||||
# Process Utilities
|
||||
#
|
||||
# CONFIG_FREE is not set
|
||||
# CONFIG_FUSER is not set
|
||||
# CONFIG_KILL is not set
|
||||
# CONFIG_KILLALL is not set
|
||||
# CONFIG_KILLALL5 is not set
|
||||
# CONFIG_NMETER is not set
|
||||
# CONFIG_PGREP is not set
|
||||
# CONFIG_PIDOF is not set
|
||||
# CONFIG_FEATURE_PIDOF_SINGLE is not set
|
||||
# CONFIG_FEATURE_PIDOF_OMIT is not set
|
||||
# CONFIG_PKILL is not set
|
||||
# CONFIG_PS is not set
|
||||
# CONFIG_FEATURE_PS_WIDE is not set
|
||||
# CONFIG_FEATURE_PS_TIME is not set
|
||||
# CONFIG_FEATURE_PS_ADDITIONAL_COLUMNS is not set
|
||||
# CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS is not set
|
||||
# CONFIG_RENICE is not set
|
||||
# CONFIG_BB_SYSCTL is not set
|
||||
# CONFIG_TOP is not set
|
||||
# CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE is not set
|
||||
# CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS is not set
|
||||
# CONFIG_FEATURE_TOP_SMP_CPU is not set
|
||||
# CONFIG_FEATURE_TOP_DECIMALS is not set
|
||||
# CONFIG_FEATURE_TOP_SMP_PROCESS is not set
|
||||
# CONFIG_FEATURE_TOPMEM is not set
|
||||
# CONFIG_FEATURE_SHOW_THREADS is not set
|
||||
# CONFIG_UPTIME is not set
|
||||
# CONFIG_WATCH is not set
|
||||
|
||||
#
|
||||
# Runit Utilities
|
||||
#
|
||||
# CONFIG_RUNSV is not set
|
||||
# CONFIG_RUNSVDIR is not set
|
||||
# CONFIG_FEATURE_RUNSVDIR_LOG is not set
|
||||
# CONFIG_SV is not set
|
||||
CONFIG_SV_DEFAULT_SERVICE_DIR=""
|
||||
# CONFIG_SVLOGD is not set
|
||||
# CONFIG_CHPST is not set
|
||||
# CONFIG_SETUIDGID is not set
|
||||
# CONFIG_ENVUIDGID is not set
|
||||
# CONFIG_ENVDIR is not set
|
||||
# CONFIG_SOFTLIMIT is not set
|
||||
# CONFIG_CHCON is not set
|
||||
# CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set
|
||||
# CONFIG_GETENFORCE is not set
|
||||
# CONFIG_GETSEBOOL is not set
|
||||
# CONFIG_LOAD_POLICY is not set
|
||||
# CONFIG_MATCHPATHCON is not set
|
||||
# CONFIG_RESTORECON is not set
|
||||
# CONFIG_RUNCON is not set
|
||||
# CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set
|
||||
# CONFIG_SELINUXENABLED is not set
|
||||
# CONFIG_SETENFORCE is not set
|
||||
# CONFIG_SETFILES is not set
|
||||
# CONFIG_FEATURE_SETFILES_CHECK_OPTION is not set
|
||||
# CONFIG_SETSEBOOL is not set
|
||||
# CONFIG_SESTATUS is not set
|
||||
|
||||
#
|
||||
# Shells
|
||||
#
|
||||
# CONFIG_ASH is not set
|
||||
# CONFIG_ASH_BASH_COMPAT is not set
|
||||
# CONFIG_ASH_JOB_CONTROL is not set
|
||||
# CONFIG_ASH_ALIAS is not set
|
||||
# CONFIG_ASH_GETOPTS is not set
|
||||
# CONFIG_ASH_BUILTIN_ECHO is not set
|
||||
# CONFIG_ASH_BUILTIN_PRINTF is not set
|
||||
# CONFIG_ASH_BUILTIN_TEST is not set
|
||||
# CONFIG_ASH_CMDCMD is not set
|
||||
# CONFIG_ASH_MAIL is not set
|
||||
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
|
||||
# CONFIG_ASH_RANDOM_SUPPORT is not set
|
||||
# CONFIG_ASH_EXPAND_PRMT is not set
|
||||
# CONFIG_HUSH is not set
|
||||
# CONFIG_HUSH_BASH_COMPAT is not set
|
||||
# CONFIG_HUSH_HELP is not set
|
||||
# CONFIG_HUSH_INTERACTIVE is not set
|
||||
# CONFIG_HUSH_JOB is not set
|
||||
# CONFIG_HUSH_TICK is not set
|
||||
# CONFIG_HUSH_IF is not set
|
||||
# CONFIG_HUSH_LOOPS is not set
|
||||
# CONFIG_HUSH_CASE is not set
|
||||
# CONFIG_HUSH_FUNCTIONS is not set
|
||||
# CONFIG_HUSH_LOCAL is not set
|
||||
# CONFIG_HUSH_EXPORT_N is not set
|
||||
# CONFIG_HUSH_RANDOM_SUPPORT is not set
|
||||
# CONFIG_FEATURE_SH_IS_ASH is not set
|
||||
# CONFIG_FEATURE_SH_IS_HUSH is not set
|
||||
CONFIG_FEATURE_SH_IS_NONE=y
|
||||
# CONFIG_FEATURE_BASH_IS_ASH is not set
|
||||
# CONFIG_FEATURE_BASH_IS_HUSH is not set
|
||||
CONFIG_FEATURE_BASH_IS_NONE=y
|
||||
# CONFIG_LASH is not set
|
||||
# CONFIG_MSH is not set
|
||||
# CONFIG_SH_MATH_SUPPORT is not set
|
||||
# CONFIG_SH_MATH_SUPPORT_64 is not set
|
||||
# CONFIG_FEATURE_SH_EXTRA_QUIET is not set
|
||||
# CONFIG_FEATURE_SH_STANDALONE is not set
|
||||
# CONFIG_FEATURE_SH_NOFORK is not set
|
||||
# CONFIG_CTTYHACK is not set
|
||||
|
||||
#
|
||||
# System Logging Utilities
|
||||
#
|
||||
# CONFIG_SYSLOGD is not set
|
||||
# CONFIG_FEATURE_ROTATE_LOGFILE is not set
|
||||
# CONFIG_FEATURE_REMOTE_LOG is not set
|
||||
# CONFIG_FEATURE_SYSLOGD_DUP is not set
|
||||
CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=0
|
||||
# CONFIG_FEATURE_IPC_SYSLOG is not set
|
||||
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=0
|
||||
# CONFIG_LOGREAD is not set
|
||||
# CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING is not set
|
||||
# CONFIG_KLOGD is not set
|
||||
# CONFIG_LOGGER is not set
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.15.0.svn
|
||||
# Fri Aug 21 00:14:11 2009
|
||||
# Busybox version: 1.17.0.git
|
||||
# Fri Apr 16 22:25:22 2010
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
@@ -14,6 +14,8 @@ CONFIG_HAVE_DOT_CONFIG=y
|
||||
#
|
||||
# CONFIG_DESKTOP is not set
|
||||
# CONFIG_EXTRA_COMPAT is not set
|
||||
CONFIG_INCLUDE_SUSv2=y
|
||||
# CONFIG_USE_PORTABLE_CODE is not set
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
@@ -22,11 +24,20 @@ CONFIG_FEATURE_VERBOSE_USAGE=y
|
||||
CONFIG_FEATURE_COMPRESS_USAGE=y
|
||||
CONFIG_FEATURE_INSTALLER=y
|
||||
CONFIG_LOCALE_SUPPORT=y
|
||||
# CONFIG_FEATURE_ASSUME_UNICODE is not set
|
||||
CONFIG_UNICODE_SUPPORT=y
|
||||
# CONFIG_UNICODE_USING_LOCALE is not set
|
||||
# CONFIG_FEATURE_CHECK_UNICODE_IN_ENV is not set
|
||||
CONFIG_SUBST_WCHAR=63
|
||||
CONFIG_LAST_SUPPORTED_WCHAR=767
|
||||
# CONFIG_UNICODE_COMBINING_WCHARS is not set
|
||||
# CONFIG_UNICODE_WIDE_WCHARS is not set
|
||||
# CONFIG_UNICODE_BIDI_SUPPORT is not set
|
||||
# CONFIG_UNICODE_NEUTRAL_TABLE is not set
|
||||
CONFIG_LONG_OPTS=y
|
||||
CONFIG_FEATURE_DEVPTS=y
|
||||
# CONFIG_FEATURE_CLEAN_UP is not set
|
||||
CONFIG_FEATURE_UTMP=y
|
||||
CONFIG_FEATURE_WTMP=y
|
||||
CONFIG_FEATURE_PIDFILE=y
|
||||
CONFIG_FEATURE_SUID=y
|
||||
CONFIG_FEATURE_SUID_CONFIG=y
|
||||
@@ -59,7 +70,6 @@ CONFIG_EXTRA_CFLAGS=""
|
||||
CONFIG_NO_DEBUG_LIB=y
|
||||
# CONFIG_DMALLOC is not set
|
||||
# CONFIG_EFENCE is not set
|
||||
CONFIG_INCLUDE_SUSv2=y
|
||||
|
||||
#
|
||||
# Installation Options
|
||||
@@ -95,7 +105,7 @@ CONFIG_FEATURE_NON_POSIX_CP=y
|
||||
CONFIG_FEATURE_COPYBUF_KB=4
|
||||
# CONFIG_MONOTONIC_SYSCALL is not set
|
||||
CONFIG_IOCTL_HEX2STR_ERROR=y
|
||||
CONFIG_FEATURE_HWIB=y
|
||||
# CONFIG_FEATURE_HWIB is not set
|
||||
|
||||
#
|
||||
# Applets
|
||||
@@ -110,6 +120,7 @@ CONFIG_FEATURE_SEAMLESS_GZ=y
|
||||
CONFIG_FEATURE_SEAMLESS_Z=y
|
||||
CONFIG_AR=y
|
||||
CONFIG_FEATURE_AR_LONG_FILENAMES=y
|
||||
CONFIG_FEATURE_AR_CREATE=y
|
||||
CONFIG_BUNZIP2=y
|
||||
CONFIG_BZIP2=y
|
||||
CONFIG_CPIO=y
|
||||
@@ -120,10 +131,11 @@ CONFIG_FEATURE_CPIO_P=y
|
||||
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_GZIP=y
|
||||
CONFIG_FEATURE_GZIP_LONG_OPTIONS=y
|
||||
CONFIG_LZOP=y
|
||||
# CONFIG_LZOP_COMPR_HIGH is not set
|
||||
# CONFIG_RPM2CPIO is not set
|
||||
# CONFIG_RPM is not set
|
||||
CONFIG_RPM2CPIO=y
|
||||
CONFIG_RPM=y
|
||||
CONFIG_TAR=y
|
||||
CONFIG_FEATURE_TAR_CREATE=y
|
||||
CONFIG_FEATURE_TAR_AUTODETECT=y
|
||||
@@ -133,6 +145,8 @@ CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY=y
|
||||
CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
|
||||
CONFIG_FEATURE_TAR_LONG_OPTIONS=y
|
||||
CONFIG_FEATURE_TAR_UNAME_GNAME=y
|
||||
CONFIG_FEATURE_TAR_NOPRESERVE_TIME=y
|
||||
# CONFIG_FEATURE_TAR_SELINUX is not set
|
||||
CONFIG_UNCOMPRESS=y
|
||||
CONFIG_UNLZMA=y
|
||||
CONFIG_FEATURE_LZMA_FAST=y
|
||||
@@ -148,15 +162,19 @@ CONFIG_CATV=y
|
||||
CONFIG_CHGRP=y
|
||||
CONFIG_CHMOD=y
|
||||
CONFIG_CHOWN=y
|
||||
CONFIG_FEATURE_CHOWN_LONG_OPTIONS=y
|
||||
CONFIG_CHROOT=y
|
||||
CONFIG_CKSUM=y
|
||||
CONFIG_COMM=y
|
||||
CONFIG_CP=y
|
||||
CONFIG_FEATURE_CP_LONG_OPTIONS=y
|
||||
CONFIG_CUT=y
|
||||
CONFIG_DATE=y
|
||||
CONFIG_FEATURE_DATE_ISOFMT=y
|
||||
CONFIG_FEATURE_DATE_COMPAT=y
|
||||
CONFIG_DD=y
|
||||
CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
|
||||
CONFIG_FEATURE_DD_THIRD_STATUS_LINE=y
|
||||
CONFIG_FEATURE_DD_IBS_OBS=y
|
||||
CONFIG_DF=y
|
||||
CONFIG_FEATURE_DF_FANCY=y
|
||||
@@ -271,7 +289,7 @@ CONFIG_FEATURE_AUTOWIDTH=y
|
||||
CONFIG_FEATURE_HUMAN_READABLE=y
|
||||
|
||||
#
|
||||
# Common options for md5sum, sha1sum
|
||||
# Common options for md5sum, sha1sum, sha256sum, sha512sum
|
||||
#
|
||||
CONFIG_FEATURE_MD5_SHA1_SUM_CHECK=y
|
||||
|
||||
@@ -298,6 +316,12 @@ CONFIG_SETKEYCODES=y
|
||||
CONFIG_SETLOGCONS=y
|
||||
CONFIG_SHOWKEY=y
|
||||
|
||||
#
|
||||
# Common options for loadfont and setfont
|
||||
#
|
||||
# CONFIG_FEATURE_LOADFONT_PSF2 is not set
|
||||
# CONFIG_FEATURE_LOADFONT_RAW is not set
|
||||
|
||||
#
|
||||
# Debian Utilities
|
||||
#
|
||||
@@ -318,9 +342,8 @@ CONFIG_AWK=y
|
||||
CONFIG_FEATURE_AWK_LIBM=y
|
||||
CONFIG_CMP=y
|
||||
CONFIG_DIFF=y
|
||||
CONFIG_FEATURE_DIFF_BINARY=y
|
||||
CONFIG_FEATURE_DIFF_LONG_OPTIONS=y
|
||||
CONFIG_FEATURE_DIFF_DIR=y
|
||||
CONFIG_FEATURE_DIFF_MINIMAL=y
|
||||
CONFIG_ED=y
|
||||
CONFIG_PATCH=y
|
||||
CONFIG_SED=y
|
||||
@@ -364,6 +387,7 @@ CONFIG_FEATURE_FIND_DELETE=y
|
||||
CONFIG_FEATURE_FIND_PATH=y
|
||||
CONFIG_FEATURE_FIND_REGEX=y
|
||||
# CONFIG_FEATURE_FIND_CONTEXT is not set
|
||||
CONFIG_FEATURE_FIND_LINKS=y
|
||||
CONFIG_GREP=y
|
||||
CONFIG_FEATURE_GREP_EGREP_ALIAS=y
|
||||
CONFIG_FEATURE_GREP_FGREP_ALIAS=y
|
||||
@@ -411,8 +435,6 @@ CONFIG_FIRST_SYSTEM_ID=100
|
||||
CONFIG_LAST_SYSTEM_ID=999
|
||||
CONFIG_DELUSER=y
|
||||
CONFIG_GETTY=y
|
||||
CONFIG_FEATURE_UTMP=y
|
||||
CONFIG_FEATURE_WTMP=y
|
||||
CONFIG_LOGIN=y
|
||||
# CONFIG_PAM is not set
|
||||
CONFIG_LOGIN_SCRIPTS=y
|
||||
@@ -453,6 +475,7 @@ CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
|
||||
# Options common to multiple modutils
|
||||
#
|
||||
# CONFIG_FEATURE_2_4_MODULES is not set
|
||||
# CONFIG_FEATURE_INSMOD_TRY_MMAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
|
||||
# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
|
||||
@@ -486,14 +509,17 @@ CONFIG_FEATURE_FDISK_WRITABLE=y
|
||||
# CONFIG_FEATURE_OSF_LABEL is not set
|
||||
CONFIG_FEATURE_FDISK_ADVANCED=y
|
||||
CONFIG_FINDFS=y
|
||||
# CONFIG_FLOCK is not set
|
||||
CONFIG_FREERAMDISK=y
|
||||
CONFIG_FSCK_MINIX=y
|
||||
# CONFIG_MKFS_EXT2 is not set
|
||||
CONFIG_MKFS_MINIX=y
|
||||
|
||||
#
|
||||
# Minix filesystem support
|
||||
#
|
||||
CONFIG_FEATURE_MINIX2=y
|
||||
# CONFIG_MKFS_REISER is not set
|
||||
CONFIG_MKFS_VFAT=y
|
||||
CONFIG_GETOPT=y
|
||||
CONFIG_FEATURE_GETOPT_LONG=y
|
||||
@@ -506,6 +532,8 @@ CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS=y
|
||||
CONFIG_IPCRM=y
|
||||
CONFIG_IPCS=y
|
||||
CONFIG_LOSETUP=y
|
||||
CONFIG_LSPCI=y
|
||||
CONFIG_LSUSB=y
|
||||
CONFIG_MDEV=y
|
||||
CONFIG_FEATURE_MDEV_CONF=y
|
||||
CONFIG_FEATURE_MDEV_RENAME=y
|
||||
@@ -518,6 +546,7 @@ CONFIG_MORE=y
|
||||
CONFIG_FEATURE_USE_TERMIOS=y
|
||||
CONFIG_VOLUMEID=y
|
||||
CONFIG_FEATURE_VOLUMEID_EXT=y
|
||||
CONFIG_FEATURE_VOLUMEID_BTRFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_REISERFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_FAT=y
|
||||
CONFIG_FEATURE_VOLUMEID_HFS=y
|
||||
@@ -560,6 +589,7 @@ CONFIG_FEATURE_UMOUNT_ALL=y
|
||||
# Common options for mount/umount
|
||||
#
|
||||
CONFIG_FEATURE_MOUNT_LOOP=y
|
||||
# CONFIG_FEATURE_MOUNT_LOOP_CREATE is not set
|
||||
# CONFIG_FEATURE_MTAB_SUPPORT is not set
|
||||
|
||||
#
|
||||
@@ -595,10 +625,11 @@ CONFIG_DEVMEM=y
|
||||
CONFIG_EJECT=y
|
||||
CONFIG_FEATURE_EJECT_SCSI=y
|
||||
CONFIG_FBSPLASH=y
|
||||
# CONFIG_FLASHCP is not set
|
||||
# CONFIG_FLASH_LOCK is not set
|
||||
# CONFIG_FLASH_UNLOCK is not set
|
||||
# CONFIG_FLASH_ERASEALL is not set
|
||||
CONFIG_IONICE=y
|
||||
# CONFIG_IONICE is not set
|
||||
# CONFIG_INOTIFYD is not set
|
||||
CONFIG_LAST=y
|
||||
# CONFIG_FEATURE_LAST_SMALL is not set
|
||||
@@ -627,7 +658,7 @@ CONFIG_MICROCOM=y
|
||||
CONFIG_MOUNTPOINT=y
|
||||
CONFIG_MT=y
|
||||
CONFIG_RAIDAUTORUN=y
|
||||
CONFIG_READAHEAD=y
|
||||
# CONFIG_READAHEAD is not set
|
||||
CONFIG_RUNLEVEL=y
|
||||
CONFIG_RX=y
|
||||
CONFIG_SETSID=y
|
||||
@@ -639,7 +670,7 @@ CONFIG_TIMEOUT=y
|
||||
CONFIG_TTYSIZE=y
|
||||
CONFIG_VOLNAME=y
|
||||
CONFIG_WALL=y
|
||||
CONFIG_WATCHDOG=y
|
||||
# CONFIG_WATCHDOG is not set
|
||||
|
||||
#
|
||||
# Networking Utilities
|
||||
@@ -658,6 +689,7 @@ CONFIG_ETHER_WAKE=y
|
||||
CONFIG_FAKEIDENTD=y
|
||||
CONFIG_FTPD=y
|
||||
CONFIG_FEATURE_FTP_WRITE=y
|
||||
CONFIG_FEATURE_FTPD_ACCEPT_BROKEN_LIST=y
|
||||
CONFIG_FTPGET=y
|
||||
CONFIG_FTPPUT=y
|
||||
CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y
|
||||
@@ -680,7 +712,7 @@ CONFIG_FEATURE_IFCONFIG_SLIP=y
|
||||
CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y
|
||||
CONFIG_FEATURE_IFCONFIG_HW=y
|
||||
CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
|
||||
CONFIG_IFENSLAVE=y
|
||||
# CONFIG_IFENSLAVE is not set
|
||||
CONFIG_IFPLUGD=y
|
||||
CONFIG_IFUPDOWN=y
|
||||
CONFIG_IFUPDOWN_IFSTATE_PATH="/var/run/ifstate"
|
||||
@@ -723,27 +755,35 @@ CONFIG_NETSTAT=y
|
||||
CONFIG_FEATURE_NETSTAT_WIDE=y
|
||||
CONFIG_FEATURE_NETSTAT_PRG=y
|
||||
CONFIG_NSLOOKUP=y
|
||||
CONFIG_NTPD=y
|
||||
CONFIG_FEATURE_NTPD_SERVER=y
|
||||
CONFIG_PING=y
|
||||
CONFIG_PING6=y
|
||||
CONFIG_FEATURE_FANCY_PING=y
|
||||
CONFIG_PSCAN=y
|
||||
CONFIG_ROUTE=y
|
||||
CONFIG_SLATTACH=y
|
||||
CONFIG_TCPSVD=y
|
||||
CONFIG_TELNET=y
|
||||
CONFIG_FEATURE_TELNET_TTYPE=y
|
||||
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
|
||||
CONFIG_TELNETD=y
|
||||
CONFIG_FEATURE_TELNETD_STANDALONE=y
|
||||
CONFIG_FEATURE_TELNETD_INETD_WAIT=y
|
||||
CONFIG_TFTP=y
|
||||
CONFIG_TFTPD=y
|
||||
CONFIG_FEATURE_TFTP_GET=y
|
||||
CONFIG_FEATURE_TFTP_PUT=y
|
||||
CONFIG_FEATURE_TFTP_BLOCKSIZE=y
|
||||
CONFIG_FEATURE_TFTP_PROGRESS_BAR=y
|
||||
# CONFIG_TFTP_DEBUG is not set
|
||||
CONFIG_TRACEROUTE=y
|
||||
CONFIG_TRACEROUTE6=y
|
||||
CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
|
||||
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
|
||||
CONFIG_TUNCTL=y
|
||||
CONFIG_FEATURE_TUNCTL_UG=y
|
||||
CONFIG_UDHCPD=y
|
||||
CONFIG_DHCPRELAY=y
|
||||
CONFIG_DUMPLEASES=y
|
||||
@@ -757,16 +797,13 @@ CONFIG_FEATURE_UDHCP_RFC3397=y
|
||||
CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
|
||||
CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80
|
||||
CONFIG_IFUPDOWN_UDHCPC_CMD_OPTIONS="-R -n"
|
||||
CONFIG_UDPSVD=y
|
||||
CONFIG_VCONFIG=y
|
||||
CONFIG_WGET=y
|
||||
CONFIG_FEATURE_WGET_STATUSBAR=y
|
||||
CONFIG_FEATURE_WGET_AUTHENTICATION=y
|
||||
CONFIG_FEATURE_WGET_LONG_OPTIONS=y
|
||||
CONFIG_ZCIP=y
|
||||
CONFIG_TCPSVD=y
|
||||
CONFIG_TUNCTL=y
|
||||
CONFIG_FEATURE_TUNCTL_UG=y
|
||||
CONFIG_UDPSVD=y
|
||||
|
||||
#
|
||||
# Print Utilities
|
||||
@@ -814,6 +851,7 @@ CONFIG_FEATURE_TOP_SMP_CPU=y
|
||||
CONFIG_FEATURE_TOP_DECIMALS=y
|
||||
CONFIG_FEATURE_TOP_SMP_PROCESS=y
|
||||
CONFIG_FEATURE_TOPMEM=y
|
||||
CONFIG_FEATURE_SHOW_THREADS=y
|
||||
CONFIG_UPTIME=y
|
||||
CONFIG_WATCH=y
|
||||
|
||||
@@ -878,6 +916,7 @@ CONFIG_HUSH_CASE=y
|
||||
CONFIG_HUSH_FUNCTIONS=y
|
||||
CONFIG_HUSH_LOCAL=y
|
||||
CONFIG_HUSH_EXPORT_N=y
|
||||
CONFIG_HUSH_RANDOM_SUPPORT=y
|
||||
# CONFIG_LASH is not set
|
||||
CONFIG_MSH=y
|
||||
CONFIG_SH_MATH_SUPPORT=y
|
||||
@@ -894,6 +933,7 @@ CONFIG_SYSLOGD=y
|
||||
CONFIG_FEATURE_ROTATE_LOGFILE=y
|
||||
CONFIG_FEATURE_REMOTE_LOG=y
|
||||
CONFIG_FEATURE_SYSLOGD_DUP=y
|
||||
CONFIG_FEATURE_SYSLOGD_READ_BUFFER_SIZE=256
|
||||
CONFIG_FEATURE_IPC_SYSLOG=y
|
||||
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=16
|
||||
CONFIG_LOGREAD=y
|
||||
@@ -1,5 +1,8 @@
|
||||
Busybox TODO
|
||||
|
||||
Harvest patches from
|
||||
http://git.openembedded.org/cgit.cgi/openembedded/tree/recipes/busybox/
|
||||
|
||||
Stuff that needs to be done. This is organized by who plans to get around to
|
||||
doing it eventually, but that doesn't mean they "own" the item. If you want to
|
||||
do one of these bounce an email off the person it's listed under to see if they
|
||||
@@ -9,9 +12,6 @@ between your work and theirs. But otherwise, all of these are fair game.
|
||||
Rob Landley suggested this:
|
||||
Implement bb_realpath() that can handle NULL on non-glibc.
|
||||
|
||||
Remove obsolete _() wrapper crud for internationalization we don't do.
|
||||
Figure out where we need utf8 support, and add it.
|
||||
|
||||
sh
|
||||
The command shell situation is a mess. We have two different
|
||||
shells that don't really share any code, and the "standalone shell" doesn't
|
||||
@@ -31,7 +31,7 @@ Rob Landley suggested this:
|
||||
How much internationalization should we do?
|
||||
|
||||
The low hanging fruit is UTF-8 character set support. We should do this.
|
||||
(Vodz pointed out the shell's cmdedit as needing work here. What else?)
|
||||
See TODO_unicode file.
|
||||
|
||||
We also have lots of hardwired english text messages. Consolidating this
|
||||
into some kind of message table not only makes translation easier, but
|
||||
@@ -59,6 +59,7 @@ Rob Landley suggested this:
|
||||
Turning libbb into a real dll is another possibility, especially if libbb
|
||||
could export some of the other library interfaces we've already more or less
|
||||
got the code for (like zlib).
|
||||
|
||||
buildroot - Make a "dogfood" option
|
||||
Busybox 1.1 will be capable of replacing most gnu packages for real world
|
||||
use, such as developing software or in a live CD. It needs wider testing.
|
||||
@@ -78,22 +79,25 @@ Rob Landley suggested this:
|
||||
|
||||
One example of an existing system that does this already is Firmware Linux:
|
||||
http://www.landley.net/code/firmware
|
||||
|
||||
initramfs
|
||||
Busybox should have a sample initramfs build script. This depends on
|
||||
bbsh, mdev, and switch_root.
|
||||
|
||||
mkdep
|
||||
Write a mkdep that doesn't segfault if there's a directory it doesn't
|
||||
have permission to read, isn't based on manually editing the output of
|
||||
lexx and yacc, doesn't make such a mess under include/config, etc.
|
||||
|
||||
Group globals into unions of structures.
|
||||
Go through and turn all the global and static variables into structures,
|
||||
and have all those structures be in a big union shared between processes,
|
||||
so busybox uses less bss. (This is a big win on nommu machines.) See
|
||||
sed.c and mdev.c for examples.
|
||||
|
||||
Go through bugs.busybox.net and close out all of that somehow.
|
||||
This one's open to everybody, but I'll wind up doing it...
|
||||
|
||||
|
||||
Bernhard Reutner-Fischer <busybox@busybox.net> suggests to look at these:
|
||||
New debug options:
|
||||
-Wlarger-than-127
|
||||
@@ -122,9 +126,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
|
||||
---
|
||||
ar
|
||||
Write support!
|
||||
---
|
||||
stty / catv
|
||||
stty's visible() function and catv's guts are identical. Merge them into
|
||||
an appropriate libbb function.
|
||||
@@ -180,40 +181,6 @@ Memory Allocation
|
||||
call free might also be optimized out by the compiler if written right, so
|
||||
we can yank those #ifdefs too, and generally clean up the code.
|
||||
---
|
||||
Switch CONFIG_SYMBOLS to ENABLE_SYMBOLS
|
||||
|
||||
In busybox 1.0 and earlier, configuration was done by CONFIG_SYMBOLS
|
||||
that were either defined or undefined to indicate whether the symbol was
|
||||
selected in the .config file. They were used with #ifdefs, ala:
|
||||
|
||||
#ifdef CONFIG_SYMBOL
|
||||
if (other_test) {
|
||||
do_code();
|
||||
}
|
||||
#endif
|
||||
|
||||
In 1.1, we have new ENABLE_SYMBOLS which are always defined (as 0 or 1),
|
||||
meaning you can still use them for preprocessor tests by replacing
|
||||
"#ifdef CONFIG_SYMBOL" with "#if ENABLE_SYMBOL". But more importantly, we
|
||||
can use them as a true or false test in normal C code:
|
||||
|
||||
if (ENABLE_SYMBOL && other_test) {
|
||||
do_code();
|
||||
}
|
||||
|
||||
(Optimizing away if() statements that resolve to a constant value
|
||||
is known as "dead code elimination", an optimization so old and simple that
|
||||
Turbo Pascal for DOS did it twenty years ago. Even modern mini-compilers
|
||||
like the Tiny C Compiler (tcc) and the Small Device C Compiler (SDCC)
|
||||
perform dead code elimination.)
|
||||
|
||||
Right now, busybox.h is #including both "config.h" (defining the
|
||||
CONFIG_SYMBOLS) and "bb_config.h" (defining the ENABLE_SYMBOLS). At some
|
||||
point in the future, it would be nice to wean ourselves off of the
|
||||
CONFIG versions. (Among other things, some defective build environments
|
||||
leak the Linux kernel's CONFIG_SYMBOLS into the system's standard #include
|
||||
files. We've experienced collisions before.)
|
||||
---
|
||||
FEATURE_CLEAN_UP
|
||||
This is more an unresolved issue than a to-do item. More thought is needed.
|
||||
|
||||
@@ -269,12 +236,7 @@ Minor stuff:
|
||||
---
|
||||
unify progress_meter. wget, flash_eraseall, pipe_progress, fbsplash, setfiles.
|
||||
---
|
||||
support start-stop-daemon -d <chdir-path>
|
||||
|
||||
Code cleanup:
|
||||
|
||||
Replace deprecated functions.
|
||||
|
||||
support start-stop-daemon -d <chdir-path>
|
||||
---
|
||||
vdprintf() -> similar sized functionality
|
||||
---
|
||||
@@ -299,8 +261,6 @@ vdprintf() -> similar sized functionality
|
||||
The first step would to generate a file/matrix what is already archived
|
||||
(also IPV6)
|
||||
|
||||
* ntpdate/ntpd (see ntpclient and openntp for examples)
|
||||
|
||||
* implement 'at'
|
||||
|
||||
* rpcbind (former portmap) or equivalent
|
||||
@@ -314,64 +274,3 @@ vdprintf() -> similar sized functionality
|
||||
most likely there is more
|
||||
|
||||
* even more support for statistics: mpstat, iostat, powertop....
|
||||
|
||||
|
||||
Unicode work needed:
|
||||
|
||||
Unicode support uses libc multibyte functions if LOCALE_SUPPORT is on
|
||||
(in this case, the code will also support many more encodings),
|
||||
or uses a limited subset of re-implemented multibyte functions
|
||||
which only understand "one byte == one char" and unicode.
|
||||
This is useful if you build against uclibc with locale support disabled.
|
||||
|
||||
Unicode-dependent applets must call check_unicode_in_env() when they
|
||||
begin executing.
|
||||
|
||||
Applet code may conditionalize on FEATURE_ASSUME_UNICODE
|
||||
in order to use more efficient code if unicode support is not requested.
|
||||
|
||||
Available functions (if you need more, implement them in libbb/unicode.c
|
||||
so that they work without LOCALE_SUPPORT too):
|
||||
|
||||
int bb_mbstrlen(str) - multibyte-aware strlen
|
||||
size_t mbstowcs(wdest, src, n)
|
||||
size_t wcstombs(dest, wsrc, n)
|
||||
size_t wcrtomb(str, wc, wstate)
|
||||
int iswspace(wc)
|
||||
int iswalnum(wc)
|
||||
int iswpunct(wc)
|
||||
|
||||
Applets which only need to align columns on screen correctly:
|
||||
|
||||
ls - already done, use source as an example
|
||||
df
|
||||
dumpleases
|
||||
lsmod
|
||||
|
||||
Applets which need to account for Unicode chars
|
||||
while processing the output:
|
||||
|
||||
[un]expand
|
||||
fold
|
||||
man
|
||||
watch
|
||||
cut (-b and -c are currently the same, needs fixing)
|
||||
|
||||
These applets need to ensure that unicode input
|
||||
is handled correctly (say, <unicode><backspace> sequence):
|
||||
|
||||
getty, login
|
||||
rm -i
|
||||
unzip (overwrite prompt)
|
||||
|
||||
Viewers/editors are more difficult (many cases to get right).
|
||||
libbb/lineedit.c is an example how to do it:
|
||||
|
||||
less, most, ed, vi
|
||||
awk
|
||||
[ef]grep
|
||||
sed
|
||||
|
||||
Probably needs some specialized work:
|
||||
|
||||
loadkeys
|
||||
@@ -0,0 +1,45 @@
|
||||
Already fixed applets:
|
||||
cal
|
||||
lsmod
|
||||
df
|
||||
dumpleases
|
||||
|
||||
Applets which may need unicode handling (more extensive than sanitizing
|
||||
of filenames in error messages):
|
||||
|
||||
ls - work in progress
|
||||
expand, unexpand - uses unicode_strlen, not scrlen
|
||||
ash, hush through lineedit - uses unicode_strlen, not scrlen
|
||||
top - need to sanitize process args
|
||||
ps - need to sanitize process args
|
||||
less
|
||||
more
|
||||
vi
|
||||
ed
|
||||
cut
|
||||
awk
|
||||
sed
|
||||
tr
|
||||
grep egrep fgrep
|
||||
fold
|
||||
sort
|
||||
head, tail
|
||||
catv - "display nonprinting chars" - what this could mean for unicode?
|
||||
wc
|
||||
chat
|
||||
dumpkmap
|
||||
last - just line up columns
|
||||
man
|
||||
microcom
|
||||
strings
|
||||
watch
|
||||
|
||||
Unsure, may need fixing:
|
||||
|
||||
hostname - do we really want to protect against bad chars in it?
|
||||
patch
|
||||
addgroup, adduser, delgroup, deluser
|
||||
telnet
|
||||
telnetd
|
||||
od
|
||||
printf
|
||||
@@ -27,9 +27,9 @@ HOSTCFLAGS_usage_pod.o = -I$(srctree_slash)include -Iinclude
|
||||
|
||||
applets/applets.o: include/usage_compressed.h include/applet_tables.h
|
||||
|
||||
applets/applet_tables: .config $(srctree_slash)include/applets.h
|
||||
applets/usage: .config $(srctree_slash)include/applets.h
|
||||
applets/usage_pod: .config include/applet_tables.h $(srctree_slash)include/applets.h
|
||||
applets/applet_tables: .config include/applets.h
|
||||
applets/usage: .config include/applets.h
|
||||
applets/usage_pod: .config include/applet_tables.h include/applets.h
|
||||
|
||||
quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
|
||||
cmd_gen_usage_compressed = $(srctree_slash)applets/usage_compressed include/usage_compressed.h applets
|
||||
@@ -38,7 +38,7 @@ include/usage_compressed.h: applets/usage $(srctree_slash)applets/usage_compress
|
||||
$(call cmd,gen_usage_compressed)
|
||||
|
||||
quiet_cmd_gen_applet_tables = GEN include/applet_tables.h
|
||||
cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h
|
||||
cmd_gen_applet_tables = applets/applet_tables include/applet_tables.h include/NUM_APPLETS.h
|
||||
|
||||
include/applet_tables.h: applets/applet_tables
|
||||
$(call cmd,gen_applet_tables)
|
||||
+24
-2
@@ -79,6 +79,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
//printf("#ifndef SKIP_definitions\n");
|
||||
printf("const char applet_names[] ALIGN1 = \"\"\n");
|
||||
for (i = 0; i < NUM_APPLETS; i++) {
|
||||
printf("\"%s\" \"\\0\"\n", applets[i].name);
|
||||
@@ -120,10 +121,31 @@ int main(int argc, char **argv)
|
||||
printf("0x%02x,\n", v);
|
||||
i++;
|
||||
}
|
||||
printf("};\n\n");
|
||||
printf("};\n");
|
||||
#endif
|
||||
|
||||
//printf("#endif /* SKIP_definitions */\n");
|
||||
printf("\n");
|
||||
printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
|
||||
|
||||
if (argv[2]) {
|
||||
char line_old[80];
|
||||
char line_new[80];
|
||||
FILE *fp;
|
||||
|
||||
line_old[0] = 0;
|
||||
fp = fopen(argv[2], "r");
|
||||
if (fp) {
|
||||
fgets(line_old, sizeof(line_old), fp);
|
||||
fclose(fp);
|
||||
}
|
||||
sprintf(line_new, "#define NUM_APPLETS %u\n", NUM_APPLETS);
|
||||
if (strcmp(line_old, line_new) != 0) {
|
||||
fp = fopen(argv[2], "w");
|
||||
if (!fp)
|
||||
return 1;
|
||||
fputs(line_new, fp);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -6,8 +6,6 @@
|
||||
*
|
||||
* Licensed under GPLv2, see file License in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#if ENABLE_BUILD_LIBBUSYBOX
|
||||
|
||||
+27
-6
@@ -5,9 +5,9 @@
|
||||
* Licensed under GPLv2, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Just #include "autoconf.h" doesn't work for builds in separate
|
||||
* object directory */
|
||||
#include "autoconf.h"
|
||||
|
||||
/* Since we can't use platform.h, have to do this again by hand: */
|
||||
@@ -21,14 +21,35 @@
|
||||
# define USE_FOR_MMU(...) __VA_ARGS__
|
||||
#endif
|
||||
|
||||
static const char usage_messages[] = ""
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
#define MAKE_USAGE(aname, usage) { aname, usage },
|
||||
static struct usage_data {
|
||||
const char *aname;
|
||||
const char *usage;
|
||||
} usage_array[] = {
|
||||
#include "applets.h"
|
||||
;
|
||||
};
|
||||
|
||||
static int compare_func(const void *a, const void *b)
|
||||
{
|
||||
const struct usage_data *ua = a;
|
||||
const struct usage_data *ub = b;
|
||||
return strcmp(ua->aname, ub->aname);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
write(STDOUT_FILENO, usage_messages, sizeof(usage_messages));
|
||||
int i;
|
||||
int num_messages = sizeof(usage_array) / sizeof(usage_array[0]);
|
||||
|
||||
if (num_messages == 0)
|
||||
return 0;
|
||||
|
||||
qsort(usage_array,
|
||||
num_messages, sizeof(usage_array[0]),
|
||||
compare_func);
|
||||
for (i = 0; i < num_messages; i++)
|
||||
write(STDOUT_FILENO, usage_array[i].usage, strlen(usage_array[i].usage) + 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -9,12 +9,19 @@ test -x "$loc/usage" || exit 1
|
||||
test "$SED" || SED=sed
|
||||
test "$DD" || DD=dd
|
||||
|
||||
sz=`"$loc/usage" | wc -c` || exit 1
|
||||
exec >"$target.$$"
|
||||
|
||||
exec >"$target"
|
||||
|
||||
echo 'static const char packed_usage[] ALIGN1 = {'
|
||||
echo '#define UNPACKED_USAGE "" \'
|
||||
"$loc/usage" | od -v -t x1 \
|
||||
| $SED -e 's/^[^ ]*//' \
|
||||
-e 's/ //g' \
|
||||
-e '/^$/d' \
|
||||
-e 's/\(..\)/\\x\1/g' \
|
||||
-e 's/^/"/' \
|
||||
-e 's/$/" \\/'
|
||||
echo ''
|
||||
|
||||
echo '#define PACKED_USAGE \'
|
||||
## Breaks on big-endian systems!
|
||||
## # Extra effort to avoid using "od -t x1": -t is not available
|
||||
## # in non-CONFIG_DESKTOPed busybox od
|
||||
@@ -24,12 +31,13 @@ echo 'static const char packed_usage[] ALIGN1 = {'
|
||||
## -e 's/ //g' \
|
||||
## -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 \
|
||||
| $SED -e 's/^[^ ]*//' \
|
||||
-e 's/ //g' \
|
||||
-e '/^$/d' \
|
||||
-e 's/\(..\)/0x\1,/g'
|
||||
-e 's/\(..\)/0x\1,/g' \
|
||||
-e 's/$/ \\/'
|
||||
echo ''
|
||||
|
||||
echo '};'
|
||||
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
|
||||
mv -- "$target.$$" "$target"
|
||||
+34
-23
@@ -6,11 +6,10 @@
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/* Just #include "autoconf.h" doesn't work for builds in separate
|
||||
* object directory */
|
||||
#include "autoconf.h"
|
||||
|
||||
#define SKIP_applet_main
|
||||
@@ -29,22 +28,39 @@
|
||||
# define USE_FOR_MMU(...) __VA_ARGS__
|
||||
#endif
|
||||
|
||||
static const char usage_messages[] = ""
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
#define MAKE_USAGE(aname, usage) { aname, usage },
|
||||
static struct usage_data {
|
||||
const char *aname;
|
||||
const char *usage;
|
||||
} usage_array[] = {
|
||||
#include "applets.h"
|
||||
;
|
||||
};
|
||||
|
||||
static int compare_func(const void *a, const void *b)
|
||||
{
|
||||
const struct usage_data *ua = a;
|
||||
const struct usage_data *ub = b;
|
||||
return strcmp(ua->aname, ub->aname);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
const char *names;
|
||||
const char *usage;
|
||||
int col, len2;
|
||||
|
||||
int i;
|
||||
int num_messages = sizeof(usage_array) / sizeof(usage_array[0]);
|
||||
|
||||
if (num_messages == 0)
|
||||
return 0;
|
||||
|
||||
qsort(usage_array,
|
||||
num_messages, sizeof(usage_array[0]),
|
||||
compare_func);
|
||||
|
||||
col = 0;
|
||||
names = applet_names;
|
||||
while (*names) {
|
||||
len2 = strlen(names) + 2;
|
||||
for (i = 0; i < num_messages; i++) {
|
||||
len2 = strlen(usage_array[i].aname) + 2;
|
||||
if (col >= 76 - len2) {
|
||||
printf(",\n");
|
||||
col = 0;
|
||||
@@ -55,29 +71,24 @@ int main(void)
|
||||
} else {
|
||||
printf(", ");
|
||||
}
|
||||
printf(names);
|
||||
printf(usage_array[i].aname);
|
||||
col += len2;
|
||||
names += len2 - 1;
|
||||
}
|
||||
printf("\n\n");
|
||||
|
||||
printf("=head1 COMMAND DESCRIPTIONS\n\n");
|
||||
printf("=over 4\n\n");
|
||||
|
||||
names = applet_names;
|
||||
usage = usage_messages;
|
||||
while (*names) {
|
||||
if (*names >= 'a' && *names <= 'z'
|
||||
&& *usage != NOUSAGE_STR[0]
|
||||
for (i = 0; i < num_messages; i++) {
|
||||
if (usage_array[i].aname[0] >= 'a' && usage_array[i].aname[0] <= 'z'
|
||||
&& usage_array[i].usage[0] != NOUSAGE_STR[0]
|
||||
) {
|
||||
printf("=item B<%s>\n\n", names);
|
||||
if (*usage)
|
||||
printf("%s %s\n\n", names, usage);
|
||||
printf("=item B<%s>\n\n", usage_array[i].aname);
|
||||
if (usage_array[i].usage[0])
|
||||
printf("%s %s\n\n", usage_array[i].aname, usage_array[i].usage);
|
||||
else
|
||||
printf("%s\n\n", names);
|
||||
printf("%s\n\n", usage_array[i].aname);
|
||||
}
|
||||
names += strlen(names) + 1;
|
||||
usage += strlen(usage) + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -5,21 +5,29 @@
|
||||
|
||||
menu "Archival Utilities"
|
||||
|
||||
INSERT
|
||||
|
||||
config FEATURE_SEAMLESS_XZ
|
||||
bool "Make tar, rpm, modprobe etc understand .xz data"
|
||||
default y
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .xz data.
|
||||
|
||||
config FEATURE_SEAMLESS_LZMA
|
||||
bool "Make tar, rpm, modprobe etc understand .lzma data"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .lzma data.
|
||||
|
||||
config FEATURE_SEAMLESS_BZ2
|
||||
bool "Make tar, rpm, modprobe etc understand .bz2 data"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .bz2 data.
|
||||
|
||||
config FEATURE_SEAMLESS_GZ
|
||||
bool "Make tar, rpm, modprobe etc understand .gz data"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .gz data.
|
||||
|
||||
@@ -31,7 +39,7 @@ config FEATURE_SEAMLESS_Z
|
||||
|
||||
config AR
|
||||
bool "ar"
|
||||
default n
|
||||
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
|
||||
@@ -54,7 +62,7 @@ config AR
|
||||
|
||||
config FEATURE_AR_LONG_FILENAMES
|
||||
bool "Support for long filenames (not needed for debs)"
|
||||
default n
|
||||
default y
|
||||
depends on AR
|
||||
help
|
||||
By default the ar format can only store the first 15 characters
|
||||
@@ -62,9 +70,16 @@ config FEATURE_AR_LONG_FILENAMES
|
||||
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 n
|
||||
default y
|
||||
help
|
||||
bunzip2 is a compression utility using the Burrows-Wheeler block
|
||||
sorting text compression algorithm, and Huffman coding. Compression
|
||||
@@ -77,7 +92,7 @@ config BUNZIP2
|
||||
|
||||
config BZIP2
|
||||
bool "bzip2"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
bzip2 is a compression utility using the Burrows-Wheeler block
|
||||
sorting text compression algorithm, and Huffman coding. Compression
|
||||
@@ -90,7 +105,7 @@ config BZIP2
|
||||
|
||||
config CPIO
|
||||
bool "cpio"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
cpio is an archival utility program used to create, modify, and
|
||||
extract contents from archives.
|
||||
@@ -104,7 +119,7 @@ config CPIO
|
||||
|
||||
config FEATURE_CPIO_O
|
||||
bool "Support for archive creation"
|
||||
default n
|
||||
default y
|
||||
depends on CPIO
|
||||
help
|
||||
This implementation of cpio can create cpio archives in the "newc"
|
||||
@@ -112,7 +127,7 @@ config FEATURE_CPIO_O
|
||||
|
||||
config FEATURE_CPIO_P
|
||||
bool "Support for passthrough mode"
|
||||
default n
|
||||
default y
|
||||
depends on FEATURE_CPIO_O
|
||||
help
|
||||
Passthrough mode. Rarely used.
|
||||
@@ -152,7 +167,7 @@ config FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
|
||||
config GUNZIP
|
||||
bool "gunzip"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
gunzip is used to decompress archives created by gzip.
|
||||
You can use the `-t' option to test the integrity of
|
||||
@@ -160,21 +175,21 @@ config GUNZIP
|
||||
|
||||
config GZIP
|
||||
bool "gzip"
|
||||
default n
|
||||
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 n
|
||||
default y
|
||||
depends on GZIP && LONG_OPTS
|
||||
help
|
||||
Enable use of long options, increases size by about 106 Bytes
|
||||
|
||||
config LZOP
|
||||
bool "lzop"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Lzop compression/decompresion.
|
||||
|
||||
@@ -189,26 +204,24 @@ config LZOP_COMPR_HIGH
|
||||
|
||||
config RPM2CPIO
|
||||
bool "rpm2cpio"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Converts an RPM file into a CPIO archive.
|
||||
|
||||
config RPM
|
||||
bool "rpm"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Mini RPM applet - queries and extracts RPM packages.
|
||||
|
||||
config TAR
|
||||
bool "tar"
|
||||
default n
|
||||
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.
|
||||
|
||||
if TAR
|
||||
|
||||
config FEATURE_TAR_CREATE
|
||||
bool "Enable archive creation"
|
||||
default y
|
||||
@@ -219,15 +232,15 @@ config FEATURE_TAR_CREATE
|
||||
|
||||
config FEATURE_TAR_AUTODETECT
|
||||
bool "Autodetect compressed tarballs"
|
||||
default n
|
||||
depends on FEATURE_SEAMLESS_Z || FEATURE_SEAMLESS_GZ || FEATURE_SEAMLESS_BZ2 || FEATURE_SEAMLESS_LZMA
|
||||
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 n
|
||||
default y
|
||||
depends on TAR
|
||||
help
|
||||
If you enable this option you'll be able to specify
|
||||
@@ -235,8 +248,8 @@ config FEATURE_TAR_FROM
|
||||
|
||||
config FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
bool "Support for old tar header format"
|
||||
default N
|
||||
depends on TAR
|
||||
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
|
||||
@@ -244,8 +257,8 @@ config FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
|
||||
config FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
bool "Enable untarring of tarballs with checksums produced by buggy Sun tar"
|
||||
default N
|
||||
depends on 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
|
||||
@@ -255,21 +268,30 @@ config FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
config FEATURE_TAR_GNU_EXTENSIONS
|
||||
bool "Support for GNU tar extensions (long filenames)"
|
||||
default y
|
||||
depends on TAR
|
||||
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 n
|
||||
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 n
|
||||
default y
|
||||
depends on TAR
|
||||
help
|
||||
Enables use of user and group names in tar. This affects contents
|
||||
@@ -278,13 +300,19 @@ config FEATURE_TAR_UNAME_GNAME
|
||||
|
||||
config FEATURE_TAR_NOPRESERVE_TIME
|
||||
bool "Enable -m (do not preserve time) option"
|
||||
default n
|
||||
default y
|
||||
depends on TAR
|
||||
help
|
||||
With this option busybox supports GNU tar -m
|
||||
(do not preserve time) option.
|
||||
|
||||
endif #tar
|
||||
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"
|
||||
@@ -295,7 +323,7 @@ config UNCOMPRESS
|
||||
|
||||
config UNLZMA
|
||||
bool "unlzma"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
unlzma is a compression utility using the Lempel-Ziv-Markov chain
|
||||
compression algorithm, and range coding. Compression
|
||||
@@ -310,15 +338,37 @@ config UNLZMA
|
||||
|
||||
config FEATURE_LZMA_FAST
|
||||
bool "Optimize unlzma for speed"
|
||||
default n
|
||||
default y
|
||||
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 n
|
||||
default y
|
||||
help
|
||||
unzip will list or extract files from a ZIP archive,
|
||||
commonly found on DOS/WIN systems. The default behavior
|
||||
@@ -7,19 +7,25 @@
|
||||
libs-y += libunarchive/
|
||||
|
||||
lib-y:=
|
||||
|
||||
INSERT
|
||||
|
||||
lib-$(CONFIG_AR) += ar.o
|
||||
lib-$(CONFIG_BUNZIP2) += bbunzip.o
|
||||
lib-$(CONFIG_BZIP2) += bzip2.o bbunzip.o
|
||||
lib-$(CONFIG_UNLZMA) += bbunzip.o
|
||||
lib-$(CONFIG_CPIO) += cpio.o
|
||||
lib-$(CONFIG_DPKG) += dpkg.o
|
||||
lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o
|
||||
lib-$(CONFIG_GUNZIP) += bbunzip.o
|
||||
lib-$(CONFIG_GZIP) += gzip.o bbunzip.o
|
||||
lib-$(CONFIG_LZOP) += lzop.o lzo1x_1.o lzo1x_1o.o lzo1x_d.o bbunzip.o
|
||||
lib-$(CONFIG_LZOP_COMPR_HIGH) += lzo1x_9x.o
|
||||
lib-$(CONFIG_RPM2CPIO) += rpm2cpio.o
|
||||
lib-$(CONFIG_RPM) += rpm.o
|
||||
lib-$(CONFIG_TAR) += tar.o
|
||||
lib-$(CONFIG_UNCOMPRESS) += bbunzip.o
|
||||
lib-$(CONFIG_UNZIP) += unzip.o
|
||||
|
||||
lib-$(CONFIG_LZOP) += lzop.o lzo1x_1.o lzo1x_1o.o lzo1x_d.o bbunzip.o
|
||||
lib-$(CONFIG_LZOP_COMPR_HIGH) += lzo1x_9x.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
|
||||
+193
-29
@@ -8,6 +8,10 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
* Archive creation support:
|
||||
* Copyright (C) 2010 Nokia Corporation. All rights reserved.
|
||||
* Written by Alexander Shishkin.
|
||||
*
|
||||
* There is no single standard to adhere to so ar may not portable
|
||||
* between different systems
|
||||
* http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
|
||||
@@ -15,6 +19,150 @@
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
#include "ar.h"
|
||||
|
||||
#if ENABLE_FEATURE_AR_CREATE
|
||||
/* filter out entries with same names as specified on the command line */
|
||||
static char FAST_FUNC filter_replaceable(archive_handle_t *handle)
|
||||
{
|
||||
if (find_list_entry(handle->accept, handle->file_header->name))
|
||||
return EXIT_FAILURE;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void output_ar_header(archive_handle_t *handle)
|
||||
{
|
||||
/* GNU ar 2.19.51.0.14 creates malformed archives
|
||||
* if input files are >10G. It also truncates files >4GB
|
||||
* (uses "size mod 4G"). We abort in this case:
|
||||
* We could add support for up to 10G files, but this is unlikely to be useful.
|
||||
* Note that unpacking side limits all fields to "unsigned int" data type,
|
||||
* and treats "all ones" as an error indicator. Thus max we allow here is UINT_MAX-1.
|
||||
*/
|
||||
enum {
|
||||
/* for 2nd field: mtime */
|
||||
MAX11CHARS = UINT_MAX > 0xffffffff ? (unsigned)99999999999 : UINT_MAX-1,
|
||||
/* for last field: filesize */
|
||||
MAX10CHARS = UINT_MAX > 0xffffffff ? (unsigned)9999999999 : UINT_MAX-1,
|
||||
};
|
||||
|
||||
struct file_header_t *fh = handle->file_header;
|
||||
|
||||
if (handle->offset & 1) {
|
||||
xwrite(handle->src_fd, "\n", 1);
|
||||
handle->offset++;
|
||||
}
|
||||
|
||||
/* Careful! The widths should be exact. Fields must be separated */
|
||||
if (sizeof(off_t) > 4 && fh->size > (off_t)MAX10CHARS) {
|
||||
bb_error_msg_and_die("'%s' is bigger than ar can handle", fh->name);
|
||||
}
|
||||
fdprintf(handle->src_fd, "%-16.16s%-12lu%-6u%-6u%-8o%-10"OFF_FMT"u`\n",
|
||||
fh->name,
|
||||
(sizeof(time_t) > 4 && fh->mtime > MAX11CHARS) ? (long)0 : (long)fh->mtime,
|
||||
fh->uid > 99999 ? 0 : (int)fh->uid,
|
||||
fh->gid > 99999 ? 0 : (int)fh->gid,
|
||||
(int)fh->mode & 07777777,
|
||||
fh->size
|
||||
);
|
||||
|
||||
handle->offset += AR_HEADER_LEN;
|
||||
}
|
||||
|
||||
/*
|
||||
* when replacing files in an existing archive, copy from the the
|
||||
* original archive those files that are to be left intact
|
||||
*/
|
||||
static void FAST_FUNC copy_data(archive_handle_t *handle)
|
||||
{
|
||||
archive_handle_t *out_handle = handle->ar__out;
|
||||
struct file_header_t *fh = handle->file_header;
|
||||
|
||||
out_handle->file_header = fh;
|
||||
output_ar_header(out_handle);
|
||||
|
||||
bb_copyfd_exact_size(handle->src_fd, out_handle->src_fd, fh->size);
|
||||
out_handle->offset += fh->size;
|
||||
}
|
||||
|
||||
static int write_ar_header(archive_handle_t *handle)
|
||||
{
|
||||
char *fn;
|
||||
char fn_h[17]; /* 15 + "/" + NUL */
|
||||
struct stat st;
|
||||
int fd;
|
||||
|
||||
fn = llist_pop(&handle->accept);
|
||||
if (!fn)
|
||||
return -1;
|
||||
|
||||
xstat(fn, &st);
|
||||
|
||||
handle->file_header->mtime = st.st_mtime;
|
||||
handle->file_header->uid = st.st_uid;
|
||||
handle->file_header->gid = st.st_gid;
|
||||
handle->file_header->mode = st.st_mode;
|
||||
handle->file_header->size = st.st_size;
|
||||
handle->file_header->name = fn_h;
|
||||
//TODO: if ENABLE_FEATURE_AR_LONG_FILENAMES...
|
||||
sprintf(fn_h, "%.15s/", bb_basename(fn));
|
||||
|
||||
output_ar_header(handle);
|
||||
|
||||
fd = xopen(fn, O_RDONLY);
|
||||
bb_copyfd_exact_size(fd, handle->src_fd, st.st_size);
|
||||
close(fd);
|
||||
handle->offset += st.st_size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int write_ar_archive(archive_handle_t *handle)
|
||||
{
|
||||
struct stat st;
|
||||
archive_handle_t *out_handle;
|
||||
|
||||
if (fstat(handle->src_fd, &st) == -1)
|
||||
bb_simple_perror_msg_and_die(handle->ar__name);
|
||||
|
||||
/* if archive exists, create a new handle for output.
|
||||
* we create it in place of the old one.
|
||||
*/
|
||||
if (st.st_size != 0) {
|
||||
out_handle = init_handle();
|
||||
xunlink(handle->ar__name);
|
||||
out_handle->src_fd = xopen(handle->ar__name, O_WRONLY | O_CREAT | O_TRUNC);
|
||||
out_handle->accept = handle->accept;
|
||||
} else {
|
||||
out_handle = handle;
|
||||
}
|
||||
|
||||
handle->ar__out = out_handle;
|
||||
|
||||
xwrite(out_handle->src_fd, AR_MAGIC "\n", AR_MAGIC_LEN + 1);
|
||||
out_handle->offset += AR_MAGIC_LEN + 1;
|
||||
|
||||
/* skip to the end of the archive if we have to append stuff */
|
||||
if (st.st_size != 0) {
|
||||
handle->filter = filter_replaceable;
|
||||
handle->action_data = copy_data;
|
||||
unpack_ar_archive(handle);
|
||||
}
|
||||
|
||||
while (write_ar_header(out_handle) == 0)
|
||||
continue;
|
||||
|
||||
/* optional, since we exit right after we return */
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(handle->src_fd);
|
||||
if (out_handle->src_fd != handle->src_fd)
|
||||
close(out_handle->src_fd);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif /* FEATURE_AR_CREATE */
|
||||
|
||||
static void FAST_FUNC header_verbose_list_ar(const file_header_t *file_header)
|
||||
{
|
||||
@@ -25,41 +173,51 @@ static void FAST_FUNC header_verbose_list_ar(const file_header_t *file_header)
|
||||
mtime[16] = ' ';
|
||||
memmove(&mtime[17], &mtime[20], 4);
|
||||
mtime[21] = '\0';
|
||||
printf("%s %d/%d%7d %s %s\n", &mode[1], file_header->uid, file_header->gid,
|
||||
(int) file_header->size, &mtime[4], file_header->name);
|
||||
printf("%s %u/%u%7"OFF_FMT"u %s %s\n", &mode[1],
|
||||
(int)file_header->uid, (int)file_header->gid,
|
||||
file_header->size,
|
||||
&mtime[4], file_header->name
|
||||
);
|
||||
}
|
||||
|
||||
#define AR_CTX_PRINT 0x01
|
||||
#define AR_CTX_LIST 0x02
|
||||
#define AR_CTX_EXTRACT 0x04
|
||||
#define AR_OPT_PRESERVE_DATE 0x08
|
||||
#define AR_OPT_VERBOSE 0x10
|
||||
#define AR_OPT_CREATE 0x20
|
||||
#define AR_OPT_INSERT 0x40
|
||||
#define AR_OPT_VERBOSE (1 << 0)
|
||||
#define AR_OPT_PRESERVE_DATE (1 << 1)
|
||||
/* "ar r" implies create, but warns about it. c suppresses warning.
|
||||
* bbox accepts but ignores it: */
|
||||
#define AR_OPT_CREATE (1 << 2)
|
||||
|
||||
#define AR_CMD_PRINT (1 << 3)
|
||||
#define FIRST_CMD AR_CMD_PRINT
|
||||
#define AR_CMD_LIST (1 << 4)
|
||||
#define AR_CMD_EXTRACT (1 << 5)
|
||||
#define AR_CMD_INSERT (1 << 6)
|
||||
|
||||
int ar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int ar_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
static const char msg_unsupported_err[] ALIGN1 =
|
||||
"archive %s is not supported";
|
||||
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned opt;
|
||||
unsigned opt, t;
|
||||
|
||||
archive_handle = init_handle();
|
||||
|
||||
/* Prepend '-' to the first argument if required */
|
||||
opt_complementary = "--:p:t:x:-1:p--tx:t--px:x--pt";
|
||||
opt = getopt32(argv, "ptxovcr");
|
||||
/* --: prepend '-' to the first argument if required */
|
||||
/* -1: at least one param is reqd */
|
||||
/* one of p,t,x[,r] is required */
|
||||
opt_complementary = "--:-1:p:t:x"IF_FEATURE_AR_CREATE(":r");
|
||||
opt = getopt32(argv, "voc""ptx"IF_FEATURE_AR_CREATE("r"));
|
||||
argv += optind;
|
||||
|
||||
if (opt & AR_CTX_PRINT) {
|
||||
t = opt / FIRST_CMD;
|
||||
if (t & (t-1)) /* more than one of p,t,x[,r] are specified */
|
||||
bb_show_usage();
|
||||
|
||||
if (opt & AR_CMD_PRINT) {
|
||||
archive_handle->action_data = data_extract_to_stdout;
|
||||
}
|
||||
if (opt & AR_CTX_LIST) {
|
||||
if (opt & AR_CMD_LIST) {
|
||||
archive_handle->action_header = header_list;
|
||||
}
|
||||
if (opt & AR_CTX_EXTRACT) {
|
||||
if (opt & AR_CMD_EXTRACT) {
|
||||
archive_handle->action_data = data_extract_all;
|
||||
}
|
||||
if (opt & AR_OPT_PRESERVE_DATE) {
|
||||
@@ -68,20 +226,26 @@ int ar_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (opt & AR_OPT_VERBOSE) {
|
||||
archive_handle->action_header = header_verbose_list_ar;
|
||||
}
|
||||
if (opt & AR_OPT_CREATE) {
|
||||
bb_error_msg_and_die(msg_unsupported_err, "creation");
|
||||
}
|
||||
if (opt & AR_OPT_INSERT) {
|
||||
bb_error_msg_and_die(msg_unsupported_err, "insertion");
|
||||
}
|
||||
#if ENABLE_FEATURE_AR_CREATE
|
||||
archive_handle->ar__name = *argv;
|
||||
#endif
|
||||
archive_handle->src_fd = xopen(*argv++,
|
||||
(opt & AR_CMD_INSERT)
|
||||
? O_RDWR | O_CREAT
|
||||
: O_RDONLY
|
||||
);
|
||||
|
||||
archive_handle->src_fd = xopen(*argv++, O_RDONLY);
|
||||
|
||||
while (*argv) {
|
||||
if (*argv)
|
||||
archive_handle->filter = filter_accept_list;
|
||||
llist_add_to(&archive_handle->accept, *argv++);
|
||||
while (*argv) {
|
||||
llist_add_to_end(&archive_handle->accept, *argv++);
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_AR_CREATE
|
||||
if (opt & AR_CMD_INSERT)
|
||||
return write_ar_archive(archive_handle);
|
||||
#endif
|
||||
|
||||
unpack_ar_archive(archive_handle);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
+115
-96
@@ -4,17 +4,16 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
enum {
|
||||
OPT_STDOUT = 0x1,
|
||||
OPT_FORCE = 0x2,
|
||||
/* gunzip and bunzip2 only: */
|
||||
OPT_VERBOSE = 0x4,
|
||||
OPT_DECOMPRESS = 0x8,
|
||||
OPT_TEST = 0x10,
|
||||
OPT_STDOUT = 1 << 0,
|
||||
OPT_FORCE = 1 << 1,
|
||||
/* only some decompressors: */
|
||||
OPT_VERBOSE = 1 << 2,
|
||||
OPT_DECOMPRESS = 1 << 3,
|
||||
OPT_TEST = 1 << 4,
|
||||
};
|
||||
|
||||
static
|
||||
@@ -28,9 +27,15 @@ int open_to_or_warn(int to_fd, const char *filename, int flags, int mode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* FAST_FUNC append_ext(char *filename, const char *expected_ext)
|
||||
{
|
||||
return xasprintf("%s.%s", filename, expected_ext);
|
||||
}
|
||||
|
||||
int FAST_FUNC bbunpack(char **argv,
|
||||
char* (*make_new_name)(char *filename),
|
||||
IF_DESKTOP(long long) int (*unpacker)(unpack_info_t *info)
|
||||
IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(unpack_info_t *info),
|
||||
char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext),
|
||||
const char *expected_ext
|
||||
)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
@@ -69,7 +74,7 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
|
||||
/* Open dst if we are going to unpack to file */
|
||||
if (filename) {
|
||||
new_name = make_new_name(filename);
|
||||
new_name = make_new_name(filename, expected_ext);
|
||||
if (!new_name) {
|
||||
bb_error_msg("%s: unknown suffix - ignored", filename);
|
||||
goto err;
|
||||
@@ -141,10 +146,9 @@ int FAST_FUNC bbunpack(char **argv,
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
#if ENABLE_BUNZIP2 || ENABLE_UNLZMA || ENABLE_UNCOMPRESS
|
||||
|
||||
#if ENABLE_UNCOMPRESS || ENABLE_BUNZIP2 || ENABLE_UNLZMA || ENABLE_UNXZ
|
||||
static
|
||||
char* make_new_name_generic(char *filename, const char *expected_ext)
|
||||
char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext)
|
||||
{
|
||||
char *extension = strrchr(filename, '.');
|
||||
if (!extension || strcmp(extension + 1, expected_ext) != 0) {
|
||||
@@ -155,42 +159,35 @@ char* make_new_name_generic(char *filename, const char *expected_ext)
|
||||
*extension = '\0';
|
||||
return filename;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Modified for busybox by Glenn McGrath
|
||||
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
|
||||
* Uncompress applet for busybox (c) 2002 Glenn McGrath
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#if ENABLE_BUNZIP2
|
||||
|
||||
#if ENABLE_UNCOMPRESS
|
||||
static
|
||||
char* make_new_name_bunzip2(char *filename)
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_uncompress(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
return make_new_name_generic(filename, "bz2");
|
||||
}
|
||||
IF_DESKTOP(long long) int status = -1;
|
||||
|
||||
static
|
||||
IF_DESKTOP(long long) int unpack_bunzip2(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
return unpack_bz2_stream_prime(STDIN_FILENO, STDOUT_FILENO);
|
||||
if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) {
|
||||
bb_error_msg("invalid magic");
|
||||
} else {
|
||||
status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
int uncompress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int uncompress_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cfvdt");
|
||||
getopt32(argv, "cf");
|
||||
argv += optind;
|
||||
if (applet_name[2] == 'c')
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
|
||||
return bbunpack(argv, make_new_name_bunzip2, unpack_bunzip2);
|
||||
return bbunpack(argv, unpack_uncompress, make_new_name_generic, "Z");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -221,11 +218,9 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#if ENABLE_GUNZIP
|
||||
|
||||
static
|
||||
char* make_new_name_gunzip(char *filename)
|
||||
char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM)
|
||||
{
|
||||
char *extension = strrchr(filename, '.');
|
||||
|
||||
@@ -249,9 +244,8 @@ char* make_new_name_gunzip(char *filename)
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
static
|
||||
IF_DESKTOP(long long) int unpack_gunzip(unpack_info_t *info)
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_gunzip(unpack_info_t *info)
|
||||
{
|
||||
IF_DESKTOP(long long) int status = -1;
|
||||
|
||||
@@ -277,7 +271,6 @@ IF_DESKTOP(long long) int unpack_gunzip(unpack_info_t *info)
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Linux kernel build uses gzip -d -n. We accept and ignore it.
|
||||
* Man page says:
|
||||
@@ -291,7 +284,6 @@ IF_DESKTOP(long long) int unpack_gunzip(unpack_info_t *info)
|
||||
* gzip: always save the original file name and time stamp (this is the default)
|
||||
* gunzip: restore the original file name and time stamp if present.
|
||||
*/
|
||||
|
||||
int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
@@ -301,9 +293,46 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (applet_name[1] == 'c')
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
|
||||
return bbunpack(argv, make_new_name_gunzip, unpack_gunzip);
|
||||
return bbunpack(argv, unpack_gunzip, make_new_name_gunzip, /*unused:*/ NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Modified for busybox by Glenn McGrath
|
||||
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
//usage:#define bunzip2_trivial_usage
|
||||
//usage: "[OPTIONS] [FILE]..."
|
||||
//usage:#define bunzip2_full_usage "\n\n"
|
||||
//usage: "Decompress FILEs (or stdin)\n"
|
||||
//usage: "\nOptions:"
|
||||
//usage: "\n -c Write to stdout"
|
||||
//usage: "\n -f Force"
|
||||
//usage:#define bzcat_trivial_usage
|
||||
//usage: "FILE"
|
||||
//usage:#define bzcat_full_usage "\n\n"
|
||||
//usage: "Decompress to stdout"
|
||||
//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))
|
||||
#if ENABLE_BUNZIP2
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
return unpack_bz2_stream_prime(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cfvdt");
|
||||
argv += optind;
|
||||
if (applet_name[2] == 'c') /* bzcat */
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
|
||||
return bbunpack(argv, unpack_bunzip2, make_new_name_generic, "bz2");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -315,70 +344,60 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
*
|
||||
* Licensed under GPL v2, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#if ENABLE_UNLZMA
|
||||
|
||||
static
|
||||
char* make_new_name_unlzma(char *filename)
|
||||
{
|
||||
return make_new_name_generic(filename, "lzma");
|
||||
}
|
||||
|
||||
static
|
||||
IF_DESKTOP(long long) int unpack_unlzma(unpack_info_t *info UNUSED_PARAM)
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
return unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
|
||||
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int unlzma_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cf");
|
||||
argv += optind;
|
||||
/* lzmacat? */
|
||||
if (applet_name[4] == 'c')
|
||||
IF_LZMA(int opts =) getopt32(argv, "cfvdt");
|
||||
# if ENABLE_LZMA
|
||||
/* lzma without -d or -t? */
|
||||
if (applet_name[2] == 'm' && !(opts & (OPT_DECOMPRESS|OPT_TEST)))
|
||||
bb_show_usage();
|
||||
# endif
|
||||
/* lzcat? */
|
||||
if (applet_name[2] == 'c')
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
|
||||
return bbunpack(argv, make_new_name_unlzma, unpack_unlzma);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Uncompress applet for busybox (c) 2002 Glenn McGrath
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#if ENABLE_UNCOMPRESS
|
||||
|
||||
static
|
||||
char* make_new_name_uncompress(char *filename)
|
||||
{
|
||||
return make_new_name_generic(filename, "Z");
|
||||
}
|
||||
|
||||
static
|
||||
IF_DESKTOP(long long) int unpack_uncompress(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
IF_DESKTOP(long long) int status = -1;
|
||||
|
||||
if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) {
|
||||
bb_error_msg("invalid magic");
|
||||
} else {
|
||||
status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int uncompress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int uncompress_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cf");
|
||||
argv += optind;
|
||||
return bbunpack(argv, unpack_unlzma, make_new_name_generic, "lzma");
|
||||
}
|
||||
#endif
|
||||
|
||||
return bbunpack(argv, make_new_name_uncompress, unpack_uncompress);
|
||||
|
||||
#if ENABLE_UNXZ
|
||||
static
|
||||
IF_DESKTOP(long long) int FAST_FUNC unpack_unxz(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
struct {
|
||||
uint32_t v1;
|
||||
uint16_t v2;
|
||||
} magic;
|
||||
xread(STDIN_FILENO, &magic, 6);
|
||||
if (magic.v1 != XZ_MAGIC1a || magic.v2 != XZ_MAGIC2a) {
|
||||
bb_error_msg("invalid magic");
|
||||
return -1;
|
||||
}
|
||||
return unpack_xz_stream(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
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 ENABLE_XZ
|
||||
/* xz without -d or -t? */
|
||||
if (applet_name[2] == '\0' && !(opts & (OPT_DECOMPRESS|OPT_TEST)))
|
||||
bb_show_usage();
|
||||
# endif
|
||||
/* xzcat? */
|
||||
if (applet_name[2] == 'c')
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
|
||||
argv += optind;
|
||||
return bbunpack(argv, unpack_unxz, make_new_name_generic, "xz");
|
||||
}
|
||||
|
||||
#endif
|
||||
+5
-3
@@ -393,10 +393,12 @@ int BZ2_bzBuffToBuffCompress(char* dest,
|
||||
bz_stream strm;
|
||||
int ret;
|
||||
|
||||
if (dest == NULL || destLen == NULL ||
|
||||
source == NULL ||
|
||||
blockSize100k < 1 || blockSize100k > 9)
|
||||
if (dest == NULL || destLen == NULL
|
||||
|| source == NULL
|
||||
|| blockSize100k < 1 || blockSize100k > 9
|
||||
) {
|
||||
return BZ_PARAM_ERROR;
|
||||
}
|
||||
|
||||
BZ2_bzCompressInit(&strm, blockSize100k);
|
||||
|
||||
|
||||
+4
-10
@@ -88,7 +88,7 @@ IF_DESKTOP(long long) int bz_write(bz_stream *strm, void* rbuf, ssize_t rlen, vo
|
||||
if (n2 != n) {
|
||||
if (n2 >= 0)
|
||||
errno = 0; /* prevent bogus error message */
|
||||
bb_perror_msg(n2 >= 0 ? "short write" : "write error");
|
||||
bb_perror_msg(n2 >= 0 ? "short write" : bb_msg_write_error);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -102,7 +102,7 @@ IF_DESKTOP(long long) int bz_write(bz_stream *strm, void* rbuf, ssize_t rlen, vo
|
||||
}
|
||||
|
||||
static
|
||||
IF_DESKTOP(long long) int compressStream(unpack_info_t *info UNUSED_PARAM)
|
||||
IF_DESKTOP(long long) int FAST_FUNC compressStream(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
IF_DESKTOP(long long) int total;
|
||||
ssize_t count;
|
||||
@@ -118,7 +118,7 @@ IF_DESKTOP(long long) int compressStream(unpack_info_t *info UNUSED_PARAM)
|
||||
while (1) {
|
||||
count = full_read(STDIN_FILENO, rbuf, IOBUF_SIZE);
|
||||
if (count < 0) {
|
||||
bb_perror_msg("read error");
|
||||
bb_perror_msg(bb_msg_read_error);
|
||||
total = -1;
|
||||
break;
|
||||
}
|
||||
@@ -135,12 +135,6 @@ IF_DESKTOP(long long) int compressStream(unpack_info_t *info UNUSED_PARAM)
|
||||
return total;
|
||||
}
|
||||
|
||||
static
|
||||
char* make_new_name_bzip2(char *filename)
|
||||
{
|
||||
return xasprintf("%s.bz2", filename);
|
||||
}
|
||||
|
||||
int bzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int bzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
@@ -181,5 +175,5 @@ int bzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
argv += optind;
|
||||
option_mask32 &= 0x7; /* ignore all except -cfv */
|
||||
return bbunpack(argv, make_new_name_bzip2, compressStream);
|
||||
return bbunpack(argv, compressStream, append_ext, "bz2");
|
||||
}
|
||||
+2
-1
@@ -311,6 +311,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* no parameters */
|
||||
opt_complementary = "=0";
|
||||
opt = getopt32(argv, OPTION_STR, &cpio_filename);
|
||||
argv += optind;
|
||||
if (opt & CPIO_OPT_FILE) { /* -F */
|
||||
xmove_fd(xopen(cpio_filename, O_RDONLY), STDIN_FILENO);
|
||||
}
|
||||
@@ -424,7 +425,7 @@ int cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (archive_handle->cpio__blocks != (off_t)-1
|
||||
&& !(opt & CPIO_OPT_QUIET)
|
||||
) {
|
||||
printf("%"OFF_FMT"u blocks\n", archive_handle->cpio__blocks);
|
||||
fprintf(stderr, "%"OFF_FMT"u blocks\n", archive_handle->cpio__blocks);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
+132
-29
@@ -245,7 +245,7 @@ static int version_compare(const unsigned ver1, const unsigned ver2)
|
||||
{
|
||||
char *ch_ver1 = name_hashtable[ver1];
|
||||
char *ch_ver2 = name_hashtable[ver2];
|
||||
unsigned long epoch1 = 0, epoch2 = 0;
|
||||
unsigned epoch1 = 0, epoch2 = 0;
|
||||
char *colon;
|
||||
char *deb_ver1, *deb_ver2;
|
||||
char *upstream_ver1;
|
||||
@@ -278,17 +278,16 @@ static int version_compare(const unsigned ver1, const unsigned ver2)
|
||||
deb_ver1 = strrchr(upstream_ver1, '-');
|
||||
deb_ver2 = strrchr(upstream_ver2, '-');
|
||||
if (deb_ver1) {
|
||||
deb_ver1[0] = '\0';
|
||||
deb_ver1++;
|
||||
*deb_ver1++ = '\0';
|
||||
}
|
||||
if (deb_ver2) {
|
||||
deb_ver2[0] = '\0';
|
||||
deb_ver2++;
|
||||
*deb_ver2++ = '\0';
|
||||
}
|
||||
result = version_compare_part(upstream_ver1, upstream_ver2);
|
||||
if (!result)
|
||||
if (result == 0) {
|
||||
/* Compare debian versions */
|
||||
result = version_compare_part(deb_ver1, deb_ver2);
|
||||
}
|
||||
|
||||
free(upstream_ver1);
|
||||
free(upstream_ver2);
|
||||
@@ -858,8 +857,9 @@ static void write_status_file(deb_file_t **deb_file)
|
||||
if (field_name == NULL) {
|
||||
break;
|
||||
}
|
||||
if ((strcmp(field_name, "Priority") == 0) ||
|
||||
(strcmp(field_name, "Section") == 0)) {
|
||||
if ((strcmp(field_name, "Priority") == 0)
|
||||
|| (strcmp(field_name, "Section") == 0)
|
||||
) {
|
||||
fprintf(new_status_file, "%s: %s\n", field_name, field_value);
|
||||
}
|
||||
}
|
||||
@@ -1079,8 +1079,9 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
|
||||
|
||||
package_num = search_package_hashtable(package_edge->name, package_edge->version, package_edge->operator);
|
||||
|
||||
if (package_edge->type == EDGE_PRE_DEPENDS ||
|
||||
package_edge->type == EDGE_DEPENDS) {
|
||||
if (package_edge->type == EDGE_PRE_DEPENDS
|
||||
|| package_edge->type == EDGE_DEPENDS
|
||||
) {
|
||||
int result=1;
|
||||
status_num = 0;
|
||||
|
||||
@@ -1306,7 +1307,7 @@ static void list_packages(const char *pattern)
|
||||
name_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->name];
|
||||
vers_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->version];
|
||||
|
||||
if (pattern && fnmatch(pattern, name_str, 0))
|
||||
if (pattern && fnmatch(pattern, name_str, 0) != 0)
|
||||
continue;
|
||||
|
||||
/* get abbreviation for status field 1 */
|
||||
@@ -1489,6 +1490,58 @@ static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, lli
|
||||
return ar_handle->dpkg__sub_archive->dpkg__buffer;
|
||||
}
|
||||
|
||||
static void append_control_file_to_llist(const char *package_name, const char *control_name, llist_t **ll)
|
||||
{
|
||||
FILE *fp;
|
||||
char *filename, *line;
|
||||
|
||||
filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, control_name);
|
||||
fp = fopen_for_read(filename);
|
||||
free(filename);
|
||||
if (fp != NULL) {
|
||||
while ((line = xmalloc_fgetline(fp)) != NULL)
|
||||
llist_add_to(ll, line);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
static char FAST_FUNC filter_rename_config(archive_handle_t *archive_handle)
|
||||
{
|
||||
int fd;
|
||||
char *name_ptr = archive_handle->file_header->name + 1;
|
||||
|
||||
/* Is this file marked as config file? */
|
||||
if (!find_list_entry(archive_handle->accept, name_ptr))
|
||||
return EXIT_SUCCESS; /* no */
|
||||
|
||||
fd = open(name_ptr, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
md5_ctx_t md5;
|
||||
char *md5line, *buf;
|
||||
int count;
|
||||
|
||||
/* Calculate MD5 of existing file */
|
||||
buf = xmalloc(4096);
|
||||
md5_begin(&md5);
|
||||
while ((count = safe_read(fd, buf, 4096)) > 0)
|
||||
md5_hash(buf, count, &md5);
|
||||
md5_end(buf, &md5); /* using buf as result storage */
|
||||
close(fd);
|
||||
|
||||
md5line = xmalloc(16 * 2 + 2 + strlen(name_ptr) + 1);
|
||||
sprintf(bin2hex(md5line, buf, 16), " %s", name_ptr);
|
||||
free(buf);
|
||||
|
||||
/* Is it changed after install? */
|
||||
if (find_list_entry(archive_handle->accept, md5line) == NULL) {
|
||||
printf("Warning: Creating %s as %s.dpkg-new\n", name_ptr, name_ptr);
|
||||
archive_handle->file_header->name = xasprintf("%s.dpkg-new", archive_handle->file_header->name);
|
||||
}
|
||||
free(md5line);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void FAST_FUNC data_extract_all_prefix(archive_handle_t *archive_handle)
|
||||
{
|
||||
char *name_ptr = archive_handle->file_header->name;
|
||||
@@ -1498,7 +1551,7 @@ static void FAST_FUNC data_extract_all_prefix(archive_handle_t *archive_handle)
|
||||
name_ptr++;
|
||||
/* Skip all leading "./" and "../" */
|
||||
while (name_ptr[0] == '.') {
|
||||
if (name_ptr[1] == '.' && name_ptr[2] == '/')
|
||||
if (name_ptr[1] == '.')
|
||||
name_ptr++;
|
||||
if (name_ptr[1] != '/')
|
||||
break;
|
||||
@@ -1508,9 +1561,29 @@ static void FAST_FUNC data_extract_all_prefix(archive_handle_t *archive_handle)
|
||||
if (name_ptr[0] != '\0') {
|
||||
archive_handle->file_header->name = xasprintf("%s%s", archive_handle->dpkg__buffer, name_ptr);
|
||||
data_extract_all(archive_handle);
|
||||
if (fnmatch("*.dpkg-new", archive_handle->file_header->name, 0) == 0) {
|
||||
/* remove .dpkg-new suffix */
|
||||
archive_handle->file_header->name[strlen(archive_handle->file_header->name) - 9] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum {
|
||||
/* Commands */
|
||||
OPT_configure = (1 << 0),
|
||||
OPT_install = (1 << 1),
|
||||
OPT_list_installed = (1 << 2),
|
||||
OPT_purge = (1 << 3),
|
||||
OPT_remove = (1 << 4),
|
||||
OPT_unpack = (1 << 5),
|
||||
OPTMASK_cmd = (1 << 6) - 1,
|
||||
/* Options */
|
||||
OPT_force = (1 << 6),
|
||||
OPT_force_ignore_depends = (1 << 7),
|
||||
OPT_force_confnew = (1 << 8),
|
||||
OPT_force_confold = (1 << 9),
|
||||
};
|
||||
|
||||
static void unpack_package(deb_file_t *deb_file)
|
||||
{
|
||||
const char *package_name = name_hashtable[package_hashtable[deb_file->package]->name];
|
||||
@@ -1521,14 +1594,21 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
archive_handle_t *archive_handle;
|
||||
FILE *out_stream;
|
||||
llist_t *accept_list;
|
||||
llist_t *conffile_list;
|
||||
int i;
|
||||
|
||||
/* If existing version, remove it first */
|
||||
conffile_list = NULL;
|
||||
if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) {
|
||||
/* Package is already installed, remove old version first */
|
||||
printf("Preparing to replace %s %s (using %s)...\n", package_name,
|
||||
name_hashtable[package_hashtable[status_package_num]->version],
|
||||
deb_file->filename);
|
||||
|
||||
/* Read md5sums from old package */
|
||||
if (!(option_mask32 & OPT_force_confold))
|
||||
append_control_file_to_llist(package_name, "md5sums", &conffile_list);
|
||||
|
||||
remove_package(status_package_num, 0);
|
||||
} else {
|
||||
printf("Unpacking %s (from %s)...\n", package_name, deb_file->filename);
|
||||
@@ -1556,9 +1636,15 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
/* Run the preinst prior to extracting */
|
||||
run_package_script_or_die(package_name, "preinst");
|
||||
|
||||
/* Don't overwrite existing config files */
|
||||
if (!(option_mask32 & OPT_force_confnew))
|
||||
append_control_file_to_llist(package_name, "conffiles", &conffile_list);
|
||||
|
||||
/* Extract data.tar.gz to the root directory */
|
||||
archive_handle = init_archive_deb_ar(deb_file->filename);
|
||||
init_archive_deb_data(archive_handle);
|
||||
archive_handle->dpkg__sub_archive->accept = conffile_list;
|
||||
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;
|
||||
@@ -1612,40 +1698,57 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv)
|
||||
int state_status;
|
||||
int status_num;
|
||||
int i;
|
||||
enum {
|
||||
OPT_configure = 0x1,
|
||||
OPT_force_ignore_depends = 0x2,
|
||||
OPT_install = 0x4,
|
||||
OPT_list_installed = 0x8,
|
||||
OPT_purge = 0x10,
|
||||
OPT_remove = 0x20,
|
||||
OPT_unpack = 0x40,
|
||||
};
|
||||
#if ENABLE_LONG_OPTS
|
||||
static const char dpkg_longopts[] ALIGN1 =
|
||||
// FIXME: we use -C non-compatibly, should be:
|
||||
// "-C|--audit Check for broken package(s)"
|
||||
"configure\0" No_argument "C"
|
||||
"force\0" Required_argument "F"
|
||||
"install\0" No_argument "i"
|
||||
"list\0" No_argument "l"
|
||||
"purge\0" No_argument "P"
|
||||
"remove\0" No_argument "r"
|
||||
"unpack\0" No_argument "u"
|
||||
"force-depends\0" No_argument "\xff"
|
||||
"force-confnew\0" No_argument "\xfe"
|
||||
"force-confold\0" No_argument "\xfd"
|
||||
;
|
||||
#endif
|
||||
|
||||
INIT_G();
|
||||
|
||||
opt = getopt32(argv, "CF:ilPru", &str_f);
|
||||
IF_LONG_OPTS(applet_long_options = dpkg_longopts);
|
||||
opt = getopt32(argv, "CilPruF:", &str_f);
|
||||
argv += optind;
|
||||
//if (opt & OPT_configure) ... // -C
|
||||
if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg)
|
||||
if (strcmp(str_f, "depends"))
|
||||
opt &= ~OPT_force_ignore_depends;
|
||||
if (opt & OPT_force) { // -F (--force in official dpkg)
|
||||
if (strcmp(str_f, "depends") == 0)
|
||||
opt |= OPT_force_ignore_depends;
|
||||
else if (strcmp(str_f, "confnew") == 0)
|
||||
opt |= OPT_force_confnew;
|
||||
else if (strcmp(str_f, "confold") == 0)
|
||||
opt |= OPT_force_confold;
|
||||
else
|
||||
bb_show_usage();
|
||||
option_mask32 = opt;
|
||||
}
|
||||
//if (opt & OPT_install) ... // -i
|
||||
//if (opt & OPT_list_installed) ... // -l
|
||||
//if (opt & OPT_purge) ... // -P
|
||||
//if (opt & OPT_remove) ... // -r
|
||||
//if (opt & OPT_unpack) ... // -u (--unpack in official dpkg)
|
||||
argv += optind;
|
||||
/* check for non-option argument if expected */
|
||||
if (!opt || (!argv[0] && !(opt && OPT_list_installed)))
|
||||
if (!(opt & OPTMASK_cmd) /* no cmd */
|
||||
|| ((opt & OPTMASK_cmd) & ((opt & OPTMASK_cmd)-1)) /* more than one cmd */
|
||||
) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
/* puts("(Reading database ... xxxxx files and directories installed.)"); */
|
||||
index_status_file("/var/lib/dpkg/status");
|
||||
|
||||
/* if the list action was given print the installed packages and exit */
|
||||
if (opt & OPT_list_installed) {
|
||||
list_packages(argv[0]);
|
||||
list_packages(argv[0]); /* param can be NULL */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -32,14 +32,17 @@ int dpkg_deb_main(int argc, char **argv)
|
||||
ar_archive->filter = filter_accept_list_reassign;
|
||||
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ
|
||||
llist_add_to(&(ar_archive->accept), (char*)"data.tar.gz");
|
||||
llist_add_to(&ar_archive->accept, (char*)"data.tar.gz");
|
||||
llist_add_to(&control_tar_llist, (char*)"control.tar.gz");
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2");
|
||||
llist_add_to(&ar_archive->accept, (char*)"data.tar.bz2");
|
||||
llist_add_to(&control_tar_llist, (char*)"control.tar.bz2");
|
||||
#endif
|
||||
#if ENABLE_FEATURE_SEAMLESS_LZMA
|
||||
llist_add_to(&ar_archive->accept, (char*)"data.tar.lzma");
|
||||
llist_add_to(&control_tar_llist, (char*)"control.tar.lzma");
|
||||
#endif
|
||||
|
||||
opt_complementary = "c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
|
||||
opt = getopt32(argv, "cefXx");
|
||||
|
||||
+10
-14
@@ -620,10 +620,12 @@ static int longest_match(IPos cur_match)
|
||||
/* Skip to next match if the match length cannot increase
|
||||
* or if the match length is less than 2:
|
||||
*/
|
||||
if (match[best_len] != scan_end ||
|
||||
match[best_len - 1] != scan_end1 ||
|
||||
*match != *scan || *++match != scan[1])
|
||||
if (match[best_len] != scan_end
|
||||
|| match[best_len - 1] != scan_end1
|
||||
|| *match != *scan || *++match != scan[1]
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* The check at best_len-1 can be removed because it will be made
|
||||
* again later. (This heuristic is not always a win.)
|
||||
@@ -674,7 +676,7 @@ static void check_match(IPos start, IPos match, int length)
|
||||
if (verbose > 1) {
|
||||
bb_error_msg("\\[%d,%d]", start - match, length);
|
||||
do {
|
||||
fputc(G1.window[start++], stderr);
|
||||
bb_putchar_stderr(G1.window[start++]);
|
||||
} while (--length != 0);
|
||||
}
|
||||
}
|
||||
@@ -962,7 +964,7 @@ static void compress_block(ct_data * ltree, ct_data * dtree);
|
||||
#else
|
||||
# define SEND_CODE(c, tree) \
|
||||
{ \
|
||||
if (verbose > 1) bb_error_msg("\ncd %3d ",(c)); \
|
||||
if (verbose > 1) bb_error_msg("\ncd %3d ", (c)); \
|
||||
send_bits(tree[c].Code, tree[c].Len); \
|
||||
}
|
||||
#endif
|
||||
@@ -1996,13 +1998,7 @@ static void zip(ulg time_stamp)
|
||||
|
||||
/* ======================================================================== */
|
||||
static
|
||||
char* make_new_name_gzip(char *filename)
|
||||
{
|
||||
return xasprintf("%s.gz", filename);
|
||||
}
|
||||
|
||||
static
|
||||
IF_DESKTOP(long long) int pack_gzip(unpack_info_t *info UNUSED_PARAM)
|
||||
IF_DESKTOP(long long) int FAST_FUNC pack_gzip(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
struct stat s;
|
||||
|
||||
@@ -2061,7 +2057,7 @@ static const char gzip_longopts[] ALIGN1 =
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Linux kernel build uses gzip -d -n. We accept and ignore it.
|
||||
* Linux kernel build uses gzip -d -n. We accept and ignore -n.
|
||||
* Man page says:
|
||||
* -n --no-name
|
||||
* gzip: do not save the original file name and time stamp.
|
||||
@@ -2111,5 +2107,5 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* Initialise the CRC32 table */
|
||||
G1.crc_32_tab = crc32_filltable(NULL, 0);
|
||||
|
||||
return bbunpack(argv, make_new_name_gzip, pack_gzip);
|
||||
return bbunpack(argv, pack_gzip, append_ext, "gz");
|
||||
}
|
||||
@@ -33,9 +33,12 @@ DPKG_FILES:= \
|
||||
get_header_tar.o \
|
||||
filter_accept_list_reassign.o
|
||||
|
||||
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)
|
||||
@@ -49,7 +52,9 @@ lib-$(CONFIG_FEATURE_SEAMLESS_Z) += open_transformer.o decompress_uncompr
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_GZ) += open_transformer.o decompress_unzip.o get_header_tar_gz.o
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_BZ2) += open_transformer.o decompress_bunzip2.o get_header_tar_bz2.o
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_LZMA) += open_transformer.o decompress_unlzma.o get_header_tar_lzma.o
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_XZ) += open_transformer.o decompress_unxz.o
|
||||
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
|
||||
lib-$(CONFIG_FEATURE_TAR_TO_COMMAND) += data_extract_to_command.o
|
||||
|
||||
ifneq ($(lib-y),)
|
||||
lib-y += $(COMMON_FILES)
|
||||
@@ -12,6 +12,17 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
int dst_fd;
|
||||
int res;
|
||||
|
||||
#if ENABLE_FEATURE_TAR_SELINUX
|
||||
char *sctx = archive_handle->tar__next_file_sctx;
|
||||
if (!sctx)
|
||||
sctx = archive_handle->tar__global_sctx;
|
||||
if (sctx) { /* setfscreatecon is 4 syscalls, avoid if possible */
|
||||
setfscreatecon(sctx);
|
||||
free(archive_handle->tar__next_file_sctx);
|
||||
archive_handle->tar__next_file_sctx = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (archive_handle->ah_flags & ARCHIVE_CREATE_LEADING_DIRS) {
|
||||
char *slash = strrchr(file_header->name, '/');
|
||||
if (slash) {
|
||||
@@ -23,12 +34,30 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
|
||||
if (archive_handle->ah_flags & ARCHIVE_UNLINK_OLD) {
|
||||
/* Remove the entry if it exists */
|
||||
if ((!S_ISDIR(file_header->mode))
|
||||
&& (unlink(file_header->name) == -1)
|
||||
&& (errno != ENOENT)
|
||||
) {
|
||||
bb_perror_msg_and_die("can't remove old file %s",
|
||||
file_header->name);
|
||||
if (!S_ISDIR(file_header->mode)) {
|
||||
/* Is it hardlink?
|
||||
* We encode hard links as regular files of size 0 with a symlink */
|
||||
if (S_ISREG(file_header->mode)
|
||||
&& file_header->link_target
|
||||
&& file_header->size == 0
|
||||
) {
|
||||
/* Ugly special case:
|
||||
* tar cf t.tar hardlink1 hardlink2 hardlink1
|
||||
* results in this tarball structure:
|
||||
* hardlink1
|
||||
* hardlink2 -> hardlink1
|
||||
* hardlink1 -> hardlink1 <== !!!
|
||||
*/
|
||||
if (strcmp(file_header->link_target, file_header->name) == 0)
|
||||
goto ret;
|
||||
}
|
||||
/* Proceed with deleting */
|
||||
if (unlink(file_header->name) == -1
|
||||
&& errno != ENOENT
|
||||
) {
|
||||
bb_perror_msg_and_die("can't remove old file %s",
|
||||
file_header->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (archive_handle->ah_flags & ARCHIVE_EXTRACT_NEWER) {
|
||||
@@ -45,7 +74,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
"same age file exists", file_header->name);
|
||||
}
|
||||
data_skip(archive_handle);
|
||||
return;
|
||||
goto ret;
|
||||
}
|
||||
else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) {
|
||||
bb_perror_msg_and_die("can't remove old file %s",
|
||||
@@ -54,7 +83,7 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
}
|
||||
|
||||
/* Handle hard links separately
|
||||
* We identified hard links as regular files of size 0 with a symlink */
|
||||
* We encode hard links as regular files of size 0 with a symlink */
|
||||
if (S_ISREG(file_header->mode)
|
||||
&& file_header->link_target
|
||||
&& file_header->size == 0
|
||||
@@ -67,89 +96,89 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
file_header->name,
|
||||
file_header->link_target);
|
||||
}
|
||||
} else {
|
||||
/* Create the filesystem entry */
|
||||
switch (file_header->mode & S_IFMT) {
|
||||
case S_IFREG: {
|
||||
/* Regular file */
|
||||
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,
|
||||
flags,
|
||||
file_header->mode
|
||||
);
|
||||
bb_copyfd_exact_size(archive_handle->src_fd, dst_fd, file_header->size);
|
||||
close(dst_fd);
|
||||
break;
|
||||
}
|
||||
case S_IFDIR:
|
||||
res = mkdir(file_header->name, file_header->mode);
|
||||
if ((res == -1)
|
||||
&& (errno != EISDIR) /* btw, Linux doesn't return this */
|
||||
&& (errno != EEXIST)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("can't make dir %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
case S_IFLNK:
|
||||
/* Symlink */
|
||||
res = symlink(file_header->link_target, file_header->name);
|
||||
if ((res == -1)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("can't create %slink "
|
||||
"from %s to %s", "sym",
|
||||
file_header->name,
|
||||
file_header->link_target);
|
||||
}
|
||||
break;
|
||||
case S_IFSOCK:
|
||||
case S_IFBLK:
|
||||
case S_IFCHR:
|
||||
case S_IFIFO:
|
||||
res = mknod(file_header->name, file_header->mode, file_header->device);
|
||||
if ((res == -1)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("can't create node %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
bb_error_msg_and_die("unrecognized file type");
|
||||
}
|
||||
/* Hardlinks have no separate mode/ownership, skip chown/chmod */
|
||||
goto ret;
|
||||
}
|
||||
|
||||
if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_OWNER)) {
|
||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||
if (!(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)) {
|
||||
/* Create the filesystem entry */
|
||||
switch (file_header->mode & S_IFMT) {
|
||||
case S_IFREG: {
|
||||
/* Regular file */
|
||||
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,
|
||||
flags,
|
||||
file_header->mode
|
||||
);
|
||||
bb_copyfd_exact_size(archive_handle->src_fd, dst_fd, file_header->size);
|
||||
close(dst_fd);
|
||||
break;
|
||||
}
|
||||
case S_IFDIR:
|
||||
res = mkdir(file_header->name, file_header->mode);
|
||||
if ((res == -1)
|
||||
&& (errno != EISDIR) /* btw, Linux doesn't return this */
|
||||
&& (errno != EEXIST)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("can't make dir %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
case S_IFLNK:
|
||||
/* Symlink */
|
||||
//TODO: what if file_header->link_target == NULL (say, corrupted tarball?)
|
||||
res = symlink(file_header->link_target, file_header->name);
|
||||
if ((res == -1)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("can't create %slink "
|
||||
"from %s to %s", "sym",
|
||||
file_header->name,
|
||||
file_header->link_target);
|
||||
}
|
||||
break;
|
||||
case S_IFSOCK:
|
||||
case S_IFBLK:
|
||||
case S_IFCHR:
|
||||
case S_IFIFO:
|
||||
res = mknod(file_header->name, file_header->mode, file_header->device);
|
||||
if ((res == -1)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("can't create node %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
bb_error_msg_and_die("unrecognized file type");
|
||||
}
|
||||
|
||||
if (!S_ISLNK(file_header->mode)) {
|
||||
if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_OWNER)) {
|
||||
uid_t uid = file_header->uid;
|
||||
gid_t gid = file_header->gid;
|
||||
|
||||
if (file_header->tar__uname) {
|
||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||
if (!(archive_handle->ah_flags & ARCHIVE_NUMERIC_OWNER)) {
|
||||
if (file_header->tar__uname) {
|
||||
//TODO: cache last name/id pair?
|
||||
struct passwd *pwd = getpwnam(file_header->tar__uname);
|
||||
if (pwd) uid = pwd->pw_uid;
|
||||
}
|
||||
if (file_header->tar__gname) {
|
||||
struct group *grp = getgrnam(file_header->tar__gname);
|
||||
if (grp) gid = grp->gr_gid;
|
||||
struct passwd *pwd = getpwnam(file_header->tar__uname);
|
||||
if (pwd) uid = pwd->pw_uid;
|
||||
}
|
||||
if (file_header->tar__gname) {
|
||||
struct group *grp = getgrnam(file_header->tar__gname);
|
||||
if (grp) gid = grp->gr_gid;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* GNU tar 1.15.1 uses chown, not lchown */
|
||||
chown(file_header->name, uid, gid);
|
||||
} else
|
||||
#endif
|
||||
chown(file_header->name, file_header->uid, file_header->gid);
|
||||
}
|
||||
if (!S_ISLNK(file_header->mode)) {
|
||||
}
|
||||
/* uclibc has no lchmod, glibc is even stranger -
|
||||
* it has lchmod which seems to do nothing!
|
||||
* so we use chmod... */
|
||||
if (!(archive_handle->ah_flags & ARCHIVE_DONT_RESTORE_PERM)) {
|
||||
chmod(file_header->name, file_header->mode);
|
||||
}
|
||||
/* same for utime */
|
||||
if (archive_handle->ah_flags & ARCHIVE_RESTORE_DATE) {
|
||||
struct timeval t[2];
|
||||
|
||||
@@ -158,4 +187,12 @@ void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
utimes(file_header->name, t);
|
||||
}
|
||||
}
|
||||
|
||||
ret: ;
|
||||
#if ENABLE_FEATURE_TAR_SELINUX
|
||||
if (sctx) {
|
||||
/* reset the context after creating an entry */
|
||||
setfscreatecon(NULL);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
enum {
|
||||
//TAR_FILETYPE,
|
||||
TAR_MODE,
|
||||
TAR_FILENAME,
|
||||
TAR_REALNAME,
|
||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||
TAR_UNAME,
|
||||
TAR_GNAME,
|
||||
#endif
|
||||
TAR_SIZE,
|
||||
TAR_UID,
|
||||
TAR_GID,
|
||||
TAR_MAX,
|
||||
};
|
||||
|
||||
static const char *const tar_var[] = {
|
||||
// "FILETYPE",
|
||||
"MODE",
|
||||
"FILENAME",
|
||||
"REALNAME",
|
||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||
"UNAME",
|
||||
"GNAME",
|
||||
#endif
|
||||
"SIZE",
|
||||
"UID",
|
||||
"GID",
|
||||
};
|
||||
|
||||
static void xputenv(char *str)
|
||||
{
|
||||
if (putenv(str))
|
||||
bb_error_msg_and_die(bb_msg_memory_exhausted);
|
||||
}
|
||||
|
||||
static void str2env(char *env[], int idx, const char *str)
|
||||
{
|
||||
env[idx] = xasprintf("TAR_%s=%s", tar_var[idx], str);
|
||||
xputenv(env[idx]);
|
||||
}
|
||||
|
||||
static void dec2env(char *env[], int idx, unsigned long long val)
|
||||
{
|
||||
env[idx] = xasprintf("TAR_%s=%llu", tar_var[idx], val);
|
||||
xputenv(env[idx]);
|
||||
}
|
||||
|
||||
static void oct2env(char *env[], int idx, unsigned long val)
|
||||
{
|
||||
env[idx] = xasprintf("TAR_%s=%lo", tar_var[idx], val);
|
||||
xputenv(env[idx]);
|
||||
}
|
||||
|
||||
void FAST_FUNC data_extract_to_command(archive_handle_t *archive_handle)
|
||||
{
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
|
||||
#if 0 /* do we need this? ENABLE_FEATURE_TAR_SELINUX */
|
||||
char *sctx = archive_handle->tar__next_file_sctx;
|
||||
if (!sctx)
|
||||
sctx = archive_handle->tar__global_sctx;
|
||||
if (sctx) { /* setfscreatecon is 4 syscalls, avoid if possible */
|
||||
setfscreatecon(sctx);
|
||||
free(archive_handle->tar__next_file_sctx);
|
||||
archive_handle->tar__next_file_sctx = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((file_header->mode & S_IFMT) == S_IFREG) {
|
||||
pid_t pid;
|
||||
int p[2], status;
|
||||
char *tar_env[TAR_MAX];
|
||||
|
||||
memset(tar_env, 0, sizeof(tar_env));
|
||||
|
||||
xpipe(p);
|
||||
pid = BB_MMU ? xfork() : xvfork();
|
||||
if (pid == 0) {
|
||||
/* Child */
|
||||
/* str2env(tar_env, TAR_FILETYPE, "f"); - parent should do it once */
|
||||
oct2env(tar_env, TAR_MODE, file_header->mode);
|
||||
str2env(tar_env, TAR_FILENAME, file_header->name);
|
||||
str2env(tar_env, TAR_REALNAME, file_header->name);
|
||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||
str2env(tar_env, TAR_UNAME, file_header->tar__uname);
|
||||
str2env(tar_env, TAR_GNAME, file_header->tar__gname);
|
||||
#endif
|
||||
dec2env(tar_env, TAR_SIZE, file_header->size);
|
||||
dec2env(tar_env, TAR_UID, file_header->uid);
|
||||
dec2env(tar_env, TAR_GID, file_header->gid);
|
||||
close(p[1]);
|
||||
xdup2(p[0], STDIN_FILENO);
|
||||
signal(SIGPIPE, SIG_DFL);
|
||||
execl(DEFAULT_SHELL, DEFAULT_SHELL_SHORT_NAME, "-c", archive_handle->tar__to_command, NULL);
|
||||
bb_perror_msg_and_die("can't execute '%s'", DEFAULT_SHELL);
|
||||
}
|
||||
close(p[0]);
|
||||
/* Our caller is expected to do signal(SIGPIPE, SIG_IGN)
|
||||
* so that we don't die if child don't read all the input: */
|
||||
bb_copyfd_exact_size(archive_handle->src_fd, p[1], -file_header->size);
|
||||
close(p[1]);
|
||||
|
||||
if (safe_waitpid(pid, &status, 0) == -1)
|
||||
bb_perror_msg_and_die("waitpid");
|
||||
if (WIFEXITED(status) && WEXITSTATUS(status))
|
||||
bb_error_msg_and_die("'%s' returned status %d",
|
||||
archive_handle->tar__to_command, WEXITSTATUS(status));
|
||||
if (WIFSIGNALED(status))
|
||||
bb_error_msg_and_die("'%s' terminated on signal %d",
|
||||
archive_handle->tar__to_command, WTERMSIG(status));
|
||||
|
||||
if (!BB_MMU) {
|
||||
int i;
|
||||
for (i = 0; i < TAR_MAX; i++) {
|
||||
if (tar_env[i])
|
||||
bb_unsetenv_and_free(tar_env[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if 0 /* ENABLE_FEATURE_TAR_SELINUX */
|
||||
if (sctx)
|
||||
/* reset the context after creating an entry */
|
||||
setfscreatecon(NULL);
|
||||
#endif
|
||||
}
|
||||
@@ -692,9 +692,9 @@ unpack_bz2_stream(int src_fd, int dst_fd)
|
||||
IF_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_bz2_stream_prime(int src_fd, int dst_fd)
|
||||
{
|
||||
unsigned char magic[2];
|
||||
xread(src_fd, magic, 2);
|
||||
if (magic[0] != 'B' || magic[1] != 'Z') {
|
||||
uint16_t magic2;
|
||||
xread(src_fd, &magic2, 2);
|
||||
if (magic2 != BZIP2_MAGIC) {
|
||||
bb_error_msg_and_die("invalid magic");
|
||||
}
|
||||
return unpack_bz2_stream(src_fd, dst_fd);
|
||||
|
||||
@@ -229,7 +229,7 @@ unpack_Z_stream(int fd_in, int fd_out)
|
||||
("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));
|
||||
bb_error_msg("uncompress: corrupt input");
|
||||
bb_error_msg("corrupted data");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* This file uses XZ Embedded library code which is written
|
||||
* by Lasse Collin <lasse.collin@tukaani.org>
|
||||
* and Igor Pavlov <http://7-zip.org/>
|
||||
*
|
||||
* See README file in unxz/ directory for more information.
|
||||
*
|
||||
* This file is:
|
||||
* Copyright (C) 2010 Denys Vlasenko <vda.linux@googlemail.com>
|
||||
* Licensed under GPLv2, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define XZ_FUNC FAST_FUNC
|
||||
#define XZ_EXTERN static
|
||||
|
||||
#define XZ_DEC_DYNALLOC
|
||||
|
||||
/* Skip check (rather than fail) of unsupported hash functions */
|
||||
#define XZ_DEC_ANY_CHECK 1
|
||||
|
||||
/* We use our own crc32 function */
|
||||
#define XZ_INTERNAL_CRC32 0
|
||||
static uint32_t *crc32_table;
|
||||
static uint32_t xz_crc32(const uint8_t *buf, size_t size, uint32_t crc)
|
||||
{
|
||||
crc = ~crc;
|
||||
|
||||
while (size != 0) {
|
||||
crc = crc32_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);
|
||||
--size;
|
||||
}
|
||||
|
||||
return ~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))
|
||||
|
||||
#include "unxz/xz_dec_bcj.c"
|
||||
#include "unxz/xz_dec_lzma2.c"
|
||||
#include "unxz/xz_dec_stream.c"
|
||||
|
||||
IF_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_xz_stream(int src_fd, int dst_fd)
|
||||
{
|
||||
struct xz_buf iobuf;
|
||||
struct xz_dec *state;
|
||||
unsigned char *membuf;
|
||||
IF_DESKTOP(long long) int total = 0;
|
||||
|
||||
if (!crc32_table)
|
||||
crc32_table = crc32_filltable(NULL, /*endian:*/ 0);
|
||||
|
||||
memset(&iobuf, 0, sizeof(iobuf));
|
||||
/* Preload XZ file signature */
|
||||
membuf = (void*) strcpy(xmalloc(2 * BUFSIZ), HEADER_MAGIC);
|
||||
iobuf.in = membuf;
|
||||
iobuf.in_size = HEADER_MAGIC_SIZE;
|
||||
iobuf.out = membuf + BUFSIZ;
|
||||
iobuf.out_size = BUFSIZ;
|
||||
|
||||
/* Limit memory usage to about 64 MiB. */
|
||||
state = xz_dec_init(XZ_DYNALLOC, 64*1024*1024);
|
||||
|
||||
while (1) {
|
||||
enum xz_ret r;
|
||||
|
||||
if (iobuf.in_pos == iobuf.in_size) {
|
||||
int rd = safe_read(src_fd, membuf, BUFSIZ);
|
||||
if (rd < 0) {
|
||||
bb_error_msg(bb_msg_read_error);
|
||||
total = -1;
|
||||
break;
|
||||
}
|
||||
iobuf.in_size = rd;
|
||||
iobuf.in_pos = 0;
|
||||
}
|
||||
// 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);
|
||||
// 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);
|
||||
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 (r != XZ_OK && r != XZ_UNSUPPORTED_CHECK) {
|
||||
bb_error_msg("corrupted data");
|
||||
total = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
xz_dec_end(state);
|
||||
free(membuf);
|
||||
|
||||
return total;
|
||||
}
|
||||
@@ -575,13 +575,16 @@ static NOINLINE int inflate_codes(STATE_PARAM_ONLY)
|
||||
do {
|
||||
/* Was: nn -= (e = (e = GUNZIP_WSIZE - ((dd &= GUNZIP_WSIZE - 1) > w ? dd : w)) > nn ? nn : e); */
|
||||
/* Who wrote THAT?? rewritten as: */
|
||||
unsigned delta;
|
||||
|
||||
dd &= GUNZIP_WSIZE - 1;
|
||||
e = GUNZIP_WSIZE - (dd > w ? dd : w);
|
||||
delta = w > dd ? w - dd : dd - w;
|
||||
if (e > nn) e = nn;
|
||||
nn -= e;
|
||||
|
||||
/* copy to new buffer to prevent possible overwrite */
|
||||
if (w - dd >= e) { /* (this test assumes unsigned comparison) */
|
||||
if (delta >= e) {
|
||||
memcpy(gunzip_window + w, gunzip_window + dd, e);
|
||||
w += e;
|
||||
dd += e;
|
||||
@@ -1069,7 +1072,7 @@ static int top_up(STATE_PARAM unsigned n)
|
||||
bytebuffer_offset = 0;
|
||||
bytebuffer_size = full_read(gunzip_src_fd, &bytebuffer[count], bytebuffer_max - count);
|
||||
if ((int)bytebuffer_size < 0) {
|
||||
bb_error_msg("read error");
|
||||
bb_error_msg(bb_msg_read_error);
|
||||
return 0;
|
||||
}
|
||||
bytebuffer_size += count;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
#include "ar.h"
|
||||
|
||||
static unsigned read_num(const char *str, int base)
|
||||
{
|
||||
@@ -23,15 +24,7 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
|
||||
unsigned size;
|
||||
union {
|
||||
char raw[60];
|
||||
struct {
|
||||
char name[16];
|
||||
char date[12];
|
||||
char uid[6];
|
||||
char gid[6];
|
||||
char mode[8];
|
||||
char size[10];
|
||||
char magic[2];
|
||||
} formatted;
|
||||
struct ar_header formatted;
|
||||
} ar;
|
||||
#if ENABLE_FEATURE_AR_LONG_FILENAMES
|
||||
static char *ar_long_names;
|
||||
@@ -55,13 +48,13 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
|
||||
}
|
||||
archive_handle->offset += 60;
|
||||
|
||||
/* align the headers based on the header magic */
|
||||
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);
|
||||
|
||||
/* special filenames have '/' as the first character */
|
||||
|
||||
@@ -14,119 +14,114 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/*
|
||||
* GNU tar uses "base-256 encoding" for very large numbers (>8 billion).
|
||||
* 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
|
||||
*
|
||||
* We expect it only in size field, where negative numbers don't make sense.
|
||||
*/
|
||||
static off_t getBase256_len12(const char *str)
|
||||
{
|
||||
off_t value;
|
||||
int len;
|
||||
typedef uint32_t aliased_uint32_t FIX_ALIASING;
|
||||
typedef off_t aliased_off_t FIX_ALIASING;
|
||||
|
||||
/* if (*str & 0x40) error; - caller prevents this */
|
||||
|
||||
if (sizeof(off_t) >= 12) {
|
||||
/* Probably 128-bit (16 byte) off_t. Can be optimized. */
|
||||
len = 12;
|
||||
value = *str++ & 0x3f;
|
||||
while (--len)
|
||||
value = (value << 8) + (unsigned char) *str++;
|
||||
return value;
|
||||
}
|
||||
|
||||
#ifdef CHECK_FOR_OVERFLOW
|
||||
/* Can be optimized to eat 32-bit chunks */
|
||||
char c = *str++ & 0x3f;
|
||||
len = 12;
|
||||
while (1) {
|
||||
if (c)
|
||||
bb_error_msg_and_die("overflow in base-256 encoded file size");
|
||||
if (--len == sizeof(off_t))
|
||||
break;
|
||||
c = *str++;
|
||||
}
|
||||
#else
|
||||
str += (12 - sizeof(off_t));
|
||||
#endif
|
||||
|
||||
/* Now str points to sizeof(off_t) least significant bytes.
|
||||
*
|
||||
* Example of tar file with 8914993153 (0x213600001) byte file.
|
||||
* Field starts at offset 7c:
|
||||
* 00070 30 30 30 00 30 30 30 30 30 30 30 00 80 00 00 00 |000.0000000.....|
|
||||
* 00080 00 00 00 02 13 60 00 01 31 31 31 32 30 33 33 36 |.....`..11120336|
|
||||
*
|
||||
* str is at offset 80 or 84 now (64-bit or 32-bit off_t).
|
||||
* We (ab)use the fact that value happens to be aligned,
|
||||
* and fetch it in one go:
|
||||
*/
|
||||
if (sizeof(off_t) == 8) {
|
||||
value = *(off_t*)str;
|
||||
value = SWAP_BE64(value);
|
||||
} else if (sizeof(off_t) == 4) {
|
||||
value = *(off_t*)str;
|
||||
value = SWAP_BE32(value);
|
||||
} else {
|
||||
value = 0;
|
||||
len = sizeof(off_t);
|
||||
while (--len)
|
||||
value = (value << 8) + (unsigned char) *str++;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/* NB: _DESTROYS_ str[len] character! */
|
||||
static unsigned long long getOctal(char *str, int len)
|
||||
{
|
||||
unsigned long long v;
|
||||
char *end;
|
||||
/* NB: leading spaces are allowed. Using strtoull to handle that.
|
||||
* The downside is that we accept e.g. "-123" too :(
|
||||
*/
|
||||
str[len] = '\0';
|
||||
v = strtoull(str, &str, 8);
|
||||
v = strtoull(str, &end, 8);
|
||||
/* std: "Each numeric field is terminated by one or more
|
||||
* <space> or NUL characters". We must support ' '! */
|
||||
if (*str != '\0' && *str != ' ')
|
||||
bb_error_msg_and_die("corrupted octal value in tar header");
|
||||
if (*end != '\0' && *end != ' ') {
|
||||
int8_t first = str[0];
|
||||
if (!(first & 0x80))
|
||||
bb_error_msg_and_die("corrupted octal value in tar header");
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* Example of tar file with 8914993153 (0x213600001) byte file.
|
||||
* Field starts at offset 7c:
|
||||
* 00070 30 30 30 00 30 30 30 30 30 30 30 00 80 00 00 00 |000.0000000.....|
|
||||
* 00080 00 00 00 02 13 60 00 01 31 31 31 32 30 33 33 36 |.....`..11120336|
|
||||
*
|
||||
* NB: tarballs with NEGATIVE unix times encoded that way were seen!
|
||||
*/
|
||||
v = first;
|
||||
/* Sign-extend using 6th bit: */
|
||||
v <<= sizeof(unsigned long long)*8 - 7;
|
||||
v = (long long)v >> (sizeof(unsigned long long)*8 - 7);
|
||||
while (--len != 0)
|
||||
v = (v << 8) + (unsigned char) *str++;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
#define GET_OCTAL(a) getOctal((a), sizeof(a))
|
||||
|
||||
void BUG_tar_header_size(void);
|
||||
#if ENABLE_FEATURE_TAR_SELINUX
|
||||
/* Scan a PAX header for SELinux contexts, via "RHT.security.selinux" keyword.
|
||||
* This is what Red Hat's patched version of tar uses.
|
||||
*/
|
||||
# define SELINUX_CONTEXT_KEYWORD "RHT.security.selinux"
|
||||
static char *get_selinux_sctx_from_pax_hdr(archive_handle_t *archive_handle, unsigned sz)
|
||||
{
|
||||
char *buf, *p;
|
||||
char *result;
|
||||
|
||||
p = buf = xmalloc(sz + 1);
|
||||
/* prevent bb_strtou from running off the buffer */
|
||||
buf[sz] = '\0';
|
||||
xread(archive_handle->src_fd, buf, sz);
|
||||
archive_handle->offset += sz;
|
||||
|
||||
result = NULL;
|
||||
while (sz != 0) {
|
||||
char *end, *value;
|
||||
unsigned len;
|
||||
|
||||
/* Every record has this format: "LEN NAME=VALUE\n" */
|
||||
len = bb_strtou(p, &end, 10);
|
||||
/* expect errno to be EINVAL, because the character
|
||||
* following the digits should be a space
|
||||
*/
|
||||
p += len;
|
||||
sz -= len;
|
||||
if ((int)sz < 0
|
||||
|| len == 0
|
||||
|| errno != EINVAL
|
||||
|| *end != ' '
|
||||
) {
|
||||
bb_error_msg("malformed extended header, skipped");
|
||||
// More verbose version:
|
||||
//bb_error_msg("malformed extended header at %"OFF_FMT"d, skipped",
|
||||
// archive_handle->offset - (sz + len));
|
||||
break;
|
||||
}
|
||||
/* overwrite the terminating newline with NUL
|
||||
* (we do not bother to check that it *was* a newline)
|
||||
*/
|
||||
p[-1] = '\0';
|
||||
/* Is it selinux security context? */
|
||||
value = end + 1;
|
||||
if (strncmp(value, SELINUX_CONTEXT_KEYWORD"=", sizeof(SELINUX_CONTEXT_KEYWORD"=") - 1) == 0) {
|
||||
value += sizeof(SELINUX_CONTEXT_KEYWORD"=") - 1;
|
||||
result = xstrdup(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(buf);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
{
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
struct {
|
||||
/* ustar header, Posix 1003.1 */
|
||||
char name[100]; /* 0-99 */
|
||||
char mode[8]; /* 100-107 */
|
||||
char uid[8]; /* 108-115 */
|
||||
char gid[8]; /* 116-123 */
|
||||
char size[12]; /* 124-135 */
|
||||
char mtime[12]; /* 136-147 */
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char linkname[100]; /* 157-256 */
|
||||
/* POSIX: "ustar" NUL "00" */
|
||||
/* GNU tar: "ustar " NUL */
|
||||
/* Normally it's defined as magic[6] followed by
|
||||
* version[2], but we put them together to simplify code
|
||||
*/
|
||||
char magic[8]; /* 257-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char devmajor[8]; /* 329-336 */
|
||||
char devminor[8]; /* 337-344 */
|
||||
char prefix[155]; /* 345-499 */
|
||||
char padding[12]; /* 500-512 */
|
||||
} tar;
|
||||
struct tar_header_t tar;
|
||||
char *cp;
|
||||
int i, sum_u, sum;
|
||||
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
@@ -143,10 +138,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
# define p_linkname 0
|
||||
#endif
|
||||
|
||||
if (sizeof(tar) != 512)
|
||||
BUG_tar_header_size();
|
||||
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS || ENABLE_FEATURE_TAR_SELINUX
|
||||
again:
|
||||
#endif
|
||||
/* Align header */
|
||||
@@ -156,7 +148,7 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
|
||||
#if ENABLE_DESKTOP || ENABLE_FEATURE_TAR_AUTODETECT
|
||||
/* to prevent misdetection of bz2 sig */
|
||||
*(uint32_t*)(&tar) = 0;
|
||||
*(aliased_uint32_t*)&tar = 0;
|
||||
i = full_read(archive_handle->src_fd, &tar, 512);
|
||||
/* If GNU tar sees EOF in above read, it says:
|
||||
* "tar: A lone zero block at N", where N = kilobyte
|
||||
@@ -204,25 +196,31 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
) {
|
||||
#if ENABLE_FEATURE_TAR_AUTODETECT
|
||||
char FAST_FUNC (*get_header_ptr)(archive_handle_t *);
|
||||
uint16_t magic2;
|
||||
|
||||
autodetect:
|
||||
magic2 = *(uint16_t*)tar.name;
|
||||
/* tar gz/bz autodetect: check for gz/bz2 magic.
|
||||
* If we see the magic, and it is the very first block,
|
||||
* we can switch to get_header_tar_gz/bz2/lzma().
|
||||
* Needs seekable fd. I wish recv(MSG_PEEK) works
|
||||
* on any fd... */
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ
|
||||
if (tar.name[0] == 0x1f && tar.name[1] == (char)0x8b) { /* gzip */
|
||||
# if ENABLE_FEATURE_SEAMLESS_GZ
|
||||
if (magic2 == GZIP_MAGIC) {
|
||||
get_header_ptr = get_header_tar_gz;
|
||||
} else
|
||||
#endif
|
||||
#if ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
if (tar.name[0] == 'B' && tar.name[1] == 'Z'
|
||||
# endif
|
||||
# if ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
if (magic2 == BZIP2_MAGIC
|
||||
&& tar.name[2] == 'h' && isdigit(tar.name[3])
|
||||
) { /* bzip2 */
|
||||
get_header_ptr = get_header_tar_bz2;
|
||||
} else
|
||||
#endif
|
||||
# endif
|
||||
# if ENABLE_FEATURE_SEAMLESS_XZ
|
||||
//TODO: if (magic2 == XZ_MAGIC1)...
|
||||
//else
|
||||
# endif
|
||||
goto err;
|
||||
/* Two different causes for lseek() != 0:
|
||||
* unseekable fd (would like to support that too, but...),
|
||||
@@ -297,15 +295,8 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
file_header->tar__uname = tar.uname[0] ? xstrndup(tar.uname, sizeof(tar.uname)) : NULL;
|
||||
file_header->tar__gname = tar.gname[0] ? xstrndup(tar.gname, sizeof(tar.gname)) : NULL;
|
||||
#endif
|
||||
/* mtime: rudimentally handle GNU tar's "base256 encoding"
|
||||
* People report tarballs with NEGATIVE unix times encoded that way */
|
||||
file_header->mtime = (tar.mtime[0] & 0x80) /* base256? */
|
||||
? 0 /* bogus */
|
||||
: GET_OCTAL(tar.mtime);
|
||||
/* size: handle GNU tar's "base256 encoding" */
|
||||
file_header->size = (tar.size[0] & 0xc0) == 0x80 /* positive base256? */
|
||||
? getBase256_len12(tar.size)
|
||||
: GET_OCTAL(tar.size);
|
||||
file_header->mtime = GET_OCTAL(tar.mtime);
|
||||
file_header->size = GET_OCTAL(tar.size);
|
||||
file_header->gid = GET_OCTAL(tar.gid);
|
||||
file_header->uid = GET_OCTAL(tar.uid);
|
||||
/* Set bits 0-11 of the files mode */
|
||||
@@ -388,8 +379,13 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
case 'S': /* Sparse file */
|
||||
case 'V': /* Volume header */
|
||||
#endif
|
||||
#if !ENABLE_FEATURE_TAR_SELINUX
|
||||
case 'g': /* pax global header */
|
||||
case 'x': { /* pax extended header */
|
||||
case 'x': /* pax extended header */
|
||||
#else
|
||||
skip_ext_hdr:
|
||||
#endif
|
||||
{
|
||||
off_t sz;
|
||||
bb_error_msg("warning: skipping header '%c'", tar.typeflag);
|
||||
sz = (file_header->size + 511) & ~(off_t)511;
|
||||
@@ -400,6 +396,18 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
/* return get_header_tar(archive_handle); */
|
||||
goto again_after_align;
|
||||
}
|
||||
#if ENABLE_FEATURE_TAR_SELINUX
|
||||
case 'g': /* pax global header */
|
||||
case 'x': { /* pax extended header */
|
||||
char **pp;
|
||||
if ((uoff_t)file_header->size > 0xfffff) /* paranoia */
|
||||
goto skip_ext_hdr;
|
||||
pp = (tar.typeflag == 'g') ? &archive_handle->tar__global_sctx : &archive_handle->tar__next_file_sctx;
|
||||
free(*pp);
|
||||
*pp = get_selinux_sctx_from_pax_hdr(archive_handle, file_header->size);
|
||||
goto again;
|
||||
}
|
||||
#endif
|
||||
default:
|
||||
bb_error_msg_and_die("unknown typeflag: 0x%x", tar.typeflag);
|
||||
}
|
||||
@@ -429,10 +437,13 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
archive_handle->action_header(/*archive_handle->*/ file_header);
|
||||
/* Note that we kill the '/' only after action_header() */
|
||||
/* (like GNU tar 1.15.1: verbose mode outputs "dir/dir/") */
|
||||
if (cp) *cp = '\0';
|
||||
archive_handle->ah_flags |= ARCHIVE_EXTRACT_QUIET;
|
||||
if (cp)
|
||||
*cp = '\0';
|
||||
archive_handle->action_data(archive_handle);
|
||||
llist_add_to(&(archive_handle->passed), file_header->name);
|
||||
if (archive_handle->accept || archive_handle->reject)
|
||||
llist_add_to(&archive_handle->passed, file_header->name);
|
||||
else /* Caller isn't interested in list of unpacked files */
|
||||
free(file_header->name);
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
free(file_header->name);
|
||||
@@ -440,7 +451,8 @@ char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
free(file_header->link_target);
|
||||
/* Do not free(file_header->name)! (why?) */
|
||||
/* Do not free(file_header->name)!
|
||||
* It might be inserted in archive_handle->passed - see above */
|
||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||
free(file_header->tar__uname);
|
||||
free(file_header->tar__gname);
|
||||
|
||||
@@ -61,6 +61,7 @@ void FAST_FUNC header_verbose_list(const file_header_t *file_header)
|
||||
|
||||
#endif /* FEATURE_TAR_UNAME_GNAME */
|
||||
|
||||
/* NB: GNU tar shows "->" for symlinks and "link to" for hardlinks */
|
||||
if (file_header->link_target) {
|
||||
printf(" -> %s", file_header->link_target);
|
||||
}
|
||||
|
||||
@@ -19,19 +19,9 @@ void FAST_FUNC open_transformer(int fd,
|
||||
int pid;
|
||||
|
||||
xpiped_pair(fd_pipe);
|
||||
|
||||
#if BB_MMU
|
||||
pid = fork();
|
||||
if (pid == -1)
|
||||
bb_perror_msg_and_die("vfork" + 1);
|
||||
#else
|
||||
pid = vfork();
|
||||
if (pid == -1)
|
||||
bb_perror_msg_and_die("vfork");
|
||||
#endif
|
||||
|
||||
pid = BB_MMU ? xfork() : xvfork();
|
||||
if (pid == 0) {
|
||||
/* child process */
|
||||
/* Child */
|
||||
close(fd_pipe.rd); /* we don't want to read from the parent */
|
||||
// FIXME: error check?
|
||||
#if BB_MMU
|
||||
|
||||
@@ -5,16 +5,17 @@
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
#include "ar.h"
|
||||
|
||||
void FAST_FUNC unpack_ar_archive(archive_handle_t *ar_archive)
|
||||
{
|
||||
char magic[7];
|
||||
|
||||
xread(ar_archive->src_fd, magic, 7);
|
||||
if (strncmp(magic, "!<arch>", 7) != 0) {
|
||||
xread(ar_archive->src_fd, magic, AR_MAGIC_LEN);
|
||||
if (strncmp(magic, AR_MAGIC, AR_MAGIC_LEN) != 0) {
|
||||
bb_error_msg_and_die("invalid ar magic");
|
||||
}
|
||||
ar_archive->offset += 7;
|
||||
ar_archive->offset += AR_MAGIC_LEN;
|
||||
|
||||
while (get_header_ar(ar_archive) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
|
||||
XZ Embedded
|
||||
===========
|
||||
|
||||
XZ Embedded is a relatively small, limited implementation of the .xz
|
||||
file format. Currently only decoding is implemented.
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
read linux/Documentation/xz.txt even if you aren't using XZ Embedded
|
||||
as part of Linux; information in that file is not repeated in this
|
||||
README.
|
||||
|
||||
Compiling the Linux kernel module
|
||||
|
||||
The xz_dec module depends on crc32 module, so make sure that you have
|
||||
it enabled (CONFIG_CRC32).
|
||||
|
||||
Building the xz_dec and xz_dec_test modules without support for BCJ
|
||||
filters:
|
||||
|
||||
cd linux/lib/xz
|
||||
make -C /path/to/kernel/source \
|
||||
KCPPFLAGS=-I"$(pwd)/../../include" M="$(pwd)" \
|
||||
CONFIG_XZ_DEC=m CONFIG_XZ_DEC_TEST=m
|
||||
|
||||
Building the xz_dec and xz_dec_test modules with support for BCJ
|
||||
filters:
|
||||
|
||||
cd linux/lib/xz
|
||||
make -C /path/to/kernel/source \
|
||||
KCPPFLAGS=-I"$(pwd)/../../include" M="$(pwd)" \
|
||||
CONFIG_XZ_DEC=m CONFIG_XZ_DEC_TEST=m CONFIG_XZ_DEC_BCJ=y \
|
||||
CONFIG_XZ_DEC_X86=y CONFIG_XZ_DEC_POWERPC=y \
|
||||
CONFIG_XZ_DEC_IA64=y CONFIG_XZ_DEC_ARM=y \
|
||||
CONFIG_XZ_DEC_ARMTHUMB=y CONFIG_XZ_DEC_SPARC=y
|
||||
|
||||
If you want only one or a few of the BCJ filters, omit the appropriate
|
||||
variables. CONFIG_XZ_DEC_BCJ=y is always required to build the support
|
||||
code shared between all BCJ filters.
|
||||
|
||||
Most people don't need the xz_dec_test module. You can skip building
|
||||
it by omitting CONFIG_XZ_DEC_TEST=m from the make command line.
|
||||
|
||||
Compiler requirements
|
||||
|
||||
XZ Embedded should compile as either GNU-C89 (used in the Linux
|
||||
kernel) or with any C99 compiler. Getting the code to compile with
|
||||
non-GNU C89 compiler or a C++ compiler should be quite easy as
|
||||
long as there is a data type for unsigned 64-bit integer (or the
|
||||
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,
|
||||
xz_dec_lzma2.c compiled with GCC 3.3.6 is 15-25 % slower than when
|
||||
compiled with GCC 4.3.3.
|
||||
|
||||
Embedding into userspace applications
|
||||
|
||||
To embed the XZ decoder, copy the following files into a single
|
||||
directory in your source code tree:
|
||||
|
||||
linux/include/linux/xz.h
|
||||
linux/lib/xz/xz_crc32.c
|
||||
linux/lib/xz/xz_dec_lzma2.c
|
||||
linux/lib/xz/xz_dec_stream.c
|
||||
linux/lib/xz/xz_lzma2.h
|
||||
linux/lib/xz/xz_private.h
|
||||
linux/lib/xz/xz_stream.h
|
||||
userspace/xz_config.h
|
||||
|
||||
Alternatively, xz.h may be placed into a different directory but then
|
||||
that directory must be in the compiler include path when compiling
|
||||
the .c files.
|
||||
|
||||
Your code should use only the functions declared in xz.h. The rest of
|
||||
the .h files are meant only for internal use in XZ Embedded.
|
||||
|
||||
You may want to modify xz_config.h to be more suitable for your build
|
||||
environment. Probably you should at least skim through it even if the
|
||||
default file works as is.
|
||||
|
||||
BCJ filter support
|
||||
|
||||
If you want support for one or more BCJ filters, you need to copy also
|
||||
linux/lib/xz/xz_dec_bcj.c into your application, and use appropriate
|
||||
#defines in xz_config.h or in compiler flags. You don't need these
|
||||
#defines in the code that just uses XZ Embedded via xz.h, but having
|
||||
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_POWERPC PowerPC Big endian only
|
||||
XZ_DEC_IA64 Itanium (IA-64) Big or little endian
|
||||
XZ_DEC_ARM ARM Little endian only
|
||||
XZ_DEC_ARMTHUMB ARM-Thumb Little endian only
|
||||
XZ_DEC_SPARC SPARC Big or little endian
|
||||
|
||||
While some architectures are (partially) bi-endian, the endianness
|
||||
setting doesn't change the endianness of the instructions on all
|
||||
architectures. That's why Itanium and SPARC filters work for both big
|
||||
and little endian executables (Itanium has little endian instructions
|
||||
and SPARC has big endian instructions).
|
||||
|
||||
There currently is no filter for little endian PowerPC or big endian
|
||||
ARM or ARM-Thumb. Implementing filters for them can be considered if
|
||||
there is a need for such filters in real-world applications.
|
||||
|
||||
Notes about shared libraries
|
||||
|
||||
If you are including XZ Embedded into a shared library, you very
|
||||
probably should rename the xz_* functions to prevent symbol
|
||||
conflicts in case your library is linked against some other library
|
||||
or application that also has XZ Embedded in it (which may even be
|
||||
a different version of XZ Embedded). TODO: Provide an easy way
|
||||
to do this.
|
||||
|
||||
Please don't create a shared library of XZ Embedded itself unless
|
||||
it is fine to rebuild everything depending on that shared library
|
||||
everytime you upgrade to a newer version of XZ Embedded. There are
|
||||
no API or ABI stability guarantees between different versions of
|
||||
XZ Embedded.
|
||||
|
||||
Specifying the calling convention
|
||||
|
||||
XZ_FUNC macro was included to support declaring functions with __init
|
||||
in Linux. Outside Linux, it can be used to specify the calling
|
||||
convention on systems that support multiple calling conventions.
|
||||
For example, on Windows, you may make all functions use the stdcall
|
||||
calling convention by defining XZ_FUNC=__stdcall when building and
|
||||
using the functions from XZ Embedded.
|
||||
|
||||
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* XZ decompressor
|
||||
*
|
||||
* Authors: Lasse Collin <lasse.collin@tukaani.org>
|
||||
* Igor Pavlov <http://7-zip.org/>
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*/
|
||||
|
||||
#ifndef XZ_H
|
||||
#define XZ_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
# include <linux/stddef.h>
|
||||
# include <linux/types.h>
|
||||
#else
|
||||
# include <stddef.h>
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
/* In Linux, this is used to make extern functions static when needed. */
|
||||
#ifndef XZ_EXTERN
|
||||
# define XZ_EXTERN extern
|
||||
#endif
|
||||
|
||||
/* In Linux, this is used to mark the functions with __init when needed. */
|
||||
#ifndef XZ_FUNC
|
||||
# define XZ_FUNC
|
||||
#endif
|
||||
|
||||
/**
|
||||
* enum xz_mode - Operation mode
|
||||
*
|
||||
* @XZ_SINGLE: Single-call mode. This uses less RAM than
|
||||
* than multi-call modes, because the LZMA2
|
||||
* dictionary doesn't need to be allocated as
|
||||
* part of the decoder state. All required data
|
||||
* structures are allocated at initialization,
|
||||
* so xz_dec_run() cannot return XZ_MEM_ERROR.
|
||||
* @XZ_PREALLOC: Multi-call mode with preallocated LZMA2
|
||||
* dictionary buffer. All data structures are
|
||||
* allocated at initialization, so xz_dec_run()
|
||||
* cannot return XZ_MEM_ERROR.
|
||||
* @XZ_DYNALLOC: Multi-call mode. The LZMA2 dictionary is
|
||||
* allocated once the required size has been
|
||||
* parsed from the stream headers. If the
|
||||
* allocation fails, xz_dec_run() will return
|
||||
* XZ_MEM_ERROR.
|
||||
*
|
||||
* It is possible to enable support only for a subset of the above
|
||||
* modes at compile time by defining XZ_DEC_SINGLE, XZ_DEC_PREALLOC,
|
||||
* or XZ_DEC_DYNALLOC. The xz_dec kernel module is always compiled
|
||||
* with support for all operation modes, but the preboot code may
|
||||
* be built with fewer features to minimize code size.
|
||||
*/
|
||||
enum xz_mode {
|
||||
XZ_SINGLE,
|
||||
XZ_PREALLOC,
|
||||
XZ_DYNALLOC
|
||||
};
|
||||
|
||||
/**
|
||||
* enum xz_ret - Return codes
|
||||
* @XZ_OK: Everything is OK so far. More input or more
|
||||
* output space is required to continue. This
|
||||
* return code is possible only in multi-call mode
|
||||
* (XZ_PREALLOC or XZ_DYNALLOC).
|
||||
* @XZ_STREAM_END: Operation finished successfully.
|
||||
* @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
|
||||
* XZ_DEC_ANY_CHECK was defined at build time,
|
||||
* which is not used in the kernel. Unsupported
|
||||
* check types return XZ_OPTIONS_ERROR if
|
||||
* XZ_DEC_ANY_CHECK was not defined at build time.
|
||||
* @XZ_MEM_ERROR: Allocating memory failed. This return code is
|
||||
* possible only if the decoder was initialized
|
||||
* with XZ_DYNALLOC. The amount of memory that was
|
||||
* tried to be allocated was no more than the
|
||||
* dict_max argument given to xz_dec_init().
|
||||
* @XZ_MEMLIMIT_ERROR: A bigger LZMA2 dictionary would be needed than
|
||||
* allowed by the dict_max argument given to
|
||||
* xz_dec_init(). This return value is possible
|
||||
* only in multi-call mode (XZ_PREALLOC or
|
||||
* XZ_DYNALLOC); the single-call mode (XZ_SINGLE)
|
||||
* ignores the dict_max argument.
|
||||
* @XZ_FORMAT_ERROR: File format was not recognized (wrong magic
|
||||
* bytes).
|
||||
* @XZ_OPTIONS_ERROR: This implementation doesn't support the requested
|
||||
* compression options. In the decoder this means
|
||||
* that the header CRC32 matches, but the header
|
||||
* itself specifies something that we don't support.
|
||||
* @XZ_DATA_ERROR: Compressed data is corrupt.
|
||||
* @XZ_BUF_ERROR: Cannot make any progress. Details are slightly
|
||||
* different between multi-call and single-call
|
||||
* mode; more information below.
|
||||
*
|
||||
* In multi-call mode, XZ_BUF_ERROR is returned when two consecutive calls
|
||||
* to XZ code cannot consume any input and cannot produce any new output.
|
||||
* This happens when there is no new input available, or the output buffer
|
||||
* is full while at least one output byte is still pending. Assuming your
|
||||
* code is not buggy, you can get this error only when decoding a compressed
|
||||
* 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
|
||||
* 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.
|
||||
*/
|
||||
enum xz_ret {
|
||||
XZ_OK,
|
||||
XZ_STREAM_END,
|
||||
XZ_UNSUPPORTED_CHECK,
|
||||
XZ_MEM_ERROR,
|
||||
XZ_MEMLIMIT_ERROR,
|
||||
XZ_FORMAT_ERROR,
|
||||
XZ_OPTIONS_ERROR,
|
||||
XZ_DATA_ERROR,
|
||||
XZ_BUF_ERROR
|
||||
};
|
||||
|
||||
/**
|
||||
* struct xz_buf - Passing input and output buffers to XZ code
|
||||
* @in: Beginning of the input buffer. This may be NULL if and only
|
||||
* if in_pos is equal to in_size.
|
||||
* @in_pos: Current position in the input buffer. This must not exceed
|
||||
* in_size.
|
||||
* @in_size: Size of the input buffer
|
||||
* @out: Beginning of the output buffer. This may be NULL if and only
|
||||
* if out_pos is equal to out_size.
|
||||
* @out_pos: Current position in the output buffer. This must not exceed
|
||||
* out_size.
|
||||
* @out_size: Size of the output buffer
|
||||
*
|
||||
* Only the contents of the output buffer from out[out_pos] onward, and
|
||||
* the variables in_pos and out_pos are modified by the XZ code.
|
||||
*/
|
||||
struct xz_buf {
|
||||
const uint8_t *in;
|
||||
size_t in_pos;
|
||||
size_t in_size;
|
||||
|
||||
uint8_t *out;
|
||||
size_t out_pos;
|
||||
size_t out_size;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct xz_dec - Opaque type to hold the XZ decoder state
|
||||
*/
|
||||
struct xz_dec;
|
||||
|
||||
/**
|
||||
* xz_dec_init() - Allocate and initialize a XZ decoder state
|
||||
* @mode: Operation mode
|
||||
* @dict_max: Maximum size of the LZMA2 dictionary (history buffer) for
|
||||
* multi-call decoding. This is ignored in single-call mode
|
||||
* (mode == XZ_SINGLE). LZMA2 dictionary is always 2^n bytes
|
||||
* or 2^n + 2^(n-1) bytes (the latter sizes are less common
|
||||
* in practice), so other values for dict_max don't make sense.
|
||||
* In the kernel, dictionary sizes of 64 KiB, 128 KiB, 256 KiB,
|
||||
* 512 KiB, and 1 MiB are probably the only reasonable values,
|
||||
* except for kernel and initramfs images where a bigger
|
||||
* dictionary can be fine and useful.
|
||||
*
|
||||
* Single-call mode (XZ_SINGLE): xz_dec_run() decodes the whole stream at
|
||||
* once. The caller must provide enough output space or the decoding will
|
||||
* fail. The output space is used as the dictionary buffer, which is why
|
||||
* there is no need to allocate the dictionary as part of the decoder's
|
||||
* internal state.
|
||||
*
|
||||
* Because the output buffer is used as the workspace, streams encoded using
|
||||
* a big dictionary are not a problem in single-call mode. It is enough that
|
||||
* the output buffer is big enough to hold the actual uncompressed data; it
|
||||
* can be smaller than the dictionary size stored in the stream headers.
|
||||
*
|
||||
* Multi-call mode with preallocated dictionary (XZ_PREALLOC): dict_max bytes
|
||||
* of memory is preallocated for the LZMA2 dictionary. This way there is no
|
||||
* risk that xz_dec_run() could run out of memory, since xz_dec_run() will
|
||||
* never allocate any memory. Instead, if the preallocated dictionary is too
|
||||
* small for decoding the given input stream, xz_dec_run() will return
|
||||
* XZ_MEMLIMIT_ERROR. Thus, it is important to know what kind of data will be
|
||||
* decoded to avoid allocating excessive amount of memory for the dictionary.
|
||||
*
|
||||
* Multi-call mode with dynamically allocated dictionary (XZ_DYNALLOC):
|
||||
* dict_max specifies the maximum allowed dictionary size that xz_dec_run()
|
||||
* may allocate once it has parsed the dictionary size from the stream
|
||||
* headers. This way excessive allocations can be avoided while still
|
||||
* limiting the maximum memory usage to a sane value to prevent running the
|
||||
* system out of memory when decompressing streams from untrusted sources.
|
||||
*
|
||||
* On success, xz_dec_init() returns a pointer to struct xz_dec, which is
|
||||
* ready to be used with xz_dec_run(). If memory allocation fails,
|
||||
* xz_dec_init() returns NULL.
|
||||
*/
|
||||
XZ_EXTERN struct xz_dec * XZ_FUNC xz_dec_init(
|
||||
enum xz_mode mode, uint32_t dict_max);
|
||||
|
||||
/**
|
||||
* xz_dec_run() - Run the XZ decoder
|
||||
* @s: Decoder state allocated using xz_dec_init()
|
||||
* @b: Input and output buffers
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
* cannot be properly done if the output buffer is truncated. Thus, you
|
||||
* cannot give the single-call decoder a too small buffer and then expect to
|
||||
* get that amount valid data from the beginning of the stream. You must use
|
||||
* the multi-call decoder if you don't want to uncompress the whole stream.
|
||||
*/
|
||||
XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_run(struct xz_dec *s, struct xz_buf *b);
|
||||
|
||||
/**
|
||||
* xz_dec_reset() - Reset an already allocated decoder state
|
||||
* @s: Decoder state allocated using xz_dec_init()
|
||||
*
|
||||
* This function can be used to reset the multi-call decoder state without
|
||||
* freeing and reallocating memory with xz_dec_end() and xz_dec_init().
|
||||
*
|
||||
* In single-call mode, xz_dec_reset() is always called in the beginning of
|
||||
* xz_dec_run(). Thus, explicit call to xz_dec_reset() is useful only in
|
||||
* multi-call mode.
|
||||
*/
|
||||
XZ_EXTERN void XZ_FUNC xz_dec_reset(struct xz_dec *s);
|
||||
|
||||
/**
|
||||
* xz_dec_end() - Free the memory allocated for the decoder state
|
||||
* @s: Decoder state allocated using xz_dec_init(). If s is NULL,
|
||||
* this function does nothing.
|
||||
*/
|
||||
XZ_EXTERN void XZ_FUNC xz_dec_end(struct xz_dec *s);
|
||||
|
||||
/*
|
||||
* Standalone build (userspace build or in-kernel build for boot time use)
|
||||
* needs a CRC32 implementation. For normal in-kernel use, kernel's own
|
||||
* CRC32 module is used instead, and users of this module don't need to
|
||||
* care about the functions below.
|
||||
*/
|
||||
#ifndef XZ_INTERNAL_CRC32
|
||||
# ifdef __KERNEL__
|
||||
# define XZ_INTERNAL_CRC32 0
|
||||
# else
|
||||
# define XZ_INTERNAL_CRC32 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if XZ_INTERNAL_CRC32
|
||||
/*
|
||||
* This must be called before any other xz_* function to initialize
|
||||
* the CRC32 lookup table.
|
||||
*/
|
||||
XZ_EXTERN void XZ_FUNC xz_crc32_init(void);
|
||||
|
||||
/*
|
||||
* Update CRC32 value using the polynomial from IEEE-802.3. To start a new
|
||||
* calculation, the third argument must be zero. To continue the calculation,
|
||||
* the previously returned value is passed as the third argument.
|
||||
*/
|
||||
XZ_EXTERN uint32_t XZ_FUNC xz_crc32(
|
||||
const uint8_t *buf, size_t size, uint32_t crc);
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Private includes and definitions for userspace use of XZ Embedded
|
||||
*
|
||||
* Author: Lasse Collin <lasse.collin@tukaani.org>
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*/
|
||||
|
||||
#ifndef XZ_CONFIG_H
|
||||
#define XZ_CONFIG_H
|
||||
|
||||
/* Uncomment as needed to enable BCJ filter decoders. */
|
||||
/* #define XZ_DEC_X86 */
|
||||
/* #define XZ_DEC_POWERPC */
|
||||
/* #define XZ_DEC_IA64 */
|
||||
/* #define XZ_DEC_ARM */
|
||||
/* #define XZ_DEC_ARMTHUMB */
|
||||
/* #define XZ_DEC_SPARC */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "xz.h"
|
||||
|
||||
#define kmalloc(size, flags) malloc(size)
|
||||
#define kfree(ptr) free(ptr)
|
||||
#define vmalloc(size) malloc(size)
|
||||
#define vfree(ptr) free(ptr)
|
||||
|
||||
#define memeq(a, b, size) (memcmp(a, b, size) == 0)
|
||||
#define memzero(buf, size) memset(buf, 0, size)
|
||||
|
||||
#undef min
|
||||
#undef min_t
|
||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
#define min_t(type, x, y) min(x, y)
|
||||
|
||||
/*
|
||||
* Some functions have been marked with __always_inline to keep the
|
||||
* performance reasonable even when the compiler is optimizing for
|
||||
* small code size. You may be able to save a few bytes by #defining
|
||||
* __always_inline to plain inline, but don't complain if the code
|
||||
* becomes slow.
|
||||
*
|
||||
* NOTE: System headers on GNU/Linux may #define this macro already,
|
||||
* so if you want to change it, you need to #undef it first.
|
||||
*/
|
||||
#ifndef __always_inline
|
||||
# ifdef __GNUC__
|
||||
# define __always_inline \
|
||||
inline __attribute__((__always_inline__))
|
||||
# else
|
||||
# define __always_inline inline
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Some functions are marked to never be inlined to reduce stack usage.
|
||||
* If you don't care about stack usage, you may want to modify this so
|
||||
* that noinline_for_stack is #defined to be empty even when using GCC.
|
||||
* Doing so may save a few bytes in binary size.
|
||||
*/
|
||||
#ifndef noinline_for_stack
|
||||
# ifdef __GNUC__
|
||||
# define noinline_for_stack __attribute__((__noinline__))
|
||||
# else
|
||||
# define noinline_for_stack
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Inline functions to access unaligned unsigned 32-bit integers */
|
||||
#ifndef get_unaligned_le32
|
||||
static inline uint32_t XZ_FUNC get_unaligned_le32(const uint8_t *buf)
|
||||
{
|
||||
return (uint32_t)buf[0]
|
||||
| ((uint32_t)buf[1] << 8)
|
||||
| ((uint32_t)buf[2] << 16)
|
||||
| ((uint32_t)buf[3] << 24);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef get_unaligned_be32
|
||||
static inline uint32_t XZ_FUNC get_unaligned_be32(const uint8_t *buf)
|
||||
{
|
||||
return (uint32_t)(buf[0] << 24)
|
||||
| ((uint32_t)buf[1] << 16)
|
||||
| ((uint32_t)buf[2] << 8)
|
||||
| (uint32_t)buf[3];
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef put_unaligned_le32
|
||||
static inline void XZ_FUNC put_unaligned_le32(uint32_t val, uint8_t *buf)
|
||||
{
|
||||
buf[0] = (uint8_t)val;
|
||||
buf[1] = (uint8_t)(val >> 8);
|
||||
buf[2] = (uint8_t)(val >> 16);
|
||||
buf[3] = (uint8_t)(val >> 24);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef put_unaligned_be32
|
||||
static inline void XZ_FUNC put_unaligned_be32(uint32_t val, uint8_t *buf)
|
||||
{
|
||||
buf[0] = (uint8_t)(val >> 24);
|
||||
buf[1] = (uint8_t)(val >> 16);
|
||||
buf[2] = (uint8_t)(val >> 8);
|
||||
buf[3] = (uint8_t)val;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Use get_unaligned_le32() also for aligned access for simplicity. On
|
||||
* little endian systems, #define get_le32(ptr) (*(const uint32_t *)(ptr))
|
||||
* could save a few bytes in code size.
|
||||
*/
|
||||
#ifndef get_le32
|
||||
# define get_le32 get_unaligned_le32
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,564 @@
|
||||
/*
|
||||
* Branch/Call/Jump (BCJ) filter decoders
|
||||
*
|
||||
* Authors: Lasse Collin <lasse.collin@tukaani.org>
|
||||
* Igor Pavlov <http://7-zip.org/>
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*/
|
||||
|
||||
#include "xz_private.h"
|
||||
|
||||
/*
|
||||
* The rest of the file is inside this ifdef. It makes things a little more
|
||||
* convenient when building without support for any BCJ filters.
|
||||
*/
|
||||
#ifdef XZ_DEC_BCJ
|
||||
|
||||
struct xz_dec_bcj {
|
||||
/* Type of the BCJ filter being used */
|
||||
enum {
|
||||
BCJ_X86 = 4, /* x86 or x86-64 */
|
||||
BCJ_POWERPC = 5, /* Big endian only */
|
||||
BCJ_IA64 = 6, /* Big or little endian */
|
||||
BCJ_ARM = 7, /* Little endian only */
|
||||
BCJ_ARMTHUMB = 8, /* Little endian only */
|
||||
BCJ_SPARC = 9 /* Big or little endian */
|
||||
} type;
|
||||
|
||||
/*
|
||||
* Return value of the next filter in the chain. We need to preserve
|
||||
* this information across calls, because we must not call the next
|
||||
* filter anymore once it has returned XZ_STREAM_END.
|
||||
*/
|
||||
enum xz_ret ret;
|
||||
|
||||
/* True if we are operating in single-call mode. */
|
||||
bool single_call;
|
||||
|
||||
/*
|
||||
* Absolute position relative to the beginning of the uncompressed
|
||||
* data (in a single .xz Block). We care only about the lowest 32
|
||||
* bits so this doesn't need to be uint64_t even with big files.
|
||||
*/
|
||||
uint32_t pos;
|
||||
|
||||
/* x86 filter state */
|
||||
uint32_t x86_prev_mask;
|
||||
|
||||
/* Temporary space to hold the variables from struct xz_buf */
|
||||
uint8_t *out;
|
||||
size_t out_pos;
|
||||
size_t out_size;
|
||||
|
||||
struct {
|
||||
/* Amount of already filtered data in the beginning of buf */
|
||||
size_t filtered;
|
||||
|
||||
/* Total amount of data currently stored in buf */
|
||||
size_t size;
|
||||
|
||||
/*
|
||||
* Buffer to hold a mix of filtered and unfiltered data. This
|
||||
* needs to be big enough to hold Alignment + 2 * Look-ahead:
|
||||
*
|
||||
* Type Alignment Look-ahead
|
||||
* x86 1 4
|
||||
* PowerPC 4 0
|
||||
* IA-64 16 0
|
||||
* ARM 4 0
|
||||
* ARM-Thumb 2 2
|
||||
* SPARC 4 0
|
||||
*/
|
||||
uint8_t buf[16];
|
||||
} temp;
|
||||
};
|
||||
|
||||
#ifdef XZ_DEC_X86
|
||||
/*
|
||||
* This is macro 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 noinline_for_stack size_t XZ_FUNC bcj_x86(
|
||||
struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
||||
{
|
||||
static const bool mask_to_allowed_status[8]
|
||||
= { true, true, true, false, true, false, false, false };
|
||||
|
||||
static const uint8_t mask_to_bit_num[8] = { 0, 1, 2, 2, 3, 3, 3, 3 };
|
||||
|
||||
size_t i;
|
||||
size_t prev_pos = (size_t)-1;
|
||||
uint32_t prev_mask = s->x86_prev_mask;
|
||||
uint32_t src;
|
||||
uint32_t dest;
|
||||
uint32_t j;
|
||||
uint8_t b;
|
||||
|
||||
if (size <= 4)
|
||||
return 0;
|
||||
|
||||
size -= 4;
|
||||
for (i = 0; i < size; ++i) {
|
||||
if ((buf[i] & 0xFE) != 0xE8)
|
||||
continue;
|
||||
|
||||
prev_pos = i - prev_pos;
|
||||
if (prev_pos > 3) {
|
||||
prev_mask = 0;
|
||||
} else {
|
||||
prev_mask = (prev_mask << (prev_pos - 1)) & 7;
|
||||
if (prev_mask != 0) {
|
||||
b = buf[i + 4 - mask_to_bit_num[prev_mask]];
|
||||
if (!mask_to_allowed_status[prev_mask]
|
||||
|| bcj_x86_test_msbyte(b)) {
|
||||
prev_pos = i;
|
||||
prev_mask = (prev_mask << 1) | 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prev_pos = i;
|
||||
|
||||
if (bcj_x86_test_msbyte(buf[i + 4])) {
|
||||
src = get_unaligned_le32(buf + i + 1);
|
||||
while (true) {
|
||||
dest = src - (s->pos + (uint32_t)i + 5);
|
||||
if (prev_mask == 0)
|
||||
break;
|
||||
|
||||
j = mask_to_bit_num[prev_mask] * 8;
|
||||
b = (uint8_t)(dest >> (24 - j));
|
||||
if (!bcj_x86_test_msbyte(b))
|
||||
break;
|
||||
|
||||
src = dest ^ (((uint32_t)1 << (32 - j)) - 1);
|
||||
}
|
||||
|
||||
dest &= 0x01FFFFFF;
|
||||
dest |= (uint32_t)0 - (dest & 0x01000000);
|
||||
put_unaligned_le32(dest, buf + i + 1);
|
||||
i += 4;
|
||||
} else {
|
||||
prev_mask = (prev_mask << 1) | 1;
|
||||
}
|
||||
}
|
||||
|
||||
prev_pos = i - prev_pos;
|
||||
s->x86_prev_mask = prev_pos > 3 ? 0 : prev_mask << (prev_pos - 1);
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XZ_DEC_POWERPC
|
||||
static noinline_for_stack size_t XZ_FUNC bcj_powerpc(
|
||||
struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
uint32_t instr;
|
||||
|
||||
for (i = 0; i + 4 <= size; i += 4) {
|
||||
instr = get_unaligned_be32(buf + i);
|
||||
if ((instr & 0xFC000003) == 0x48000001) {
|
||||
instr &= 0x03FFFFFC;
|
||||
instr -= s->pos + (uint32_t)i;
|
||||
instr &= 0x03FFFFFC;
|
||||
instr |= 0x48000001;
|
||||
put_unaligned_be32(instr, buf + i);
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XZ_DEC_IA64
|
||||
static noinline_for_stack size_t XZ_FUNC bcj_ia64(
|
||||
struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
||||
{
|
||||
static const uint8_t branch_table[32] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
4, 4, 6, 6, 0, 0, 7, 7,
|
||||
4, 4, 0, 0, 4, 4, 0, 0
|
||||
};
|
||||
|
||||
/*
|
||||
* The local variables take a little bit stack space, but it's less
|
||||
* than what LZMA2 decoder takes, so it doesn't make sense to reduce
|
||||
* stack usage here without doing that for the LZMA2 decoder too.
|
||||
*/
|
||||
|
||||
/* Loop counters */
|
||||
size_t i;
|
||||
size_t j;
|
||||
|
||||
/* Instruction slot (0, 1, or 2) in the 128-bit instruction word */
|
||||
uint32_t slot;
|
||||
|
||||
/* Bitwise offset of the instruction indicated by slot */
|
||||
uint32_t bit_pos;
|
||||
|
||||
/* bit_pos split into byte and bit parts */
|
||||
uint32_t byte_pos;
|
||||
uint32_t bit_res;
|
||||
|
||||
/* Address part of an instruction */
|
||||
uint32_t addr;
|
||||
|
||||
/* Mask used to detect which instructions to convert */
|
||||
uint32_t mask;
|
||||
|
||||
/* 41-bit instruction stored somewhere in the lowest 48 bits */
|
||||
uint64_t instr;
|
||||
|
||||
/* Instruction normalized with bit_res for easier manipulation */
|
||||
uint64_t norm;
|
||||
|
||||
for (i = 0; i + 16 <= size; i += 16) {
|
||||
mask = branch_table[buf[i] & 0x1F];
|
||||
for (slot = 0, bit_pos = 5; slot < 3; ++slot, bit_pos += 41) {
|
||||
if (((mask >> slot) & 1) == 0)
|
||||
continue;
|
||||
|
||||
byte_pos = bit_pos >> 3;
|
||||
bit_res = bit_pos & 7;
|
||||
instr = 0;
|
||||
for (j = 0; j < 6; ++j)
|
||||
instr |= (uint64_t)(buf[i + j + byte_pos])
|
||||
<< (8 * j);
|
||||
|
||||
norm = instr >> bit_res;
|
||||
|
||||
if (((norm >> 37) & 0x0F) == 0x05
|
||||
&& ((norm >> 9) & 0x07) == 0) {
|
||||
addr = (norm >> 13) & 0x0FFFFF;
|
||||
addr |= ((uint32_t)(norm >> 36) & 1) << 20;
|
||||
addr <<= 4;
|
||||
addr -= s->pos + (uint32_t)i;
|
||||
addr >>= 4;
|
||||
|
||||
norm &= ~((uint64_t)0x8FFFFF << 13);
|
||||
norm |= (uint64_t)(addr & 0x0FFFFF) << 13;
|
||||
norm |= (uint64_t)(addr & 0x100000)
|
||||
<< (36 - 20);
|
||||
|
||||
instr &= (1 << bit_res) - 1;
|
||||
instr |= norm << bit_res;
|
||||
|
||||
for (j = 0; j < 6; j++)
|
||||
buf[i + j + byte_pos]
|
||||
= (uint8_t)(instr >> (8 * j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XZ_DEC_ARM
|
||||
static noinline_for_stack size_t XZ_FUNC bcj_arm(
|
||||
struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
uint32_t addr;
|
||||
|
||||
for (i = 0; i + 4 <= size; i += 4) {
|
||||
if (buf[i + 3] == 0xEB) {
|
||||
addr = (uint32_t)buf[i] | ((uint32_t)buf[i + 1] << 8)
|
||||
| ((uint32_t)buf[i + 2] << 16);
|
||||
addr <<= 2;
|
||||
addr -= s->pos + (uint32_t)i + 8;
|
||||
addr >>= 2;
|
||||
buf[i] = (uint8_t)addr;
|
||||
buf[i + 1] = (uint8_t)(addr >> 8);
|
||||
buf[i + 2] = (uint8_t)(addr >> 16);
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XZ_DEC_ARMTHUMB
|
||||
static noinline_for_stack size_t XZ_FUNC bcj_armthumb(
|
||||
struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
uint32_t addr;
|
||||
|
||||
for (i = 0; i + 4 <= size; i += 2) {
|
||||
if ((buf[i + 1] & 0xF8) == 0xF0
|
||||
&& (buf[i + 3] & 0xF8) == 0xF8) {
|
||||
addr = (((uint32_t)buf[i + 1] & 0x07) << 19)
|
||||
| ((uint32_t)buf[i] << 11)
|
||||
| (((uint32_t)buf[i + 3] & 0x07) << 8)
|
||||
| (uint32_t)buf[i + 2];
|
||||
addr <<= 1;
|
||||
addr -= s->pos + (uint32_t)i + 4;
|
||||
addr >>= 1;
|
||||
buf[i + 1] = (uint8_t)(0xF0 | ((addr >> 19) & 0x07));
|
||||
buf[i] = (uint8_t)(addr >> 11);
|
||||
buf[i + 3] = (uint8_t)(0xF8 | ((addr >> 8) & 0x07));
|
||||
buf[i + 2] = (uint8_t)addr;
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef XZ_DEC_SPARC
|
||||
static noinline_for_stack size_t XZ_FUNC bcj_sparc(
|
||||
struct xz_dec_bcj *s, uint8_t *buf, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
uint32_t instr;
|
||||
|
||||
for (i = 0; i + 4 <= size; i += 4) {
|
||||
instr = get_unaligned_be32(buf + i);
|
||||
if ((instr >> 22) == 0x100 || (instr >> 22) == 0x1FF) {
|
||||
instr <<= 2;
|
||||
instr -= s->pos + (uint32_t)i;
|
||||
instr >>= 2;
|
||||
instr = ((uint32_t)0x40000000 - (instr & 0x400000))
|
||||
| 0x40000000 | (instr & 0x3FFFFF);
|
||||
put_unaligned_be32(instr, buf + i);
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Apply the selected BCJ filter. Update *pos and s->pos to match the amount
|
||||
* of data that got filtered.
|
||||
*
|
||||
* NOTE: This is implemented as a switch statement to avoid using function
|
||||
* pointers, which could be problematic in the kernel boot code, which must
|
||||
* avoid pointers to static data (at least on x86).
|
||||
*/
|
||||
static void XZ_FUNC bcj_apply(struct xz_dec_bcj *s,
|
||||
uint8_t *buf, size_t *pos, size_t size)
|
||||
{
|
||||
size_t filtered;
|
||||
|
||||
buf += *pos;
|
||||
size -= *pos;
|
||||
|
||||
switch (s->type) {
|
||||
#ifdef XZ_DEC_X86
|
||||
case BCJ_X86:
|
||||
filtered = bcj_x86(s, buf, size);
|
||||
break;
|
||||
#endif
|
||||
#ifdef XZ_DEC_POWERPC
|
||||
case BCJ_POWERPC:
|
||||
filtered = bcj_powerpc(s, buf, size);
|
||||
break;
|
||||
#endif
|
||||
#ifdef XZ_DEC_IA64
|
||||
case BCJ_IA64:
|
||||
filtered = bcj_ia64(s, buf, size);
|
||||
break;
|
||||
#endif
|
||||
#ifdef XZ_DEC_ARM
|
||||
case BCJ_ARM:
|
||||
filtered = bcj_arm(s, buf, size);
|
||||
break;
|
||||
#endif
|
||||
#ifdef XZ_DEC_ARMTHUMB
|
||||
case BCJ_ARMTHUMB:
|
||||
filtered = bcj_armthumb(s, buf, size);
|
||||
break;
|
||||
#endif
|
||||
#ifdef XZ_DEC_SPARC
|
||||
case BCJ_SPARC:
|
||||
filtered = bcj_sparc(s, buf, size);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
/* Never reached but silence compiler warnings. */
|
||||
filtered = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
*pos += filtered;
|
||||
s->pos += filtered;
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush pending filtered data from temp to the output buffer.
|
||||
* Move the remaining mixture of possibly filtered and unfiltered
|
||||
* data to the beginning of temp.
|
||||
*/
|
||||
static void XZ_FUNC bcj_flush(struct xz_dec_bcj *s, struct xz_buf *b)
|
||||
{
|
||||
size_t copy_size;
|
||||
|
||||
copy_size = min_t(size_t, s->temp.filtered, b->out_size - b->out_pos);
|
||||
memcpy(b->out + b->out_pos, s->temp.buf, copy_size);
|
||||
b->out_pos += copy_size;
|
||||
|
||||
s->temp.filtered -= copy_size;
|
||||
s->temp.size -= copy_size;
|
||||
memmove(s->temp.buf, s->temp.buf + copy_size, s->temp.size);
|
||||
}
|
||||
|
||||
/*
|
||||
* The BCJ filter functions are primitive in sense that they process the
|
||||
* data in chunks of 1-16 bytes. To hide this issue, this function does
|
||||
* some buffering.
|
||||
*/
|
||||
XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_bcj_run(struct xz_dec_bcj *s,
|
||||
struct xz_dec_lzma2 *lzma2, struct xz_buf *b)
|
||||
{
|
||||
size_t out_start;
|
||||
|
||||
/*
|
||||
* Flush pending already filtered data to the output buffer. Return
|
||||
* immediatelly if we couldn't flush everything, or if the next
|
||||
* filter in the chain had already returned XZ_STREAM_END.
|
||||
*/
|
||||
if (s->temp.filtered > 0) {
|
||||
bcj_flush(s, b);
|
||||
if (s->temp.filtered > 0)
|
||||
return XZ_OK;
|
||||
|
||||
if (s->ret == XZ_STREAM_END)
|
||||
return XZ_STREAM_END;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we have more output space than what is currently pending in
|
||||
* temp, copy the unfiltered data from temp to the output buffer
|
||||
* and try to fill the output buffer by decoding more data from the
|
||||
* 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.
|
||||
*/
|
||||
if (s->temp.size < b->out_size - b->out_pos) {
|
||||
out_start = b->out_pos;
|
||||
memcpy(b->out + b->out_pos, s->temp.buf, s->temp.size);
|
||||
b->out_pos += s->temp.size;
|
||||
|
||||
s->ret = xz_dec_lzma2_run(lzma2, b);
|
||||
if (s->ret != XZ_STREAM_END
|
||||
&& (s->ret != XZ_OK || s->single_call))
|
||||
return s->ret;
|
||||
|
||||
bcj_apply(s, b->out, &out_start, b->out_pos);
|
||||
|
||||
/*
|
||||
* As an exception, if the next filter returned XZ_STREAM_END,
|
||||
* we can do that too, since the last few bytes that remain
|
||||
* unfiltered are meant to remain unfiltered.
|
||||
*/
|
||||
if (s->ret == XZ_STREAM_END)
|
||||
return XZ_STREAM_END;
|
||||
|
||||
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 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.
|
||||
*/
|
||||
if (s->temp.size > 0) {
|
||||
/* Make b->out{,_pos,_size} temporarily point to s->temp. */
|
||||
s->out = b->out;
|
||||
s->out_pos = b->out_pos;
|
||||
s->out_size = b->out_size;
|
||||
b->out = s->temp.buf;
|
||||
b->out_pos = s->temp.size;
|
||||
b->out_size = sizeof(s->temp.buf);
|
||||
|
||||
s->ret = xz_dec_lzma2_run(lzma2, b);
|
||||
|
||||
s->temp.size = b->out_pos;
|
||||
b->out = s->out;
|
||||
b->out_pos = s->out_pos;
|
||||
b->out_size = s->out_size;
|
||||
|
||||
if (s->ret != XZ_OK && s->ret != XZ_STREAM_END)
|
||||
return s->ret;
|
||||
|
||||
bcj_apply(s, s->temp.buf, &s->temp.filtered, s->temp.size);
|
||||
|
||||
/*
|
||||
* If the next filter returned XZ_STREAM_END, we mark that
|
||||
* everything is filtered, since the last unfiltered bytes
|
||||
* of the stream are meant to be left as is.
|
||||
*/
|
||||
if (s->ret == XZ_STREAM_END)
|
||||
s->temp.filtered = s->temp.size;
|
||||
|
||||
bcj_flush(s, b);
|
||||
if (s->temp.filtered > 0)
|
||||
return XZ_OK;
|
||||
}
|
||||
|
||||
return s->ret;
|
||||
}
|
||||
|
||||
XZ_EXTERN struct xz_dec_bcj * XZ_FUNC xz_dec_bcj_create(bool single_call)
|
||||
{
|
||||
struct xz_dec_bcj *s = kmalloc(sizeof(*s), GFP_KERNEL);
|
||||
if (s != NULL)
|
||||
s->single_call = single_call;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_bcj_reset(
|
||||
struct xz_dec_bcj *s, uint8_t id)
|
||||
{
|
||||
switch (id) {
|
||||
#ifdef XZ_DEC_X86
|
||||
case BCJ_X86:
|
||||
#endif
|
||||
#ifdef XZ_DEC_POWERPC
|
||||
case BCJ_POWERPC:
|
||||
#endif
|
||||
#ifdef XZ_DEC_IA64
|
||||
case BCJ_IA64:
|
||||
#endif
|
||||
#ifdef XZ_DEC_ARM
|
||||
case BCJ_ARM:
|
||||
#endif
|
||||
#ifdef XZ_DEC_ARMTHUMB
|
||||
case BCJ_ARMTHUMB:
|
||||
#endif
|
||||
#ifdef XZ_DEC_SPARC
|
||||
case BCJ_SPARC:
|
||||
#endif
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Unsupported Filter ID */
|
||||
return XZ_OPTIONS_ERROR;
|
||||
}
|
||||
|
||||
s->type = id;
|
||||
s->ret = XZ_OK;
|
||||
s->pos = 0;
|
||||
s->x86_prev_mask = 0;
|
||||
s->temp.filtered = 0;
|
||||
s->temp.size = 0;
|
||||
|
||||
return XZ_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,822 @@
|
||||
/*
|
||||
* .xz Stream decoder
|
||||
*
|
||||
* Author: Lasse Collin <lasse.collin@tukaani.org>
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*/
|
||||
|
||||
#include "xz_private.h"
|
||||
#include "xz_stream.h"
|
||||
|
||||
/* Hash used to validate the Index field */
|
||||
struct xz_dec_hash {
|
||||
vli_type unpadded;
|
||||
vli_type uncompressed;
|
||||
uint32_t crc32;
|
||||
};
|
||||
|
||||
struct xz_dec {
|
||||
/* Position in dec_main() */
|
||||
enum {
|
||||
SEQ_STREAM_HEADER,
|
||||
SEQ_BLOCK_START,
|
||||
SEQ_BLOCK_HEADER,
|
||||
SEQ_BLOCK_UNCOMPRESS,
|
||||
SEQ_BLOCK_PADDING,
|
||||
SEQ_BLOCK_CHECK,
|
||||
SEQ_INDEX,
|
||||
SEQ_INDEX_PADDING,
|
||||
SEQ_INDEX_CRC32,
|
||||
SEQ_STREAM_FOOTER
|
||||
} sequence;
|
||||
|
||||
/* Position in variable-length integers and Check fields */
|
||||
uint32_t pos;
|
||||
|
||||
/* Variable-length integer decoded by dec_vli() */
|
||||
vli_type vli;
|
||||
|
||||
/* Saved in_pos and out_pos */
|
||||
size_t in_start;
|
||||
size_t out_start;
|
||||
|
||||
/* CRC32 value in Block or Index */
|
||||
uint32_t crc32;
|
||||
|
||||
/* Type of the integrity check calculated from uncompressed data */
|
||||
enum xz_check check_type;
|
||||
|
||||
/* Operation mode */
|
||||
enum xz_mode mode;
|
||||
|
||||
/*
|
||||
* True if the next call to xz_dec_run() is allowed to return
|
||||
* XZ_BUF_ERROR.
|
||||
*/
|
||||
bool allow_buf_error;
|
||||
|
||||
/* Information stored in Block Header */
|
||||
struct {
|
||||
/*
|
||||
* Value stored in the Compressed Size field, or
|
||||
* VLI_UNKNOWN if Compressed Size is not present.
|
||||
*/
|
||||
vli_type compressed;
|
||||
|
||||
/*
|
||||
* Value stored in the Uncompressed Size field, or
|
||||
* VLI_UNKNOWN if Uncompressed Size is not present.
|
||||
*/
|
||||
vli_type uncompressed;
|
||||
|
||||
/* Size of the Block Header field */
|
||||
uint32_t size;
|
||||
} block_header;
|
||||
|
||||
/* Information collected when decoding Blocks */
|
||||
struct {
|
||||
/* Observed compressed size of the current Block */
|
||||
vli_type compressed;
|
||||
|
||||
/* Observed uncompressed size of the current Block */
|
||||
vli_type uncompressed;
|
||||
|
||||
/* Number of Blocks decoded so far */
|
||||
vli_type count;
|
||||
|
||||
/*
|
||||
* Hash calculated from the Block sizes. This is used to
|
||||
* validate the Index field.
|
||||
*/
|
||||
struct xz_dec_hash hash;
|
||||
} block;
|
||||
|
||||
/* Variables needed when verifying the Index field */
|
||||
struct {
|
||||
/* Position in dec_index() */
|
||||
enum {
|
||||
SEQ_INDEX_COUNT,
|
||||
SEQ_INDEX_UNPADDED,
|
||||
SEQ_INDEX_UNCOMPRESSED
|
||||
} sequence;
|
||||
|
||||
/* Size of the Index in bytes */
|
||||
vli_type size;
|
||||
|
||||
/* Number of Records (matches block.count in valid files) */
|
||||
vli_type count;
|
||||
|
||||
/*
|
||||
* Hash calculated from the Records (matches block.hash in
|
||||
* valid files).
|
||||
*/
|
||||
struct xz_dec_hash hash;
|
||||
} index;
|
||||
|
||||
/*
|
||||
* Temporary buffer needed to hold Stream Header, Block Header,
|
||||
* and Stream Footer. The Block Header is the biggest (1 KiB)
|
||||
* so we reserve space according to that. buf[] has to be aligned
|
||||
* to a multiple of four bytes; the size_t variables before it
|
||||
* should guarantee this.
|
||||
*/
|
||||
struct {
|
||||
size_t pos;
|
||||
size_t size;
|
||||
uint8_t buf[1024];
|
||||
} temp;
|
||||
|
||||
struct xz_dec_lzma2 *lzma2;
|
||||
|
||||
#ifdef XZ_DEC_BCJ
|
||||
struct xz_dec_bcj *bcj;
|
||||
bool bcj_active;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef XZ_DEC_ANY_CHECK
|
||||
/* Sizes of the Check field with different Check IDs */
|
||||
static const uint8_t check_sizes[16] = {
|
||||
0,
|
||||
4, 4, 4,
|
||||
8, 8, 8,
|
||||
16, 16, 16,
|
||||
32, 32, 32,
|
||||
64, 64, 64
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fill s->temp by copying data starting from b->in[b->in_pos]. Caller
|
||||
* must have set s->temp.pos to indicate how much data we are supposed
|
||||
* to copy into s->temp.buf. Return true once s->temp.pos has reached
|
||||
* s->temp.size.
|
||||
*/
|
||||
static bool XZ_FUNC fill_temp(struct xz_dec *s, struct xz_buf *b)
|
||||
{
|
||||
size_t copy_size = min_t(size_t,
|
||||
b->in_size - b->in_pos, s->temp.size - s->temp.pos);
|
||||
|
||||
memcpy(s->temp.buf + s->temp.pos, b->in + b->in_pos, copy_size);
|
||||
b->in_pos += copy_size;
|
||||
s->temp.pos += copy_size;
|
||||
|
||||
if (s->temp.pos == s->temp.size) {
|
||||
s->temp.pos = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Decode a variable-length integer (little-endian base-128 encoding) */
|
||||
static enum xz_ret XZ_FUNC dec_vli(struct xz_dec *s,
|
||||
const uint8_t *in, size_t *in_pos, size_t in_size)
|
||||
{
|
||||
uint8_t byte;
|
||||
|
||||
if (s->pos == 0)
|
||||
s->vli = 0;
|
||||
|
||||
while (*in_pos < in_size) {
|
||||
byte = in[*in_pos];
|
||||
++*in_pos;
|
||||
|
||||
s->vli |= (vli_type)(byte & 0x7F) << s->pos;
|
||||
|
||||
if ((byte & 0x80) == 0) {
|
||||
/* Don't allow non-minimal encodings. */
|
||||
if (byte == 0 && s->pos != 0)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
s->pos = 0;
|
||||
return XZ_STREAM_END;
|
||||
}
|
||||
|
||||
s->pos += 7;
|
||||
if (s->pos == 7 * VLI_BYTES_MAX)
|
||||
return XZ_DATA_ERROR;
|
||||
}
|
||||
|
||||
return XZ_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode the Compressed Data field from a Block. Update and validate
|
||||
* the observed compressed and uncompressed sizes of the Block so that
|
||||
* they don't exceed the values possibly stored in the Block Header
|
||||
* (validation assumes that no integer overflow occurs, since vli_type
|
||||
* is normally uint64_t). Update the CRC32 if presence of the CRC32
|
||||
* field was indicated in Stream Header.
|
||||
*
|
||||
* Once the decoding is finished, validate that the observed sizes match
|
||||
* the sizes possibly stored in the Block Header. Update the hash and
|
||||
* Block count, which are later used to validate the Index field.
|
||||
*/
|
||||
static enum xz_ret XZ_FUNC dec_block(struct xz_dec *s, struct xz_buf *b)
|
||||
{
|
||||
enum xz_ret ret;
|
||||
|
||||
s->in_start = b->in_pos;
|
||||
s->out_start = b->out_pos;
|
||||
|
||||
#ifdef XZ_DEC_BCJ
|
||||
if (s->bcj_active)
|
||||
ret = xz_dec_bcj_run(s->bcj, s->lzma2, b);
|
||||
else
|
||||
#endif
|
||||
ret = xz_dec_lzma2_run(s->lzma2, b);
|
||||
|
||||
s->block.compressed += b->in_pos - s->in_start;
|
||||
s->block.uncompressed += b->out_pos - s->out_start;
|
||||
|
||||
/*
|
||||
* There is no need to separately check for VLI_UNKNOWN, since
|
||||
* the observed sizes are always smaller than VLI_UNKNOWN.
|
||||
*/
|
||||
if (s->block.compressed > s->block_header.compressed
|
||||
|| s->block.uncompressed
|
||||
> s->block_header.uncompressed)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
if (s->check_type == XZ_CHECK_CRC32)
|
||||
s->crc32 = xz_crc32(b->out + s->out_start,
|
||||
b->out_pos - s->out_start, s->crc32);
|
||||
|
||||
if (ret == XZ_STREAM_END) {
|
||||
if (s->block_header.compressed != VLI_UNKNOWN
|
||||
&& s->block_header.compressed
|
||||
!= s->block.compressed)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
if (s->block_header.uncompressed != VLI_UNKNOWN
|
||||
&& s->block_header.uncompressed
|
||||
!= s->block.uncompressed)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
s->block.hash.unpadded += s->block_header.size
|
||||
+ s->block.compressed;
|
||||
|
||||
#ifdef XZ_DEC_ANY_CHECK
|
||||
s->block.hash.unpadded += check_sizes[s->check_type];
|
||||
#else
|
||||
if (s->check_type == XZ_CHECK_CRC32)
|
||||
s->block.hash.unpadded += 4;
|
||||
#endif
|
||||
|
||||
s->block.hash.uncompressed += s->block.uncompressed;
|
||||
s->block.hash.crc32 = xz_crc32(
|
||||
(const uint8_t *)&s->block.hash,
|
||||
sizeof(s->block.hash), s->block.hash.crc32);
|
||||
|
||||
++s->block.count;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Update the Index size and the CRC32 value. */
|
||||
static void XZ_FUNC index_update(struct xz_dec *s, const struct xz_buf *b)
|
||||
{
|
||||
size_t in_used = b->in_pos - s->in_start;
|
||||
s->index.size += in_used;
|
||||
s->crc32 = xz_crc32(b->in + s->in_start, in_used, s->crc32);
|
||||
}
|
||||
|
||||
/*
|
||||
* Decode the Number of Records, Unpadded Size, and Uncompressed Size
|
||||
* fields from the Index field. That is, Index Padding and CRC32 are not
|
||||
* decoded by this function.
|
||||
*
|
||||
* This can return XZ_OK (more input needed), XZ_STREAM_END (everything
|
||||
* successfully decoded), or XZ_DATA_ERROR (input is corrupt).
|
||||
*/
|
||||
static enum xz_ret XZ_FUNC dec_index(struct xz_dec *s, struct xz_buf *b)
|
||||
{
|
||||
enum xz_ret ret;
|
||||
|
||||
do {
|
||||
ret = dec_vli(s, b->in, &b->in_pos, b->in_size);
|
||||
if (ret != XZ_STREAM_END) {
|
||||
index_update(s, b);
|
||||
return ret;
|
||||
}
|
||||
|
||||
switch (s->index.sequence) {
|
||||
case SEQ_INDEX_COUNT:
|
||||
s->index.count = s->vli;
|
||||
|
||||
/*
|
||||
* Validate that the Number of Records field
|
||||
* indicates the same number of Records as
|
||||
* there were Blocks in the Stream.
|
||||
*/
|
||||
if (s->index.count != s->block.count)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
s->index.sequence = SEQ_INDEX_UNPADDED;
|
||||
break;
|
||||
|
||||
case SEQ_INDEX_UNPADDED:
|
||||
s->index.hash.unpadded += s->vli;
|
||||
s->index.sequence = SEQ_INDEX_UNCOMPRESSED;
|
||||
break;
|
||||
|
||||
case SEQ_INDEX_UNCOMPRESSED:
|
||||
s->index.hash.uncompressed += s->vli;
|
||||
s->index.hash.crc32 = xz_crc32(
|
||||
(const uint8_t *)&s->index.hash,
|
||||
sizeof(s->index.hash),
|
||||
s->index.hash.crc32);
|
||||
--s->index.count;
|
||||
s->index.sequence = SEQ_INDEX_UNPADDED;
|
||||
break;
|
||||
}
|
||||
} while (s->index.count > 0);
|
||||
|
||||
return XZ_STREAM_END;
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate that the next four input bytes match the value of s->crc32.
|
||||
* s->pos must be zero when starting to validate the first byte.
|
||||
*/
|
||||
static enum xz_ret XZ_FUNC crc32_validate(struct xz_dec *s, struct xz_buf *b)
|
||||
{
|
||||
do {
|
||||
if (b->in_pos == b->in_size)
|
||||
return XZ_OK;
|
||||
|
||||
if (((s->crc32 >> s->pos) & 0xFF) != b->in[b->in_pos++])
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
s->pos += 8;
|
||||
|
||||
} while (s->pos < 32);
|
||||
|
||||
s->crc32 = 0;
|
||||
s->pos = 0;
|
||||
|
||||
return XZ_STREAM_END;
|
||||
}
|
||||
|
||||
#ifdef XZ_DEC_ANY_CHECK
|
||||
/*
|
||||
* Skip over the Check field when the Check ID is not supported.
|
||||
* Returns true once the whole Check field has been skipped over.
|
||||
*/
|
||||
static bool XZ_FUNC check_skip(struct xz_dec *s, struct xz_buf *b)
|
||||
{
|
||||
while (s->pos < check_sizes[s->check_type]) {
|
||||
if (b->in_pos == b->in_size)
|
||||
return false;
|
||||
|
||||
++b->in_pos;
|
||||
++s->pos;
|
||||
}
|
||||
|
||||
s->pos = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Decode the Stream Header field (the first 12 bytes of the .xz Stream). */
|
||||
static enum xz_ret XZ_FUNC dec_stream_header(struct xz_dec *s)
|
||||
{
|
||||
if (!memeq(s->temp.buf, HEADER_MAGIC, HEADER_MAGIC_SIZE))
|
||||
return XZ_FORMAT_ERROR;
|
||||
|
||||
if (xz_crc32(s->temp.buf + HEADER_MAGIC_SIZE, 2, 0)
|
||||
!= get_le32(s->temp.buf + HEADER_MAGIC_SIZE + 2))
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
if (s->temp.buf[HEADER_MAGIC_SIZE] != 0)
|
||||
return XZ_OPTIONS_ERROR;
|
||||
|
||||
/*
|
||||
* Of integrity checks, we support only none (Check ID = 0) and
|
||||
* CRC32 (Check ID = 1). However, if XZ_DEC_ANY_CHECK is defined,
|
||||
* we will accept other check types too, but then the check won't
|
||||
* be verified and a warning (XZ_UNSUPPORTED_CHECK) will be given.
|
||||
*/
|
||||
s->check_type = s->temp.buf[HEADER_MAGIC_SIZE + 1];
|
||||
|
||||
#ifdef XZ_DEC_ANY_CHECK
|
||||
if (s->check_type > XZ_CHECK_MAX)
|
||||
return XZ_OPTIONS_ERROR;
|
||||
|
||||
if (s->check_type > XZ_CHECK_CRC32)
|
||||
return XZ_UNSUPPORTED_CHECK;
|
||||
#else
|
||||
if (s->check_type > XZ_CHECK_CRC32)
|
||||
return XZ_OPTIONS_ERROR;
|
||||
#endif
|
||||
|
||||
return XZ_OK;
|
||||
}
|
||||
|
||||
/* Decode the Stream Footer field (the last 12 bytes of the .xz Stream) */
|
||||
static enum xz_ret XZ_FUNC dec_stream_footer(struct xz_dec *s)
|
||||
{
|
||||
if (!memeq(s->temp.buf + 10, FOOTER_MAGIC, FOOTER_MAGIC_SIZE))
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
if (xz_crc32(s->temp.buf + 4, 6, 0) != get_le32(s->temp.buf))
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
/*
|
||||
* Validate Backward Size. Note that we never added the size of the
|
||||
* Index CRC32 field to s->index.size, thus we use s->index.size / 4
|
||||
* instead of s->index.size / 4 - 1.
|
||||
*/
|
||||
if ((s->index.size >> 2) != get_le32(s->temp.buf + 4))
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
if (s->temp.buf[8] != 0 || s->temp.buf[9] != s->check_type)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
/*
|
||||
* Use XZ_STREAM_END instead of XZ_OK to be more convenient
|
||||
* for the caller.
|
||||
*/
|
||||
return XZ_STREAM_END;
|
||||
}
|
||||
|
||||
/* Decode the Block Header and initialize the filter chain. */
|
||||
static enum xz_ret XZ_FUNC dec_block_header(struct xz_dec *s)
|
||||
{
|
||||
enum xz_ret ret;
|
||||
|
||||
/*
|
||||
* Validate the CRC32. We know that the temp buffer is at least
|
||||
* eight bytes so this is safe.
|
||||
*/
|
||||
s->temp.size -= 4;
|
||||
if (xz_crc32(s->temp.buf, s->temp.size, 0)
|
||||
!= get_le32(s->temp.buf + s->temp.size))
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
s->temp.pos = 2;
|
||||
|
||||
/*
|
||||
* Catch unsupported Block Flags. We support only one or two filters
|
||||
* in the chain, so we catch that with the same test.
|
||||
*/
|
||||
#ifdef XZ_DEC_BCJ
|
||||
if (s->temp.buf[1] & 0x3E)
|
||||
#else
|
||||
if (s->temp.buf[1] & 0x3F)
|
||||
#endif
|
||||
return XZ_OPTIONS_ERROR;
|
||||
|
||||
/* Compressed Size */
|
||||
if (s->temp.buf[1] & 0x40) {
|
||||
if (dec_vli(s, s->temp.buf, &s->temp.pos, s->temp.size)
|
||||
!= XZ_STREAM_END)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
s->block_header.compressed = s->vli;
|
||||
} else {
|
||||
s->block_header.compressed = VLI_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Uncompressed Size */
|
||||
if (s->temp.buf[1] & 0x80) {
|
||||
if (dec_vli(s, s->temp.buf, &s->temp.pos, s->temp.size)
|
||||
!= XZ_STREAM_END)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
s->block_header.uncompressed = s->vli;
|
||||
} else {
|
||||
s->block_header.uncompressed = VLI_UNKNOWN;
|
||||
}
|
||||
|
||||
#ifdef XZ_DEC_BCJ
|
||||
/* If there are two filters, the first one must be a BCJ filter. */
|
||||
s->bcj_active = s->temp.buf[1] & 0x01;
|
||||
if (s->bcj_active) {
|
||||
if (s->temp.size - s->temp.pos < 2)
|
||||
return XZ_OPTIONS_ERROR;
|
||||
|
||||
ret = xz_dec_bcj_reset(s->bcj, s->temp.buf[s->temp.pos++]);
|
||||
if (ret != XZ_OK)
|
||||
return ret;
|
||||
|
||||
/*
|
||||
* We don't support custom start offset,
|
||||
* so Size of Properties must be zero.
|
||||
*/
|
||||
if (s->temp.buf[s->temp.pos++] != 0x00)
|
||||
return XZ_OPTIONS_ERROR;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Valid Filter Flags always take at least two bytes. */
|
||||
if (s->temp.size - s->temp.pos < 2)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
/* Filter ID = LZMA2 */
|
||||
if (s->temp.buf[s->temp.pos++] != 0x21)
|
||||
return XZ_OPTIONS_ERROR;
|
||||
|
||||
/* Size of Properties = 1-byte Filter Properties */
|
||||
if (s->temp.buf[s->temp.pos++] != 0x01)
|
||||
return XZ_OPTIONS_ERROR;
|
||||
|
||||
/* Filter Properties contains LZMA2 dictionary size. */
|
||||
if (s->temp.size - s->temp.pos < 1)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
ret = xz_dec_lzma2_reset(s->lzma2, s->temp.buf[s->temp.pos++]);
|
||||
if (ret != XZ_OK)
|
||||
return ret;
|
||||
|
||||
/* The rest must be Header Padding. */
|
||||
while (s->temp.pos < s->temp.size)
|
||||
if (s->temp.buf[s->temp.pos++] != 0x00)
|
||||
return XZ_OPTIONS_ERROR;
|
||||
|
||||
s->temp.pos = 0;
|
||||
s->block.compressed = 0;
|
||||
s->block.uncompressed = 0;
|
||||
|
||||
return XZ_OK;
|
||||
}
|
||||
|
||||
static enum xz_ret XZ_FUNC dec_main(struct xz_dec *s, struct xz_buf *b)
|
||||
{
|
||||
enum xz_ret ret;
|
||||
|
||||
/*
|
||||
* Store the start position for the case when we are in the middle
|
||||
* of the Index field.
|
||||
*/
|
||||
s->in_start = b->in_pos;
|
||||
|
||||
while (true) {
|
||||
switch (s->sequence) {
|
||||
case SEQ_STREAM_HEADER:
|
||||
/*
|
||||
* Stream Header is copied to s->temp, and then
|
||||
* decoded from there. This way if the caller
|
||||
* gives us only little input at a time, we can
|
||||
* still keep the Stream Header decoding code
|
||||
* simple. Similar approach is used in many places
|
||||
* in this file.
|
||||
*/
|
||||
if (!fill_temp(s, b))
|
||||
return XZ_OK;
|
||||
|
||||
/*
|
||||
* If dec_stream_header() returns
|
||||
* XZ_UNSUPPORTED_CHECK, it is still possible
|
||||
* to continue decoding if working in multi-call
|
||||
* mode. Thus, update s->sequence before calling
|
||||
* dec_stream_header().
|
||||
*/
|
||||
s->sequence = SEQ_BLOCK_START;
|
||||
|
||||
ret = dec_stream_header(s);
|
||||
if (ret != XZ_OK)
|
||||
return ret;
|
||||
|
||||
case SEQ_BLOCK_START:
|
||||
/* We need one byte of input to continue. */
|
||||
if (b->in_pos == b->in_size)
|
||||
return XZ_OK;
|
||||
|
||||
/* See if this is the beginning of the Index field. */
|
||||
if (b->in[b->in_pos] == 0) {
|
||||
s->in_start = b->in_pos++;
|
||||
s->sequence = SEQ_INDEX;
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the size of the Block Header and
|
||||
* prepare to decode it.
|
||||
*/
|
||||
s->block_header.size
|
||||
= ((uint32_t)b->in[b->in_pos] + 1) * 4;
|
||||
|
||||
s->temp.size = s->block_header.size;
|
||||
s->temp.pos = 0;
|
||||
s->sequence = SEQ_BLOCK_HEADER;
|
||||
|
||||
case SEQ_BLOCK_HEADER:
|
||||
if (!fill_temp(s, b))
|
||||
return XZ_OK;
|
||||
|
||||
ret = dec_block_header(s);
|
||||
if (ret != XZ_OK)
|
||||
return ret;
|
||||
|
||||
s->sequence = SEQ_BLOCK_UNCOMPRESS;
|
||||
|
||||
case SEQ_BLOCK_UNCOMPRESS:
|
||||
ret = dec_block(s, b);
|
||||
if (ret != XZ_STREAM_END)
|
||||
return ret;
|
||||
|
||||
s->sequence = SEQ_BLOCK_PADDING;
|
||||
|
||||
case SEQ_BLOCK_PADDING:
|
||||
/*
|
||||
* Size of Compressed Data + Block Padding
|
||||
* must be a multiple of four. We don't need
|
||||
* s->block.compressed for anything else
|
||||
* anymore, so we use it here to test the size
|
||||
* of the Block Padding field.
|
||||
*/
|
||||
while (s->block.compressed & 3) {
|
||||
if (b->in_pos == b->in_size)
|
||||
return XZ_OK;
|
||||
|
||||
if (b->in[b->in_pos++] != 0)
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
++s->block.compressed;
|
||||
}
|
||||
|
||||
s->sequence = SEQ_BLOCK_CHECK;
|
||||
|
||||
case SEQ_BLOCK_CHECK:
|
||||
if (s->check_type == XZ_CHECK_CRC32) {
|
||||
ret = crc32_validate(s, b);
|
||||
if (ret != XZ_STREAM_END)
|
||||
return ret;
|
||||
}
|
||||
#ifdef XZ_DEC_ANY_CHECK
|
||||
else if (!check_skip(s, b)) {
|
||||
return XZ_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
s->sequence = SEQ_BLOCK_START;
|
||||
break;
|
||||
|
||||
case SEQ_INDEX:
|
||||
ret = dec_index(s, b);
|
||||
if (ret != XZ_STREAM_END)
|
||||
return ret;
|
||||
|
||||
s->sequence = SEQ_INDEX_PADDING;
|
||||
|
||||
case SEQ_INDEX_PADDING:
|
||||
while ((s->index.size + (b->in_pos - s->in_start))
|
||||
& 3) {
|
||||
if (b->in_pos == b->in_size) {
|
||||
index_update(s, b);
|
||||
return XZ_OK;
|
||||
}
|
||||
|
||||
if (b->in[b->in_pos++] != 0)
|
||||
return XZ_DATA_ERROR;
|
||||
}
|
||||
|
||||
/* Finish the CRC32 value and Index size. */
|
||||
index_update(s, b);
|
||||
|
||||
/* Compare the hashes to validate the Index field. */
|
||||
if (!memeq(&s->block.hash, &s->index.hash,
|
||||
sizeof(s->block.hash)))
|
||||
return XZ_DATA_ERROR;
|
||||
|
||||
s->sequence = SEQ_INDEX_CRC32;
|
||||
|
||||
case SEQ_INDEX_CRC32:
|
||||
ret = crc32_validate(s, b);
|
||||
if (ret != XZ_STREAM_END)
|
||||
return ret;
|
||||
|
||||
s->temp.size = STREAM_HEADER_SIZE;
|
||||
s->sequence = SEQ_STREAM_FOOTER;
|
||||
|
||||
case SEQ_STREAM_FOOTER:
|
||||
if (!fill_temp(s, b))
|
||||
return XZ_OK;
|
||||
|
||||
return dec_stream_footer(s);
|
||||
}
|
||||
}
|
||||
|
||||
/* Never reached */
|
||||
}
|
||||
|
||||
/*
|
||||
* xz_dec_run() is a wrapper for dec_main() to handle some special cases in
|
||||
* multi-call and single-call decoding.
|
||||
*
|
||||
* In multi-call mode, we must return XZ_BUF_ERROR when it seems clear that we
|
||||
* are not going to make any progress anymore. This is to prevent the caller
|
||||
* from calling us infinitely when the input file is truncated or otherwise
|
||||
* corrupt. Since zlib-style API allows that the caller fills the input buffer
|
||||
* only when the decoder doesn't produce any new output, we have to be careful
|
||||
* to avoid returning XZ_BUF_ERROR too easily: XZ_BUF_ERROR is returned only
|
||||
* after the second consecutive call to xz_dec_run() that makes no progress.
|
||||
*
|
||||
* In single-call mode, if we couldn't decode everything and no error
|
||||
* occurred, either the input is truncated or the output buffer is too small.
|
||||
* Since we know that the last input byte never produces any output, we know
|
||||
* that if all the input was consumed and decoding wasn't finished, the file
|
||||
* must be corrupt. Otherwise the output buffer has to be too small or the
|
||||
* file is corrupt in a way that decoding it produces too big output.
|
||||
*
|
||||
* If single-call decoding fails, we reset b->in_pos and b->out_pos back to
|
||||
* their original values. This is because with some filter chains there won't
|
||||
* be any valid uncompressed data in the output buffer unless the decoding
|
||||
* actually succeeds (that's the price to pay of using the output buffer as
|
||||
* the workspace).
|
||||
*/
|
||||
XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_run(struct xz_dec *s, struct xz_buf *b)
|
||||
{
|
||||
size_t in_start;
|
||||
size_t out_start;
|
||||
enum xz_ret ret;
|
||||
|
||||
if (DEC_IS_SINGLE(s->mode))
|
||||
xz_dec_reset(s);
|
||||
|
||||
in_start = b->in_pos;
|
||||
out_start = b->out_pos;
|
||||
ret = dec_main(s, b);
|
||||
|
||||
if (DEC_IS_SINGLE(s->mode)) {
|
||||
if (ret == XZ_OK)
|
||||
ret = b->in_pos == b->in_size
|
||||
? XZ_DATA_ERROR : XZ_BUF_ERROR;
|
||||
|
||||
if (ret != XZ_STREAM_END) {
|
||||
b->in_pos = in_start;
|
||||
b->out_pos = out_start;
|
||||
}
|
||||
|
||||
} else if (ret == XZ_OK && in_start == b->in_pos
|
||||
&& out_start == b->out_pos) {
|
||||
if (s->allow_buf_error)
|
||||
ret = XZ_BUF_ERROR;
|
||||
|
||||
s->allow_buf_error = true;
|
||||
} else {
|
||||
s->allow_buf_error = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
XZ_EXTERN struct xz_dec * XZ_FUNC xz_dec_init(
|
||||
enum xz_mode mode, uint32_t dict_max)
|
||||
{
|
||||
struct xz_dec *s = kmalloc(sizeof(*s), GFP_KERNEL);
|
||||
if (s == NULL)
|
||||
return NULL;
|
||||
|
||||
s->mode = mode;
|
||||
|
||||
#ifdef XZ_DEC_BCJ
|
||||
s->bcj = xz_dec_bcj_create(DEC_IS_SINGLE(mode));
|
||||
if (s->bcj == NULL)
|
||||
goto error_bcj;
|
||||
#endif
|
||||
|
||||
s->lzma2 = xz_dec_lzma2_create(mode, dict_max);
|
||||
if (s->lzma2 == NULL)
|
||||
goto error_lzma2;
|
||||
|
||||
xz_dec_reset(s);
|
||||
return s;
|
||||
|
||||
error_lzma2:
|
||||
#ifdef XZ_DEC_BCJ
|
||||
xz_dec_bcj_end(s->bcj);
|
||||
error_bcj:
|
||||
#endif
|
||||
kfree(s);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
XZ_EXTERN void XZ_FUNC xz_dec_reset(struct xz_dec *s)
|
||||
{
|
||||
s->sequence = SEQ_STREAM_HEADER;
|
||||
s->allow_buf_error = false;
|
||||
s->pos = 0;
|
||||
s->crc32 = 0;
|
||||
memzero(&s->block, sizeof(s->block));
|
||||
memzero(&s->index, sizeof(s->index));
|
||||
s->temp.pos = 0;
|
||||
s->temp.size = STREAM_HEADER_SIZE;
|
||||
}
|
||||
|
||||
XZ_EXTERN void XZ_FUNC xz_dec_end(struct xz_dec *s)
|
||||
{
|
||||
if (s != NULL) {
|
||||
xz_dec_lzma2_end(s->lzma2);
|
||||
#ifdef XZ_DEC_BCJ
|
||||
xz_dec_bcj_end(s->bcj);
|
||||
#endif
|
||||
kfree(s);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* LZMA2 definitions
|
||||
*
|
||||
* Authors: Lasse Collin <lasse.collin@tukaani.org>
|
||||
* Igor Pavlov <http://7-zip.org/>
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*/
|
||||
|
||||
#ifndef XZ_LZMA2_H
|
||||
#define XZ_LZMA2_H
|
||||
|
||||
/* Range coder constants */
|
||||
#define RC_SHIFT_BITS 8
|
||||
#define RC_TOP_BITS 24
|
||||
#define RC_TOP_VALUE (1 << RC_TOP_BITS)
|
||||
#define RC_BIT_MODEL_TOTAL_BITS 11
|
||||
#define RC_BIT_MODEL_TOTAL (1 << RC_BIT_MODEL_TOTAL_BITS)
|
||||
#define RC_MOVE_BITS 5
|
||||
|
||||
/*
|
||||
* Maximum number of position states. A position state is the lowest pb
|
||||
* number of bits of the current uncompressed offset. In some places there
|
||||
* are different sets of probabilities for different position states.
|
||||
*/
|
||||
#define POS_STATES_MAX (1 << 4)
|
||||
|
||||
/*
|
||||
* This enum is used to track which LZMA symbols have occurred most recently
|
||||
* and in which order. This information is used to predict the next symbol.
|
||||
*
|
||||
* Symbols:
|
||||
* - Literal: One 8-bit byte
|
||||
* - Match: Repeat a chunk of data at some distance
|
||||
* - Long repeat: Multi-byte match at a recently seen distance
|
||||
* - Short repeat: One-byte repeat at a recently seen distance
|
||||
*
|
||||
* The symbol names are in from STATE_oldest_older_previous. REP means
|
||||
* either short or long repeated match, and NONLIT means any non-literal.
|
||||
*/
|
||||
enum lzma_state {
|
||||
STATE_LIT_LIT,
|
||||
STATE_MATCH_LIT_LIT,
|
||||
STATE_REP_LIT_LIT,
|
||||
STATE_SHORTREP_LIT_LIT,
|
||||
STATE_MATCH_LIT,
|
||||
STATE_REP_LIT,
|
||||
STATE_SHORTREP_LIT,
|
||||
STATE_LIT_MATCH,
|
||||
STATE_LIT_LONGREP,
|
||||
STATE_LIT_SHORTREP,
|
||||
STATE_NONLIT_MATCH,
|
||||
STATE_NONLIT_REP
|
||||
};
|
||||
|
||||
/* Total number of states */
|
||||
#define STATES 12
|
||||
|
||||
/* The lowest 7 states indicate that the previous state was a literal. */
|
||||
#define LIT_STATES 7
|
||||
|
||||
/* Indicate that the latest symbol was a literal. */
|
||||
static inline void XZ_FUNC lzma_state_literal(enum lzma_state *state)
|
||||
{
|
||||
if (*state <= STATE_SHORTREP_LIT_LIT)
|
||||
*state = STATE_LIT_LIT;
|
||||
else if (*state <= STATE_LIT_SHORTREP)
|
||||
*state -= 3;
|
||||
else
|
||||
*state -= 6;
|
||||
}
|
||||
|
||||
/* Indicate that the latest symbol was a match. */
|
||||
static inline void XZ_FUNC lzma_state_match(enum lzma_state *state)
|
||||
{
|
||||
*state = *state < LIT_STATES ? STATE_LIT_MATCH : STATE_NONLIT_MATCH;
|
||||
}
|
||||
|
||||
/* Indicate that the latest state was a long repeated match. */
|
||||
static inline void XZ_FUNC lzma_state_long_rep(enum lzma_state *state)
|
||||
{
|
||||
*state = *state < LIT_STATES ? STATE_LIT_LONGREP : STATE_NONLIT_REP;
|
||||
}
|
||||
|
||||
/* Indicate that the latest symbol was a short match. */
|
||||
static inline void XZ_FUNC lzma_state_short_rep(enum lzma_state *state)
|
||||
{
|
||||
*state = *state < LIT_STATES ? STATE_LIT_SHORTREP : STATE_NONLIT_REP;
|
||||
}
|
||||
|
||||
/* Test if the previous symbol was a literal. */
|
||||
static inline bool XZ_FUNC lzma_state_is_literal(enum lzma_state state)
|
||||
{
|
||||
return state < LIT_STATES;
|
||||
}
|
||||
|
||||
/* Each literal coder is divided in three sections:
|
||||
* - 0x001-0x0FF: Without match byte
|
||||
* - 0x101-0x1FF: With match byte; match bit is 0
|
||||
* - 0x201-0x2FF: With match byte; match bit is 1
|
||||
*
|
||||
* Match byte is used when the previous LZMA symbol was something else than
|
||||
* a literal (that is, it was some kind of match).
|
||||
*/
|
||||
#define LITERAL_CODER_SIZE 0x300
|
||||
|
||||
/* Maximum number of literal coders */
|
||||
#define LITERAL_CODERS_MAX (1 << 4)
|
||||
|
||||
/* Minimum length of a match is two bytes. */
|
||||
#define MATCH_LEN_MIN 2
|
||||
|
||||
/* Match length is encoded with 4, 5, or 10 bits.
|
||||
*
|
||||
* Length Bits
|
||||
* 2-9 4 = Choice=0 + 3 bits
|
||||
* 10-17 5 = Choice=1 + Choice2=0 + 3 bits
|
||||
* 18-273 10 = Choice=1 + Choice2=1 + 8 bits
|
||||
*/
|
||||
#define LEN_LOW_BITS 3
|
||||
#define LEN_LOW_SYMBOLS (1 << LEN_LOW_BITS)
|
||||
#define LEN_MID_BITS 3
|
||||
#define LEN_MID_SYMBOLS (1 << LEN_MID_BITS)
|
||||
#define LEN_HIGH_BITS 8
|
||||
#define LEN_HIGH_SYMBOLS (1 << LEN_HIGH_BITS)
|
||||
#define LEN_SYMBOLS (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS)
|
||||
|
||||
/*
|
||||
* Maximum length of a match is 273 which is a result of the encoding
|
||||
* described above.
|
||||
*/
|
||||
#define MATCH_LEN_MAX (MATCH_LEN_MIN + LEN_SYMBOLS - 1)
|
||||
|
||||
/*
|
||||
* Different sets of probabilities are used for match distances that have
|
||||
* very short match length: Lengths of 2, 3, and 4 bytes have a separate
|
||||
* set of probabilities for each length. The matches with longer length
|
||||
* use a shared set of probabilities.
|
||||
*/
|
||||
#define DIST_STATES 4
|
||||
|
||||
/*
|
||||
* Get the index of the appropriate probability array for decoding
|
||||
* the distance slot.
|
||||
*/
|
||||
static inline uint32_t XZ_FUNC lzma_get_dist_state(uint32_t len)
|
||||
{
|
||||
return len < DIST_STATES + MATCH_LEN_MIN
|
||||
? len - MATCH_LEN_MIN : DIST_STATES - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* The highest two bits of a 32-bit match distance are encoded using six bits.
|
||||
* This six-bit value is called a distance slot. This way encoding a 32-bit
|
||||
* value takes 6-36 bits, larger values taking more bits.
|
||||
*/
|
||||
#define DIST_SLOT_BITS 6
|
||||
#define DIST_SLOTS (1 << DIST_SLOT_BITS)
|
||||
|
||||
/* Match distances up to 127 are fully encoded using probabilities. Since
|
||||
* the highest two bits (distance slot) are always encoded using six bits,
|
||||
* the distances 0-3 don't need any additional bits to encode, since the
|
||||
* distance slot itself is the same as the actual distance. DIST_MODEL_START
|
||||
* indicates the first distance slot where at least one additional bit is
|
||||
* needed.
|
||||
*/
|
||||
#define DIST_MODEL_START 4
|
||||
|
||||
/*
|
||||
* Match distances greater than 127 are encoded in three pieces:
|
||||
* - distance slot: the highest two bits
|
||||
* - direct bits: 2-26 bits below the highest two bits
|
||||
* - alignment bits: four lowest bits
|
||||
*
|
||||
* Direct bits don't use any probabilities.
|
||||
*
|
||||
* The distance slot value of 14 is for distances 128-191.
|
||||
*/
|
||||
#define DIST_MODEL_END 14
|
||||
|
||||
/* Distance slots that indicate a distance <= 127. */
|
||||
#define FULL_DISTANCES_BITS (DIST_MODEL_END / 2)
|
||||
#define FULL_DISTANCES (1 << FULL_DISTANCES_BITS)
|
||||
|
||||
/*
|
||||
* For match distances greater than 127, only the highest two bits and the
|
||||
* lowest four bits (alignment) is encoded using probabilities.
|
||||
*/
|
||||
#define ALIGN_BITS 4
|
||||
#define ALIGN_SIZE (1 << ALIGN_BITS)
|
||||
#define ALIGN_MASK (ALIGN_SIZE - 1)
|
||||
|
||||
/* Total number of all probability variables */
|
||||
#define PROBS_TOTAL (1846 + LITERAL_CODERS_MAX * LITERAL_CODER_SIZE)
|
||||
|
||||
/*
|
||||
* LZMA remembers the four most recent match distances. Reusing these
|
||||
* distances tends to take less space than re-encoding the actual
|
||||
* distance value.
|
||||
*/
|
||||
#define REPS 4
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Private includes and definitions
|
||||
*
|
||||
* Author: Lasse Collin <lasse.collin@tukaani.org>
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*/
|
||||
|
||||
#ifndef XZ_PRIVATE_H
|
||||
#define XZ_PRIVATE_H
|
||||
|
||||
#ifdef __KERNEL__
|
||||
/* XZ_PREBOOT may be defined only via decompress_unxz.c. */
|
||||
# ifndef XZ_PREBOOT
|
||||
# include <linux/slab.h>
|
||||
# include <linux/vmalloc.h>
|
||||
# include <linux/string.h>
|
||||
# define memeq(a, b, size) (memcmp(a, b, size) == 0)
|
||||
# define memzero(buf, size) memset(buf, 0, size)
|
||||
# endif
|
||||
# include <asm/byteorder.h>
|
||||
# include <asm/unaligned.h>
|
||||
# define get_le32(p) le32_to_cpup((const uint32_t *)(p))
|
||||
/* XZ_IGNORE_KCONFIG may be defined only via decompress_unxz.c. */
|
||||
# ifndef XZ_IGNORE_KCONFIG
|
||||
# ifdef CONFIG_XZ_DEC_X86
|
||||
# define XZ_DEC_X86
|
||||
# endif
|
||||
# ifdef CONFIG_XZ_DEC_POWERPC
|
||||
# define XZ_DEC_POWERPC
|
||||
# endif
|
||||
# ifdef CONFIG_XZ_DEC_IA64
|
||||
# define XZ_DEC_IA64
|
||||
# endif
|
||||
# ifdef CONFIG_XZ_DEC_ARM
|
||||
# define XZ_DEC_ARM
|
||||
# endif
|
||||
# ifdef CONFIG_XZ_DEC_ARMTHUMB
|
||||
# define XZ_DEC_ARMTHUMB
|
||||
# endif
|
||||
# ifdef CONFIG_XZ_DEC_SPARC
|
||||
# define XZ_DEC_SPARC
|
||||
# endif
|
||||
# endif
|
||||
# include <linux/xz.h>
|
||||
#else
|
||||
/*
|
||||
* For userspace builds, use a separate header to define the required
|
||||
* macros and functions. This makes it easier to adapt the code into
|
||||
* different environments and avoids clutter in the Linux kernel tree.
|
||||
*/
|
||||
# include "xz_config.h"
|
||||
#endif
|
||||
|
||||
/* If no specific decoding mode is requested, enable support for all modes. */
|
||||
#if !defined(XZ_DEC_SINGLE) && !defined(XZ_DEC_PREALLOC) \
|
||||
&& !defined(XZ_DEC_DYNALLOC)
|
||||
# define XZ_DEC_SINGLE
|
||||
# define XZ_DEC_PREALLOC
|
||||
# define XZ_DEC_DYNALLOC
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The DEC_IS_foo(mode) macros are used in "if" statements. If only some
|
||||
* of the supported modes are enabled, these macros will evaluate to true or
|
||||
* false at compile time and thus allow the compiler to omit unneeded code.
|
||||
*/
|
||||
#ifdef XZ_DEC_SINGLE
|
||||
# define DEC_IS_SINGLE(mode) ((mode) == XZ_SINGLE)
|
||||
#else
|
||||
# define DEC_IS_SINGLE(mode) (false)
|
||||
#endif
|
||||
|
||||
#ifdef XZ_DEC_PREALLOC
|
||||
# define DEC_IS_PREALLOC(mode) ((mode) == XZ_PREALLOC)
|
||||
#else
|
||||
# define DEC_IS_PREALLOC(mode) (false)
|
||||
#endif
|
||||
|
||||
#ifdef XZ_DEC_DYNALLOC
|
||||
# define DEC_IS_DYNALLOC(mode) ((mode) == XZ_DYNALLOC)
|
||||
#else
|
||||
# define DEC_IS_DYNALLOC(mode) (false)
|
||||
#endif
|
||||
|
||||
#if !defined(XZ_DEC_SINGLE)
|
||||
# define DEC_IS_MULTI(mode) (true)
|
||||
#elif defined(XZ_DEC_PREALLOC) || defined(XZ_DEC_DYNALLOC)
|
||||
# define DEC_IS_MULTI(mode) ((mode) != XZ_SINGLE)
|
||||
#else
|
||||
# define DEC_IS_MULTI(mode) (false)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* If any of the BCJ filter decoders are wanted, define XZ_DEC_BCJ.
|
||||
* XZ_DEC_BCJ is used to enable generic support for BCJ decoders.
|
||||
*/
|
||||
#ifndef XZ_DEC_BCJ
|
||||
# if defined(XZ_DEC_X86) || defined(XZ_DEC_POWERPC) \
|
||||
|| defined(XZ_DEC_IA64) || defined(XZ_DEC_ARM) \
|
||||
|| defined(XZ_DEC_ARM) || defined(XZ_DEC_ARMTHUMB) \
|
||||
|| defined(XZ_DEC_SPARC)
|
||||
# define XZ_DEC_BCJ
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used
|
||||
* before calling xz_dec_lzma2_run().
|
||||
*/
|
||||
XZ_EXTERN struct xz_dec_lzma2 * XZ_FUNC xz_dec_lzma2_create(
|
||||
enum xz_mode mode, uint32_t dict_max);
|
||||
|
||||
/*
|
||||
* Decode the LZMA2 properties (one byte) and reset the decoder. Return
|
||||
* XZ_OK on success, XZ_MEMLIMIT_ERROR if the preallocated dictionary is not
|
||||
* big enough, and XZ_OPTIONS_ERROR if props indicates something that this
|
||||
* decoder doesn't support.
|
||||
*/
|
||||
XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_lzma2_reset(
|
||||
struct xz_dec_lzma2 *s, uint8_t props);
|
||||
|
||||
/* Decode raw LZMA2 stream from b->in to b->out. */
|
||||
XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_lzma2_run(
|
||||
struct xz_dec_lzma2 *s, struct xz_buf *b);
|
||||
|
||||
/* Free the memory allocated for the LZMA2 decoder. */
|
||||
XZ_EXTERN void XZ_FUNC xz_dec_lzma2_end(struct xz_dec_lzma2 *s);
|
||||
|
||||
#ifdef XZ_DEC_BCJ
|
||||
/*
|
||||
* Allocate memory for BCJ decoders. xz_dec_bcj_reset() must be used before
|
||||
* calling xz_dec_bcj_run().
|
||||
*/
|
||||
XZ_EXTERN struct xz_dec_bcj * XZ_FUNC xz_dec_bcj_create(bool single_call);
|
||||
|
||||
/*
|
||||
* Decode the Filter ID of a BCJ filter. This implementation doesn't
|
||||
* support custom start offsets, so no decoding of Filter Properties
|
||||
* is needed. Returns XZ_OK if the given Filter ID is supported.
|
||||
* Otherwise XZ_OPTIONS_ERROR is returned.
|
||||
*/
|
||||
XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_bcj_reset(
|
||||
struct xz_dec_bcj *s, uint8_t id);
|
||||
|
||||
/*
|
||||
* Decode raw BCJ + LZMA2 stream. This must be used only if there actually is
|
||||
* a BCJ filter in the chain. If the chain has only LZMA2, xz_dec_lzma2_run()
|
||||
* must be called directly.
|
||||
*/
|
||||
XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_bcj_run(struct xz_dec_bcj *s,
|
||||
struct xz_dec_lzma2 *lzma2, struct xz_buf *b);
|
||||
|
||||
/* Free the memory allocated for the BCJ filters. */
|
||||
#define xz_dec_bcj_end(s) kfree(s)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Definitions for handling the .xz file format
|
||||
*
|
||||
* Author: Lasse Collin <lasse.collin@tukaani.org>
|
||||
*
|
||||
* This file has been put into the public domain.
|
||||
* You can do whatever you want with this file.
|
||||
*/
|
||||
|
||||
#ifndef XZ_STREAM_H
|
||||
#define XZ_STREAM_H
|
||||
|
||||
#if defined(__KERNEL__) && !XZ_INTERNAL_CRC32
|
||||
# include <linux/crc32.h>
|
||||
# undef crc32
|
||||
# define xz_crc32(buf, size, crc) \
|
||||
(~crc32_le(~(uint32_t)(crc), buf, size))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* See the .xz file format specification at
|
||||
* http://tukaani.org/xz/xz-file-format.txt
|
||||
* to understand the container format.
|
||||
*/
|
||||
|
||||
#define STREAM_HEADER_SIZE 12
|
||||
|
||||
#define HEADER_MAGIC "\3757zXZ\0"
|
||||
#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.
|
||||
*/
|
||||
typedef uint64_t vli_type;
|
||||
|
||||
#define VLI_MAX ((vli_type)-1 / 2)
|
||||
#define VLI_UNKNOWN ((vli_type)-1)
|
||||
|
||||
/* Maximum encoded size of a VLI */
|
||||
#define VLI_BYTES_MAX (sizeof(vli_type) * 8 / 7)
|
||||
|
||||
/* Integrity Check types */
|
||||
enum xz_check {
|
||||
XZ_CHECK_NONE = 0,
|
||||
XZ_CHECK_CRC32 = 1,
|
||||
XZ_CHECK_CRC64 = 4,
|
||||
XZ_CHECK_SHA256 = 10
|
||||
};
|
||||
|
||||
/* Maximum possible Check ID */
|
||||
#define XZ_CHECK_MAX 15
|
||||
|
||||
#endif
|
||||
+84
-82
@@ -176,7 +176,7 @@ static int swd_init(lzo_swd_p s)
|
||||
if (s->look > 0) {
|
||||
if (s->look > SWD_F)
|
||||
s->look = SWD_F;
|
||||
memcpy(&s->b[s->ip],s->c->ip,s->look);
|
||||
memcpy(&s->b[s->ip], s->c->ip, s->look);
|
||||
s->c->ip += s->look;
|
||||
s->ip += s->look;
|
||||
}
|
||||
@@ -256,8 +256,8 @@ static void swd_accept(lzo_swd_p s, unsigned n)
|
||||
swd_remove_node(s,s->rp);
|
||||
|
||||
/* add bp into HEAD3 */
|
||||
key = HEAD3(s->b,s->bp);
|
||||
s->succ3[s->bp] = s_get_head3(s,key);
|
||||
key = HEAD3(s->b, s->bp);
|
||||
s->succ3[s->bp] = s_get_head3(s, key);
|
||||
s->head3[key] = s->bp;
|
||||
s->best3[s->bp] = SWD_F + 1;
|
||||
s->llen3[key]++;
|
||||
@@ -265,7 +265,7 @@ static void swd_accept(lzo_swd_p s, unsigned n)
|
||||
|
||||
#ifdef HEAD2
|
||||
/* add bp into HEAD2 */
|
||||
key = HEAD2(s->b,s->bp);
|
||||
key = HEAD2(s->b, s->bp);
|
||||
s->head2[key] = s->bp;
|
||||
#endif
|
||||
|
||||
@@ -298,18 +298,19 @@ static void swd_search(lzo_swd_p s, unsigned node, unsigned cnt)
|
||||
|
||||
assert(m_len < s->look);
|
||||
|
||||
if (p2[m_len - 1] == scan_end1 &&
|
||||
p2[m_len] == p1[m_len] &&
|
||||
p2[0] == p1[0] &&
|
||||
p2[1] == p1[1]) {
|
||||
if (p2[m_len - 1] == scan_end1
|
||||
&& p2[m_len] == p1[m_len]
|
||||
&& p2[0] == p1[0]
|
||||
&& p2[1] == p1[1]
|
||||
) {
|
||||
unsigned i;
|
||||
assert(lzo_memcmp(bp,&b[node],3) == 0);
|
||||
assert(lzo_memcmp(bp, &b[node], 3) == 0);
|
||||
|
||||
p1 += 2; p2 += 2;
|
||||
do {} while (++p1 < px && *p1 == *++p2);
|
||||
i = p1-bp;
|
||||
|
||||
assert(lzo_memcmp(bp,&b[node],i) == 0);
|
||||
assert(lzo_memcmp(bp, &b[node], i) == 0);
|
||||
|
||||
#if defined(SWD_BEST_OFF)
|
||||
if (i < SWD_BEST_OFF) {
|
||||
@@ -345,10 +346,10 @@ static int swd_search2(lzo_swd_p s)
|
||||
assert(s->look >= 2);
|
||||
assert(s->m_len > 0);
|
||||
|
||||
key = s->head2[ HEAD2(s->b,s->bp) ];
|
||||
key = s->head2[HEAD2(s->b, s->bp)];
|
||||
if (key == NIL2)
|
||||
return 0;
|
||||
assert(lzo_memcmp(&s->b[s->bp],&s->b[key],2) == 0);
|
||||
assert(lzo_memcmp(&s->b[s->bp], &s->b[key], 2) == 0);
|
||||
#if defined(SWD_BEST_OFF)
|
||||
if (s->best_pos[2] == 0)
|
||||
s->best_pos[2] = key + 1;
|
||||
@@ -377,7 +378,7 @@ static void swd_findbest(lzo_swd_p s)
|
||||
|
||||
/* get current head, add bp into HEAD3 */
|
||||
key = HEAD3(s->b,s->bp);
|
||||
node = s->succ3[s->bp] = s_get_head3(s,key);
|
||||
node = s->succ3[s->bp] = s_get_head3(s, key);
|
||||
cnt = s->llen3[key]++;
|
||||
assert(s->llen3[key] <= SWD_N + SWD_F);
|
||||
if (cnt > s->max_chain)
|
||||
@@ -396,7 +397,7 @@ static void swd_findbest(lzo_swd_p s)
|
||||
if (swd_search2(s))
|
||||
#endif
|
||||
if (s->look >= 3)
|
||||
swd_search(s,node,cnt);
|
||||
swd_search(s, node, cnt);
|
||||
if (s->m_len > len)
|
||||
s->m_off = swd_pos2off(s,s->m_pos);
|
||||
s->best3[s->bp] = s->m_len;
|
||||
@@ -404,11 +405,12 @@ static void swd_findbest(lzo_swd_p s)
|
||||
#if defined(SWD_BEST_OFF)
|
||||
if (s->use_best_off) {
|
||||
int i;
|
||||
for (i = 2; i < SWD_BEST_OFF; i++)
|
||||
for (i = 2; i < SWD_BEST_OFF; i++) {
|
||||
if (s->best_pos[i] > 0)
|
||||
s->best_off[i] = swd_pos2off(s,s->best_pos[i]-1);
|
||||
s->best_off[i] = swd_pos2off(s, s->best_pos[i]-1);
|
||||
else
|
||||
s->best_off[i] = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -417,7 +419,7 @@ static void swd_findbest(lzo_swd_p s)
|
||||
|
||||
#ifdef HEAD2
|
||||
/* add bp into HEAD2 */
|
||||
key = HEAD2(s->b,s->bp);
|
||||
key = HEAD2(s->b, s->bp);
|
||||
s->head2[key] = s->bp;
|
||||
#endif
|
||||
}
|
||||
@@ -467,7 +469,7 @@ static int find_match(lzo1x_999_t *c, lzo_swd_p s,
|
||||
s->m_len = 1;
|
||||
#ifdef SWD_BEST_OFF
|
||||
if (s->use_best_off)
|
||||
memset(s->best_pos,0,sizeof(s->best_pos));
|
||||
memset(s->best_pos, 0, sizeof(s->best_pos));
|
||||
#endif
|
||||
swd_findbest(s);
|
||||
c->m_len = s->m_len;
|
||||
@@ -505,7 +507,8 @@ static uint8_t *code_match(lzo1x_999_t *c,
|
||||
assert(op > c->out);
|
||||
if (m_len == 2) {
|
||||
assert(m_off <= M1_MAX_OFFSET);
|
||||
assert(c->r1_lit > 0); assert(c->r1_lit < 4);
|
||||
assert(c->r1_lit > 0);
|
||||
assert(c->r1_lit < 4);
|
||||
m_off -= 1;
|
||||
*op++ = M1_MARKER | ((m_off & 3) << 2);
|
||||
*op++ = m_off >> 2;
|
||||
@@ -529,11 +532,10 @@ static uint8_t *code_match(lzo1x_999_t *c,
|
||||
else {
|
||||
m_len -= M3_MAX_LEN;
|
||||
*op++ = M3_MARKER | 0;
|
||||
while (m_len > 255)
|
||||
{
|
||||
m_len -= 255;
|
||||
*op++ = 0;
|
||||
}
|
||||
while (m_len > 255) {
|
||||
m_len -= 255;
|
||||
*op++ = 0;
|
||||
}
|
||||
assert(m_len > 0);
|
||||
*op++ = m_len;
|
||||
}
|
||||
@@ -543,7 +545,8 @@ static uint8_t *code_match(lzo1x_999_t *c,
|
||||
unsigned k;
|
||||
|
||||
assert(m_len >= 3);
|
||||
assert(m_off > 0x4000); assert(m_off <= 0xbfff);
|
||||
assert(m_off > 0x4000);
|
||||
assert(m_off <= 0xbfff);
|
||||
m_off -= 0x4000;
|
||||
k = (m_off & 0x4000) >> 11;
|
||||
if (m_len <= M4_MAX_LEN)
|
||||
@@ -551,11 +554,10 @@ static uint8_t *code_match(lzo1x_999_t *c,
|
||||
else {
|
||||
m_len -= M4_MAX_LEN;
|
||||
*op++ = M4_MARKER | k | 0;
|
||||
while (m_len > 255)
|
||||
{
|
||||
m_len -= 255;
|
||||
*op++ = 0;
|
||||
}
|
||||
while (m_len > 255) {
|
||||
m_len -= 255;
|
||||
*op++ = 0;
|
||||
}
|
||||
assert(m_len > 0);
|
||||
*op++ = m_len;
|
||||
}
|
||||
@@ -598,7 +600,7 @@ static uint8_t *code_run(lzo1x_999_t *c, uint8_t *op, const uint8_t *ii,
|
||||
{
|
||||
if (lit > 0) {
|
||||
assert(m_len >= 2);
|
||||
op = STORE_RUN(c,op,ii,lit);
|
||||
op = STORE_RUN(c, op, ii, lit);
|
||||
} else {
|
||||
assert(m_len >= 3);
|
||||
}
|
||||
@@ -681,32 +683,32 @@ static void better_match(const lzo_swd_p swd,
|
||||
return;
|
||||
|
||||
/* M3/M4 -> M2 */
|
||||
if (*m_off > M2_MAX_OFFSET &&
|
||||
*m_len >= M2_MIN_LEN + 1 && *m_len <= M2_MAX_LEN + 1 &&
|
||||
swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= M2_MAX_OFFSET)
|
||||
{
|
||||
*m_len = *m_len - 1;
|
||||
*m_off = swd->best_off[*m_len];
|
||||
return;
|
||||
}
|
||||
if (*m_off > M2_MAX_OFFSET
|
||||
&& *m_len >= M2_MIN_LEN + 1 && *m_len <= M2_MAX_LEN + 1
|
||||
&& swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= M2_MAX_OFFSET
|
||||
) {
|
||||
*m_len = *m_len - 1;
|
||||
*m_off = swd->best_off[*m_len];
|
||||
return;
|
||||
}
|
||||
|
||||
/* M4 -> M2 */
|
||||
if (*m_off > M3_MAX_OFFSET &&
|
||||
*m_len >= M4_MAX_LEN + 1 && *m_len <= M2_MAX_LEN + 2 &&
|
||||
swd->best_off[*m_len-2] && swd->best_off[*m_len-2] <= M2_MAX_OFFSET)
|
||||
{
|
||||
*m_len = *m_len - 2;
|
||||
*m_off = swd->best_off[*m_len];
|
||||
return;
|
||||
}
|
||||
if (*m_off > M3_MAX_OFFSET
|
||||
&& *m_len >= M4_MAX_LEN + 1 && *m_len <= M2_MAX_LEN + 2
|
||||
&& swd->best_off[*m_len-2] && swd->best_off[*m_len-2] <= M2_MAX_OFFSET
|
||||
) {
|
||||
*m_len = *m_len - 2;
|
||||
*m_off = swd->best_off[*m_len];
|
||||
return;
|
||||
}
|
||||
/* M4 -> M3 */
|
||||
if (*m_off > M3_MAX_OFFSET &&
|
||||
*m_len >= M4_MAX_LEN + 1 && *m_len <= M3_MAX_LEN + 1 &&
|
||||
swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= M3_MAX_OFFSET)
|
||||
{
|
||||
*m_len = *m_len - 1;
|
||||
*m_off = swd->best_off[*m_len];
|
||||
}
|
||||
if (*m_off > M3_MAX_OFFSET
|
||||
&& *m_len >= M4_MAX_LEN + 1 && *m_len <= M3_MAX_LEN + 1
|
||||
&& swd->best_off[*m_len-1] && swd->best_off[*m_len-1] <= M3_MAX_OFFSET
|
||||
) {
|
||||
*m_len = *m_len - 1;
|
||||
*m_off = swd->best_off[*m_len];
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -728,8 +730,8 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len,
|
||||
unsigned lit;
|
||||
unsigned m_len, m_off;
|
||||
lzo1x_999_t cc;
|
||||
lzo1x_999_t * const c = &cc;
|
||||
lzo_swd_p const swd = (lzo_swd_p) wrkmem;
|
||||
lzo1x_999_t *const c = &cc;
|
||||
const lzo_swd_p swd = (lzo_swd_p) wrkmem;
|
||||
int r;
|
||||
|
||||
c->init = 0;
|
||||
@@ -766,18 +768,18 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len,
|
||||
assert(ii + lit == c->bp);
|
||||
assert(swd->b_char == *(c->bp));
|
||||
|
||||
if ( m_len < 2 ||
|
||||
(m_len == 2 && (m_off > M1_MAX_OFFSET || lit == 0 || lit >= 4)) ||
|
||||
/* Do not accept this match for compressed-data compatibility
|
||||
* with LZO v1.01 and before
|
||||
* [ might be a problem for decompress() and optimize() ]
|
||||
*/
|
||||
(m_len == 2 && op == out) ||
|
||||
(op == out && lit == 0))
|
||||
{
|
||||
/* a literal */
|
||||
m_len = 0;
|
||||
}
|
||||
if (m_len < 2
|
||||
|| (m_len == 2 && (m_off > M1_MAX_OFFSET || lit == 0 || lit >= 4))
|
||||
/* Do not accept this match for compressed-data compatibility
|
||||
* with LZO v1.01 and before
|
||||
* [ might be a problem for decompress() and optimize() ]
|
||||
*/
|
||||
|| (m_len == 2 && op == out)
|
||||
|| (op == out && lit == 0)
|
||||
) {
|
||||
/* a literal */
|
||||
m_len = 0;
|
||||
}
|
||||
else if (m_len == M2_MIN_LEN) {
|
||||
/* compression ratio improves if we code a literal in some cases */
|
||||
if (m_off > MX_MAX_OFFSET && lit >= 4)
|
||||
@@ -788,7 +790,7 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len,
|
||||
/* a literal */
|
||||
lit++;
|
||||
swd->max_chain = max_chain;
|
||||
r = find_match(c,swd,1,0);
|
||||
r = find_match(c, swd, 1, 0);
|
||||
assert(r == 0);
|
||||
continue;
|
||||
}
|
||||
@@ -796,7 +798,7 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len,
|
||||
/* a match */
|
||||
#if defined(SWD_BEST_OFF)
|
||||
if (swd->use_best_off)
|
||||
better_match(swd,&m_len,&m_off);
|
||||
better_match(swd, &m_len, &m_off);
|
||||
#endif
|
||||
|
||||
/* shall we try a lazy match ? */
|
||||
@@ -807,7 +809,7 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len,
|
||||
max_ahead = 0;
|
||||
} else {
|
||||
/* yes, try a lazy match */
|
||||
l1 = len_of_coded_match(m_len,m_off,lit);
|
||||
l1 = len_of_coded_match(m_len, m_off, lit);
|
||||
assert(l1 > 0);
|
||||
max_ahead = LZO_MIN(2, (unsigned)l1 - 1);
|
||||
}
|
||||
@@ -820,7 +822,7 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len,
|
||||
swd->max_chain = max_chain >> 2;
|
||||
else
|
||||
swd->max_chain = max_chain;
|
||||
r = find_match(c,swd,1,0);
|
||||
r = find_match(c, swd, 1, 0);
|
||||
ahead++;
|
||||
|
||||
assert(r == 0);
|
||||
@@ -833,23 +835,23 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len,
|
||||
continue;
|
||||
#if defined(SWD_BEST_OFF)
|
||||
if (swd->use_best_off)
|
||||
better_match(swd,&c->m_len,&c->m_off);
|
||||
better_match(swd, &c->m_len, &c->m_off);
|
||||
#endif
|
||||
l2 = len_of_coded_match(c->m_len,c->m_off,lit+ahead);
|
||||
l2 = len_of_coded_match(c->m_len, c->m_off, lit+ahead);
|
||||
if (l2 < 0)
|
||||
continue;
|
||||
|
||||
/* compressed-data compatibility [see above] */
|
||||
l3 = (op == out) ? -1 : len_of_coded_match(ahead,m_off,lit);
|
||||
l3 = (op == out) ? -1 : len_of_coded_match(ahead, m_off, lit);
|
||||
|
||||
lazy_match_min_gain = min_gain(ahead,lit,lit+ahead,l1,l2,l3);
|
||||
lazy_match_min_gain = min_gain(ahead, lit, lit+ahead, l1, l2, l3);
|
||||
if (c->m_len >= m_len + lazy_match_min_gain) {
|
||||
if (l3 > 0) {
|
||||
/* code previous run */
|
||||
op = code_run(c,op,ii,lit);
|
||||
op = code_run(c, op, ii, lit);
|
||||
lit = 0;
|
||||
/* code shortened match */
|
||||
op = code_match(c,op,ahead,m_off);
|
||||
op = code_match(c, op, ahead, m_off);
|
||||
} else {
|
||||
lit += ahead;
|
||||
assert(ii + lit == c->bp);
|
||||
@@ -861,13 +863,13 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len,
|
||||
assert(ii + lit + ahead == c->bp);
|
||||
|
||||
/* 1 - code run */
|
||||
op = code_run(c,op,ii,lit);
|
||||
op = code_run(c, op, ii, lit);
|
||||
lit = 0;
|
||||
|
||||
/* 2 - code match */
|
||||
op = code_match(c,op,m_len,m_off);
|
||||
op = code_match(c, op, m_len, m_off);
|
||||
swd->max_chain = max_chain;
|
||||
r = find_match(c,swd,m_len,1+ahead);
|
||||
r = find_match(c, swd, m_len, 1+ahead);
|
||||
assert(r == 0);
|
||||
|
||||
lazy_match_done: ;
|
||||
@@ -875,7 +877,7 @@ static int lzo1x_999_compress_internal(const uint8_t *in, unsigned in_len,
|
||||
|
||||
/* store final run */
|
||||
if (lit > 0)
|
||||
op = STORE_RUN(c,op,ii,lit);
|
||||
op = STORE_RUN(c, op, ii, lit);
|
||||
|
||||
#if defined(LZO_EOF_CODE)
|
||||
*op++ = M4_MARKER | 1;
|
||||
|
||||
+14
-11
@@ -166,9 +166,12 @@ static NOINLINE int lzo1x_optimize(uint8_t *in, unsigned in_len,
|
||||
o_m1_a++;
|
||||
}
|
||||
/* test if a literal run follows */
|
||||
else if (nl == 0 && ip[0] < 16 && ip[0] != 0 &&
|
||||
(lit + 2 + ip[0] < 16))
|
||||
{
|
||||
else
|
||||
if (nl == 0
|
||||
&& ip[0] < 16
|
||||
&& ip[0] != 0
|
||||
&& (lit + 2 + ip[0] < 16)
|
||||
) {
|
||||
t = *ip++;
|
||||
/* remove short run */
|
||||
*litp &= ~3;
|
||||
@@ -393,7 +396,7 @@ struct globals {
|
||||
const uint32_t *lzo_crc32_table;
|
||||
chksum_t chksum_in;
|
||||
chksum_t chksum_out;
|
||||
};
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define INIT_G() do { } while (0)
|
||||
//#define G (*ptr_to_globals)
|
||||
@@ -472,7 +475,7 @@ lzo_crc32(uint32_t c, const uint8_t* buf, unsigned len)
|
||||
|
||||
crc = ~c;
|
||||
if (len != 0) do {
|
||||
crc = G.lzo_crc32_table[((int)crc ^ *buf) & 0xff] ^ (crc >> 8);
|
||||
crc = G.lzo_crc32_table[(uint8_t)((int)crc ^ *buf)] ^ (crc >> 8);
|
||||
buf += 1;
|
||||
len -= 1;
|
||||
} while (len > 0);
|
||||
@@ -735,12 +738,12 @@ static NOINLINE smallint lzo_decompress(const header_t *h)
|
||||
bb_error_msg_and_die("this file is a split lzop file");
|
||||
|
||||
if (dst_len > MAX_BLOCK_SIZE)
|
||||
bb_error_msg_and_die("lzop file corrupted");
|
||||
bb_error_msg_and_die("corrupted data");
|
||||
|
||||
/* read compressed block size */
|
||||
src_len = read32();
|
||||
if (src_len <= 0 || src_len > dst_len)
|
||||
bb_error_msg_and_die("lzop file corrupted");
|
||||
bb_error_msg_and_die("corrupted data");
|
||||
|
||||
if (dst_len > block_size) {
|
||||
if (b2) {
|
||||
@@ -794,7 +797,7 @@ static NOINLINE smallint lzo_decompress(const header_t *h)
|
||||
r = lzo1x_decompress_safe(b1, src_len, b2, &d, NULL);
|
||||
|
||||
if (r != 0 /*LZO_E_OK*/ || dst_len != d) {
|
||||
bb_error_msg_and_die("corrupted compressed data");
|
||||
bb_error_msg_and_die("corrupted data");
|
||||
}
|
||||
dst = b2;
|
||||
} else {
|
||||
@@ -1039,7 +1042,7 @@ static smallint do_lzo_decompress(void)
|
||||
return lzo_decompress(&header);
|
||||
}
|
||||
|
||||
static char* make_new_name_lzop(char *filename)
|
||||
static char* FAST_FUNC make_new_name_lzop(char *filename, const char *expected_ext UNUSED_PARAM)
|
||||
{
|
||||
if (option_mask32 & OPT_DECOMPRESS) {
|
||||
char *extension = strrchr(filename, '.');
|
||||
@@ -1051,7 +1054,7 @@ static char* make_new_name_lzop(char *filename)
|
||||
return xasprintf("%s.lzo", filename);
|
||||
}
|
||||
|
||||
static IF_DESKTOP(long long) int pack_lzop(unpack_info_t *info UNUSED_PARAM)
|
||||
static IF_DESKTOP(long long) int FAST_FUNC pack_lzop(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
if (option_mask32 & OPT_DECOMPRESS)
|
||||
return do_lzo_decompress();
|
||||
@@ -1071,5 +1074,5 @@ int lzop_main(int argc UNUSED_PARAM, char **argv)
|
||||
option_mask32 |= OPT_DECOMPRESS;
|
||||
|
||||
G.lzo_crc32_table = crc32_filltable(NULL, 0);
|
||||
return bbunpack(argv, make_new_name_lzop, pack_lzop);
|
||||
return bbunpack(argv, pack_lzop, make_new_name_lzop, /*unused:*/ NULL);
|
||||
}
|
||||
+44
-71
@@ -9,8 +9,8 @@
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
#include "rpm.h"
|
||||
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
#define RPM_CHAR_TYPE 1
|
||||
#define RPM_INT8_TYPE 2
|
||||
#define RPM_INT16_TYPE 3
|
||||
@@ -46,6 +46,7 @@
|
||||
#define TAG_DIRINDEXES 1116
|
||||
#define TAG_BASENAMES 1117
|
||||
#define TAG_DIRNAMES 1118
|
||||
|
||||
#define RPMFILE_CONFIG (1 << 0)
|
||||
#define RPMFILE_DOC (1 << 1)
|
||||
|
||||
@@ -70,7 +71,7 @@ static void *map;
|
||||
static rpm_index **mytags;
|
||||
static int tagcount;
|
||||
|
||||
static void extract_cpio_gz(int fd);
|
||||
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);
|
||||
@@ -121,6 +122,8 @@ int rpm_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
while (*argv) {
|
||||
const char *source_rpm;
|
||||
|
||||
rpm_fd = xopen(*argv++, O_RDONLY);
|
||||
mytags = rpm_gettags(rpm_fd, &tagcount);
|
||||
if (!mytags)
|
||||
@@ -129,11 +132,13 @@ int rpm_main(int argc, char **argv)
|
||||
/* 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_gz(rpm_fd);
|
||||
extract_cpio(rpm_fd, source_rpm);
|
||||
/* Set the correct file uid/gid's */
|
||||
loop_through_files(TAG_BASENAMES, fileaction_setowngrp);
|
||||
}
|
||||
@@ -147,14 +152,20 @@ int rpm_main(int argc, char **argv)
|
||||
time_t bdate_time;
|
||||
struct tm *bdate_ptm;
|
||||
char bdatestring[50];
|
||||
printf("Name : %-29sRelocations: %s\n", rpm_getstr(TAG_NAME, 0), rpm_getstr(TAG_PREFIXS, 0) ? rpm_getstr(TAG_PREFIXS, 0) : "(not relocateable)");
|
||||
printf("Version : %-34sVendor: %s\n", rpm_getstr(TAG_VERSION, 0), rpm_getstr(TAG_VENDOR, 0) ? rpm_getstr(TAG_VENDOR, 0) : "(none)");
|
||||
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), rpm_getstr(TAG_SOURCERPM, 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));
|
||||
@@ -187,23 +198,23 @@ int rpm_main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void extract_cpio_gz(int fd)
|
||||
static void extract_cpio(int fd, const char *source_rpm)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned char magic[2];
|
||||
#if BB_MMU
|
||||
IF_DESKTOP(long long) int FAST_FUNC (*xformer)(int src_fd, int dst_fd);
|
||||
enum { xformer_prog = 0 };
|
||||
#else
|
||||
enum { xformer = 0 };
|
||||
const char *xformer_prog;
|
||||
#endif
|
||||
|
||||
if (source_rpm != NULL) {
|
||||
/* Binary rpm (it was built from some SRPM), install to root */
|
||||
xchdir("/");
|
||||
} /* else: SRPM, install to current dir */
|
||||
|
||||
/* Initialize */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->seek = seek_by_read;
|
||||
//archive_handle->action_header = header_list;
|
||||
archive_handle->action_data = data_extract_all;
|
||||
#if 0 /* For testing (rpm -i only lists the files in internal cpio): */
|
||||
archive_handle->action_header = header_list;
|
||||
archive_handle->action_data = data_skip;
|
||||
#endif
|
||||
archive_handle->ah_flags = ARCHIVE_RESTORE_DATE | ARCHIVE_CREATE_LEADING_DIRS
|
||||
/* compat: overwrite existing files.
|
||||
* try "rpm -i foo.src.rpm" few times in a row -
|
||||
@@ -213,46 +224,14 @@ static void extract_cpio_gz(int fd)
|
||||
archive_handle->src_fd = fd;
|
||||
/*archive_handle->offset = 0; - init_handle() did it */
|
||||
|
||||
// TODO: open_zipped does the same
|
||||
|
||||
xread(archive_handle->src_fd, &magic, 2);
|
||||
#if BB_MMU
|
||||
xformer = unpack_gz_stream;
|
||||
#else
|
||||
xformer_prog = "gunzip";
|
||||
#endif
|
||||
if (magic[0] != 0x1f || magic[1] != 0x8b) {
|
||||
if (!ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
|| magic[0] != 'B' || magic[1] != 'Z'
|
||||
) {
|
||||
bb_error_msg_and_die("no gzip"
|
||||
IF_FEATURE_SEAMLESS_BZ2("/bzip2")
|
||||
" magic");
|
||||
}
|
||||
#if BB_MMU
|
||||
xformer = unpack_bz2_stream;
|
||||
#else
|
||||
xformer_prog = "bunzip2";
|
||||
#endif
|
||||
} else {
|
||||
#if !BB_MMU
|
||||
/* NOMMU version of open_transformer execs an external unzipper that should
|
||||
* have the file position at the start of the file */
|
||||
xlseek(archive_handle->src_fd, 0, SEEK_SET);
|
||||
#endif
|
||||
}
|
||||
|
||||
xchdir("/"); /* Install RPM's to root */
|
||||
open_transformer(archive_handle->src_fd, xformer, xformer_prog);
|
||||
archive_handle->offset = 0;
|
||||
setup_unzip_on_fd(archive_handle->src_fd /*, fail_if_not_detected: 1*/);
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
static rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
{
|
||||
/* We should never need mode than 200, and realloc later */
|
||||
/* We should never need more than 200 (shrink via realloc later) */
|
||||
rpm_index **tags = xzalloc(200 * sizeof(tags[0]));
|
||||
int pass, tagindex = 0;
|
||||
|
||||
@@ -260,27 +239,16 @@ static rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
|
||||
/* 1st pass is the signature headers, 2nd is the main stuff */
|
||||
for (pass = 0; pass < 2; pass++) {
|
||||
struct {
|
||||
char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */
|
||||
uint8_t version; /* 1 byte version number */
|
||||
uint32_t reserved; /* 4 bytes reserved */
|
||||
uint32_t entries; /* Number of entries in header (4 bytes) */
|
||||
uint32_t size; /* Size of store (4 bytes) */
|
||||
} header;
|
||||
struct BUG_header {
|
||||
char BUG_header[sizeof(header) == 16 ? 1 : -1];
|
||||
};
|
||||
struct rpm_header header;
|
||||
rpm_index *tmpindex;
|
||||
int storepos;
|
||||
|
||||
xread(fd, &header, sizeof(header));
|
||||
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0)
|
||||
return NULL; /* Invalid magic */
|
||||
if (header.version != 1)
|
||||
return NULL; /* This program only supports v1 headers */
|
||||
if (header.magic_and_ver != htonl(RPM_HEADER_MAGICnVER))
|
||||
return NULL; /* Invalid magic, or not version 1 */
|
||||
header.size = ntohl(header.size);
|
||||
header.entries = ntohl(header.entries);
|
||||
storepos = xlseek(fd,0,SEEK_CUR) + header.entries * 16;
|
||||
storepos = xlseek(fd, 0, SEEK_CUR) + header.entries * 16;
|
||||
|
||||
while (header.entries--) {
|
||||
tmpindex = tags[tagindex++] = xmalloc(sizeof(*tmpindex));
|
||||
@@ -292,14 +260,16 @@ static rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
if (pass == 0)
|
||||
tmpindex->tag -= 743;
|
||||
}
|
||||
xlseek(fd, header.size, SEEK_CUR); /* Seek past store */
|
||||
storepos = xlseek(fd, header.size, SEEK_CUR); /* Seek past store */
|
||||
/* Skip padding to 8 byte boundary after reading signature headers */
|
||||
if (pass == 0)
|
||||
xlseek(fd, (8 - (xlseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR);
|
||||
xlseek(fd, (-storepos) & 0x7, SEEK_CUR);
|
||||
}
|
||||
tags = xrealloc(tags, tagindex * sizeof(tags[0])); /* realloc tags to save space */
|
||||
/* realloc tags to save space */
|
||||
tags = xrealloc(tags, tagindex * sizeof(tags[0]));
|
||||
*num_tags = tagindex;
|
||||
return tags; /* All done, leave the file at the start of the gzipped cpio archive */
|
||||
/* All done, leave the file at the start of the gzipped cpio archive */
|
||||
return tags;
|
||||
}
|
||||
|
||||
static int bsearch_rpmtag(const void *key, const void *item)
|
||||
@@ -324,10 +294,13 @@ static char *rpm_getstr(int tag, int itemindex)
|
||||
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found[0]->count)
|
||||
return NULL;
|
||||
if (found[0]->type == RPM_STRING_TYPE || found[0]->type == RPM_I18NSTRING_TYPE || found[0]->type == RPM_STRING_ARRAY_TYPE) {
|
||||
if (found[0]->type == RPM_STRING_TYPE
|
||||
|| found[0]->type == RPM_I18NSTRING_TYPE
|
||||
|| found[0]->type == RPM_STRING_ARRAY_TYPE
|
||||
) {
|
||||
int n;
|
||||
char *tmpstr = (char *) map + found[0]->offset;
|
||||
for (n=0; n < itemindex; n++)
|
||||
for (n = 0; n < itemindex; n++)
|
||||
tmpstr = tmpstr + strlen(tmpstr) + 1;
|
||||
return tmpstr;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* RPM structs and consts
|
||||
*
|
||||
* Copyright (C) 2001 by Laurence Anderson
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
/* RPM file starts with this struct: */
|
||||
struct rpm_lead {
|
||||
uint32_t magic;
|
||||
uint8_t major, minor;
|
||||
uint16_t type;
|
||||
uint16_t archnum;
|
||||
char name[66];
|
||||
uint16_t osnum;
|
||||
uint16_t signature_type;
|
||||
char reserved[16];
|
||||
};
|
||||
struct BUG_rpm_lead {
|
||||
char bug[sizeof(struct rpm_lead) == 96 ? 1 : -1];
|
||||
};
|
||||
#define RPM_LEAD_MAGIC 0xedabeedb
|
||||
#define RPM_LEAD_MAGIC_STR "\355\253\356\333"
|
||||
|
||||
/* Then follows the header: */
|
||||
struct rpm_header {
|
||||
uint32_t magic_and_ver; /* 3 byte magic: 0x8e 0xad 0xe8; 1 byte version: 0x01 */
|
||||
uint32_t reserved; /* 4 bytes reserved */
|
||||
uint32_t entries; /* Number of entries in header (4 bytes) */
|
||||
uint32_t size; /* Size of store (4 bytes) */
|
||||
};
|
||||
struct BUG_rpm_header {
|
||||
char bug[sizeof(struct rpm_header) == 16 ? 1 : -1];
|
||||
};
|
||||
#define RPM_HEADER_MAGICnVER 0x8eade801
|
||||
#define RPM_HEADER_MAGIC_STR "\216\255\350"
|
||||
+42
-39
@@ -8,30 +8,7 @@
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define RPM_MAGIC 0xedabeedb
|
||||
#define RPM_MAGIC_STR "\355\253\356\333"
|
||||
|
||||
struct rpm_lead {
|
||||
uint32_t magic;
|
||||
uint8_t major, minor;
|
||||
uint16_t type;
|
||||
uint16_t archnum;
|
||||
char name[66];
|
||||
uint16_t osnum;
|
||||
uint16_t signature_type;
|
||||
char reserved[16];
|
||||
};
|
||||
|
||||
#define RPM_HEADER_MAGICnVER 0x8eade801
|
||||
#define RPM_HEADER_MAGIC_STR "\216\255\350"
|
||||
|
||||
struct rpm_header {
|
||||
uint32_t magic_and_ver; /* 3 byte magic: 0x8e 0xad 0xe8; 1 byte version */
|
||||
uint32_t reserved; /* 4 bytes reserved */
|
||||
uint32_t entries; /* Number of entries in header (4 bytes) */
|
||||
uint32_t size; /* Size of store (4 bytes) */
|
||||
};
|
||||
#include "rpm.h"
|
||||
|
||||
enum { rpm_fd = STDIN_FILENO };
|
||||
|
||||
@@ -65,8 +42,6 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
struct rpm_lead lead;
|
||||
unsigned pos;
|
||||
unsigned char magic[2];
|
||||
IF_DESKTOP(long long) int FAST_FUNC (*unpack)(int src_fd, int dst_fd);
|
||||
|
||||
if (argv[1]) {
|
||||
xmove_fd(xopen(argv[1], O_RDONLY), rpm_fd);
|
||||
@@ -74,33 +49,61 @@ int rpm2cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
xread(rpm_fd, &lead, sizeof(lead));
|
||||
|
||||
/* Just check the magic, the rest is irrelevant */
|
||||
if (lead.magic != htonl(RPM_MAGIC)) {
|
||||
if (lead.magic != htonl(RPM_LEAD_MAGIC)) {
|
||||
bb_error_msg_and_die("invalid RPM magic");
|
||||
}
|
||||
|
||||
/* Skip the signature header, align to 8 bytes */
|
||||
pos = skip_header();
|
||||
seek_by_jump(rpm_fd, (8 - pos) & 7);
|
||||
seek_by_jump(rpm_fd, (-(int)pos) & 7);
|
||||
|
||||
/* Skip the main header */
|
||||
skip_header();
|
||||
|
||||
xread(rpm_fd, &magic, 2);
|
||||
unpack = unpack_gz_stream;
|
||||
if (magic[0] != 0x1f || magic[1] != 0x8b) {
|
||||
if (!ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
|| magic[0] != 'B' || magic[1] != 'Z'
|
||||
#if 0
|
||||
/* This works, but doesn't report uncompress errors (they happen in child) */
|
||||
setup_unzip_on_fd(rpm_fd /*fail_if_not_detected: 1*/);
|
||||
if (bb_copyfd_eof(rpm_fd, STDOUT_FILENO) < 0)
|
||||
bb_error_msg_and_die("error unpacking");
|
||||
#else
|
||||
/* BLOAT */
|
||||
{
|
||||
union {
|
||||
uint8_t b[4];
|
||||
uint16_t b16[2];
|
||||
uint32_t b32[1];
|
||||
} magic;
|
||||
IF_DESKTOP(long long) int FAST_FUNC (*unpack)(int src_fd, int dst_fd);
|
||||
|
||||
xread(rpm_fd, magic.b16, sizeof(magic.b16[0]));
|
||||
if (magic.b16[0] == GZIP_MAGIC) {
|
||||
unpack = unpack_gz_stream;
|
||||
} else
|
||||
if (ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
&& magic.b16[0] == BZIP2_MAGIC
|
||||
) {
|
||||
bb_error_msg_and_die("invalid gzip"
|
||||
unpack = unpack_bz2_stream;
|
||||
} else
|
||||
if (ENABLE_FEATURE_SEAMLESS_XZ
|
||||
&& magic.b16[0] == XZ_MAGIC1
|
||||
) {
|
||||
xread(rpm_fd, magic.b32, sizeof(magic.b32[0]));
|
||||
if (magic.b32[0] != XZ_MAGIC2)
|
||||
goto no_magic;
|
||||
/* unpack_xz_stream wants fd at position 6, no need to seek */
|
||||
//xlseek(rpm_fd, -6, SEEK_CUR);
|
||||
unpack = unpack_xz_stream;
|
||||
} else {
|
||||
no_magic:
|
||||
bb_error_msg_and_die("no gzip"
|
||||
IF_FEATURE_SEAMLESS_BZ2("/bzip2")
|
||||
IF_FEATURE_SEAMLESS_XZ("/xz")
|
||||
" magic");
|
||||
}
|
||||
unpack = unpack_bz2_stream;
|
||||
}
|
||||
|
||||
if (unpack(rpm_fd, STDOUT_FILENO) < 0) {
|
||||
bb_error_msg_and_die("error unpacking");
|
||||
if (unpack(rpm_fd, STDOUT_FILENO) < 0)
|
||||
bb_error_msg_and_die("error unpacking");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(rpm_fd);
|
||||
|
||||
+79
-42
@@ -48,37 +48,6 @@
|
||||
|
||||
#if ENABLE_FEATURE_TAR_CREATE
|
||||
|
||||
/* Tar file constants */
|
||||
|
||||
#define TAR_BLOCK_SIZE 512
|
||||
|
||||
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
|
||||
#define NAME_SIZE 100
|
||||
#define NAME_SIZE_STR "100"
|
||||
typedef struct TarHeader { /* byte offset */
|
||||
char name[NAME_SIZE]; /* 0-99 */
|
||||
char mode[8]; /* 100-107 */
|
||||
char uid[8]; /* 108-115 */
|
||||
char gid[8]; /* 116-123 */
|
||||
char size[12]; /* 124-135 */
|
||||
char mtime[12]; /* 136-147 */
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char linkname[NAME_SIZE]; /* 157-256 */
|
||||
/* POSIX: "ustar" NUL "00" */
|
||||
/* GNU tar: "ustar " NUL */
|
||||
/* Normally it's defined as magic[6] followed by
|
||||
* version[2], but we put them together to save code.
|
||||
*/
|
||||
char magic[8]; /* 257-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char devmajor[8]; /* 329-336 */
|
||||
char devminor[8]; /* 337-344 */
|
||||
char prefix[155]; /* 345-499 */
|
||||
char padding[12]; /* 500-512 (pad to exactly TAR_BLOCK_SIZE) */
|
||||
} TarHeader;
|
||||
|
||||
/*
|
||||
** writeTarFile(), writeFileToTarball(), and writeTarHeader() are
|
||||
** the only functions that deal with the HardLinkInfo structure.
|
||||
@@ -193,7 +162,7 @@ static void putOctal(char *cp, int len, off_t value)
|
||||
}
|
||||
#define PUT_OCTAL(a, b) putOctal((a), sizeof(a), (b))
|
||||
|
||||
static void chksum_and_xwrite(int fd, struct TarHeader* hp)
|
||||
static void chksum_and_xwrite(int fd, struct tar_header_t* hp)
|
||||
{
|
||||
/* POSIX says that checksum is done on unsigned bytes
|
||||
* (Sun and HP-UX gets it wrong... more details in
|
||||
@@ -235,7 +204,7 @@ static void writeLongname(int fd, int type, const char *name, int dir)
|
||||
"00000000000",
|
||||
"00000000000",
|
||||
};
|
||||
struct TarHeader header;
|
||||
struct tar_header_t header;
|
||||
int size;
|
||||
|
||||
dir = !!dir; /* normalize: 0/1 */
|
||||
@@ -262,16 +231,12 @@ static void writeLongname(int fd, int type, const char *name, int dir)
|
||||
#endif
|
||||
|
||||
/* Write out a tar header for the specified file/directory/whatever */
|
||||
void BUG_tar_header_size(void);
|
||||
static int writeTarHeader(struct TarBallInfo *tbInfo,
|
||||
const char *header_name, const char *fileName, struct stat *statbuf)
|
||||
{
|
||||
struct TarHeader header;
|
||||
struct tar_header_t header;
|
||||
|
||||
if (sizeof(header) != 512)
|
||||
BUG_tar_header_size();
|
||||
|
||||
memset(&header, 0, sizeof(struct TarHeader));
|
||||
memset(&header, 0, sizeof(header));
|
||||
|
||||
strncpy(header.name, header_name, sizeof(header.name));
|
||||
|
||||
@@ -549,9 +514,7 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip)
|
||||
(void) &zip_exec;
|
||||
# endif
|
||||
|
||||
gzipPid = vfork();
|
||||
if (gzipPid < 0)
|
||||
bb_perror_msg_and_die("vfork");
|
||||
gzipPid = xvfork();
|
||||
|
||||
if (gzipPid == 0) {
|
||||
/* child */
|
||||
@@ -738,6 +701,68 @@ static void handle_SIGCHLD(int status)
|
||||
}
|
||||
#endif
|
||||
|
||||
//usage:#define tar_trivial_usage
|
||||
//usage: "-[" IF_FEATURE_TAR_CREATE("c") "xt" IF_FEATURE_SEAMLESS_GZ("z")
|
||||
//usage: IF_FEATURE_SEAMLESS_BZ2("j") IF_FEATURE_SEAMLESS_LZMA("a")
|
||||
//usage: IF_FEATURE_SEAMLESS_Z("Z") IF_FEATURE_TAR_NOPRESERVE_TIME("m") "vO] "
|
||||
//usage: IF_FEATURE_TAR_FROM("[-X FILE] ")
|
||||
//usage: "[-f TARFILE] [-C DIR] [FILE]..."
|
||||
//usage:#define tar_full_usage "\n\n"
|
||||
//usage: IF_FEATURE_TAR_CREATE("Create, extract, ")
|
||||
//usage: IF_NOT_FEATURE_TAR_CREATE("Extract ")
|
||||
//usage: "or list files from a tar file\n"
|
||||
//usage: "\nOperation:"
|
||||
//usage: IF_FEATURE_TAR_CREATE(
|
||||
//usage: "\n c Create"
|
||||
//usage: )
|
||||
//usage: "\n x Extract"
|
||||
//usage: "\n t List"
|
||||
//usage: "\nOptions:"
|
||||
//usage: "\n f Name of TARFILE ('-' for stdin/out)"
|
||||
//usage: "\n C Change to DIR before operation"
|
||||
//usage: "\n v Verbose"
|
||||
//usage: IF_FEATURE_SEAMLESS_GZ(
|
||||
//usage: "\n z (De)compress using gzip"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_SEAMLESS_BZ2(
|
||||
//usage: "\n j (De)compress using bzip2"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_SEAMLESS_LZMA(
|
||||
//usage: "\n a (De)compress using lzma"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_SEAMLESS_Z(
|
||||
//usage: "\n Z (De)compress using compress"
|
||||
//usage: )
|
||||
//usage: "\n O Extract to stdout"
|
||||
//usage: IF_FEATURE_TAR_CREATE(
|
||||
//usage: "\n h Follow symlinks"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_TAR_NOPRESERVE_TIME(
|
||||
//usage: "\n m Don't restore mtime"
|
||||
//usage: )
|
||||
//usage: IF_FEATURE_TAR_FROM(
|
||||
//usage: IF_FEATURE_TAR_LONG_OPTIONS(
|
||||
//usage: "\n exclude File to exclude"
|
||||
//usage: )
|
||||
//usage: "\n X File with names to exclude"
|
||||
//usage: "\n T File with names to include"
|
||||
//usage: )
|
||||
//usage:
|
||||
//usage:#define tar_example_usage
|
||||
//usage: "$ zcat /tmp/tarball.tar.gz | tar -xf -\n"
|
||||
//usage: "$ tar -cf /tmp/tarball.tar /usr/local\n"
|
||||
|
||||
// Supported but aren't in --help:
|
||||
// o no-same-owner
|
||||
// p same-permissions
|
||||
// k keep-old
|
||||
// numeric-owner
|
||||
// no-same-permissions
|
||||
// overwrite
|
||||
//IF_FEATURE_TAR_TO_COMMAND(
|
||||
// to-command
|
||||
//)
|
||||
|
||||
enum {
|
||||
OPTBIT_KEEP_OLD = 8,
|
||||
IF_FEATURE_TAR_CREATE( OPTBIT_CREATE ,)
|
||||
@@ -750,6 +775,7 @@ enum {
|
||||
IF_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,) // 16th bit
|
||||
IF_FEATURE_TAR_NOPRESERVE_TIME(OPTBIT_NOPRESERVE_TIME,)
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||
IF_FEATURE_TAR_TO_COMMAND(OPTBIT_2COMMAND ,)
|
||||
OPTBIT_NUMERIC_OWNER,
|
||||
OPTBIT_NOPRESERVE_PERM,
|
||||
OPTBIT_OVERWRITE,
|
||||
@@ -772,6 +798,7 @@ enum {
|
||||
OPT_GZIP = IF_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
|
||||
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_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
|
||||
@@ -812,6 +839,9 @@ static const char tar_longopts[] ALIGN1 =
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_NOPRESERVE_TIME
|
||||
"touch\0" No_argument "m"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_TO_COMMAND
|
||||
"to-command\0" Required_argument "\xfb"
|
||||
# endif
|
||||
/* use numeric uid/gid from tar header, not textual */
|
||||
"numeric-owner\0" No_argument "\xfc"
|
||||
@@ -904,6 +934,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
, &tar_filename // -f filename
|
||||
IF_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
|
||||
IF_FEATURE_TAR_FROM(, &(tar_handle->reject)) // X
|
||||
IF_FEATURE_TAR_TO_COMMAND(, &(tar_handle->tar__to_command)) // --to-command
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
|
||||
, &excludes // --exclude
|
||||
#endif
|
||||
@@ -922,6 +953,12 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (opt & OPT_2STDOUT)
|
||||
tar_handle->action_data = data_extract_to_stdout;
|
||||
|
||||
if (opt & OPT_2COMMAND) {
|
||||
putenv((char*)"TAR_FILETYPE=f");
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
tar_handle->action_data = data_extract_to_command;
|
||||
}
|
||||
|
||||
if (opt & OPT_KEEP_OLD)
|
||||
tar_handle->ah_flags &= ~ARCHIVE_UNLINK_OLD;
|
||||
|
||||
|
||||
+101
-64
@@ -25,12 +25,12 @@
|
||||
enum {
|
||||
#if BB_BIG_ENDIAN
|
||||
ZIP_FILEHEADER_MAGIC = 0x504b0304,
|
||||
ZIP_CDS_MAGIC = 0x504b0102,
|
||||
ZIP_CDE_MAGIC = 0x504b0506,
|
||||
ZIP_CDF_MAGIC = 0x504b0102, /* central directory's file header */
|
||||
ZIP_CDE_MAGIC = 0x504b0506, /* "end of central directory" record */
|
||||
ZIP_DD_MAGIC = 0x504b0708,
|
||||
#else
|
||||
ZIP_FILEHEADER_MAGIC = 0x04034b50,
|
||||
ZIP_CDS_MAGIC = 0x02014b50,
|
||||
ZIP_CDF_MAGIC = 0x02014b50,
|
||||
ZIP_CDE_MAGIC = 0x06054b50,
|
||||
ZIP_DD_MAGIC = 0x08074b50,
|
||||
#endif
|
||||
@@ -42,7 +42,7 @@ typedef union {
|
||||
uint8_t raw[ZIP_HEADER_LEN];
|
||||
struct {
|
||||
uint16_t version; /* 0-1 */
|
||||
uint16_t flags; /* 2-3 */
|
||||
uint16_t zip_flags; /* 2-3 */
|
||||
uint16_t method; /* 4-5 */
|
||||
uint16_t modtime; /* 6-7 */
|
||||
uint16_t moddate; /* 8-9 */
|
||||
@@ -66,7 +66,6 @@ struct BUG_zip_header_must_be_26_bytes {
|
||||
|
||||
#define FIX_ENDIANNESS_ZIP(zip_header) do { \
|
||||
(zip_header).formatted.version = SWAP_LE16((zip_header).formatted.version ); \
|
||||
(zip_header).formatted.flags = SWAP_LE16((zip_header).formatted.flags ); \
|
||||
(zip_header).formatted.method = SWAP_LE16((zip_header).formatted.method ); \
|
||||
(zip_header).formatted.modtime = SWAP_LE16((zip_header).formatted.modtime ); \
|
||||
(zip_header).formatted.moddate = SWAP_LE16((zip_header).formatted.moddate ); \
|
||||
@@ -77,15 +76,15 @@ struct BUG_zip_header_must_be_26_bytes {
|
||||
(zip_header).formatted.extra_len = SWAP_LE16((zip_header).formatted.extra_len ); \
|
||||
} while (0)
|
||||
|
||||
#define CDS_HEADER_LEN 42
|
||||
#define CDF_HEADER_LEN 42
|
||||
|
||||
typedef union {
|
||||
uint8_t raw[CDS_HEADER_LEN];
|
||||
uint8_t raw[CDF_HEADER_LEN];
|
||||
struct {
|
||||
/* uint32_t signature; 50 4b 01 02 */
|
||||
uint16_t version_made_by; /* 0-1 */
|
||||
uint16_t version_needed; /* 2-3 */
|
||||
uint16_t cds_flags; /* 4-5 */
|
||||
uint16_t cdf_flags; /* 4-5 */
|
||||
uint16_t method; /* 6-7 */
|
||||
uint16_t mtime; /* 8-9 */
|
||||
uint16_t mdate; /* 10-11 */
|
||||
@@ -100,21 +99,25 @@ typedef union {
|
||||
uint32_t external_file_attributes PACKED; /* 34-37 */
|
||||
uint32_t relative_offset_of_local_header PACKED; /* 38-41 */
|
||||
} formatted PACKED;
|
||||
} cds_header_t;
|
||||
} cdf_header_t;
|
||||
|
||||
struct BUG_cds_header_must_be_42_bytes {
|
||||
char BUG_cds_header_must_be_42_bytes[
|
||||
offsetof(cds_header_t, formatted.relative_offset_of_local_header) + 4
|
||||
== CDS_HEADER_LEN ? 1 : -1];
|
||||
struct BUG_cdf_header_must_be_42_bytes {
|
||||
char BUG_cdf_header_must_be_42_bytes[
|
||||
offsetof(cdf_header_t, formatted.relative_offset_of_local_header) + 4
|
||||
== CDF_HEADER_LEN ? 1 : -1];
|
||||
};
|
||||
|
||||
#define FIX_ENDIANNESS_CDS(cds_header) do { \
|
||||
(cds_header).formatted.crc32 = SWAP_LE32((cds_header).formatted.crc32 ); \
|
||||
(cds_header).formatted.cmpsize = SWAP_LE32((cds_header).formatted.cmpsize ); \
|
||||
(cds_header).formatted.ucmpsize = SWAP_LE32((cds_header).formatted.ucmpsize ); \
|
||||
(cds_header).formatted.file_name_length = SWAP_LE16((cds_header).formatted.file_name_length); \
|
||||
(cds_header).formatted.extra_field_length = SWAP_LE16((cds_header).formatted.extra_field_length); \
|
||||
(cds_header).formatted.file_comment_length = SWAP_LE16((cds_header).formatted.file_comment_length); \
|
||||
#define FIX_ENDIANNESS_CDF(cdf_header) do { \
|
||||
(cdf_header).formatted.crc32 = SWAP_LE32((cdf_header).formatted.crc32 ); \
|
||||
(cdf_header).formatted.cmpsize = SWAP_LE32((cdf_header).formatted.cmpsize ); \
|
||||
(cdf_header).formatted.ucmpsize = SWAP_LE32((cdf_header).formatted.ucmpsize ); \
|
||||
(cdf_header).formatted.file_name_length = SWAP_LE16((cdf_header).formatted.file_name_length); \
|
||||
(cdf_header).formatted.extra_field_length = SWAP_LE16((cdf_header).formatted.extra_field_length); \
|
||||
(cdf_header).formatted.file_comment_length = SWAP_LE16((cdf_header).formatted.file_comment_length); \
|
||||
IF_DESKTOP( \
|
||||
(cdf_header).formatted.version_made_by = SWAP_LE16((cdf_header).formatted.version_made_by); \
|
||||
(cdf_header).formatted.external_file_attributes = SWAP_LE32((cdf_header).formatted.external_file_attributes); \
|
||||
) \
|
||||
} while (0)
|
||||
|
||||
#define CDE_HEADER_LEN 16
|
||||
@@ -124,11 +127,11 @@ typedef union {
|
||||
struct {
|
||||
/* uint32_t signature; 50 4b 05 06 */
|
||||
uint16_t this_disk_no;
|
||||
uint16_t disk_with_cds_no;
|
||||
uint16_t cds_entries_on_this_disk;
|
||||
uint16_t cds_entries_total;
|
||||
uint32_t cds_size;
|
||||
uint32_t cds_offset;
|
||||
uint16_t disk_with_cdf_no;
|
||||
uint16_t cdf_entries_on_this_disk;
|
||||
uint16_t cdf_entries_total;
|
||||
uint32_t cdf_size;
|
||||
uint32_t cdf_offset;
|
||||
/* uint16_t file_comment_length; */
|
||||
/* .ZIP file comment (variable size) */
|
||||
} formatted PACKED;
|
||||
@@ -140,30 +143,33 @@ struct BUG_cde_header_must_be_16_bytes {
|
||||
};
|
||||
|
||||
#define FIX_ENDIANNESS_CDE(cde_header) do { \
|
||||
(cde_header).formatted.cds_offset = SWAP_LE32((cde_header).formatted.cds_offset); \
|
||||
(cde_header).formatted.cdf_offset = SWAP_LE32((cde_header).formatted.cdf_offset); \
|
||||
} while (0)
|
||||
|
||||
enum { zip_fd = 3 };
|
||||
|
||||
|
||||
#if ENABLE_DESKTOP
|
||||
|
||||
#define PEEK_FROM_END 16384
|
||||
|
||||
/* NB: does not preserve file position! */
|
||||
static uint32_t find_cds_offset(void)
|
||||
static uint32_t find_cdf_offset(void)
|
||||
{
|
||||
unsigned char buf[1024];
|
||||
cde_header_t cde_header;
|
||||
unsigned char *p;
|
||||
off_t end;
|
||||
unsigned char *buf = xzalloc(PEEK_FROM_END);
|
||||
|
||||
end = xlseek(zip_fd, 0, SEEK_END);
|
||||
if (end < 1024)
|
||||
end = 1024;
|
||||
end -= 1024;
|
||||
end -= PEEK_FROM_END;
|
||||
if (end < 0)
|
||||
end = 0;
|
||||
xlseek(zip_fd, end, SEEK_SET);
|
||||
full_read(zip_fd, buf, 1024);
|
||||
full_read(zip_fd, buf, PEEK_FROM_END);
|
||||
|
||||
p = buf;
|
||||
while (p <= buf + 1024 - CDE_HEADER_LEN - 4) {
|
||||
while (p <= buf + PEEK_FROM_END - CDE_HEADER_LEN - 4) {
|
||||
if (*p != 'P') {
|
||||
p++;
|
||||
continue;
|
||||
@@ -177,32 +183,32 @@ static uint32_t find_cds_offset(void)
|
||||
/* we found CDE! */
|
||||
memcpy(cde_header.raw, p + 1, CDE_HEADER_LEN);
|
||||
FIX_ENDIANNESS_CDE(cde_header);
|
||||
return cde_header.formatted.cds_offset;
|
||||
free(buf);
|
||||
return cde_header.formatted.cdf_offset;
|
||||
}
|
||||
//free(buf);
|
||||
bb_error_msg_and_die("can't find file table");
|
||||
};
|
||||
|
||||
static uint32_t read_next_cds(int count_m1, uint32_t cds_offset, cds_header_t *cds_ptr)
|
||||
static uint32_t read_next_cdf(uint32_t cdf_offset, cdf_header_t *cdf_ptr)
|
||||
{
|
||||
off_t org;
|
||||
|
||||
org = xlseek(zip_fd, 0, SEEK_CUR);
|
||||
|
||||
if (!cds_offset)
|
||||
cds_offset = find_cds_offset();
|
||||
if (!cdf_offset)
|
||||
cdf_offset = find_cdf_offset();
|
||||
|
||||
while (count_m1-- >= 0) {
|
||||
xlseek(zip_fd, cds_offset + 4, SEEK_SET);
|
||||
xread(zip_fd, cds_ptr->raw, CDS_HEADER_LEN);
|
||||
FIX_ENDIANNESS_CDS(*cds_ptr);
|
||||
cds_offset += 4 + CDS_HEADER_LEN
|
||||
+ cds_ptr->formatted.file_name_length
|
||||
+ cds_ptr->formatted.extra_field_length
|
||||
+ cds_ptr->formatted.file_comment_length;
|
||||
}
|
||||
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 cds_offset;
|
||||
return cdf_offset;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -258,8 +264,7 @@ int unzip_main(int argc, char **argv)
|
||||
smallint listing = 0;
|
||||
smallint overwrite = O_PROMPT;
|
||||
#if ENABLE_DESKTOP
|
||||
uint32_t cds_offset;
|
||||
unsigned cds_entries;
|
||||
uint32_t cdf_offset;
|
||||
#endif
|
||||
unsigned long total_usize;
|
||||
unsigned long total_size;
|
||||
@@ -435,20 +440,42 @@ int unzip_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
/* Example of an archive with one 0-byte long file named 'z'
|
||||
* created by Zip 2.31 on Unix:
|
||||
* 0000 [50 4b]03 04 0a 00 00 00 00 00 42 1a b8 3c 00 00 |PK........B..<..|
|
||||
* sig........ vneed flags compr mtime mdate crc32>
|
||||
* 0010 00 00 00 00 00 00 00 00 00 00 01 00 15 00 7a 55 |..............zU|
|
||||
* >..... csize...... usize...... fnlen exlen fn ex>
|
||||
* 0020 54 09 00 03 cc d3 f9 4b cc d3 f9 4b 55 78 04 00 |T......K...KUx..|
|
||||
* >tra_field......................................
|
||||
* 0030 00 00 00 00[50 4b]01 02 17 03 0a 00 00 00 00 00 |....PK..........|
|
||||
* ........... sig........ vmade vneed flags compr
|
||||
* 0040 42 1a b8 3c 00 00 00 00 00 00 00 00 00 00 00 00 |B..<............|
|
||||
* mtime mdate crc32...... csize...... usize......
|
||||
* 0050 01 00 0d 00 00 00 00 00 00 00 00 00 a4 81 00 00 |................|
|
||||
* fnlen exlen clen. dnum. iattr eattr...... relofs> (eattr = rw-r--r--)
|
||||
* 0060 00 00 7a 55 54 05 00 03 cc d3 f9 4b 55 78 00 00 |..zUT......KUx..|
|
||||
* >..... fn extra_field...........................
|
||||
* 0070 [50 4b]05 06 00 00 00 00 01 00 01 00 3c 00 00 00 |PK..........<...|
|
||||
* 0080 34 00 00 00 00 00 |4.....|
|
||||
*/
|
||||
total_usize = 0;
|
||||
total_size = 0;
|
||||
total_entries = 0;
|
||||
#if ENABLE_DESKTOP
|
||||
cds_entries = 0;
|
||||
cds_offset = 0;
|
||||
cdf_offset = 0;
|
||||
#endif
|
||||
while (1) {
|
||||
uint32_t magic;
|
||||
mode_t dir_mode = 0777;
|
||||
#if ENABLE_DESKTOP
|
||||
mode_t file_mode = 0666;
|
||||
#endif
|
||||
|
||||
/* Check magic number */
|
||||
xread(zip_fd, &magic, 4);
|
||||
/* Central directory? It's at the end, so exit */
|
||||
if (magic == ZIP_CDS_MAGIC)
|
||||
if (magic == ZIP_CDF_MAGIC)
|
||||
break;
|
||||
#if ENABLE_DESKTOP
|
||||
/* Data descriptor? It was a streaming file, go on */
|
||||
@@ -468,23 +495,29 @@ int unzip_main(int argc, char **argv)
|
||||
bb_error_msg_and_die("unsupported method %d", zip_header.formatted.method);
|
||||
}
|
||||
#if !ENABLE_DESKTOP
|
||||
if (zip_header.formatted.flags & 0x0009) {
|
||||
if (zip_header.formatted.zip_flags & SWAP_LE16(0x0009)) {
|
||||
bb_error_msg_and_die("zip flags 1 and 8 are not supported");
|
||||
}
|
||||
#else
|
||||
if (zip_header.formatted.flags & 0x0001) {
|
||||
if (zip_header.formatted.zip_flags & SWAP_LE16(0x0001)) {
|
||||
/* 0x0001 - encrypted */
|
||||
bb_error_msg_and_die("zip flag 1 (encryption) is not supported");
|
||||
}
|
||||
if (zip_header.formatted.flags & 0x0008) {
|
||||
cds_header_t cds_header;
|
||||
/* 0x0008 - streaming. [u]cmpsize can be reliably gotten
|
||||
* only from Central Directory. See unzip_doc.txt */
|
||||
cds_offset = read_next_cds(total_entries - cds_entries, cds_offset, &cds_header);
|
||||
cds_entries = total_entries + 1;
|
||||
zip_header.formatted.crc32 = cds_header.formatted.crc32;
|
||||
zip_header.formatted.cmpsize = cds_header.formatted.cmpsize;
|
||||
zip_header.formatted.ucmpsize = cds_header.formatted.ucmpsize;
|
||||
|
||||
{
|
||||
cdf_header_t cdf_header;
|
||||
cdf_offset = read_next_cdf(cdf_offset, &cdf_header);
|
||||
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 */
|
||||
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 */
|
||||
dir_mode = file_mode = (cdf_header.formatted.external_file_attributes >> 16);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -550,7 +583,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, 0777, 0)) {
|
||||
if (bb_make_directory(dst_fn, dir_mode, 0)) {
|
||||
bb_error_msg_and_die("exiting");
|
||||
}
|
||||
} else {
|
||||
@@ -592,7 +625,11 @@ int unzip_main(int argc, char **argv)
|
||||
overwrite = O_ALWAYS;
|
||||
case 'y': /* Open file and fall into unzip */
|
||||
unzip_create_leading_dirs(dst_fn);
|
||||
#if ENABLE_DESKTOP
|
||||
dst_fd = xopen3(dst_fn, O_WRONLY | O_CREAT | O_TRUNC, file_mode);
|
||||
#else
|
||||
dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC);
|
||||
#endif
|
||||
case -1: /* Unzip */
|
||||
if (!quiet) {
|
||||
printf(" inflating: %s\n", dst_fn);
|
||||
|
||||
Binary file not shown.
@@ -5,75 +5,83 @@
|
||||
|
||||
menu "Console Utilities"
|
||||
|
||||
INSERT
|
||||
|
||||
config CHVT
|
||||
bool "chvt"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program is used to change to another terminal.
|
||||
Example: chvt 4 (change to terminal /dev/tty4)
|
||||
|
||||
config FGCONSOLE
|
||||
bool "fgconsole"
|
||||
default y
|
||||
help
|
||||
This program prints active (foreground) console number.
|
||||
|
||||
config CLEAR
|
||||
bool "clear"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program clears the terminal screen.
|
||||
|
||||
config DEALLOCVT
|
||||
bool "deallocvt"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program deallocates unused virtual consoles.
|
||||
|
||||
config DUMPKMAP
|
||||
bool "dumpkmap"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program dumps the kernel's keyboard translation table to
|
||||
stdout, in binary format. You can then use loadkmap to load it.
|
||||
|
||||
config KBD_MODE
|
||||
bool "kbd_mode"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program reports and sets keyboard mode.
|
||||
|
||||
config LOADFONT
|
||||
bool "loadfont"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program loads a console font from standard input.
|
||||
|
||||
config LOADKMAP
|
||||
bool "loadkmap"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program loads a keyboard translation table from
|
||||
standard input.
|
||||
|
||||
config OPENVT
|
||||
bool "openvt"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program is used to start a command on an unused
|
||||
virtual terminal.
|
||||
|
||||
config RESET
|
||||
bool "reset"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program is used to reset the terminal screen, if it
|
||||
gets messed up.
|
||||
|
||||
config RESIZE
|
||||
bool "resize"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program is used to (re)set the width and height of your current
|
||||
terminal.
|
||||
|
||||
config FEATURE_RESIZE_PRINT
|
||||
bool "Print environment variables"
|
||||
default n
|
||||
default y
|
||||
depends on RESIZE
|
||||
help
|
||||
Prints the newly set size (number of columns and rows) of
|
||||
@@ -83,27 +91,27 @@ config FEATURE_RESIZE_PRINT
|
||||
|
||||
config SETCONSOLE
|
||||
bool "setconsole"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program redirects the system console to another device,
|
||||
like the current tty while logged in via telnet.
|
||||
|
||||
config FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
default y
|
||||
depends on SETCONSOLE && LONG_OPTS
|
||||
help
|
||||
Support long options for the setconsole applet.
|
||||
|
||||
config SETFONT
|
||||
bool "setfont"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Allows to load console screen map. Useful for i18n.
|
||||
|
||||
config FEATURE_SETFONT_TEXTUAL_MAP
|
||||
bool "Support reading textual screen maps"
|
||||
default n
|
||||
default y
|
||||
depends on SETFONT
|
||||
help
|
||||
Support reading textual screen maps.
|
||||
@@ -118,21 +126,38 @@ config DEFAULT_SETFONT_DIR
|
||||
|
||||
config SETKEYCODES
|
||||
bool "setkeycodes"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program loads entries into the kernel's scancode-to-keycode
|
||||
map, allowing unusual keyboards to generate usable keycodes.
|
||||
|
||||
config SETLOGCONS
|
||||
bool "setlogcons"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program redirects the output console of kernel messages.
|
||||
|
||||
config SHOWKEY
|
||||
bool "showkey"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Shows keys pressed.
|
||||
|
||||
comment "Common options for loadfont and setfont"
|
||||
depends on LOADFONT || SETFONT
|
||||
|
||||
config FEATURE_LOADFONT_PSF2
|
||||
bool "Support for PSF2 console fonts"
|
||||
default y
|
||||
depends on LOADFONT || SETFONT
|
||||
help
|
||||
Support PSF2 console fonts.
|
||||
|
||||
config FEATURE_LOADFONT_RAW
|
||||
bool "Support for old (raw) console fonts"
|
||||
default y
|
||||
depends on LOADFONT || SETFONT
|
||||
help
|
||||
Support old (raw) console fonts.
|
||||
|
||||
endmenu
|
||||
@@ -5,7 +5,10 @@
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
lib-y:=
|
||||
|
||||
INSERT
|
||||
lib-$(CONFIG_CHVT) += chvt.o
|
||||
lib-$(CONFIG_FGCONSOLE) += fgconsole.o
|
||||
lib-$(CONFIG_CLEAR) += clear.o
|
||||
lib-$(CONFIG_DEALLOCVT) += deallocvt.o
|
||||
lib-$(CONFIG_DUMPKMAP) += dumpkmap.o
|
||||
@@ -5,15 +5,12 @@
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
*/
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
return printf("\033[H\033[J") != 6;
|
||||
/* home; clear to the end of screen */
|
||||
return full_write1_str("\033[H""\033[J") != 6;
|
||||
}
|
||||
@@ -24,12 +24,17 @@ struct kbentry {
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int dumpkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int dumpkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
int dumpkmap_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
RESERVE_CONFIG_BUFFER(flags, MAX_NR_KEYMAPS);
|
||||
|
||||
/* When user accidentally runs "dumpkmap FILE"
|
||||
* instead of "dumpkmap >FILE", we'd dump binary stuff to tty.
|
||||
* Let's prevent it: */
|
||||
if (argv[1])
|
||||
bb_show_usage();
|
||||
/* bb_warn_ignoring_args(argv[1]);*/
|
||||
|
||||
fd = get_console_fd_or_die();
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini fgconsole implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2010 by Grigory Batalov <bga@altlinux.org>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
struct vt_stat {
|
||||
unsigned short v_active; /* active vt */
|
||||
unsigned short v_signal; /* signal to send */
|
||||
unsigned short v_state; /* vt bitmask */
|
||||
};
|
||||
enum { VT_GETSTATE = 0x5603 }; /* get global vt state info */
|
||||
|
||||
int fgconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int fgconsole_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
struct vt_stat vtstat;
|
||||
|
||||
vtstat.v_active = 0;
|
||||
xioctl(get_console_fd_or_die(), VT_GETSTATE, &vtstat);
|
||||
printf("%d\n", vtstat.v_active);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+206
-107
@@ -13,7 +13,7 @@
|
||||
#include <sys/kd.h>
|
||||
|
||||
#ifndef KDFONTOP
|
||||
#define KDFONTOP 0x4B72
|
||||
# define KDFONTOP 0x4B72
|
||||
struct console_font_op {
|
||||
unsigned op; /* KD_FONT_OP_* */
|
||||
unsigned flags; /* KD_FONT_FLAG_* */
|
||||
@@ -21,91 +21,137 @@ struct console_font_op {
|
||||
unsigned charcount;
|
||||
unsigned char *data; /* font data with height fixed to 32 */
|
||||
};
|
||||
|
||||
#define KD_FONT_OP_SET 0 /* Set font */
|
||||
#define KD_FONT_OP_GET 1 /* Get font */
|
||||
#define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default,
|
||||
data points to name / NULL */
|
||||
#define KD_FONT_OP_COPY 3 /* Copy from another console */
|
||||
|
||||
#define KD_FONT_FLAG_OLD 0x80000000 /* Invoked via old interface */
|
||||
#define KD_FONT_FLAG_DONT_RECALC 1 /* Don't call adjust_height() */
|
||||
# define KD_FONT_OP_SET 0 /* Set font */
|
||||
# define KD_FONT_OP_GET 1 /* Get font */
|
||||
# define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default, data points to name / NULL */
|
||||
# define KD_FONT_OP_COPY 3 /* Copy from another console */
|
||||
# define KD_FONT_FLAG_OLD 0x80000000 /* Invoked via old interface */
|
||||
# define KD_FONT_FLAG_DONT_RECALC 1 /* Don't call adjust_height() */
|
||||
/* (Used internally for PIO_FONT support) */
|
||||
#endif /* KDFONTOP */
|
||||
|
||||
|
||||
enum {
|
||||
PSF_MAGIC1 = 0x36,
|
||||
PSF_MAGIC2 = 0x04,
|
||||
|
||||
PSF_MODE512 = 0x01,
|
||||
PSF_MODEHASTAB = 0x02,
|
||||
PSF_MAXMODE = 0x03,
|
||||
PSF_SEPARATOR = 0xffff
|
||||
PSF1_MAGIC0 = 0x36,
|
||||
PSF1_MAGIC1 = 0x04,
|
||||
PSF1_MODE512 = 0x01,
|
||||
PSF1_MODEHASTAB = 0x02,
|
||||
PSF1_MODEHASSEQ = 0x04,
|
||||
PSF1_MAXMODE = 0x05,
|
||||
PSF1_STARTSEQ = 0xfffe,
|
||||
PSF1_SEPARATOR = 0xffff,
|
||||
};
|
||||
|
||||
struct psf_header {
|
||||
unsigned char magic1, magic2; /* Magic number */
|
||||
struct psf1_header {
|
||||
unsigned char magic[2]; /* Magic number */
|
||||
unsigned char mode; /* PSF font mode */
|
||||
unsigned char charsize; /* Character size */
|
||||
};
|
||||
|
||||
#define PSF_MAGIC_OK(x) ((x)->magic1 == PSF_MAGIC1 && (x)->magic2 == PSF_MAGIC2)
|
||||
#define psf1h(x) ((struct psf1_header*)(x))
|
||||
|
||||
static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
|
||||
#define PSF1_MAGIC_OK(x) ( \
|
||||
(x)->magic[0] == PSF1_MAGIC0 \
|
||||
&& (x)->magic[1] == PSF1_MAGIC1 \
|
||||
)
|
||||
|
||||
#if ENABLE_FEATURE_LOADFONT_PSF2
|
||||
enum {
|
||||
PSF2_MAGIC0 = 0x72,
|
||||
PSF2_MAGIC1 = 0xb5,
|
||||
PSF2_MAGIC2 = 0x4a,
|
||||
PSF2_MAGIC3 = 0x86,
|
||||
PSF2_HAS_UNICODE_TABLE = 0x01,
|
||||
PSF2_MAXVERSION = 0,
|
||||
PSF2_STARTSEQ = 0xfe,
|
||||
PSF2_SEPARATOR = 0xff
|
||||
};
|
||||
|
||||
struct psf2_header {
|
||||
unsigned char magic[4];
|
||||
unsigned int version;
|
||||
unsigned int headersize; /* offset of bitmaps in file */
|
||||
unsigned int flags;
|
||||
unsigned int length; /* number of glyphs */
|
||||
unsigned int charsize; /* number of bytes for each character */
|
||||
unsigned int height; /* max dimensions of glyphs */
|
||||
unsigned int width; /* charsize = height * ((width + 7) / 8) */
|
||||
};
|
||||
|
||||
#define psf2h(x) ((struct psf2_header*)(x))
|
||||
|
||||
#define PSF2_MAGIC_OK(x) ( \
|
||||
(x)->magic[0] == PSF2_MAGIC0 \
|
||||
&& (x)->magic[1] == PSF2_MAGIC1 \
|
||||
&& (x)->magic[2] == PSF2_MAGIC2 \
|
||||
&& (x)->magic[3] == PSF2_MAGIC3 \
|
||||
)
|
||||
#endif /* ENABLE_FEATURE_LOADFONT_PSF2 */
|
||||
|
||||
|
||||
static void do_loadfont(int fd, unsigned char *inbuf, int height, int width, int charsize, int fontsize)
|
||||
{
|
||||
char *buf;
|
||||
unsigned char *buf;
|
||||
int charwidth = 32 * ((width+7)/8);
|
||||
int i;
|
||||
|
||||
if (unit < 1 || unit > 32)
|
||||
bb_error_msg_and_die("bad character size %d", unit);
|
||||
if (height < 1 || height > 32 || width < 1 || width > 32)
|
||||
bb_error_msg_and_die("bad character size %dx%d", height, width);
|
||||
|
||||
buf = xzalloc(16 * 1024);
|
||||
buf = xzalloc(charwidth * ((fontsize < 128) ? 128 : fontsize));
|
||||
for (i = 0; i < fontsize; i++)
|
||||
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
|
||||
memcpy(buf + (i*charwidth), inbuf + (i*charsize), charsize);
|
||||
|
||||
{ /* KDFONTOP */
|
||||
struct console_font_op cfo;
|
||||
|
||||
cfo.op = KD_FONT_OP_SET;
|
||||
cfo.flags = 0;
|
||||
cfo.width = 8;
|
||||
cfo.height = unit;
|
||||
cfo.width = width;
|
||||
cfo.height = height;
|
||||
cfo.charcount = fontsize;
|
||||
cfo.data = (void*)buf;
|
||||
#if 0
|
||||
if (!ioctl_or_perror(fd, KDFONTOP, &cfo, "KDFONTOP ioctl failed (will try PIO_FONTX)"))
|
||||
goto ret; /* success */
|
||||
#else
|
||||
cfo.data = buf;
|
||||
xioctl(fd, KDFONTOP, &cfo);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* These ones do not honour -C tty (they set font on current tty regardless)
|
||||
* On x86, this distinction is visible on framebuffer consoles
|
||||
* (regular character consoles may have only one shared font anyway)
|
||||
*/
|
||||
#if defined(PIO_FONTX) && !defined(__sparc__)
|
||||
{
|
||||
struct consolefontdesc cfd;
|
||||
|
||||
cfd.charcount = fontsize;
|
||||
cfd.charheight = unit;
|
||||
cfd.chardata = buf;
|
||||
|
||||
if (!ioctl_or_perror(fd, PIO_FONTX, &cfd, "PIO_FONTX ioctl failed (will try PIO_FONT)"))
|
||||
goto ret; /* success */
|
||||
}
|
||||
#endif
|
||||
xioctl(fd, PIO_FONT, buf);
|
||||
ret:
|
||||
#endif /* 0 */
|
||||
free(buf);
|
||||
}
|
||||
|
||||
static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
/*
|
||||
* Format of the Unicode information:
|
||||
*
|
||||
* For each font position <uc>*<seq>*<term>
|
||||
* where <uc> is a 2-byte little endian Unicode value (PSF1)
|
||||
* or an UTF-8 coded value (PSF2),
|
||||
* <seq> = <ss><uc><uc>*, <ss> = psf1 ? 0xFFFE : 0xFE,
|
||||
* <term> = psf1 ? 0xFFFF : 0xFF.
|
||||
* and * denotes zero or more occurrences of the preceding item.
|
||||
*
|
||||
* Semantics:
|
||||
* The leading <uc>* part gives Unicode symbols that are all
|
||||
* represented by this font position. The following sequences
|
||||
* are sequences of Unicode symbols - probably a symbol
|
||||
* together with combining accents - also represented by
|
||||
* this font position.
|
||||
*
|
||||
* Example:
|
||||
* At the font position for a capital A-ring glyph, we
|
||||
* may have:
|
||||
* 00C5,212B,FFFE,0041,030A,FFFF
|
||||
* Some font positions may be described by sequences only,
|
||||
* namely when there is no precomposed Unicode value for the glyph.
|
||||
*/
|
||||
#if !ENABLE_FEATURE_LOADFONT_PSF2
|
||||
#define do_loadtable(fd, inbuf, tailsz, fontsize, psf2) \
|
||||
do_loadtable(fd, inbuf, tailsz, fontsize)
|
||||
#endif
|
||||
static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize, int psf2)
|
||||
{
|
||||
#if !ENABLE_FEATURE_LOADFONT_PSF2
|
||||
/* gcc 4.3.1 code size: */
|
||||
# define psf2 0 /* +0 bytes */
|
||||
// const int psf2 = 0; /* +8 bytes */
|
||||
// enum { psf2 = 0 }; /* +13 bytes */
|
||||
#endif
|
||||
struct unimapinit advice;
|
||||
struct unimapdesc ud;
|
||||
struct unipair *up;
|
||||
@@ -114,15 +160,48 @@ static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
uint16_t unicode;
|
||||
|
||||
maxct = tailsz; /* more than enough */
|
||||
up = xmalloc(maxct * sizeof(struct unipair));
|
||||
up = xmalloc(maxct * sizeof(*up));
|
||||
|
||||
for (glyph = 0; glyph < fontsize; glyph++) {
|
||||
while (tailsz >= 2) {
|
||||
unicode = (((uint16_t) inbuf[1]) << 8) + inbuf[0];
|
||||
tailsz -= 2;
|
||||
inbuf += 2;
|
||||
if (unicode == PSF_SEPARATOR)
|
||||
break;
|
||||
while (tailsz > 0) {
|
||||
if (!psf2) { /* PSF1 */
|
||||
unicode = (((uint16_t) inbuf[1]) << 8) + inbuf[0];
|
||||
tailsz -= 2;
|
||||
inbuf += 2;
|
||||
if (unicode == PSF1_SEPARATOR)
|
||||
break;
|
||||
} else { /* PSF2 */
|
||||
#if ENABLE_FEATURE_LOADFONT_PSF2
|
||||
--tailsz;
|
||||
unicode = *inbuf++;
|
||||
if (unicode == PSF2_SEPARATOR) {
|
||||
break;
|
||||
} else if (unicode == PSF2_STARTSEQ) {
|
||||
bb_error_msg_and_die("unicode sequences not implemented");
|
||||
} else if (unicode >= 0xC0) {
|
||||
if (unicode >= 0xFC)
|
||||
unicode &= 0x01, maxct = 5;
|
||||
else if (unicode >= 0xF8)
|
||||
unicode &= 0x03, maxct = 4;
|
||||
else if (unicode >= 0xF0)
|
||||
unicode &= 0x07, maxct = 3;
|
||||
else if (unicode >= 0xE0)
|
||||
unicode &= 0x0F, maxct = 2;
|
||||
else
|
||||
unicode &= 0x1F, maxct = 1;
|
||||
do {
|
||||
if (tailsz <= 0 || *inbuf < 0x80 || *inbuf > 0xBF)
|
||||
bb_error_msg_and_die("illegal UTF-8 character");
|
||||
--tailsz;
|
||||
unicode = (unicode << 6) + (*inbuf++ & 0x3F);
|
||||
} while (--maxct > 0);
|
||||
} else if (unicode >= 0x80) {
|
||||
bb_error_msg_and_die("illegal UTF-8 character");
|
||||
}
|
||||
#else
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
up[ct].unicode = unicode;
|
||||
up[ct].fontpos = glyph;
|
||||
ct++;
|
||||
@@ -139,58 +218,78 @@ static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
ud.entry_ct = ct;
|
||||
ud.entries = up;
|
||||
xioctl(fd, PIO_UNIMAP, &ud);
|
||||
#undef psf2
|
||||
}
|
||||
|
||||
static void do_load(int fd, struct psf_header *psfhdr, size_t len)
|
||||
static void do_load(int fd, unsigned char *buffer, size_t len)
|
||||
{
|
||||
int unit;
|
||||
int fontsize;
|
||||
int hastable;
|
||||
unsigned head0, head = head;
|
||||
int height;
|
||||
int width = 8;
|
||||
int charsize;
|
||||
int fontsize = 256;
|
||||
int has_table = 0;
|
||||
unsigned char *font = buffer;
|
||||
unsigned char *table;
|
||||
|
||||
/* test for psf first */
|
||||
if (len >= sizeof(struct psf_header) && PSF_MAGIC_OK(psfhdr)) {
|
||||
if (psfhdr->mode > PSF_MAXMODE)
|
||||
if (len >= sizeof(struct psf1_header) && PSF1_MAGIC_OK(psf1h(buffer))) {
|
||||
if (psf1h(buffer)->mode > PSF1_MAXMODE)
|
||||
bb_error_msg_and_die("unsupported psf file mode");
|
||||
fontsize = ((psfhdr->mode & PSF_MODE512) ? 512 : 256);
|
||||
#if !defined(PIO_FONTX) || defined(__sparc__)
|
||||
if (fontsize != 256)
|
||||
bb_error_msg_and_die("only fontsize 256 supported");
|
||||
if (psf1h(buffer)->mode & PSF1_MODE512)
|
||||
fontsize = 512;
|
||||
if (psf1h(buffer)->mode & PSF1_MODEHASTAB)
|
||||
has_table = 1;
|
||||
height = charsize = psf1h(buffer)->charsize;
|
||||
font += sizeof(struct psf1_header);
|
||||
} else
|
||||
#if ENABLE_FEATURE_LOADFONT_PSF2
|
||||
if (len >= sizeof(struct psf2_header) && PSF2_MAGIC_OK(psf2h(buffer))) {
|
||||
if (psf2h(buffer)->version > PSF2_MAXVERSION)
|
||||
bb_error_msg_and_die("unsupported psf file version");
|
||||
fontsize = psf2h(buffer)->length;
|
||||
if (psf2h(buffer)->flags & PSF2_HAS_UNICODE_TABLE)
|
||||
has_table = 2;
|
||||
charsize = psf2h(buffer)->charsize;
|
||||
height = psf2h(buffer)->height;
|
||||
width = psf2h(buffer)->width;
|
||||
font += psf2h(buffer)->headersize;
|
||||
} else
|
||||
#endif
|
||||
hastable = (psfhdr->mode & PSF_MODEHASTAB);
|
||||
unit = psfhdr->charsize;
|
||||
head0 = sizeof(struct psf_header);
|
||||
|
||||
head = head0 + fontsize * unit;
|
||||
if (head > len || (!hastable && head != len))
|
||||
bb_error_msg_and_die("input file: bad length");
|
||||
} else {
|
||||
/* file with three code pages? */
|
||||
if (len == 9780) {
|
||||
head0 = 40;
|
||||
unit = 16;
|
||||
} else {
|
||||
/* bare font */
|
||||
if (len & 0377)
|
||||
bb_error_msg_and_die("input file: bad length");
|
||||
head0 = 0;
|
||||
unit = len / 256;
|
||||
}
|
||||
fontsize = 256;
|
||||
hastable = 0;
|
||||
#if ENABLE_FEATURE_LOADFONT_RAW
|
||||
if (len == 9780) { /* file with three code pages? */
|
||||
charsize = height = 16;
|
||||
font += 40;
|
||||
} else if ((len & 0377) == 0) { /* bare font */
|
||||
charsize = height = len / 256;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
bb_error_msg_and_die("input file: bad length or unsupported font type");
|
||||
}
|
||||
|
||||
do_loadfont(fd, (unsigned char *)psfhdr + head0, unit, fontsize);
|
||||
if (hastable)
|
||||
do_loadtable(fd, (unsigned char *)psfhdr + head, len - head, fontsize);
|
||||
#if !defined(PIO_FONTX) || defined(__sparc__)
|
||||
if (fontsize != 256)
|
||||
bb_error_msg_and_die("only fontsize 256 supported");
|
||||
#endif
|
||||
|
||||
table = font + fontsize * charsize;
|
||||
buffer += len;
|
||||
|
||||
if (table > buffer || (!has_table && table != buffer))
|
||||
bb_error_msg_and_die("input file: bad length");
|
||||
|
||||
do_loadfont(fd, font, height, width, charsize, fontsize);
|
||||
|
||||
if (has_table)
|
||||
do_loadtable(fd, table, buffer - table, fontsize, has_table - 1);
|
||||
}
|
||||
|
||||
|
||||
#if ENABLE_LOADFONT
|
||||
int loadfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int loadfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
size_t len;
|
||||
struct psf_header *psfhdr;
|
||||
unsigned char *buffer;
|
||||
|
||||
// no arguments allowed!
|
||||
opt_complementary = "=0";
|
||||
@@ -202,11 +301,11 @@ int loadfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
* just read the entire file.
|
||||
*/
|
||||
len = 32*1024; // can't be larger
|
||||
psfhdr = xmalloc_read(STDIN_FILENO, &len);
|
||||
buffer = xmalloc_read(STDIN_FILENO, &len);
|
||||
// xmalloc_open_zipped_read_close(filename, &len);
|
||||
if (!psfhdr)
|
||||
if (!buffer)
|
||||
bb_perror_msg_and_die("error reading input font");
|
||||
do_load(get_console_fd_or_die(), psfhdr, len);
|
||||
do_load(get_console_fd_or_die(), buffer, len);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -269,7 +368,7 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
size_t len;
|
||||
unsigned opts;
|
||||
int fd;
|
||||
struct psf_header *psfhdr;
|
||||
unsigned char *buffer;
|
||||
char *mapfilename;
|
||||
const char *tty_name = CURRENT_TTY;
|
||||
|
||||
@@ -287,10 +386,10 @@ int setfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
// load font
|
||||
len = 32*1024; // can't be larger
|
||||
psfhdr = xmalloc_open_zipped_read_close(*argv, &len);
|
||||
if (!psfhdr)
|
||||
buffer = xmalloc_open_zipped_read_close(*argv, &len);
|
||||
if (!buffer)
|
||||
bb_simple_perror_msg_and_die(*argv);
|
||||
do_load(fd, psfhdr, len);
|
||||
do_load(fd, buffer, len);
|
||||
|
||||
// load the screen map, if any
|
||||
if (opts & 1) { // -m
|
||||
|
||||
@@ -24,7 +24,7 @@ struct kbentry {
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int loadkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int loadkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
int loadkmap_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
@@ -32,6 +32,11 @@ int loadkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
/* const char *tty_name = CURRENT_TTY; */
|
||||
RESERVE_CONFIG_BUFFER(flags, MAX_NR_KEYMAPS);
|
||||
|
||||
/* When user accidentally runs "loadkmap FILE"
|
||||
* instead of "loadkmap <FILE", we end up waiting for input from tty.
|
||||
* Let's prevent it: */
|
||||
if (argv[1])
|
||||
bb_show_usage();
|
||||
/* bb_warn_ignoring_args(argv[1]); */
|
||||
fd = get_console_fd_or_die();
|
||||
/* or maybe:
|
||||
|
||||
@@ -97,8 +97,7 @@ static NOINLINE void vfork_child(char **argv)
|
||||
//bb_error_msg("our pgrp %d", getpgrp());
|
||||
//bb_error_msg("VT's sid %d", tcgetsid(0));
|
||||
//bb_error_msg("VT's pgrp %d", tcgetpgrp(0));
|
||||
BB_EXECVP(argv[0], argv);
|
||||
bb_perror_msg_and_die("exec %s", argv[0]);
|
||||
BB_EXECVP_or_die(argv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
|
||||
if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
|
||||
/* See 'man 4 console_codes' for details:
|
||||
* "ESC c" -- Reset
|
||||
* "ESC ( K" -- Select user mapping
|
||||
* "ESC [ J" -- Erase display
|
||||
* "ESC [ 0 m" -- Reset all display attributes
|
||||
* "ESC [ ? 25 h" -- Make cursor visible.
|
||||
* "ESC c" -- Reset
|
||||
* "ESC ( K" -- Select user mapping
|
||||
* "ESC [ J" -- Erase to the end of screen
|
||||
* "ESC [ 0 m" -- Reset all display attributes
|
||||
* "ESC [ ? 25 h" -- Make cursor visible
|
||||
*/
|
||||
printf("\033c\033(K\033[J\033[0m\033[?25h");
|
||||
/* http://bugs.busybox.net/view.php?id=1414:
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
|
||||
#define ESC "\033"
|
||||
|
||||
#define old_termios (*(struct termios*)&bb_common_bufsiz1)
|
||||
#define old_termios_p ((struct termios*)&bb_common_bufsiz1)
|
||||
|
||||
static void
|
||||
onintr(int sig UNUSED_PARAM)
|
||||
{
|
||||
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
|
||||
tcsetattr(STDERR_FILENO, TCSANOW, old_termios_p);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
@@ -33,8 +33,8 @@ int resize_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
* and operate on it - should we do the same?
|
||||
*/
|
||||
|
||||
tcgetattr(STDERR_FILENO, &old_termios); /* fiddle echo */
|
||||
new = old_termios;
|
||||
tcgetattr(STDERR_FILENO, old_termios_p); /* fiddle echo */
|
||||
memcpy(&new, old_termios_p, sizeof(new));
|
||||
new.c_cflag |= (CLOCAL | CREAD);
|
||||
new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
||||
bb_signals(0
|
||||
@@ -61,7 +61,7 @@ int resize_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
* (gotten via TIOCGWINSZ) and recomputing *pixel values */
|
||||
ret = ioctl(STDERR_FILENO, TIOCSWINSZ, &w);
|
||||
|
||||
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
|
||||
tcsetattr(STDERR_FILENO, TCSANOW, old_termios_p);
|
||||
|
||||
if (ENABLE_FEATURE_RESIZE_PRINT)
|
||||
printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n",
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
//#include <sys/ioctl.h>
|
||||
#include "libbb.h"
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
@@ -23,7 +21,7 @@ enum {
|
||||
int setkeycodes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setkeycodes_main(int argc, char **argv)
|
||||
{
|
||||
int fd, sc;
|
||||
int fd;
|
||||
struct kbkeycode a;
|
||||
|
||||
if (!(argc & 1) /* if even */ || argc < 2) {
|
||||
@@ -32,17 +30,17 @@ int setkeycodes_main(int argc, char **argv)
|
||||
|
||||
fd = get_console_fd_or_die();
|
||||
|
||||
while (argc > 2) {
|
||||
a.keycode = xatou_range(argv[2], 0, 127);
|
||||
a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255);
|
||||
if (a.scancode > 127) {
|
||||
a.scancode -= 0xe000;
|
||||
a.scancode += 128;
|
||||
while (argv[1]) {
|
||||
int sc = xstrtoul_range(argv[1], 16, 0, 0xe07f);
|
||||
if (sc >= 0xe000) {
|
||||
sc -= 0xe000;
|
||||
sc += 0x0080;
|
||||
}
|
||||
a.scancode = sc;
|
||||
a.keycode = xatou_range(argv[2], 0, 255);
|
||||
ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
|
||||
"can't set SCANCODE %x to KEYCODE %d",
|
||||
sc, a.keycode);
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -5,89 +5,76 @@
|
||||
|
||||
menu "Coreutils"
|
||||
|
||||
config BASENAME
|
||||
bool "basename"
|
||||
default n
|
||||
help
|
||||
basename is used to strip the directory and suffix from filenames,
|
||||
leaving just the filename itself. Enable this option if you wish
|
||||
to enable the 'basename' utility.
|
||||
INSERT
|
||||
|
||||
config CAL
|
||||
bool "cal"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
cal is used to display a monthly calender.
|
||||
|
||||
config CAT
|
||||
bool "cat"
|
||||
default n
|
||||
help
|
||||
cat is used to concatenate files and print them to the standard
|
||||
output. Enable this option if you wish to enable the 'cat' utility.
|
||||
|
||||
config CATV
|
||||
bool "catv"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Display nonprinting characters as escape sequences (like some
|
||||
implementations' cat -v option).
|
||||
|
||||
config CHGRP
|
||||
bool "chgrp"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
chgrp is used to change the group ownership of files.
|
||||
|
||||
config CHMOD
|
||||
bool "chmod"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
chmod is used to change the access permission of files.
|
||||
|
||||
config CHOWN
|
||||
bool "chown"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
chown is used to change the user and/or group ownership
|
||||
of files.
|
||||
|
||||
config FEATURE_CHOWN_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
default y
|
||||
depends on CHOWN && LONG_OPTS
|
||||
help
|
||||
Enable use of long options
|
||||
|
||||
config CHROOT
|
||||
bool "chroot"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
chroot is used to change the root directory and run a command.
|
||||
The default command is `/bin/sh'.
|
||||
|
||||
config CKSUM
|
||||
bool "cksum"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
cksum is used to calculate the CRC32 checksum of a file.
|
||||
|
||||
config COMM
|
||||
bool "comm"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
comm is used to compare two files line by line and return
|
||||
a three-column output.
|
||||
|
||||
config CP
|
||||
bool "cp"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
cp is used to copy files and directories.
|
||||
|
||||
config FEATURE_CP_LONG_OPTIONS
|
||||
bool "Enable long options for cp"
|
||||
default n
|
||||
default y
|
||||
depends on CP && LONG_OPTS
|
||||
help
|
||||
Enable long options for cp.
|
||||
@@ -95,45 +82,14 @@ config FEATURE_CP_LONG_OPTIONS
|
||||
|
||||
config CUT
|
||||
bool "cut"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
cut is used to print selected parts of lines from
|
||||
each file to stdout.
|
||||
|
||||
config DATE
|
||||
bool "date"
|
||||
default n
|
||||
help
|
||||
date is used to set the system date or display the
|
||||
current time in the given format.
|
||||
|
||||
config FEATURE_DATE_ISOFMT
|
||||
bool "Enable ISO date format output (-I)"
|
||||
default y
|
||||
depends on DATE
|
||||
help
|
||||
Enable option (-I) to output an ISO-8601 compliant
|
||||
date/time string.
|
||||
|
||||
config FEATURE_DATE_COMPAT
|
||||
bool "Support weird 'date MMDDhhmm[[YY]YY][.ss]' format"
|
||||
default y
|
||||
depends on DATE
|
||||
help
|
||||
System time can be set by 'date -s DATE' and simply 'date DATE',
|
||||
but formats of DATE string are different. 'date DATE' accepts
|
||||
a rather weird MMDDhhmm[[YY]YY][.ss] format with completely
|
||||
unnatural placement of year between minutes and seconds.
|
||||
date -s (and other commands like touch -d) use more sensible
|
||||
formats (for one, ISO format YYYY-MM-DD hh:mm:ss.ssssss).
|
||||
|
||||
With this option off, 'date DATE' is 'date -s DATE' support
|
||||
the same format. With it on, 'date DATE' additionally supports
|
||||
MMDDhhmm[[YY]YY][.ss] format.
|
||||
|
||||
config DD
|
||||
bool "dd"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
dd copies a file (from standard input to standard output,
|
||||
by default) using specific input and output blocksizes,
|
||||
@@ -155,7 +111,7 @@ config FEATURE_DD_SIGNAL_HANDLING
|
||||
|
||||
config FEATURE_DD_THIRD_STATUS_LINE
|
||||
bool "Enable the third status line upon signal"
|
||||
default n
|
||||
default y
|
||||
depends on DD && FEATURE_DD_SIGNAL_HANDLING
|
||||
help
|
||||
Displays a coreutils-like third status line with transferred bytes,
|
||||
@@ -163,7 +119,7 @@ config FEATURE_DD_THIRD_STATUS_LINE
|
||||
|
||||
config FEATURE_DD_IBS_OBS
|
||||
bool "Enable ibs, obs and conv options"
|
||||
default n
|
||||
default y
|
||||
depends on DD
|
||||
help
|
||||
Enables support for writing a certain number of bytes in and out,
|
||||
@@ -171,28 +127,32 @@ config FEATURE_DD_IBS_OBS
|
||||
|
||||
config DF
|
||||
bool "df"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
df reports the amount of disk space used and available
|
||||
on filesystems.
|
||||
|
||||
config FEATURE_DF_FANCY
|
||||
bool "Enable -a, -i, -B"
|
||||
default n
|
||||
default y
|
||||
depends on DF
|
||||
help
|
||||
This option enables -a, -i and -B.
|
||||
|
||||
-a Show all filesystems
|
||||
-i Inodes
|
||||
-B <SIZE> Blocksize
|
||||
|
||||
config DIRNAME
|
||||
bool "dirname"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
dirname is used to strip a non-directory suffix from
|
||||
a file name.
|
||||
|
||||
config DOS2UNIX
|
||||
bool "dos2unix/unix2dos"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
dos2unix is used to convert a text file from DOS format to
|
||||
UNIX format, and vice versa.
|
||||
@@ -207,7 +167,7 @@ config UNIX2DOS
|
||||
|
||||
config DU
|
||||
bool "du (default blocksize of 512 bytes)"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
du is used to report the amount of disk space used
|
||||
for specified files.
|
||||
@@ -221,7 +181,7 @@ config FEATURE_DU_DEFAULT_BLOCKSIZE_1K
|
||||
|
||||
config ECHO
|
||||
bool "echo (basic SuSv3 version taking no options)"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
echo is used to print a specified string to stdout.
|
||||
|
||||
@@ -235,7 +195,7 @@ config FEATURE_FANCY_ECHO
|
||||
|
||||
config ENV
|
||||
bool "env"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
env is used to set an environment variable and run
|
||||
a command; without options it displays the current
|
||||
@@ -243,34 +203,34 @@ config ENV
|
||||
|
||||
config FEATURE_ENV_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
default y
|
||||
depends on ENV && LONG_OPTS
|
||||
help
|
||||
Support long options for the env applet.
|
||||
|
||||
config EXPAND
|
||||
bool "expand"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
By default, convert all tabs to spaces.
|
||||
|
||||
config FEATURE_EXPAND_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
default y
|
||||
depends on EXPAND && LONG_OPTS
|
||||
help
|
||||
Support long options for the expand applet.
|
||||
|
||||
config EXPR
|
||||
bool "expr"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
expr is used to calculate numbers and print the result
|
||||
to standard output.
|
||||
|
||||
config EXPR_MATH_SUPPORT_64
|
||||
bool "Extend Posix numbers support to 64 bit"
|
||||
default n
|
||||
default y
|
||||
depends on EXPR
|
||||
help
|
||||
Enable 64-bit math support in the expr applet. This will make
|
||||
@@ -279,83 +239,83 @@ config EXPR_MATH_SUPPORT_64
|
||||
|
||||
config FALSE
|
||||
bool "false"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
false returns an exit code of FALSE (1).
|
||||
|
||||
config FOLD
|
||||
bool "fold"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Wrap text to fit a specific width.
|
||||
|
||||
config FSYNC
|
||||
bool "fsync"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
fsync is used to flush file-related cached blocks to disk.
|
||||
|
||||
config HEAD
|
||||
bool "head"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
head is used to print the first specified number of lines
|
||||
from files.
|
||||
|
||||
config FEATURE_FANCY_HEAD
|
||||
bool "Enable head options (-c, -q, and -v)"
|
||||
default n
|
||||
default y
|
||||
depends on HEAD
|
||||
help
|
||||
This enables the head options (-c, -q, and -v).
|
||||
|
||||
config HOSTID
|
||||
bool "hostid"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
hostid prints the numeric identifier (in hexadecimal) for
|
||||
the current host.
|
||||
|
||||
config ID
|
||||
bool "id"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
id displays the current user and group ID names.
|
||||
|
||||
config INSTALL
|
||||
bool "install"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Copy files and set attributes.
|
||||
|
||||
config FEATURE_INSTALL_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
default y
|
||||
depends on INSTALL && LONG_OPTS
|
||||
help
|
||||
Support long options for the install applet.
|
||||
|
||||
config LENGTH
|
||||
bool "length"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
length is used to print out the length of a specified string.
|
||||
|
||||
config LN
|
||||
bool "ln"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
ln is used to create hard or soft links between files.
|
||||
|
||||
config LOGNAME
|
||||
bool "logname"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
logname is used to print the current user's login name.
|
||||
|
||||
config LS
|
||||
bool "ls"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
ls is used to list the contents of directories.
|
||||
|
||||
@@ -410,7 +370,7 @@ config FEATURE_LS_COLOR
|
||||
|
||||
config FEATURE_LS_COLOR_IS_DEFAULT
|
||||
bool "Produce colored ls output by default"
|
||||
default n
|
||||
default y
|
||||
depends on FEATURE_LS_COLOR
|
||||
help
|
||||
Saying yes here will turn coloring on by default,
|
||||
@@ -421,123 +381,123 @@ config FEATURE_LS_COLOR_IS_DEFAULT
|
||||
|
||||
config MD5SUM
|
||||
bool "md5sum"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
md5sum is used to print or check MD5 checksums.
|
||||
|
||||
config MKDIR
|
||||
bool "mkdir"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
mkdir is used to create directories with the specified names.
|
||||
|
||||
config FEATURE_MKDIR_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
default y
|
||||
depends on MKDIR && LONG_OPTS
|
||||
help
|
||||
Support long options for the mkdir applet.
|
||||
|
||||
config MKFIFO
|
||||
bool "mkfifo"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
mkfifo is used to create FIFOs (named pipes).
|
||||
The `mknod' program can also create FIFOs.
|
||||
|
||||
config MKNOD
|
||||
bool "mknod"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
mknod is used to create FIFOs or block/character special
|
||||
files with the specified names.
|
||||
|
||||
config MV
|
||||
bool "mv"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
mv is used to move or rename files or directories.
|
||||
|
||||
config FEATURE_MV_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
default y
|
||||
depends on MV && LONG_OPTS
|
||||
help
|
||||
Support long options for the mv applet.
|
||||
|
||||
config NICE
|
||||
bool "nice"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
nice runs a program with modified scheduling priority.
|
||||
|
||||
config NOHUP
|
||||
bool "nohup"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
run a command immune to hangups, with output to a non-tty.
|
||||
|
||||
config OD
|
||||
bool "od"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
od is used to dump binary files in octal and other formats.
|
||||
|
||||
config PRINTENV
|
||||
bool "printenv"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
printenv is used to print all or part of environment.
|
||||
|
||||
config PRINTF
|
||||
bool "printf"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
printf is used to format and print specified strings.
|
||||
It's similar to `echo' except it has more options.
|
||||
|
||||
config PWD
|
||||
bool "pwd"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
pwd is used to print the current directory.
|
||||
|
||||
config READLINK
|
||||
bool "readlink"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
This program reads a symbolic link and returns the name
|
||||
of the file it points to
|
||||
|
||||
config FEATURE_READLINK_FOLLOW
|
||||
bool "Enable canonicalization by following all symlinks (-f)"
|
||||
default n
|
||||
default y
|
||||
depends on READLINK
|
||||
help
|
||||
Enable the readlink option (-f).
|
||||
|
||||
config REALPATH
|
||||
bool "realpath"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Return the canonicalized absolute pathname.
|
||||
This isn't provided by GNU shellutils, but where else does it belong.
|
||||
|
||||
config RM
|
||||
bool "rm"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
rm is used to remove files or directories.
|
||||
|
||||
config RMDIR
|
||||
bool "rmdir"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
rmdir is used to remove empty directories.
|
||||
|
||||
config FEATURE_RMDIR_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
default y
|
||||
depends on RMDIR && LONG_OPTS
|
||||
help
|
||||
Support long options for the rmdir applet, including
|
||||
@@ -545,31 +505,31 @@ config FEATURE_RMDIR_LONG_OPTIONS
|
||||
|
||||
config SEQ
|
||||
bool "seq"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
print a sequence of numbers
|
||||
|
||||
config SHA1SUM
|
||||
bool "sha1sum"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Compute and check SHA1 message digest
|
||||
|
||||
config SHA256SUM
|
||||
bool "sha256sum"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Compute and check SHA256 message digest
|
||||
|
||||
config SHA512SUM
|
||||
bool "sha512sum"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
Compute and check SHA512 message digest
|
||||
|
||||
config SLEEP
|
||||
bool "sleep"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
sleep is used to pause for a specified number of seconds.
|
||||
It comes in 3 versions:
|
||||
@@ -583,21 +543,21 @@ config SLEEP
|
||||
|
||||
config FEATURE_FANCY_SLEEP
|
||||
bool "Enable multiple arguments and s/m/h/d suffixes"
|
||||
default n
|
||||
default y
|
||||
depends on SLEEP
|
||||
help
|
||||
Allow sleep to pause for specified minutes, hours, and days.
|
||||
|
||||
config FEATURE_FLOAT_SLEEP
|
||||
bool "Enable fractional arguments"
|
||||
default n
|
||||
default y
|
||||
depends on FEATURE_FANCY_SLEEP
|
||||
help
|
||||
Allow for fractional numeric parameters.
|
||||
|
||||
config SORT
|
||||
bool "sort"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
sort is used to sort lines of text in specified files.
|
||||
|
||||
@@ -615,13 +575,13 @@ config FEATURE_SORT_BIG
|
||||
|
||||
config SPLIT
|
||||
bool "split"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
split a file into pieces.
|
||||
|
||||
config FEATURE_SPLIT_FANCY
|
||||
bool "Fancy extensions"
|
||||
default n
|
||||
default y
|
||||
depends on SPLIT
|
||||
help
|
||||
Add support for features not required by SUSv3.
|
||||
@@ -630,13 +590,13 @@ config FEATURE_SPLIT_FANCY
|
||||
|
||||
config STAT
|
||||
bool "stat"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
display file or filesystem status.
|
||||
|
||||
config FEATURE_STAT_FORMAT
|
||||
bool "Enable custom formats (-c)"
|
||||
default n
|
||||
default y
|
||||
depends on STAT
|
||||
help
|
||||
Without this, stat will not support the '-c format' option where
|
||||
@@ -645,31 +605,31 @@ config FEATURE_STAT_FORMAT
|
||||
|
||||
config STTY
|
||||
bool "stty"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
stty is used to change and print terminal line settings.
|
||||
|
||||
config SUM
|
||||
bool "sum"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
checksum and count the blocks in a file
|
||||
|
||||
config SYNC
|
||||
bool "sync"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
sync is used to flush filesystem buffers.
|
||||
|
||||
config TAC
|
||||
bool "tac"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
tac is used to concatenate and print files in reverse.
|
||||
|
||||
config TAIL
|
||||
bool "tail"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
tail is used to print the last specified number of lines
|
||||
from files.
|
||||
@@ -682,155 +642,118 @@ config FEATURE_FANCY_TAIL
|
||||
The options (-q, -s, and -v) are provided by GNU tail, but
|
||||
are not specific in the SUSv3 standard.
|
||||
|
||||
-q Never output headers giving file names
|
||||
-s SEC Wait SEC seconds between reads with -f
|
||||
-v Always output headers giving file names
|
||||
|
||||
config TEE
|
||||
bool "tee"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
tee is used to read from standard input and write
|
||||
to standard output and files.
|
||||
|
||||
config FEATURE_TEE_USE_BLOCK_IO
|
||||
bool "Enable block I/O (larger/faster) instead of byte I/O"
|
||||
default n
|
||||
default y
|
||||
depends on TEE
|
||||
help
|
||||
Enable this option for a faster tee, at expense of size.
|
||||
|
||||
config TEST
|
||||
bool "test"
|
||||
default n
|
||||
help
|
||||
test is used to check file types and compare values,
|
||||
returning an appropriate exit code. The bash shell
|
||||
has test built in, ash can build it in optionally.
|
||||
|
||||
config FEATURE_TEST_64
|
||||
bool "Extend test to 64 bit"
|
||||
default n
|
||||
depends on TEST || ASH_BUILTIN_TEST || HUSH
|
||||
help
|
||||
Enable 64-bit support in test.
|
||||
|
||||
config TOUCH
|
||||
bool "touch"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
touch is used to create or change the access and/or
|
||||
modification timestamp of specified files.
|
||||
|
||||
config TR
|
||||
bool "tr"
|
||||
default n
|
||||
help
|
||||
tr is used to squeeze, and/or delete characters from standard
|
||||
input, writing to standard output.
|
||||
|
||||
config FEATURE_TR_CLASSES
|
||||
bool "Enable character classes (such as [:upper:])"
|
||||
default n
|
||||
depends on TR
|
||||
help
|
||||
Enable character classes, enabling commands such as:
|
||||
tr [:upper:] [:lower:] to convert input into lowercase.
|
||||
|
||||
config FEATURE_TR_EQUIV
|
||||
bool "Enable equivalence classes"
|
||||
default n
|
||||
depends on TR
|
||||
help
|
||||
Enable equivalence classes, which essentially add the enclosed
|
||||
character to the current set. For instance, tr [=a=] xyz would
|
||||
replace all instances of 'a' with 'xyz'. This option is mainly
|
||||
useful for cases when no other way of expressing a character
|
||||
is possible.
|
||||
|
||||
config TRUE
|
||||
bool "true"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
true returns an exit code of TRUE (0).
|
||||
|
||||
config TTY
|
||||
bool "tty"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
tty is used to print the name of the current terminal to
|
||||
standard output.
|
||||
|
||||
config UNAME
|
||||
bool "uname"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
uname is used to print system information.
|
||||
|
||||
config UNEXPAND
|
||||
bool "unexpand"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
By default, convert only leading sequences of blanks to tabs.
|
||||
|
||||
config FEATURE_UNEXPAND_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
default y
|
||||
depends on UNEXPAND && LONG_OPTS
|
||||
help
|
||||
Support long options for the unexpand applet.
|
||||
|
||||
config UNIQ
|
||||
bool "uniq"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
uniq is used to remove duplicate lines from a sorted file.
|
||||
|
||||
config USLEEP
|
||||
bool "usleep"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
usleep is used to pause for a specified number of microseconds.
|
||||
|
||||
config UUDECODE
|
||||
bool "uudecode"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
uudecode is used to decode a uuencoded file.
|
||||
|
||||
config UUENCODE
|
||||
bool "uuencode"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
uuencode is used to uuencode a file.
|
||||
|
||||
config WC
|
||||
bool "wc"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
wc is used to print the number of bytes, words, and lines,
|
||||
in specified files.
|
||||
|
||||
config FEATURE_WC_LARGE
|
||||
bool "Support very large files in wc"
|
||||
default n
|
||||
default y
|
||||
depends on WC
|
||||
help
|
||||
Use "unsigned long long" in wc for counter variables.
|
||||
|
||||
config WHO
|
||||
bool "who"
|
||||
default n
|
||||
select FEATURE_UTMP
|
||||
default y
|
||||
depends on FEATURE_UTMP
|
||||
help
|
||||
who is used to show who is logged on.
|
||||
|
||||
config WHOAMI
|
||||
bool "whoami"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
whoami is used to print the username of the current
|
||||
user id (same as id -un).
|
||||
|
||||
config YES
|
||||
bool "yes"
|
||||
default n
|
||||
default y
|
||||
help
|
||||
yes is used to repeatedly output a specific string, or
|
||||
the default string `y'.
|
||||
@@ -840,7 +763,7 @@ comment "Common options for cp and mv"
|
||||
|
||||
config FEATURE_PRESERVE_HARDLINKS
|
||||
bool "Preserve hard links"
|
||||
default n
|
||||
default y
|
||||
depends on CP || MV
|
||||
help
|
||||
Allow cp and mv to preserve hard links.
|
||||
@@ -864,7 +787,7 @@ comment "Common options for df, du, ls"
|
||||
|
||||
config FEATURE_HUMAN_READABLE
|
||||
bool "Support for human readable output (example 13k, 23M, 235G)"
|
||||
default n
|
||||
default y
|
||||
depends on DF || DU || LS
|
||||
help
|
||||
Allow df, du, and ls to have human readable output.
|
||||
@@ -874,7 +797,7 @@ comment "Common options for md5sum, sha1sum, sha256sum, sha512sum"
|
||||
|
||||
config FEATURE_MD5_SHA1_SUM_CHECK
|
||||
bool "Enable -c, -s and -w options"
|
||||
default n
|
||||
default y
|
||||
depends on MD5SUM || SHA1SUM || SHA256SUM || SHA512SUM
|
||||
help
|
||||
Enabling the -c options allows files to be checked
|
||||
@@ -7,22 +7,20 @@
|
||||
libs-y += libcoreutils/
|
||||
|
||||
lib-y:=
|
||||
lib-$(CONFIG_BASENAME) += basename.o
|
||||
|
||||
INSERT
|
||||
lib-$(CONFIG_CAL) += cal.o
|
||||
lib-$(CONFIG_CAT) += cat.o
|
||||
lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
|
||||
lib-$(CONFIG_LESS) += cat.o # less too
|
||||
lib-$(CONFIG_CRONTAB) += cat.o # crontab -l
|
||||
lib-$(CONFIG_CATV) += catv.o
|
||||
lib-$(CONFIG_CHGRP) += chgrp.o chown.o
|
||||
lib-$(CONFIG_CHMOD) += chmod.o
|
||||
lib-$(CONFIG_CHOWN) += chown.o
|
||||
lib-$(CONFIG_ADDUSER) += chown.o # used by adduser
|
||||
lib-$(CONFIG_ADDGROUP) += chown.o # used by adduser
|
||||
lib-$(CONFIG_CHROOT) += chroot.o
|
||||
lib-$(CONFIG_CKSUM) += cksum.o
|
||||
lib-$(CONFIG_COMM) += comm.o
|
||||
lib-$(CONFIG_CP) += cp.o
|
||||
lib-$(CONFIG_CUT) += cut.o
|
||||
lib-$(CONFIG_DATE) += date.o
|
||||
lib-$(CONFIG_DD) += dd.o
|
||||
lib-$(CONFIG_DF) += df.o
|
||||
lib-$(CONFIG_DIRNAME) += dirname.o
|
||||
@@ -76,12 +74,7 @@ lib-$(CONFIG_SYNC) += sync.o
|
||||
lib-$(CONFIG_TAC) += tac.o
|
||||
lib-$(CONFIG_TAIL) += tail.o
|
||||
lib-$(CONFIG_TEE) += tee.o
|
||||
lib-$(CONFIG_TEST) += test.o test_ptr_hack.o
|
||||
lib-$(CONFIG_ASH) += test.o test_ptr_hack.o # used by ash
|
||||
lib-$(CONFIG_HUSH) += test.o test_ptr_hack.o # used by hush
|
||||
lib-$(CONFIG_MSH) += test.o test_ptr_hack.o # used by msh
|
||||
lib-$(CONFIG_TOUCH) += touch.o
|
||||
lib-$(CONFIG_TR) += tr.o
|
||||
lib-$(CONFIG_TRUE) += true.o
|
||||
lib-$(CONFIG_TTY) += tty.o
|
||||
lib-$(CONFIG_UNAME) += uname.o
|
||||
+15
-7
@@ -5,13 +5,8 @@
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */
|
||||
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Changes:
|
||||
@@ -20,6 +15,19 @@
|
||||
* 3) Save some space by using strcmp(). Calling strncmp() here was silly.
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */
|
||||
|
||||
//kbuild:lib-$(CONFIG_BASENAME) += basename.o
|
||||
|
||||
//config:config BASENAME
|
||||
//config: bool "basename"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: basename is used to strip the directory and suffix from filenames,
|
||||
//config: leaving just the filename itself. Enable this option if you wish
|
||||
//config: to enable the 'basename' utility.
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
@@ -30,7 +38,7 @@ int basename_main(int argc, char **argv)
|
||||
size_t m, n;
|
||||
char *s;
|
||||
|
||||
if (((unsigned int)(argc-2)) >= 2) {
|
||||
if ((unsigned)(argc-2) >= 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
@@ -40,7 +48,7 @@ int basename_main(int argc, char **argv)
|
||||
m = strlen(s);
|
||||
if (*++argv) {
|
||||
n = strlen(*argv);
|
||||
if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) {
|
||||
if ((m > n) && (strcmp(s+m-n, *argv) == 0)) {
|
||||
m -= n;
|
||||
/*s[m] = '\0'; - redundant */
|
||||
}
|
||||
|
||||
+9
-6
@@ -87,8 +87,8 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* "Su Mo Tu We Th Fr Sa" */
|
||||
/* -j heading: */
|
||||
/* " Su Mo Tu We Th Fr Sa" */
|
||||
char day_headings[ENABLE_FEATURE_ASSUME_UNICODE ? 28 * 6 : 28];
|
||||
IF_FEATURE_ASSUME_UNICODE(char *hp = day_headings;)
|
||||
char day_headings[ENABLE_UNICODE_SUPPORT ? 28 * 6 : 28];
|
||||
IF_UNICODE_SUPPORT(char *hp = day_headings;)
|
||||
char buf[40];
|
||||
|
||||
init_unicode();
|
||||
@@ -113,7 +113,10 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (argv[2]) {
|
||||
bb_show_usage();
|
||||
}
|
||||
month = xatou_range(*argv++, 1, 12);
|
||||
if (!(flags & 2)) { /* no -y */
|
||||
month = xatou_range(*argv, 1, 12);
|
||||
}
|
||||
argv++;
|
||||
}
|
||||
year = xatou_range(*argv, 1, 9999);
|
||||
}
|
||||
@@ -131,11 +134,11 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
|
||||
zero_tm.tm_wday = i;
|
||||
/* abbreviated weekday name according to locale */
|
||||
strftime(buf, sizeof(buf), "%a", &zero_tm);
|
||||
#if ENABLE_FEATURE_ASSUME_UNICODE
|
||||
#if ENABLE_UNICODE_SUPPORT
|
||||
if (julian)
|
||||
*hp++ = ' ';
|
||||
{
|
||||
char *two_wchars = unicode_cut_nchars(2, buf);
|
||||
char *two_wchars = unicode_conv_to_printable_fixedwidth(NULL, buf, 2);
|
||||
strcpy(hp, two_wchars);
|
||||
free(two_wchars);
|
||||
}
|
||||
@@ -146,7 +149,7 @@ int cal_main(int argc UNUSED_PARAM, char **argv)
|
||||
#endif
|
||||
}
|
||||
} while (++i < 12);
|
||||
IF_FEATURE_ASSUME_UNICODE(hp[-1] = '\0';)
|
||||
IF_UNICODE_SUPPORT(hp[-1] = '\0';)
|
||||
|
||||
if (month) {
|
||||
unsigned row, len, days[MAXDAYS];
|
||||
|
||||
@@ -10,6 +10,18 @@
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
|
||||
|
||||
//kbuild:lib-$(CONFIG_CAT) += cat.o
|
||||
//kbuild:lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
|
||||
//kbuild:lib-$(CONFIG_LESS) += cat.o # less too
|
||||
//kbuild:lib-$(CONFIG_CRONTAB) += cat.o # crontab -l
|
||||
|
||||
//config:config CAT
|
||||
//config: bool "cat"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: cat is used to concatenate files and print them to the standard
|
||||
//config: output. Enable this option if you wish to enable the 'cat' utility.
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf, void
|
||||
newmode = statbuf->st_mode;
|
||||
|
||||
if (!bb_parse_mode((char *)param, &newmode))
|
||||
bb_error_msg_and_die("invalid mode: %s", (char *)param);
|
||||
bb_error_msg_and_die("invalid mode '%s'", (char *)param);
|
||||
|
||||
if (chmod(fileName, newmode) == 0) {
|
||||
if (OPT_VERBOSE
|
||||
|
||||
+6
-5
@@ -62,8 +62,8 @@ static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf,
|
||||
{
|
||||
#define param (*(struct param_t*)vparam)
|
||||
#define opt option_mask32
|
||||
uid_t u = (param.ugid.uid == (uid_t)-1) ? statbuf->st_uid : param.ugid.uid;
|
||||
gid_t g = (param.ugid.gid == (gid_t)-1) ? statbuf->st_gid : param.ugid.gid;
|
||||
uid_t u = (param.ugid.uid == (uid_t)-1L) ? statbuf->st_uid : param.ugid.uid;
|
||||
gid_t g = (param.ugid.gid == (gid_t)-1L) ? statbuf->st_gid : param.ugid.gid;
|
||||
|
||||
if (param.chown_func(fileName, u, g) == 0) {
|
||||
if (OPT_VERBOSE
|
||||
@@ -75,7 +75,7 @@ static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf,
|
||||
return TRUE;
|
||||
}
|
||||
if (!OPT_QUIET)
|
||||
bb_simple_perror_msg(fileName); /* A filename can have % in it... */
|
||||
bb_simple_perror_msg(fileName);
|
||||
return FALSE;
|
||||
#undef opt
|
||||
#undef param
|
||||
@@ -87,8 +87,9 @@ int chown_main(int argc UNUSED_PARAM, char **argv)
|
||||
int opt, flags;
|
||||
struct param_t param;
|
||||
|
||||
param.ugid.uid = -1;
|
||||
param.ugid.gid = -1;
|
||||
/* Just -1 might not work: uid_t may be unsigned long */
|
||||
param.ugid.uid = -1L;
|
||||
param.ugid.gid = -1L;
|
||||
|
||||
#if ENABLE_FEATURE_CHOWN_LONG_OPTIONS
|
||||
applet_long_options = chown_longopts;
|
||||
|
||||
+1
-2
@@ -30,6 +30,5 @@ int chroot_main(int argc UNUSED_PARAM, char **argv)
|
||||
argv[1] = (char *) "-i";
|
||||
}
|
||||
|
||||
BB_EXECVP(*argv, argv);
|
||||
bb_perror_msg_and_die("can't execute '%s'", *argv);
|
||||
BB_EXECVP_or_die(argv);
|
||||
}
|
||||
+99
-6
@@ -51,7 +51,51 @@
|
||||
* and does not support -Ins
|
||||
* -D FMT is a bbox extension for _input_ conversion of -d DATE
|
||||
*/
|
||||
|
||||
//kbuild:lib-$(CONFIG_DATE) += date.o
|
||||
|
||||
//config:config DATE
|
||||
//config: bool "date"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: date is used to set the system date or display the
|
||||
//config: current time in the given format.
|
||||
//config:
|
||||
//config:config FEATURE_DATE_ISOFMT
|
||||
//config: bool "Enable ISO date format output (-I)"
|
||||
//config: default y
|
||||
//config: depends on DATE
|
||||
//config: help
|
||||
//config: Enable option (-I) to output an ISO-8601 compliant
|
||||
//config: date/time string.
|
||||
//config:
|
||||
//config:config FEATURE_DATE_NANO
|
||||
//config: bool "Support %[num]N nanosecond format specifier"
|
||||
//config: default n
|
||||
//config: depends on DATE
|
||||
//config: help
|
||||
//config: Support %[num]N format specifier. Adds ~250 bytes of code.
|
||||
//config:
|
||||
//config:config FEATURE_DATE_COMPAT
|
||||
//config: bool "Support weird 'date MMDDhhmm[[YY]YY][.ss]' format"
|
||||
//config: default y
|
||||
//config: depends on DATE
|
||||
//config: help
|
||||
//config: System time can be set by 'date -s DATE' and simply 'date DATE',
|
||||
//config: but formats of DATE string are different. 'date DATE' accepts
|
||||
//config: a rather weird MMDDhhmm[[YY]YY][.ss] format with completely
|
||||
//config: unnatural placement of year between minutes and seconds.
|
||||
//config: date -s (and other commands like touch -d) use more sensible
|
||||
//config: formats (for one, ISO format YYYY-MM-DD hh:mm:ss.ssssss).
|
||||
//config:
|
||||
//config: With this option off, 'date DATE' is 'date -s DATE' support
|
||||
//config: the same format. With it on, 'date DATE' additionally supports
|
||||
//config: MMDDhhmm[[YY]YY][.ss] format.
|
||||
|
||||
#include "libbb.h"
|
||||
#if ENABLE_FEATURE_DATE_NANO
|
||||
# include <sys/syscall.h>
|
||||
#endif
|
||||
|
||||
enum {
|
||||
OPT_RFC2822 = (1 << 0), /* R */
|
||||
@@ -84,9 +128,9 @@ static const char date_longopts[] ALIGN1 =
|
||||
int date_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
struct timespec ts;
|
||||
struct tm tm_time;
|
||||
char buf_fmt_dt2str[64];
|
||||
time_t tm;
|
||||
unsigned opt;
|
||||
int ifmt = -1;
|
||||
char *date_str;
|
||||
@@ -161,11 +205,20 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (opt & OPT_REFERENCE) {
|
||||
struct stat statbuf;
|
||||
xstat(filename, &statbuf);
|
||||
tm = statbuf.st_mtime;
|
||||
ts.tv_sec = statbuf.st_mtime;
|
||||
#if ENABLE_FEATURE_DATE_NANO
|
||||
ts.tv_nsec = statbuf.st_mtim.tv_nsec;
|
||||
#endif
|
||||
} else {
|
||||
time(&tm);
|
||||
#if ENABLE_FEATURE_DATE_NANO
|
||||
/* libc has incredibly messy way of doing this,
|
||||
* typically requiring -lrt. We just skip all this mess */
|
||||
syscall(__NR_clock_gettime, CLOCK_REALTIME, &ts);
|
||||
#else
|
||||
time(&ts.tv_sec);
|
||||
#endif
|
||||
}
|
||||
localtime_r(&tm, &tm_time);
|
||||
localtime_r(&ts.tv_sec, &tm_time);
|
||||
|
||||
/* If date string is given, update tm_time, and maybe set date */
|
||||
if (date_str != NULL) {
|
||||
@@ -184,12 +237,12 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
/* Correct any day of week and day of year etc. fields */
|
||||
tm_time.tm_isdst = -1; /* Be sure to recheck dst */
|
||||
tm = validate_tm_time(date_str, &tm_time);
|
||||
ts.tv_sec = validate_tm_time(date_str, &tm_time);
|
||||
|
||||
maybe_set_utc(opt);
|
||||
|
||||
/* if setting time, set it */
|
||||
if ((opt & OPT_SET) && stime(&tm) < 0) {
|
||||
if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) {
|
||||
bb_perror_msg("can't set date");
|
||||
}
|
||||
}
|
||||
@@ -222,6 +275,46 @@ int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y";
|
||||
}
|
||||
}
|
||||
#if ENABLE_FEATURE_DATE_NANO
|
||||
else {
|
||||
/* User-specified fmt_dt2str */
|
||||
/* Search for and process "%N" */
|
||||
char *p = fmt_dt2str;
|
||||
while ((p = strchr(p, '%')) != NULL) {
|
||||
int n, m;
|
||||
unsigned pres, scale;
|
||||
|
||||
p++;
|
||||
if (*p == '%') {
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
n = strspn(p, "0123456789");
|
||||
if (p[n] != 'N') {
|
||||
p += n;
|
||||
continue;
|
||||
}
|
||||
/* We have "%[nnn]N" */
|
||||
p[-1] = '\0';
|
||||
p[n] = '\0';
|
||||
scale = 1;
|
||||
pres = 9;
|
||||
if (n) {
|
||||
pres = xatoi_u(p);
|
||||
if (pres == 0)
|
||||
pres = 9;
|
||||
m = 9 - pres;
|
||||
while (--m >= 0)
|
||||
scale *= 10;
|
||||
}
|
||||
|
||||
m = p - fmt_dt2str;
|
||||
p += n + 1;
|
||||
fmt_dt2str = xasprintf("%s%0*u%s", fmt_dt2str, pres, (unsigned)ts.tv_nsec / scale, p);
|
||||
p = fmt_dt2str + m;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#define date_buf bb_common_bufsiz1
|
||||
if (*fmt_dt2str == '\0') {
|
||||
|
||||
+6
-3
@@ -38,7 +38,7 @@ struct globals {
|
||||
unsigned long long total_bytes;
|
||||
unsigned long long begin_time_us;
|
||||
#endif
|
||||
};
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define INIT_G() do { \
|
||||
/* we have to zero it out because of NOEXEC */ \
|
||||
@@ -301,9 +301,12 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (ftruncate(ofd, seek * obs) < 0) {
|
||||
struct stat st;
|
||||
|
||||
if (fstat(ofd, &st) < 0 || S_ISREG(st.st_mode) ||
|
||||
S_ISDIR(st.st_mode))
|
||||
if (fstat(ofd, &st) < 0
|
||||
|| S_ISREG(st.st_mode)
|
||||
|| S_ISDIR(st.st_mode)
|
||||
) {
|
||||
goto die_outfile;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
+10
-9
@@ -114,9 +114,6 @@ int df_main(int argc UNUSED_PARAM, char **argv)
|
||||
while (1) {
|
||||
const char *device;
|
||||
const char *mount_point;
|
||||
#if ENABLE_FEATURE_ASSUME_UNICODE
|
||||
size_t dev_len;
|
||||
#endif
|
||||
|
||||
if (mount_table) {
|
||||
mount_entry = getmntent(mount_table);
|
||||
@@ -177,12 +174,16 @@ int df_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_ASSUME_UNICODE
|
||||
dev_len = unicode_strlen(device);
|
||||
if (dev_len > 20) {
|
||||
printf("%s\n%20s", device, "");
|
||||
} else {
|
||||
printf("%s%*s", device, 20 - (int)dev_len, "");
|
||||
#if ENABLE_UNICODE_SUPPORT
|
||||
{
|
||||
uni_stat_t uni_stat;
|
||||
char *uni_dev = unicode_conv_to_printable(&uni_stat, device);
|
||||
if (uni_stat.unicode_width > 20) {
|
||||
printf("%s\n%20s", uni_dev, "");
|
||||
} else {
|
||||
printf("%s%*s", uni_dev, 20 - (int)uni_stat.unicode_width, "");
|
||||
}
|
||||
free(uni_dev);
|
||||
}
|
||||
#else
|
||||
if (printf("\n%-20s" + 1, device) > 20)
|
||||
|
||||
@@ -92,7 +92,7 @@ int dos2unix_main(int argc UNUSED_PARAM, char **argv)
|
||||
do {
|
||||
/* might be convert(NULL) if there is no filename given */
|
||||
convert(*argv, conv_type);
|
||||
} while (*++argv);
|
||||
} while (*argv && *++argv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+1
-1
@@ -50,7 +50,7 @@ struct globals {
|
||||
int slink_depth;
|
||||
int du_depth;
|
||||
dev_t dir_dev;
|
||||
};
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
|
||||
|
||||
|
||||
+2
-5
@@ -76,11 +76,8 @@ int env_main(int argc UNUSED_PARAM, char **argv)
|
||||
++argv;
|
||||
}
|
||||
|
||||
if (*argv) {
|
||||
BB_EXECVP(*argv, argv);
|
||||
/* SUSv3-mandated exit codes. */
|
||||
xfunc_error_retval = (errno == ENOENT) ? 127 : 126;
|
||||
bb_simple_perror_msg_and_die(*argv);
|
||||
if (argv[0]) {
|
||||
BB_EXECVP_or_die(argv);
|
||||
}
|
||||
|
||||
if (environ) { /* clearenv() may set environ == NULL! */
|
||||
|
||||
+20
-11
@@ -48,8 +48,12 @@ static void expand(FILE *file, unsigned tab_size, unsigned opt)
|
||||
if (c == '\t') {
|
||||
unsigned len;
|
||||
*ptr = '\0';
|
||||
# if ENABLE_FEATURE_ASSUME_UNICODE
|
||||
len = unicode_strlen(ptr_strbeg);
|
||||
# if ENABLE_UNICODE_SUPPORT
|
||||
{
|
||||
uni_stat_t uni_stat;
|
||||
printable_string(&uni_stat, ptr_strbeg);
|
||||
len = uni_stat.unicode_width;
|
||||
}
|
||||
# else
|
||||
len = ptr - ptr_strbeg;
|
||||
# endif
|
||||
@@ -77,12 +81,13 @@ static void unexpand(FILE *file, unsigned tab_size, unsigned opt)
|
||||
|
||||
while (*ptr) {
|
||||
unsigned n;
|
||||
unsigned len;
|
||||
unsigned len = 0;
|
||||
|
||||
while (*ptr == ' ') {
|
||||
column++;
|
||||
ptr++;
|
||||
len++;
|
||||
}
|
||||
column += len;
|
||||
if (*ptr == '\t') {
|
||||
column += tab_size - (column % tab_size);
|
||||
ptr++;
|
||||
@@ -90,22 +95,26 @@ static void unexpand(FILE *file, unsigned tab_size, unsigned opt)
|
||||
}
|
||||
|
||||
n = column / tab_size;
|
||||
column = column % tab_size;
|
||||
while (n--)
|
||||
putchar('\t');
|
||||
if (n) {
|
||||
len = column = column % tab_size;
|
||||
while (n--)
|
||||
putchar('\t');
|
||||
}
|
||||
|
||||
if ((opt & OPT_INITIAL) && ptr != line) {
|
||||
printf("%*s%s", column, "", ptr);
|
||||
printf("%*s%s", len, "", ptr);
|
||||
break;
|
||||
}
|
||||
n = strcspn(ptr, "\t ");
|
||||
printf("%*s%.*s", column, "", n, ptr);
|
||||
# if ENABLE_FEATURE_ASSUME_UNICODE
|
||||
printf("%*s%.*s", len, "", n, ptr);
|
||||
# if ENABLE_UNICODE_SUPPORT
|
||||
{
|
||||
char c;
|
||||
uni_stat_t uni_stat;
|
||||
c = ptr[n];
|
||||
ptr[n] = '\0';
|
||||
len = unicode_strlen(ptr);
|
||||
printable_string(&uni_stat, ptr);
|
||||
len = uni_stat.unicode_width;
|
||||
ptr[n] = c;
|
||||
}
|
||||
# else
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ typedef struct valinfo VALUE;
|
||||
/* The arguments given to the program, minus the program name. */
|
||||
struct globals {
|
||||
char **args;
|
||||
};
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
|
||||
/* forward declarations */
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#ifndef O_NOATIME
|
||||
# define O_NOATIME 0
|
||||
#endif
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
|
||||
+1
-7
@@ -20,16 +20,14 @@ static const char head_opts[] ALIGN1 =
|
||||
#endif
|
||||
;
|
||||
|
||||
#if ENABLE_FEATURE_FANCY_HEAD
|
||||
static const struct suffix_mult head_suffixes[] = {
|
||||
{ "b", 512 },
|
||||
{ "k", 1024 },
|
||||
{ "m", 1024*1024 },
|
||||
{ "", 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
static const char header_fmt_str[] ALIGN1 = "\n==> %s <==\n";
|
||||
#define header_fmt_str "\n==> %s <==\n"
|
||||
|
||||
int head_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int head_main(int argc, char **argv)
|
||||
@@ -78,11 +76,7 @@ int head_main(int argc, char **argv)
|
||||
#if ENABLE_INCLUDE_SUSv2 || ENABLE_FEATURE_FANCY_HEAD
|
||||
GET_COUNT:
|
||||
#endif
|
||||
#if !ENABLE_FEATURE_FANCY_HEAD
|
||||
count = xatoul(p);
|
||||
#else
|
||||
count = xatoul_sfx(p, head_suffixes);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
|
||||
+14
-13
@@ -50,7 +50,7 @@ static void setdefaultfilecon(const char *path)
|
||||
|
||||
if (lsetfilecon(path, scontext) < 0) {
|
||||
if (errno != ENOTSUP) {
|
||||
bb_perror_msg("warning: failed to change context"
|
||||
bb_perror_msg("warning: can't change context"
|
||||
" of %s to %s", path, scontext);
|
||||
}
|
||||
}
|
||||
@@ -167,12 +167,23 @@ int install_main(int argc, char **argv)
|
||||
free(ddir);
|
||||
}
|
||||
if (isdir)
|
||||
dest = concat_path_file(last, basename(arg));
|
||||
if (copy_file(arg, dest, copy_flags)) {
|
||||
dest = concat_path_file(last, bb_basename(arg));
|
||||
if (copy_file(arg, dest, copy_flags) != 0) {
|
||||
/* copy is not made */
|
||||
ret = EXIT_FAILURE;
|
||||
goto next;
|
||||
}
|
||||
if (opts & OPT_STRIP) {
|
||||
char *args[4];
|
||||
args[0] = (char*)"strip";
|
||||
args[1] = (char*)"-p"; /* -p --preserve-dates */
|
||||
args[2] = dest;
|
||||
args[3] = NULL;
|
||||
if (spawn_and_wait(args)) {
|
||||
bb_perror_msg("strip");
|
||||
ret = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the file mode (always, not only with -m).
|
||||
@@ -192,16 +203,6 @@ int install_main(int argc, char **argv)
|
||||
bb_perror_msg("can't change %s of %s", "ownership", dest);
|
||||
ret = EXIT_FAILURE;
|
||||
}
|
||||
if (opts & OPT_STRIP) {
|
||||
char *args[3];
|
||||
args[0] = (char*)"strip";
|
||||
args[1] = dest;
|
||||
args[2] = NULL;
|
||||
if (spawn_and_wait(args)) {
|
||||
bb_perror_msg("strip");
|
||||
ret = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
next:
|
||||
if (ENABLE_FEATURE_CLEAN_UP && isdir)
|
||||
free(dest);
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
||||
|
||||
lib-y:=
|
||||
|
||||
INSERT
|
||||
lib-$(CONFIG_MKFIFO) += getopt_mk_fifo_nod.o
|
||||
lib-$(CONFIG_MKNOD) += getopt_mk_fifo_nod.o
|
||||
lib-$(CONFIG_INSTALL) += cp_mv_stat.o
|
||||
+246
-224
@@ -241,9 +241,6 @@ struct dnode {
|
||||
IF_SELINUX(security_context_t sid;)
|
||||
};
|
||||
|
||||
static struct dnode **list_dir(const char *, unsigned *);
|
||||
static unsigned list_single(const struct dnode *);
|
||||
|
||||
struct globals {
|
||||
#if ENABLE_FEATURE_LS_COLOR
|
||||
smallint show_color;
|
||||
@@ -258,7 +255,7 @@ struct globals {
|
||||
/* Do time() just once. Saves one syscall per file for "ls -l" */
|
||||
time_t current_time_t;
|
||||
#endif
|
||||
};
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#if ENABLE_FEATURE_LS_COLOR
|
||||
# define show_color (G.show_color )
|
||||
@@ -528,242 +525,66 @@ static void dnsort(struct dnode **dn, int size)
|
||||
#endif
|
||||
|
||||
|
||||
static void showfiles(struct dnode **dn, unsigned nfiles)
|
||||
static unsigned calc_name_len(const char *name)
|
||||
{
|
||||
unsigned i, ncols, nrows, row, nc;
|
||||
unsigned column = 0;
|
||||
unsigned nexttab = 0;
|
||||
unsigned column_width = 0; /* for STYLE_LONG and STYLE_SINGLE not used */
|
||||
unsigned len;
|
||||
uni_stat_t uni_stat;
|
||||
|
||||
/* Never happens:
|
||||
if (dn == NULL || nfiles < 1)
|
||||
return;
|
||||
*/
|
||||
// TODO: quote tab as \t, etc, if -Q
|
||||
name = printable_string(&uni_stat, name);
|
||||
|
||||
if (all_fmt & STYLE_LONG) {
|
||||
ncols = 1;
|
||||
} else {
|
||||
/* find the longest file name, use that as the column width */
|
||||
for (i = 0; dn[i]; i++) {
|
||||
int len = unicode_strlen(dn[i]->name);
|
||||
if (column_width < len)
|
||||
column_width = len;
|
||||
if (!(option_mask32 & OPT_Q)) {
|
||||
return uni_stat.unicode_width;
|
||||
}
|
||||
|
||||
len = 2 + uni_stat.unicode_width;
|
||||
while (*name) {
|
||||
if (*name == '"' || *name == '\\') {
|
||||
len++;
|
||||
}
|
||||
column_width += tabstops +
|
||||
IF_SELINUX( ((all_fmt & LIST_CONTEXT) ? 33 : 0) + )
|
||||
((all_fmt & LIST_INO) ? 8 : 0) +
|
||||
((all_fmt & LIST_BLOCKS) ? 5 : 0);
|
||||
ncols = (int) (terminal_width / column_width);
|
||||
}
|
||||
|
||||
if (ncols > 1) {
|
||||
nrows = nfiles / ncols;
|
||||
if (nrows * ncols < nfiles)
|
||||
nrows++; /* round up fractionals */
|
||||
} else {
|
||||
nrows = nfiles;
|
||||
ncols = 1;
|
||||
}
|
||||
|
||||
for (row = 0; row < nrows; row++) {
|
||||
for (nc = 0; nc < ncols; nc++) {
|
||||
/* reach into the array based on the column and row */
|
||||
if (all_fmt & DISP_ROWS)
|
||||
i = (row * ncols) + nc; /* display across row */
|
||||
else
|
||||
i = (nc * nrows) + row; /* display by column */
|
||||
if (i < nfiles) {
|
||||
if (column > 0) {
|
||||
nexttab -= column;
|
||||
printf("%*s", nexttab, "");
|
||||
column += nexttab;
|
||||
}
|
||||
nexttab = column + column_width;
|
||||
column += list_single(dn[i]);
|
||||
}
|
||||
}
|
||||
putchar('\n');
|
||||
column = 0;
|
||||
name++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
#if ENABLE_DESKTOP
|
||||
/* http://www.opengroup.org/onlinepubs/9699919799/utilities/ls.html
|
||||
* If any of the -l, -n, -s options is specified, each list
|
||||
* of files within the directory shall be preceded by a
|
||||
* status line indicating the number of file system blocks
|
||||
* occupied by files in the directory in 512-byte units if
|
||||
* the -k option is not specified, or 1024-byte units if the
|
||||
* -k option is specified, rounded up to the next integral
|
||||
* number of units.
|
||||
/* Return the number of used columns.
|
||||
* Note that only STYLE_COLUMNS uses return value.
|
||||
* STYLE_SINGLE and STYLE_LONG don't care.
|
||||
* coreutils 7.2 also supports:
|
||||
* ls -b (--escape) = octal escapes (although it doesn't look like working)
|
||||
* ls -N (--literal) = not escape at all
|
||||
*/
|
||||
/* by Jorgen Overgaard (jorgen AT antistaten.se) */
|
||||
static off_t calculate_blocks(struct dnode **dn)
|
||||
static unsigned print_name(const char *name)
|
||||
{
|
||||
uoff_t blocks = 1;
|
||||
if (dn) {
|
||||
while (*dn) {
|
||||
/* st_blocks is in 512 byte blocks */
|
||||
blocks += (*dn)->dstat.st_blocks;
|
||||
dn++;
|
||||
}
|
||||
unsigned len;
|
||||
uni_stat_t uni_stat;
|
||||
|
||||
// TODO: quote tab as \t, etc, if -Q
|
||||
name = printable_string(&uni_stat, name);
|
||||
|
||||
if (!(option_mask32 & OPT_Q)) {
|
||||
fputs(name, stdout);
|
||||
return uni_stat.unicode_width;
|
||||
}
|
||||
|
||||
/* Even though standard says use 512 byte blocks, coreutils use 1k */
|
||||
/* Actually, we round up by calculating (blocks + 1) / 2,
|
||||
* "+ 1" was done when we initialized blocks to 1 */
|
||||
return blocks >> 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void showdirs(struct dnode **dn, int first)
|
||||
{
|
||||
unsigned nfiles;
|
||||
unsigned dndirs;
|
||||
struct dnode **subdnp;
|
||||
struct dnode **dnd;
|
||||
|
||||
/* Never happens:
|
||||
if (dn == NULL || ndirs < 1) {
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
for (; *dn; dn++) {
|
||||
if (all_fmt & (DISP_DIRNAME | DISP_RECURSIVE)) {
|
||||
if (!first)
|
||||
bb_putchar('\n');
|
||||
first = 0;
|
||||
printf("%s:\n", (*dn)->fullname);
|
||||
}
|
||||
subdnp = list_dir((*dn)->fullname, &nfiles);
|
||||
#if ENABLE_DESKTOP
|
||||
if ((all_fmt & STYLE_MASK) == STYLE_LONG)
|
||||
printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp));
|
||||
#endif
|
||||
if (nfiles > 0) {
|
||||
/* list all files at this level */
|
||||
dnsort(subdnp, nfiles);
|
||||
showfiles(subdnp, nfiles);
|
||||
if (ENABLE_FEATURE_LS_RECURSIVE
|
||||
&& (all_fmt & DISP_RECURSIVE)
|
||||
) {
|
||||
/* recursive - list the sub-dirs */
|
||||
dnd = splitdnarray(subdnp, SPLIT_SUBDIR);
|
||||
dndirs = count_dirs(subdnp, SPLIT_SUBDIR);
|
||||
if (dndirs > 0) {
|
||||
dnsort(dnd, dndirs);
|
||||
showdirs(dnd, 0);
|
||||
/* free the array of dnode pointers to the dirs */
|
||||
free(dnd);
|
||||
}
|
||||
}
|
||||
/* free the dnodes and the fullname mem */
|
||||
dfree(subdnp);
|
||||
len = 2 + uni_stat.unicode_width;
|
||||
putchar('"');
|
||||
while (*name) {
|
||||
if (*name == '"' || *name == '\\') {
|
||||
putchar('\\');
|
||||
len++;
|
||||
}
|
||||
putchar(*name++);
|
||||
}
|
||||
putchar('"');
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/* Returns NULL-terminated malloced vector of pointers (or NULL) */
|
||||
static struct dnode **list_dir(const char *path, unsigned *nfiles_p)
|
||||
{
|
||||
struct dnode *dn, *cur, **dnp;
|
||||
struct dirent *entry;
|
||||
DIR *dir;
|
||||
unsigned i, nfiles;
|
||||
|
||||
/* Never happens:
|
||||
if (path == NULL)
|
||||
return NULL;
|
||||
*/
|
||||
|
||||
*nfiles_p = 0;
|
||||
dir = warn_opendir(path);
|
||||
if (dir == NULL) {
|
||||
exit_code = EXIT_FAILURE;
|
||||
return NULL; /* could not open the dir */
|
||||
}
|
||||
dn = NULL;
|
||||
nfiles = 0;
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
char *fullname;
|
||||
|
||||
/* are we going to list the file- it may be . or .. or a hidden file */
|
||||
if (entry->d_name[0] == '.') {
|
||||
if ((!entry->d_name[1] || (entry->d_name[1] == '.' && !entry->d_name[2]))
|
||||
&& !(all_fmt & DISP_DOT)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (!(all_fmt & DISP_HIDDEN))
|
||||
continue;
|
||||
}
|
||||
fullname = concat_path_file(path, entry->d_name);
|
||||
cur = my_stat(fullname, bb_basename(fullname), 0);
|
||||
if (!cur) {
|
||||
free(fullname);
|
||||
continue;
|
||||
}
|
||||
cur->fname_allocated = 1;
|
||||
cur->next = dn;
|
||||
dn = cur;
|
||||
nfiles++;
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
if (dn == NULL)
|
||||
return NULL;
|
||||
|
||||
/* now that we know how many files there are
|
||||
* allocate memory for an array to hold dnode pointers
|
||||
*/
|
||||
*nfiles_p = nfiles;
|
||||
dnp = dnalloc(nfiles);
|
||||
for (i = 0; /* i < nfiles - detected via !dn below */; i++) {
|
||||
dnp[i] = dn; /* save pointer to node in array */
|
||||
dn = dn->next;
|
||||
if (!dn)
|
||||
break;
|
||||
}
|
||||
|
||||
return dnp;
|
||||
}
|
||||
|
||||
|
||||
static int print_name(const char *name)
|
||||
{
|
||||
if (option_mask32 & OPT_Q) {
|
||||
#if ENABLE_FEATURE_ASSUME_UNICODE
|
||||
unsigned len = 2 + unicode_strlen(name);
|
||||
#else
|
||||
unsigned len = 2;
|
||||
#endif
|
||||
putchar('"');
|
||||
while (*name) {
|
||||
if (*name == '"') {
|
||||
putchar('\\');
|
||||
len++;
|
||||
}
|
||||
putchar(*name++);
|
||||
if (!ENABLE_FEATURE_ASSUME_UNICODE)
|
||||
len++;
|
||||
}
|
||||
putchar('"');
|
||||
return len;
|
||||
}
|
||||
/* No -Q: */
|
||||
#if ENABLE_FEATURE_ASSUME_UNICODE
|
||||
fputs(name, stdout);
|
||||
return unicode_strlen(name);
|
||||
#else
|
||||
return printf("%s", name);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Return the number of used columns.
|
||||
* Note that only STYLE_COLUMNS uses return value,
|
||||
* STYLE_SINGLE and STYLE_LONG don't care.
|
||||
*/
|
||||
static NOINLINE unsigned list_single(const struct dnode *dn)
|
||||
{
|
||||
unsigned column = 0;
|
||||
@@ -914,6 +735,207 @@ static NOINLINE unsigned list_single(const struct dnode *dn)
|
||||
return column;
|
||||
}
|
||||
|
||||
static void showfiles(struct dnode **dn, unsigned nfiles)
|
||||
{
|
||||
unsigned i, ncols, nrows, row, nc;
|
||||
unsigned column = 0;
|
||||
unsigned nexttab = 0;
|
||||
unsigned column_width = 0; /* used only by STYLE_COLUMNS */
|
||||
|
||||
if (all_fmt & STYLE_LONG) { /* STYLE_LONG or STYLE_SINGLE */
|
||||
ncols = 1;
|
||||
} else {
|
||||
/* find the longest file name, use that as the column width */
|
||||
for (i = 0; dn[i]; i++) {
|
||||
int len = calc_name_len(dn[i]->name);
|
||||
if (column_width < len)
|
||||
column_width = len;
|
||||
}
|
||||
column_width += tabstops +
|
||||
IF_SELINUX( ((all_fmt & LIST_CONTEXT) ? 33 : 0) + )
|
||||
((all_fmt & LIST_INO) ? 8 : 0) +
|
||||
((all_fmt & LIST_BLOCKS) ? 5 : 0);
|
||||
ncols = (int) (terminal_width / column_width);
|
||||
}
|
||||
|
||||
if (ncols > 1) {
|
||||
nrows = nfiles / ncols;
|
||||
if (nrows * ncols < nfiles)
|
||||
nrows++; /* round up fractionals */
|
||||
} else {
|
||||
nrows = nfiles;
|
||||
ncols = 1;
|
||||
}
|
||||
|
||||
for (row = 0; row < nrows; row++) {
|
||||
for (nc = 0; nc < ncols; nc++) {
|
||||
/* reach into the array based on the column and row */
|
||||
if (all_fmt & DISP_ROWS)
|
||||
i = (row * ncols) + nc; /* display across row */
|
||||
else
|
||||
i = (nc * nrows) + row; /* display by column */
|
||||
if (i < nfiles) {
|
||||
if (column > 0) {
|
||||
nexttab -= column;
|
||||
printf("%*s", nexttab, "");
|
||||
column += nexttab;
|
||||
}
|
||||
nexttab = column + column_width;
|
||||
column += list_single(dn[i]);
|
||||
}
|
||||
}
|
||||
putchar('\n');
|
||||
column = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if ENABLE_DESKTOP
|
||||
/* http://www.opengroup.org/onlinepubs/9699919799/utilities/ls.html
|
||||
* If any of the -l, -n, -s options is specified, each list
|
||||
* of files within the directory shall be preceded by a
|
||||
* status line indicating the number of file system blocks
|
||||
* occupied by files in the directory in 512-byte units if
|
||||
* the -k option is not specified, or 1024-byte units if the
|
||||
* -k option is specified, rounded up to the next integral
|
||||
* number of units.
|
||||
*/
|
||||
/* by Jorgen Overgaard (jorgen AT antistaten.se) */
|
||||
static off_t calculate_blocks(struct dnode **dn)
|
||||
{
|
||||
uoff_t blocks = 1;
|
||||
if (dn) {
|
||||
while (*dn) {
|
||||
/* st_blocks is in 512 byte blocks */
|
||||
blocks += (*dn)->dstat.st_blocks;
|
||||
dn++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Even though standard says use 512 byte blocks, coreutils use 1k */
|
||||
/* Actually, we round up by calculating (blocks + 1) / 2,
|
||||
* "+ 1" was done when we initialized blocks to 1 */
|
||||
return blocks >> 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static struct dnode **list_dir(const char *, unsigned *);
|
||||
|
||||
static void showdirs(struct dnode **dn, int first)
|
||||
{
|
||||
unsigned nfiles;
|
||||
unsigned dndirs;
|
||||
struct dnode **subdnp;
|
||||
struct dnode **dnd;
|
||||
|
||||
/* Never happens:
|
||||
if (dn == NULL || ndirs < 1) {
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
for (; *dn; dn++) {
|
||||
if (all_fmt & (DISP_DIRNAME | DISP_RECURSIVE)) {
|
||||
if (!first)
|
||||
bb_putchar('\n');
|
||||
first = 0;
|
||||
printf("%s:\n", (*dn)->fullname);
|
||||
}
|
||||
subdnp = list_dir((*dn)->fullname, &nfiles);
|
||||
#if ENABLE_DESKTOP
|
||||
if ((all_fmt & STYLE_MASK) == STYLE_LONG)
|
||||
printf("total %"OFF_FMT"u\n", calculate_blocks(subdnp));
|
||||
#endif
|
||||
if (nfiles > 0) {
|
||||
/* list all files at this level */
|
||||
dnsort(subdnp, nfiles);
|
||||
showfiles(subdnp, nfiles);
|
||||
if (ENABLE_FEATURE_LS_RECURSIVE
|
||||
&& (all_fmt & DISP_RECURSIVE)
|
||||
) {
|
||||
/* recursive - list the sub-dirs */
|
||||
dnd = splitdnarray(subdnp, SPLIT_SUBDIR);
|
||||
dndirs = count_dirs(subdnp, SPLIT_SUBDIR);
|
||||
if (dndirs > 0) {
|
||||
dnsort(dnd, dndirs);
|
||||
showdirs(dnd, 0);
|
||||
/* free the array of dnode pointers to the dirs */
|
||||
free(dnd);
|
||||
}
|
||||
}
|
||||
/* free the dnodes and the fullname mem */
|
||||
dfree(subdnp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Returns NULL-terminated malloced vector of pointers (or NULL) */
|
||||
static struct dnode **list_dir(const char *path, unsigned *nfiles_p)
|
||||
{
|
||||
struct dnode *dn, *cur, **dnp;
|
||||
struct dirent *entry;
|
||||
DIR *dir;
|
||||
unsigned i, nfiles;
|
||||
|
||||
/* Never happens:
|
||||
if (path == NULL)
|
||||
return NULL;
|
||||
*/
|
||||
|
||||
*nfiles_p = 0;
|
||||
dir = warn_opendir(path);
|
||||
if (dir == NULL) {
|
||||
exit_code = EXIT_FAILURE;
|
||||
return NULL; /* could not open the dir */
|
||||
}
|
||||
dn = NULL;
|
||||
nfiles = 0;
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
char *fullname;
|
||||
|
||||
/* are we going to list the file- it may be . or .. or a hidden file */
|
||||
if (entry->d_name[0] == '.') {
|
||||
if ((!entry->d_name[1] || (entry->d_name[1] == '.' && !entry->d_name[2]))
|
||||
&& !(all_fmt & DISP_DOT)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
if (!(all_fmt & DISP_HIDDEN))
|
||||
continue;
|
||||
}
|
||||
fullname = concat_path_file(path, entry->d_name);
|
||||
cur = my_stat(fullname, bb_basename(fullname), 0);
|
||||
if (!cur) {
|
||||
free(fullname);
|
||||
continue;
|
||||
}
|
||||
cur->fname_allocated = 1;
|
||||
cur->next = dn;
|
||||
dn = cur;
|
||||
nfiles++;
|
||||
}
|
||||
closedir(dir);
|
||||
|
||||
if (dn == NULL)
|
||||
return NULL;
|
||||
|
||||
/* now that we know how many files there are
|
||||
* allocate memory for an array to hold dnode pointers
|
||||
*/
|
||||
*nfiles_p = nfiles;
|
||||
dnp = dnalloc(nfiles);
|
||||
for (i = 0; /* i < nfiles - detected via !dn below */; i++) {
|
||||
dnp[i] = dn; /* save pointer to node in array */
|
||||
dn = dn->next;
|
||||
if (!dn)
|
||||
break;
|
||||
}
|
||||
|
||||
return dnp;
|
||||
}
|
||||
|
||||
|
||||
int ls_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
|
||||
@@ -101,8 +101,10 @@ int md5_sha1_sum_main(int argc UNUSED_PARAM, char **argv)
|
||||
unsigned flags;
|
||||
/*hash_algo_t hash_algo = applet_name[3];*/
|
||||
|
||||
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK)
|
||||
flags = getopt32(argv, "scw");
|
||||
if (ENABLE_FEATURE_MD5_SHA1_SUM_CHECK) {
|
||||
/* -b "binary", -t "text" are ignored (shaNNNsum compat) */
|
||||
flags = getopt32(argv, "scwbt");
|
||||
}
|
||||
else optind = 1;
|
||||
argv += optind;
|
||||
//argc -= optind;
|
||||
|
||||
+1
-5
@@ -47,9 +47,5 @@ int nice_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
BB_EXECVP(*argv, argv); /* Now exec the desired program. */
|
||||
|
||||
/* The exec failed... */
|
||||
xfunc_error_retval = (errno == ENOENT) ? 127 : 126; /* SUSv3 */
|
||||
bb_simple_perror_msg_and_die(*argv);
|
||||
BB_EXECVP_or_die(argv);
|
||||
}
|
||||
+2
-2
@@ -75,6 +75,6 @@ int nohup_main(int argc UNUSED_PARAM, char **argv)
|
||||
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
|
||||
BB_EXECVP(argv[1], argv+1);
|
||||
bb_simple_perror_msg_and_die(argv[1]);
|
||||
argv++;
|
||||
BB_EXECVP_or_die(argv);
|
||||
}
|
||||
@@ -502,7 +502,7 @@ check_and_close(void)
|
||||
}
|
||||
|
||||
if (ferror(stdout)) {
|
||||
bb_error_msg("write error");
|
||||
bb_error_msg(bb_msg_write_error);
|
||||
ioerror = 1;
|
||||
}
|
||||
}
|
||||
@@ -521,7 +521,7 @@ check_and_close(void)
|
||||
S_ORIG is solely for reporting errors. It should be the full format
|
||||
string argument. */
|
||||
|
||||
static const char *
|
||||
static NOINLINE const char *
|
||||
decode_one_format(const char *s_orig, const char *s, struct tspec *tspec)
|
||||
{
|
||||
enum size_spec size_spec;
|
||||
|
||||
+3
-13
@@ -17,30 +17,20 @@ int realpath_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
#if PATH_MAX > (BUFSIZ+1)
|
||||
RESERVE_CONFIG_BUFFER(resolved_path, PATH_MAX);
|
||||
# define resolved_path_MUST_FREE 1
|
||||
#else
|
||||
#define resolved_path bb_common_bufsiz1
|
||||
# define resolved_path_MUST_FREE 0
|
||||
#endif
|
||||
|
||||
if (!*++argv) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
do {
|
||||
if (realpath(*argv, resolved_path) != NULL) {
|
||||
char *resolved_path = xmalloc_realpath(*argv);
|
||||
if (resolved_path != NULL) {
|
||||
puts(resolved_path);
|
||||
free(resolved_path);
|
||||
} else {
|
||||
retval = EXIT_FAILURE;
|
||||
bb_simple_perror_msg(*argv);
|
||||
}
|
||||
} while (*++argv);
|
||||
|
||||
#if ENABLE_FEATURE_CLEAN_UP && resolved_path_MUST_FREE
|
||||
RELEASE_CONFIG_BUFFER(resolved_path);
|
||||
#endif
|
||||
|
||||
fflush_stdout_and_exit(retval);
|
||||
}
|
||||
+112
-110
@@ -12,10 +12,8 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
/* vars to control behavior */
|
||||
#define OPT_FILESYS (1 << 0)
|
||||
#define OPT_TERSE (1 << 1)
|
||||
#define OPT_DEREFERENCE (1 << 2)
|
||||
@@ -154,7 +152,7 @@ static void printfs(char *pformat, const char *msg)
|
||||
}
|
||||
|
||||
/* print statfs info */
|
||||
static void print_statfs(char *pformat, const char m,
|
||||
static void FAST_FUNC print_statfs(char *pformat, const char m,
|
||||
const char *const filename, const void *data
|
||||
IF_SELINUX(, security_context_t scontext))
|
||||
{
|
||||
@@ -166,34 +164,34 @@ static void print_statfs(char *pformat, const char m,
|
||||
printf(pformat, get_f_fsid(statfsbuf));
|
||||
} else if (m == 'l') {
|
||||
strcat(pformat, "lu");
|
||||
printf(pformat, (unsigned long) (statfsbuf->f_namelen));
|
||||
printf(pformat, (unsigned long) statfsbuf->f_namelen);
|
||||
} else if (m == 't') {
|
||||
strcat(pformat, "lx");
|
||||
printf(pformat, (unsigned long) (statfsbuf->f_type)); /* no equiv */
|
||||
printf(pformat, (unsigned long) statfsbuf->f_type); /* no equiv */
|
||||
} else if (m == 'T') {
|
||||
printfs(pformat, human_fstype(statfsbuf->f_type));
|
||||
} else if (m == 'b') {
|
||||
strcat(pformat, "jd");
|
||||
printf(pformat, (intmax_t) (statfsbuf->f_blocks));
|
||||
strcat(pformat, "llu");
|
||||
printf(pformat, (unsigned long long) statfsbuf->f_blocks);
|
||||
} else if (m == 'f') {
|
||||
strcat(pformat, "jd");
|
||||
printf(pformat, (intmax_t) (statfsbuf->f_bfree));
|
||||
strcat(pformat, "llu");
|
||||
printf(pformat, (unsigned long long) statfsbuf->f_bfree);
|
||||
} else if (m == 'a') {
|
||||
strcat(pformat, "jd");
|
||||
printf(pformat, (intmax_t) (statfsbuf->f_bavail));
|
||||
strcat(pformat, "llu");
|
||||
printf(pformat, (unsigned long long) statfsbuf->f_bavail);
|
||||
} else if (m == 's' || m == 'S') {
|
||||
strcat(pformat, "lu");
|
||||
printf(pformat, (unsigned long) (statfsbuf->f_bsize));
|
||||
printf(pformat, (unsigned long) statfsbuf->f_bsize);
|
||||
} else if (m == 'c') {
|
||||
strcat(pformat, "jd");
|
||||
printf(pformat, (intmax_t) (statfsbuf->f_files));
|
||||
strcat(pformat, "llu");
|
||||
printf(pformat, (unsigned long long) statfsbuf->f_files);
|
||||
} else if (m == 'd') {
|
||||
strcat(pformat, "jd");
|
||||
printf(pformat, (intmax_t) (statfsbuf->f_ffree));
|
||||
#if ENABLE_SELINUX
|
||||
strcat(pformat, "llu");
|
||||
printf(pformat, (unsigned long long) statfsbuf->f_ffree);
|
||||
# if ENABLE_SELINUX
|
||||
} else if (m == 'C' && (option_mask32 & OPT_SELINUX)) {
|
||||
printfs(pformat, scontext);
|
||||
#endif
|
||||
# endif
|
||||
} else {
|
||||
strcatc(pformat, 'c');
|
||||
printf(pformat, m);
|
||||
@@ -201,7 +199,7 @@ static void print_statfs(char *pformat, const char m,
|
||||
}
|
||||
|
||||
/* print stat info */
|
||||
static void print_stat(char *pformat, const char m,
|
||||
static void FAST_FUNC print_stat(char *pformat, const char m,
|
||||
const char *const filename, const void *data
|
||||
IF_SELINUX(, security_context_t scontext))
|
||||
{
|
||||
@@ -218,23 +216,20 @@ static void print_stat(char *pformat, const char m,
|
||||
char *linkname = xmalloc_readlink_or_warn(filename);
|
||||
if (linkname == NULL)
|
||||
return;
|
||||
/*printf("\"%s\" -> \"%s\"", filename, linkname); */
|
||||
printf(pformat, filename);
|
||||
printf(" -> ");
|
||||
printf(pformat, linkname);
|
||||
printf("'%s' -> '%s'", filename, linkname);
|
||||
free(linkname);
|
||||
} else {
|
||||
printf(pformat, filename);
|
||||
}
|
||||
} else if (m == 'd') {
|
||||
strcat(pformat, "ju");
|
||||
printf(pformat, (uintmax_t) statbuf->st_dev);
|
||||
strcat(pformat, "llu");
|
||||
printf(pformat, (unsigned long long) statbuf->st_dev);
|
||||
} else if (m == 'D') {
|
||||
strcat(pformat, "jx");
|
||||
printf(pformat, (uintmax_t) statbuf->st_dev);
|
||||
strcat(pformat, "llx");
|
||||
printf(pformat, (unsigned long long) statbuf->st_dev);
|
||||
} else if (m == 'i') {
|
||||
strcat(pformat, "ju");
|
||||
printf(pformat, (uintmax_t) statbuf->st_ino);
|
||||
strcat(pformat, "llu");
|
||||
printf(pformat, (unsigned long long) statbuf->st_ino);
|
||||
} else if (m == 'a') {
|
||||
strcat(pformat, "lo");
|
||||
printf(pformat, (unsigned long) (statbuf->st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO)));
|
||||
@@ -269,14 +264,14 @@ static void print_stat(char *pformat, const char m,
|
||||
strcat(pformat, "lx");
|
||||
printf(pformat, (unsigned long) minor(statbuf->st_rdev));
|
||||
} else if (m == 's') {
|
||||
strcat(pformat, "ju");
|
||||
printf(pformat, (uintmax_t) (statbuf->st_size));
|
||||
strcat(pformat, "llu");
|
||||
printf(pformat, (unsigned long long) statbuf->st_size);
|
||||
} else if (m == 'B') {
|
||||
strcat(pformat, "lu");
|
||||
printf(pformat, (unsigned long) 512); //ST_NBLOCKSIZE
|
||||
} else if (m == 'b') {
|
||||
strcat(pformat, "ju");
|
||||
printf(pformat, (uintmax_t) statbuf->st_blocks);
|
||||
strcat(pformat, "llu");
|
||||
printf(pformat, (unsigned long long) statbuf->st_blocks);
|
||||
} else if (m == 'o') {
|
||||
strcat(pformat, "lu");
|
||||
printf(pformat, (unsigned long) statbuf->st_blksize);
|
||||
@@ -284,31 +279,34 @@ static void print_stat(char *pformat, const char m,
|
||||
printfs(pformat, human_time(statbuf->st_atime));
|
||||
} else if (m == 'X') {
|
||||
strcat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu");
|
||||
printf(pformat, (unsigned long) statbuf->st_atime);
|
||||
/* note: (unsigned long) would be wrong:
|
||||
* imagine (unsigned long64)int32 */
|
||||
printf(pformat, (long) statbuf->st_atime);
|
||||
} else if (m == 'y') {
|
||||
printfs(pformat, human_time(statbuf->st_mtime));
|
||||
} else if (m == 'Y') {
|
||||
strcat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu");
|
||||
printf(pformat, (unsigned long) statbuf->st_mtime);
|
||||
printf(pformat, (long) statbuf->st_mtime);
|
||||
} else if (m == 'z') {
|
||||
printfs(pformat, human_time(statbuf->st_ctime));
|
||||
} else if (m == 'Z') {
|
||||
strcat(pformat, TYPE_SIGNED(time_t) ? "ld" : "lu");
|
||||
printf(pformat, (unsigned long) statbuf->st_ctime);
|
||||
#if ENABLE_SELINUX
|
||||
printf(pformat, (long) statbuf->st_ctime);
|
||||
# if ENABLE_SELINUX
|
||||
} else if (m == 'C' && (option_mask32 & OPT_SELINUX)) {
|
||||
printfs(pformat, scontext);
|
||||
#endif
|
||||
# endif
|
||||
} else {
|
||||
strcatc(pformat, 'c');
|
||||
printf(pformat, m);
|
||||
}
|
||||
}
|
||||
|
||||
static void print_it(const char *masterformat, const char *filename,
|
||||
void (*print_func) (char*, char, const char*, const void* IF_SELINUX(, security_context_t scontext)),
|
||||
static void print_it(const char *masterformat,
|
||||
const char *filename,
|
||||
void FAST_FUNC (*print_func)(char*, char, const char*, const void* IF_SELINUX(, security_context_t scontext)),
|
||||
const void *data
|
||||
IF_SELINUX(, security_context_t scontext) )
|
||||
IF_SELINUX(, security_context_t scontext))
|
||||
{
|
||||
/* Create a working copy of the format string */
|
||||
char *format = xstrdup(masterformat);
|
||||
@@ -319,24 +317,28 @@ static void print_it(const char *masterformat, const char *filename,
|
||||
|
||||
b = format;
|
||||
while (b) {
|
||||
/* Each iteration finds next %spec,
|
||||
* prints preceding string and handles found %spec
|
||||
*/
|
||||
size_t len;
|
||||
char *p = strchr(b, '%');
|
||||
if (!p) {
|
||||
/* coreutils 6.3 always prints <cr> at the end */
|
||||
/* coreutils 6.3 always prints newline at the end */
|
||||
/*fputs(b, stdout);*/
|
||||
puts(b);
|
||||
break;
|
||||
}
|
||||
*p++ = '\0';
|
||||
fputs(b, stdout);
|
||||
|
||||
/* dest = "%<modifiers>" */
|
||||
len = strspn(p, "#-+.I 0123456789");
|
||||
dest[0] = '%';
|
||||
memcpy(dest + 1, p, len);
|
||||
dest[1 + len] = '\0';
|
||||
p += len;
|
||||
len = 1 + strspn(p + 1, "#-+.I 0123456789");
|
||||
memcpy(dest, p, len);
|
||||
dest[len] = '\0';
|
||||
|
||||
/* print preceding string */
|
||||
*p = '\0';
|
||||
fputs(b, stdout);
|
||||
|
||||
p += len;
|
||||
b = p + 1;
|
||||
switch (*p) {
|
||||
case '\0':
|
||||
@@ -355,7 +357,7 @@ static void print_it(const char *masterformat, const char *filename,
|
||||
free(format);
|
||||
free(dest);
|
||||
}
|
||||
#endif
|
||||
#endif /* FEATURE_STAT_FORMAT */
|
||||
|
||||
/* Stat the file system and print what we find. */
|
||||
#if !ENABLE_FEATURE_STAT_FORMAT
|
||||
@@ -364,7 +366,6 @@ static void print_it(const char *masterformat, const char *filename,
|
||||
static bool do_statfs(const char *filename, const char *format)
|
||||
{
|
||||
struct statfs statfsbuf;
|
||||
|
||||
#if !ENABLE_FEATURE_STAT_FORMAT
|
||||
const char *format;
|
||||
#endif
|
||||
@@ -389,7 +390,7 @@ static bool do_statfs(const char *filename, const char *format)
|
||||
|
||||
#if ENABLE_FEATURE_STAT_FORMAT
|
||||
if (format == NULL) {
|
||||
#if !ENABLE_SELINUX
|
||||
# if !ENABLE_SELINUX
|
||||
format = (option_mask32 & OPT_TERSE
|
||||
? "%n %i %l %t %s %b %f %a %c %d\n"
|
||||
: " File: \"%n\"\n"
|
||||
@@ -397,7 +398,7 @@ static bool do_statfs(const char *filename, const char *format)
|
||||
"Block size: %-10s\n"
|
||||
"Blocks: Total: %-10b Free: %-10f Available: %a\n"
|
||||
"Inodes: Total: %-10c Free: %d");
|
||||
#else
|
||||
# else
|
||||
format = (option_mask32 & OPT_TERSE
|
||||
? (option_mask32 & OPT_SELINUX ? "%n %i %l %t %s %b %f %a %c %d %C\n":
|
||||
"%n %i %l %t %s %b %f %a %c %d\n")
|
||||
@@ -414,7 +415,7 @@ static bool do_statfs(const char *filename, const char *format)
|
||||
"Blocks: Total: %-10b Free: %-10f Available: %a\n"
|
||||
"Inodes: Total: %-10c Free: %d\n")
|
||||
);
|
||||
#endif /* SELINUX */
|
||||
# endif /* SELINUX */
|
||||
}
|
||||
print_it(format, filename, print_statfs, &statfsbuf IF_SELINUX(, scontext));
|
||||
#else /* FEATURE_STAT_FORMAT */
|
||||
@@ -428,47 +429,48 @@ static bool do_statfs(const char *filename, const char *format)
|
||||
statfsbuf.f_namelen);
|
||||
|
||||
if (option_mask32 & OPT_TERSE)
|
||||
printf("%lx ", (unsigned long) (statfsbuf.f_type));
|
||||
printf("%lx ", (unsigned long) statfsbuf.f_type);
|
||||
else
|
||||
printf("Type: %s\n", human_fstype(statfsbuf.f_type));
|
||||
|
||||
#if !ENABLE_SELINUX
|
||||
# if !ENABLE_SELINUX
|
||||
format = (option_mask32 & OPT_TERSE
|
||||
? "%lu %ld %ld %ld %ld %ld\n"
|
||||
? "%lu %llu %llu %llu %llu %llu\n"
|
||||
: "Block size: %-10lu\n"
|
||||
"Blocks: Total: %-10jd Free: %-10jd Available: %jd\n"
|
||||
"Inodes: Total: %-10jd Free: %jd\n");
|
||||
"Blocks: Total: %-10llu Free: %-10llu Available: %llu\n"
|
||||
"Inodes: Total: %-10llu Free: %llu\n");
|
||||
printf(format,
|
||||
(unsigned long) (statfsbuf.f_bsize),
|
||||
(intmax_t) (statfsbuf.f_blocks),
|
||||
(intmax_t) (statfsbuf.f_bfree),
|
||||
(intmax_t) (statfsbuf.f_bavail),
|
||||
(intmax_t) (statfsbuf.f_files),
|
||||
(intmax_t) (statfsbuf.f_ffree));
|
||||
#else
|
||||
(unsigned long) statfsbuf.f_bsize,
|
||||
(unsigned long long) statfsbuf.f_blocks,
|
||||
(unsigned long long) statfsbuf.f_bfree,
|
||||
(unsigned long long) statfsbuf.f_bavail,
|
||||
(unsigned long long) statfsbuf.f_files,
|
||||
(unsigned long long) statfsbuf.f_ffree);
|
||||
# else
|
||||
format = (option_mask32 & OPT_TERSE
|
||||
? (option_mask32 & OPT_SELINUX ? "%lu %ld %ld %ld %ld %ld %C\n":
|
||||
"%lu %ld %ld %ld %ld %ld\n")
|
||||
: (option_mask32 & OPT_SELINUX ?
|
||||
"Block size: %-10lu\n"
|
||||
"Blocks: Total: %-10jd Free: %-10jd Available: %jd\n"
|
||||
"Inodes: Total: %-10jd Free: %jd"
|
||||
"S_context: %C\n":
|
||||
"Block size: %-10lu\n"
|
||||
"Blocks: Total: %-10jd Free: %-10jd Available: %jd\n"
|
||||
"Inodes: Total: %-10jd Free: %jd\n"));
|
||||
? (option_mask32 & OPT_SELINUX ? "%lu %llu %llu %llu %llu %llu %C\n" : "%lu %llu %llu %llu %llu %llu\n")
|
||||
: (option_mask32 & OPT_SELINUX
|
||||
? "Block size: %-10lu\n"
|
||||
"Blocks: Total: %-10llu Free: %-10llu Available: %llu\n"
|
||||
"Inodes: Total: %-10llu Free: %llu"
|
||||
"S_context: %C\n"
|
||||
: "Block size: %-10lu\n"
|
||||
"Blocks: Total: %-10llu Free: %-10llu Available: %llu\n"
|
||||
"Inodes: Total: %-10llu Free: %llu\n"
|
||||
)
|
||||
);
|
||||
printf(format,
|
||||
(unsigned long) (statfsbuf.f_bsize),
|
||||
(intmax_t) (statfsbuf.f_blocks),
|
||||
(intmax_t) (statfsbuf.f_bfree),
|
||||
(intmax_t) (statfsbuf.f_bavail),
|
||||
(intmax_t) (statfsbuf.f_files),
|
||||
(intmax_t) (statfsbuf.f_ffree),
|
||||
(unsigned long) statfsbuf.f_bsize,
|
||||
(unsigned long long) statfsbuf.f_blocks,
|
||||
(unsigned long long) statfsbuf.f_bfree,
|
||||
(unsigned long long) statfsbuf.f_bavail,
|
||||
(unsigned long long) statfsbuf.f_files,
|
||||
(unsigned long long) statfsbuf.f_ffree,
|
||||
scontext);
|
||||
|
||||
if (scontext)
|
||||
freecon(scontext);
|
||||
#endif
|
||||
# endif
|
||||
#endif /* FEATURE_STAT_FORMAT */
|
||||
return 1;
|
||||
}
|
||||
@@ -501,13 +503,13 @@ static bool do_stat(const char *filename, const char *format)
|
||||
|
||||
#if ENABLE_FEATURE_STAT_FORMAT
|
||||
if (format == NULL) {
|
||||
#if !ENABLE_SELINUX
|
||||
# if !ENABLE_SELINUX
|
||||
if (option_mask32 & OPT_TERSE) {
|
||||
format = "%n %s %b %f %u %g %D %i %h %t %T %X %Y %Z %o";
|
||||
} else {
|
||||
if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode)) {
|
||||
format =
|
||||
" File: \"%N\"\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"
|
||||
@@ -515,14 +517,14 @@ static bool do_stat(const char *filename, const char *format)
|
||||
"Access: %x\n" "Modify: %y\n" "Change: %z\n";
|
||||
} else {
|
||||
format =
|
||||
" File: \"%N\"\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";
|
||||
}
|
||||
}
|
||||
#else
|
||||
# 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":
|
||||
@@ -530,14 +532,14 @@ static bool do_stat(const char *filename, const char *format)
|
||||
} else {
|
||||
if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode)) {
|
||||
format = (option_mask32 & OPT_SELINUX ?
|
||||
" File: \"%N\"\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"
|
||||
" File: %N\n"
|
||||
" Size: %-10s\tBlocks: %-10b IO Block: %-6o %F\n"
|
||||
"Device: %Dh/%dd\tInode: %-10i Links: %-5h"
|
||||
" Device type: %t,%T\n"
|
||||
@@ -545,34 +547,34 @@ static bool do_stat(const char *filename, const char *format)
|
||||
"Access: %x\n" "Modify: %y\n" "Change: %z\n");
|
||||
} else {
|
||||
format = (option_mask32 & OPT_SELINUX ?
|
||||
" File: \"%N\"\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"
|
||||
" 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
|
||||
# endif
|
||||
}
|
||||
print_it(format, filename, print_stat, &statbuf IF_SELINUX(, scontext));
|
||||
#else /* FEATURE_STAT_FORMAT */
|
||||
if (option_mask32 & OPT_TERSE) {
|
||||
printf("%s %ju %ju %lx %lu %lu %jx %ju %lu %lx %lx %lu %lu %lu %lu"
|
||||
printf("%s %llu %llu %lx %lu %lu %llx %llu %lu %lx %lx %lu %lu %lu %lu"
|
||||
IF_NOT_SELINUX("\n"),
|
||||
filename,
|
||||
(uintmax_t) (statbuf.st_size),
|
||||
(uintmax_t) statbuf.st_blocks,
|
||||
(unsigned long long) statbuf.st_size,
|
||||
(unsigned long long) statbuf.st_blocks,
|
||||
(unsigned long) statbuf.st_mode,
|
||||
(unsigned long) statbuf.st_uid,
|
||||
(unsigned long) statbuf.st_gid,
|
||||
(uintmax_t) statbuf.st_dev,
|
||||
(uintmax_t) statbuf.st_ino,
|
||||
(unsigned long long) statbuf.st_dev,
|
||||
(unsigned long long) statbuf.st_ino,
|
||||
(unsigned long) statbuf.st_nlink,
|
||||
(unsigned long) major(statbuf.st_rdev),
|
||||
(unsigned long) minor(statbuf.st_rdev),
|
||||
@@ -581,12 +583,12 @@ static bool do_stat(const char *filename, const char *format)
|
||||
(unsigned long) statbuf.st_ctime,
|
||||
(unsigned long) statbuf.st_blksize
|
||||
);
|
||||
#if ENABLE_SELINUX
|
||||
# if ENABLE_SELINUX
|
||||
if (option_mask32 & OPT_SELINUX)
|
||||
printf(" %lc\n", *scontext);
|
||||
else
|
||||
bb_putchar('\n');
|
||||
#endif
|
||||
# endif
|
||||
} else {
|
||||
char *linkname = NULL;
|
||||
|
||||
@@ -600,19 +602,19 @@ static bool do_stat(const char *filename, const char *format)
|
||||
if (S_ISLNK(statbuf.st_mode))
|
||||
linkname = xmalloc_readlink_or_warn(filename);
|
||||
if (linkname)
|
||||
printf(" File: \"%s\" -> \"%s\"\n", filename, linkname);
|
||||
printf(" File: '%s' -> '%s'\n", filename, linkname);
|
||||
else
|
||||
printf(" File: \"%s\"\n", filename);
|
||||
printf(" File: '%s'\n", filename);
|
||||
|
||||
printf(" Size: %-10ju\tBlocks: %-10ju IO Block: %-6lu %s\n"
|
||||
"Device: %jxh/%jud\tInode: %-10ju Links: %-5lu",
|
||||
(uintmax_t) (statbuf.st_size),
|
||||
(uintmax_t) statbuf.st_blocks,
|
||||
printf(" Size: %-10llu\tBlocks: %-10llu IO Block: %-6lu %s\n"
|
||||
"Device: %llxh/%llud\tInode: %-10llu Links: %-5lu",
|
||||
(unsigned long long) statbuf.st_size,
|
||||
(unsigned long long) statbuf.st_blocks,
|
||||
(unsigned long) statbuf.st_blksize,
|
||||
file_type(&statbuf),
|
||||
(uintmax_t) statbuf.st_dev,
|
||||
(uintmax_t) statbuf.st_dev,
|
||||
(uintmax_t) statbuf.st_ino,
|
||||
(unsigned long long) statbuf.st_dev,
|
||||
(unsigned long long) statbuf.st_dev,
|
||||
(unsigned long long) statbuf.st_ino,
|
||||
(unsigned long) statbuf.st_nlink);
|
||||
if (S_ISBLK(statbuf.st_mode) || S_ISCHR(statbuf.st_mode))
|
||||
printf(" Device type: %lx,%lx\n",
|
||||
@@ -627,9 +629,9 @@ static bool do_stat(const char *filename, const char *format)
|
||||
(pw_ent != NULL) ? pw_ent->pw_name : "UNKNOWN",
|
||||
(unsigned long) statbuf.st_gid,
|
||||
(gw_ent != NULL) ? gw_ent->gr_name : "UNKNOWN");
|
||||
#if ENABLE_SELINUX
|
||||
# if ENABLE_SELINUX
|
||||
printf(" S_Context: %lc\n", *scontext);
|
||||
#endif
|
||||
# endif
|
||||
printf("Access: %s\n" "Modify: %s\n" "Change: %s\n",
|
||||
human_time(statbuf.st_atime),
|
||||
human_time(statbuf.st_mtime),
|
||||
|
||||
+1
-1
@@ -625,7 +625,7 @@ struct globals {
|
||||
/* Current position, to know when to wrap */
|
||||
unsigned current_col;
|
||||
char buf[10];
|
||||
};
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
#define INIT_G() do { \
|
||||
G.device_name = bb_msg_standard_input; \
|
||||
|
||||
+7
-6
@@ -35,7 +35,7 @@ static const struct suffix_mult tail_suffixes[] = {
|
||||
|
||||
struct globals {
|
||||
bool status;
|
||||
};
|
||||
} FIX_ALIASING;
|
||||
#define G (*(struct globals*)&bb_common_bufsiz1)
|
||||
|
||||
static void tail_xprint_header(const char *fmt, const char *filename)
|
||||
@@ -66,7 +66,7 @@ static ssize_t tail_read(int fd, char *buf, size_t count)
|
||||
return r;
|
||||
}
|
||||
|
||||
static const char header_fmt[] ALIGN1 = "\n==> %s <==\n";
|
||||
#define header_fmt_str "\n==> %s <==\n"
|
||||
|
||||
static unsigned eat_num(const char *p)
|
||||
{
|
||||
@@ -166,7 +166,7 @@ int tail_main(int argc, char **argv)
|
||||
tailbuf = xmalloc(tailbufsize);
|
||||
|
||||
/* tail the files */
|
||||
fmt = header_fmt + 1; /* skip header leading newline on first output */
|
||||
fmt = header_fmt_str + 1; /* skip header leading newline on first output */
|
||||
i = 0;
|
||||
do {
|
||||
char *buf;
|
||||
@@ -181,7 +181,7 @@ int tail_main(int argc, char **argv)
|
||||
|
||||
if (nfiles > header_threshhold) {
|
||||
tail_xprint_header(fmt, argv[i]);
|
||||
fmt = header_fmt;
|
||||
fmt = header_fmt_str;
|
||||
}
|
||||
|
||||
if (!from_top) {
|
||||
@@ -241,7 +241,8 @@ int tail_main(int argc, char **argv)
|
||||
} while (nwrite);
|
||||
}
|
||||
}
|
||||
xwrite(STDOUT_FILENO, buf + nread - nwrite, nwrite);
|
||||
if (nwrite > 0)
|
||||
xwrite(STDOUT_FILENO, buf + nread - nwrite, nwrite);
|
||||
} else if (count) {
|
||||
if (COUNT_BYTES) {
|
||||
taillen += nread;
|
||||
@@ -332,7 +333,7 @@ int tail_main(int argc, char **argv)
|
||||
if (ENABLE_FEATURE_FANCY_TAIL && fd < 0)
|
||||
continue;
|
||||
if (nfiles > header_threshhold) {
|
||||
fmt = header_fmt;
|
||||
fmt = header_fmt_str;
|
||||
}
|
||||
while ((nread = tail_read(fd, tailbuf, BUFSIZ)) > 0) {
|
||||
if (fmt) {
|
||||
|
||||
+21
-1
@@ -19,6 +19,26 @@
|
||||
* Original copyright notice states:
|
||||
* "This program is in the Public Domain."
|
||||
*/
|
||||
|
||||
//kbuild:lib-$(CONFIG_TEST) += test.o test_ptr_hack.o
|
||||
//kbuild:lib-$(CONFIG_ASH) += test.o test_ptr_hack.o
|
||||
//kbuild:lib-$(CONFIG_HUSH) += test.o test_ptr_hack.o
|
||||
|
||||
//config:config TEST
|
||||
//config: bool "test"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: test is used to check file types and compare values,
|
||||
//config: returning an appropriate exit code. The bash shell
|
||||
//config: has test built in, ash can build it in optionally.
|
||||
//config:
|
||||
//config:config FEATURE_TEST_64
|
||||
//config: bool "Extend test to 64 bit"
|
||||
//config: default y
|
||||
//config: depends on TEST || ASH_BUILTIN_TEST || HUSH
|
||||
//config: help
|
||||
//config: Enable 64-bit support in test.
|
||||
|
||||
#include "libbb.h"
|
||||
#include <setjmp.h>
|
||||
|
||||
@@ -393,7 +413,7 @@ static number_t getn(const char *s)
|
||||
if (errno != 0)
|
||||
syntax(s, "out of range");
|
||||
|
||||
if (*(skip_whitespace(p)))
|
||||
if (p == s || *(skip_whitespace(p)) != '\0')
|
||||
syntax(s, "bad number");
|
||||
|
||||
return r;
|
||||
|
||||
+2
-2
@@ -104,7 +104,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
|
||||
do {
|
||||
if (utimes(*argv, reference_file ? timebuf : NULL) != 0) {
|
||||
if (utimes(*argv, (reference_file || date_str) ? timebuf : NULL) != 0) {
|
||||
if (errno == ENOENT) { /* no such file */
|
||||
if (opts) { /* creation is disabled, so ignore */
|
||||
continue;
|
||||
@@ -113,7 +113,7 @@ int touch_main(int argc UNUSED_PARAM, char **argv)
|
||||
fd = open(*argv, O_RDWR | O_CREAT, 0666);
|
||||
if (fd >= 0) {
|
||||
xclose(fd);
|
||||
if (reference_file)
|
||||
if (reference_file || date_str)
|
||||
utimes(*argv, timebuf);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,35 @@
|
||||
/* http://www.opengroup.org/onlinepubs/009695399/utilities/tr.html
|
||||
* TODO: graph, print
|
||||
*/
|
||||
|
||||
//kbuild:lib-$(CONFIG_TR) += tr.o
|
||||
|
||||
//config:config TR
|
||||
//config: bool "tr"
|
||||
//config: default y
|
||||
//config: help
|
||||
//config: tr is used to squeeze, and/or delete characters from standard
|
||||
//config: input, writing to standard output.
|
||||
//config:
|
||||
//config:config FEATURE_TR_CLASSES
|
||||
//config: bool "Enable character classes (such as [:upper:])"
|
||||
//config: default y
|
||||
//config: depends on TR
|
||||
//config: help
|
||||
//config: Enable character classes, enabling commands such as:
|
||||
//config: tr [:upper:] [:lower:] to convert input into lowercase.
|
||||
//config:
|
||||
//config:config FEATURE_TR_EQUIV
|
||||
//config: bool "Enable equivalence classes"
|
||||
//config: default y
|
||||
//config: depends on TR
|
||||
//config: help
|
||||
//config: Enable equivalence classes, which essentially add the enclosed
|
||||
//config: character to the current set. For instance, tr [=a=] xyz would
|
||||
//config: replace all instances of 'a' with 'xyz'. This option is mainly
|
||||
//config: useful for cases when no other way of expressing a character
|
||||
//config: is possible.
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
enum {
|
||||
|
||||
@@ -88,6 +88,8 @@ int wc_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (!argv[0]) {
|
||||
*--argv = (char *) bb_msg_standard_input;
|
||||
fname_fmt = "\n";
|
||||
}
|
||||
if (!argv[1]) { /* zero or one filename? */
|
||||
if (!((print_type-1) & print_type)) /* exactly one option? */
|
||||
start_fmt = "%"COUNT_FMT;
|
||||
}
|
||||
|
||||
Loaded 100 of 532 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user