Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e7ba6979c | ||
|
|
3d90be2efe | ||
|
|
b32502da83 | ||
|
|
568d8c9a5c | ||
|
|
05732281e4 | ||
|
|
4b38e29764 | ||
|
|
58875aefe4 | ||
|
|
d0587ed966 | ||
|
|
cbcff2936e | ||
|
|
1787e22465 | ||
|
|
2a51af2579 | ||
|
|
9a1fa8cf07 | ||
|
|
7c139b4778 | ||
|
|
b8e72fdde1 | ||
|
|
afa37cf508 | ||
|
|
f9234135f8 | ||
|
|
4f93cde77f | ||
|
|
f363065021 | ||
|
|
c86e052b81 | ||
|
|
e84aeb5bcb | ||
|
|
88a2aa98e0 | ||
|
|
97fd6d81b4 | ||
|
|
6111a8f2e7 | ||
|
|
16deb86746 | ||
|
|
3d101dd467 | ||
|
|
be862096c0 | ||
|
|
54e3d1f00d | ||
|
|
f24cdf1554 | ||
|
|
dfce08f281 | ||
|
|
bd852076b9 | ||
|
|
de8a6a01d8 | ||
|
|
41e1dc3f8b | ||
|
|
4b4b619c9c | ||
|
|
1c86a29aea | ||
|
|
83bb98f759 | ||
|
|
8e1a0cc4c9 | ||
|
|
6b343ddbc8 | ||
|
|
081ef799fa | ||
|
|
7a96504d30 | ||
|
|
75acbe322c | ||
|
|
757ed50841 | ||
|
|
4b0bb9e0fd | ||
|
|
486e7ca6b7 | ||
|
|
84a9b8750e | ||
|
|
3ce293b585 | ||
|
|
4efeaee387 | ||
|
|
5e892bae51 | ||
|
|
bff32ce4d5 | ||
|
|
1cc70225e7 | ||
|
|
54d14ca1a2 | ||
|
|
24af7201e9 | ||
|
|
972288e62f | ||
|
|
dd2b2f75ae | ||
|
|
5659407595 | ||
|
|
7f2527e5a7 | ||
|
|
650a0459b8 | ||
|
|
16c7fb7fc5 | ||
|
|
e1e93c1e1c | ||
|
|
6ef06eeed4 | ||
|
|
75ab6af71e | ||
|
|
cfa2b3a209 | ||
|
|
1ce190b7c1 | ||
|
|
9616aff095 | ||
|
|
26a8016da6 | ||
|
|
fe42d17318 | ||
|
|
75605788ff | ||
|
|
07766bb0e7 | ||
|
|
da799e8227 | ||
|
|
e930fe1441 | ||
|
|
fad03bc3bb | ||
|
|
93ebd4f58d | ||
|
|
5df955fce2 | ||
|
|
c9c893d4f5 | ||
|
|
8a164052bf | ||
|
|
d55a36255d | ||
|
|
b5c33b10b9 | ||
|
|
39c651e909 | ||
|
|
b3f09f4a50 | ||
|
|
214aec46bd | ||
|
|
955bccc94f | ||
|
|
1203c9bf2f | ||
|
|
baca175912 | ||
|
|
ecea8f201e | ||
|
|
a4688bf55d | ||
|
|
be644a81e9 | ||
|
|
49622d7846 | ||
|
|
4eb8b936cb | ||
|
|
2b52b2797b | ||
|
|
3aba666514 | ||
|
|
bebbd8c9ba | ||
|
|
f25d57e0b4 | ||
|
|
71bc71a7dc | ||
|
|
339f5eb2e0 | ||
|
|
48e71c188f | ||
|
|
02f0c4c2bf | ||
|
|
f5a157615d | ||
|
|
e11b4a4705 | ||
|
|
12eda0ab97 | ||
|
|
67a32adbca | ||
|
|
a1c631278b | ||
|
|
18d6fc1a50 | ||
|
|
5c1de36702 | ||
|
|
8a91081d9d | ||
|
|
cd27c42552 | ||
|
|
6c939e0cb4 | ||
|
|
36b7e28fa0 | ||
|
|
673d4bbab6 | ||
|
|
7fb8a00341 | ||
|
|
0085f231b2 | ||
|
|
80281fefc0 | ||
|
|
ab9eef21a5 | ||
|
|
8e858e2700 | ||
|
|
41cca2b4f5 | ||
|
|
c115fdbc80 | ||
|
|
9431e564aa | ||
|
|
140644dc1c | ||
|
|
ccd412da09 | ||
|
|
1ccd96fd1f | ||
|
|
d238a477b7 | ||
|
|
ec77ba128a | ||
|
|
1c660b4bd2 | ||
|
|
3af3e5b4b0 | ||
|
|
940494f813 | ||
|
|
29e31ddd81 | ||
|
|
dcbd51dd28 | ||
|
|
19c238bc90 | ||
|
|
2110aa9ece | ||
|
|
4c7e5b6c76 | ||
|
|
5066473d41 | ||
|
|
966bb43766 | ||
|
|
b716754199 | ||
|
|
cce38586ae | ||
|
|
f8ea0f3a66 | ||
|
|
385304d449 | ||
|
|
4222ae440a | ||
|
|
018e085d44 | ||
|
|
629563b5d7 | ||
|
|
5276402f2c | ||
|
|
f98dc4db7a | ||
|
|
0dec6de38b | ||
|
|
cc5715184b | ||
|
|
2de3d9fbee | ||
|
|
a89150733a | ||
|
|
99eb8500c9 | ||
|
|
fc06f2968b | ||
|
|
5651bfc204 | ||
|
|
bc54cffc83 | ||
|
|
4d2183bee1 | ||
|
|
4fe15f3d9e | ||
|
|
a6704933dd | ||
|
|
5c67e3ed90 | ||
|
|
fe1f00a7a7 | ||
|
|
9650f36210 | ||
|
|
aa74445514 | ||
|
|
0c032a49b9 | ||
|
|
7a2ca5e111 | ||
|
|
a624c11d5e | ||
|
|
2da584fc4e | ||
|
|
b012b10dbd | ||
|
|
e5570da2cf | ||
|
|
5cedb75aa7 | ||
|
|
3bf0020a5f | ||
|
|
131ae177a7 | ||
|
|
a0f82e928a | ||
|
|
d0762e3d52 | ||
|
|
54cf511ce1 | ||
|
|
ec27feb045 | ||
|
|
c84520d73d | ||
|
|
d818dcc72a | ||
|
|
7fd00cbff7 | ||
|
|
4998c81891 | ||
|
|
9ab2658836 | ||
|
|
b30418ac19 | ||
|
|
ae30210d90 | ||
|
|
b5368bf437 | ||
|
|
e54b472ffc | ||
|
|
9a1c71a0f2 | ||
|
|
a3055846a4 | ||
|
|
6089c2c31e | ||
|
|
6ca0444420 | ||
|
|
136f42f503 | ||
|
|
ad67a3925c | ||
|
|
c8e9993514 | ||
|
|
9ca26d38c5 | ||
|
|
d244c5eaf8 | ||
|
|
b477e18c1e | ||
|
|
0aa6ba5d44 | ||
|
|
4423e5beef | ||
|
|
c5d9e8ff3d | ||
|
|
0850cdabde | ||
|
|
8c6c6e955b | ||
|
|
710694f0e5 | ||
|
|
d4eda22d0c | ||
|
|
d46d3c292e | ||
|
|
b292264bfd | ||
|
|
1d76f439da | ||
|
|
cc24419e98 | ||
|
|
dc485c9da6 | ||
|
|
f885c543da | ||
|
|
8c0164c373 | ||
|
|
d909d23451 | ||
|
|
7154b99c89 | ||
|
|
01986e9c6f | ||
|
|
cf787cf3a5 | ||
|
|
10b7996c1b | ||
|
|
cbd6e65744 | ||
|
|
e991303406 | ||
|
|
1094452423 | ||
|
|
5870ad9672 | ||
|
|
42823d597a | ||
|
|
45854b5e3f | ||
|
|
9f85de1821 | ||
|
|
e8ce0626d9 | ||
|
|
06af216528 | ||
|
|
c7ba8b9d6c | ||
|
|
6a1829d90c | ||
|
|
a5c5ae03eb | ||
|
|
37c8f36357 | ||
|
|
4c97863109 | ||
|
|
e968fcd562 | ||
|
|
4921b54f37 | ||
|
|
0aa8490693 | ||
|
|
64392905ef | ||
|
|
4f8d27f29a | ||
|
|
493691a4f5 | ||
|
|
7a7e54a190 | ||
|
|
e129f43c83 | ||
|
|
7fca91a3de | ||
|
|
8bb21af72c | ||
|
|
a100707c04 | ||
|
|
731d357295 | ||
|
|
c4d606e367 | ||
|
|
de55b5d014 | ||
|
|
4bb31899e5 | ||
|
|
1e3b068689 | ||
|
|
6b50f73171 | ||
|
|
489f93ebae | ||
|
|
00ccf95bc8 | ||
|
|
71d8abf30c | ||
|
|
bb81c5831a | ||
|
|
c72c1ed932 | ||
|
|
0c886c65de | ||
|
|
15d78fb724 | ||
|
|
34c4e5f0b3 | ||
|
|
54767db8c7 | ||
|
|
27a131e08e | ||
|
|
eb10e17b7b | ||
|
|
9356b5022c | ||
|
|
322661d025 | ||
|
|
89ef65f024 | ||
|
|
ab2aea4447 | ||
|
|
06c0a71d23 | ||
|
|
b6aae0f381 | ||
|
|
a41fdf331a | ||
|
|
e935602ff5 | ||
|
|
86811803e3 | ||
|
|
c562bb7487 | ||
|
|
fe7a9f1277 | ||
|
|
826c85f382 | ||
|
|
dccb1a5343 | ||
|
|
afe488d4bc | ||
|
|
9d938732d0 | ||
|
|
4e1715f4b9 | ||
|
|
2806b2368c | ||
|
|
8ca35d2d65 | ||
|
|
4d9a358ec1 | ||
|
|
6912ea1467 | ||
|
|
eeafc1a057 | ||
|
|
ca549c5e69 | ||
|
|
bde74b617f | ||
|
|
e2473f8c23 | ||
|
|
8c78395120 | ||
|
|
e06bed30cf | ||
|
|
cd75a96f0f | ||
|
|
14813c5943 | ||
|
|
aae82e0d8b | ||
|
|
9dca07d949 | ||
|
|
434ad5456b | ||
|
|
e0eebc1ef3 | ||
|
|
fd94efa41f | ||
|
|
5ff8f3d7fd | ||
|
|
98c0bba09d | ||
|
|
fc7f92253a | ||
|
|
8b942c6639 | ||
|
|
86724af484 | ||
|
|
f98d637ba4 | ||
|
|
5b6195c9bc | ||
|
|
bc5262d3dd | ||
|
|
a1042e94f1 | ||
|
|
30abe97940 | ||
|
|
90ec4dc0c7 | ||
|
|
aeb4bdd582 | ||
|
|
581930cc0d | ||
|
|
b9a279ba94 | ||
|
|
677cb5eea5 | ||
|
|
218f2f4882 | ||
|
|
84d2d493b4 | ||
|
|
7b1c5aacb0 | ||
|
|
0e282c9aed | ||
|
|
11353ae0ab | ||
|
|
a01579d4eb | ||
|
|
6cda89700e | ||
|
|
841ef1308b | ||
|
|
08e7097340 | ||
|
|
71a6a4e723 | ||
|
|
1c747b32c7 | ||
|
|
82f8788acc | ||
|
|
b5bb40f088 | ||
|
|
425997223c | ||
|
|
52848eecca | ||
|
|
769d1e05e6 | ||
|
|
d77f7c3136 | ||
|
|
5de9e9ce0b | ||
|
|
9adc6ced4f | ||
|
|
448f0241e0 | ||
|
|
fdcd7c4237 | ||
|
|
835f575b61 | ||
|
|
620e57b421 | ||
|
|
d0f33b3ce8 | ||
|
|
bb8c7c041c | ||
|
|
703e20235a | ||
|
|
6cd2d2bcba | ||
|
|
35d4da0fb5 | ||
|
|
85629f08bc | ||
|
|
3c99a59915 | ||
|
|
d8760a705c | ||
|
|
95fef7071e | ||
|
|
38f6319421 | ||
|
|
253ce00296 | ||
|
|
b01b4e2a1f | ||
|
|
6258fd3454 | ||
|
|
8e1c71529c | ||
|
|
00cdbd8fc2 | ||
|
|
5592fac308 | ||
|
|
47bdb3ac48 | ||
|
|
82b39e83ab | ||
|
|
7b1f23610f | ||
|
|
2f0c0d0b88 | ||
|
|
b3f3c23f78 | ||
|
|
12f96c1cec | ||
|
|
af45760cca | ||
|
|
d19f4aaa21 | ||
|
|
1118a1de46 | ||
|
|
8b1ae45037 | ||
|
|
b31c252860 | ||
|
|
088a212bf5 | ||
|
|
ca5b35299e | ||
|
|
d58c19479d | ||
|
|
a8e2e1872a | ||
|
|
312735878b | ||
|
|
12a3917e45 | ||
|
|
8942c12782 | ||
|
|
316355524f | ||
|
|
91f20ab510 | ||
|
|
e055443412 | ||
|
|
4ebaf10742 | ||
|
|
2405ad659e | ||
|
|
9af7c9d6b6 | ||
|
|
f8c11aa65d | ||
|
|
e18a293a52 | ||
|
|
1abf91aa25 | ||
|
|
a0e701d137 | ||
|
|
74c9d2365a | ||
|
|
c966ba46a9 | ||
|
|
f8384fa50c | ||
|
|
1a250d9f32 | ||
|
|
7f0d7ae4f5 | ||
|
|
41aaefce71 | ||
|
|
cbbc043d1b | ||
|
|
ef44d9d9f2 | ||
|
|
ae114c235e | ||
|
|
79cc55975f | ||
|
|
8eb0549e5d | ||
|
|
94feb1c807 | ||
|
|
d4a745c3d4 | ||
|
|
a6e31ad834 | ||
|
|
4950f010f3 | ||
|
|
21fc740023 | ||
|
|
4fa566d4ad | ||
|
|
9e8df9354a | ||
|
|
b64eed6030 | ||
|
|
d1a6e8d320 | ||
|
|
d97c9244b1 | ||
|
|
b8b81a6f8f | ||
|
|
844ff096ec | ||
|
|
fdf7aec532 | ||
|
|
c14c95ec89 | ||
|
|
19250813a8 | ||
|
|
ffcef2d1f7 | ||
|
|
7a431b3715 | ||
|
|
150f402b36 | ||
|
|
2418288cac | ||
|
|
3a34d0c08a | ||
|
|
21b080daa8 | ||
|
|
f8abc100cc | ||
|
|
4df8135cf6 | ||
|
|
5d68724d5b | ||
|
|
2c91652bbc | ||
|
|
6536a9b583 | ||
|
|
f8138d1f91 | ||
|
|
4fa5e8b455 | ||
|
|
f7996f3b70 | ||
|
|
3821fb13ea | ||
|
|
8e9ccba371 | ||
|
|
085231fbba | ||
|
|
1a8bf7f5d3 | ||
|
|
7573541f74 | ||
|
|
bbe514683a | ||
|
|
9de420c27c | ||
|
|
62a6983a81 | ||
|
|
886bb0df66 | ||
|
|
1c962f23e0 | ||
|
|
59f2c34037 | ||
|
|
bae7948a5a | ||
|
|
db1edde6d8 | ||
|
|
d1e54e4f56 | ||
|
|
0f48663f83 | ||
|
|
e86bd6cde5 | ||
|
|
8fc4011992 | ||
|
|
f07fe62d89 | ||
|
|
44c2eb23dd | ||
|
|
d6c23aeefb | ||
|
|
c1feac6e9f | ||
|
|
681f183b94 | ||
|
|
91c06e0a3c | ||
|
|
42646c5585 | ||
|
|
6998142998 | ||
|
|
db6a5c3f9e | ||
|
|
3ae6f34135 | ||
|
|
2f6df7fa0a | ||
|
|
56c83eaaf5 | ||
|
|
89af56b3e5 | ||
|
|
52933d47bd | ||
|
|
ef87d46b8c | ||
|
|
1a03c21adf | ||
|
|
da31fbc1b1 | ||
|
|
f824136f6b | ||
|
|
ed0f6db35e | ||
|
|
30551fd6da | ||
|
|
ad403413c7 | ||
|
|
88e2b1cb62 | ||
|
|
7ae93f0fe7 | ||
|
|
5568b722d4 | ||
|
|
70722ec4ce | ||
|
|
f0b71c19ae | ||
|
|
fa85b86f38 | ||
|
|
b05955e0a5 | ||
|
|
8336f080cb | ||
|
|
8a820b2732 | ||
|
|
ea9e35f5dd | ||
|
|
3697a829de | ||
|
|
da98165ad6 | ||
|
|
c7a4aa5c99 | ||
|
|
d1a19affeb | ||
|
|
cd42cb8df0 | ||
|
|
447b543eaf | ||
|
|
cc33ef12d2 | ||
|
|
3376298b59 | ||
|
|
98b8e9487d | ||
|
|
89d49a4236 | ||
|
|
a0e2a0a192 | ||
|
|
b893497151 | ||
|
|
a9b60e93ee | ||
|
|
ceab8700df | ||
|
|
bfe1950c63 | ||
|
|
e428e9d43b | ||
|
|
b8429fb1f4 | ||
|
|
a773af3b1d | ||
|
|
a8951cbc34 | ||
|
|
919c10dd88 | ||
|
|
b36b370fbe | ||
|
|
562dc249e0 | ||
|
|
6eebed561a | ||
|
|
c9d34da375 | ||
|
|
d54708399d | ||
|
|
9b1381fd2f | ||
|
|
bb3d0fab3b | ||
|
|
75fa4eb155 | ||
|
|
87033fb5fa | ||
|
|
73464ce53d | ||
|
|
aa95959cb8 | ||
|
|
6dd392a252 | ||
|
|
24cfe8fe0c | ||
|
|
2a85676fa5 | ||
|
|
ace35eeb88 | ||
|
|
a71199e0f0 | ||
|
|
e5c095345e | ||
|
|
e1d3e034a9 | ||
|
|
6dc6ebbf44 | ||
|
|
f782f52c8c | ||
|
|
b2abef3e54 | ||
|
|
e27f15615f | ||
|
|
d1a302b52f | ||
|
|
50ddabc859 | ||
|
|
95b307103a | ||
|
|
c519320000 | ||
|
|
13463af29f | ||
|
|
98ee06d3d4 | ||
|
|
806116b234 | ||
|
|
d514ba226b | ||
|
|
5dd76862ef | ||
|
|
4a64c33443 | ||
|
|
cb04ff5c68 | ||
|
|
80602a98bc | ||
|
|
1b3e8179a2 | ||
|
|
68ffb9a85d | ||
|
|
40ae9b5617 | ||
|
|
c255f8b492 | ||
|
|
6a5dc5d75a | ||
|
|
3bba545a54 | ||
|
|
b5a122b6f9 | ||
|
|
d9e4ddc38b | ||
|
|
c1a339983f | ||
|
|
57ec574af7 | ||
|
|
7fa0fcafca | ||
|
|
9a44c4f91c | ||
|
|
ba092336f0 | ||
|
|
9cd7a249f1 | ||
|
|
f959bee0f4 | ||
|
|
8f27c34c28 | ||
|
|
666da5e2c6 | ||
|
|
270c17c0e6 | ||
|
|
3ef70d43ad | ||
|
|
bf0a201008 | ||
|
|
5dd7ef0f37 | ||
|
|
407b8c0b70 | ||
|
|
0de9375ee6 | ||
|
|
c4f623ef2a | ||
|
|
64c5402584 | ||
|
|
d63c3a032a | ||
|
|
b6488c1780 | ||
|
|
5a4f0994b0 | ||
|
|
7a50a64986 | ||
|
|
765996aaea | ||
|
|
0ee3999d13 | ||
|
|
7cea262273 | ||
|
|
a5b3e76c38 | ||
|
|
f4dff77355 | ||
|
|
9ac9e55e3c | ||
|
|
e13a537795 | ||
|
|
1dc1b37b33 | ||
|
|
7e46cf748e | ||
|
|
2a813e20e2 | ||
|
|
8f6c79240d | ||
|
|
4cccc03768 | ||
|
|
a6df5907d2 | ||
|
|
e31f721e14 | ||
|
|
f4c52b32db | ||
|
|
0849207ce0 | ||
|
|
c5cb38f4d9 | ||
|
|
f93ab47c45 | ||
|
|
1d14e6f48c | ||
|
|
afc9ff99fd | ||
|
|
714701c890 | ||
|
|
0a8a774179 | ||
|
|
d56b47f9a6 | ||
|
|
f1282a8792 | ||
|
|
f65d1338dc | ||
|
|
d51d14e36f | ||
|
|
e147a72173 | ||
|
|
e865e81d34 | ||
|
|
bf66fbc8e2 | ||
|
|
6910741067 | ||
|
|
3f3190e34c | ||
|
|
9a7cef930f | ||
|
|
b95636c52f | ||
|
|
2375d75f32 | ||
|
|
8cd1a288fa | ||
|
|
28703015ab | ||
|
|
f58906b646 | ||
|
|
28fbd69bf8 | ||
|
|
359d7ca0e7 | ||
|
|
7f1dc21a5d | ||
|
|
8eb3b391ad | ||
|
|
249fabf1a3 | ||
|
|
15b213ef5a | ||
|
|
908d6b7054 | ||
|
|
7cfecc4b36 | ||
|
|
c8e6e35ba4 | ||
|
|
83e5d6f772 | ||
|
|
f42ff90453 | ||
|
|
fcfe834d50 | ||
|
|
6dca70a049 | ||
|
|
db50647d1f | ||
|
|
b8c77b5b25 | ||
|
|
0f5905e617 | ||
|
|
c88894602d | ||
|
|
b131b271a0 | ||
|
|
7cdc54ff59 | ||
|
|
10f7dd1ea1 | ||
|
|
0a10da29a7 | ||
|
|
f7583d89b0 | ||
|
|
9f739445cd | ||
|
|
a597aaddfa | ||
|
|
3469c185e5 | ||
|
|
6a1d661036 | ||
|
|
79e77cdbed | ||
|
|
cda6c636ca | ||
|
|
44b2ea786e | ||
|
|
728534b3cb | ||
|
|
56b956952e | ||
|
|
f7b0d4a3e5 | ||
|
|
a883fa4cee | ||
|
|
9729e65706 | ||
|
|
5b6f776fe9 | ||
|
|
35a4bbe74f | ||
|
|
5e2db5e8ee | ||
|
|
5fa7148761 | ||
|
|
16c2c700fd | ||
|
|
db2b52425d | ||
|
|
900406c359 | ||
|
|
6f0540e7ec | ||
|
|
32f3ebf08f | ||
|
|
2ea630f9a5 | ||
|
|
2f8f71b20d | ||
|
|
b15b7f7a4a | ||
|
|
57d83ff5f9 | ||
|
|
1819eee436 | ||
|
|
95da177b09 | ||
|
|
b7c50c9896 | ||
|
|
feea1b972c | ||
|
|
bc95f57932 | ||
|
|
882e60c442 | ||
|
|
bbda98f14c | ||
|
|
bb59f02218 | ||
|
|
91d4a2dac3 | ||
|
|
1375bc7b67 | ||
|
|
8b22b07bc5 | ||
|
|
becd8c538c | ||
|
|
732268fe69 | ||
|
|
4c87d4f242 | ||
|
|
eb98be02ac | ||
|
|
93f6aa6bca | ||
|
|
610c4aa197 | ||
|
|
002526481e | ||
|
|
ab24e18c7a | ||
|
|
b8bb27c7ea | ||
|
|
28bb84bd4e | ||
|
|
016a82e279 | ||
|
|
66b86c6902 | ||
|
|
c6ce8733dd | ||
|
|
a35c9e91ba | ||
|
|
2425bdce34 | ||
|
|
834410a5a5 | ||
|
|
c61852a02b | ||
|
|
601ae1378b | ||
|
|
df38188367 | ||
|
|
7df69b887a | ||
|
|
c2f5b02293 | ||
|
|
1fffe38e01 | ||
|
|
229b3d2072 | ||
|
|
e2d3ded354 | ||
|
|
30d7a346e6 | ||
|
|
5e90e10647 | ||
|
|
f1a6c6b362 | ||
|
|
097c324f59 | ||
|
|
d9e15f2068 | ||
|
|
079f8afa0a | ||
|
|
10d0d4eec7 | ||
|
|
3ece72dc3f | ||
|
|
459903bd4e | ||
|
|
d686a045c8 | ||
|
|
8a0a83d503 | ||
|
|
2813ce2aad | ||
|
|
a7b2c41e03 | ||
|
|
c9bb67787a | ||
|
|
bf11e8942d | ||
|
|
e5667c1cfe | ||
|
|
ec0c920a78 | ||
|
|
664733f1a3 | ||
|
|
0d42ddff70 | ||
|
|
cf749bc10c | ||
|
|
c1660fea6d | ||
|
|
b596335868 | ||
|
|
7725d0ff5c | ||
|
|
2d27e4ccbb | ||
|
|
87cd4a87e3 | ||
|
|
43bddf31e9 | ||
|
|
f2408e6c3f | ||
|
|
5dd27b1ee0 | ||
|
|
ed836cdc30 | ||
|
|
809a6e3104 | ||
|
|
3feb2fc535 | ||
|
|
d031ffa623 | ||
|
|
b833ca9d2d | ||
|
|
d6772501db | ||
|
|
d398ecab9d | ||
|
|
8023d7df78 | ||
|
|
b8a8e601df | ||
|
|
c50f370f98 | ||
|
|
4fbb584a0e | ||
|
|
0b35470d9b | ||
|
|
cf30cc82a3 | ||
|
|
376ce1e775 | ||
|
|
14621929a1 | ||
|
|
a741b778fe | ||
|
|
93ad1c2385 | ||
|
|
4e4662cc73 | ||
|
|
c90c3f30a8 | ||
|
|
48237b0c88 | ||
|
|
b40bdb383a | ||
|
|
7627cc1454 | ||
|
|
81e264d4af | ||
|
|
be2f9f7fe0 | ||
|
|
32eddffa30 | ||
|
|
c8717cd857 | ||
|
|
0801ef28ca | ||
|
|
75f8d080a2 | ||
|
|
d6bbf99a8b | ||
|
|
aad4999eea | ||
|
|
428f7ae6e2 | ||
|
|
8b45837b4c | ||
|
|
5e618ff439 | ||
|
|
7ca3921e5e | ||
|
|
5096246ffb | ||
|
|
f8c8bb1160 | ||
|
|
921f5df25f | ||
|
|
04b30ba3b8 | ||
|
|
3aa2d51cd6 | ||
|
|
9229794ab3 | ||
|
|
a8381948da | ||
|
|
1288722f3e | ||
|
|
40f62a8c3d | ||
|
|
3e7ef7ead4 | ||
|
|
9cade08917 | ||
|
|
04291bc5ae | ||
|
|
3eb91c2e35 | ||
|
|
5d148e2646 | ||
|
|
fcdb00f735 | ||
|
|
6c85ddc850 | ||
|
|
a3ee69fa6c | ||
|
|
0bb993f39b | ||
|
|
736230e209 | ||
|
|
c9cdeaa3fe | ||
|
|
4a5cf16a36 | ||
|
|
6a353c8158 | ||
|
|
83edaf3fd6 | ||
|
|
22dcd04f8f | ||
|
|
89f0b3486d | ||
|
|
61126ab30a | ||
|
|
5a3395bc01 | ||
|
|
abfc4cf6d8 | ||
|
|
f7eaccde13 | ||
|
|
a7189f01a4 | ||
|
|
04c6386c45 | ||
|
|
8a00f44bf4 | ||
|
|
a5342b4541 | ||
|
|
8bfd215fb2 | ||
|
|
193bcf381e | ||
|
|
68532b3578 | ||
|
|
e766715032 | ||
|
|
b3a071543d | ||
|
|
d4f3d1a4bd | ||
|
|
0871bc89fb | ||
|
|
e867b7ce86 | ||
|
|
83ea643d8d | ||
|
|
3672fe9e91 | ||
|
|
1119972f91 | ||
|
|
6c5e5a0e85 | ||
|
|
067e3f031a | ||
|
|
07159f0f0e | ||
|
|
8528151658 | ||
|
|
6476cc1089 | ||
|
|
9f60929cc4 | ||
|
|
5af906e7c8 | ||
|
|
402151671b | ||
|
|
77a1a53a98 | ||
|
|
9494919ea5 | ||
|
|
aae0311356 | ||
|
|
459e4d6cf7 | ||
|
|
fa07680091 | ||
|
|
9d4533ede1 | ||
|
|
dd539f7687 | ||
|
|
9225854144 | ||
|
|
048c93cc55 | ||
|
|
35fb512728 | ||
|
|
d3ada32285 | ||
|
|
966ec7c067 | ||
|
|
31c65f2456 | ||
|
|
14aa9f7415 | ||
|
|
b141b9b512 | ||
|
|
4126b1f5c6 | ||
|
|
8c76487f06 | ||
|
|
6ae8079e2d | ||
|
|
3b8ff68ec8 | ||
|
|
5f18e7ca33 | ||
|
|
a3b4fed8b3 | ||
|
|
6191a7a007 | ||
|
|
afea46b4e4 | ||
|
|
41be5b863d | ||
|
|
8d463072df | ||
|
|
5d499e1600 | ||
|
|
e2fb719ba3 | ||
|
|
df0553bbd2 | ||
|
|
656f746e74 | ||
|
|
8c0c119130 | ||
|
|
94cf69fe3e | ||
|
|
5c7596058d | ||
|
|
8c35d65c43 | ||
|
|
e80e2a3660 | ||
|
|
3b8fc1c582 | ||
|
|
51b4c92f80 | ||
|
|
fefb279ace | ||
|
|
cf70433173 | ||
|
|
82f9e28513 | ||
|
|
25d8062128 | ||
|
|
b54b208d90 | ||
|
|
dca0b707c0 | ||
|
|
621204bbf6 | ||
|
|
d3d004dd35 | ||
|
|
1340ca8c87 | ||
|
|
2fe7b73d99 | ||
|
|
1de0830e62 | ||
|
|
ddec5af6b0 | ||
|
|
f0ed376eda | ||
|
|
670a6626ca | ||
|
|
ebe578ab2f | ||
|
|
68f2187265 | ||
|
|
1457915afc | ||
|
|
940b2e4b73 | ||
|
|
c6f188def8 | ||
|
|
e63a0dee9e | ||
|
|
8077850330 | ||
|
|
d18a3a20db | ||
|
|
c8400a2162 | ||
|
|
44c7917cab | ||
|
|
d35d540217 | ||
|
|
a481d87ff7 | ||
|
|
7534e0834f | ||
|
|
703aa13ff5 | ||
|
|
4e70bf4359 | ||
|
|
50e77e1cc1 | ||
|
|
dce3fde414 | ||
|
|
7c4503d223 | ||
|
|
2295b49169 | ||
|
|
9b44db5d9d | ||
|
|
f24e1f40e0 | ||
|
|
8d73c35916 | ||
|
|
9bff26cccb | ||
|
|
c108ed5497 | ||
|
|
456fa6c0b1 | ||
|
|
df51892690 | ||
|
|
e1a0d486e4 | ||
|
|
dd2982882b | ||
|
|
b79b87a30f | ||
|
|
9fa9950784 | ||
|
|
b560577cb2 | ||
|
|
52b5eba715 | ||
|
|
fdc101782a | ||
|
|
534d88e34e | ||
|
|
13c5a6832f | ||
|
|
f46be09106 | ||
|
|
4e33e07f60 | ||
|
|
5f03158f66 | ||
|
|
d0e70af9d1 | ||
|
|
bf39216cc4 | ||
|
|
c6ec8c9680 | ||
|
|
023b57d935 | ||
|
|
efeed5ed28 | ||
|
|
3544ae6004 | ||
|
|
3a6755f56f | ||
|
|
c345d8e945 | ||
|
|
997aa1179e | ||
|
|
ea62077b85 | ||
|
|
88ca067690 | ||
|
|
2d5ca60bfb | ||
|
|
372686bde7 | ||
|
|
9c267b851e | ||
|
|
98ae2160b6 | ||
|
|
a6dbb08a48 | ||
|
|
12f5676cce | ||
|
|
5cb46485dd | ||
|
|
f6f43df60b | ||
|
|
8de82bf84f | ||
|
|
665b02cb60 | ||
|
|
1db39b2f51 | ||
|
|
1114de7219 | ||
|
|
cba9ef5523 | ||
|
|
1ac42bf66e | ||
|
|
da8f43fd34 | ||
|
|
ca3c981c07 | ||
|
|
7039a66b58 | ||
|
|
1385899416 | ||
|
|
5625415085 | ||
|
|
890ac9deb2 | ||
|
|
f7a57848c2 | ||
|
|
96e9d3c968 | ||
|
|
a655152b00 | ||
|
|
bede7d0ebe | ||
|
|
4fa499a17b | ||
|
|
c12f53090b | ||
|
|
4e6ceb4455 | ||
|
|
000b9ba91f | ||
|
|
de59c0f58f | ||
|
|
01c27fc5ac | ||
|
|
a3310527db | ||
|
|
8bf7bb8541 | ||
|
|
1868409c86 | ||
|
|
5d2f1736d9 | ||
|
|
7d219aab70 | ||
|
|
8f8f268cfd | ||
|
|
67b23e6043 | ||
|
|
40920825d5 | ||
|
|
b6332248ca | ||
|
|
9275814a9e | ||
|
|
cf94446af7 | ||
|
|
6edaddec02 | ||
|
|
f0a97fb43a | ||
|
|
fe54458e46 | ||
|
|
7c1ed2e922 | ||
|
|
1c3577f91d | ||
|
|
2e864cd219 | ||
|
|
546cd1881a | ||
|
|
e2016e145b | ||
|
|
b97c9842a5 | ||
|
|
bb119d059a | ||
|
|
97a8dd3857 | ||
|
|
f8aa109a9f | ||
|
|
aecabffb8b | ||
|
|
55a994055f | ||
|
|
3038ac9c19 | ||
|
|
02be0f5350 | ||
|
|
14c1940255 | ||
|
|
1decd0e529 | ||
|
|
39d551fd15 | ||
|
|
274b8c0639 | ||
|
|
7e3eb5171b | ||
|
|
7935a5a992 | ||
|
|
70210168fc | ||
|
|
3ed001ff26 | ||
|
|
530c3ef818 | ||
|
|
0b193a7871 | ||
|
|
a959588b80 | ||
|
|
6c30db8bd3 | ||
|
|
51937534fb | ||
|
|
266bc17690 | ||
|
|
b1726785f9 | ||
|
|
f0d6cc8ca9 | ||
|
|
b02ef82c99 | ||
|
|
6248a734e2 | ||
|
|
981b24db5e | ||
|
|
5492884311 | ||
|
|
57308afb5b | ||
|
|
06b543b217 | ||
|
|
524176680d | ||
|
|
de9ec92958 | ||
|
|
ce97960a6e | ||
|
|
c16bd212e3 | ||
|
|
94d5d82bd8 | ||
|
|
956a569360 | ||
|
|
0bb628f4f3 | ||
|
|
a77947f5bb | ||
|
|
be905d550c | ||
|
|
2f4399c6cc | ||
|
|
0534125ccc | ||
|
|
e175ff252f | ||
|
|
22f6dcb47c | ||
|
|
8b8c75e6ab | ||
|
|
a552eeb498 | ||
|
|
3312c989e6 | ||
|
|
d9867320b4 | ||
|
|
da3cec9c85 | ||
|
|
29d94b907f | ||
|
|
a94554d010 | ||
|
|
01a74f9649 | ||
|
|
c290563319 | ||
|
|
c1876d7364 | ||
|
|
4c196a80fc | ||
|
|
ec17d437ab | ||
|
|
2dbeaa95ca | ||
|
|
a36a676923 | ||
|
|
7f1f5b001f | ||
|
|
a65a17700a | ||
|
|
fe76cd5a5c | ||
|
|
d78b433414 | ||
|
|
6429aabbf1 | ||
|
|
b97f07f5a1 | ||
|
|
0372197385 | ||
|
|
754a88f7aa | ||
|
|
01e88f0339 | ||
|
|
27ee7ba95e | ||
|
|
099efbf99e | ||
|
|
750fc6d7bb | ||
|
|
8514fc5681 | ||
|
|
0e87d347e8 | ||
|
|
109d21fe74 | ||
|
|
cb1ba86507 | ||
|
|
f47ff100cc | ||
|
|
cad36681d2 | ||
|
|
7869c018b5 | ||
|
|
ae843e9cc8 | ||
|
|
e9a7a6212b | ||
|
|
05592ac00c | ||
|
|
3503ff72c6 | ||
|
|
42f67026a1 | ||
|
|
ce32f65a1b | ||
|
|
a528643330 | ||
|
|
116080a13a | ||
|
|
fbdf121b7d | ||
|
|
4ef6f647a3 | ||
|
|
eb84a42fdd | ||
|
|
94b383d419 | ||
|
|
d1f939eaf3 | ||
|
|
a6585774f9 | ||
|
|
3ccc100670 | ||
|
|
c7b9bad519 | ||
|
|
79deb66c35 | ||
|
|
2969c772c2 | ||
|
|
debaf2fe02 | ||
|
|
20b253d2d8 | ||
|
|
8971cdaeca | ||
|
|
e40c04b826 | ||
|
|
9efb070dcb | ||
|
|
7eab79acc5 | ||
|
|
85f9e32f7f | ||
|
|
23514fe251 | ||
|
|
f70265290c | ||
|
|
0b5fd45ef7 | ||
|
|
9213a9e0f2 | ||
|
|
a6127aacef | ||
|
|
6231e870ec | ||
|
|
029c469934 | ||
|
|
a52145a927 | ||
|
|
c889d2b786 | ||
|
|
c0975199be | ||
|
|
9c99b62b9e | ||
|
|
13b4924ce0 | ||
|
|
3bc59aa2a4 | ||
|
|
fc56dd2e21 | ||
|
|
8d474b5009 | ||
|
|
66fabdb631 | ||
|
|
4d0f54af94 | ||
|
|
30a64cdc95 | ||
|
|
215c61d3c2 | ||
|
|
f5fc1384e9 | ||
|
|
69115c656d | ||
|
|
da9d1d079e | ||
|
|
7ccf5cc064 | ||
|
|
af9854b81a | ||
|
|
be507170eb | ||
|
|
25098f7fd5 | ||
|
|
6eb2f8edce | ||
|
|
1d6fb6d448 | ||
|
|
727ef94447 | ||
|
|
85c6de71bf | ||
|
|
cc9962d7fb | ||
|
|
73810e8d42 | ||
|
|
7fee0c4357 | ||
|
|
92582f2e11 | ||
|
|
577905f1e4 | ||
|
|
20cc6d567f | ||
|
|
1b2b5cfba8 | ||
|
|
16bbb20089 | ||
|
|
b5f50ea344 | ||
|
|
428a5cd0d3 | ||
|
|
00d7d6cef6 | ||
|
|
64d7e93081 | ||
|
|
57b56674a3 | ||
|
|
dea6e3d3cf | ||
|
|
49ea46667f | ||
|
|
69674941dd | ||
|
|
3077294615 | ||
|
|
d2b13eab98 | ||
|
|
39e93cc951 | ||
|
|
2244a21a8e | ||
|
|
5983914c1b | ||
|
|
1bfca7bac7 | ||
|
|
9852d5a1e6 | ||
|
|
8fafacd7ec | ||
|
|
42dfcd2612 | ||
|
|
0c45bb23d2 | ||
|
|
d5d614c5f4 | ||
|
|
9cac521f07 | ||
|
|
3526a1320a | ||
|
|
d797fcd726 | ||
|
|
2f50aa42c5 | ||
|
|
bd8f43dbab | ||
|
|
9a9edf200b | ||
|
|
6bbd174593 | ||
|
|
942e4291fe | ||
|
|
2e502914b0 | ||
|
|
dd93abeaff | ||
|
|
ef08184d9e | ||
|
|
3476ad651d | ||
|
|
c27f4f5445 | ||
|
|
d35c0efddb | ||
|
|
239369b368 | ||
|
|
a9801658ee | ||
|
|
b750dec40a | ||
|
|
049d6b8c08 | ||
|
|
b7d8dd9ab1 | ||
|
|
3da6aa878a | ||
|
|
f522d1231c | ||
|
|
6d655be5df | ||
|
|
3538b9a882 | ||
|
|
5d725462d4 | ||
|
|
e614eaf40d | ||
|
|
4cb035dd23 | ||
|
|
02496aa69e | ||
|
|
797b4d210d | ||
|
|
d25a2645f5 | ||
|
|
02add9e53a | ||
|
|
4d609cb5a3 | ||
|
|
8cedabaee0 | ||
|
|
adff40e80d | ||
|
|
1da6a21666 | ||
|
|
21afc7dc29 | ||
|
|
22dca23d52 | ||
|
|
314908da9e | ||
|
|
65113e8d97 | ||
|
|
af906a3b6c | ||
|
|
a9abecd85e | ||
|
|
65dbd8752b | ||
|
|
60e3dd6016 | ||
|
|
035aae5841 | ||
|
|
27af5a0dd3 | ||
|
|
87d80dcc3e | ||
|
|
06ab5fb6b9 | ||
|
|
bcf4908e71 | ||
|
|
e0b7f71d26 | ||
|
|
2cbe6e6eb2 | ||
|
|
db7f2e5881 | ||
|
|
cb6874cc66 | ||
|
|
d53dd3e627 | ||
|
|
bfbc4ebf40 | ||
|
|
686298d6fb | ||
|
|
89d9d4d5f7 | ||
|
|
f5bbc692a0 | ||
|
|
1fdd83f897 | ||
|
|
31e2c00ec3 | ||
|
|
88621d7398 | ||
|
|
8c1eda528a | ||
|
|
73561cc75a | ||
|
|
6ce8dae1d5 | ||
|
|
99b706858b | ||
|
|
8479063667 | ||
|
|
028ba280be | ||
|
|
b8cea6dcb3 | ||
|
|
abfe107f78 | ||
|
|
82ac9ecfe5 | ||
|
|
099ed50f91 | ||
|
|
f78ab5396d | ||
|
|
4b5827a69b | ||
|
|
ecb29573e9 | ||
|
|
98a915713d | ||
|
|
1ffe1ede54 | ||
|
|
43ee36c6da | ||
|
|
0e4690d4ef | ||
|
|
289e86a0a5 | ||
|
|
d591a360d3 | ||
|
|
13068a4fdb | ||
|
|
71193a853d | ||
|
|
5bd2a4b6ce | ||
|
|
4470b74e29 | ||
|
|
eb28ce4644 | ||
|
|
fac4ebea3d | ||
|
|
95718b3091 | ||
|
|
b90a371a4c | ||
|
|
4640b05afd | ||
|
|
a299efb7b0 | ||
|
|
10b36f94bb | ||
|
|
b988462d3e | ||
|
|
519d7df930 | ||
|
|
e55a73c7a8 | ||
|
|
3ba7bd143e | ||
|
|
721b46e0e6 | ||
|
|
e3781b7312 | ||
|
|
47b16a6fe9 | ||
|
|
7250915d78 | ||
|
|
236c6755d2 | ||
|
|
affb7a61a6 | ||
|
|
59fe8b9089 | ||
|
|
f4e50b0bcd | ||
|
|
cb376eebf0 | ||
|
|
e6a3fef08c | ||
|
|
23b61be0df | ||
|
|
74bb70cf54 | ||
|
|
3629d95a24 | ||
|
|
27d07c9ce2 | ||
|
|
daf58ef61a | ||
|
|
2c55fcac08 | ||
|
|
6ced427a6d | ||
|
|
403777ffae | ||
|
|
081e38483e | ||
|
|
86b4d64aa3 | ||
|
|
7478804b78 | ||
|
|
280a264fb8 | ||
|
|
d921b2ecc0 | ||
|
|
6dce0b6fa7 | ||
|
|
581d4f36b3 | ||
|
|
cae61e7ca4 | ||
|
|
2aced7ea04 | ||
|
|
533320c659 | ||
|
|
565bc33332 | ||
|
|
c052576821 | ||
|
|
91dc086d63 | ||
|
|
446129adae | ||
|
|
52c7d7ebf3 | ||
|
|
fc367f9824 | ||
|
|
277eb6bb44 | ||
|
|
eac0c06938 | ||
|
|
0b7dfb5ae7 | ||
|
|
a7881119cc | ||
|
|
4795e4e011 | ||
|
|
7cc6b69bb0 | ||
|
|
e1a0f5372f | ||
|
|
5ebeb3ec56 | ||
|
|
91a339002a | ||
|
|
8840759c61 | ||
|
|
eea561871b | ||
|
|
bf30c69a38 |
No files matched your search
@@ -113,7 +113,7 @@ Manuel Novoa III <mjn3@codepoet.org>
|
||||
|
||||
Vladimir Oleynik <dzo@simtreas.ru>
|
||||
cmdedit; bb_mkdep, xargs(current), httpd(current);
|
||||
ports: ash, crond, fdisk (initial, unmaintained now), inetd, stty, traceroute,
|
||||
ports: ash, crond, fdisk (initial, unmaintained now), inetd, stty, traceroute,
|
||||
top;
|
||||
locale, various fixes
|
||||
and irreconcilable critic of everything not perfect.
|
||||
|
||||
@@ -13,7 +13,7 @@ menu "Busybox Settings"
|
||||
|
||||
menu "General Configuration"
|
||||
|
||||
config CONFIG_NITPICK
|
||||
config NITPICK
|
||||
bool "See lots more (probably unnecessary) configuration options."
|
||||
default n
|
||||
help
|
||||
@@ -29,10 +29,18 @@ config CONFIG_NITPICK
|
||||
|
||||
You have been warned.
|
||||
|
||||
config DESKTOP
|
||||
bool "Enable options for full-blown desktop systems"
|
||||
default n
|
||||
help
|
||||
Enable options and features which are not essential.
|
||||
Select this only if you plan to use busybox on full-blown
|
||||
desktop machine with common Linux distro, not on an embedded box.
|
||||
|
||||
choice
|
||||
prompt "Buffer allocation policy"
|
||||
default CONFIG_FEATURE_BUFFERS_USE_MALLOC
|
||||
depends on CONFIG_NITPICK
|
||||
default FEATURE_BUFFERS_USE_MALLOC
|
||||
depends on NITPICK
|
||||
help
|
||||
There are 3 ways BusyBox can handle buffer allocations:
|
||||
- Use malloc. This costs code size for the call to xmalloc.
|
||||
@@ -43,18 +51,18 @@ choice
|
||||
behavior was the only one available for BusyBox versions 0.48 and
|
||||
earlier.
|
||||
|
||||
config CONFIG_FEATURE_BUFFERS_USE_MALLOC
|
||||
config FEATURE_BUFFERS_USE_MALLOC
|
||||
bool "Allocate with Malloc"
|
||||
|
||||
config CONFIG_FEATURE_BUFFERS_GO_ON_STACK
|
||||
config FEATURE_BUFFERS_GO_ON_STACK
|
||||
bool "Allocate on the Stack"
|
||||
|
||||
config CONFIG_FEATURE_BUFFERS_GO_IN_BSS
|
||||
config FEATURE_BUFFERS_GO_IN_BSS
|
||||
bool "Allocate in the .bss section"
|
||||
|
||||
endchoice
|
||||
|
||||
config CONFIG_SHOW_USAGE
|
||||
config SHOW_USAGE
|
||||
bool "Show terse applet usage messages"
|
||||
default y
|
||||
help
|
||||
@@ -63,20 +71,20 @@ config CONFIG_SHOW_USAGE
|
||||
messages if you say no here.
|
||||
This will save you up to 7k.
|
||||
|
||||
config CONFIG_FEATURE_VERBOSE_USAGE
|
||||
config FEATURE_VERBOSE_USAGE
|
||||
bool "Show verbose applet usage messages"
|
||||
default n
|
||||
select CONFIG_SHOW_USAGE
|
||||
select 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
|
||||
busybox binary. In the default configuration, this will add about
|
||||
13k, but it can add much more depending on your configuration.
|
||||
|
||||
config CONFIG_FEATURE_COMPRESS_USAGE
|
||||
config FEATURE_COMPRESS_USAGE
|
||||
bool "Store applet usage messages in compressed form"
|
||||
default y
|
||||
depends on CONFIG_SHOW_USAGE && CONFIG_NITPICK
|
||||
depends on SHOW_USAGE
|
||||
help
|
||||
Store usage messages in compressed form, uncompress them on-the-fly
|
||||
when <applet> --help is called.
|
||||
@@ -87,7 +95,7 @@ config CONFIG_FEATURE_COMPRESS_USAGE
|
||||
and have very little memory, this might not be a win. Otherwise,
|
||||
you probably want this.
|
||||
|
||||
config CONFIG_FEATURE_INSTALLER
|
||||
config FEATURE_INSTALLER
|
||||
bool "Support --install [-s] to install applet links at runtime"
|
||||
default n
|
||||
help
|
||||
@@ -96,23 +104,21 @@ config CONFIG_FEATURE_INSTALLER
|
||||
applets that are compiled into busybox. This feature requires the
|
||||
/proc filesystem.
|
||||
|
||||
config CONFIG_LOCALE_SUPPORT
|
||||
config LOCALE_SUPPORT
|
||||
bool "Enable locale support (system needs locale for this to work)"
|
||||
default n
|
||||
help
|
||||
Enable this if your system has locale support and you would like
|
||||
busybox to support locale settings.
|
||||
|
||||
config CONFIG_GETOPT_LONG
|
||||
bool
|
||||
config GETOPT_LONG
|
||||
bool "Enable support for --long-options"
|
||||
default y
|
||||
# bool "Enable support for --long-options"
|
||||
# default n
|
||||
# help
|
||||
# Enable this if you want busybox applets to use the gnu --long-option
|
||||
# style, in addition to single character -a -b -c style options.
|
||||
help
|
||||
Enable this if you want busybox applets to use the gnu --long-option
|
||||
style, in addition to single character -a -b -c style options.
|
||||
|
||||
config CONFIG_FEATURE_DEVPTS
|
||||
config FEATURE_DEVPTS
|
||||
bool "Use the devpts filesystem for Unix98 PTYs"
|
||||
default y
|
||||
help
|
||||
@@ -122,10 +128,10 @@ config CONFIG_FEATURE_DEVPTS
|
||||
/dev/ttyp<number> will be used. To use this option, you should have
|
||||
devpts mounted.
|
||||
|
||||
config CONFIG_FEATURE_CLEAN_UP
|
||||
config FEATURE_CLEAN_UP
|
||||
bool "Clean up all memory before exiting (usually not needed)"
|
||||
default n
|
||||
depends on CONFIG_NITPICK
|
||||
depends on NITPICK
|
||||
help
|
||||
As a size optimization, busybox normally exits without explicitly
|
||||
freeing dynamically allocated memory or closing files. This saves
|
||||
@@ -135,7 +141,7 @@ config CONFIG_FEATURE_CLEAN_UP
|
||||
Don't enable this unless you have a really good reason to clean
|
||||
things up manually.
|
||||
|
||||
config CONFIG_FEATURE_SUID
|
||||
config FEATURE_SUID
|
||||
bool "Support for SUID/SGID handling"
|
||||
default n
|
||||
help
|
||||
@@ -150,10 +156,17 @@ config CONFIG_FEATURE_SUID
|
||||
are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs,
|
||||
and vlock.
|
||||
|
||||
config CONFIG_FEATURE_SUID_CONFIG
|
||||
config FEATURE_SYSLOG
|
||||
bool "Support for syslog"
|
||||
default n
|
||||
help
|
||||
This option is auto-selected when you select any applet which may
|
||||
send its output to syslog. You do not need to select it manually.
|
||||
|
||||
config FEATURE_SUID_CONFIG
|
||||
bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
|
||||
default n if CONFIG_FEATURE_SUID
|
||||
depends on CONFIG_FEATURE_SUID
|
||||
default n if FEATURE_SUID
|
||||
depends on FEATURE_SUID
|
||||
help
|
||||
Allow the SUID / SGID state of an applet to be determined at runtime
|
||||
by checking /etc/busybox.conf. (This is sort of a poor man's sudo.)
|
||||
@@ -182,15 +195,23 @@ config CONFIG_FEATURE_SUID_CONFIG
|
||||
Robert 'sandman' Griebl has more information here:
|
||||
<url: http://www.softforge.de/bb/suid.html >.
|
||||
|
||||
config CONFIG_FEATURE_SUID_CONFIG_QUIET
|
||||
config FEATURE_SUID_CONFIG_QUIET
|
||||
bool "Suppress warning message if /etc/busybox.conf is not readable"
|
||||
default y
|
||||
depends on CONFIG_FEATURE_SUID_CONFIG
|
||||
depends on FEATURE_SUID_CONFIG
|
||||
help
|
||||
/etc/busybox.conf should be readable by the user needing the SUID, check
|
||||
this option to avoid users to be notified about missing permissions.
|
||||
|
||||
config CONFIG_SELINUX
|
||||
config FEATURE_HAVE_RPC
|
||||
bool "RPC support"
|
||||
default y
|
||||
help
|
||||
Select this if you have rpc support.
|
||||
This automatically turns off all configuration options that rely
|
||||
on RPC.
|
||||
|
||||
config SELINUX
|
||||
bool "Support NSA Security Enhanced Linux"
|
||||
default n
|
||||
help
|
||||
@@ -210,7 +231,15 @@ config CONFIG_SELINUX
|
||||
|
||||
Most people will leave this set to 'N'.
|
||||
|
||||
config CONFIG_BUSYBOX_EXEC_PATH
|
||||
config FEATURE_EXEC_PREFER_APPLETS
|
||||
bool "exec prefers applets"
|
||||
default n
|
||||
help
|
||||
This is an experimental option which directs applets about to
|
||||
call 'exec' to try and find an applicable busybox applet before
|
||||
searching the executable path for a binary or symlink to execute.
|
||||
|
||||
config BUSYBOX_EXEC_PATH
|
||||
string "Path to BusyBox executable"
|
||||
default "/proc/self/exe"
|
||||
help
|
||||
@@ -224,7 +253,7 @@ endmenu
|
||||
|
||||
menu 'Build Options'
|
||||
|
||||
config CONFIG_STATIC
|
||||
config STATIC
|
||||
bool "Build BusyBox as a static binary (no shared libs)"
|
||||
default n
|
||||
help
|
||||
@@ -238,7 +267,7 @@ config CONFIG_STATIC
|
||||
|
||||
Most people will leave this set to 'N'.
|
||||
|
||||
config CONFIG_BUILD_LIBBUSYBOX
|
||||
config BUILD_LIBBUSYBOX
|
||||
bool "Build shared libbusybox"
|
||||
default n
|
||||
help
|
||||
@@ -250,10 +279,10 @@ config CONFIG_BUILD_LIBBUSYBOX
|
||||
binary serves no purpose (and increases the size). You should
|
||||
almost certainly say "no" to this right now.
|
||||
|
||||
config CONFIG_FEATURE_FULL_LIBBUSYBOX
|
||||
config FEATURE_FULL_LIBBUSYBOX
|
||||
bool "Feature-complete libbusybox"
|
||||
default n if !CONFIG_FEATURE_SHARED_BUSYBOX
|
||||
depends on CONFIG_BUILD_LIBBUSYBOX
|
||||
default n if !FEATURE_SHARED_BUSYBOX
|
||||
depends on BUILD_LIBBUSYBOX
|
||||
help
|
||||
Build a libbusybox with the complete feature-set, disregarding
|
||||
the actually selected config.
|
||||
@@ -269,15 +298,15 @@ config CONFIG_FEATURE_FULL_LIBBUSYBOX
|
||||
|
||||
Say 'N' if in doubt.
|
||||
|
||||
config CONFIG_FEATURE_SHARED_BUSYBOX
|
||||
config FEATURE_SHARED_BUSYBOX
|
||||
bool "Use shared libbusybox for busybox"
|
||||
default y if CONFIG_BUILD_LIBBUSYBOX
|
||||
depends on !CONFIG_STATIC && CONFIG_BUILD_LIBBUSYBOX
|
||||
default y if BUILD_LIBBUSYBOX
|
||||
depends on !STATIC && BUILD_LIBBUSYBOX
|
||||
help
|
||||
Use libbusybox.so also for busybox itself.
|
||||
You need to have a working dynamic linker to use this variant.
|
||||
|
||||
config CONFIG_LFS
|
||||
config LFS
|
||||
bool "Build with Large File Support (for accessing files > 2 GB)"
|
||||
default n
|
||||
select FDISK_SUPPORT_LARGE_DISKS
|
||||
@@ -289,7 +318,7 @@ config CONFIG_LFS
|
||||
cp, mount, tar, and many others. If you want to access files larger
|
||||
than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.
|
||||
|
||||
config CONFIG_BUILD_AT_ONCE
|
||||
config BUILD_AT_ONCE
|
||||
bool "Compile all sources at once"
|
||||
default n
|
||||
help
|
||||
@@ -312,7 +341,7 @@ endmenu
|
||||
|
||||
menu 'Debugging Options'
|
||||
|
||||
config CONFIG_DEBUG
|
||||
config DEBUG
|
||||
bool "Build BusyBox with extra Debugging symbols"
|
||||
default n
|
||||
help
|
||||
@@ -323,21 +352,30 @@ config CONFIG_DEBUG
|
||||
|
||||
Most people should answer N.
|
||||
|
||||
config CONFIG_DEBUG_PESSIMIZE
|
||||
bool "Disable compiler optimizations."
|
||||
config WERROR
|
||||
bool "Abort compilation on any warning"
|
||||
default n
|
||||
depends on CONFIG_DEBUG
|
||||
help
|
||||
The compiler's optimization of source code can eliminate and reorder
|
||||
code, resulting in an executable that's hard to understand when
|
||||
stepping through it with a debugger. This switches it off, resulting
|
||||
in a much bigger executable that more closely matches the source
|
||||
code.
|
||||
Selecting this will add -Werror to gcc command line.
|
||||
|
||||
Most people should answer N.
|
||||
|
||||
# Seems to be unused
|
||||
#config DEBUG_PESSIMIZE
|
||||
# bool "Disable compiler optimizations."
|
||||
# default n
|
||||
# depends on DEBUG
|
||||
# help
|
||||
# The compiler's optimization of source code can eliminate and reorder
|
||||
# code, resulting in an executable that's hard to understand when
|
||||
# stepping through it with a debugger. This switches it off, resulting
|
||||
# in a much bigger executable that more closely matches the source
|
||||
# code.
|
||||
|
||||
choice
|
||||
prompt "Additional debugging library"
|
||||
default CONFIG_NO_DEBUG_LIB
|
||||
depends on CONFIG_DEBUG
|
||||
default NO_DEBUG_LIB
|
||||
depends on DEBUG
|
||||
help
|
||||
Using an additional debugging library will make BusyBox become
|
||||
considerable larger and will cause it to run more slowly. You
|
||||
@@ -365,31 +403,31 @@ choice
|
||||
you are hunting a hard to find memory problem.
|
||||
|
||||
|
||||
config CONFIG_NO_DEBUG_LIB
|
||||
config NO_DEBUG_LIB
|
||||
bool "None"
|
||||
|
||||
config CONFIG_DMALLOC
|
||||
config DMALLOC
|
||||
bool "Dmalloc"
|
||||
|
||||
config CONFIG_EFENCE
|
||||
config EFENCE
|
||||
bool "Electric-fence"
|
||||
|
||||
endchoice
|
||||
|
||||
config CONFIG_DEBUG_YANK_SUSv2
|
||||
bool "Disable obsolete features removed before SUSv3?"
|
||||
config INCLUDE_SUSv2
|
||||
bool "Enable obsolete features removed before SUSv3?"
|
||||
default y
|
||||
help
|
||||
This option will disable backwards compatibility with SuSv2,
|
||||
This option will enable backwards compatibility with SuSv2,
|
||||
specifically, old-style numeric options ('command -1 <file>')
|
||||
will not be supported in head, tail, and fold. (Note: should
|
||||
yank from renice too.)
|
||||
will be supported in head, tail, and fold. (Note: should
|
||||
affect renice too.)
|
||||
|
||||
endmenu
|
||||
|
||||
menu 'Installation Options'
|
||||
|
||||
config CONFIG_INSTALL_NO_USR
|
||||
config INSTALL_NO_USR
|
||||
bool "Don't use /usr"
|
||||
default n
|
||||
help
|
||||
@@ -397,31 +435,30 @@ config CONFIG_INSTALL_NO_USR
|
||||
that you really want this behaviour.
|
||||
|
||||
choice
|
||||
prompt "Applets links"
|
||||
default CONFIG_INSTALL_APPLET_SYMLINKS
|
||||
help
|
||||
Choose how you install applets links.
|
||||
prompt "Applets links"
|
||||
default INSTALL_APPLET_SYMLINKS
|
||||
help
|
||||
Choose how you install applets links.
|
||||
|
||||
config CONFIG_INSTALL_APPLET_SYMLINKS
|
||||
bool "as soft-links"
|
||||
help
|
||||
Install applets as soft-links to the busybox binary. This needs some
|
||||
free inodes on the filesystem, but might help with filesystem
|
||||
generators that can't cope with hard-links.
|
||||
config INSTALL_APPLET_SYMLINKS
|
||||
bool "as soft-links"
|
||||
help
|
||||
Install applets as soft-links to the busybox binary. This needs some
|
||||
free inodes on the filesystem, but might help with filesystem
|
||||
generators that can't cope with hard-links.
|
||||
|
||||
config CONFIG_INSTALL_APPLET_HARDLINKS
|
||||
bool "as hard-links"
|
||||
help
|
||||
Install applets as hard-links to the busybox binary. This might count
|
||||
on a filesystem with few inodes.
|
||||
config INSTALL_APPLET_HARDLINKS
|
||||
bool "as hard-links"
|
||||
help
|
||||
Install applets as hard-links to the busybox binary. This might count
|
||||
on a filesystem with few inodes.
|
||||
|
||||
config CONFIG_INSTALL_APPLET_DONT
|
||||
bool
|
||||
prompt "not installed"
|
||||
depends on CONFIG_FEATURE_INSTALLER || CONFIG_FEATURE_SH_STANDALONE_SHELL
|
||||
help
|
||||
Do not install applets links. Usefull when using the -install feature
|
||||
or a standalone shell for rescue pruposes.
|
||||
config INSTALL_APPLET_DONT
|
||||
bool "not installed"
|
||||
depends on FEATURE_INSTALLER || FEATURE_SH_STANDALONE_SHELL || FEATURE_EXEC_PREFER_APPLETS
|
||||
help
|
||||
Do not install applet links. Useful when using the -install feature
|
||||
or a standalone shell for rescue pruposes.
|
||||
|
||||
endchoice
|
||||
|
||||
@@ -455,3 +492,5 @@ source networking/Config.in
|
||||
source procps/Config.in
|
||||
source shell/Config.in
|
||||
source sysklogd/Config.in
|
||||
source runit/Config.in
|
||||
source selinux/Config.in
|
||||
@@ -5,7 +5,7 @@ The BusyBox build process is similar to the Linux kernel build:
|
||||
|
||||
make menuconfig # This creates a file called ".config"
|
||||
make # This creates the "busybox" executable
|
||||
make install # or make PREFIX=/path/from/root install
|
||||
make install # or make CONFIG_PREFIX=/path/from/root install
|
||||
|
||||
The full list of configuration and install options is available by typing:
|
||||
|
||||
@@ -32,8 +32,10 @@ any built-in busybox applets directly, without looking for external
|
||||
programs by that name. Supplying an empty command path (as above) means
|
||||
the only commands busybox can find are the built-in ones.
|
||||
|
||||
(Note that the standalone shell currently requires /proc/self/exe to
|
||||
launch new applets.)
|
||||
Note that the standalone shell requires CONFIG_BUSYBOX_EXEC_PATH
|
||||
to be set appropriately, depending on whether or not /proc/self/exe is
|
||||
available or not. If you do not have /proc, then point that config option
|
||||
to the location of your busybox binary, usually /bin/busybox.
|
||||
|
||||
Configuring Busybox:
|
||||
====================
|
||||
@@ -112,7 +114,7 @@ configuration step, as in:
|
||||
make O=/some/empty/directory allyesconfig
|
||||
cd /some/empty/directory
|
||||
make
|
||||
make PREFIX=. install
|
||||
make CONFIG_PREFIX=. install
|
||||
|
||||
More Information:
|
||||
=================
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
--- A note on GPL versions
|
||||
|
||||
BusyBox is distributed under version 2 of the General Public License (included
|
||||
in its entirety, below). Version 2 is the only version of this license which
|
||||
this version of BusyBox (or modified versions derived from this one) may be
|
||||
distributed under.
|
||||
|
||||
------------------------------------------------------------------------
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
# ==========================================================================
|
||||
# Build system
|
||||
# ==========================================================================
|
||||
|
||||
%.bflt: %_unstripped
|
||||
$(CROSS_COMPILE)elf2flt $(ELF2FLTFLAGS) $< -o $@
|
||||
|
||||
busybox.links: $(srctree)/applets/busybox.mkll $(objtree)/include/autoconf.h $(srctree)/include/applets.h
|
||||
$(Q)-$(SHELL) $^ >$@
|
||||
|
||||
.PHONY: install
|
||||
ifeq ($(CONFIG_INSTALL_APPLET_SYMLINKS),y)
|
||||
INSTALL_OPTS:= --symlinks
|
||||
endif
|
||||
ifeq ($(CONFIG_INSTALL_APPLET_HARDLINKS),y)
|
||||
INSTALL_OPTS:= --hardlinks
|
||||
endif
|
||||
install: $(srctree)/applets/install.sh busybox busybox.links
|
||||
$(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
|
||||
$(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
|
||||
ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
|
||||
@echo
|
||||
@echo
|
||||
@echo --------------------------------------------------
|
||||
@echo You will probably need to make your busybox binary
|
||||
@echo setuid root to ensure all configured applets will
|
||||
@echo work properly.
|
||||
@echo --------------------------------------------------
|
||||
@echo
|
||||
endif
|
||||
|
||||
uninstall: busybox.links
|
||||
rm -f $(CONFIG_PREFIX)/bin/busybox
|
||||
for i in `cat busybox.links` ; do rm -f $(CONFIG_PREFIX)$$i; done
|
||||
ifneq ($(strip $(DO_INSTALL_LIBS)),n)
|
||||
for i in $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS); do \
|
||||
rm -f $(CONFIG_PREFIX)$$i; \
|
||||
done
|
||||
endif
|
||||
|
||||
check test: busybox busybox.links
|
||||
bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \
|
||||
$(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)
|
||||
|
||||
.PHONY: release
|
||||
release: distclean
|
||||
cd ..; \
|
||||
rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
|
||||
cp -a busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
|
||||
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
|
||||
-name .svn \
|
||||
-print \
|
||||
-exec rm -r -f {} \; ; \
|
||||
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type f \
|
||||
-name .\#* \
|
||||
-print \
|
||||
-exec rm -f {} \; ; \
|
||||
tar -czf busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION).tar.gz \
|
||||
busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ ; }
|
||||
|
||||
.PHONY: checkhelp
|
||||
checkhelp:
|
||||
$(Q)$(srctree)/scripts/checkhelp.awk \
|
||||
$(patsubst %,$(srctree)/%,$(wildcard $(patsubst %,%/Config.in,$(busybox-dirs) ./)))
|
||||
|
||||
.PHONY: sizes
|
||||
sizes: busybox_unstripped
|
||||
$(NM) --size-sort $(<)
|
||||
|
||||
.PHONY: bloatcheck
|
||||
bloatcheck: busybox_old busybox_unstripped
|
||||
@$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped
|
||||
|
||||
.PHONY: baseline
|
||||
baseline: busybox_unstripped
|
||||
@mv busybox_unstripped busybox_old
|
||||
|
||||
.PHONY: objsizes
|
||||
objsizes: busybox_unstripped
|
||||
$(srctree)/scripts/objsizes
|
||||
|
||||
.PHONY: bigdata
|
||||
bigdata: busybox_unstripped
|
||||
nm --size-sort busybox_unstripped | grep -vi ' [tr] ' | tail -20
|
||||
|
||||
# Documentation Targets
|
||||
.PHONY: doc
|
||||
doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
|
||||
|
||||
docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
|
||||
$(srctree)/include/usage.h \
|
||||
$(srctree)/docs/busybox_footer.pod \
|
||||
$(srctree)/docs/autodocifier.pl
|
||||
$(disp_doc)
|
||||
$(Q)-mkdir -p docs
|
||||
$(Q)-( cat $(srctree)/docs/busybox_header.pod ; \
|
||||
$(srctree)/docs/autodocifier.pl $(srctree)/include/usage.h ; \
|
||||
cat $(srctree)/docs/busybox_footer.pod ; ) > docs/busybox.pod
|
||||
|
||||
docs/BusyBox.txt: docs/busybox.pod
|
||||
$(disp_doc)
|
||||
$(Q)-mkdir -p docs
|
||||
$(Q)-pod2text $< > $@
|
||||
|
||||
docs/BusyBox.1: docs/busybox.pod
|
||||
$(disp_doc)
|
||||
$(Q)-mkdir -p docs
|
||||
$(Q)-pod2man --center=BusyBox --release="version $(VERSION)" \
|
||||
$< > $@
|
||||
|
||||
docs/BusyBox.html: docs/busybox.net/BusyBox.html
|
||||
$(disp_doc)
|
||||
$(Q)-mkdir -p docs
|
||||
$(Q)-rm -f docs/BusyBox.html
|
||||
$(Q)-cp docs/busybox.net/BusyBox.html docs/BusyBox.html
|
||||
|
||||
docs/busybox.net/BusyBox.html: docs/busybox.pod
|
||||
$(Q)-mkdir -p docs/busybox.net
|
||||
$(Q)-pod2html --noindex $< > \
|
||||
docs/busybox.net/BusyBox.html
|
||||
$(Q)-rm -f pod2htm*
|
||||
|
||||
# documentation, cross-reference
|
||||
# Modern distributions already ship synopsis packages (e.g. debian)
|
||||
# If you have an old distribution go to http://synopsis.fresco.org/
|
||||
syn_tgt = $(wildcard $(patsubst %,%/*.c,$(busybox-alldirs)))
|
||||
syn = $(patsubst %.c, %.syn, $(syn_tgt))
|
||||
|
||||
comma:= ,
|
||||
brace_open:= (
|
||||
brace_close:= )
|
||||
|
||||
SYN_CPPFLAGS := $(strip $(CPPFLAGS) $(EXTRA_CPPFLAGS))
|
||||
SYN_CPPFLAGS := $(subst $(brace_open),\$(brace_open),$(SYN_CPPFLAGS))
|
||||
SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS))
|
||||
#SYN_CPPFLAGS := $(subst ",\",$(SYN_CPPFLAGS))
|
||||
#")
|
||||
#SYN_CPPFLAGS := [$(patsubst %,'%'$(comma),$(SYN_CPPFLAGS))'']
|
||||
|
||||
%.syn: %.c
|
||||
synopsis -p C -l Comments.SSDFilter,Comments.Previous -Wp,preprocess=True,cppflags="'$(SYN_CPPFLAGS)'" -o $@ $<
|
||||
|
||||
.PHONY: html
|
||||
html: $(syn)
|
||||
synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
|
||||
@@ -0,0 +1,64 @@
|
||||
# ==========================================================================
|
||||
# Build system
|
||||
# ==========================================================================
|
||||
|
||||
BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
|
||||
|
||||
# -std=gnu99 needed for [U]LLONG_MAX on some systems
|
||||
CPPFLAGS += $(call cc-option,-std=gnu99,)
|
||||
|
||||
CPPFLAGS += \
|
||||
-Iinclude -Ilibbb \
|
||||
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
|
||||
-include include/autoconf.h \
|
||||
-D_GNU_SOURCE -DNDEBUG \
|
||||
$(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
|
||||
-D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
|
||||
|
||||
# flag checks are grouped together to speed the checks up a bit..
|
||||
CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,)
|
||||
CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
|
||||
# If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
|
||||
# (or anything else for that matter) make sure that it is still possible
|
||||
# to build bbox without warnings. Current offender: find.c:alloc_action().
|
||||
# Looks more like gcc bug: gcc will warn on it with or without prototype.
|
||||
# But still, warning-free compile is a must, or else we will drown
|
||||
# in warnings pretty soon.
|
||||
|
||||
ifeq ($(CONFIG_WERROR),y)
|
||||
CFLAGS += $(call cc-option,-Werror,)
|
||||
endif
|
||||
# gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
|
||||
CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
|
||||
|
||||
# gcc emits bogus "no prev proto" warning on find.c:alloc_action()
|
||||
ifneq ($(CONFIG_WERROR),y)
|
||||
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
|
||||
endif
|
||||
|
||||
CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
|
||||
# -fno-guess-branch-probability: prohibit pseudo-random guessing
|
||||
# of branch probabilities (hopefully makes bloatcheck more stable):
|
||||
CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
|
||||
CFLAGS += $(call cc-option,-funsigned-char -static-libgcc,)
|
||||
CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1,)
|
||||
|
||||
# FIXME: These warnings are at least partially to be concerned about and should
|
||||
# be fixed..
|
||||
#CFLAGS+=$(call cc-option,-Wconversion,)
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
CFLAGS += $(call cc-option,-g)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STATIC),y)
|
||||
LDLIBS += -static
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SELINUX),y)
|
||||
LDLIBS += -lselinux -lsepol
|
||||
endif
|
||||
#LDFLAGS += -nostdlib
|
||||
|
||||
# Busybox is a stack-fatty so make sure we increase default size
|
||||
FLTFLAGS += -s 20000
|
||||
@@ -0,0 +1,42 @@
|
||||
# ==========================================================================
|
||||
# Build system
|
||||
# ==========================================================================
|
||||
|
||||
help:
|
||||
@echo 'Cleaning:'
|
||||
@echo ' clean - delete temporary files created by build'
|
||||
@echo ' distclean - delete all non-source files (including .config)'
|
||||
@echo
|
||||
@echo 'Build:'
|
||||
@echo ' all - Executable and documentation'
|
||||
@echo ' busybox - the swiss-army executable'
|
||||
@echo ' doc - docs/BusyBox.{txt,html,1}'
|
||||
@echo ' html - create html-based cross-reference'
|
||||
@echo
|
||||
@echo 'Configuration:'
|
||||
@echo ' allnoconfig - disable all symbols in .config'
|
||||
@echo ' allyesconfig - enable all symbols in .config (see defconfig)'
|
||||
@echo ' allbareconfig - enable all applets without any sub-features'
|
||||
@echo ' config - text based configurator (of last resort)'
|
||||
@echo ' defconfig - set .config to largest generic configuration'
|
||||
@echo ' menuconfig - interactive curses-based configurator'
|
||||
@echo ' oldconfig - resolve any unresolved symbols in .config'
|
||||
@echo ' hosttools - build sed for the host.'
|
||||
@echo ' You can use these commands if the commands on the host'
|
||||
@echo ' is unusable. Afterwards use it like:'
|
||||
@echo ' make SED="$(objtree)/sed"'
|
||||
@echo
|
||||
@echo 'Installation:'
|
||||
@echo ' install - install busybox into $(CONFIG_PREFIX)'
|
||||
@echo ' uninstall'
|
||||
@echo
|
||||
@echo 'Development:'
|
||||
@echo ' baseline - create busybox_old for bloatcheck.'
|
||||
@echo ' bloatcheck - show size difference between old and new versions'
|
||||
@echo ' check - run the test suite for all applets'
|
||||
@echo ' checkhelp - check for missing help-entries in Config.in'
|
||||
@echo ' randconfig - generate a random configuration'
|
||||
@echo ' release - create a distribution tarball'
|
||||
@echo ' sizes - show size of all enabled busybox symbols'
|
||||
@echo ' objsizes - show size of each .o object built'
|
||||
@echo
|
||||
@@ -50,10 +50,10 @@ Using busybox:
|
||||
|
||||
The build automatically generates a file "busybox.links", which is used by
|
||||
'make install' to create symlinks to the BusyBox binary for all compiled in
|
||||
commands. This uses the PREFIX environment variable to specify where to
|
||||
install, and installs hardlinks or symlinks depending on the configuration
|
||||
preferences. (You can also manually run the install script at
|
||||
"applets/install.sh").
|
||||
commands. This uses the CONFIG_PREFIX environment variable to specify
|
||||
where to install, and installs hardlinks or symlinks depending
|
||||
on the configuration preferences. (You can also manually run
|
||||
the install script at "applets/install.sh").
|
||||
|
||||
----------------
|
||||
|
||||
@@ -194,5 +194,5 @@ Supported hardware:
|
||||
|
||||
Please feed suggestions, bug reports, insults, and bribes back to the busybox
|
||||
maintainer:
|
||||
Rob Landley
|
||||
<rob@landley.net>
|
||||
Denis Vlasenko
|
||||
<vda.linux@googlemail.com>
|
||||
@@ -1,427 +0,0 @@
|
||||
# Rules.make for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under GPLv2, see the file LICENSE in this tarball for details.
|
||||
#
|
||||
|
||||
# Pull in the user's busybox configuration
|
||||
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
|
||||
-include $(top_builddir)/.config
|
||||
endif
|
||||
|
||||
#--------------------------------------------------------
|
||||
PROG := busybox
|
||||
MAJOR_VERSION :=1
|
||||
MINOR_VERSION :=2
|
||||
SUBLEVEL_VERSION:=0
|
||||
EXTRAVERSION :=
|
||||
VERSION :=$(MAJOR_VERSION).$(MINOR_VERSION).$(SUBLEVEL_VERSION)$(EXTRAVERSION)
|
||||
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
|
||||
|
||||
|
||||
#--------------------------------------------------------
|
||||
# With a modern GNU make(1) (highly recommended, that's what all the
|
||||
# developers use), all of the following configuration values can be
|
||||
# overridden at the command line. For example:
|
||||
# make CROSS_COMPILE=powerpc-linux- top_srcdir="$HOME/busybox" PREFIX=/mnt/app
|
||||
#--------------------------------------------------------
|
||||
|
||||
# If you are running a cross compiler, you will want to set CROSS_COMPILE
|
||||
# to something more interesting... Target architecture is determined
|
||||
# by asking the CC compiler what arch it compiles things for, so unless
|
||||
# your compiler is broken, you should not need to specify TARGET_ARCH
|
||||
CC = $(CROSS_COMPILE)gcc
|
||||
AR = $(CROSS_COMPILE)ar
|
||||
AS = $(CROSS_COMPILE)as
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
NM = $(CROSS_COMPILE)nm
|
||||
STRIP = $(CROSS_COMPILE)strip
|
||||
ELF2FLT = $(CROSS_COMPILE)elf2flt
|
||||
CPP = $(CC) -E
|
||||
SED ?= sed
|
||||
BZIP2 ?= bzip2
|
||||
|
||||
|
||||
# What OS are you compiling busybox for? This allows you to include
|
||||
# OS specific things, syscall overrides, etc.
|
||||
TARGET_OS=linux
|
||||
|
||||
# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
|
||||
LC_ALL:= C
|
||||
|
||||
# This must bind late because srcdir is reset for every source subdirectory.
|
||||
INCS:=-I$(top_builddir)/include -I$(top_srcdir)/include
|
||||
CFLAGS=$(INCS) -I$(srcdir) -D_GNU_SOURCE
|
||||
CFLAGS+=$(CHECKED_CFLAGS)
|
||||
ARFLAGS=cru
|
||||
|
||||
# gcc centric. Perhaps fiddle with findstring gcc,$(CC) for the rest
|
||||
# get the CC MAJOR/MINOR version
|
||||
CC_MAJOR:=$(shell printf "%02d" $(shell echo __GNUC__ | $(CC) -E -xc - | tail -n 1))
|
||||
CC_MINOR:=$(shell printf "%02d" $(shell echo __GNUC_MINOR__ | $(CC) -E -xc - | tail -n 1))
|
||||
|
||||
#--------------------------------------------------------
|
||||
export VERSION BUILDTIME HOSTCC HOSTCFLAGS CROSS_COMPILE CC AR AS LD NM STRIP CPP
|
||||
ifeq ($(strip $(TARGET_ARCH)),)
|
||||
TARGET_ARCH:=$(shell $(CC) -dumpmachine | $(SED) -e s'/-.*//' \
|
||||
-e 's/i.86/i386/' \
|
||||
-e 's/sparc.*/sparc/' \
|
||||
-e 's/arm.*/arm/g' \
|
||||
-e 's/m68k.*/m68k/' \
|
||||
-e 's/ppc/powerpc/g' \
|
||||
-e 's/v850.*/v850/g' \
|
||||
-e 's/sh[234]/sh/' \
|
||||
-e 's/mips-.*/mips/' \
|
||||
-e 's/mipsel-.*/mipsel/' \
|
||||
-e 's/cris.*/cris/' \
|
||||
)
|
||||
endif
|
||||
|
||||
# A nifty macro to make testing gcc features easier, but note that everything
|
||||
# that uses this _must_ use := or it will be re-evaluated everytime it is
|
||||
# referenced.
|
||||
ifeq ($(strip $(BUILD_VERBOSE)),2)
|
||||
VERBOSE_CHECK_CC=echo CC=\"$(1)\" check_cc $(2) >&2;
|
||||
endif
|
||||
check_cc=$(shell \
|
||||
$(VERBOSE_CHECK_CC) \
|
||||
if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
|
||||
echo "int i;" > ./conftest.c; \
|
||||
if $(1) $(2) -c -o conftest.o conftest.c > /dev/null 2>&1; \
|
||||
then echo "$(2)"; else echo "$(3)"; fi ; \
|
||||
rm -f conftest.c conftest.o; \
|
||||
fi)
|
||||
|
||||
ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
|
||||
check_cc:=
|
||||
endif
|
||||
|
||||
# A not very robust macro to check for available ld flags
|
||||
ifeq ($(strip $(BUILD_VERBOSE)),2)
|
||||
VERBOSE_CHECK_LD=echo LD=\"$(1)\" check_ld $(2) >&2;
|
||||
endif
|
||||
check_ld=$(shell \
|
||||
$(VERBOSE_CHECK_LD) \
|
||||
if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
|
||||
$(1) -o /dev/null -b binary /dev/null > /dev/null 2>&1 && \
|
||||
echo "-Wl,$(2)" ; \
|
||||
fi)
|
||||
|
||||
ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
|
||||
check_ld:=
|
||||
endif
|
||||
|
||||
# A not very robust macro to check for available strip flags
|
||||
ifeq ($(strip $(BUILD_VERBOSE)),2)
|
||||
VERBOSE_CHECK_STRIP=echo STRIPCMD=\"$(1)\" check_strip $(2) >&2;
|
||||
endif
|
||||
check_strip=$(shell \
|
||||
$(VERBOSE_CHECK_STRIP) \
|
||||
if [ "x$(1)" != "x" ] && [ "x$(2)" != "x" ]; then \
|
||||
echo "int i;" > ./conftest.c ; \
|
||||
$(CC) -c -o conftest.o conftest.c > /dev/null 2>&1 ; \
|
||||
$(1) $(2) conftest.o > /dev/null 2>&1 && \
|
||||
echo "$(1) $(2)" || echo "$(3)"; \
|
||||
rm -f conftest.c conftest.o > /dev/null 2>&1 ; \
|
||||
fi)
|
||||
|
||||
ifneq ($(filter $(nocheck_targets),$(MAKECMDGOALS)),)
|
||||
check_strip:=
|
||||
endif
|
||||
|
||||
|
||||
# Select the compiler needed to build binaries for your development system
|
||||
HOSTCC = gcc
|
||||
HOSTCFLAGS:=$(call check_cc,$(HOSTCC),-Wall,)
|
||||
HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-Wstrict-prototypes,)
|
||||
HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-O2,)
|
||||
HOSTCFLAGS+=$(call check_cc,$(HOSTCC),-fomit-frame-pointer,)
|
||||
|
||||
LD_WHOLE_ARCHIVE:=$(shell echo "int i;" > conftest.c ; \
|
||||
$(CC) -c -o conftest.o conftest.c ; \
|
||||
echo "int main(void){return 0;}" > conftest_main.c ; \
|
||||
$(CC) -c -o conftest_main.o conftest_main.c ; \
|
||||
$(AR) $(ARFLAGS) conftest.a conftest.o ; \
|
||||
$(CC) -Wl,--whole-archive conftest.a -Wl,--no-whole-archive \
|
||||
conftest_main.o -o conftest > /dev/null 2>&1 \
|
||||
&& echo "-Wl,--whole-archive" ; \
|
||||
rm conftest_main.o conftest_main.c conftest.o conftest.c \
|
||||
conftest.a conftest > /dev/null 2>&1 ; )
|
||||
ifneq ($(findstring whole-archive,$(LD_WHOLE_ARCHIVE)),)
|
||||
LD_NO_WHOLE_ARCHIVE:= -Wl,--no-whole-archive
|
||||
endif
|
||||
|
||||
LD_START_GROUP:=$(shell echo "int bar(void){return 0;}" > conftest.c ; \
|
||||
$(CC) -c -o conftest.o conftest.c ; \
|
||||
echo "int main(void){return bar();}" > conftest_main.c ; \
|
||||
$(CC) -c -o conftest_main.o conftest_main.c ; \
|
||||
$(AR) $(ARFLAGS) conftest.a conftest.o ; \
|
||||
$(CC) -Wl,--start-group conftest.a conftest_main.o -Wl,--end-group \
|
||||
-o conftest > /dev/null 2>&1 && echo "-Wl,--start-group" ; \
|
||||
rm conftest_main.o conftest_main.c conftest.o conftest.c \
|
||||
conftest.a conftest > /dev/null 2>&1 ; )
|
||||
ifneq ($(findstring start-group,$(LD_START_GROUP)),)
|
||||
LD_END_GROUP:= -Wl,--end-group
|
||||
endif
|
||||
|
||||
CHECKED_LDFLAGS := $(call check_ld,$(LD),--warn-common,)
|
||||
|
||||
# Pin CHECKED_CFLAGS with := so it's only evaluated once.
|
||||
CHECKED_CFLAGS:=$(call check_cc,$(CC),-Wall,)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(HOSTCC),-Werror,)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-funsigned-char,)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-mmax-stack-frame=256,)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-fno-builtin-strlen)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-finline-limit=0)
|
||||
|
||||
# Preemptively pin this too.
|
||||
PROG_CFLAGS:=
|
||||
|
||||
|
||||
#--------------------------------------------------------
|
||||
# Arch specific compiler optimization stuff should go here.
|
||||
# Unless you want to override the defaults, do not set anything
|
||||
# for OPTIMIZATION...
|
||||
|
||||
# use '-Os' optimization if available, else use -O2
|
||||
OPTIMIZATION:=$(call check_cc,$(CC),-Os,-O2)
|
||||
|
||||
ifeq ($(CONFIG_BUILD_AT_ONCE),y)
|
||||
# gcc 2.95 exits with 0 for "unrecognized option"
|
||||
ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 3 ] ; echo $$?)),0)
|
||||
CFLAGS_COMBINE:=$(call check_cc,$(CC),--combine,)
|
||||
endif
|
||||
OPTIMIZATION+=$(call check_cc,$(CC),-funit-at-a-time,)
|
||||
OPTIMIZATION+=$(call check_cc,$(CC),-fgcse-after-reload,)
|
||||
ifneq ($(CONFIG_BUILD_LIBBUSYBOX),y)
|
||||
# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25795
|
||||
# This prevents us from using -fwhole-program when we build the lib
|
||||
PROG_CFLAGS+=$(call check_cc,$(CC),-fwhole-program,)
|
||||
endif # CONFIG_BUILD_LIBBUSYBOX
|
||||
endif # CONFIG_BUILD_AT_ONCE
|
||||
|
||||
LIB_LDFLAGS:=$(call check_ld,$(LD),--enable-new-dtags,)
|
||||
#LIB_LDFLAGS+=$(call check_ld,$(LD),--reduce-memory-overheads,)
|
||||
#LIB_LDFLAGS+=$(call check_ld,$(LD),--as-needed,)
|
||||
#LIB_LDFLAGS+=$(call check_ld,$(LD),--warn-shared-textrel,)
|
||||
|
||||
|
||||
# Some nice architecture specific optimizations
|
||||
ifeq ($(strip $(TARGET_ARCH)),arm)
|
||||
OPTIMIZATION+=-fstrict-aliasing
|
||||
endif
|
||||
ifeq ($(strip $(TARGET_ARCH)),i386)
|
||||
OPTIMIZATION+=$(call check_cc,$(CC),-march=i386,)
|
||||
# gcc-4.0 and older seem to benefit from these
|
||||
#ifneq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
|
||||
OPTIMIZATION+=$(call check_cc,$(CC),-mpreferred-stack-boundary=2,)
|
||||
OPTIMIZATION+=$(call check_cc,$(CC),-falign-functions=1 -falign-jumps=1 -falign-loops=1,\
|
||||
-malign-functions=0 -malign-jumps=0 -malign-loops=0)
|
||||
#endif # gcc-4.0 and older
|
||||
|
||||
# gcc-4.1 and beyond seem to benefit from these
|
||||
ifeq ($(strip $(shell [ $(CC_MAJOR) -ge 4 -a $(CC_MINOR) -ge 1 ] ; echo $$?)),0)
|
||||
# turn off flags which hurt -Os
|
||||
OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-loop-optimize,)
|
||||
OPTIMIZATION+=$(call check_cc,$(CC),-fno-tree-dominator-opts,)
|
||||
OPTIMIZATION+=$(call check_cc,$(CC),-fno-strength-reduce,)
|
||||
|
||||
OPTIMIZATION+=$(call check_cc,$(CC),-fno-branch-count-reg,)
|
||||
endif # gcc-4.1 and beyond
|
||||
endif
|
||||
OPTIMIZATION+=$(call check_cc,$(CC),-fomit-frame-pointer,)
|
||||
OPTIMIZATION+=$(call check_cc,$(CC),-ffunction-sections -fdata-sections,)
|
||||
|
||||
#
|
||||
#--------------------------------------------------------
|
||||
# If you're going to do a lot of builds with a non-vanilla configuration,
|
||||
# it makes sense to adjust parameters above, so you can type "make"
|
||||
# by itself, instead of following it by the same half-dozen overrides
|
||||
# every time. The stuff below, on the other hand, is probably less
|
||||
# prone to casual user adjustment.
|
||||
#
|
||||
|
||||
ifeq ($(strip $(CONFIG_LFS)),y)
|
||||
# For large file summit support
|
||||
CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
|
||||
endif
|
||||
ifeq ($(strip $(CONFIG_DMALLOC)),y)
|
||||
# For testing mem leaks with dmalloc
|
||||
CFLAGS+=-DDMALLOC
|
||||
LIBRARIES:=-ldmalloc
|
||||
else
|
||||
ifeq ($(strip $(CONFIG_EFENCE)),y)
|
||||
LIBRARIES:=-lefence
|
||||
endif
|
||||
endif
|
||||
|
||||
# Debugging info
|
||||
|
||||
ifeq ($(strip $(CONFIG_DEBUG)),y)
|
||||
CFLAGS +=-g
|
||||
else
|
||||
CFLAGS +=-DNDEBUG
|
||||
CHECKED_LDFLAGS += $(call check_ld,$(LD),--sort-common,)
|
||||
CHECKED_LDFLAGS += $(call check_ld,--gc-sections,)
|
||||
endif
|
||||
|
||||
ifneq ($(strip $(CONFIG_DEBUG_PESSIMIZE)),y)
|
||||
CFLAGS += $(OPTIMIZATION)
|
||||
endif
|
||||
|
||||
# warn a bit more verbosely for non-release versions
|
||||
ifneq ($(EXTRAVERSION),)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wstrict-prototypes,)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-prototypes,)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wmissing-declarations,)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wunused,)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Winit-self,)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wshadow,)
|
||||
CHECKED_CFLAGS+=$(call check_cc,$(CC),-Wcast-align,)
|
||||
endif
|
||||
STRIPCMD:=$(call check_strip,$(STRIP),-s --remove-section=.note --remove-section=.comment,$(STRIP))
|
||||
ifeq ($(strip $(CONFIG_STATIC)),y)
|
||||
PROG_CFLAGS += $(call check_cc,$(CC),-static,)
|
||||
endif
|
||||
CFLAGS_SHARED := $(call check_cc,$(CC),-shared,)
|
||||
LIB_CFLAGS+=$(CFLAGS_SHARED)
|
||||
|
||||
ifeq ($(strip $(CONFIG_BUILD_LIBBUSYBOX)),y)
|
||||
CFLAGS_PIC:= $(call check_cc,$(CC),-fPIC,)
|
||||
LIB_CFLAGS+=$(CFLAGS_PIC)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(CONFIG_SELINUX)),y)
|
||||
LIBRARIES += -lselinux
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(PREFIX)),)
|
||||
PREFIX:=`pwd`/_install
|
||||
endif
|
||||
|
||||
ifneq ($(strip $(CONFIG_GETOPT_LONG)),y)
|
||||
CFLAGS += -D__need_getopt
|
||||
endif
|
||||
|
||||
# Additional complications due to support for pristine source dir.
|
||||
# Include files in the build directory should take precedence over
|
||||
# the copy in top_srcdir, both during the compilation phase and the
|
||||
# shell script that finds the list of object files.
|
||||
# Work in progress by <ldoolitt@recycle.lbl.gov>.
|
||||
|
||||
|
||||
OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
|
||||
CFLAGS += $(CHECKED_CFLAGS) $(CROSS_CFLAGS)
|
||||
LDFLAGS += $(CHECKED_LDFLAGS)
|
||||
|
||||
ifdef BB_INIT_SCRIPT
|
||||
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
|
||||
endif
|
||||
|
||||
# Put user-supplied flags at the end, where they
|
||||
# have a chance of winning.
|
||||
-include $(top_builddir)/.config.mak
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Installation options
|
||||
ifeq ($(strip $(CONFIG_INSTALL_APPLET_HARDLINKS)),y)
|
||||
INSTALL_OPTS=--hardlinks
|
||||
endif
|
||||
ifeq ($(strip $(CONFIG_INSTALL_APPLET_SYMLINKS)),y)
|
||||
INSTALL_OPTS=--symlinks
|
||||
endif
|
||||
ifeq ($(strip $(CONFIG_INSTALL_APPLET_DONT)),y)
|
||||
INSTALL_OPTS=
|
||||
endif
|
||||
|
||||
#------------------------------------------------------------
|
||||
# Make the output nice and tight
|
||||
MAKEFLAGS += --no-print-directory
|
||||
export MAKE_IS_SILENT=n
|
||||
ifneq ($(findstring s,$(MAKEFLAGS)),)
|
||||
export MAKE_IS_SILENT=y
|
||||
SECHO := @-false
|
||||
DISP := sil
|
||||
Q := @
|
||||
else
|
||||
ifneq ($(BUILD_VERBOSE),)
|
||||
SECHO := @-false
|
||||
DISP := ver
|
||||
Q :=
|
||||
else
|
||||
SECHO := @echo
|
||||
DISP := pur
|
||||
Q := @
|
||||
endif
|
||||
endif
|
||||
|
||||
show_objs = $(subst $(top_builddir)/,,$(subst ../,,$@))
|
||||
pur_disp_compile.c = echo " "CC $(show_objs)
|
||||
pur_disp_compile.h = echo " "HOSTCC $(show_objs)
|
||||
pur_disp_strip = echo " "STRIP $(show_objs)
|
||||
pur_disp_link = echo " "LINK $(show_objs)
|
||||
pur_disp_link.h = echo " "HOSTLINK $(show_objs)
|
||||
pur_disp_ar = echo " "AR $(ARFLAGS) $(show_objs)
|
||||
pur_disp_elf2flt = echo " "ELF2FLT $(ELF2FLTFLAGS) $(show_objs)
|
||||
sil_disp_compile.c = true
|
||||
sil_disp_compile.h = true
|
||||
sil_disp_strip = true
|
||||
sil_disp_link = true
|
||||
sil_disp_link.h = true
|
||||
sil_disp_ar = true
|
||||
sil_disp_elf2flt = true
|
||||
ver_disp_compile.c = echo $(cmd_compile.c)
|
||||
ver_disp_compile.h = echo $(cmd_compile.h)
|
||||
ver_disp_strip = echo $(cmd_strip)
|
||||
ver_disp_link = echo $(cmd_link)
|
||||
ver_disp_link.h = echo $(cmd_link.h)
|
||||
ver_disp_ar = echo $(cmd_ar)
|
||||
ver_disp_elf2flt = echo $(cmd_elf2flt)
|
||||
disp_compile.c = $($(DISP)_disp_compile.c)
|
||||
disp_compile.h = $($(DISP)_disp_compile.h)
|
||||
disp_strip = $($(DISP)_disp_strip)
|
||||
disp_link = $($(DISP)_disp_link)
|
||||
disp_link.h = $($(DISP)_disp_link.h)
|
||||
disp_ar = $($(DISP)_disp_ar)
|
||||
disp_gen = $(SECHO) " "GEN $@ ; true
|
||||
disp_doc = $(SECHO) " "DOC $(subst docs/,,$@) ; true
|
||||
disp_elf2flt = $($(DISP)_disp_elf2flt)
|
||||
cmd_compile.c = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
cmd_compile.h = $(HOSTCC) $(HOSTCFLAGS) $(INCS) -c -o $@ $<
|
||||
cmd_strip = $(STRIPCMD) $@
|
||||
cmd_link = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \
|
||||
$(PROG_CFLAGS) $(PROG_LDFLAGS) $(CFLAGS_COMBINE) \
|
||||
-o $@ $(LD_START_GROUP) \
|
||||
$(APPLETS_DEFINE) $(APPLET_SRC) \
|
||||
$(BUSYBOX_DEFINE) $(BUSYBOX_SRC) $(libraries-y) \
|
||||
$(LDBUSYBOX) $(LIBRARIES) \
|
||||
$(LD_END_GROUP)
|
||||
cmd_link.so = $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) \
|
||||
$(LIB_CFLAGS) $(CFLAGS_COMBINE) $(LIB_LDFLAGS) \
|
||||
-o $(@) $(LD_START_GROUP) $(LD_WHOLE_ARCHIVE) \
|
||||
$(LIBRARY_DEFINE) $(^) \
|
||||
$(LD_NO_WHOLE_ARCHIVE) $(LD_END_GROUP)
|
||||
cmd_link.h = $(HOSTCC) $(HOSTCFLAGS) $(INCS) $< -o $@
|
||||
cmd_ar = $(AR) $(ARFLAGS) $@ $^
|
||||
cmd_elf2flt = $(ELF2FLT) $(ELF2FLTFLAGS) $< -o $@
|
||||
compile.c = @$(disp_compile.c) ; $(cmd_compile.c)
|
||||
compile.h = @$(disp_compile.h) ; $(cmd_compile.h)
|
||||
do_strip = @$(disp_strip) ; $(cmd_strip)
|
||||
do_link = @$(disp_link) ; $(cmd_link)
|
||||
do_link.so = @$(disp_link) ; $(cmd_link.so)
|
||||
do_link.h = @$(disp_link.h) ; $(cmd_link.h)
|
||||
do_ar = @$(disp_ar) ; $(cmd_ar)
|
||||
do_elf2flt = @$(disp_elf2flt) ; $(cmd_elf2flt)
|
||||
|
||||
uppercase = $(shell echo $1 | $(SED) -e "y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/")
|
||||
%.a:
|
||||
@if test -z "$($(call uppercase,$*)_DIR)" ; then \
|
||||
echo "Invalid target $@" ; \
|
||||
exit 1 ; \
|
||||
fi
|
||||
$(Q)$(MAKE) $($(call uppercase,$*)_DIR)$@
|
||||
|
||||
.PHONY: dummy
|
||||
@@ -33,7 +33,7 @@ Rob Landley <rob@landley.net>:
|
||||
depmod
|
||||
busybox lacks a way to update module deps when running from firmware without the
|
||||
use of the depmod.pl (perl is to bloated for most embedded setups) and or orig
|
||||
modutils. The orig depmod is rather pointless to have to add to a firmware image
|
||||
modutils. The orig depmod is rather pointless to have to add to a firmware image
|
||||
in when we already have a insmod/rmmod and friends.
|
||||
Unify base64 handling.
|
||||
There's base64 encoding and decoding going on in:
|
||||
@@ -117,13 +117,19 @@ Rob Landley <rob@landley.net>:
|
||||
This one's open to everybody, but I'll wind up doing it...
|
||||
|
||||
|
||||
Bernhard Fischer <rep.nop@anon.at>:
|
||||
Makefile stuff:
|
||||
make -j is broken, -j1 is forced atm
|
||||
Bernhard Fischer <busybox@busybox.net> suggests to look at these:
|
||||
New debug options:
|
||||
-Wlarger-than-127
|
||||
Cleanup any big users
|
||||
-Wunused-parameter
|
||||
Facilitate applet PROTOTYPES to provide means for having applets that
|
||||
do a) not take any arguments b) need only one of argc or argv c) need
|
||||
both argc and argv. All of these three options should go for the most
|
||||
feature complete denominator.
|
||||
Collate BUFSIZ IOBUF_SIZE MY_BUF_SIZE PIPE_PROGRESS_SIZE BUFSIZE PIPESIZE
|
||||
Use bb_common_bufsiz1?
|
||||
make bb_common_bufsiz1 configurable, size wise.
|
||||
make pipesize configurable, size wise.
|
||||
Use bb_common_bufsiz1 throughout applets!
|
||||
|
||||
As yet unclaimed:
|
||||
|
||||
@@ -135,10 +141,10 @@ diff
|
||||
Make sure we handle empty files properly:
|
||||
From the patch man page:
|
||||
|
||||
you can remove a file by sending out a context diff that compares
|
||||
the file to be deleted with an empty file dated the Epoch. The
|
||||
file will be removed unless patch is conforming to POSIX and the
|
||||
-E or --remove-empty-files option is not given.
|
||||
you can remove a file by sending out a context diff that compares
|
||||
the file to be deleted with an empty file dated the Epoch. The
|
||||
file will be removed unless patch is conforming to POSIX and the
|
||||
-E or --remove-empty-files option is not given.
|
||||
---
|
||||
patch
|
||||
Should have simple fuzz factor support to apply patches at an offset which
|
||||
@@ -147,6 +153,10 @@ patch
|
||||
And while we're at it, a new patch filename quoting format is apparently
|
||||
coming soon: http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
|
||||
---
|
||||
ps / top
|
||||
Add support for both RSS and VSIZE rather than just one or the other.
|
||||
Or make it a build option.
|
||||
---
|
||||
man
|
||||
It would be nice to have a man command. Not one that handles troff or
|
||||
anything, just one that can handle preformatted ascii man pages, possibly
|
||||
@@ -157,9 +167,15 @@ man
|
||||
---
|
||||
ar
|
||||
Write support?
|
||||
---
|
||||
crond
|
||||
turn FEATURE_DEBUG_OPT into ENABLE_FEATURE_CROND_DEBUG_OPT
|
||||
----
|
||||
stty / catv
|
||||
stty's visible() function and catv's guts are identical. Merge them into
|
||||
an appropriate libbb function.
|
||||
----
|
||||
struct suffix_mult
|
||||
Several duplicate users of: grep -r "1024\*1024" * -B2 -A1
|
||||
Merge to a single size_suffixes[] in libbb.
|
||||
Users: head tail od_bloaty hexdump and (partially as it wouldn't hurt) svlogd
|
||||
|
||||
Architectural issues:
|
||||
|
||||
@@ -255,7 +271,7 @@ FEATURE_CLEAN_UP
|
||||
jumps out of the normal flow control and bypasses any cleanup code we
|
||||
put at the end of our applets.
|
||||
|
||||
It's possible to add hooks to libbb functions like xmalloc() and bb_xopen()
|
||||
It's possible to add hooks to libbb functions like xmalloc() and xopen()
|
||||
to add their entries to a linked list, which could be traversed and
|
||||
freed/closed automatically. (This would need to be able to free just the
|
||||
entries after a checkpoint to be usable for a forkless standalone shell.
|
||||
@@ -287,9 +303,6 @@ Minor stuff:
|
||||
-> fprintf(stderr, "unalias: %s not found\n", *argptr);
|
||||
---
|
||||
possible code duplication ingroup() and is_a_group_member()
|
||||
---
|
||||
unify itoa: netstat.c, hush.c, lash.c, msh.c
|
||||
Put one single, robust version into e.g. safe_strtol.c
|
||||
---
|
||||
Move __get_hz() to a better place and (re)use it in route.c, ash.c, msh.c
|
||||
---
|
||||
@@ -305,4 +318,3 @@ sigblock(), siggetmask(), sigsetmask(), sigmask() -> sigprocmask et al
|
||||
---
|
||||
vdprintf() -> similar sized functionality
|
||||
---
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
obj-y:=
|
||||
obj-y += applets.o
|
||||
obj-y += busybox.o
|
||||
|
||||
# Generated file needs additional love
|
||||
|
||||
applets/applets.o: .config include/usage_compressed.h
|
||||
|
||||
hostprogs-y += usage
|
||||
always := $(hostprogs-y)
|
||||
HOSTCFLAGS_usage.o = -I$(srctree)/include
|
||||
|
||||
quiet_cmd_gen_usage_compressed = GEN include/usage_compressed.h
|
||||
cmd_gen_usage_compressed = $(srctree)/applets/usage_compressed include/usage_compressed.h applets
|
||||
include/usage_compressed.h: .config $(srctree)/include/usage.h applets/usage
|
||||
$(call cmd,gen_usage_compressed)
|
||||
@@ -1,23 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
ifndef top_srcdir
|
||||
top_srcdir=..
|
||||
endif
|
||||
ifndef top_builddir
|
||||
top_builddir=..
|
||||
endif
|
||||
srcdir=$(top_srcdir)/applets
|
||||
APPLETS_DIR:=./
|
||||
include $(top_srcdir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(top_builddir).depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
APPLETS_AR:=applets.a
|
||||
ifndef $(APPLETS_DIR)
|
||||
APPLETS_DIR:=$(top_builddir)/applets/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/applets
|
||||
|
||||
APPLET_SRC:= $(patsubst %,$(srcdir)/%,applets.c busybox.c version.c)
|
||||
APPLET_OBJ:= $(patsubst $(srcdir)/%.c,$(APPLETS_DIR)%.o, $(APPLET_SRC))
|
||||
|
||||
APPLET_SRC-y+=$(APPLET_SRC)
|
||||
APPLET_SRC-a+=$(APPLET_SRC)
|
||||
|
||||
libraries-y+=$(APPLETS_DIR)$(APPLETS_AR)
|
||||
|
||||
$(APPLETS_DIR)$(APPLETS_AR): $(APPLET_OBJ)
|
||||
$(do_ar)
|
||||
|
||||
$(APPLET_OBJ): $(top_builddir)/.config
|
||||
$(APPLET_OBJ): $(APPLETS_DIR)%.o: $(srcdir)/%.c
|
||||
$(compile.c)
|
||||
+104
-86
@@ -12,10 +12,23 @@
|
||||
* Licensed under GPLv2 or later, see file License in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define PROTOTYPES
|
||||
#include "applets.h"
|
||||
#undef PROTOTYPES
|
||||
|
||||
|
||||
/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
|
||||
#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
|
||||
#warning Static linking against glibc produces buggy executables
|
||||
#warning (glibc does not cope well with ld --gc-sections).
|
||||
#warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
|
||||
#warning Note that glibc is unsuitable for static linking anyway.
|
||||
#warning If you still want to do it, remove -Wl,--gc-sections
|
||||
#warning from top-level Makefile and remove this warning.
|
||||
#endif
|
||||
|
||||
#if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE
|
||||
static const char usage_messages[] =
|
||||
@@ -36,47 +49,45 @@ static const char usage_messages[] =
|
||||
static struct BB_applet *applet_using;
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
|
||||
const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
const unsigned short NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
|
||||
#include <ctype.h>
|
||||
#include "pwd_.h"
|
||||
#include "grp_.h"
|
||||
|
||||
#define CONFIG_FILE "/etc/busybox.conf"
|
||||
|
||||
/* applets [] is const, so we have to define this "override" structure */
|
||||
static struct BB_suid_config
|
||||
{
|
||||
struct BB_applet *m_applet;
|
||||
struct BB_applet *m_applet;
|
||||
|
||||
uid_t m_uid;
|
||||
gid_t m_gid;
|
||||
mode_t m_mode;
|
||||
uid_t m_uid;
|
||||
gid_t m_gid;
|
||||
mode_t m_mode;
|
||||
|
||||
struct BB_suid_config *m_next;
|
||||
struct BB_suid_config *m_next;
|
||||
} *suid_config;
|
||||
|
||||
static int suid_cfg_readable;
|
||||
|
||||
/* check if u is member of group g */
|
||||
static int ingroup (uid_t u, gid_t g)
|
||||
static int ingroup(uid_t u, gid_t g)
|
||||
{
|
||||
struct group *grp = getgrgid (g);
|
||||
struct group *grp = getgrgid(g);
|
||||
|
||||
if (grp) {
|
||||
char **mem;
|
||||
if (grp) {
|
||||
char **mem;
|
||||
|
||||
for (mem = grp->gr_mem; *mem; mem++) {
|
||||
struct passwd *pwd = getpwnam (*mem);
|
||||
for (mem = grp->gr_mem; *mem; mem++) {
|
||||
struct passwd *pwd = getpwnam(*mem);
|
||||
|
||||
if (pwd && (pwd->pw_uid == u))
|
||||
return 1;
|
||||
if (pwd && (pwd->pw_uid == u))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This should probably be a libbb routine. In that case,
|
||||
@@ -100,7 +111,7 @@ static char *get_trimmed_slice(char *s, char *e)
|
||||
}
|
||||
|
||||
|
||||
#define parse_error(x) { err=x; goto pe_label; }
|
||||
#define parse_error(x) do { errmsg = x; goto pe_label; } while(0)
|
||||
|
||||
/* Don't depend on the tools to combine strings. */
|
||||
static const char config_file[] = CONFIG_FILE;
|
||||
@@ -124,7 +135,7 @@ static void parse_config_file(void)
|
||||
struct BB_suid_config *sct;
|
||||
struct BB_applet *applet;
|
||||
FILE *f;
|
||||
char *err;
|
||||
const char *errmsg;
|
||||
char *s;
|
||||
char *e;
|
||||
int i, lc, section;
|
||||
@@ -137,7 +148,7 @@ static void parse_config_file(void)
|
||||
|| !S_ISREG(st.st_mode) /* Not a regular file? */
|
||||
|| (st.st_uid != 0) /* Not owned by root? */
|
||||
|| (st.st_mode & (S_IWGRP | S_IWOTH)) /* Writable by non-root? */
|
||||
|| !(f = fopen(config_file, "r")) /* Can not open? */
|
||||
|| !(f = fopen(config_file, "r")) /* Cannot open? */
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -266,8 +277,8 @@ static void parse_config_file(void)
|
||||
|
||||
sct->m_uid = strtoul(s, &e2, 10);
|
||||
if (*e2 || (s == e2)) {
|
||||
struct passwd *pwd;
|
||||
if (!(pwd = getpwnam(s))) {
|
||||
struct passwd *pwd = getpwnam(s);
|
||||
if (!pwd) {
|
||||
parse_error("user");
|
||||
}
|
||||
sct->m_uid = pwd->pw_uid;
|
||||
@@ -301,7 +312,7 @@ static void parse_config_file(void)
|
||||
|
||||
pe_label:
|
||||
fprintf(stderr, "Parse error in %s, line %d: %s\n",
|
||||
config_file, lc, err);
|
||||
config_file, lc, errmsg);
|
||||
|
||||
fclose(f);
|
||||
/* Release any allocated memory before returning. */
|
||||
@@ -310,68 +321,73 @@ static void parse_config_file(void)
|
||||
free(sct_head);
|
||||
sct_head = sct;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#else
|
||||
#define parse_config_file()
|
||||
#define parse_config_file() ((void)0)
|
||||
#endif /* CONFIG_FEATURE_SUID_CONFIG */
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID
|
||||
static void check_suid (struct BB_applet *applet)
|
||||
static void check_suid(struct BB_applet *applet)
|
||||
{
|
||||
uid_t ruid = getuid (); /* real [ug]id */
|
||||
uid_t rgid = getgid ();
|
||||
uid_t ruid = getuid(); /* real [ug]id */
|
||||
uid_t rgid = getgid();
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
if (suid_cfg_readable) {
|
||||
struct BB_suid_config *sct;
|
||||
if (suid_cfg_readable) {
|
||||
struct BB_suid_config *sct;
|
||||
|
||||
for (sct = suid_config; sct; sct = sct->m_next) {
|
||||
if (sct->m_applet == applet)
|
||||
break;
|
||||
}
|
||||
if (sct) {
|
||||
mode_t m = sct->m_mode;
|
||||
for (sct = suid_config; sct; sct = sct->m_next) {
|
||||
if (sct->m_applet == applet)
|
||||
break;
|
||||
}
|
||||
if (sct) {
|
||||
mode_t m = sct->m_mode;
|
||||
|
||||
if (sct->m_uid == ruid) /* same uid */
|
||||
m >>= 6;
|
||||
else if ((sct->m_gid == rgid) || ingroup (ruid, sct->m_gid)) /* same group / in group */
|
||||
m >>= 3;
|
||||
if (sct->m_uid == ruid)
|
||||
/* same uid */
|
||||
m >>= 6;
|
||||
else if ((sct->m_gid == rgid) || ingroup(ruid, sct->m_gid))
|
||||
/* same group / in group */
|
||||
m >>= 3;
|
||||
|
||||
if (!(m & S_IXOTH)) /* is x bit not set ? */
|
||||
bb_error_msg_and_die ("You have no permission to run this applet!");
|
||||
if (!(m & S_IXOTH)) /* is x bit not set ? */
|
||||
bb_error_msg_and_die("you have no permission to run this applet!");
|
||||
|
||||
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { /* *both* have to be set for sgid */
|
||||
xsetgid(sct->m_gid);
|
||||
} else xsetgid(rgid); /* no sgid -> drop */
|
||||
|
||||
if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid);
|
||||
else xsetuid(ruid); /* no suid -> drop */
|
||||
if (sct->m_gid != 0) {
|
||||
/* _both_ have to be set for sgid */
|
||||
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
|
||||
xsetgid(sct->m_gid);
|
||||
} else xsetgid(rgid); /* no sgid -> drop */
|
||||
}
|
||||
if (sct->m_uid != 0) {
|
||||
if (sct->m_mode & S_ISUID) xsetuid(sct->m_uid);
|
||||
else xsetuid(ruid); /* no suid -> drop */
|
||||
}
|
||||
} else {
|
||||
/* default: drop all privileges */
|
||||
xsetgid(rgid);
|
||||
xsetuid(ruid);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
/* default: drop all privileges */
|
||||
xsetgid(rgid);
|
||||
xsetuid(ruid);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
#ifndef CONFIG_FEATURE_SUID_CONFIG_QUIET
|
||||
static int onetime = 0;
|
||||
static int onetime = 0;
|
||||
|
||||
if (!onetime) {
|
||||
onetime = 1;
|
||||
fprintf (stderr, "Using fallback suid method\n");
|
||||
if (!onetime) {
|
||||
onetime = 1;
|
||||
fprintf(stderr, "Using fallback suid method\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (applet->need_suid == _BB_SUID_ALWAYS) {
|
||||
if (geteuid()) bb_error_msg_and_die("Applet requires root privileges!");
|
||||
} else if (applet->need_suid == _BB_SUID_NEVER) {
|
||||
xsetgid(rgid); /* drop all privileges */
|
||||
xsetuid(ruid);
|
||||
}
|
||||
if (applet->need_suid == _BB_SUID_ALWAYS) {
|
||||
if (geteuid()) bb_error_msg_and_die("applet requires root privileges!");
|
||||
} else if (applet->need_suid == _BB_SUID_NEVER) {
|
||||
xsetgid(rgid); /* drop all privileges */
|
||||
xsetuid(ruid);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define check_suid(x)
|
||||
@@ -379,7 +395,7 @@ static void check_suid (struct BB_applet *applet)
|
||||
|
||||
|
||||
|
||||
#if ENABLE_FEATURE_COMPRESS_USAGE
|
||||
#ifdef CONFIG_FEATURE_COMPRESS_USAGE
|
||||
|
||||
#include "usage_compressed.h"
|
||||
#include "unarchive.h"
|
||||
@@ -426,7 +442,7 @@ static const char *unpack_usage_messages(void)
|
||||
#define unpack_usage_messages() usage_messages
|
||||
#endif /* ENABLE_FEATURE_COMPRESS_USAGE */
|
||||
|
||||
void bb_show_usage (void)
|
||||
void bb_show_usage(void)
|
||||
{
|
||||
if (ENABLE_SHOW_USAGE) {
|
||||
const char *format_string;
|
||||
@@ -439,39 +455,41 @@ void bb_show_usage (void)
|
||||
format_string = "%s\n\nUsage: %s %s\n\n";
|
||||
if (*usage_string == '\b')
|
||||
format_string = "%s\n\nNo help available.\n\n";
|
||||
fprintf (stderr, format_string, bb_msg_full_version,
|
||||
fprintf(stderr, format_string, bb_msg_full_version,
|
||||
applet_using->name, usage_string);
|
||||
}
|
||||
|
||||
exit (bb_default_error_retval);
|
||||
exit(xfunc_error_retval);
|
||||
}
|
||||
|
||||
static int applet_name_compare(const void *name, const void *vapplet)
|
||||
{
|
||||
const struct BB_applet *applet = vapplet;
|
||||
const struct BB_applet *applet = vapplet;
|
||||
|
||||
return strcmp(name, applet->name);
|
||||
return strcmp(name, applet->name);
|
||||
}
|
||||
|
||||
extern const size_t NUM_APPLETS;
|
||||
|
||||
struct BB_applet *find_applet_by_name(const char *name)
|
||||
{
|
||||
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
|
||||
applet_name_compare);
|
||||
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
|
||||
applet_name_compare);
|
||||
}
|
||||
|
||||
void run_applet_by_name(const char *name, int argc, char **argv)
|
||||
{
|
||||
if (ENABLE_FEATURE_SUID_CONFIG) parse_config_file();
|
||||
if (ENABLE_FEATURE_SUID_CONFIG)
|
||||
parse_config_file();
|
||||
|
||||
if (!strncmp(name, "busybox", 7)) busybox_main(argc, argv);
|
||||
if (!strncmp(name, "busybox", 7))
|
||||
exit(busybox_main(argc, argv));
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
applet_using = find_applet_by_name(name);
|
||||
if (applet_using) {
|
||||
bb_applet_name = applet_using->name;
|
||||
if(argc==2 && !strcmp(argv[1], "--help")) bb_show_usage();
|
||||
if(ENABLE_FEATURE_SUID) check_suid(applet_using);
|
||||
exit((*(applet_using->main))(argc, argv));
|
||||
applet_name = applet_using->name;
|
||||
if (argc == 2 && !strcmp(argv[1], "--help"))
|
||||
bb_show_usage();
|
||||
if (ENABLE_FEATURE_SUID)
|
||||
check_suid(applet_using);
|
||||
exit(applet_using->main(argc, argv));
|
||||
}
|
||||
}
|
||||
+47
-54
@@ -2,21 +2,11 @@
|
||||
/*
|
||||
* BusyBox' main applet dispatcher.
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
* Licensed under GPLv2, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#if ENABLE_LOCALE_SUPPORT
|
||||
#include <locale.h>
|
||||
#else
|
||||
#define setlocale(x,y)
|
||||
#endif
|
||||
|
||||
const char *bb_applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
|
||||
const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
|
||||
|
||||
#ifdef CONFIG_FEATURE_INSTALLER
|
||||
/*
|
||||
@@ -24,8 +14,8 @@ const char *bb_applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
* or else...
|
||||
*/
|
||||
static const char usr_bin [] ="/usr/bin";
|
||||
static const char usr_sbin[] ="/usr/sbin";
|
||||
static const char usr_bin [] = "/usr/bin";
|
||||
static const char usr_sbin[] = "/usr/sbin";
|
||||
|
||||
static const char* const install_dir[] = {
|
||||
&usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
|
||||
@@ -36,25 +26,25 @@ static const char* const install_dir[] = {
|
||||
};
|
||||
|
||||
/* abstract link() */
|
||||
typedef int (*__link_f)(const char *, const char *);
|
||||
typedef int (*link_func)(const char *, const char *);
|
||||
|
||||
/* create (sym)links for each applet */
|
||||
static void install_links(const char *busybox, int use_symbolic_links)
|
||||
{
|
||||
__link_f Link = link;
|
||||
|
||||
link_func lf = link;
|
||||
char *fpc;
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
lf = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
fpc = concat_path_file(
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, fpc);
|
||||
if (rc!=0 && errno!=EEXIST) {
|
||||
install_dir[applets[i].location],
|
||||
applets[i].name);
|
||||
rc = lf(busybox, fpc);
|
||||
if (rc != 0 && errno != EEXIST) {
|
||||
bb_perror_msg("%s", fpc);
|
||||
}
|
||||
free(fpc);
|
||||
@@ -69,19 +59,21 @@ int main(int argc, char **argv)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
bb_applet_name=argv[0];
|
||||
if (*bb_applet_name == '-') bb_applet_name++;
|
||||
for (s = bb_applet_name; *s ;)
|
||||
if (*(s++) == '/') bb_applet_name = s;
|
||||
applet_name = argv[0];
|
||||
if (*applet_name == '-')
|
||||
applet_name++;
|
||||
while ((s = strchr(applet_name, '/')))
|
||||
applet_name = s + 1;
|
||||
|
||||
/* Set locale for everybody except `init' */
|
||||
if(ENABLE_LOCALE_SUPPORT && getpid() != 1)
|
||||
/* Set locale for everybody except 'init' */
|
||||
if (ENABLE_LOCALE_SUPPORT && getpid() != 1)
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
run_applet_by_name(bb_applet_name, argc, argv);
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
bb_error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
int busybox_main(int argc, char **argv);
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
/*
|
||||
@@ -91,44 +83,45 @@ int busybox_main(int argc, char **argv)
|
||||
*/
|
||||
if (ENABLE_FEATURE_INSTALLER && argc > 1 && !strcmp(argv[1], "--install")) {
|
||||
int use_symbolic_links = 0;
|
||||
int rc = 0;
|
||||
char *busybox;
|
||||
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argc > 2) {
|
||||
if ((strcmp(argv[2], "-s") == 0)) {
|
||||
if (argc > 2)
|
||||
if (strcmp(argv[2], "-s") == 0)
|
||||
use_symbolic_links = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* link */
|
||||
busybox = xreadlink("/proc/self/exe");
|
||||
if (busybox) {
|
||||
install_links(busybox, use_symbolic_links);
|
||||
// XXX: FIXME: this is broken. Why not just use argv[0] ?
|
||||
busybox = xmalloc_readlink_or_warn("/proc/self/exe");
|
||||
if (!busybox)
|
||||
return 1;
|
||||
install_links(busybox, use_symbolic_links);
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(busybox);
|
||||
} else {
|
||||
rc = 1;
|
||||
}
|
||||
return rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Deal with --help. (Also print help when called with no arguments) */
|
||||
|
||||
if (argc==1 || !strcmp(argv[1],"--help") ) {
|
||||
if (argc>2) {
|
||||
run_applet_by_name(bb_applet_name=argv[2], 2, argv);
|
||||
if (argc == 1 || !strcmp(argv[1], "--help") ) {
|
||||
if (argc > 2) {
|
||||
applet_name = argv[2];
|
||||
run_applet_by_name(applet_name, 2, argv);
|
||||
} else {
|
||||
const struct BB_applet *a;
|
||||
int col, output_width;
|
||||
|
||||
output_width = 80 - sizeof("start-stop-daemon, ") - 8;
|
||||
if (ENABLE_FEATURE_AUTOWIDTH) {
|
||||
/* Obtain the terminal width. */
|
||||
get_terminal_width_height(0, &output_width, NULL);
|
||||
/* leading tab and room to wrap */
|
||||
output_width -= 20;
|
||||
} else output_width = 60;
|
||||
output_width -= sizeof("start-stop-daemon, ") + 8;
|
||||
}
|
||||
|
||||
printf("%s\n\n"
|
||||
printf("%s\n"
|
||||
"Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others.\n"
|
||||
"Licensed under GPLv2. See source distribution for full notice.\n\n"
|
||||
"Usage: busybox [function] [arguments]...\n"
|
||||
" or: [function] [arguments]...\n\n"
|
||||
"\tBusyBox is a multi-call binary that combines many common Unix\n"
|
||||
@@ -136,19 +129,19 @@ int busybox_main(int argc, char **argv)
|
||||
"\tlink to busybox for each function they wish to use and BusyBox\n"
|
||||
"\twill act like whatever it was invoked as!\n"
|
||||
"\nCurrently defined functions:\n", bb_msg_full_version);
|
||||
|
||||
col=0;
|
||||
for(a = applets; a->name;) {
|
||||
col += printf("%s%s", (col ? ", " : "\t"), (a++)->name);
|
||||
col = 0;
|
||||
for (a = applets; a->name;) {
|
||||
col += printf("%s%s", (col ? ", " : "\t"), a->name);
|
||||
a++;
|
||||
if (col > output_width && a->name) {
|
||||
printf(",\n");
|
||||
puts(",");
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
printf("\n\n");
|
||||
exit(0);
|
||||
puts("\n");
|
||||
return 0;
|
||||
}
|
||||
} else run_applet_by_name(argv[1], argc-1, argv+1);
|
||||
} else run_applet_by_name(argv[1], argc - 1, argv + 1);
|
||||
|
||||
bb_error_msg_and_die("applet not found");
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-include/bb_config.h}
|
||||
CONFIG_H=${1:-include/autoconf.h}
|
||||
APPLETS_H=${2:-include/applets.h}
|
||||
$HOSTCC -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*LINK/{
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/* Minimal wrapper to build an individual busybox applet.
|
||||
*
|
||||
* Copyright 2005 Rob Landley <rob@landley.net
|
||||
*
|
||||
* Licensed under GPL version 2, see file LICENSE in this tarball for details
|
||||
*/
|
||||
|
||||
const char *applet_name;
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
//Ok to remove? #include "bb_config.h"
|
||||
#include "usage.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
applet_name=argv[0];
|
||||
|
||||
return APPLET_main(argc,argv);
|
||||
}
|
||||
|
||||
void bb_show_usage(void)
|
||||
{
|
||||
printf(APPLET_full_usage "\n");
|
||||
|
||||
exit(1);
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static const char usage_messages[] =
|
||||
#include "../include/autoconf.h"
|
||||
#include "../include/busybox.h"
|
||||
|
||||
static const char usage_messages[] = ""
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
#include "applets.h"
|
||||
Executable
+19
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
target="$1"
|
||||
loc="$2"
|
||||
|
||||
test "$target" || exit 1
|
||||
test "$loc" || loc=.
|
||||
test -x "$loc/usage" || exit 1
|
||||
test "$SED" || SED=sed
|
||||
|
||||
sz=`"$loc/usage" | wc -c` || exit 1
|
||||
|
||||
exec >"$target"
|
||||
|
||||
echo 'static const char packed_usage[] = '
|
||||
"$loc/usage" | bzip2 -1 | od -v -t x1 \
|
||||
| $SED -e 's/^[^ ]*//' -e 's/ *\(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/'
|
||||
echo ';'
|
||||
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
|
||||
@@ -1,17 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Version stuff.
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#ifndef BB_EXTRA_VERSION
|
||||
#define BANNER "BusyBox v" BB_VER " (" BB_BT ")"
|
||||
#else
|
||||
#define BANNER "BusyBox v" BB_VER " (" BB_EXTRA_VERSION ")"
|
||||
#endif
|
||||
|
||||
const char BB_BANNER[]=BANNER;
|
||||
const char * const bb_msg_full_version = BANNER " multi-call binary";
|
||||
@@ -0,0 +1,5 @@
|
||||
# ==========================================================================
|
||||
# Build system
|
||||
# ==========================================================================
|
||||
|
||||
CFLAGS += $(call cc-option,-march=i386 -mpreferred-stack-boundary=2,)
|
||||
+53
-53
@@ -5,7 +5,7 @@
|
||||
|
||||
menu "Archival Utilities"
|
||||
|
||||
config CONFIG_AR
|
||||
config AR
|
||||
bool "ar"
|
||||
default n
|
||||
help
|
||||
@@ -28,17 +28,17 @@ config CONFIG_AR
|
||||
Unless you have a specific application which requires ar, you should
|
||||
probably say N here.
|
||||
|
||||
config CONFIG_FEATURE_AR_LONG_FILENAMES
|
||||
config FEATURE_AR_LONG_FILENAMES
|
||||
bool "Enable support for long filenames (not need for debs)"
|
||||
default n
|
||||
depends on CONFIG_AR
|
||||
depends on AR
|
||||
help
|
||||
By default the ar format can only store the first 15 characters of the
|
||||
filename, this option removes that limitation.
|
||||
It supports the GNU ar long filename method which moves multiple long
|
||||
filenames into a the data section of a new ar entry.
|
||||
|
||||
config CONFIG_BUNZIP2
|
||||
config BUNZIP2
|
||||
bool "bunzip2"
|
||||
default n
|
||||
help
|
||||
@@ -54,7 +54,7 @@ config CONFIG_BUNZIP2
|
||||
Unless you have a specific application which requires bunzip2, you
|
||||
should probably say N here.
|
||||
|
||||
config CONFIG_CPIO
|
||||
config CPIO
|
||||
bool "cpio"
|
||||
default n
|
||||
help
|
||||
@@ -68,7 +68,7 @@ config CONFIG_CPIO
|
||||
Unless you have a specific application which requires cpio, you should
|
||||
probably say N here.
|
||||
|
||||
config CONFIG_DPKG
|
||||
config DPKG
|
||||
bool "dpkg"
|
||||
default n
|
||||
help
|
||||
@@ -77,7 +77,7 @@ config CONFIG_DPKG
|
||||
This implementation of dpkg has a number of limitations, you should use the
|
||||
official dpkg if possible.
|
||||
|
||||
config CONFIG_DPKG_DEB
|
||||
config DPKG_DEB
|
||||
bool "dpkg_deb"
|
||||
default n
|
||||
help
|
||||
@@ -88,16 +88,16 @@ config CONFIG_DPKG_DEB
|
||||
Unless you have a specific application which requires dpkg-deb, you should
|
||||
probably say N here.
|
||||
|
||||
config CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
config FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
bool "extract only (-x)"
|
||||
default n
|
||||
depends on CONFIG_DPKG_DEB
|
||||
depends on DPKG_DEB
|
||||
help
|
||||
This reduces dpkg-deb to the equivalent of "ar -p <deb> data.tar.gz | tar -zx".
|
||||
However it saves space as none of the extra dpkg-deb, ar or tar options are
|
||||
needed, they are linked to internally.
|
||||
|
||||
config CONFIG_GUNZIP
|
||||
config GUNZIP
|
||||
bool "gunzip"
|
||||
default n
|
||||
help
|
||||
@@ -105,35 +105,35 @@ config CONFIG_GUNZIP
|
||||
You can use the `-t' option to test the integrity of
|
||||
an archive, without decompressing it.
|
||||
|
||||
config CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
config FEATURE_GUNZIP_UNCOMPRESS
|
||||
bool "Uncompress support"
|
||||
default n
|
||||
depends on CONFIG_GUNZIP
|
||||
depends on GUNZIP
|
||||
help
|
||||
Enable if you want gunzip to have the ability to decompress
|
||||
archives created by the program compress (not much
|
||||
used anymore).
|
||||
|
||||
config CONFIG_GZIP
|
||||
config GZIP
|
||||
bool "gzip"
|
||||
default n
|
||||
help
|
||||
gzip is used to compress files.
|
||||
It's probably the most widely used UNIX compression program.
|
||||
|
||||
config CONFIG_RPM2CPIO
|
||||
config RPM2CPIO
|
||||
bool "rpm2cpio"
|
||||
default n
|
||||
help
|
||||
Converts an RPM file into a CPIO archive.
|
||||
|
||||
config CONFIG_RPM
|
||||
config RPM
|
||||
bool "rpm"
|
||||
default n
|
||||
help
|
||||
Mini RPM applet - queries and extracts
|
||||
Mini RPM applet - queries and extracts RPM packages.
|
||||
|
||||
config CONFIG_TAR
|
||||
config TAR
|
||||
bool "tar"
|
||||
default n
|
||||
help
|
||||
@@ -141,86 +141,86 @@ config CONFIG_TAR
|
||||
create compressed archives. It's probably the most widely used
|
||||
UNIX archive program.
|
||||
|
||||
config CONFIG_FEATURE_TAR_CREATE
|
||||
config FEATURE_TAR_CREATE
|
||||
bool "Enable archive creation"
|
||||
default y
|
||||
depends on CONFIG_TAR
|
||||
depends on TAR
|
||||
help
|
||||
If you enable this option you'll be able to create
|
||||
tar archives using the `-c' option.
|
||||
|
||||
config CONFIG_FEATURE_TAR_BZIP2
|
||||
config FEATURE_TAR_BZIP2
|
||||
bool "Enable -j option to handle .tar.bz2 files"
|
||||
default n
|
||||
depends on CONFIG_TAR
|
||||
depends on TAR
|
||||
help
|
||||
If you enable this option you'll be able to extract
|
||||
archives compressed with bzip2.
|
||||
|
||||
config CONFIG_FEATURE_TAR_LZMA
|
||||
config FEATURE_TAR_LZMA
|
||||
bool "Enable -a option to handle .tar.lzma files"
|
||||
default n
|
||||
depends on CONFIG_TAR
|
||||
depends on TAR
|
||||
help
|
||||
If you enable this option you'll be able to extract
|
||||
archives compressed with lzma.
|
||||
|
||||
config CONFIG_FEATURE_TAR_FROM
|
||||
config FEATURE_TAR_FROM
|
||||
bool "Enable -X (exclude from) and -T (include from) options)"
|
||||
default n
|
||||
depends on CONFIG_TAR
|
||||
depends on TAR
|
||||
help
|
||||
If you enable this option you'll be able to specify
|
||||
a list of files to include or exclude from an archive.
|
||||
|
||||
config CONFIG_FEATURE_TAR_GZIP
|
||||
config FEATURE_TAR_GZIP
|
||||
bool "Enable -z option"
|
||||
default y
|
||||
depends on CONFIG_TAR
|
||||
depends on TAR
|
||||
help
|
||||
If you enable this option tar will be able to call gzip,
|
||||
when creating or extracting tar gziped archives.
|
||||
|
||||
config CONFIG_FEATURE_TAR_COMPRESS
|
||||
config FEATURE_TAR_COMPRESS
|
||||
bool "Enable -Z option"
|
||||
default n
|
||||
depends on CONFIG_TAR
|
||||
depends on TAR
|
||||
help
|
||||
If you enable this option tar will be able to call uncompress,
|
||||
when extracting .tar.Z archives.
|
||||
|
||||
config CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
config FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
bool "Enable support for old tar header format"
|
||||
default N
|
||||
depends on CONFIG_TAR
|
||||
depends on TAR
|
||||
help
|
||||
This option is required to unpack archives created in
|
||||
the old GNU format; help to kill this old format by
|
||||
repacking your ancient archives with the new format.
|
||||
|
||||
config CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
config FEATURE_TAR_GNU_EXTENSIONS
|
||||
bool "Enable support for some GNU tar extensions"
|
||||
default y
|
||||
depends on CONFIG_TAR
|
||||
depends on TAR
|
||||
help
|
||||
With this option busybox supports GNU long filenames and
|
||||
linknames.
|
||||
|
||||
config CONFIG_FEATURE_TAR_LONG_OPTIONS
|
||||
config FEATURE_TAR_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
depends on CONFIG_TAR && CONFIG_GETOPT_LONG
|
||||
depends on TAR && GETOPT_LONG
|
||||
help
|
||||
Enable use of long options, increases size by about 400 Bytes
|
||||
|
||||
config CONFIG_UNCOMPRESS
|
||||
config UNCOMPRESS
|
||||
bool "uncompress"
|
||||
default n
|
||||
help
|
||||
uncompress is used to decompress archives created by compress.
|
||||
Not much used anymore, replaced by gzip/gunzip.
|
||||
|
||||
config CONFIG_UNLZMA
|
||||
config UNLZMA
|
||||
bool "unlzma"
|
||||
default n
|
||||
help
|
||||
@@ -235,15 +235,15 @@ config CONFIG_UNLZMA
|
||||
Unless you have a specific application which requires unlzma, you
|
||||
should probably say N here.
|
||||
|
||||
config CONFIG_FEATURE_LZMA_FAST
|
||||
config FEATURE_LZMA_FAST
|
||||
bool "Optimze unlzma for speed"
|
||||
default n
|
||||
depends on CONFIG_UNLZMA
|
||||
depends on UNLZMA
|
||||
help
|
||||
This option reduces decompression time by about 33% at the cost of
|
||||
a 2K bigger binary.
|
||||
|
||||
config CONFIG_UNZIP
|
||||
config UNZIP
|
||||
bool "unzip"
|
||||
default n
|
||||
help
|
||||
@@ -254,31 +254,31 @@ config CONFIG_UNZIP
|
||||
directory of your choice.
|
||||
|
||||
comment "Common options for cpio and tar"
|
||||
depends on CONFIG_CPIO || CONFIG_TAR
|
||||
depends on CPIO || TAR
|
||||
|
||||
config CONFIG_FEATURE_UNARCHIVE_TAPE
|
||||
config FEATURE_UNARCHIVE_TAPE
|
||||
bool "Enable tape drive support"
|
||||
default n
|
||||
depends on CONFIG_CPIO || CONFIG_TAR
|
||||
depends on CPIO || TAR
|
||||
help
|
||||
I don't think this is needed anymore.
|
||||
|
||||
comment "Common options for dpkg and dpkg_deb"
|
||||
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
depends on DPKG || DPKG_DEB
|
||||
|
||||
config CONFIG_FEATURE_DEB_TAR_GZ
|
||||
config FEATURE_DEB_TAR_GZ
|
||||
bool "gzip debian packages (normal)"
|
||||
default y if CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
default y if DPKG || DPKG_DEB
|
||||
depends on DPKG || DPKG_DEB
|
||||
help
|
||||
This is the default compression method inside the debian ar file.
|
||||
|
||||
If you want compatibility with standard .deb's you should say yes here.
|
||||
|
||||
config CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
config FEATURE_DEB_TAR_BZ2
|
||||
bool "bzip2 debian packages"
|
||||
default n
|
||||
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
depends on DPKG || DPKG_DEB
|
||||
help
|
||||
This allows dpkg and dpkg-deb to extract deb's that are compressed internally
|
||||
with bzip2 instead of gzip.
|
||||
@@ -286,15 +286,15 @@ config CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
You only want this if you are creating your own custom debian packages that
|
||||
use an internal control.tar.bz2 or data.tar.bz2.
|
||||
|
||||
config CONFIG_FEATURE_DEB_TAR_LZMA
|
||||
config FEATURE_DEB_TAR_LZMA
|
||||
bool "lzma debian packages"
|
||||
default n
|
||||
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
depends on DPKG || DPKG_DEB
|
||||
help
|
||||
This allows dpkg and dpkg-deb to extract deb's that are compressed
|
||||
internally with lzma instead of gzip.
|
||||
internally with lzma instead of gzip.
|
||||
|
||||
You only want this if you are creating your own custom debian
|
||||
packages that use an internal control.tar.lzma or data.tar.lzma.
|
||||
packages that use an internal control.tar.lzma or data.tar.lzma.
|
||||
|
||||
endmenu
|
||||
@@ -0,0 +1,22 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
libs-y += libunarchive/
|
||||
|
||||
lib-y:=
|
||||
lib-$(CONFIG_AR) += ar.o
|
||||
lib-$(CONFIG_BUNZIP2) += 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_RPM2CPIO) += rpm2cpio.o
|
||||
lib-$(CONFIG_RPM) += rpm.o
|
||||
lib-$(CONFIG_TAR) += tar.o
|
||||
lib-$(CONFIG_UNCOMPRESS) += bbunzip.o
|
||||
lib-$(CONFIG_UNZIP) += unzip.o
|
||||
@@ -1,23 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
ifndef top_srcdir
|
||||
top_srcdir=..
|
||||
endif
|
||||
ifndef top_builddir
|
||||
top_builddir=..
|
||||
endif
|
||||
ARCHIVAL_DIR:=./
|
||||
srcdir=$(top_srcdir)/archival
|
||||
include $(top_srcdir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
ARCHIVAL_AR:=archival.a
|
||||
ifndef $(ARCHIVAL_DIR)
|
||||
ARCHIVAL_DIR:=$(top_builddir)/archival/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/archival
|
||||
|
||||
ARCHIVAL-y:=
|
||||
ARCHIVAL-$(CONFIG_APT_GET) +=
|
||||
ARCHIVAL-$(CONFIG_AR) += ar.o
|
||||
ARCHIVAL-$(CONFIG_BUNZIP2) += bunzip2.o
|
||||
ARCHIVAL-$(CONFIG_UNLZMA) += unlzma.o
|
||||
ARCHIVAL-$(CONFIG_CPIO) += cpio.o
|
||||
ARCHIVAL-$(CONFIG_DPKG) += dpkg.o
|
||||
ARCHIVAL-$(CONFIG_DPKG_DEB) += dpkg_deb.o
|
||||
ARCHIVAL-$(CONFIG_GUNZIP) += gunzip.o
|
||||
ARCHIVAL-$(CONFIG_GZIP) += gzip.o
|
||||
ARCHIVAL-$(CONFIG_RPM2CPIO) += rpm2cpio.o
|
||||
ARCHIVAL-$(CONFIG_RPM) += rpm.o
|
||||
ARCHIVAL-$(CONFIG_TAR) += tar.o
|
||||
ARCHIVAL-$(CONFIG_UNCOMPRESS) += uncompress.o
|
||||
ARCHIVAL-$(CONFIG_UNZIP) += unzip.o
|
||||
|
||||
ifneq ($(strip $(ARCHIVAL-y)),)
|
||||
libraries-y+=$(ARCHIVAL_DIR)$(ARCHIVAL_AR)
|
||||
endif
|
||||
|
||||
ARCHIVAL_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(ARCHIVAL-y))
|
||||
ARCHIVAL_SRC-a:=$(wildcard $(srcdir)/*.c)
|
||||
APPLET_SRC-y+=$(ARCHIVAL_SRC-y)
|
||||
APPLET_SRC-a+=$(ARCHIVAL_SRC-a)
|
||||
|
||||
$(ARCHIVAL_DIR)$(ARCHIVAL_AR): $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
|
||||
$(do_ar)
|
||||
|
||||
$(ARCHIVAL_DIR)%.o: $(srcdir)/%.c
|
||||
$(compile.c)
|
||||
+10
-16
@@ -14,16 +14,8 @@
|
||||
* http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
static void header_verbose_list_ar(const file_header_t *file_header)
|
||||
{
|
||||
@@ -34,7 +26,8 @@ static void 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 %d/%d%7d %s %s\n", &mode[1], file_header->uid, file_header->gid,
|
||||
(int) file_header->size, &mtime[4], file_header->name);
|
||||
}
|
||||
|
||||
#define AR_CTX_PRINT 0x01
|
||||
@@ -45,10 +38,11 @@ static void header_verbose_list_ar(const file_header_t *file_header)
|
||||
#define AR_OPT_CREATE 0x20
|
||||
#define AR_OPT_INSERT 0x40
|
||||
|
||||
int ar_main(int argc, char **argv);
|
||||
int ar_main(int argc, char **argv)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
static const char msg_unsupported_err[] =
|
||||
"Archive %s not supported. Install binutils 'ar'.";
|
||||
char magic[8];
|
||||
@@ -56,8 +50,8 @@ int ar_main(int argc, char **argv)
|
||||
archive_handle = init_handle();
|
||||
|
||||
/* Prepend '-' to the first argument if required */
|
||||
bb_opt_complementally = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
|
||||
opt = bb_getopt_ulflags(argc, argv, "ptxovcr");
|
||||
opt_complementary = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
|
||||
opt = getopt32(argc, argv, "ptxovcr");
|
||||
|
||||
if (opt & AR_CTX_PRINT) {
|
||||
archive_handle->action_data = data_extract_to_stdout;
|
||||
@@ -81,7 +75,7 @@ int ar_main(int argc, char **argv)
|
||||
bb_error_msg_and_die(msg_unsupported_err, "insertion");
|
||||
}
|
||||
|
||||
archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
|
||||
archive_handle->src_fd = xopen(argv[optind++], O_RDONLY);
|
||||
|
||||
while (optind < argc) {
|
||||
archive_handle->filter = filter_accept_list;
|
||||
@@ -90,11 +84,11 @@ int ar_main(int argc, char **argv)
|
||||
|
||||
xread(archive_handle->src_fd, magic, 7);
|
||||
if (strncmp(magic, "!<arch>", 7) != 0) {
|
||||
bb_error_msg_and_die("Invalid ar magic");
|
||||
bb_error_msg_and_die("invalid ar magic");
|
||||
}
|
||||
archive_handle->offset += 7;
|
||||
|
||||
while (get_header_ar(archive_handle) == EXIT_SUCCESS);
|
||||
while (get_header_ar(archive_handle) == EXIT_SUCCESS) /* repeat */;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Common code for gunzip-like applets
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
enum {
|
||||
OPT_STDOUT = 0x1,
|
||||
OPT_FORCE = 0x2,
|
||||
/* gunzip only: */
|
||||
OPT_VERBOSE = 0x4,
|
||||
OPT_DECOMPRESS = 0x8,
|
||||
OPT_TEST = 0x10,
|
||||
};
|
||||
|
||||
static
|
||||
int open_to_or_warn(int to_fd, const char *filename, int flags, int mode)
|
||||
{
|
||||
int fd = open(filename, flags, mode);
|
||||
if (fd < 0) {
|
||||
bb_perror_msg("%s", filename);
|
||||
return 1;
|
||||
}
|
||||
if (fd != to_fd) {
|
||||
if (dup2(fd, to_fd) < 0)
|
||||
bb_perror_msg_and_die("cannot dup");
|
||||
close(fd);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bbunpack(char **argv,
|
||||
char* (*make_new_name)(char *filename),
|
||||
USE_DESKTOP(long long) int (*unpacker)(void)
|
||||
)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
USE_DESKTOP(long long) int status;
|
||||
char *filename, *new_name;
|
||||
smallint exitcode = 0;
|
||||
|
||||
do {
|
||||
/* NB: new_name is *maybe* malloc'ed! */
|
||||
new_name = NULL;
|
||||
filename = *argv; /* can be NULL - 'streaming' bunzip2 */
|
||||
|
||||
if (filename && LONE_DASH(filename))
|
||||
filename = NULL;
|
||||
|
||||
/* Open src */
|
||||
if (filename) {
|
||||
if (stat(filename, &stat_buf) != 0) {
|
||||
bb_perror_msg("%s", filename);
|
||||
err:
|
||||
exitcode = 1;
|
||||
goto free_name;
|
||||
}
|
||||
if (open_to_or_warn(STDIN_FILENO, filename, O_RDONLY, 0))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Special cases: test, stdout */
|
||||
if (option_mask32 & (OPT_STDOUT|OPT_TEST)) {
|
||||
if (option_mask32 & OPT_TEST)
|
||||
if (open_to_or_warn(STDOUT_FILENO, bb_dev_null, O_WRONLY, 0))
|
||||
goto err;
|
||||
filename = NULL;
|
||||
}
|
||||
|
||||
/* Open dst if we are going to unpack to file */
|
||||
if (filename) {
|
||||
new_name = make_new_name(filename);
|
||||
if (!new_name) {
|
||||
bb_error_msg("%s: unknown suffix - ignored", filename);
|
||||
goto err;
|
||||
}
|
||||
/* O_EXCL: "real" bunzip2 doesn't overwrite files */
|
||||
/* GNU gunzip goes not bail out, but goes to next file */
|
||||
if (open_to_or_warn(STDOUT_FILENO, new_name, O_WRONLY | O_CREAT | O_EXCL,
|
||||
stat_buf.st_mode))
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Check that the input is sane */
|
||||
if (isatty(STDIN_FILENO) && (option_mask32 & OPT_FORCE) == 0) {
|
||||
bb_error_msg_and_die("compressed data not read from terminal, "
|
||||
"use -f to force it");
|
||||
}
|
||||
|
||||
status = unpacker();
|
||||
if (status < 0)
|
||||
exitcode = 1;
|
||||
|
||||
if (filename) {
|
||||
char *del = new_name;
|
||||
if (status >= 0) {
|
||||
/* TODO: restore user/group/times here? */
|
||||
/* Delete _compressed_ file */
|
||||
del = filename;
|
||||
/* restore extension (unless tgz -> tar case) */
|
||||
if (new_name == filename)
|
||||
filename[strlen(filename)] = '.';
|
||||
}
|
||||
if (unlink(del) < 0)
|
||||
bb_perror_msg_and_die("cannot remove %s", del);
|
||||
|
||||
#if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */
|
||||
/* Extreme bloat for gunzip compat */
|
||||
if (ENABLE_DESKTOP && (option_mask32 & OPT_VERBOSE) && status >= 0) {
|
||||
fprintf(stderr, "%s: %u%% - replaced with %s\n",
|
||||
filename, (unsigned)(stat_buf.st_size*100 / (status+1)), new_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
free_name:
|
||||
if (new_name != filename)
|
||||
free(new_name);
|
||||
}
|
||||
} while (*argv && *++argv);
|
||||
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
#if ENABLE_BUNZIP2 || ENABLE_UNLZMA || ENABLE_UNCOMPRESS
|
||||
|
||||
static
|
||||
char* make_new_name_generic(char *filename, const char *expected_ext)
|
||||
{
|
||||
char *extension = strrchr(filename, '.');
|
||||
if (!extension || strcmp(extension + 1, expected_ext) != 0) {
|
||||
/* Mimic GNU gunzip - "real" bunzip2 tries to */
|
||||
/* unpack file anyway, to file.out */
|
||||
return NULL;
|
||||
}
|
||||
*extension = '\0';
|
||||
return filename;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Modified for busybox by Glenn McGrath <bug1@iinet.net.au>
|
||||
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#if ENABLE_BUNZIP2
|
||||
|
||||
static
|
||||
char* make_new_name_bunzip2(char *filename)
|
||||
{
|
||||
return make_new_name_generic(filename, "bz2");
|
||||
}
|
||||
|
||||
static
|
||||
USE_DESKTOP(long long) int unpack_bunzip2(void)
|
||||
{
|
||||
return uncompressStream(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
|
||||
int bunzip2_main(int argc, char **argv);
|
||||
int bunzip2_main(int argc, char **argv)
|
||||
{
|
||||
getopt32(argc, argv, "cf");
|
||||
argv += optind;
|
||||
if (applet_name[2] == 'c')
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
|
||||
return bbunpack(argv, make_new_name_bunzip2, unpack_bunzip2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Gzip implementation for busybox
|
||||
*
|
||||
* Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly.
|
||||
*
|
||||
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
|
||||
* based on gzip sources
|
||||
*
|
||||
* Adjusted further by Erik Andersen <andersen@codepoet.org> to support files as
|
||||
* well as stdin/stdout, and to generally behave itself wrt command line
|
||||
* handling.
|
||||
*
|
||||
* General cleanup to better adhere to the style guide and make use of standard
|
||||
* busybox functions by Glenn McGrath <bug1@iinet.net.au>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
|
||||
* Copyright (C) 1992-1993 Jean-loup Gailly
|
||||
* The unzip code was written and put in the public domain by Mark Adler.
|
||||
* Portions of the lzw code are derived from the public domain 'compress'
|
||||
* written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies,
|
||||
* Ken Turkowski, Dave Mack and Peter Jannesen.
|
||||
*
|
||||
* See the license_msg below and the file COPYING for the software license.
|
||||
* See the file algorithm.doc for the compression algorithms and file formats.
|
||||
*/
|
||||
|
||||
#if ENABLE_GUNZIP
|
||||
|
||||
static
|
||||
char* make_new_name_gunzip(char *filename)
|
||||
{
|
||||
char *extension = strrchr(filename, '.');
|
||||
|
||||
if (!extension)
|
||||
return NULL;
|
||||
|
||||
extension++;
|
||||
if (strcmp(extension, "tgz" + 1) == 0
|
||||
#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
|| strcmp(extension, "Z") == 0
|
||||
#endif
|
||||
) {
|
||||
extension[-1] = '\0';
|
||||
} else if(strcmp(extension, "tgz") == 0) {
|
||||
filename = xstrdup(filename);
|
||||
extension = strrchr(filename, '.');
|
||||
extension[2] = 'a';
|
||||
extension[3] = 'r';
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
|
||||
static
|
||||
USE_DESKTOP(long long) int unpack_gunzip(void)
|
||||
{
|
||||
USE_DESKTOP(long long) int status = -1;
|
||||
|
||||
/* do the decompression, and cleanup */
|
||||
if (xread_char(STDIN_FILENO) == 0x1f) {
|
||||
unsigned char magic2;
|
||||
|
||||
magic2 = xread_char(STDIN_FILENO);
|
||||
if (ENABLE_FEATURE_GUNZIP_UNCOMPRESS && magic2 == 0x9d) {
|
||||
status = uncompress(STDIN_FILENO, STDOUT_FILENO);
|
||||
} else if (magic2 == 0x8b) {
|
||||
check_header_gzip_or_die(STDIN_FILENO);
|
||||
status = inflate_gunzip(STDIN_FILENO, STDOUT_FILENO);
|
||||
} else {
|
||||
goto bad_magic;
|
||||
}
|
||||
if (status < 0) {
|
||||
bb_error_msg("error inflating");
|
||||
}
|
||||
} else {
|
||||
bad_magic:
|
||||
bb_error_msg("invalid magic");
|
||||
/* status is still == -1 */
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int gunzip_main(int argc, char **argv);
|
||||
int gunzip_main(int argc, char **argv)
|
||||
{
|
||||
getopt32(argc, argv, "cfvdt");
|
||||
argv += optind;
|
||||
/* if called as zcat */
|
||||
if (applet_name[1] == 'c')
|
||||
option_mask32 |= OPT_STDOUT;
|
||||
|
||||
return bbunpack(argv, make_new_name_gunzip, unpack_gunzip);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Small lzma deflate implementation.
|
||||
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
|
||||
*
|
||||
* Based on bunzip.c from busybox
|
||||
*
|
||||
* 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
|
||||
USE_DESKTOP(long long) int unpack_unlzma(void)
|
||||
{
|
||||
return unlzma(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
|
||||
int unlzma_main(int argc, char **argv);
|
||||
int unlzma_main(int argc, char **argv)
|
||||
{
|
||||
getopt32(argc, argv, "c");
|
||||
argv += optind;
|
||||
/* lzmacat? */
|
||||
if (applet_name[4] == '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
|
||||
USE_DESKTOP(long long) int unpack_uncompress(void)
|
||||
{
|
||||
USE_DESKTOP(long long) int status = -1;
|
||||
|
||||
if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) {
|
||||
bb_error_msg("invalid magic");
|
||||
} else {
|
||||
status = uncompress(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int uncompress_main(int argc, char **argv);
|
||||
int uncompress_main(int argc, char **argv)
|
||||
{
|
||||
getopt32(argc, argv, "cf");
|
||||
argv += optind;
|
||||
|
||||
return bbunpack(argv, make_new_name_uncompress, unpack_uncompress);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,67 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Modified for busybox by Glenn McGrath <bug1@iinet.net.au>
|
||||
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define BUNZIP2_OPT_STDOUT 1
|
||||
#define BUNZIP2_OPT_FORCE 2
|
||||
|
||||
int bunzip2_main(int argc, char **argv)
|
||||
{
|
||||
char *filename;
|
||||
unsigned long opt;
|
||||
int status, src_fd, dst_fd;
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "cf");
|
||||
|
||||
/* Set input filename and number */
|
||||
filename = argv[optind];
|
||||
if ((filename) && (filename[0] != '-') && (filename[1] != '\0')) {
|
||||
/* Open input file */
|
||||
src_fd = bb_xopen(filename, O_RDONLY);
|
||||
} else {
|
||||
src_fd = STDIN_FILENO;
|
||||
filename = 0;
|
||||
}
|
||||
|
||||
/* if called as bzcat force the stdout flag */
|
||||
if ((opt & BUNZIP2_OPT_STDOUT) || bb_applet_name[2] == 'c')
|
||||
filename = 0;
|
||||
|
||||
/* Check that the input is sane. */
|
||||
if (isatty(src_fd) && (opt & BUNZIP2_OPT_FORCE) == 0) {
|
||||
bb_error_msg_and_die("Compressed data not read from terminal. Use -f to force it.");
|
||||
}
|
||||
|
||||
if (filename) {
|
||||
struct stat stat_buf;
|
||||
char *extension=filename+strlen(filename)-4;
|
||||
if (strcmp(extension, ".bz2") != 0) {
|
||||
bb_error_msg_and_die("Invalid extension");
|
||||
}
|
||||
xstat(filename, &stat_buf);
|
||||
*extension=0;
|
||||
dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
|
||||
} else dst_fd = STDOUT_FILENO;
|
||||
status = uncompressStream(src_fd, dst_fd);
|
||||
if(filename) {
|
||||
if (!status) filename[strlen(filename)]='.';
|
||||
if (unlink(filename) < 0) {
|
||||
bb_error_msg_and_die("Couldn't remove %s", filename);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
+6
-5
@@ -26,19 +26,20 @@
|
||||
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
|
||||
#define CPIO_OPT_PRESERVE_MTIME 0x40
|
||||
|
||||
int cpio_main(int argc, char **argv);
|
||||
int cpio_main(int argc, char **argv)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
char *cpio_filename = NULL;
|
||||
unsigned long opt;
|
||||
unsigned opt;
|
||||
|
||||
/* Initialise */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->src_fd = STDIN_FILENO;
|
||||
archive_handle->seek = seek_by_char;
|
||||
archive_handle->seek = seek_by_read;
|
||||
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "ituvF:dm", &cpio_filename);
|
||||
opt = getopt32(argc, argv, "ituvF:dm", &cpio_filename);
|
||||
|
||||
/* One of either extract or test options must be given */
|
||||
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
|
||||
@@ -67,7 +68,7 @@ int cpio_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
if (cpio_filename) { /* CPIO_OPT_FILE */
|
||||
archive_handle->src_fd = bb_xopen(cpio_filename, O_RDONLY);
|
||||
archive_handle->src_fd = xopen(cpio_filename, O_RDONLY);
|
||||
archive_handle->seek = seek_by_jump;
|
||||
}
|
||||
if (opt & CPIO_OPT_CREATE_LEADING_DIR) {
|
||||
@@ -82,5 +83,5 @@ int cpio_main(int argc, char **argv)
|
||||
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+447
-416
File diff suppressed because it is too large.
Load diff
+15
-19
@@ -4,13 +4,8 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define DPKG_DEB_OPT_CONTENTS 1
|
||||
#define DPKG_DEB_OPT_CONTROL 2
|
||||
@@ -18,13 +13,14 @@
|
||||
#define DPKG_DEB_OPT_EXTRACT 8
|
||||
#define DPKG_DEB_OPT_EXTRACT_VERBOSE 16
|
||||
|
||||
int dpkg_deb_main(int argc, char **argv);
|
||||
int dpkg_deb_main(int argc, char **argv)
|
||||
{
|
||||
archive_handle_t *ar_archive;
|
||||
archive_handle_t *tar_archive;
|
||||
llist_t *control_tar_llist = NULL;
|
||||
unsigned long opt;
|
||||
char *extract_dir = NULL;
|
||||
unsigned opt;
|
||||
const char *extract_dir = NULL;
|
||||
short argcount = 1;
|
||||
|
||||
/* Setup the tar archive handle */
|
||||
@@ -36,17 +32,17 @@ int dpkg_deb_main(int argc, char **argv)
|
||||
ar_archive->filter = filter_accept_list_reassign;
|
||||
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
llist_add_to(&(ar_archive->accept), "data.tar.gz");
|
||||
llist_add_to(&control_tar_llist, "control.tar.gz");
|
||||
llist_add_to(&(ar_archive->accept), (char*)"data.tar.gz");
|
||||
llist_add_to(&control_tar_llist, (char*)"control.tar.gz");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
llist_add_to(&(ar_archive->accept), "data.tar.bz2");
|
||||
llist_add_to(&control_tar_llist, "control.tar.bz2");
|
||||
llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2");
|
||||
llist_add_to(&control_tar_llist, (char*)"control.tar.bz2");
|
||||
#endif
|
||||
|
||||
bb_opt_complementally = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
|
||||
opt = bb_getopt_ulflags(argc, argv, "cefXx");
|
||||
opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
|
||||
opt = getopt32(argc, argv, "cefXx");
|
||||
|
||||
if (opt & DPKG_DEB_OPT_CONTENTS) {
|
||||
tar_archive->action_header = header_verbose_list;
|
||||
@@ -65,7 +61,7 @@ int dpkg_deb_main(int argc, char **argv)
|
||||
* it should accept a second argument which specifies a
|
||||
* specific field to print */
|
||||
ar_archive->accept = control_tar_llist;
|
||||
llist_add_to(&(tar_archive->accept), "./control");
|
||||
llist_add_to(&(tar_archive->accept), (char*)"./control");
|
||||
tar_archive->filter = filter_accept_list;
|
||||
tar_archive->action_data = data_extract_to_stdout;
|
||||
}
|
||||
@@ -81,7 +77,7 @@ int dpkg_deb_main(int argc, char **argv)
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
tar_archive->src_fd = ar_archive->src_fd = bb_xopen(argv[optind++], O_RDONLY);
|
||||
tar_archive->src_fd = ar_archive->src_fd = xopen(argv[optind++], O_RDONLY);
|
||||
|
||||
/* Workout where to extract the files */
|
||||
/* 2nd argument is a dir name */
|
||||
@@ -90,12 +86,12 @@ int dpkg_deb_main(int argc, char **argv)
|
||||
}
|
||||
if (extract_dir) {
|
||||
mkdir(extract_dir, 0777); /* bb_make_directory(extract_dir, 0777, 0) */
|
||||
bb_xchdir(extract_dir);
|
||||
xchdir(extract_dir);
|
||||
}
|
||||
unpack_ar_archive(ar_archive);
|
||||
|
||||
/* Cleanup */
|
||||
close (ar_archive->src_fd);
|
||||
close(ar_archive->src_fd);
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Gzip implementation for busybox
|
||||
*
|
||||
* Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly.
|
||||
*
|
||||
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
|
||||
* based on gzip sources
|
||||
*
|
||||
* Adjusted further by Erik Andersen <andersen@codepoet.org> to support files as
|
||||
* well as stdin/stdout, and to generally behave itself wrt command line
|
||||
* handling.
|
||||
*
|
||||
* General cleanup to better adhere to the style guide and make use of standard
|
||||
* busybox functions by Glenn McGrath <bug1@iinet.net.au>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
|
||||
* Copyright (C) 1992-1993 Jean-loup Gailly
|
||||
* The unzip code was written and put in the public domain by Mark Adler.
|
||||
* Portions of the lzw code are derived from the public domain 'compress'
|
||||
* written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies,
|
||||
* Ken Turkowski, Dave Mack and Peter Jannesen.
|
||||
*
|
||||
* See the license_msg below and the file COPYING for the software license.
|
||||
* See the file algorithm.doc for the compression algorithms and file formats.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define GUNZIP_OPT_STDOUT 1
|
||||
#define GUNZIP_OPT_FORCE 2
|
||||
#define GUNZIP_OPT_TEST 4
|
||||
#define GUNZIP_OPT_DECOMPRESS 8
|
||||
|
||||
int gunzip_main(int argc, char **argv)
|
||||
{
|
||||
char status = EXIT_SUCCESS;
|
||||
unsigned long opt;
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "cftd");
|
||||
/* if called as zcat */
|
||||
if (strcmp(bb_applet_name, "zcat") == 0) {
|
||||
opt |= GUNZIP_OPT_STDOUT;
|
||||
}
|
||||
|
||||
do {
|
||||
struct stat stat_buf;
|
||||
const char *old_path = argv[optind];
|
||||
const char *delete_path = NULL;
|
||||
char *new_path = NULL;
|
||||
int src_fd;
|
||||
int dst_fd;
|
||||
|
||||
optind++;
|
||||
|
||||
if (old_path == NULL || strcmp(old_path, "-") == 0) {
|
||||
src_fd = STDIN_FILENO;
|
||||
opt |= GUNZIP_OPT_STDOUT;
|
||||
} else {
|
||||
src_fd = bb_xopen(old_path, O_RDONLY);
|
||||
|
||||
/* Get the time stamp on the input file. */
|
||||
xstat(old_path, &stat_buf);
|
||||
}
|
||||
|
||||
/* Check that the input is sane. */
|
||||
if (isatty(src_fd) && ((opt & GUNZIP_OPT_FORCE) == 0)) {
|
||||
bb_error_msg_and_die
|
||||
("compressed data not read from terminal. Use -f to force it.");
|
||||
}
|
||||
|
||||
/* Set output filename and number */
|
||||
if (opt & GUNZIP_OPT_TEST) {
|
||||
dst_fd = bb_xopen(bb_dev_null, O_WRONLY); /* why does test use filenum 2 ? */
|
||||
} else if (opt & GUNZIP_OPT_STDOUT) {
|
||||
dst_fd = STDOUT_FILENO;
|
||||
} else {
|
||||
char *extension;
|
||||
|
||||
new_path = bb_xstrdup(old_path);
|
||||
|
||||
extension = strrchr(new_path, '.');
|
||||
#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
if (extension && (strcmp(extension, ".Z") == 0)) {
|
||||
*extension = '\0';
|
||||
} else
|
||||
#endif
|
||||
if (extension && (strcmp(extension, ".gz") == 0)) {
|
||||
*extension = '\0';
|
||||
} else if (extension && (strcmp(extension, ".tgz") == 0)) {
|
||||
extension[2] = 'a';
|
||||
extension[3] = 'r';
|
||||
} else {
|
||||
bb_error_msg_and_die("Invalid extension");
|
||||
}
|
||||
|
||||
/* Open output file (with correct permissions) */
|
||||
dst_fd = bb_xopen3(new_path, O_WRONLY | O_CREAT, stat_buf.st_mode);
|
||||
|
||||
/* If unzip succeeds remove the old file */
|
||||
delete_path = old_path;
|
||||
}
|
||||
|
||||
/* do the decompression, and cleanup */
|
||||
if (xread_char(src_fd) == 0x1f) {
|
||||
unsigned char magic2;
|
||||
|
||||
magic2 = xread_char(src_fd);
|
||||
#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
if (magic2 == 0x9d) {
|
||||
status = uncompress(src_fd, dst_fd);
|
||||
} else
|
||||
#endif
|
||||
if (magic2 == 0x8b) {
|
||||
check_header_gzip(src_fd);
|
||||
status = inflate_gunzip(src_fd, dst_fd);
|
||||
if (status != 0) {
|
||||
bb_error_msg_and_die("Error inflating");
|
||||
}
|
||||
} else {
|
||||
bb_error_msg_and_die("Invalid magic");
|
||||
}
|
||||
} else {
|
||||
bb_error_msg_and_die("Invalid magic");
|
||||
}
|
||||
|
||||
if ((status != EXIT_SUCCESS) && (new_path)) {
|
||||
/* Unzip failed, remove new path instead of old path */
|
||||
delete_path = new_path;
|
||||
}
|
||||
|
||||
if (dst_fd != STDOUT_FILENO) {
|
||||
close(dst_fd);
|
||||
}
|
||||
if (src_fd != STDIN_FILENO) {
|
||||
close(src_fd);
|
||||
}
|
||||
|
||||
/* delete_path will be NULL if in test mode or from stdin */
|
||||
if (delete_path && (unlink(delete_path) == -1)) {
|
||||
bb_error_msg_and_die("Couldn't remove %s", delete_path);
|
||||
}
|
||||
|
||||
free(new_path);
|
||||
|
||||
} while (optind < argc);
|
||||
|
||||
return status;
|
||||
}
|
||||
+1163
-1558
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,59 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
||||
|
||||
lib-y:= \
|
||||
\
|
||||
data_skip.o \
|
||||
data_extract_all.o \
|
||||
data_extract_to_stdout.o \
|
||||
data_extract_to_buffer.o \
|
||||
\
|
||||
filter_accept_all.o \
|
||||
filter_accept_list.o \
|
||||
filter_accept_reject_list.o \
|
||||
\
|
||||
header_skip.o \
|
||||
header_list.o \
|
||||
header_verbose_list.o \
|
||||
\
|
||||
archive_xread_all_eof.o \
|
||||
\
|
||||
seek_by_read.o \
|
||||
seek_by_jump.o \
|
||||
\
|
||||
data_align.o \
|
||||
find_list_entry.o \
|
||||
open_transformer.o \
|
||||
init_handle.o
|
||||
|
||||
GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o
|
||||
DPKG_FILES:= \
|
||||
get_header_ar.o \
|
||||
unpack_ar_archive.o \
|
||||
get_header_tar.o \
|
||||
filter_accept_list_reassign.o
|
||||
|
||||
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_CPIO) += get_header_cpio.o
|
||||
lib-$(CONFIG_DPKG) += $(DPKG_FILES)
|
||||
lib-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
|
||||
lib-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
|
||||
lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
lib-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
lib-$(CONFIG_TAR) += get_header_tar.o
|
||||
lib-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
|
||||
lib-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
|
||||
lib-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
|
||||
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
|
||||
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
|
||||
@@ -1,36 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
ifndef top_srcdir
|
||||
top_srcdir=../..
|
||||
endif
|
||||
ifndef top_builddir
|
||||
top_builddir=../..
|
||||
endif
|
||||
srcdir=$(top_srcdir)/archival/libunarchive
|
||||
LIBUNARCHIVE_DIR:=./
|
||||
include $(top_srcdir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
||||
|
||||
LIBUNARCHIVE_AR:=libunarchive.a
|
||||
ifndef $(LIBUNARCHIVE_DIR)
|
||||
LIBUNARCHIVE_DIR:=$(top_builddir)/archival/libunarchive
|
||||
endif
|
||||
srcdir=$(top_srcdir)/archival/libunarchive
|
||||
|
||||
LIBUNARCHIVE-obj:=$(LIBUNARCHIVE_DIR)/$(LIBUNARCHIVE_AR)
|
||||
|
||||
libraries-y+=$(LIBUNARCHIVE-obj)
|
||||
|
||||
LIBUNARCHIVE-y:= \
|
||||
\
|
||||
data_skip.o \
|
||||
data_extract_all.o \
|
||||
data_extract_to_stdout.o \
|
||||
data_extract_to_buffer.o \
|
||||
\
|
||||
filter_accept_all.o \
|
||||
filter_accept_list.o \
|
||||
filter_accept_reject_list.o \
|
||||
\
|
||||
header_skip.o \
|
||||
header_list.o \
|
||||
header_verbose_list.o \
|
||||
\
|
||||
archive_xread_all_eof.o \
|
||||
\
|
||||
seek_by_char.o \
|
||||
seek_by_jump.o \
|
||||
\
|
||||
data_align.o \
|
||||
find_list_entry.o \
|
||||
open_transformer.o \
|
||||
init_handle.o
|
||||
|
||||
GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o
|
||||
DPKG_FILES:= \
|
||||
get_header_ar.o \
|
||||
unpack_ar_archive.o \
|
||||
get_header_tar.o \
|
||||
filter_accept_list_reassign.o
|
||||
|
||||
LIBUNARCHIVE-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
|
||||
LIBUNARCHIVE-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
|
||||
LIBUNARCHIVE-$(CONFIG_UNLZMA) += decompress_unlzma.o
|
||||
LIBUNARCHIVE-$(CONFIG_CPIO) += get_header_cpio.o
|
||||
LIBUNARCHIVE-$(CONFIG_DPKG) += $(DPKG_FILES)
|
||||
LIBUNARCHIVE-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
|
||||
LIBUNARCHIVE-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
|
||||
LIBUNARCHIVE-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
LIBUNARCHIVE-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
LIBUNARCHIVE-$(CONFIG_TAR) += get_header_tar.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_LZMA) += decompress_unlzma.o get_header_tar_lzma.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
|
||||
LIBUNARCHIVE-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
|
||||
LIBUNARCHIVE-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
|
||||
|
||||
|
||||
LIBUNARCHIVE-y:=$(sort $(LIBUNARCHIVE-y))
|
||||
|
||||
LIBUNARCHIVE_SRC-y:=$(patsubst %,$(srcdir)/%,$(subst .o,.c,$(LIBUNARCHIVE-y)))
|
||||
LIBUNARCHIVE_SRC-a:=$(wildcard $(srcdir)/*.c)
|
||||
LIBRARY_SRC-y+=$(LIBUNARCHIVE_SRC-y)
|
||||
LIBRARY_SRC-a+=$(LIBUNARCHIVE_SRC-a)
|
||||
|
||||
$(LIBUNARCHIVE_DIR)/$(LIBUNARCHIVE_AR): $(patsubst %,$(LIBUNARCHIVE_DIR)/%,$(LIBUNARCHIVE-y))
|
||||
$(do_ar)
|
||||
|
||||
$(LIBUNARCHIVE_DIR)/%.o: $(srcdir)/%.c
|
||||
$(compile.c)
|
||||
@@ -3,19 +3,18 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned char *buf, size_t count)
|
||||
ssize_t archive_xread_all_eof(archive_handle_t *archive_handle,
|
||||
unsigned char *buf, size_t count)
|
||||
{
|
||||
ssize_t size;
|
||||
|
||||
size = full_read(archive_handle->src_fd, buf, count);
|
||||
if ((size != 0) && (size != count)) {
|
||||
bb_perror_msg_and_die("Short read, read %ld of %ld", (long)size, (long)count);
|
||||
if (size != 0 && size != count) {
|
||||
bb_error_msg_and_die("short read: %u of %u",
|
||||
(unsigned)size, (unsigned)count);
|
||||
}
|
||||
return(size);
|
||||
return size;
|
||||
}
|
||||
@@ -2,12 +2,11 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h" /* for external decl of check_header_gzip */
|
||||
|
||||
void check_header_gzip(int src_fd)
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h" /* for external decl of check_header_gzip_or_die */
|
||||
|
||||
void check_header_gzip_or_die(int src_fd)
|
||||
{
|
||||
union {
|
||||
unsigned char raw[8];
|
||||
@@ -17,20 +16,20 @@ void check_header_gzip(int src_fd)
|
||||
unsigned int mtime;
|
||||
unsigned char xtra_flags;
|
||||
unsigned char os_flags;
|
||||
} formated;
|
||||
} formatted;
|
||||
} header;
|
||||
|
||||
xread(src_fd, header.raw, 8);
|
||||
|
||||
/* Check the compression method */
|
||||
if (header.formated.method != 8) {
|
||||
bb_error_msg_and_die("Unknown compression method %d",
|
||||
header.formated.method);
|
||||
if (header.formatted.method != 8) {
|
||||
bb_error_msg_and_die("unknown compression method %d",
|
||||
header.formatted.method);
|
||||
}
|
||||
|
||||
if (header.formated.flags & 0x04) {
|
||||
if (header.formatted.flags & 0x04) {
|
||||
/* bit 2 set: extra field present */
|
||||
unsigned char extra_short;
|
||||
unsigned extra_short;
|
||||
|
||||
extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8);
|
||||
while (extra_short > 0) {
|
||||
@@ -41,22 +40,20 @@ void check_header_gzip(int src_fd)
|
||||
}
|
||||
|
||||
/* Discard original name if any */
|
||||
if (header.formated.flags & 0x08) {
|
||||
if (header.formatted.flags & 0x08) {
|
||||
/* bit 3 set: original file name present */
|
||||
while(xread_char(src_fd) != 0);
|
||||
while (xread_char(src_fd) != 0);
|
||||
}
|
||||
|
||||
/* Discard file comment if any */
|
||||
if (header.formated.flags & 0x10) {
|
||||
if (header.formatted.flags & 0x10) {
|
||||
/* bit 4 set: file comment present */
|
||||
while(xread_char(src_fd) != 0);
|
||||
while (xread_char(src_fd) != 0);
|
||||
}
|
||||
|
||||
/* Read the header checksum */
|
||||
if (header.formated.flags & 0x02) {
|
||||
if (header.formatted.flags & 0x02) {
|
||||
xread_char(src_fd);
|
||||
xread_char(src_fd);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -5,9 +5,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
@@ -17,6 +14,4 @@ void data_align(archive_handle_t *archive_handle, const unsigned short boundary)
|
||||
|
||||
archive_handle->seek(archive_handle, skip_amount);
|
||||
archive_handle->offset += skip_amount;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -3,16 +3,6 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
@@ -23,16 +13,19 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
int res;
|
||||
|
||||
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
|
||||
char *name = bb_xstrdup(file_header->name);
|
||||
bb_make_directory (dirname(name), -1, FILEUTILS_RECUR);
|
||||
char *name = xstrdup(file_header->name);
|
||||
bb_make_directory(dirname(name), -1, FILEUTILS_RECUR);
|
||||
free(name);
|
||||
}
|
||||
|
||||
/* Check if the file already exists */
|
||||
if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
|
||||
/* Remove the existing entry if it exists */
|
||||
if (((file_header->mode & S_IFMT) != S_IFDIR) && (unlink(file_header->name) == -1) && (errno != ENOENT)) {
|
||||
bb_perror_msg_and_die("Couldnt remove old file");
|
||||
if (((file_header->mode & S_IFMT) != S_IFDIR)
|
||||
&& (unlink(file_header->name) == -1)
|
||||
&& (errno != ENOENT)
|
||||
) {
|
||||
bb_perror_msg_and_die("cannot remove old file");
|
||||
}
|
||||
}
|
||||
else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) {
|
||||
@@ -40,72 +33,89 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
struct stat statbuf;
|
||||
if (lstat(file_header->name, &statbuf) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
bb_perror_msg_and_die("Couldnt stat old file");
|
||||
bb_perror_msg_and_die("cannot stat old file");
|
||||
}
|
||||
}
|
||||
else if (statbuf.st_mtime <= file_header->mtime) {
|
||||
if (!(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_error_msg("%s not created: newer or same age file exists", file_header->name);
|
||||
bb_error_msg("%s not created: newer or "
|
||||
"same age file exists", file_header->name);
|
||||
}
|
||||
data_skip(archive_handle);
|
||||
return;
|
||||
}
|
||||
else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) {
|
||||
bb_perror_msg_and_die("Couldnt remove old file %s", file_header->name);
|
||||
bb_perror_msg_and_die("cannot remove old file %s",
|
||||
file_header->name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle hard links separately
|
||||
* We identified hard links as regular files of size 0 with a symlink */
|
||||
if (S_ISREG(file_header->mode) && (file_header->link_name) && (file_header->size == 0)) {
|
||||
if (S_ISREG(file_header->mode) && (file_header->link_name)
|
||||
&& (file_header->size == 0)
|
||||
) {
|
||||
/* hard link */
|
||||
res = link(file_header->link_name, file_header->name);
|
||||
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("Couldnt create hard link");
|
||||
bb_perror_msg("cannot create hard link");
|
||||
}
|
||||
} else {
|
||||
/* Create the filesystem entry */
|
||||
switch(file_header->mode & S_IFMT) {
|
||||
case S_IFREG: {
|
||||
/* Regular file */
|
||||
dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL);
|
||||
bb_copyfd_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 ((errno != EISDIR) && (res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("extract_archive: %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
case S_IFLNK:
|
||||
/* Symlink */
|
||||
res = symlink(file_header->link_name, file_header->name);
|
||||
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name);
|
||||
}
|
||||
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->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("Cannot create node %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
bb_error_msg_and_die("Unrecognised file type");
|
||||
switch (file_header->mode & S_IFMT) {
|
||||
case S_IFREG: {
|
||||
/* Regular file */
|
||||
dst_fd = xopen3(file_header->name, O_WRONLY | O_CREAT | O_EXCL,
|
||||
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 ((errno != EISDIR) && (res == -1)
|
||||
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("extract_archive: %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
case S_IFLNK:
|
||||
/* Symlink */
|
||||
res = symlink(file_header->link_name, file_header->name);
|
||||
if ((res == -1)
|
||||
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("cannot create symlink "
|
||||
"from %s to '%s'",
|
||||
file_header->name,
|
||||
file_header->link_name);
|
||||
}
|
||||
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->flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("cannot create node %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
bb_error_msg_and_die("unrecognized file type");
|
||||
}
|
||||
}
|
||||
|
||||
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) {
|
||||
lchown(file_header->name, file_header->uid, file_header->gid);
|
||||
}
|
||||
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_PERM) &&
|
||||
(file_header->mode & S_IFMT) != S_IFLNK)
|
||||
{
|
||||
/* uclibc has no lchmod, glibc is even stranger -
|
||||
* it has lchmod which seems to do nothing!
|
||||
* so we use chmod... */
|
||||
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_PERM)
|
||||
&& (file_header->mode & S_IFMT) != S_IFLNK
|
||||
) {
|
||||
chmod(file_header->name, file_header->mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,9 +10,8 @@
|
||||
|
||||
void data_extract_to_buffer(archive_handle_t *archive_handle)
|
||||
{
|
||||
const unsigned int size = archive_handle->file_header->size;
|
||||
unsigned int size = archive_handle->file_header->size;
|
||||
|
||||
archive_handle->buffer = xzalloc(size + 1);
|
||||
|
||||
xread(archive_handle->src_fd, archive_handle->buffer, size);
|
||||
}
|
||||
@@ -4,9 +4,10 @@
|
||||
*/
|
||||
|
||||
#include "unarchive.h"
|
||||
#include <unistd.h>
|
||||
|
||||
void data_extract_to_stdout(archive_handle_t *archive_handle)
|
||||
{
|
||||
bb_copyfd_size(archive_handle->src_fd, STDOUT_FILENO, archive_handle->file_header->size);
|
||||
bb_copyfd_exact_size(archive_handle->src_fd,
|
||||
STDOUT_FILENO,
|
||||
archive_handle->file_header->size);
|
||||
}
|
||||
@@ -28,37 +28,29 @@
|
||||
Manuel
|
||||
*/
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
#include "unarchive.h"
|
||||
|
||||
/* Constants for Huffman coding */
|
||||
#define MAX_GROUPS 6
|
||||
#define GROUP_SIZE 50 /* 64 would have been more efficient */
|
||||
#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */
|
||||
#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */
|
||||
#define SYMBOL_RUNA 0
|
||||
#define SYMBOL_RUNB 1
|
||||
#define MAX_GROUPS 6
|
||||
#define GROUP_SIZE 50 /* 64 would have been more efficient */
|
||||
#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */
|
||||
#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */
|
||||
#define SYMBOL_RUNA 0
|
||||
#define SYMBOL_RUNB 1
|
||||
|
||||
/* Status return values */
|
||||
#define RETVAL_OK 0
|
||||
#define RETVAL_LAST_BLOCK (-1)
|
||||
#define RETVAL_NOT_BZIP_DATA (-2)
|
||||
#define RETVAL_UNEXPECTED_INPUT_EOF (-3)
|
||||
#define RETVAL_UNEXPECTED_OUTPUT_EOF (-4)
|
||||
#define RETVAL_DATA_ERROR (-5)
|
||||
#define RETVAL_OUT_OF_MEMORY (-6)
|
||||
#define RETVAL_OBSOLETE_INPUT (-7)
|
||||
#define RETVAL_OK 0
|
||||
#define RETVAL_LAST_BLOCK (-1)
|
||||
#define RETVAL_NOT_BZIP_DATA (-2)
|
||||
#define RETVAL_UNEXPECTED_INPUT_EOF (-3)
|
||||
#define RETVAL_UNEXPECTED_OUTPUT_EOF (-4)
|
||||
#define RETVAL_DATA_ERROR (-5)
|
||||
#define RETVAL_OUT_OF_MEMORY (-6)
|
||||
#define RETVAL_OBSOLETE_INPUT (-7)
|
||||
|
||||
/* Other housekeeping constants */
|
||||
#define IOBUF_SIZE 4096
|
||||
#define IOBUF_SIZE 4096
|
||||
|
||||
/* This is what we know about each Huffman coding group */
|
||||
struct group_data {
|
||||
@@ -159,7 +151,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* Reset longjmp I/O error handling */
|
||||
|
||||
i=setjmp(bd->jmpbuf);
|
||||
if(i) return i;
|
||||
if (i) return i;
|
||||
|
||||
/* Read in header signature and CRC, then validate signature.
|
||||
(last block signature means CRC is for whole file, return now) */
|
||||
@@ -174,8 +166,8 @@ static int get_next_block(bunzip_data *bd)
|
||||
some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
|
||||
it didn't actually work. */
|
||||
|
||||
if(get_bits(bd,1)) return RETVAL_OBSOLETE_INPUT;
|
||||
if((origPtr=get_bits(bd,24)) > dbufSize) return RETVAL_DATA_ERROR;
|
||||
if (get_bits(bd,1)) return RETVAL_OBSOLETE_INPUT;
|
||||
if ((origPtr=get_bits(bd,24)) > dbufSize) return RETVAL_DATA_ERROR;
|
||||
|
||||
/* mapping table: if some byte values are never used (encoding things
|
||||
like ascii text), the compression code removes the gaps to have fewer
|
||||
@@ -188,7 +180,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
for (i=0;i<16;i++) {
|
||||
if(t&(1<<(15-i))) {
|
||||
k=get_bits(bd,16);
|
||||
for(j=0;j<16;j++)
|
||||
for (j=0;j<16;j++)
|
||||
if(k&(1<<(15-j))) symToByte[symTotal++]=(16*i)+j;
|
||||
}
|
||||
}
|
||||
@@ -204,17 +196,17 @@ static int get_next_block(bunzip_data *bd)
|
||||
start of the list.) */
|
||||
|
||||
if(!(nSelectors=get_bits(bd, 15))) return RETVAL_DATA_ERROR;
|
||||
for(i=0; i<groupCount; i++) mtfSymbol[i] = i;
|
||||
for(i=0; i<nSelectors; i++) {
|
||||
for (i=0; i<groupCount; i++) mtfSymbol[i] = i;
|
||||
for (i=0; i<nSelectors; i++) {
|
||||
|
||||
/* Get next value */
|
||||
|
||||
for(j=0;get_bits(bd,1);j++) if (j>=groupCount) return RETVAL_DATA_ERROR;
|
||||
for (j=0;get_bits(bd,1);j++) if (j>=groupCount) return RETVAL_DATA_ERROR;
|
||||
|
||||
/* Decode MTF to get the next selector */
|
||||
|
||||
uc = mtfSymbol[j];
|
||||
for(;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
|
||||
for (;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
|
||||
mtfSymbol[0]=selectors[i]=uc;
|
||||
}
|
||||
|
||||
@@ -235,7 +227,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
|
||||
t=get_bits(bd, 5)-1;
|
||||
for (i = 0; i < symCount; i++) {
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
if (((unsigned)t) > (MAX_HUFCODE_BITS-1))
|
||||
return RETVAL_DATA_ERROR;
|
||||
|
||||
@@ -262,7 +254,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* Find largest and smallest lengths in this group */
|
||||
|
||||
minLen=maxLen=length[0];
|
||||
for(i = 1; i < symCount; i++) {
|
||||
for (i = 1; i < symCount; i++) {
|
||||
if(length[i] > maxLen) maxLen = length[i];
|
||||
else if(length[i] < minLen) minLen = length[i];
|
||||
}
|
||||
@@ -292,9 +284,9 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
|
||||
|
||||
pp=0;
|
||||
for(i=minLen;i<=maxLen;i++) {
|
||||
for (i=minLen;i<=maxLen;i++) {
|
||||
temp[i]=limit[i]=0;
|
||||
for(t=0;t<symCount;t++)
|
||||
for (t=0;t<symCount;t++)
|
||||
if(length[t]==i) hufGroup->permute[pp++] = t;
|
||||
}
|
||||
|
||||
@@ -333,7 +325,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
|
||||
/* Initialize symbol occurrence counters and symbol Move To Front table */
|
||||
|
||||
for(i=0;i<256;i++) {
|
||||
for (i=0;i<256;i++) {
|
||||
byteCount[i] = 0;
|
||||
mtfSymbol[i]=(unsigned char)i;
|
||||
}
|
||||
@@ -341,7 +333,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* Loop through compressed symbols. */
|
||||
|
||||
runPos=dbufCount=selector=0;
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
|
||||
/* fetch next Huffman coding group from list. */
|
||||
|
||||
@@ -380,7 +372,7 @@ got_huff_bits:
|
||||
/* Figure how how many bits are in next symbol and unget extras */
|
||||
|
||||
i=hufGroup->minLen;
|
||||
while(j>limit[i]) ++i;
|
||||
while (j>limit[i]) ++i;
|
||||
bd->inbufBitCount += (hufGroup->maxLen - i);
|
||||
|
||||
/* Huffman decode value to get nextSym (with bounds checking) */
|
||||
@@ -429,7 +421,7 @@ got_huff_bits:
|
||||
|
||||
uc = symToByte[mtfSymbol[0]];
|
||||
byteCount[uc] += t;
|
||||
while(t--) dbuf[dbufCount++]=uc;
|
||||
while (t--) dbuf[dbufCount++]=uc;
|
||||
}
|
||||
|
||||
/* Is this the terminating symbol? */
|
||||
@@ -481,7 +473,7 @@ end_of_huffman_loop:
|
||||
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
|
||||
|
||||
j=0;
|
||||
for(i=0;i<256;i++) {
|
||||
for (i=0;i<256;i++) {
|
||||
k=j+byteCount[i];
|
||||
byteCount[i] = j;
|
||||
j=k;
|
||||
@@ -543,7 +535,7 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
|
||||
/* Loop outputting bytes */
|
||||
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
|
||||
/* If the output buffer is full, snapshot state and return */
|
||||
|
||||
@@ -655,7 +647,7 @@ static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf,
|
||||
|
||||
/* Init the CRC32 table (big endian) */
|
||||
|
||||
bd->crc32Table = bb_crc32_filltable(1);
|
||||
bd->crc32Table = crc32_filltable(1);
|
||||
|
||||
/* Setup for I/O error handling via longjmp */
|
||||
|
||||
@@ -679,20 +671,24 @@ static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf,
|
||||
/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip data,
|
||||
not end of file.) */
|
||||
|
||||
int uncompressStream(int src_fd, int dst_fd)
|
||||
USE_DESKTOP(long long) int
|
||||
uncompressStream(int src_fd, int dst_fd)
|
||||
{
|
||||
USE_DESKTOP(long long total_written = 0;)
|
||||
char *outbuf;
|
||||
bunzip_data *bd;
|
||||
int i;
|
||||
|
||||
outbuf=xmalloc(IOBUF_SIZE);
|
||||
if(!(i=start_bunzip(&bd,src_fd,0,0))) {
|
||||
for(;;) {
|
||||
i=start_bunzip(&bd,src_fd,0,0);
|
||||
if(!i) {
|
||||
for (;;) {
|
||||
if((i=read_bunzip(bd,outbuf,IOBUF_SIZE)) <= 0) break;
|
||||
if(i!=write(dst_fd,outbuf,i)) {
|
||||
i=RETVAL_UNEXPECTED_OUTPUT_EOF;
|
||||
break;
|
||||
}
|
||||
USE_DESKTOP(total_written += i;)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -700,27 +696,27 @@ int uncompressStream(int src_fd, int dst_fd)
|
||||
|
||||
if(i==RETVAL_LAST_BLOCK) {
|
||||
if (bd->headerCRC!=bd->totalCRC) {
|
||||
bb_error_msg("Data integrity error when decompressing.");
|
||||
bb_error_msg("data integrity error when decompressing");
|
||||
} else {
|
||||
i=RETVAL_OK;
|
||||
}
|
||||
} else if (i==RETVAL_UNEXPECTED_OUTPUT_EOF) {
|
||||
bb_error_msg("Compressed file ends unexpectedly");
|
||||
bb_error_msg("compressed file ends unexpectedly");
|
||||
} else {
|
||||
bb_error_msg("Decompression failed");
|
||||
bb_error_msg("decompression failed");
|
||||
}
|
||||
free(bd->dbuf);
|
||||
free(bd);
|
||||
free(outbuf);
|
||||
|
||||
return i;
|
||||
return i ? i : USE_DESKTOP(total_written) + 0;
|
||||
}
|
||||
|
||||
#ifdef TESTING
|
||||
|
||||
static char * const bunzip_errors[]={NULL,"Bad file checksum","Not bzip data",
|
||||
"Unexpected input EOF","Unexpected output EOF","Data error",
|
||||
"Out of memory","Obsolete (pre 0.9.5) bzip format not supported."};
|
||||
"Out of memory","Obsolete (pre 0.9.5) bzip format not supported."};
|
||||
|
||||
/* Dumb little test thing, decompress stdin to stdout */
|
||||
int main(int argc, char *argv[])
|
||||
@@ -728,8 +724,8 @@ int main(int argc, char *argv[])
|
||||
int i=uncompressStream(0,1);
|
||||
char c;
|
||||
|
||||
if(i) fprintf(stderr,"%s\n", bunzip_errors[-i]);
|
||||
else if(read(0,&c,1)) fprintf(stderr,"Trailing garbage ignored\n");
|
||||
if(i<0) fprintf(stderr,"%s\n", bunzip_errors[-i]);
|
||||
else if(read(0,&c,1)) fprintf(stderr,"Trailing garbage ignored\n");
|
||||
return -i;
|
||||
}
|
||||
#endif
|
||||
@@ -64,28 +64,12 @@
|
||||
#undef MAXSEG_64K
|
||||
#define MAXCODE(n) (1L << (n))
|
||||
|
||||
/* Block compress mode -C compatible with 2.0 */
|
||||
static int block_mode = BLOCK_MODE;
|
||||
|
||||
/* user settable max # bits/code */
|
||||
static int maxbits = BITS;
|
||||
|
||||
/* Input buffer */
|
||||
static unsigned char inbuf[IBUFSIZ + 64];
|
||||
|
||||
/* Output buffer */
|
||||
static unsigned char outbuf[OBUFSIZ + 2048];
|
||||
|
||||
|
||||
static unsigned char htab[HSIZE];
|
||||
static unsigned short codetab[HSIZE];
|
||||
|
||||
#define htabof(i) htab[i]
|
||||
#define codetabof(i) codetab[i]
|
||||
#define tab_prefixof(i) codetabof(i)
|
||||
#define tab_suffixof(i) ((unsigned char *)(htab))[i]
|
||||
#define de_stack ((unsigned char *)&(htab[HSIZE-1]))
|
||||
#define clear_htab() memset(htab, -1, sizeof(htab))
|
||||
#define clear_htab() memset(htab, -1, HSIZE)
|
||||
#define clear_tab_prefixof() memset(codetab, 0, 256);
|
||||
|
||||
|
||||
@@ -96,8 +80,10 @@ static unsigned short codetab[HSIZE];
|
||||
* with those of the compress() routine. See the definitions above.
|
||||
*/
|
||||
|
||||
int uncompress(int fd_in, int fd_out)
|
||||
USE_DESKTOP(long long) int
|
||||
uncompress(int fd_in, int fd_out)
|
||||
{
|
||||
USE_DESKTOP(long long total_written = 0;)
|
||||
unsigned char *stackp;
|
||||
long int code;
|
||||
int finchar;
|
||||
@@ -113,23 +99,42 @@ int uncompress(int fd_in, int fd_out)
|
||||
long int maxmaxcode;
|
||||
int n_bits;
|
||||
int rsize = 0;
|
||||
RESERVE_CONFIG_UBUFFER(inbuf, IBUFSIZ + 64);
|
||||
RESERVE_CONFIG_UBUFFER(outbuf, OBUFSIZ + 2048);
|
||||
unsigned char htab[HSIZE];
|
||||
unsigned short codetab[HSIZE];
|
||||
|
||||
/* Hmm, these were statics - why?! */
|
||||
/* user settable max # bits/code */
|
||||
int maxbits; /* = BITS; */
|
||||
/* block compress mode -C compatible with 2.0 */
|
||||
int block_mode; /* = BLOCK_MODE; */
|
||||
|
||||
memset(inbuf, 0, IBUFSIZ + 64);
|
||||
memset(outbuf, 0, OBUFSIZ + 2048);
|
||||
|
||||
insize = 0;
|
||||
|
||||
inbuf[0] = xread_char(fd_in);
|
||||
/* xread isn't good here, we have to return - caller may want
|
||||
* to do some cleanup (e.g. delete incomplete unpacked file etc) */
|
||||
if (full_read(fd_in, inbuf, 1) != 1) {
|
||||
bb_error_msg("short read");
|
||||
return -1;
|
||||
}
|
||||
|
||||
maxbits = inbuf[0] & BIT_MASK;
|
||||
block_mode = inbuf[0] & BLOCK_MODE;
|
||||
maxmaxcode = MAXCODE(maxbits);
|
||||
|
||||
if (maxbits > BITS) {
|
||||
bb_error_msg("compressed with %d bits, can only handle %d bits", maxbits,
|
||||
BITS);
|
||||
bb_error_msg("compressed with %d bits, can only handle "
|
||||
"%d bits", maxbits, BITS);
|
||||
return -1;
|
||||
}
|
||||
|
||||
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
n_bits = INIT_BITS;
|
||||
maxcode = MAXCODE(INIT_BITS) - 1;
|
||||
bitmask = (1 << INIT_BITS) - 1;
|
||||
oldcode = -1;
|
||||
finchar = 0;
|
||||
outpos = 0;
|
||||
@@ -145,13 +150,14 @@ int uncompress(int fd_in, int fd_out)
|
||||
}
|
||||
|
||||
do {
|
||||
resetbuf:;
|
||||
resetbuf:
|
||||
{
|
||||
int i;
|
||||
int e;
|
||||
int o;
|
||||
|
||||
e = insize - (o = (posbits >> 3));
|
||||
o = posbits >> 3;
|
||||
e = insize - o;
|
||||
|
||||
for (i = 0; i < e; ++i)
|
||||
inbuf[i] = inbuf[i + o];
|
||||
@@ -160,8 +166,9 @@ int uncompress(int fd_in, int fd_out)
|
||||
posbits = 0;
|
||||
}
|
||||
|
||||
if (insize < (int) sizeof(inbuf) - IBUFSIZ) {
|
||||
if (insize < (int) (IBUFSIZ + 64) - IBUFSIZ) {
|
||||
rsize = safe_read(fd_in, inbuf + insize, IBUFSIZ);
|
||||
//error check??
|
||||
insize += rsize;
|
||||
}
|
||||
|
||||
@@ -186,16 +193,16 @@ int uncompress(int fd_in, int fd_out)
|
||||
{
|
||||
unsigned char *p = &inbuf[posbits >> 3];
|
||||
|
||||
code =
|
||||
((((long) (p[0])) | ((long) (p[1]) << 8) |
|
||||
((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
|
||||
code = ((((long) (p[0])) | ((long) (p[1]) << 8) |
|
||||
((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
|
||||
}
|
||||
posbits += n_bits;
|
||||
|
||||
|
||||
if (oldcode == -1) {
|
||||
outbuf[outpos++] = (unsigned char) (finchar =
|
||||
(int) (oldcode = code));
|
||||
oldcode = code;
|
||||
finchar = (int) oldcode;
|
||||
outbuf[outpos++] = (unsigned char) finchar;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -206,8 +213,9 @@ int uncompress(int fd_in, int fd_out)
|
||||
((posbits - 1) +
|
||||
((n_bits << 3) -
|
||||
(posbits - 1 + (n_bits << 3)) % (n_bits << 3)));
|
||||
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
n_bits = INIT_BITS;
|
||||
maxcode = MAXCODE(INIT_BITS) - 1;
|
||||
bitmask = (1 << INIT_BITS) - 1;
|
||||
goto resetbuf;
|
||||
}
|
||||
|
||||
@@ -240,13 +248,15 @@ int uncompress(int fd_in, int fd_out)
|
||||
code = tab_prefixof(code);
|
||||
}
|
||||
|
||||
*--stackp = (unsigned char) (finchar = tab_suffixof(code));
|
||||
finchar = tab_suffixof(code);
|
||||
*--stackp = (unsigned char) finchar;
|
||||
|
||||
/* And put them out in forward order */
|
||||
{
|
||||
int i;
|
||||
|
||||
if (outpos + (i = (de_stack - stackp)) >= OBUFSIZ) {
|
||||
i = de_stack - stackp;
|
||||
if (outpos + i >= OBUFSIZ) {
|
||||
do {
|
||||
if (i > OBUFSIZ - outpos) {
|
||||
i = OBUFSIZ - outpos;
|
||||
@@ -258,11 +268,14 @@ int uncompress(int fd_in, int fd_out)
|
||||
}
|
||||
|
||||
if (outpos >= OBUFSIZ) {
|
||||
write(fd_out, outbuf, outpos);
|
||||
full_write(fd_out, outbuf, outpos);
|
||||
//error check??
|
||||
USE_DESKTOP(total_written += outpos;)
|
||||
outpos = 0;
|
||||
}
|
||||
stackp += i;
|
||||
} while ((i = (de_stack - stackp)) > 0);
|
||||
i = de_stack - stackp;
|
||||
} while (i > 0);
|
||||
} else {
|
||||
memcpy(outbuf + outpos, stackp, i);
|
||||
outpos += i;
|
||||
@@ -270,7 +283,8 @@ int uncompress(int fd_in, int fd_out)
|
||||
}
|
||||
|
||||
/* Generate the new entry. */
|
||||
if ((code = free_ent) < maxmaxcode) {
|
||||
code = free_ent;
|
||||
if (code < maxmaxcode) {
|
||||
tab_prefixof(code) = (unsigned short) oldcode;
|
||||
tab_suffixof(code) = (unsigned char) finchar;
|
||||
free_ent = code + 1;
|
||||
@@ -283,8 +297,12 @@ int uncompress(int fd_in, int fd_out)
|
||||
} while (rsize > 0);
|
||||
|
||||
if (outpos > 0) {
|
||||
write(fd_out, outbuf, outpos);
|
||||
full_write(fd_out, outbuf, outpos);
|
||||
//error check??
|
||||
USE_DESKTOP(total_written += outpos;)
|
||||
}
|
||||
|
||||
return 0;
|
||||
RELEASE_CONFIG_BUFFER(inbuf);
|
||||
RELEASE_CONFIG_BUFFER(outbuf);
|
||||
return USE_DESKTOP(total_written) + 0;
|
||||
}
|
||||
@@ -22,15 +22,23 @@
|
||||
typedef struct {
|
||||
int fd;
|
||||
uint8_t *ptr;
|
||||
uint8_t *buffer;
|
||||
|
||||
/* Was keeping rc on stack in unlzma and separately allocating buffer,
|
||||
* but with "buffer 'attached to' allocated rc" code is smaller: */
|
||||
/* uint8_t *buffer; */
|
||||
#define RC_BUFFER ((uint8_t*)(rc+1))
|
||||
|
||||
uint8_t *buffer_end;
|
||||
int buffer_size;
|
||||
|
||||
/* Had provisions for variable buffer, but we don't need it here */
|
||||
/* int buffer_size; */
|
||||
#define RC_BUFFER_SIZE 0x10000
|
||||
|
||||
uint32_t code;
|
||||
uint32_t range;
|
||||
uint32_t bound;
|
||||
} rc_t;
|
||||
|
||||
|
||||
#define RC_TOP_BITS 24
|
||||
#define RC_MOVE_BITS 5
|
||||
#define RC_MODEL_TOTAL_BITS 11
|
||||
@@ -39,22 +47,24 @@ typedef struct {
|
||||
/* Called twice: once at startup and once in rc_normalize() */
|
||||
static void rc_read(rc_t * rc)
|
||||
{
|
||||
rc->buffer_size = read(rc->fd, rc->buffer, rc->buffer_size);
|
||||
if (rc->buffer_size <= 0)
|
||||
int buffer_size = safe_read(rc->fd, RC_BUFFER, RC_BUFFER_SIZE);
|
||||
if (buffer_size <= 0)
|
||||
bb_error_msg_and_die("unexpected EOF");
|
||||
rc->ptr = rc->buffer;
|
||||
rc->buffer_end = rc->buffer + rc->buffer_size;
|
||||
rc->ptr = RC_BUFFER;
|
||||
rc->buffer_end = RC_BUFFER + buffer_size;
|
||||
}
|
||||
|
||||
/* Called once */
|
||||
static void rc_init(rc_t * rc, int fd, int buffer_size)
|
||||
static rc_t* rc_init(int fd) /*, int buffer_size) */
|
||||
{
|
||||
int i;
|
||||
rc_t* rc;
|
||||
|
||||
rc = xmalloc(sizeof(rc_t) + RC_BUFFER_SIZE);
|
||||
|
||||
rc->fd = fd;
|
||||
rc->buffer = xmalloc(buffer_size);
|
||||
rc->buffer_size = buffer_size;
|
||||
rc->buffer_end = rc->buffer + rc->buffer_size;
|
||||
/* rc->buffer_size = buffer_size; */
|
||||
rc->buffer_end = RC_BUFFER + RC_BUFFER_SIZE;
|
||||
rc->ptr = rc->buffer_end;
|
||||
|
||||
rc->code = 0;
|
||||
@@ -64,13 +74,14 @@ static void rc_init(rc_t * rc, int fd, int buffer_size)
|
||||
rc_read(rc);
|
||||
rc->code = (rc->code << 8) | *rc->ptr++;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Called once. TODO: bb_maybe_free() */
|
||||
/* Called once */
|
||||
static ATTRIBUTE_ALWAYS_INLINE void rc_free(rc_t * rc)
|
||||
{
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(rc->buffer);
|
||||
free(rc);
|
||||
}
|
||||
|
||||
/* Called twice, but one callsite is in speed_inline'd rc_is_bit_0_helper() */
|
||||
@@ -163,57 +174,63 @@ typedef struct {
|
||||
} __attribute__ ((packed)) lzma_header_t;
|
||||
|
||||
|
||||
#define LZMA_BASE_SIZE 1846
|
||||
#define LZMA_LIT_SIZE 768
|
||||
/* #defines will force compiler to compute/optimize each one with each usage.
|
||||
* Have heart and use enum instead. */
|
||||
enum {
|
||||
LZMA_BASE_SIZE = 1846,
|
||||
LZMA_LIT_SIZE = 768,
|
||||
|
||||
#define LZMA_NUM_POS_BITS_MAX 4
|
||||
LZMA_NUM_POS_BITS_MAX = 4,
|
||||
|
||||
#define LZMA_LEN_NUM_LOW_BITS 3
|
||||
#define LZMA_LEN_NUM_MID_BITS 3
|
||||
#define LZMA_LEN_NUM_HIGH_BITS 8
|
||||
LZMA_LEN_NUM_LOW_BITS = 3,
|
||||
LZMA_LEN_NUM_MID_BITS = 3,
|
||||
LZMA_LEN_NUM_HIGH_BITS = 8,
|
||||
|
||||
#define LZMA_LEN_CHOICE 0
|
||||
#define LZMA_LEN_CHOICE_2 (LZMA_LEN_CHOICE + 1)
|
||||
#define LZMA_LEN_LOW (LZMA_LEN_CHOICE_2 + 1)
|
||||
#define LZMA_LEN_MID (LZMA_LEN_LOW \
|
||||
+ (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_LOW_BITS)))
|
||||
#define LZMA_LEN_HIGH (LZMA_LEN_MID \
|
||||
+(1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_MID_BITS)))
|
||||
#define LZMA_NUM_LEN_PROBS (LZMA_LEN_HIGH + (1 << LZMA_LEN_NUM_HIGH_BITS))
|
||||
LZMA_LEN_CHOICE = 0,
|
||||
LZMA_LEN_CHOICE_2 = (LZMA_LEN_CHOICE + 1),
|
||||
LZMA_LEN_LOW = (LZMA_LEN_CHOICE_2 + 1),
|
||||
LZMA_LEN_MID = (LZMA_LEN_LOW \
|
||||
+ (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_LOW_BITS))),
|
||||
LZMA_LEN_HIGH = (LZMA_LEN_MID \
|
||||
+ (1 << (LZMA_NUM_POS_BITS_MAX + LZMA_LEN_NUM_MID_BITS))),
|
||||
LZMA_NUM_LEN_PROBS = (LZMA_LEN_HIGH + (1 << LZMA_LEN_NUM_HIGH_BITS)),
|
||||
|
||||
#define LZMA_NUM_STATES 12
|
||||
#define LZMA_NUM_LIT_STATES 7
|
||||
LZMA_NUM_STATES = 12,
|
||||
LZMA_NUM_LIT_STATES = 7,
|
||||
|
||||
#define LZMA_START_POS_MODEL_INDEX 4
|
||||
#define LZMA_END_POS_MODEL_INDEX 14
|
||||
#define LZMA_NUM_FULL_DISTANCES (1 << (LZMA_END_POS_MODEL_INDEX >> 1))
|
||||
LZMA_START_POS_MODEL_INDEX = 4,
|
||||
LZMA_END_POS_MODEL_INDEX = 14,
|
||||
LZMA_NUM_FULL_DISTANCES = (1 << (LZMA_END_POS_MODEL_INDEX >> 1)),
|
||||
|
||||
#define LZMA_NUM_POS_SLOT_BITS 6
|
||||
#define LZMA_NUM_LEN_TO_POS_STATES 4
|
||||
LZMA_NUM_POS_SLOT_BITS = 6,
|
||||
LZMA_NUM_LEN_TO_POS_STATES = 4,
|
||||
|
||||
#define LZMA_NUM_ALIGN_BITS 4
|
||||
LZMA_NUM_ALIGN_BITS = 4,
|
||||
|
||||
#define LZMA_MATCH_MIN_LEN 2
|
||||
LZMA_MATCH_MIN_LEN = 2,
|
||||
|
||||
#define LZMA_IS_MATCH 0
|
||||
#define LZMA_IS_REP (LZMA_IS_MATCH + (LZMA_NUM_STATES <<LZMA_NUM_POS_BITS_MAX))
|
||||
#define LZMA_IS_REP_G0 (LZMA_IS_REP + LZMA_NUM_STATES)
|
||||
#define LZMA_IS_REP_G1 (LZMA_IS_REP_G0 + LZMA_NUM_STATES)
|
||||
#define LZMA_IS_REP_G2 (LZMA_IS_REP_G1 + LZMA_NUM_STATES)
|
||||
#define LZMA_IS_REP_0_LONG (LZMA_IS_REP_G2 + LZMA_NUM_STATES)
|
||||
#define LZMA_POS_SLOT (LZMA_IS_REP_0_LONG \
|
||||
+ (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX))
|
||||
#define LZMA_SPEC_POS (LZMA_POS_SLOT \
|
||||
+(LZMA_NUM_LEN_TO_POS_STATES << LZMA_NUM_POS_SLOT_BITS))
|
||||
#define LZMA_ALIGN (LZMA_SPEC_POS \
|
||||
+ LZMA_NUM_FULL_DISTANCES - LZMA_END_POS_MODEL_INDEX)
|
||||
#define LZMA_LEN_CODER (LZMA_ALIGN + (1 << LZMA_NUM_ALIGN_BITS))
|
||||
#define LZMA_REP_LEN_CODER (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS)
|
||||
#define LZMA_LITERAL (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS)
|
||||
LZMA_IS_MATCH = 0,
|
||||
LZMA_IS_REP = (LZMA_IS_MATCH + (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX)),
|
||||
LZMA_IS_REP_G0 = (LZMA_IS_REP + LZMA_NUM_STATES),
|
||||
LZMA_IS_REP_G1 = (LZMA_IS_REP_G0 + LZMA_NUM_STATES),
|
||||
LZMA_IS_REP_G2 = (LZMA_IS_REP_G1 + LZMA_NUM_STATES),
|
||||
LZMA_IS_REP_0_LONG = (LZMA_IS_REP_G2 + LZMA_NUM_STATES),
|
||||
LZMA_POS_SLOT = (LZMA_IS_REP_0_LONG \
|
||||
+ (LZMA_NUM_STATES << LZMA_NUM_POS_BITS_MAX)),
|
||||
LZMA_SPEC_POS = (LZMA_POS_SLOT \
|
||||
+ (LZMA_NUM_LEN_TO_POS_STATES << LZMA_NUM_POS_SLOT_BITS)),
|
||||
LZMA_ALIGN = (LZMA_SPEC_POS \
|
||||
+ LZMA_NUM_FULL_DISTANCES - LZMA_END_POS_MODEL_INDEX),
|
||||
LZMA_LEN_CODER = (LZMA_ALIGN + (1 << LZMA_NUM_ALIGN_BITS)),
|
||||
LZMA_REP_LEN_CODER = (LZMA_LEN_CODER + LZMA_NUM_LEN_PROBS),
|
||||
LZMA_LITERAL = (LZMA_REP_LEN_CODER + LZMA_NUM_LEN_PROBS),
|
||||
};
|
||||
|
||||
|
||||
int unlzma(int src_fd, int dst_fd)
|
||||
USE_DESKTOP(long long) int
|
||||
unlzma(int src_fd, int dst_fd)
|
||||
{
|
||||
USE_DESKTOP(long long total_written = 0;)
|
||||
lzma_header_t header;
|
||||
int lc, pb, lp;
|
||||
uint32_t pos_state_mask;
|
||||
@@ -224,7 +241,7 @@ int unlzma(int src_fd, int dst_fd)
|
||||
uint16_t *prob_lit;
|
||||
int num_bits;
|
||||
int num_probs;
|
||||
rc_t rc;
|
||||
rc_t *rc;
|
||||
int i, mi;
|
||||
uint8_t *buffer;
|
||||
uint8_t previous_byte = 0;
|
||||
@@ -233,8 +250,7 @@ int unlzma(int src_fd, int dst_fd)
|
||||
int state = 0;
|
||||
uint32_t rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
|
||||
|
||||
if (read(src_fd, &header, sizeof(header)) != sizeof(header))
|
||||
bb_error_msg_and_die("can't read header");
|
||||
xread(src_fd, &header, sizeof(header));
|
||||
|
||||
if (header.pos >= (9 * 5 * 5))
|
||||
bb_error_msg_and_die("bad header");
|
||||
@@ -259,16 +275,16 @@ int unlzma(int src_fd, int dst_fd)
|
||||
for (i = 0; i < num_probs; i++)
|
||||
p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
|
||||
|
||||
rc_init(&rc, src_fd, 0x10000);
|
||||
rc = rc_init(src_fd); /*, RC_BUFFER_SIZE); */
|
||||
|
||||
while (global_pos + buffer_pos < header.dst_size) {
|
||||
int pos_state = (buffer_pos + global_pos) & pos_state_mask;
|
||||
|
||||
prob =
|
||||
p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state;
|
||||
if (rc_is_bit_0(&rc, prob)) {
|
||||
if (rc_is_bit_0(rc, prob)) {
|
||||
mi = 1;
|
||||
rc_update_bit_0(&rc, prob);
|
||||
rc_update_bit_0(rc, prob);
|
||||
prob = (p + LZMA_LITERAL + (LZMA_LIT_SIZE
|
||||
* ((((buffer_pos + global_pos) & literal_pos_mask) << lc)
|
||||
+ (previous_byte >> (8 - lc)))));
|
||||
@@ -286,7 +302,7 @@ int unlzma(int src_fd, int dst_fd)
|
||||
match_byte <<= 1;
|
||||
bit = match_byte & 0x100;
|
||||
prob_lit = prob + 0x100 + bit + mi;
|
||||
if (rc_get_bit(&rc, prob_lit, &mi)) {
|
||||
if (rc_get_bit(rc, prob_lit, &mi)) {
|
||||
if (!bit)
|
||||
break;
|
||||
} else {
|
||||
@@ -297,7 +313,7 @@ int unlzma(int src_fd, int dst_fd)
|
||||
}
|
||||
while (mi < 0x100) {
|
||||
prob_lit = prob + mi;
|
||||
rc_get_bit(&rc, prob_lit, &mi);
|
||||
rc_get_bit(rc, prob_lit, &mi);
|
||||
}
|
||||
previous_byte = (uint8_t) mi;
|
||||
|
||||
@@ -305,7 +321,9 @@ int unlzma(int src_fd, int dst_fd)
|
||||
if (buffer_pos == header.dict_size) {
|
||||
buffer_pos = 0;
|
||||
global_pos += header.dict_size;
|
||||
write(dst_fd, buffer, header.dict_size);
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
|
||||
goto bad;
|
||||
USE_DESKTOP(total_written += header.dict_size;)
|
||||
}
|
||||
if (state < 4)
|
||||
state = 0;
|
||||
@@ -317,24 +335,24 @@ int unlzma(int src_fd, int dst_fd)
|
||||
int offset;
|
||||
uint16_t *prob_len;
|
||||
|
||||
rc_update_bit_1(&rc, prob);
|
||||
rc_update_bit_1(rc, prob);
|
||||
prob = p + LZMA_IS_REP + state;
|
||||
if (rc_is_bit_0(&rc, prob)) {
|
||||
rc_update_bit_0(&rc, prob);
|
||||
if (rc_is_bit_0(rc, prob)) {
|
||||
rc_update_bit_0(rc, prob);
|
||||
rep3 = rep2;
|
||||
rep2 = rep1;
|
||||
rep1 = rep0;
|
||||
state = state < LZMA_NUM_LIT_STATES ? 0 : 3;
|
||||
prob = p + LZMA_LEN_CODER;
|
||||
} else {
|
||||
rc_update_bit_1(&rc, prob);
|
||||
rc_update_bit_1(rc, prob);
|
||||
prob = p + LZMA_IS_REP_G0 + state;
|
||||
if (rc_is_bit_0(&rc, prob)) {
|
||||
rc_update_bit_0(&rc, prob);
|
||||
if (rc_is_bit_0(rc, prob)) {
|
||||
rc_update_bit_0(rc, prob);
|
||||
prob = (p + LZMA_IS_REP_0_LONG
|
||||
+ (state << LZMA_NUM_POS_BITS_MAX) + pos_state);
|
||||
if (rc_is_bit_0(&rc, prob)) {
|
||||
rc_update_bit_0(&rc, prob);
|
||||
if (rc_is_bit_0(rc, prob)) {
|
||||
rc_update_bit_0(rc, prob);
|
||||
|
||||
state = state < LZMA_NUM_LIT_STATES ? 9 : 11;
|
||||
pos = buffer_pos - rep0;
|
||||
@@ -345,28 +363,30 @@ int unlzma(int src_fd, int dst_fd)
|
||||
if (buffer_pos == header.dict_size) {
|
||||
buffer_pos = 0;
|
||||
global_pos += header.dict_size;
|
||||
write(dst_fd, buffer, header.dict_size);
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
|
||||
goto bad;
|
||||
USE_DESKTOP(total_written += header.dict_size;)
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
rc_update_bit_1(&rc, prob);
|
||||
rc_update_bit_1(rc, prob);
|
||||
}
|
||||
} else {
|
||||
uint32_t distance;
|
||||
|
||||
rc_update_bit_1(&rc, prob);
|
||||
rc_update_bit_1(rc, prob);
|
||||
prob = p + LZMA_IS_REP_G1 + state;
|
||||
if (rc_is_bit_0(&rc, prob)) {
|
||||
rc_update_bit_0(&rc, prob);
|
||||
if (rc_is_bit_0(rc, prob)) {
|
||||
rc_update_bit_0(rc, prob);
|
||||
distance = rep1;
|
||||
} else {
|
||||
rc_update_bit_1(&rc, prob);
|
||||
rc_update_bit_1(rc, prob);
|
||||
prob = p + LZMA_IS_REP_G2 + state;
|
||||
if (rc_is_bit_0(&rc, prob)) {
|
||||
rc_update_bit_0(&rc, prob);
|
||||
if (rc_is_bit_0(rc, prob)) {
|
||||
rc_update_bit_0(rc, prob);
|
||||
distance = rep2;
|
||||
} else {
|
||||
rc_update_bit_1(&rc, prob);
|
||||
rc_update_bit_1(rc, prob);
|
||||
distance = rep3;
|
||||
rep3 = rep2;
|
||||
}
|
||||
@@ -380,30 +400,30 @@ int unlzma(int src_fd, int dst_fd)
|
||||
}
|
||||
|
||||
prob_len = prob + LZMA_LEN_CHOICE;
|
||||
if (rc_is_bit_0(&rc, prob_len)) {
|
||||
rc_update_bit_0(&rc, prob_len);
|
||||
if (rc_is_bit_0(rc, prob_len)) {
|
||||
rc_update_bit_0(rc, prob_len);
|
||||
prob_len = (prob + LZMA_LEN_LOW
|
||||
+ (pos_state << LZMA_LEN_NUM_LOW_BITS));
|
||||
offset = 0;
|
||||
num_bits = LZMA_LEN_NUM_LOW_BITS;
|
||||
} else {
|
||||
rc_update_bit_1(&rc, prob_len);
|
||||
rc_update_bit_1(rc, prob_len);
|
||||
prob_len = prob + LZMA_LEN_CHOICE_2;
|
||||
if (rc_is_bit_0(&rc, prob_len)) {
|
||||
rc_update_bit_0(&rc, prob_len);
|
||||
if (rc_is_bit_0(rc, prob_len)) {
|
||||
rc_update_bit_0(rc, prob_len);
|
||||
prob_len = (prob + LZMA_LEN_MID
|
||||
+ (pos_state << LZMA_LEN_NUM_MID_BITS));
|
||||
offset = 1 << LZMA_LEN_NUM_LOW_BITS;
|
||||
num_bits = LZMA_LEN_NUM_MID_BITS;
|
||||
} else {
|
||||
rc_update_bit_1(&rc, prob_len);
|
||||
rc_update_bit_1(rc, prob_len);
|
||||
prob_len = prob + LZMA_LEN_HIGH;
|
||||
offset = ((1 << LZMA_LEN_NUM_LOW_BITS)
|
||||
+ (1 << LZMA_LEN_NUM_MID_BITS));
|
||||
num_bits = LZMA_LEN_NUM_HIGH_BITS;
|
||||
}
|
||||
}
|
||||
rc_bit_tree_decode(&rc, prob_len, num_bits, &len);
|
||||
rc_bit_tree_decode(rc, prob_len, num_bits, &len);
|
||||
len += offset;
|
||||
|
||||
if (state < 4) {
|
||||
@@ -416,7 +436,7 @@ int unlzma(int src_fd, int dst_fd)
|
||||
LZMA_NUM_LEN_TO_POS_STATES ? len :
|
||||
LZMA_NUM_LEN_TO_POS_STATES - 1)
|
||||
<< LZMA_NUM_POS_SLOT_BITS);
|
||||
rc_bit_tree_decode(&rc, prob, LZMA_NUM_POS_SLOT_BITS,
|
||||
rc_bit_tree_decode(rc, prob, LZMA_NUM_POS_SLOT_BITS,
|
||||
&pos_slot);
|
||||
if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
|
||||
num_bits = (pos_slot >> 1) - 1;
|
||||
@@ -427,7 +447,7 @@ int unlzma(int src_fd, int dst_fd)
|
||||
} else {
|
||||
num_bits -= LZMA_NUM_ALIGN_BITS;
|
||||
while (num_bits--)
|
||||
rep0 = (rep0 << 1) | rc_direct_bit(&rc);
|
||||
rep0 = (rep0 << 1) | rc_direct_bit(rc);
|
||||
prob = p + LZMA_ALIGN;
|
||||
rep0 <<= LZMA_NUM_ALIGN_BITS;
|
||||
num_bits = LZMA_NUM_ALIGN_BITS;
|
||||
@@ -435,7 +455,7 @@ int unlzma(int src_fd, int dst_fd)
|
||||
i = 1;
|
||||
mi = 1;
|
||||
while (num_bits--) {
|
||||
if (rc_get_bit(&rc, prob + mi, &mi))
|
||||
if (rc_get_bit(rc, prob + mi, &mi))
|
||||
rep0 |= i;
|
||||
i <<= 1;
|
||||
}
|
||||
@@ -456,15 +476,22 @@ int unlzma(int src_fd, int dst_fd)
|
||||
if (buffer_pos == header.dict_size) {
|
||||
buffer_pos = 0;
|
||||
global_pos += header.dict_size;
|
||||
write(dst_fd, buffer, header.dict_size);
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
|
||||
goto bad;
|
||||
USE_DESKTOP(total_written += header.dict_size;)
|
||||
}
|
||||
len--;
|
||||
} while (len != 0 && buffer_pos < header.dst_size);
|
||||
}
|
||||
}
|
||||
|
||||
write(dst_fd, buffer, buffer_pos);
|
||||
rc_free(&rc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (full_write(dst_fd, buffer, buffer_pos) != buffer_pos) {
|
||||
bad:
|
||||
rc_free(rc);
|
||||
return -1;
|
||||
}
|
||||
rc_free(rc);
|
||||
USE_DESKTOP(total_written += buffer_pos;)
|
||||
return USE_DESKTOP(total_written) + 0;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -11,9 +11,7 @@
|
||||
/* Accept any non-null name, its not really a filter at all */
|
||||
char filter_accept_all(archive_handle_t *archive_handle)
|
||||
{
|
||||
if (archive_handle->file_header->name) {
|
||||
return(EXIT_SUCCESS);
|
||||
} else {
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
if (archive_handle->file_header->name)
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -13,9 +13,7 @@
|
||||
*/
|
||||
char filter_accept_list(archive_handle_t *archive_handle)
|
||||
{
|
||||
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
|
||||
return(EXIT_SUCCESS);
|
||||
} else {
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name))
|
||||
return EXIT_SUCCESS;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -5,17 +5,13 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/*
|
||||
* Reassign the subarchive metadata parser based on the filename extension
|
||||
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz
|
||||
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
|
||||
* Reassign the subarchive metadata parser based on the filename extension
|
||||
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz
|
||||
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
|
||||
*/
|
||||
char filter_accept_list_reassign(archive_handle_t *archive_handle)
|
||||
{
|
||||
@@ -30,19 +26,19 @@ char filter_accept_list_reassign(archive_handle_t *archive_handle)
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
if (strcmp(name_ptr, ".gz") == 0) {
|
||||
archive_handle->action_data_subarchive = get_header_tar_gz;
|
||||
return(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
if (strcmp(name_ptr, ".bz2") == 0) {
|
||||
archive_handle->action_data_subarchive = get_header_tar_bz2;
|
||||
return(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
if (ENABLE_FEATURE_DEB_TAR_LZMA && !strcmp(name_ptr, ".lzma")) {
|
||||
archive_handle->action_data_subarchive = get_header_tar_lzma;
|
||||
return(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -14,20 +14,20 @@
|
||||
char filter_accept_reject_list(archive_handle_t *archive_handle)
|
||||
{
|
||||
const char *key = archive_handle->file_header->name;
|
||||
const llist_t *reject_entry = find_list_entry(archive_handle->reject, key);
|
||||
const llist_t *reject_entry = find_list_entry2(archive_handle->reject, key);
|
||||
const llist_t *accept_entry;
|
||||
|
||||
/* If the key is in a reject list fail */
|
||||
if (reject_entry) {
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
accept_entry = find_list_entry(archive_handle->accept, key);
|
||||
accept_entry = find_list_entry2(archive_handle->accept, key);
|
||||
|
||||
/* Fail if an accept list was specified and the key wasnt in there */
|
||||
if ((accept_entry == NULL) && archive_handle->accept) {
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Accepted */
|
||||
return(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -9,14 +9,46 @@
|
||||
#include <stdlib.h>
|
||||
#include "unarchive.h"
|
||||
|
||||
/* Find a string in a list */
|
||||
/* Find a string in a shell pattern list */
|
||||
const llist_t *find_list_entry(const llist_t *list, const char *filename)
|
||||
{
|
||||
while (list) {
|
||||
if (fnmatch(list->data, filename, 0) == 0) {
|
||||
return (list);
|
||||
return list;
|
||||
}
|
||||
list = list->link;
|
||||
}
|
||||
return(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Same, but compares only path components present in pattern
|
||||
* (extra trailing path components in filename are assumed to match)
|
||||
*/
|
||||
const llist_t *find_list_entry2(const llist_t *list, const char *filename)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
int pattern_slash_cnt;
|
||||
const char *c;
|
||||
char *d;
|
||||
|
||||
while (list) {
|
||||
c = list->data;
|
||||
pattern_slash_cnt = 0;
|
||||
while (*c)
|
||||
if (*c++ == '/') pattern_slash_cnt++;
|
||||
c = filename;
|
||||
d = buf;
|
||||
/* paranoia is better that buffer overflows */
|
||||
while (*c && d != buf + sizeof(buf)-1) {
|
||||
if (*c == '/' && --pattern_slash_cnt < 0)
|
||||
break;
|
||||
*d++ = *c++;
|
||||
}
|
||||
*d = '\0';
|
||||
if (fnmatch(list->data, buf, 0) == 0) {
|
||||
return list;
|
||||
}
|
||||
list = list->link;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -4,15 +4,12 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
char get_header_ar(archive_handle_t *archive_handle)
|
||||
{
|
||||
int err;
|
||||
file_header_t *typed = archive_handle->file_header;
|
||||
union {
|
||||
char raw[60];
|
||||
@@ -24,17 +21,17 @@ char get_header_ar(archive_handle_t *archive_handle)
|
||||
char mode[8];
|
||||
char size[10];
|
||||
char magic[2];
|
||||
} formated;
|
||||
} formatted;
|
||||
} ar;
|
||||
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
|
||||
static char *ar_long_names;
|
||||
static unsigned int ar_long_name_size;
|
||||
#endif
|
||||
|
||||
/* dont use bb_xread as we want to handle the error ourself */
|
||||
/* dont use xread as we want to handle the error ourself */
|
||||
if (read(archive_handle->src_fd, ar.raw, 60) != 60) {
|
||||
/* End Of File */
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* ar header starts on an even byte (2 byte aligned)
|
||||
@@ -49,20 +46,30 @@ char get_header_ar(archive_handle_t *archive_handle)
|
||||
archive_handle->offset += 60;
|
||||
|
||||
/* align the headers based on the header magic */
|
||||
if ((ar.formated.magic[0] != '`') || (ar.formated.magic[1] != '\n')) {
|
||||
bb_error_msg_and_die("Invalid ar header");
|
||||
}
|
||||
if (ar.formatted.magic[0] != '`' || ar.formatted.magic[1] != '\n')
|
||||
bb_error_msg_and_die("invalid ar header");
|
||||
|
||||
typed->mode = strtol(ar.formated.mode, NULL, 8);
|
||||
typed->mtime = atoi(ar.formated.date);
|
||||
typed->uid = atoi(ar.formated.uid);
|
||||
typed->gid = atoi(ar.formated.gid);
|
||||
typed->size = atoi(ar.formated.size);
|
||||
/* FIXME: more thorough routine would be in order here */
|
||||
/* (we have something like that in tar) */
|
||||
/* but for now we are lax. This code works because */
|
||||
/* on misformatted numbers bb_strtou returns all-ones */
|
||||
typed->mode = err = bb_strtou(ar.formatted.mode, NULL, 8);
|
||||
if (err == -1) bb_error_msg_and_die("invalid ar header");
|
||||
typed->mtime = err = bb_strtou(ar.formatted.date, NULL, 10);
|
||||
if (err == -1) bb_error_msg_and_die("invalid ar header");
|
||||
typed->uid = err = bb_strtou(ar.formatted.uid, NULL, 10);
|
||||
if (err == -1) bb_error_msg_and_die("invalid ar header");
|
||||
typed->gid = err = bb_strtou(ar.formatted.gid, NULL, 10);
|
||||
if (err == -1) bb_error_msg_and_die("invalid ar header");
|
||||
typed->size = err = bb_strtou(ar.formatted.size, NULL, 10);
|
||||
if (err == -1) bb_error_msg_and_die("invalid ar header");
|
||||
|
||||
/* long filenames have '/' as the first character */
|
||||
if (ar.formated.name[0] == '/') {
|
||||
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
|
||||
if (ar.formated.name[1] == '/') {
|
||||
if (ar.formatted.name[0] == '/') {
|
||||
#if ENABLE_FEATURE_AR_LONG_FILENAMES
|
||||
unsigned long_offset;
|
||||
|
||||
if (ar.formatted.name[1] == '/') {
|
||||
/* If the second char is a '/' then this entries data section
|
||||
* stores long filename for multiple entries, they are stored
|
||||
* in static variable long_names for use in future entries */
|
||||
@@ -72,27 +79,29 @@ char get_header_ar(archive_handle_t *archive_handle)
|
||||
archive_handle->offset += ar_long_name_size;
|
||||
/* This ar entries data section only contained filenames for other records
|
||||
* they are stored in the static ar_long_names for future reference */
|
||||
return (get_header_ar(archive_handle)); /* Return next header */
|
||||
} else if (ar.formated.name[1] == ' ') {
|
||||
return get_header_ar(archive_handle); /* Return next header */
|
||||
}
|
||||
|
||||
if (ar.formatted.name[1] == ' ') {
|
||||
/* This is the index of symbols in the file for compilers */
|
||||
data_skip(archive_handle);
|
||||
archive_handle->offset += typed->size;
|
||||
return (get_header_ar(archive_handle)); /* Return next header */
|
||||
} else {
|
||||
/* The number after the '/' indicates the offset in the ar data section
|
||||
(saved in variable long_name) that conatains the real filename */
|
||||
const unsigned int long_offset = atoi(&ar.formated.name[1]);
|
||||
if (long_offset >= ar_long_name_size) {
|
||||
bb_error_msg_and_die("Cant resolve long filename");
|
||||
}
|
||||
typed->name = bb_xstrdup(ar_long_names + long_offset);
|
||||
return get_header_ar(archive_handle); /* Return next header */
|
||||
}
|
||||
|
||||
/* The number after the '/' indicates the offset in the ar data section
|
||||
* (saved in variable long_name) that conatains the real filename */
|
||||
long_offset = atoi(&ar.formatted.name[1]);
|
||||
if (long_offset >= ar_long_name_size) {
|
||||
bb_error_msg_and_die("can't resolve long filename");
|
||||
}
|
||||
typed->name = xstrdup(ar_long_names + long_offset);
|
||||
#else
|
||||
bb_error_msg_and_die("long filenames not supported");
|
||||
#endif
|
||||
} else {
|
||||
/* short filenames */
|
||||
typed->name = bb_xstrndup(ar.formated.name, 16);
|
||||
typed->name = xstrndup(ar.formatted.name, 16);
|
||||
}
|
||||
|
||||
typed->name[strcspn(typed->name, " /")] = '\0';
|
||||
@@ -100,7 +109,8 @@ char get_header_ar(archive_handle_t *archive_handle)
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_header(typed);
|
||||
if (archive_handle->sub_archive) {
|
||||
while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS);
|
||||
while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS)
|
||||
/* repeat */;
|
||||
} else {
|
||||
archive_handle->action_data(archive_handle);
|
||||
}
|
||||
@@ -112,5 +122,5 @@ char get_header_ar(archive_handle_t *archive_handle)
|
||||
/* Set the file pointer to the correct spot, we may have been reading a compressed file */
|
||||
lseek(archive_handle->src_fd, archive_handle->offset, SEEK_SET);
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -4,16 +4,11 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/sysmacros.h> /* major() and minor() */
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
typedef struct hardlinks_s {
|
||||
file_header_t *entry;
|
||||
char *name;
|
||||
int inode;
|
||||
struct hardlinks_s *next;
|
||||
} hardlinks_t;
|
||||
@@ -22,60 +17,81 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
{
|
||||
static hardlinks_t *saved_hardlinks = NULL;
|
||||
static unsigned short pending_hardlinks = 0;
|
||||
static int inode;
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
char cpio_header[110];
|
||||
int namesize;
|
||||
char dummy[16];
|
||||
int major, minor, nlink, inode;
|
||||
int major, minor, nlink;
|
||||
|
||||
if (pending_hardlinks) { /* Deal with any pending hardlinks */
|
||||
hardlinks_t *tmp;
|
||||
hardlinks_t *oldtmp;
|
||||
hardlinks_t *tmp, *oldtmp;
|
||||
|
||||
tmp = saved_hardlinks;
|
||||
oldtmp = NULL;
|
||||
|
||||
file_header->link_name = file_header->name;
|
||||
file_header->size = 0;
|
||||
|
||||
while (tmp) {
|
||||
bb_error_msg_and_die("need to fix this\n");
|
||||
if (tmp->entry->link_name) { /* Found a hardlink ready to be extracted */
|
||||
file_header = tmp->entry;
|
||||
if (oldtmp) {
|
||||
oldtmp->next = tmp->next; /* Remove item from linked list */
|
||||
} else {
|
||||
saved_hardlinks = tmp->next;
|
||||
}
|
||||
free(tmp);
|
||||
if (tmp->inode != inode) {
|
||||
tmp = tmp->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
file_header->name = tmp->name;
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_data(archive_handle);
|
||||
archive_handle->action_header(archive_handle->file_header);
|
||||
}
|
||||
|
||||
pending_hardlinks--;
|
||||
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
free(oldtmp->name);
|
||||
free(oldtmp);
|
||||
if (oldtmp == saved_hardlinks)
|
||||
saved_hardlinks = tmp;
|
||||
}
|
||||
pending_hardlinks = 0; /* No more pending hardlinks, read next file entry */
|
||||
|
||||
file_header->name = file_header->link_name;
|
||||
|
||||
if (pending_hardlinks > 1) {
|
||||
bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?");
|
||||
}
|
||||
|
||||
/* No more pending hardlinks, read next file entry */
|
||||
pending_hardlinks = 0;
|
||||
}
|
||||
|
||||
/* There can be padding before archive header */
|
||||
data_align(archive_handle, 4);
|
||||
|
||||
if (archive_xread_all_eof(archive_handle, (unsigned char*)cpio_header, 110) == 0) {
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
archive_handle->offset += 110;
|
||||
|
||||
if ((strncmp(&cpio_header[0], "07070", 5) != 0) || ((cpio_header[5] != '1') && (cpio_header[5] != '2'))) {
|
||||
bb_error_msg_and_die("Unsupported cpio format, use newc or crc");
|
||||
if (strncmp(&cpio_header[0], "07070", 5) != 0
|
||||
|| (cpio_header[5] != '1' && cpio_header[5] != '2')
|
||||
) {
|
||||
bb_error_msg_and_die("unsupported cpio format, use newc or crc");
|
||||
}
|
||||
|
||||
{
|
||||
unsigned long tmpsize;
|
||||
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
|
||||
unsigned long tmpsize;
|
||||
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
|
||||
dummy, &inode, (unsigned int*)&file_header->mode,
|
||||
(unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
|
||||
&nlink, &file_header->mtime, &tmpsize,
|
||||
dummy, &major, &minor, &namesize, dummy);
|
||||
file_header->size = tmpsize;
|
||||
file_header->size = tmpsize;
|
||||
}
|
||||
|
||||
file_header->name = (char *) xzalloc(namesize + 1);
|
||||
free(file_header->name);
|
||||
file_header->name = xzalloc(namesize + 1);
|
||||
/* Read in filename */
|
||||
xread(archive_handle->src_fd, file_header->name, namesize);
|
||||
archive_handle->offset += namesize;
|
||||
@@ -84,26 +100,29 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
data_align(archive_handle, 4);
|
||||
|
||||
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
|
||||
printf("%d blocks\n", (int) (archive_handle->offset % 512 ? (archive_handle->offset / 512) + 1 : archive_handle->offset / 512)); /* Always round up */
|
||||
/* Always round up */
|
||||
printf("%d blocks\n", (int) (archive_handle->offset % 512 ?
|
||||
archive_handle->offset / 512 + 1 :
|
||||
archive_handle->offset / 512
|
||||
));
|
||||
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
|
||||
hardlinks_t *tmp = saved_hardlinks;
|
||||
hardlinks_t *oldtmp = NULL;
|
||||
while (tmp) {
|
||||
bb_error_msg("%s not created: cannot resolve hardlink", tmp->entry->name);
|
||||
bb_error_msg("%s not created: cannot resolve hardlink", tmp->name);
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
free (oldtmp->entry->name);
|
||||
free (oldtmp->entry);
|
||||
free (oldtmp);
|
||||
free(oldtmp->name);
|
||||
free(oldtmp);
|
||||
}
|
||||
saved_hardlinks = NULL;
|
||||
pending_hardlinks = 0;
|
||||
}
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (S_ISLNK(file_header->mode)) {
|
||||
file_header->link_name = (char *) xzalloc(file_header->size + 1);
|
||||
file_header->link_name = xzalloc(file_header->size + 1);
|
||||
xread(archive_handle->src_fd, file_header->link_name, file_header->size);
|
||||
archive_handle->offset += file_header->size;
|
||||
file_header->size = 0; /* Stop possible seeks in future */
|
||||
@@ -115,23 +134,14 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
hardlinks_t *new = xmalloc(sizeof(hardlinks_t));
|
||||
new->next = saved_hardlinks;
|
||||
new->inode = inode;
|
||||
new->entry = file_header;
|
||||
/* name current allocated, freed later */
|
||||
new->name = file_header->name;
|
||||
file_header->name = NULL;
|
||||
saved_hardlinks = new;
|
||||
return(EXIT_SUCCESS); // Skip this one
|
||||
} else { /* Found the file with data in */
|
||||
hardlinks_t *tmp = saved_hardlinks;
|
||||
pending_hardlinks = 1;
|
||||
while (tmp) {
|
||||
if (tmp->inode == inode) {
|
||||
tmp->entry->link_name = bb_xstrdup(file_header->name);
|
||||
nlink--;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
if (nlink > 1) {
|
||||
bb_error_msg("error resolving hardlink: did you create the archive with GNU cpio 2.0-2.2?");
|
||||
}
|
||||
return EXIT_SUCCESS; /* Skip this one */
|
||||
}
|
||||
/* Found the file with data in */
|
||||
pending_hardlinks = nlink;
|
||||
}
|
||||
file_header->device = makedev(major, minor);
|
||||
|
||||
@@ -146,5 +156,5 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
|
||||
free(file_header->link_name);
|
||||
|
||||
return (EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -11,138 +11,179 @@
|
||||
* http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/sysmacros.h> /* For makedev */
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
static char *longname = NULL;
|
||||
static char *linkname = NULL;
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
static char *longname;
|
||||
static char *linkname;
|
||||
#else
|
||||
enum {
|
||||
longname = 0,
|
||||
linkname = 0,
|
||||
};
|
||||
#endif
|
||||
|
||||
/* NB: _DESTROYS_ str[len] character! */
|
||||
static unsigned long long getOctal(char *str, int len)
|
||||
{
|
||||
unsigned long long v;
|
||||
/* Actually, tar header allows leading spaces also.
|
||||
* Oh well, we will be liberal and skip this...
|
||||
* The only downside probably is that we allow "-123" too :)
|
||||
if (*str < '0' || *str > '7')
|
||||
bb_error_msg_and_die("corrupted octal value in tar header");
|
||||
*/
|
||||
str[len] = '\0';
|
||||
v = strtoull(str, &str, 8);
|
||||
if (*str)
|
||||
bb_error_msg_and_die("corrupted octal value in tar header");
|
||||
return v;
|
||||
}
|
||||
#define GET_OCTAL(a) getOctal((a), sizeof(a))
|
||||
|
||||
void BUG_tar_header_size(void);
|
||||
char get_header_tar(archive_handle_t *archive_handle)
|
||||
{
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
union {
|
||||
/* ustar header, Posix 1003.1 */
|
||||
unsigned char raw[512];
|
||||
struct {
|
||||
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 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char version[2]; /* 263-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 */
|
||||
} formated;
|
||||
} tar;
|
||||
long sum = 0;
|
||||
long i;
|
||||
static int end = 0;
|
||||
static int end;
|
||||
|
||||
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 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char version[2]; /* 263-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;
|
||||
char *cp;
|
||||
int i, sum_u, sum_s, sum;
|
||||
int parse_names;
|
||||
|
||||
if (sizeof(tar) != 512)
|
||||
BUG_tar_header_size();
|
||||
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
again:
|
||||
#endif
|
||||
/* Align header */
|
||||
data_align(archive_handle, 512);
|
||||
|
||||
xread(archive_handle->src_fd, tar.raw, 512);
|
||||
again_after_align:
|
||||
|
||||
xread(archive_handle->src_fd, &tar, 512);
|
||||
archive_handle->offset += 512;
|
||||
|
||||
/* If there is no filename its an empty header */
|
||||
if (tar.formated.name[0] == 0) {
|
||||
if (tar.name[0] == 0) {
|
||||
if (end) {
|
||||
/* This is the second consecutive empty header! End of archive!
|
||||
* Read until the end to empty the pipe from gz or bz2
|
||||
*/
|
||||
while (full_read(archive_handle->src_fd, tar.raw, 512) == 512);
|
||||
return(EXIT_FAILURE);
|
||||
while (full_read(archive_handle->src_fd, &tar, 512) == 512)
|
||||
/* repeat */;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
end = 1;
|
||||
return(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
end = 0;
|
||||
|
||||
/* Check header has valid magic, "ustar" is for the proper tar
|
||||
* 0's are for the old tar format
|
||||
*/
|
||||
if (strncmp(tar.formated.magic, "ustar", 5) != 0) {
|
||||
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0)
|
||||
if (strncmp(tar.magic, "ustar", 5) != 0) {
|
||||
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
if (memcmp(tar.magic, "\0\0\0\0", 5) != 0)
|
||||
#endif
|
||||
bb_error_msg_and_die("Invalid tar magic");
|
||||
}
|
||||
/* Do checksum on headers */
|
||||
for (i = 0; i < 148 ; i++) {
|
||||
sum += tar.raw[i];
|
||||
}
|
||||
sum += ' ' * 8;
|
||||
for (i = 156; i < 512 ; i++) {
|
||||
sum += tar.raw[i];
|
||||
}
|
||||
if (sum != strtol(tar.formated.chksum, NULL, 8)) {
|
||||
bb_error_msg("Invalid tar header checksum");
|
||||
return(EXIT_FAILURE);
|
||||
bb_error_msg_and_die("invalid tar magic");
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
if (longname) {
|
||||
file_header->name = longname;
|
||||
longname = NULL;
|
||||
/* Do checksum on headers.
|
||||
* POSIX says that checksum is done on unsigned bytes, but
|
||||
* Sun and HP-UX gets it wrong... more details in
|
||||
* GNU tar source. */
|
||||
sum_s = sum_u = ' ' * sizeof(tar.chksum);
|
||||
for (i = 0; i < 148 ; i++) {
|
||||
sum_u += ((unsigned char*)&tar)[i];
|
||||
sum_s += ((signed char*)&tar)[i];
|
||||
}
|
||||
else if (linkname) {
|
||||
file_header->name = linkname;
|
||||
linkname = NULL;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
file_header->name = bb_xstrndup(tar.formated.name,100);
|
||||
|
||||
if (tar.formated.prefix[0]) {
|
||||
char *temp = file_header->name;
|
||||
file_header->name = concat_path_file(tar.formated.prefix, temp);
|
||||
free(temp);
|
||||
}
|
||||
for (i = 156; i < 512 ; i++) {
|
||||
sum_u += ((unsigned char*)&tar)[i];
|
||||
sum_s += ((signed char*)&tar)[i];
|
||||
}
|
||||
/* This field does not need special treatment (getOctal) */
|
||||
sum = xstrtoul(tar.chksum, 8);
|
||||
if (sum_u != sum && sum_s != sum) {
|
||||
bb_error_msg_and_die("invalid tar header checksum");
|
||||
}
|
||||
|
||||
file_header->uid = strtol(tar.formated.uid, NULL, 8);
|
||||
file_header->gid = strtol(tar.formated.gid, NULL, 8);
|
||||
file_header->size = strtol(tar.formated.size, NULL, 8);
|
||||
file_header->mtime = strtol(tar.formated.mtime, NULL, 8);
|
||||
file_header->link_name = (tar.formated.linkname[0] != '\0') ?
|
||||
bb_xstrdup(tar.formated.linkname) : NULL;
|
||||
file_header->device = makedev(strtol(tar.formated.devmajor, NULL, 8),
|
||||
strtol(tar.formated.devminor, NULL, 8));
|
||||
/* 0 is reserved for high perf file, treat as normal file */
|
||||
if (!tar.typeflag) tar.typeflag = '0';
|
||||
parse_names = (tar.typeflag >= '0' && tar.typeflag <= '7');
|
||||
|
||||
/* getOctal trashes subsequent field, therefore we call it
|
||||
* on fields in reverse order */
|
||||
if (tar.devmajor[0]) {
|
||||
unsigned minor = GET_OCTAL(tar.devminor);
|
||||
unsigned major = GET_OCTAL(tar.devmajor);
|
||||
file_header->device = makedev(major, minor);
|
||||
}
|
||||
file_header->link_name = NULL;
|
||||
if (!linkname && parse_names && tar.linkname[0]) {
|
||||
/* we trash magic[0] here, it's ok */
|
||||
tar.linkname[sizeof(tar.linkname)] = '\0';
|
||||
file_header->link_name = xstrdup(tar.linkname);
|
||||
/* FIXME: what if we have non-link object with link_name? */
|
||||
/* Will link_name be free()ed? */
|
||||
}
|
||||
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 */
|
||||
file_header->mode = 07777 & strtol(tar.formated.mode, NULL, 8);
|
||||
file_header->mode = 07777 & GET_OCTAL(tar.mode);
|
||||
|
||||
file_header->name = NULL;
|
||||
if (!longname && parse_names) {
|
||||
/* we trash mode[0] here, it's ok */
|
||||
tar.name[sizeof(tar.name)] = '\0';
|
||||
if (tar.prefix[0]) {
|
||||
/* and padding[0] */
|
||||
tar.prefix[sizeof(tar.prefix)] = '\0';
|
||||
file_header->name = concat_path_file(tar.prefix, tar.name);
|
||||
} else
|
||||
file_header->name = xstrdup(tar.name);
|
||||
}
|
||||
|
||||
/* Set bits 12-15 of the files mode */
|
||||
switch (tar.formated.typeflag) {
|
||||
/* (typeflag was not trashed because chksum does not use getOctal) */
|
||||
switch (tar.typeflag) {
|
||||
/* busybox identifies hard links as being regular files with 0 size and a link name */
|
||||
case '1':
|
||||
file_header->mode |= S_IFREG;
|
||||
break;
|
||||
case '7':
|
||||
/* Reserved for high performance files, treat as normal file */
|
||||
case 0:
|
||||
/* case 0: */
|
||||
case '0':
|
||||
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
if (last_char_is(file_header->name, '/')) {
|
||||
file_header->mode |= S_IFDIR;
|
||||
} else
|
||||
#endif
|
||||
file_header->mode |= S_IFREG;
|
||||
file_header->mode |= S_IFREG;
|
||||
break;
|
||||
case '2':
|
||||
file_header->mode |= S_IFLNK;
|
||||
@@ -159,54 +200,85 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
case '6':
|
||||
file_header->mode |= S_IFIFO;
|
||||
break;
|
||||
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
case 'L': {
|
||||
longname = xzalloc(file_header->size + 1);
|
||||
xread(archive_handle->src_fd, longname, file_header->size);
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
return(get_header_tar(archive_handle));
|
||||
}
|
||||
case 'K': {
|
||||
linkname = xzalloc(file_header->size + 1);
|
||||
xread(archive_handle->src_fd, linkname, file_header->size);
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
file_header->name = linkname;
|
||||
return(get_header_tar(archive_handle));
|
||||
}
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
case 'L':
|
||||
/* free: paranoia: tar with several consecutive longnames */
|
||||
free(longname);
|
||||
/* For paranoia reasons we allocate extra NUL char */
|
||||
longname = xzalloc(file_header->size + 1);
|
||||
/* We read ASCIZ string, including NUL */
|
||||
xread(archive_handle->src_fd, longname, file_header->size);
|
||||
archive_handle->offset += file_header->size;
|
||||
/* return get_header_tar(archive_handle); */
|
||||
/* gcc 4.1.1 didn't optimize it into jump */
|
||||
/* so we will do it ourself, this also saves stack */
|
||||
goto again;
|
||||
case 'K':
|
||||
free(linkname);
|
||||
linkname = xzalloc(file_header->size + 1);
|
||||
xread(archive_handle->src_fd, linkname, file_header->size);
|
||||
archive_handle->offset += file_header->size;
|
||||
/* return get_header_tar(archive_handle); */
|
||||
goto again;
|
||||
case 'D': /* GNU dump dir */
|
||||
case 'M': /* Continuation of multi volume archive*/
|
||||
case 'M': /* Continuation of multi volume archive */
|
||||
case 'N': /* Old GNU for names > 100 characters */
|
||||
case 'S': /* Sparse file */
|
||||
case 'V': /* Volume header */
|
||||
#endif
|
||||
case 'g': /* pax global header */
|
||||
case 'x': /* pax extended header */
|
||||
bb_error_msg("Ignoring extension type %c", tar.formated.typeflag);
|
||||
break;
|
||||
case 'x': { /* pax extended header */
|
||||
off_t sz;
|
||||
bb_error_msg("warning: skipping header '%c'", tar.typeflag);
|
||||
sz = (file_header->size + 511) & ~(off_t)511;
|
||||
archive_handle->offset += sz;
|
||||
sz >>= 9; /* sz /= 512 but w/o contortions for signed div */
|
||||
while (sz--)
|
||||
xread(archive_handle->src_fd, &tar, 512);
|
||||
/* return get_header_tar(archive_handle); */
|
||||
goto again_after_align;
|
||||
}
|
||||
default:
|
||||
bb_error_msg("Unknown typeflag: 0x%x", tar.formated.typeflag);
|
||||
bb_error_msg_and_die("unknown typeflag: 0x%x", tar.typeflag);
|
||||
}
|
||||
{ /* Strip trailing '/' in directories */
|
||||
/* Must be done after mode is set as '/' is used to check if its a directory */
|
||||
char *tmp = last_char_is(file_header->name, '/');
|
||||
if (tmp) {
|
||||
*tmp = '\0';
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
if (longname) {
|
||||
file_header->name = longname;
|
||||
longname = NULL;
|
||||
}
|
||||
if (linkname) {
|
||||
file_header->link_name = linkname;
|
||||
linkname = NULL;
|
||||
}
|
||||
#endif
|
||||
if (!strncmp(file_header->name, "/../"+1, 3)
|
||||
|| strstr(file_header->name, "/../")
|
||||
) {
|
||||
bb_error_msg_and_die("name with '..' encountered: '%s'",
|
||||
file_header->name);
|
||||
}
|
||||
|
||||
/* Strip trailing '/' in directories */
|
||||
/* Must be done after mode is set as '/' is used to check if it's a directory */
|
||||
cp = last_char_is(file_header->name, '/');
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
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->flags |= ARCHIVE_EXTRACT_QUIET;
|
||||
archive_handle->action_data(archive_handle);
|
||||
llist_add_to(&(archive_handle->passed), file_header->name);
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
free(file_header->name);
|
||||
}
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
free(file_header->link_name);
|
||||
/* Do not free(file_header->name)! */
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -3,25 +3,18 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
char get_header_tar_bz2(archive_handle_t *archive_handle)
|
||||
{
|
||||
/* Cant lseek over pipe's */
|
||||
archive_handle->seek = seek_by_char;
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompressStream);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS);
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
|
||||
|
||||
/* Can only do one file at a time */
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -12,20 +12,20 @@ char get_header_tar_gz(archive_handle_t *archive_handle)
|
||||
{
|
||||
unsigned char magic[2];
|
||||
|
||||
/* Cant lseek over pipe's */
|
||||
archive_handle->seek = seek_by_char;
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
xread(archive_handle->src_fd, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("Invalid gzip magic");
|
||||
bb_error_msg_and_die("invalid gzip magic");
|
||||
}
|
||||
|
||||
check_header_gzip(archive_handle->src_fd);
|
||||
check_header_gzip_or_die(archive_handle->src_fd);
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS);
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
|
||||
|
||||
/* Can only do one file at a time */
|
||||
return(EXIT_FAILURE);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
@@ -11,13 +11,12 @@
|
||||
char get_header_tar_lzma(archive_handle_t * archive_handle)
|
||||
{
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_char;
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unlzma);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS);
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
|
||||
|
||||
/* Can only do one file at a time */
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
@@ -13,11 +10,11 @@ void header_verbose_list(const file_header_t *file_header)
|
||||
{
|
||||
struct tm *mtime = localtime(&(file_header->mtime));
|
||||
|
||||
printf("%s %d/%d%10u %4u-%02u-%02u %02u:%02u:%02u %s",
|
||||
printf("%s %d/%d %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
|
||||
bb_mode_string(file_header->mode),
|
||||
file_header->uid,
|
||||
file_header->gid,
|
||||
(unsigned int) file_header->size,
|
||||
file_header->size,
|
||||
1900 + mtime->tm_year,
|
||||
1 + mtime->tm_mon,
|
||||
mtime->tm_mday,
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
@@ -12,13 +10,13 @@ archive_handle_t *init_handle(void)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
|
||||
/* Initialise default values */
|
||||
/* Initialize default values */
|
||||
archive_handle = xzalloc(sizeof(archive_handle_t));
|
||||
archive_handle->file_header = xmalloc(sizeof(file_header_t));
|
||||
archive_handle->file_header = xzalloc(sizeof(file_header_t));
|
||||
archive_handle->action_header = header_skip;
|
||||
archive_handle->action_data = data_skip;
|
||||
archive_handle->filter = filter_accept_all;
|
||||
archive_handle->seek = seek_by_jump;
|
||||
|
||||
return(archive_handle);
|
||||
return archive_handle;
|
||||
}
|
||||
@@ -11,32 +11,34 @@
|
||||
#include "unarchive.h"
|
||||
|
||||
/* transformer(), more than meets the eye */
|
||||
int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd))
|
||||
int open_transformer(int src_fd,
|
||||
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd))
|
||||
{
|
||||
int fd_pipe[2];
|
||||
int pid;
|
||||
|
||||
if (pipe(fd_pipe) != 0) {
|
||||
bb_perror_msg_and_die("Can't create pipe");
|
||||
bb_perror_msg_and_die("can't create pipe");
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
bb_perror_msg_and_die("Fork failed");
|
||||
bb_perror_msg_and_die("fork failed");
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
/* child process */
|
||||
close(fd_pipe[0]); /* We don't wan't to read from the parent */
|
||||
transformer(src_fd, fd_pipe[1]);
|
||||
close(fd_pipe[1]); /* Send EOF */
|
||||
close(fd_pipe[0]); /* We don't wan't to read from the parent */
|
||||
// FIXME: error check?
|
||||
transformer(src_fd, fd_pipe[1]);
|
||||
close(fd_pipe[1]); /* Send EOF */
|
||||
close(src_fd);
|
||||
exit(0);
|
||||
/* notreached */
|
||||
exit(0);
|
||||
/* notreached */
|
||||
}
|
||||
|
||||
/* parent process */
|
||||
close(fd_pipe[1]); /* Don't want to write to the child */
|
||||
|
||||
return(fd_pipe[0]);
|
||||
return fd_pipe[0];
|
||||
}
|
||||
@@ -16,9 +16,9 @@ void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amo
|
||||
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
|
||||
#ifdef CONFIG_FEATURE_UNARCHIVE_TAPE
|
||||
if (errno == ESPIPE) {
|
||||
seek_by_char(archive_handle, amount);
|
||||
seek_by_read(archive_handle, amount);
|
||||
} else
|
||||
#endif
|
||||
bb_perror_msg_and_die("Seek failure");
|
||||
bb_perror_msg_and_die("seek failure");
|
||||
}
|
||||
}
|
||||
@@ -8,16 +8,11 @@
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
|
||||
|
||||
/* If we are reading through a pipe(), or from stdin then we cant lseek,
|
||||
/* If we are reading through a pipe(), or from stdin then we can't lseek,
|
||||
* we must read and discard the data to skip over it.
|
||||
*
|
||||
* TODO: rename to seek_by_read
|
||||
*/
|
||||
void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size)
|
||||
void seek_by_read(const archive_handle_t *archive_handle, const unsigned int jump_size)
|
||||
{
|
||||
if (jump_size) {
|
||||
bb_copyfd_size(archive_handle->src_fd, -1, jump_size);
|
||||
}
|
||||
if (jump_size)
|
||||
bb_copyfd_exact_size(archive_handle->src_fd, -1, jump_size);
|
||||
}
|
||||
@@ -14,7 +14,7 @@ void unpack_ar_archive(archive_handle_t *ar_archive)
|
||||
|
||||
xread(ar_archive->src_fd, magic, 7);
|
||||
if (strncmp(magic, "!<arch>", 7) != 0) {
|
||||
bb_error_msg_and_die("Invalid ar magic");
|
||||
bb_error_msg_and_die("invalid ar magic");
|
||||
}
|
||||
ar_archive->offset += 7;
|
||||
|
||||
|
||||
+190
-160
@@ -7,57 +7,47 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <netinet/in.h> /* For ntohl & htonl function */
|
||||
#include <string.h> /* For strncmp */
|
||||
#include <sys/mman.h> /* For mmap */
|
||||
#include <time.h> /* For ctime */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
#define RPM_CHAR_TYPE 1
|
||||
#define RPM_INT8_TYPE 2
|
||||
#define RPM_INT16_TYPE 3
|
||||
#define RPM_INT32_TYPE 4
|
||||
/* #define RPM_INT64_TYPE 5 ---- These aren't supported (yet) */
|
||||
#define RPM_STRING_TYPE 6
|
||||
#define RPM_BIN_TYPE 7
|
||||
#define RPM_STRING_ARRAY_TYPE 8
|
||||
#define RPM_I18NSTRING_TYPE 9
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
#define RPM_CHAR_TYPE 1
|
||||
#define RPM_INT8_TYPE 2
|
||||
#define RPM_INT16_TYPE 3
|
||||
#define RPM_INT32_TYPE 4
|
||||
/* #define RPM_INT64_TYPE 5 ---- These aren't supported (yet) */
|
||||
#define RPM_STRING_TYPE 6
|
||||
#define RPM_BIN_TYPE 7
|
||||
#define RPM_STRING_ARRAY_TYPE 8
|
||||
#define RPM_I18NSTRING_TYPE 9
|
||||
|
||||
#define RPMTAG_NAME 1000
|
||||
#define RPMTAG_VERSION 1001
|
||||
#define RPMTAG_RELEASE 1002
|
||||
#define RPMTAG_SUMMARY 1004
|
||||
#define RPMTAG_DESCRIPTION 1005
|
||||
#define RPMTAG_BUILDTIME 1006
|
||||
#define RPMTAG_BUILDHOST 1007
|
||||
#define RPMTAG_SIZE 1009
|
||||
#define RPMTAG_VENDOR 1011
|
||||
#define RPMTAG_LICENSE 1014
|
||||
#define RPMTAG_PACKAGER 1015
|
||||
#define RPMTAG_GROUP 1016
|
||||
#define RPMTAG_URL 1020
|
||||
#define RPMTAG_PREIN 1023
|
||||
#define RPMTAG_POSTIN 1024
|
||||
#define RPMTAG_FILEFLAGS 1037
|
||||
#define RPMTAG_FILEUSERNAME 1039
|
||||
#define RPMTAG_FILEGROUPNAME 1040
|
||||
#define RPMTAG_SOURCERPM 1044
|
||||
#define RPMTAG_PREINPROG 1085
|
||||
#define RPMTAG_POSTINPROG 1086
|
||||
#define RPMTAG_PREFIXS 1098
|
||||
#define RPMTAG_DIRINDEXES 1116
|
||||
#define RPMTAG_BASENAMES 1117
|
||||
#define RPMTAG_DIRNAMES 1118
|
||||
#define RPMFILE_CONFIG (1 << 0)
|
||||
#define RPMFILE_DOC (1 << 1)
|
||||
#define TAG_NAME 1000
|
||||
#define TAG_VERSION 1001
|
||||
#define TAG_RELEASE 1002
|
||||
#define TAG_SUMMARY 1004
|
||||
#define TAG_DESCRIPTION 1005
|
||||
#define TAG_BUILDTIME 1006
|
||||
#define TAG_BUILDHOST 1007
|
||||
#define TAG_SIZE 1009
|
||||
#define TAG_VENDOR 1011
|
||||
#define TAG_LICENSE 1014
|
||||
#define TAG_PACKAGER 1015
|
||||
#define TAG_GROUP 1016
|
||||
#define TAG_URL 1020
|
||||
#define TAG_PREIN 1023
|
||||
#define TAG_POSTIN 1024
|
||||
#define TAG_FILEFLAGS 1037
|
||||
#define TAG_FILEUSERNAME 1039
|
||||
#define TAG_FILEGROUPNAME 1040
|
||||
#define TAG_SOURCERPM 1044
|
||||
#define TAG_PREINPROG 1085
|
||||
#define TAG_POSTINPROG 1086
|
||||
#define TAG_PREFIXS 1098
|
||||
#define TAG_DIRINDEXES 1116
|
||||
#define TAG_BASENAMES 1117
|
||||
#define TAG_DIRNAMES 1118
|
||||
#define RPMFILE_CONFIG (1 << 0)
|
||||
#define RPMFILE_DOC (1 << 1)
|
||||
|
||||
enum rpm_functions_e {
|
||||
rpm_query = 1,
|
||||
@@ -80,43 +70,43 @@ static void *map;
|
||||
static rpm_index **mytags;
|
||||
static int tagcount;
|
||||
|
||||
void extract_cpio_gz(int fd);
|
||||
rpm_index **rpm_gettags(int fd, int *num_tags);
|
||||
int bsearch_rpmtag(const void *key, const void *item);
|
||||
char *rpm_getstring(int tag, int itemindex);
|
||||
int rpm_getint(int tag, int itemindex);
|
||||
int rpm_getcount(int tag);
|
||||
void exec_script(int progtag, int datatag, char *prefix);
|
||||
void fileaction_dobackup(char *filename, int fileref);
|
||||
void fileaction_setowngrp(char *filename, int fileref);
|
||||
void fileaction_list(char *filename, int itemno);
|
||||
void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref));
|
||||
static void extract_cpio_gz(int fd);
|
||||
static rpm_index **rpm_gettags(int fd, int *num_tags);
|
||||
static int bsearch_rpmtag(const void *key, const void *item);
|
||||
static char *rpm_getstr(int tag, int itemindex);
|
||||
static int rpm_getint(int tag, int itemindex);
|
||||
static int rpm_getcount(int tag);
|
||||
static void fileaction_dobackup(char *filename, int fileref);
|
||||
static void fileaction_setowngrp(char *filename, int fileref);
|
||||
static void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref));
|
||||
|
||||
int rpm_main(int argc, char **argv);
|
||||
int rpm_main(int argc, char **argv)
|
||||
{
|
||||
int opt = 0, func = 0, rpm_fd, offset;
|
||||
const int pagesize = getpagesize();
|
||||
|
||||
while ((opt = getopt(argc, argv, "iqpldc")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i': // First arg: Install mode, with q: Information
|
||||
if (!func) func |= rpm_install;
|
||||
case 'i': /* First arg: Install mode, with q: Information */
|
||||
if (!func) func = rpm_install;
|
||||
else func |= rpm_query_info;
|
||||
break;
|
||||
case 'q': // First arg: Query mode
|
||||
if (!func) func |= rpm_query;
|
||||
else bb_show_usage();
|
||||
case 'q': /* First arg: Query mode */
|
||||
if (func) bb_show_usage();
|
||||
func = rpm_query;
|
||||
break;
|
||||
case 'p': // Query a package
|
||||
case 'p': /* Query a package */
|
||||
func |= rpm_query_package;
|
||||
break;
|
||||
case 'l': // List files in a package
|
||||
case 'l': /* List files in a package */
|
||||
func |= rpm_query_list;
|
||||
break;
|
||||
case 'd': // List doc files in a package (implies list)
|
||||
case 'd': /* List doc files in a package (implies list) */
|
||||
func |= rpm_query_list;
|
||||
func |= rpm_query_list_doc;
|
||||
break;
|
||||
case 'c': // List config files in a package (implies list)
|
||||
case 'c': /* List config files in a package (implies list) */
|
||||
func |= rpm_query_list;
|
||||
func |= rpm_query_list_config;
|
||||
break;
|
||||
@@ -124,68 +114,84 @@ int rpm_main(int argc, char **argv)
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
if (!argc) bb_show_usage();
|
||||
|
||||
while (*argv) {
|
||||
rpm_fd = xopen(*argv++, O_RDONLY);
|
||||
mytags = rpm_gettags(rpm_fd, &tagcount);
|
||||
if (!mytags)
|
||||
bb_error_msg_and_die("error reading rpm header");
|
||||
offset = xlseek(rpm_fd, 0, SEEK_CUR);
|
||||
/* Mimimum is one page */
|
||||
map = mmap(0, offset > pagesize ? (offset + offset % pagesize) : pagesize, PROT_READ, MAP_PRIVATE, rpm_fd, 0);
|
||||
|
||||
if (optind == argc) bb_show_usage();
|
||||
while (optind < argc) {
|
||||
rpm_fd = bb_xopen(argv[optind], O_RDONLY);
|
||||
mytags = rpm_gettags(rpm_fd, (int *) &tagcount);
|
||||
offset = lseek(rpm_fd, 0, SEEK_CUR);
|
||||
if (!mytags) { printf("Error reading rpm header\n"); exit(-1); }
|
||||
map = mmap(0, offset > getpagesize() ? (offset + offset % getpagesize()) : getpagesize(), PROT_READ, MAP_PRIVATE, rpm_fd, 0); // Mimimum is one page
|
||||
if (func & rpm_install) {
|
||||
loop_through_files(RPMTAG_BASENAMES, fileaction_dobackup); /* Backup any config files */
|
||||
extract_cpio_gz(rpm_fd); // Extact the archive
|
||||
loop_through_files(RPMTAG_BASENAMES, fileaction_setowngrp); /* Set the correct file uid/gid's */
|
||||
} else if (func & rpm_query && func & rpm_query_package) {
|
||||
if (!((func & rpm_query_info) || (func & rpm_query_list))) { // If just a straight query, just give package name
|
||||
printf("%s-%s-%s\n", rpm_getstring(RPMTAG_NAME, 0), rpm_getstring(RPMTAG_VERSION, 0), rpm_getstring(RPMTAG_RELEASE, 0));
|
||||
/* Backup any config files */
|
||||
loop_through_files(TAG_BASENAMES, fileaction_dobackup);
|
||||
/* Extact the archive */
|
||||
extract_cpio_gz(rpm_fd);
|
||||
/* Set the correct file uid/gid's */
|
||||
loop_through_files(TAG_BASENAMES, fileaction_setowngrp);
|
||||
}
|
||||
else if ((func & (rpm_query|rpm_query_package)) == (rpm_query|rpm_query_package)) {
|
||||
if (!(func & (rpm_query_info|rpm_query_list))) {
|
||||
/* If just a straight query, just give package name */
|
||||
printf("%s-%s-%s\n", rpm_getstr(TAG_NAME, 0), rpm_getstr(TAG_VERSION, 0), rpm_getstr(TAG_RELEASE, 0));
|
||||
}
|
||||
if (func & rpm_query_info) {
|
||||
/* Do the nice printout */
|
||||
time_t bdate_time;
|
||||
struct tm *bdate;
|
||||
char bdatestring[50];
|
||||
printf("Name : %-29sRelocations: %s\n", rpm_getstring(RPMTAG_NAME, 0), rpm_getstring(RPMTAG_PREFIXS, 0) ? rpm_getstring(RPMTAG_PREFIXS, 0) : "(not relocateable)");
|
||||
printf("Version : %-34sVendor: %s\n", rpm_getstring(RPMTAG_VERSION, 0), rpm_getstring(RPMTAG_VENDOR, 0) ? rpm_getstring(RPMTAG_VENDOR, 0) : "(none)");
|
||||
bdate_time = rpm_getint(RPMTAG_BUILDTIME, 0);
|
||||
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)");
|
||||
bdate_time = rpm_getint(TAG_BUILDTIME, 0);
|
||||
bdate = localtime((time_t *) &bdate_time);
|
||||
strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate);
|
||||
printf("Release : %-30sBuild Date: %s\n", rpm_getstring(RPMTAG_RELEASE, 0), bdatestring);
|
||||
printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstring(RPMTAG_BUILDHOST, 0));
|
||||
printf("Group : %-30sSource RPM: %s\n", rpm_getstring(RPMTAG_GROUP, 0), rpm_getstring(RPMTAG_SOURCERPM, 0));
|
||||
printf("Size : %-33dLicense: %s\n", rpm_getint(RPMTAG_SIZE, 0), rpm_getstring(RPMTAG_LICENSE, 0));
|
||||
printf("URL : %s\n", rpm_getstring(RPMTAG_URL, 0));
|
||||
printf("Summary : %s\n", rpm_getstring(RPMTAG_SUMMARY, 0));
|
||||
printf("Description :\n%s\n", rpm_getstring(RPMTAG_DESCRIPTION, 0));
|
||||
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("Size : %-33dLicense: %s\n", rpm_getint(TAG_SIZE, 0), rpm_getstr(TAG_LICENSE, 0));
|
||||
printf("URL : %s\n", rpm_getstr(TAG_URL, 0));
|
||||
printf("Summary : %s\n", rpm_getstr(TAG_SUMMARY, 0));
|
||||
printf("Description :\n%s\n", rpm_getstr(TAG_DESCRIPTION, 0));
|
||||
}
|
||||
if (func & rpm_query_list) {
|
||||
int count, it, flags;
|
||||
count = rpm_getcount(RPMTAG_BASENAMES);
|
||||
count = rpm_getcount(TAG_BASENAMES);
|
||||
for (it = 0; it < count; it++) {
|
||||
flags = rpm_getint(RPMTAG_FILEFLAGS, it);
|
||||
switch ((func & rpm_query_list_doc) + (func & rpm_query_list_config))
|
||||
{
|
||||
case rpm_query_list_doc: if (!(flags & RPMFILE_DOC)) continue; break;
|
||||
case rpm_query_list_config: if (!(flags & RPMFILE_CONFIG)) continue; break;
|
||||
case rpm_query_list_doc + rpm_query_list_config: if (!((flags & RPMFILE_CONFIG) || (flags & RPMFILE_DOC))) continue; break;
|
||||
flags = rpm_getint(TAG_FILEFLAGS, it);
|
||||
switch (func & (rpm_query_list_doc|rpm_query_list_config)) {
|
||||
case rpm_query_list_doc:
|
||||
if (!(flags & RPMFILE_DOC)) continue;
|
||||
break;
|
||||
case rpm_query_list_config:
|
||||
if (!(flags & RPMFILE_CONFIG)) continue;
|
||||
break;
|
||||
case rpm_query_list_doc|rpm_query_list_config:
|
||||
if (!(flags & (RPMFILE_CONFIG|RPMFILE_DOC))) continue;
|
||||
break;
|
||||
}
|
||||
printf("%s%s\n", rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES, it)), rpm_getstring(RPMTAG_BASENAMES, it));
|
||||
printf("%s%s\n",
|
||||
rpm_getstr(TAG_DIRNAMES, rpm_getint(TAG_DIRINDEXES, it)),
|
||||
rpm_getstr(TAG_BASENAMES, it));
|
||||
}
|
||||
}
|
||||
}
|
||||
optind++;
|
||||
free (mytags);
|
||||
free(mytags);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void extract_cpio_gz(int fd) {
|
||||
static void extract_cpio_gz(int fd) {
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned char magic[2];
|
||||
|
||||
/* Initialise */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->seek = seek_by_char;
|
||||
archive_handle->seek = seek_by_read;
|
||||
//archive_handle->action_header = header_list;
|
||||
archive_handle->action_data = data_extract_all;
|
||||
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
|
||||
@@ -195,24 +201,28 @@ void extract_cpio_gz(int fd) {
|
||||
|
||||
xread(archive_handle->src_fd, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("Invalid gzip magic");
|
||||
bb_error_msg_and_die("invalid gzip magic");
|
||||
}
|
||||
check_header_gzip(archive_handle->src_fd);
|
||||
bb_xchdir("/"); // Install RPM's to root
|
||||
check_header_gzip_or_die(archive_handle->src_fd);
|
||||
xchdir("/"); /* Install RPM's to root */
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
|
||||
/* loop */;
|
||||
}
|
||||
|
||||
|
||||
rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
static rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
{
|
||||
rpm_index **tags = xzalloc(200 * sizeof(struct rpmtag *)); /* We should never need mode than 200, and realloc later */
|
||||
/* We should never need mode than 200, and realloc later */
|
||||
rpm_index **tags = xzalloc(200 * sizeof(struct rpmtag *));
|
||||
int pass, tagindex = 0;
|
||||
lseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */
|
||||
|
||||
for (pass = 0; pass < 2; pass++) { /* 1st pass is the signature headers, 2nd is the main stuff */
|
||||
xlseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */
|
||||
|
||||
/* 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 */
|
||||
@@ -223,87 +233,112 @@ rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
rpm_index *tmpindex;
|
||||
int storepos;
|
||||
|
||||
read(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 */
|
||||
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 */
|
||||
header.size = ntohl(header.size);
|
||||
header.entries = ntohl(header.entries);
|
||||
storepos = lseek(fd,0,SEEK_CUR) + header.entries * 16;
|
||||
storepos = xlseek(fd,0,SEEK_CUR) + header.entries * 16;
|
||||
|
||||
while (header.entries--) {
|
||||
tmpindex = tags[tagindex++] = xmalloc(sizeof(rpm_index));
|
||||
read(fd, tmpindex, sizeof(rpm_index));
|
||||
tmpindex->tag = ntohl(tmpindex->tag); tmpindex->type = ntohl(tmpindex->type); tmpindex->count = ntohl(tmpindex->count);
|
||||
xread(fd, tmpindex, sizeof(rpm_index));
|
||||
tmpindex->tag = ntohl(tmpindex->tag);
|
||||
tmpindex->type = ntohl(tmpindex->type);
|
||||
tmpindex->count = ntohl(tmpindex->count);
|
||||
tmpindex->offset = storepos + ntohl(tmpindex->offset);
|
||||
if (pass==0) tmpindex->tag -= 743;
|
||||
if (pass==0)
|
||||
tmpindex->tag -= 743;
|
||||
}
|
||||
lseek(fd, header.size, SEEK_CUR); /* Seek past store */
|
||||
if (pass==0) lseek(fd, (8 - (lseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR); /* Skip padding to 8 byte boundary after reading signature headers */
|
||||
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);
|
||||
}
|
||||
tags = realloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */
|
||||
tags = xrealloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */
|
||||
*num_tags = tagindex;
|
||||
return tags; /* All done, leave the file at the start of the gzipped cpio archive */
|
||||
}
|
||||
|
||||
int bsearch_rpmtag(const void *key, const void *item)
|
||||
static int bsearch_rpmtag(const void *key, const void *item)
|
||||
{
|
||||
int *tag = (int *)key;
|
||||
rpm_index **tmp = (rpm_index **) item;
|
||||
return (*tag - tmp[0]->tag);
|
||||
}
|
||||
|
||||
int rpm_getcount(int tag)
|
||||
static int rpm_getcount(int tag)
|
||||
{
|
||||
rpm_index **found;
|
||||
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found) return 0;
|
||||
else return found[0]->count;
|
||||
if (!found)
|
||||
return 0;
|
||||
return found[0]->count;
|
||||
}
|
||||
|
||||
char *rpm_getstring(int tag, int itemindex)
|
||||
static char *rpm_getstr(int tag, int itemindex)
|
||||
{
|
||||
rpm_index **found;
|
||||
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found[0]->count) return NULL;
|
||||
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) {
|
||||
int n;
|
||||
char *tmpstr = (char *) (map + found[0]->offset);
|
||||
for (n=0; n < itemindex; n++) tmpstr = tmpstr + strlen(tmpstr) + 1;
|
||||
for (n=0; n < itemindex; n++)
|
||||
tmpstr = tmpstr + strlen(tmpstr) + 1;
|
||||
return tmpstr;
|
||||
} else return NULL;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int rpm_getint(int tag, int itemindex)
|
||||
static int rpm_getint(int tag, int itemindex)
|
||||
{
|
||||
rpm_index **found;
|
||||
int n, *tmpint;
|
||||
int *tmpint; /* NB: using int8_t* would be easier to code */
|
||||
|
||||
/* gcc throws warnings here when sizeof(void*)!=sizeof(int) ...
|
||||
* it's ok to ignore it because tag won't be used as a pointer */
|
||||
found = bsearch(&tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found[0]->count) return -1;
|
||||
if (!found || itemindex >= found[0]->count)
|
||||
return -1;
|
||||
|
||||
tmpint = (int *) (map + found[0]->offset);
|
||||
|
||||
if (found[0]->type == RPM_INT32_TYPE) {
|
||||
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 4);
|
||||
return ntohl(*tmpint);
|
||||
} else if (found[0]->type == RPM_INT16_TYPE) {
|
||||
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 2);
|
||||
return ntohs(*tmpint);
|
||||
} else if (found[0]->type == RPM_INT8_TYPE) {
|
||||
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 1);
|
||||
return ntohs(*tmpint);
|
||||
} else return -1;
|
||||
tmpint = (int *) ((char *) tmpint + itemindex*4);
|
||||
/*return ntohl(*tmpint);*/
|
||||
/* int can be != int32_t */
|
||||
return ntohl(*(int32_t*)tmpint);
|
||||
}
|
||||
if (found[0]->type == RPM_INT16_TYPE) {
|
||||
tmpint = (int *) ((char *) tmpint + itemindex*2);
|
||||
/* ??? read int, and THEN ntohs() it?? */
|
||||
/*return ntohs(*tmpint);*/
|
||||
return ntohs(*(int16_t*)tmpint);
|
||||
}
|
||||
if (found[0]->type == RPM_INT8_TYPE) {
|
||||
tmpint = (int *) ((char *) tmpint + itemindex);
|
||||
/* ??? why we don't read byte here??? */
|
||||
/*return ntohs(*tmpint);*/
|
||||
return *(int8_t*)tmpint;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void fileaction_dobackup(char *filename, int fileref)
|
||||
static void fileaction_dobackup(char *filename, int fileref)
|
||||
{
|
||||
struct stat oldfile;
|
||||
int stat_res;
|
||||
char *newname;
|
||||
if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */
|
||||
stat_res = lstat (filename, &oldfile);
|
||||
if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */
|
||||
newname = bb_xstrdup(filename);
|
||||
newname = strcat(newname, ".rpmorig");
|
||||
if (rpm_getint(TAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) {
|
||||
/* Only need to backup config files */
|
||||
stat_res = lstat(filename, &oldfile);
|
||||
if (stat_res == 0 && S_ISREG(oldfile.st_mode)) {
|
||||
/* File already exists - really should check MD5's etc to see if different */
|
||||
newname = xasprintf("%s.rpmorig", filename);
|
||||
copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS);
|
||||
remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE);
|
||||
free(newname);
|
||||
@@ -311,26 +346,21 @@ void fileaction_dobackup(char *filename, int fileref)
|
||||
}
|
||||
}
|
||||
|
||||
void fileaction_setowngrp(char *filename, int fileref)
|
||||
static void fileaction_setowngrp(char *filename, int fileref)
|
||||
{
|
||||
int uid, gid;
|
||||
uid = bb_xgetpwnam(rpm_getstring(RPMTAG_FILEUSERNAME, fileref));
|
||||
gid = bb_xgetgrnam(rpm_getstring(RPMTAG_FILEGROUPNAME, fileref));
|
||||
chown (filename, uid, gid);
|
||||
uid = xuname2uid(rpm_getstr(TAG_FILEUSERNAME, fileref));
|
||||
gid = xgroup2gid(rpm_getstr(TAG_FILEGROUPNAME, fileref));
|
||||
chown(filename, uid, gid);
|
||||
}
|
||||
|
||||
void fileaction_list(char *filename, int ATTRIBUTE_UNUSED fileref)
|
||||
{
|
||||
printf("%s\n", filename);
|
||||
}
|
||||
|
||||
void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref))
|
||||
static void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref))
|
||||
{
|
||||
int count = 0;
|
||||
while (rpm_getstring(filetag, count)) {
|
||||
char * filename = bb_xasprintf("%s%s",
|
||||
rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES,
|
||||
count)), rpm_getstring(RPMTAG_BASENAMES, count));
|
||||
while (rpm_getstr(filetag, count)) {
|
||||
char* filename = xasprintf("%s%s",
|
||||
rpm_getstr(TAG_DIRNAMES, rpm_getint(TAG_DIRINDEXES, count)),
|
||||
rpm_getstr(TAG_BASENAMES, count));
|
||||
fileaction(filename, count++);
|
||||
free(filename);
|
||||
}
|
||||
|
||||
+9
-13
@@ -6,11 +6,6 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <netinet/in.h> /* For ntohl & htonl function */
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
@@ -42,10 +37,10 @@ static void skip_header(int rpm_fd)
|
||||
|
||||
xread(rpm_fd, &header, sizeof(struct rpm_header));
|
||||
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) {
|
||||
bb_error_msg_and_die("Invalid RPM header magic"); /* Invalid magic */
|
||||
bb_error_msg_and_die("invalid RPM header magic"); /* Invalid magic */
|
||||
}
|
||||
if (header.version != 1) {
|
||||
bb_error_msg_and_die("Unsupported RPM header version"); /* This program only supports v1 headers */
|
||||
bb_error_msg_and_die("unsupported RPM header version"); /* This program only supports v1 headers */
|
||||
}
|
||||
header.entries = ntohl(header.entries);
|
||||
header.size = ntohl(header.size);
|
||||
@@ -54,6 +49,7 @@ static void skip_header(int rpm_fd)
|
||||
}
|
||||
|
||||
/* No getopt required */
|
||||
int rpm2cpio_main(int argc, char **argv);
|
||||
int rpm2cpio_main(int argc, char **argv)
|
||||
{
|
||||
struct rpm_lead lead;
|
||||
@@ -63,12 +59,12 @@ int rpm2cpio_main(int argc, char **argv)
|
||||
if (argc == 1) {
|
||||
rpm_fd = STDIN_FILENO;
|
||||
} else {
|
||||
rpm_fd = bb_xopen(argv[1], O_RDONLY);
|
||||
rpm_fd = xopen(argv[1], O_RDONLY);
|
||||
}
|
||||
|
||||
xread(rpm_fd, &lead, sizeof(struct rpm_lead));
|
||||
if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) {
|
||||
bb_error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */
|
||||
bb_error_msg_and_die("invalid RPM magic"); /* Just check the magic, the rest is irrelevant */
|
||||
}
|
||||
|
||||
/* Skip the signature header */
|
||||
@@ -80,12 +76,12 @@ int rpm2cpio_main(int argc, char **argv)
|
||||
|
||||
xread(rpm_fd, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("Invalid gzip magic");
|
||||
bb_error_msg_and_die("invalid gzip magic");
|
||||
}
|
||||
|
||||
check_header_gzip(rpm_fd);
|
||||
if (inflate_gunzip(rpm_fd, STDOUT_FILENO) != 0) {
|
||||
bb_error_msg("Error inflating");
|
||||
check_header_gzip_or_die(rpm_fd);
|
||||
if (inflate_gunzip(rpm_fd, STDOUT_FILENO) < 0) {
|
||||
bb_error_msg("error inflating");
|
||||
}
|
||||
|
||||
close(rpm_fd);
|
||||
|
||||
+462
-393
File diff suppressed because it is too large.
Load diff
@@ -1,100 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Uncompress applet for busybox (c) 2002 Glenn McGrath
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define GUNZIP_TO_STDOUT 1
|
||||
#define GUNZIP_FORCE 2
|
||||
|
||||
int uncompress_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
unsigned long flags;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "cf");
|
||||
|
||||
while (optind < argc) {
|
||||
const char *compressed_file = argv[optind++];
|
||||
const char *delete_path = NULL;
|
||||
char *uncompressed_file = NULL;
|
||||
int src_fd;
|
||||
int dst_fd;
|
||||
|
||||
if (strcmp(compressed_file, "-") == 0) {
|
||||
src_fd = STDIN_FILENO;
|
||||
flags |= GUNZIP_TO_STDOUT;
|
||||
} else {
|
||||
src_fd = bb_xopen(compressed_file, O_RDONLY);
|
||||
}
|
||||
|
||||
/* Check that the input is sane. */
|
||||
if (isatty(src_fd) && ((flags & GUNZIP_FORCE) == 0)) {
|
||||
bb_error_msg_and_die
|
||||
("compressed data not read from terminal. Use -f to force it.");
|
||||
}
|
||||
|
||||
/* Set output filename and number */
|
||||
if (flags & GUNZIP_TO_STDOUT) {
|
||||
dst_fd = STDOUT_FILENO;
|
||||
} else {
|
||||
struct stat stat_buf;
|
||||
char *extension;
|
||||
|
||||
uncompressed_file = bb_xstrdup(compressed_file);
|
||||
|
||||
extension = strrchr(uncompressed_file, '.');
|
||||
if (!extension || (strcmp(extension, ".Z") != 0)) {
|
||||
bb_error_msg_and_die("Invalid extension");
|
||||
}
|
||||
*extension = '\0';
|
||||
|
||||
/* Open output file */
|
||||
xstat(compressed_file, &stat_buf);
|
||||
dst_fd = bb_xopen3(uncompressed_file, O_WRONLY | O_CREAT,
|
||||
stat_buf.st_mode);
|
||||
|
||||
/* If unzip succeeds remove the old file */
|
||||
delete_path = compressed_file;
|
||||
}
|
||||
|
||||
/* do the decompression, and cleanup */
|
||||
if ((xread_char(src_fd) != 0x1f) || (xread_char(src_fd) != 0x9d)) {
|
||||
bb_error_msg_and_die("Invalid magic");
|
||||
}
|
||||
|
||||
status = uncompress(src_fd, dst_fd);
|
||||
|
||||
if ((status != EXIT_SUCCESS) && (uncompressed_file)) {
|
||||
/* Unzip failed, remove the uncomressed file instead of compressed file */
|
||||
delete_path = uncompressed_file;
|
||||
}
|
||||
|
||||
if (dst_fd != STDOUT_FILENO) {
|
||||
close(dst_fd);
|
||||
}
|
||||
if (src_fd != STDIN_FILENO) {
|
||||
close(src_fd);
|
||||
}
|
||||
|
||||
/* delete_path will be NULL if in test mode or from stdin */
|
||||
if (delete_path && (unlink(delete_path) == -1)) {
|
||||
bb_error_msg_and_die("Couldn't remove %s", delete_path);
|
||||
}
|
||||
|
||||
free(uncompressed_file);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Small lzma deflate implementation.
|
||||
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
|
||||
*
|
||||
* Based on bunzip.c from busybox
|
||||
*
|
||||
* Licensed under GPL v2, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define UNLZMA_OPT_STDOUT 1
|
||||
|
||||
int unlzma_main(int argc, char **argv)
|
||||
{
|
||||
char *filename;
|
||||
unsigned long opt;
|
||||
int status, src_fd, dst_fd;
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "c");
|
||||
|
||||
/* Set input filename and number */
|
||||
filename = argv[optind];
|
||||
if ((filename) && (filename[0] != '-') && (filename[1] != '\0')) {
|
||||
/* Open input file */
|
||||
src_fd = bb_xopen(filename, O_RDONLY);
|
||||
} else {
|
||||
src_fd = STDIN_FILENO;
|
||||
filename = 0;
|
||||
}
|
||||
|
||||
/* if called as lzmacat force the stdout flag */
|
||||
if ((opt & UNLZMA_OPT_STDOUT) || bb_applet_name[4] == 'c')
|
||||
filename = 0;
|
||||
|
||||
if (filename) {
|
||||
struct stat stat_buf;
|
||||
char *extension = filename + strlen(filename) - 5;
|
||||
|
||||
if (strcmp(extension, ".lzma") != 0) {
|
||||
bb_error_msg_and_die("Invalid extension");
|
||||
}
|
||||
xstat(filename, &stat_buf);
|
||||
*extension = 0;
|
||||
dst_fd = bb_xopen3(filename, O_WRONLY | O_CREAT, stat_buf.st_mode);
|
||||
} else
|
||||
dst_fd = STDOUT_FILENO;
|
||||
status = unlzma(src_fd, dst_fd);
|
||||
if (filename) {
|
||||
if (!status)
|
||||
filename[strlen(filename)] = '.';
|
||||
if (unlink(filename) < 0) {
|
||||
bb_error_msg_and_die("Couldn't remove %s", filename);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
+59
-74
@@ -24,22 +24,14 @@
|
||||
* - central directory
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define ZIP_FILEHEADER_MAGIC SWAP_LE32(0x04034b50)
|
||||
#define ZIP_CDS_MAGIC SWAP_LE32(0x02014b50)
|
||||
#define ZIP_CDS_END_MAGIC SWAP_LE32(0x06054b50)
|
||||
#define ZIP_DD_MAGIC SWAP_LE32(0x08074b50)
|
||||
|
||||
extern unsigned int gunzip_crc;
|
||||
extern unsigned int gunzip_bytes_out;
|
||||
|
||||
typedef union {
|
||||
unsigned char raw[26];
|
||||
struct {
|
||||
@@ -53,56 +45,55 @@ typedef union {
|
||||
unsigned int ucmpsize ATTRIBUTE_PACKED; /* 18-21 */
|
||||
unsigned short filename_len; /* 22-23 */
|
||||
unsigned short extra_len; /* 24-25 */
|
||||
} formated ATTRIBUTE_PACKED;
|
||||
} formatted ATTRIBUTE_PACKED;
|
||||
} zip_header_t;
|
||||
|
||||
static void unzip_skip(int fd, off_t skip)
|
||||
{
|
||||
if (lseek(fd, skip, SEEK_CUR) == (off_t)-1) {
|
||||
if ((errno != ESPIPE) || (bb_copyfd_size(fd, -1, skip) != skip)) {
|
||||
bb_error_msg_and_die("Seek failure");
|
||||
}
|
||||
if (errno != ESPIPE)
|
||||
bb_error_msg_and_die("seek failure");
|
||||
bb_copyfd_exact_size(fd, -1, skip);
|
||||
}
|
||||
}
|
||||
|
||||
static void unzip_create_leading_dirs(char *fn)
|
||||
{
|
||||
/* Create all leading directories */
|
||||
char *name = bb_xstrdup(fn);
|
||||
char *name = xstrdup(fn);
|
||||
if (bb_make_directory(dirname(name), 0777, FILEUTILS_RECUR)) {
|
||||
bb_error_msg_and_die("Exiting"); /* bb_make_directory is noisy */
|
||||
bb_error_msg_and_die("exiting"); /* bb_make_directory is noisy */
|
||||
}
|
||||
free(name);
|
||||
}
|
||||
|
||||
static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
|
||||
{
|
||||
if (zip_header->formated.method == 0) {
|
||||
if (zip_header->formatted.method == 0) {
|
||||
/* Method 0 - stored (not compressed) */
|
||||
int size = zip_header->formated.ucmpsize;
|
||||
if (size && (bb_copyfd_size(src_fd, dst_fd, size) != size)) {
|
||||
bb_error_msg_and_die("Cannot complete extraction");
|
||||
}
|
||||
|
||||
off_t size = zip_header->formatted.ucmpsize;
|
||||
if (size)
|
||||
bb_copyfd_exact_size(src_fd, dst_fd, size);
|
||||
} else {
|
||||
/* Method 8 - inflate */
|
||||
inflate_init(zip_header->formated.cmpsize);
|
||||
inflate_unzip(src_fd, dst_fd);
|
||||
inflate_cleanup();
|
||||
inflate_unzip_result res;
|
||||
/* err = */ inflate_unzip(&res, zip_header->formatted.cmpsize, src_fd, dst_fd);
|
||||
// we should check for -1 error return
|
||||
/* Validate decompression - crc */
|
||||
if (zip_header->formated.crc32 != (gunzip_crc ^ 0xffffffffL)) {
|
||||
bb_error_msg("Invalid compressed data--crc error");
|
||||
if (zip_header->formatted.crc32 != (res.crc ^ 0xffffffffL)) {
|
||||
bb_error_msg("invalid compressed data--%s error", "crc");
|
||||
return 1;
|
||||
}
|
||||
/* Validate decompression - size */
|
||||
if (zip_header->formated.ucmpsize != gunzip_bytes_out) {
|
||||
bb_error_msg("Invalid compressed data--length error");
|
||||
if (zip_header->formatted.ucmpsize != res.bytes_out) {
|
||||
bb_error_msg("invalid compressed data--%s error", "length");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unzip_main(int argc, char **argv);
|
||||
int unzip_main(int argc, char **argv)
|
||||
{
|
||||
zip_header_t zip_header;
|
||||
@@ -119,10 +110,10 @@ int unzip_main(int argc, char **argv)
|
||||
char key_buf[512];
|
||||
struct stat stat_buf;
|
||||
|
||||
while((opt = getopt(argc, argv, "-d:lnopqx")) != -1) {
|
||||
switch(opt_range) {
|
||||
while ((opt = getopt(argc, argv, "-d:lnopqx")) != -1) {
|
||||
switch (opt_range) {
|
||||
case 0: /* Options */
|
||||
switch(opt) {
|
||||
switch (opt) {
|
||||
case 'l': /* List */
|
||||
verbosity = v_list;
|
||||
break;
|
||||
@@ -143,7 +134,7 @@ int unzip_main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 1 : /* The zip file */
|
||||
src_fn = bb_xstrndup(optarg, strlen(optarg)+4);
|
||||
src_fn = xstrndup(optarg, strlen(optarg)+4);
|
||||
opt_range++;
|
||||
break;
|
||||
|
||||
@@ -192,27 +183,26 @@ int unzip_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Open input file */
|
||||
if (strcmp("-", src_fn) == 0) {
|
||||
if (LONE_DASH(src_fn)) {
|
||||
src_fd = STDIN_FILENO;
|
||||
/* Cannot use prompt mode since zip data is arriving on STDIN */
|
||||
overwrite = (overwrite == o_prompt) ? o_never : overwrite;
|
||||
|
||||
} else {
|
||||
static const char *const extn[] = {"", ".zip", ".ZIP"};
|
||||
int orig_src_fn_len = strlen(src_fn);
|
||||
for(i = 0; (i < 3) && (src_fd == -1); i++) {
|
||||
for (i = 0; (i < 3) && (src_fd == -1); i++) {
|
||||
strcpy(src_fn + orig_src_fn_len, extn[i]);
|
||||
src_fd = open(src_fn, O_RDONLY);
|
||||
}
|
||||
if (src_fd == -1) {
|
||||
src_fn[orig_src_fn_len] = 0;
|
||||
bb_error_msg_and_die("Cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
|
||||
bb_error_msg_and_die("cannot open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
|
||||
}
|
||||
}
|
||||
|
||||
/* Change dir if necessary */
|
||||
if (base_dir)
|
||||
bb_xchdir(base_dir);
|
||||
xchdir(base_dir);
|
||||
|
||||
if (verbosity != v_silent)
|
||||
printf("Archive: %s\n", src_fn);
|
||||
@@ -227,36 +217,36 @@ int unzip_main(int argc, char **argv)
|
||||
if (magic == ZIP_CDS_MAGIC) {
|
||||
break;
|
||||
} else if (magic != ZIP_FILEHEADER_MAGIC) {
|
||||
bb_error_msg_and_die("Invalid zip magic %08X", magic);
|
||||
bb_error_msg_and_die("invalid zip magic %08X", magic);
|
||||
}
|
||||
|
||||
/* Read the file header */
|
||||
xread(src_fd, zip_header.raw, 26);
|
||||
zip_header.formated.version = SWAP_LE32(zip_header.formated.version);
|
||||
zip_header.formated.flags = SWAP_LE32(zip_header.formated.flags);
|
||||
zip_header.formated.method = SWAP_LE32(zip_header.formated.method);
|
||||
zip_header.formated.modtime = SWAP_LE32(zip_header.formated.modtime);
|
||||
zip_header.formated.moddate = SWAP_LE32(zip_header.formated.moddate);
|
||||
zip_header.formated.crc32 = SWAP_LE32(zip_header.formated.crc32);
|
||||
zip_header.formated.cmpsize = SWAP_LE32(zip_header.formated.cmpsize);
|
||||
zip_header.formated.ucmpsize = SWAP_LE32(zip_header.formated.ucmpsize);
|
||||
zip_header.formated.filename_len = SWAP_LE32(zip_header.formated.filename_len);
|
||||
zip_header.formated.extra_len = SWAP_LE32(zip_header.formated.extra_len);
|
||||
if ((zip_header.formated.method != 0) && (zip_header.formated.method != 8)) {
|
||||
bb_error_msg_and_die("Unsupported compression method %d", zip_header.formated.method);
|
||||
zip_header.formatted.version = SWAP_LE32(zip_header.formatted.version);
|
||||
zip_header.formatted.flags = SWAP_LE32(zip_header.formatted.flags);
|
||||
zip_header.formatted.method = SWAP_LE32(zip_header.formatted.method);
|
||||
zip_header.formatted.modtime = SWAP_LE32(zip_header.formatted.modtime);
|
||||
zip_header.formatted.moddate = SWAP_LE32(zip_header.formatted.moddate);
|
||||
zip_header.formatted.crc32 = SWAP_LE32(zip_header.formatted.crc32);
|
||||
zip_header.formatted.cmpsize = SWAP_LE32(zip_header.formatted.cmpsize);
|
||||
zip_header.formatted.ucmpsize = SWAP_LE32(zip_header.formatted.ucmpsize);
|
||||
zip_header.formatted.filename_len = SWAP_LE32(zip_header.formatted.filename_len);
|
||||
zip_header.formatted.extra_len = SWAP_LE32(zip_header.formatted.extra_len);
|
||||
if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) {
|
||||
bb_error_msg_and_die("unsupported compression method %d", zip_header.formatted.method);
|
||||
}
|
||||
|
||||
/* Read filename */
|
||||
free(dst_fn);
|
||||
dst_fn = xzalloc(zip_header.formated.filename_len + 1);
|
||||
xread(src_fd, dst_fn, zip_header.formated.filename_len);
|
||||
dst_fn = xzalloc(zip_header.formatted.filename_len + 1);
|
||||
xread(src_fd, dst_fn, zip_header.formatted.filename_len);
|
||||
|
||||
/* Skip extra header bytes */
|
||||
unzip_skip(src_fd, zip_header.formated.extra_len);
|
||||
unzip_skip(src_fd, zip_header.formatted.extra_len);
|
||||
|
||||
if ((verbosity == v_list) && !list_header_done){
|
||||
printf(" Length Date Time Name\n"
|
||||
" -------- ---- ---- ----\n");
|
||||
puts(" Length Date Time Name\n"
|
||||
" -------- ---- ---- ----");
|
||||
list_header_done = 1;
|
||||
}
|
||||
|
||||
@@ -266,12 +256,12 @@ int unzip_main(int argc, char **argv)
|
||||
i = 'n';
|
||||
|
||||
} else { /* Extract entry */
|
||||
total_size += zip_header.formated.ucmpsize;
|
||||
total_size += zip_header.formatted.ucmpsize;
|
||||
|
||||
if (verbosity == v_list) { /* List entry */
|
||||
unsigned int dostime = zip_header.formated.modtime | (zip_header.formated.moddate << 16);
|
||||
unsigned int dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
|
||||
printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
|
||||
zip_header.formated.ucmpsize,
|
||||
zip_header.formatted.ucmpsize,
|
||||
(dostime & 0x01e00000) >> 21,
|
||||
(dostime & 0x001f0000) >> 16,
|
||||
(((dostime & 0xfe000000) >> 25) + 1980) % 100,
|
||||
@@ -280,21 +270,19 @@ int unzip_main(int argc, char **argv)
|
||||
dst_fn);
|
||||
total_entries++;
|
||||
i = 'n';
|
||||
|
||||
} else if (dst_fd == STDOUT_FILENO) { /* Extracting to STDOUT */
|
||||
i = -1;
|
||||
|
||||
} else if (last_char_is(dst_fn, '/')) { /* Extract directory */
|
||||
if (stat(dst_fn, &stat_buf) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
bb_perror_msg_and_die("Cannot stat '%s'",dst_fn);
|
||||
bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
|
||||
}
|
||||
if (verbosity == v_normal) {
|
||||
printf(" creating: %s\n", dst_fn);
|
||||
}
|
||||
unzip_create_leading_dirs(dst_fn);
|
||||
if (bb_make_directory(dst_fn, 0777, 0)) {
|
||||
bb_error_msg_and_die("Exiting");
|
||||
bb_error_msg_and_die("exiting");
|
||||
}
|
||||
} else {
|
||||
if (!S_ISDIR(stat_buf.st_mode)) {
|
||||
@@ -304,28 +292,25 @@ int unzip_main(int argc, char **argv)
|
||||
i = 'n';
|
||||
|
||||
} else { /* Extract file */
|
||||
_check_file:
|
||||
_check_file:
|
||||
if (stat(dst_fn, &stat_buf) == -1) { /* File does not exist */
|
||||
if (errno != ENOENT) {
|
||||
bb_perror_msg_and_die("Cannot stat '%s'",dst_fn);
|
||||
bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
|
||||
}
|
||||
i = 'y';
|
||||
|
||||
} else { /* File already exists */
|
||||
if (overwrite == o_never) {
|
||||
i = 'n';
|
||||
|
||||
} else if (S_ISREG(stat_buf.st_mode)) { /* File is regular file */
|
||||
if (overwrite == o_always) {
|
||||
i = 'y';
|
||||
} else {
|
||||
printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
|
||||
if (!fgets(key_buf, 512, stdin)) {
|
||||
bb_perror_msg_and_die("Cannot read input");
|
||||
bb_perror_msg_and_die("cannot read input");
|
||||
}
|
||||
i = key_buf[0];
|
||||
}
|
||||
|
||||
} else { /* File is not regular file */
|
||||
bb_error_msg_and_die("'%s' exists but is not regular file",dst_fn);
|
||||
}
|
||||
@@ -338,13 +323,13 @@ int unzip_main(int argc, char **argv)
|
||||
overwrite = o_always;
|
||||
case 'y': /* Open file and fall into unzip */
|
||||
unzip_create_leading_dirs(dst_fn);
|
||||
dst_fd = bb_xopen(dst_fn, O_WRONLY | O_CREAT);
|
||||
dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC);
|
||||
case -1: /* Unzip */
|
||||
if (verbosity == v_normal) {
|
||||
printf(" inflating: %s\n", dst_fn);
|
||||
}
|
||||
if (unzip_extract(&zip_header, src_fd, dst_fd)) {
|
||||
failed = 1;
|
||||
failed = 1;
|
||||
}
|
||||
if (dst_fd != STDOUT_FILENO) {
|
||||
/* closing STDOUT is potentially bad for future business */
|
||||
@@ -356,17 +341,17 @@ int unzip_main(int argc, char **argv)
|
||||
overwrite = o_never;
|
||||
case 'n':
|
||||
/* Skip entry data */
|
||||
unzip_skip(src_fd, zip_header.formated.cmpsize);
|
||||
unzip_skip(src_fd, zip_header.formatted.cmpsize);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
/* Prompt for new name */
|
||||
printf("new name: ");
|
||||
if (!fgets(key_buf, 512, stdin)) {
|
||||
bb_perror_msg_and_die("Cannot read input");
|
||||
bb_perror_msg_and_die("cannot read input");
|
||||
}
|
||||
free(dst_fn);
|
||||
dst_fn = bb_xstrdup(key_buf);
|
||||
dst_fn = xstrdup(key_buf);
|
||||
chomp(dst_fn);
|
||||
goto _check_file;
|
||||
|
||||
@@ -376,7 +361,7 @@ int unzip_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Data descriptor section */
|
||||
if (zip_header.formated.flags & 4) {
|
||||
if (zip_header.formatted.flags & 4) {
|
||||
/* skip over duplicate crc, compressed size and uncompressed size */
|
||||
unzip_skip(src_fd, 12);
|
||||
}
|
||||
|
||||
+30
-13
@@ -5,81 +5,98 @@
|
||||
|
||||
menu "Console Utilities"
|
||||
|
||||
config CONFIG_CHVT
|
||||
config CHVT
|
||||
bool "chvt"
|
||||
default n
|
||||
help
|
||||
This program is used to change to another terminal.
|
||||
Example: chvt 4 (change to terminal /dev/tty4)
|
||||
|
||||
config CONFIG_CLEAR
|
||||
config CLEAR
|
||||
bool "clear"
|
||||
default n
|
||||
help
|
||||
This program clears the terminal screen.
|
||||
|
||||
config CONFIG_DEALLOCVT
|
||||
config DEALLOCVT
|
||||
bool "deallocvt"
|
||||
default n
|
||||
help
|
||||
This program deallocates unused virtual consoles.
|
||||
|
||||
config CONFIG_DUMPKMAP
|
||||
config DUMPKMAP
|
||||
bool "dumpkmap"
|
||||
default n
|
||||
help
|
||||
This program dumps the kernel's keyboard translation table to
|
||||
stdout, in binary format. You can then use loadkmap to load it.
|
||||
|
||||
config CONFIG_LOADFONT
|
||||
config LOADFONT
|
||||
bool "loadfont"
|
||||
default n
|
||||
help
|
||||
This program loads a console font from standard input.
|
||||
|
||||
config CONFIG_LOADKMAP
|
||||
config LOADKMAP
|
||||
bool "loadkmap"
|
||||
default n
|
||||
help
|
||||
This program loads a keyboard translation table from
|
||||
standard input.
|
||||
|
||||
config CONFIG_OPENVT
|
||||
config OPENVT
|
||||
bool "openvt"
|
||||
default n
|
||||
help
|
||||
This program is used to start a command on an unused
|
||||
virtual terminal.
|
||||
|
||||
config CONFIG_RESET
|
||||
config RESET
|
||||
bool "reset"
|
||||
default n
|
||||
help
|
||||
This program is used to reset the terminal screen, if it
|
||||
gets messed up.
|
||||
|
||||
config CONFIG_SETCONSOLE
|
||||
config RESIZE
|
||||
bool "resize"
|
||||
default n
|
||||
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
|
||||
depends on RESIZE
|
||||
help
|
||||
Prints the newly set size (number of columns and rows) of
|
||||
the terminal.
|
||||
E.g.:
|
||||
COLUMNS=80;LINES=44;export COLUMNS LINES;
|
||||
|
||||
config SETCONSOLE
|
||||
bool "setconsole"
|
||||
default n
|
||||
help
|
||||
This program redirects the system console to another device,
|
||||
like the current tty while logged in via telnet.
|
||||
|
||||
config CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
config FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
depends on CONFIG_SET_CONSOLE && CONFIG_GETOPT_LONG
|
||||
depends on SET_CONSOLE && GETOPT_LONG
|
||||
help
|
||||
Support long options for the setconsole applet.
|
||||
|
||||
config CONFIG_SETKEYCODES
|
||||
config SETKEYCODES
|
||||
bool "setkeycodes"
|
||||
default n
|
||||
help
|
||||
This program loads entries into the kernel's scancode-to-keycode
|
||||
map, allowing unusual keyboards to generate usable keycodes.
|
||||
|
||||
config CONFIG_SETLOGCONS
|
||||
config SETLOGCONS
|
||||
bool "setlogcons"
|
||||
default n
|
||||
help
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
lib-y:=
|
||||
lib-$(CONFIG_CHVT) += chvt.o
|
||||
lib-$(CONFIG_CLEAR) += clear.o
|
||||
lib-$(CONFIG_DEALLOCVT) += deallocvt.o
|
||||
lib-$(CONFIG_DUMPKMAP) += dumpkmap.o
|
||||
lib-$(CONFIG_SETCONSOLE) += setconsole.o
|
||||
lib-$(CONFIG_LOADFONT) += loadfont.o
|
||||
lib-$(CONFIG_LOADKMAP) += loadkmap.o
|
||||
lib-$(CONFIG_OPENVT) += openvt.o
|
||||
lib-$(CONFIG_RESET) += reset.o
|
||||
lib-$(CONFIG_RESIZE) += resize.o
|
||||
lib-$(CONFIG_SETKEYCODES) += setkeycodes.o
|
||||
lib-$(CONFIG_SETLOGCONS) += setlogcons.o
|
||||
@@ -1,23 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
ifndef top_srcdir
|
||||
top_srcdir=..
|
||||
endif
|
||||
ifndef top_builddir
|
||||
top_builddir=..
|
||||
endif
|
||||
srcdir=$(top_srcdir)/console/tools
|
||||
CONSOLETOOLS_DIR:=./
|
||||
include $(top_srcdir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
CONSOLETOOLS_AR:=console-tools.a
|
||||
ifndef $(CONSOLETOOLS_DIR)
|
||||
CONSOLETOOLS_DIR:=$(top_builddir)/console-tools/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/console-tools
|
||||
|
||||
CONSOLETOOLS-y:=
|
||||
CONSOLETOOLS-$(CONFIG_CHVT) += chvt.o
|
||||
CONSOLETOOLS-$(CONFIG_CLEAR) += clear.o
|
||||
CONSOLETOOLS-$(CONFIG_DEALLOCVT) += deallocvt.o
|
||||
CONSOLETOOLS-$(CONFIG_DUMPKMAP) += dumpkmap.o
|
||||
CONSOLETOOLS-$(CONFIG_SETCONSOLE) += setconsole.o
|
||||
CONSOLETOOLS-$(CONFIG_LOADFONT) += loadfont.o
|
||||
CONSOLETOOLS-$(CONFIG_LOADKMAP) += loadkmap.o
|
||||
CONSOLETOOLS-$(CONFIG_OPENVT) += openvt.o
|
||||
CONSOLETOOLS-$(CONFIG_RESET) += reset.o
|
||||
CONSOLETOOLS-$(CONFIG_SETKEYCODES) += setkeycodes.o
|
||||
CONSOLETOOLS-$(CONFIG_SETLOGCONS) += setlogcons.o
|
||||
|
||||
ifneq ($(strip $(CONSOLETOOLS-y)),)
|
||||
libraries-y+=$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR)
|
||||
endif
|
||||
CONSOLETOOLS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(CONSOLETOOLS-y))
|
||||
CONSOLETOOLS_SRC-a:=$(wildcard $(srcdir)/*.c)
|
||||
APPLET_SRC-y+=$(CONSOLETOOLS_SRC-y)
|
||||
APPLET_SRC-a+=$(CONSOLETOOLS_SRC-a)
|
||||
|
||||
$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR): $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS-y))
|
||||
$(do_ar)
|
||||
|
||||
$(CONSOLETOOLS_DIR)%.o: $(srcdir)/%.c
|
||||
$(compile.c)
|
||||
@@ -7,11 +7,6 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
@@ -20,6 +15,7 @@ enum {
|
||||
VT_WAITACTIVE = 0x5607 /* wait for vt active */
|
||||
};
|
||||
|
||||
int chvt_main(int argc, char **argv);
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
@@ -29,7 +25,7 @@ int chvt_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
fd = get_console_fd();
|
||||
num = bb_xgetlarg(argv[1], 10, 0, INT_MAX);
|
||||
num = xatoul_range(argv[1], 1, 63);
|
||||
if ((-1 == ioctl(fd, VT_ACTIVATE, num))
|
||||
|| (-1 == ioctl(fd, VT_WAITACTIVE, num))) {
|
||||
bb_perror_msg_and_die("ioctl");
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
int clear_main(int argc, char **argv);
|
||||
int clear_main(int argc, char **argv)
|
||||
{
|
||||
return printf("\033[H\033[J") != 6;
|
||||
|
||||
@@ -10,31 +10,25 @@
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
|
||||
|
||||
int deallocvt_main(int argc, char *argv[]);
|
||||
int deallocvt_main(int argc, char *argv[])
|
||||
{
|
||||
/* num = 0 deallocate all unused consoles */
|
||||
int num = 0;
|
||||
|
||||
switch (argc) {
|
||||
case 2:
|
||||
if ((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0) {
|
||||
bb_error_msg_and_die("0: illegal VT number");
|
||||
}
|
||||
case 2:
|
||||
num = xatoul_range(argv[1], 1, 63);
|
||||
/* Fallthrough */
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
|
||||
|
||||
@@ -8,13 +8,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
@@ -29,18 +22,19 @@ struct kbentry {
|
||||
#define NR_KEYS 128
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int dumpkmap_main(int argc, char **argv);
|
||||
int dumpkmap_main(int argc, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
|
||||
char flags[MAX_NR_KEYMAPS];
|
||||
|
||||
if (argc >= 2 && *argv[1] == '-')
|
||||
if (argc >= 2 && argv[1][0] == '-')
|
||||
bb_show_usage();
|
||||
|
||||
fd = bb_xopen(CURRENT_VC, O_RDWR);
|
||||
fd = xopen(CURRENT_VC, O_RDWR);
|
||||
|
||||
write(1, magic, 7);
|
||||
write(1, "bkeymap", 7);
|
||||
|
||||
/* Here we want to set everything to 0 except for indexes:
|
||||
* [0-2] [4-6] [8-10] [12] */
|
||||
|
||||
+16
-25
@@ -7,20 +7,10 @@
|
||||
* Loads the console font, and possibly the corresponding screen map(s).
|
||||
* (Adapted for busybox by Matej Vela.)
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kd.h>
|
||||
#include <endian.h>
|
||||
#include "busybox.h"
|
||||
#include <sys/kd.h>
|
||||
|
||||
enum{
|
||||
enum {
|
||||
PSF_MAGIC1 = 0x36,
|
||||
PSF_MAGIC2 = 0x04,
|
||||
|
||||
@@ -40,6 +30,7 @@ struct psf_header {
|
||||
|
||||
static void loadnewfont(int fd);
|
||||
|
||||
int loadfont_main(int argc, char **argv);
|
||||
int loadfont_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
@@ -47,7 +38,7 @@ int loadfont_main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
bb_show_usage();
|
||||
|
||||
fd = bb_xopen(CURRENT_VC, O_RDWR);
|
||||
fd = xopen(CURRENT_VC, O_RDWR);
|
||||
loadnewfont(fd);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
@@ -61,7 +52,7 @@ static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (unit < 1 || unit > 32)
|
||||
bb_error_msg_and_die("Bad character size %d", unit);
|
||||
bb_error_msg_and_die("bad character size %d", unit);
|
||||
|
||||
for (i = 0; i < fontsize; i++)
|
||||
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
|
||||
@@ -91,14 +82,14 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
struct unipair *up;
|
||||
int ct = 0, maxct;
|
||||
int glyph;
|
||||
u_short unicode;
|
||||
uint16_t unicode;
|
||||
|
||||
maxct = tailsz; /* more than enough */
|
||||
up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
|
||||
up = xmalloc(maxct * sizeof(struct unipair));
|
||||
|
||||
for (glyph = 0; glyph < fontsize; glyph++) {
|
||||
while (tailsz >= 2) {
|
||||
unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
|
||||
unicode = (((uint16_t) inbuf[1]) << 8) + inbuf[0];
|
||||
tailsz -= 2;
|
||||
inbuf += 2;
|
||||
if (unicode == PSF_SEPARATOR)
|
||||
@@ -118,8 +109,8 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
|
||||
#ifdef ENOIOCTLCMD
|
||||
if (errno == ENOIOCTLCMD) {
|
||||
bb_error_msg("It seems this kernel is older than 1.1.92");
|
||||
bb_error_msg_and_die("No Unicode mapping table loaded.");
|
||||
bb_error_msg("it seems this kernel is older than 1.1.92");
|
||||
bb_error_msg_and_die("no Unicode mapping table loaded");
|
||||
} else
|
||||
#endif
|
||||
bb_perror_msg_and_die("PIO_UNIMAPCLR");
|
||||
@@ -144,13 +135,13 @@ static void loadnewfont(int fd)
|
||||
*/
|
||||
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
|
||||
if (ferror(stdin))
|
||||
bb_perror_msg_and_die("Error reading input font");
|
||||
bb_perror_msg_and_die("error reading input font");
|
||||
/* use malloc/realloc in case of giant files;
|
||||
maybe these do not occur: 16kB for the font,
|
||||
and 16kB for the map leaves 32 unicode values
|
||||
for each font position */
|
||||
if (!feof(stdin))
|
||||
bb_perror_msg_and_die("Font too large");
|
||||
bb_perror_msg_and_die("font too large");
|
||||
|
||||
/* test for psf first */
|
||||
{
|
||||
@@ -168,11 +159,11 @@ static void loadnewfont(int fd)
|
||||
goto no_psf;
|
||||
|
||||
if (psfhdr.mode > PSF_MAXMODE)
|
||||
bb_error_msg_and_die("Unsupported psf file mode");
|
||||
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");
|
||||
bb_error_msg_and_die("only fontsize 256 supported");
|
||||
#endif
|
||||
hastable = (psfhdr.mode & PSF_MODEHASTAB);
|
||||
unit = psfhdr.charsize;
|
||||
@@ -180,7 +171,7 @@ static void loadnewfont(int fd)
|
||||
|
||||
head = head0 + fontsize * unit;
|
||||
if (head > inputlth || (!hastable && head != inputlth))
|
||||
bb_error_msg_and_die("Input file: bad length");
|
||||
bb_error_msg_and_die("input file: bad length");
|
||||
do_loadfont(fd, inbuf + head0, unit, fontsize);
|
||||
if (hastable)
|
||||
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
|
||||
@@ -195,7 +186,7 @@ static void loadnewfont(int fd)
|
||||
} else {
|
||||
/* bare font */
|
||||
if (inputlth & 0377)
|
||||
bb_error_msg_and_die("Bad input file size");
|
||||
bb_error_msg_and_die("bad input file size");
|
||||
offset = 0;
|
||||
unit = inputlth / 256;
|
||||
}
|
||||
|
||||
@@ -8,13 +8,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define BINARY_KEYMAP_MAGIC "bkeymap"
|
||||
@@ -32,28 +25,29 @@ struct kbentry {
|
||||
#define NR_KEYS 128
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int loadkmap_main(int argc, char **argv);
|
||||
int loadkmap_main(int argc, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
u_short ibuff[NR_KEYS];
|
||||
uint16_t ibuff[NR_KEYS];
|
||||
char flags[MAX_NR_KEYMAPS];
|
||||
char buff[7];
|
||||
|
||||
if (argc != 1)
|
||||
bb_show_usage();
|
||||
|
||||
fd = bb_xopen(CURRENT_VC, O_RDWR);
|
||||
fd = xopen(CURRENT_VC, O_RDWR);
|
||||
|
||||
xread(0, buff, 7);
|
||||
if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||
bb_error_msg_and_die("This is not a valid binary keymap.");
|
||||
bb_error_msg_and_die("this is not a valid binary keymap");
|
||||
|
||||
xread(0, flags, MAX_NR_KEYMAPS);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
xread(0, ibuff, NR_KEYS * sizeof(u_short));
|
||||
xread(0, ibuff, NR_KEYS * sizeof(uint16_t));
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
|
||||
+11
-21
@@ -10,43 +10,33 @@
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
int openvt_main(int argc, char **argv);
|
||||
int openvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
char vtname[sizeof(VC_FORMAT) + 2];
|
||||
|
||||
|
||||
if (argc < 3) {
|
||||
bb_show_usage();
|
||||
}
|
||||
/* check for Illegal vt number: < 1 or > 12 */
|
||||
sprintf(vtname, VC_FORMAT, (int)bb_xgetlarg(argv[1], 10, 1, 12));
|
||||
/* check for illegal vt number: < 1 or > 63 */
|
||||
sprintf(vtname, VC_FORMAT, (int)xatoul_range(argv[1], 1, 63));
|
||||
|
||||
if (fork() == 0) {
|
||||
/* leave current vt */
|
||||
if (setsid() < 0) {
|
||||
bb_perror_msg_and_die("setsid");
|
||||
}
|
||||
close(0); /* so that new vt becomes stdin */
|
||||
|
||||
/* child */
|
||||
/* leave current vt (controlling tty) */
|
||||
setsid();
|
||||
/* and grab new one */
|
||||
fd = bb_xopen(vtname, O_RDWR);
|
||||
|
||||
/* Reassign stdout and sterr */
|
||||
fd = xopen(vtname, O_RDWR);
|
||||
/* Reassign stdin, stdout and sterr */
|
||||
dup2(fd, STDIN_FILENO);
|
||||
dup2(fd, STDOUT_FILENO);
|
||||
dup2(fd, STDERR_FILENO);
|
||||
while (fd > 2) close(fd--);
|
||||
|
||||
execvp(argv[2], &argv[2]);
|
||||
BB_EXECVP(argv[2], &argv[2]);
|
||||
_exit(1);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int reset_main(int argc, char **argv);
|
||||
int reset_main(int argc, char **argv)
|
||||
{
|
||||
if (isatty(1)) {
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* resize - set terminal width and height.
|
||||
*
|
||||
* Copyright 2006 Bernhard Fischer
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
/* no options, no getopt */
|
||||
#include "busybox.h"
|
||||
|
||||
#define ESC "\033"
|
||||
|
||||
struct termios old;
|
||||
|
||||
static void
|
||||
onintr(int sig ATTRIBUTE_UNUSED)
|
||||
{
|
||||
tcsetattr(STDERR_FILENO, TCSANOW, &old);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
int resize_main(int argc, char **argv);
|
||||
int resize_main(int argc, char **argv)
|
||||
{
|
||||
struct termios new;
|
||||
struct winsize w = { 0,0,0,0 };
|
||||
int ret;
|
||||
|
||||
/* We use _stderr_ in order to make resize usable
|
||||
* in shell backticks (those redirect stdout away from tty).
|
||||
* NB: other versions of resize open "/dev/tty"
|
||||
* and operate on it - should we do the same?
|
||||
*/
|
||||
|
||||
tcgetattr(STDERR_FILENO, &old); /* fiddle echo */
|
||||
new = old;
|
||||
new.c_cflag |= (CLOCAL | CREAD);
|
||||
new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
||||
signal(SIGINT, onintr);
|
||||
signal(SIGQUIT, onintr);
|
||||
signal(SIGTERM, onintr);
|
||||
signal(SIGALRM, onintr);
|
||||
tcsetattr(STDERR_FILENO, TCSANOW, &new);
|
||||
|
||||
/* save_cursor_pos 7
|
||||
* scroll_whole_screen [r
|
||||
* put_cursor_waaaay_off [$x;$yH
|
||||
* get_cursor_pos [6n
|
||||
* restore_cursor_pos 8
|
||||
*/
|
||||
fprintf(stderr, ESC"7" ESC"[r" ESC"[999;999H" ESC"[6n");
|
||||
alarm(3); /* Just in case terminal won't answer */
|
||||
scanf(ESC"[%hu;%huR", &w.ws_row, &w.ws_col);
|
||||
fprintf(stderr, ESC"8");
|
||||
|
||||
/* BTW, other versions of resize recalculate w.ws_xpixel, ws.ws_ypixel
|
||||
* by calculating character cell HxW from old values
|
||||
* (gotten via TIOCGWINSZ) and recomputing *pixel values */
|
||||
ret = ioctl(STDERR_FILENO, TIOCSWINSZ, &w);
|
||||
|
||||
tcsetattr(STDERR_FILENO, TCSANOW, &old);
|
||||
|
||||
if (ENABLE_FEATURE_RESIZE_PRINT)
|
||||
printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n",
|
||||
w.ws_col, w.ws_row);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -7,13 +7,6 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h> /* struct option */
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
@@ -25,15 +18,16 @@ static const struct option setconsole_long_options[] = {
|
||||
|
||||
#define OPT_SETCONS_RESET 1
|
||||
|
||||
int setconsole_main(int argc, char **argv);
|
||||
int setconsole_main(int argc, char **argv)
|
||||
{
|
||||
unsigned long flags;
|
||||
const char *device = CURRENT_TTY;
|
||||
|
||||
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
bb_applet_long_options = setconsole_long_options;
|
||||
applet_long_options = setconsole_long_options;
|
||||
#endif
|
||||
flags = bb_getopt_ulflags(argc, argv, "r");
|
||||
flags = getopt32(argc, argv, "r");
|
||||
|
||||
if (argc - optind > 1)
|
||||
bb_show_usage();
|
||||
@@ -44,10 +38,10 @@ int setconsole_main(int argc, char **argv)
|
||||
device = argv[optind];
|
||||
} else {
|
||||
if (flags & OPT_SETCONS_RESET)
|
||||
device = CONSOLE_DEV;
|
||||
device = DEV_CONSOLE;
|
||||
}
|
||||
|
||||
if (-1 == ioctl(bb_xopen(device, O_RDONLY), TIOCCONS)) {
|
||||
if (-1 == ioctl(xopen(device, O_RDONLY), TIOCCONS)) {
|
||||
bb_perror_msg_and_die("TIOCCONS");
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
+18
-29
@@ -9,9 +9,6 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
@@ -24,38 +21,30 @@ enum {
|
||||
KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
|
||||
};
|
||||
|
||||
extern int
|
||||
setkeycodes_main(int argc, char** argv)
|
||||
int setkeycodes_main(int argc, char** argv);
|
||||
int setkeycodes_main(int argc, char** argv)
|
||||
{
|
||||
char *ep;
|
||||
int fd, sc;
|
||||
struct kbkeycode a;
|
||||
int fd, sc;
|
||||
struct kbkeycode a;
|
||||
|
||||
if (argc % 2 != 1 || argc < 2) {
|
||||
bb_show_usage();
|
||||
if (argc % 2 != 1 || argc < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
fd = get_console_fd();
|
||||
|
||||
while (argc > 2) {
|
||||
a.keycode = atoi(argv[2]);
|
||||
a.scancode = sc = strtol(argv[1], &ep, 16);
|
||||
if (*ep) {
|
||||
bb_error_msg_and_die("error reading SCANCODE: '%s'", argv[1]);
|
||||
while (argc > 2) {
|
||||
a.keycode = xatoul_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;
|
||||
}
|
||||
if (ioctl(fd, KDSETKEYCODE, &a)) {
|
||||
bb_perror_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
|
||||
}
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
}
|
||||
if (a.scancode > 127) {
|
||||
a.scancode -= 0xe000;
|
||||
a.scancode += 128;
|
||||
}
|
||||
if (a.scancode > 255 || a.keycode > 127) {
|
||||
bb_error_msg_and_die("SCANCODE or KEYCODE outside bounds");
|
||||
}
|
||||
if (ioctl(fd,KDSETKEYCODE,&a)) {
|
||||
perror("KDSETKEYCODE");
|
||||
bb_error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
|
||||
}
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* setlogcons: Send kernel messages to the current console or to console N
|
||||
* setlogcons: Send kernel messages to the current console or to console N
|
||||
*
|
||||
* Copyright (C) 2006 by Jan Kiszka <jan.kiszka@web.de>
|
||||
*
|
||||
@@ -9,13 +9,10 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int setlogcons_main(int argc, char **argv)
|
||||
int setlogcons_main(int argc, char **argv);
|
||||
int setlogcons_main(int argc, char **argv)
|
||||
{
|
||||
struct {
|
||||
char fn;
|
||||
@@ -26,10 +23,10 @@ extern int setlogcons_main(int argc, char **argv)
|
||||
arg.subarg = 0; /* to specified console (current as default) */
|
||||
|
||||
if (argc == 2)
|
||||
arg.subarg = atoi(argv[1]);
|
||||
arg.subarg = xatoul_range(argv[1], 0, 63);
|
||||
|
||||
if (ioctl(bb_xopen(VC_1, O_RDONLY), TIOCLINUX, &arg))
|
||||
bb_perror_msg_and_die("TIOCLINUX");;
|
||||
if (ioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg))
|
||||
bb_perror_msg_and_die("TIOCLINUX");
|
||||
|
||||
return 0;
|
||||
}
|
||||
+160
-153
@@ -5,7 +5,7 @@
|
||||
|
||||
menu "Coreutils"
|
||||
|
||||
config CONFIG_BASENAME
|
||||
config BASENAME
|
||||
bool "basename"
|
||||
default n
|
||||
help
|
||||
@@ -13,101 +13,101 @@ config CONFIG_BASENAME
|
||||
leaving just the filename itself. Enable this option if you wish
|
||||
to enable the 'basename' utility.
|
||||
|
||||
config CONFIG_CAL
|
||||
config CAL
|
||||
bool "cal"
|
||||
default n
|
||||
help
|
||||
cal is used to display a monthly calender.
|
||||
|
||||
config CONFIG_CAT
|
||||
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 CONFIG_CATV
|
||||
config CATV
|
||||
bool "catv"
|
||||
default n
|
||||
help
|
||||
Display nonprinting characters as escape sequences (like some
|
||||
implementations' cat -v option).
|
||||
|
||||
config CONFIG_CHGRP
|
||||
config CHGRP
|
||||
bool "chgrp"
|
||||
default n
|
||||
help
|
||||
chgrp is used to change the group ownership of files.
|
||||
|
||||
config CONFIG_CHMOD
|
||||
config CHMOD
|
||||
bool "chmod"
|
||||
default n
|
||||
help
|
||||
chmod is used to change the access permission of files.
|
||||
|
||||
config CONFIG_CHOWN
|
||||
config CHOWN
|
||||
bool "chown"
|
||||
default n
|
||||
help
|
||||
chown is used to change the user and/or group ownership
|
||||
of files.
|
||||
|
||||
config CONFIG_CHROOT
|
||||
config CHROOT
|
||||
bool "chroot"
|
||||
default n
|
||||
help
|
||||
chroot is used to change the root directory and run a command.
|
||||
The default command is `/bin/sh'.
|
||||
|
||||
config CONFIG_CKSUM
|
||||
config CKSUM
|
||||
bool "cksum"
|
||||
default n
|
||||
help
|
||||
cksum is used to calculate the CRC32 checksum of a file.
|
||||
|
||||
config CONFIG_CMP
|
||||
config CMP
|
||||
bool "cmp"
|
||||
default n
|
||||
help
|
||||
cmp is used to compare two files and returns the result
|
||||
to standard output.
|
||||
|
||||
config CONFIG_COMM
|
||||
config COMM
|
||||
bool "comm"
|
||||
default n
|
||||
help
|
||||
comm is used to compare two files line by line and return
|
||||
a three-column output.
|
||||
|
||||
config CONFIG_CP
|
||||
config CP
|
||||
bool "cp"
|
||||
default n
|
||||
help
|
||||
cp is used to copy files and directories.
|
||||
|
||||
config CONFIG_CUT
|
||||
config CUT
|
||||
bool "cut"
|
||||
default n
|
||||
help
|
||||
cut is used to print selected parts of lines from
|
||||
each file to stdout.
|
||||
|
||||
config CONFIG_DATE
|
||||
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 CONFIG_FEATURE_DATE_ISOFMT
|
||||
config FEATURE_DATE_ISOFMT
|
||||
bool "Enable ISO date format output (-I)"
|
||||
default y
|
||||
depends on CONFIG_DATE
|
||||
depends on DATE
|
||||
help
|
||||
Enable option (-I) to output an ISO-8601 compliant
|
||||
date/time string.
|
||||
|
||||
config CONFIG_DD
|
||||
config DD
|
||||
bool "dd"
|
||||
default n
|
||||
help
|
||||
@@ -115,34 +115,34 @@ config CONFIG_DD
|
||||
by default) using specific input and output blocksizes,
|
||||
while optionally performing conversions on it.
|
||||
|
||||
config CONFIG_FEATURE_DD_SIGNAL_HANDLING
|
||||
config FEATURE_DD_SIGNAL_HANDLING
|
||||
bool "Enable DD signal handling for status reporting"
|
||||
default y
|
||||
depends on CONFIG_DD
|
||||
depends on DD
|
||||
help
|
||||
sending a SIGUSR1 signal to a running `dd' process makes it
|
||||
print to standard error the number of records read and written
|
||||
sending a SIGUSR1 signal to a running `dd' process makes it
|
||||
print to standard error the number of records read and written
|
||||
so far, then to resume copying.
|
||||
|
||||
$ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid
|
||||
$ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid
|
||||
10899206+0 records in 10899206+0 records out
|
||||
|
||||
config CONFIG_FEATURE_DD_IBS_OBS
|
||||
config FEATURE_DD_IBS_OBS
|
||||
bool "Enable ibs, obs and conv options"
|
||||
default n
|
||||
depends on CONFIG_DD
|
||||
depends on DD
|
||||
help
|
||||
Enables support for writing a certain number of bytes in and out,
|
||||
at a time, and performing conversions on the data stream.
|
||||
|
||||
config CONFIG_DF
|
||||
config DF
|
||||
bool "df"
|
||||
default n
|
||||
help
|
||||
df reports the amount of disk space used and available
|
||||
on filesystems.
|
||||
|
||||
config CONFIG_DIFF
|
||||
config DIFF
|
||||
bool "diff"
|
||||
default n
|
||||
help
|
||||
@@ -150,81 +150,81 @@ config CONFIG_DIFF
|
||||
differences between them in a form that can be given to
|
||||
the patch command.
|
||||
|
||||
config CONFIG_FEATURE_DIFF_BINARY
|
||||
config FEATURE_DIFF_BINARY
|
||||
bool "Enable checks for binary files"
|
||||
default y
|
||||
depends on CONFIG_DIFF
|
||||
depends on DIFF
|
||||
help
|
||||
This option enables support for checking for binary files
|
||||
before a comparison is carried out.
|
||||
|
||||
config CONFIG_FEATURE_DIFF_DIR
|
||||
config FEATURE_DIFF_DIR
|
||||
bool "Enable directory support"
|
||||
default y
|
||||
depends on CONFIG_DIFF
|
||||
depends on DIFF
|
||||
help
|
||||
This option enables support for directory and subdirectory
|
||||
comparison.
|
||||
|
||||
config CONFIG_FEATURE_DIFF_MINIMAL
|
||||
config FEATURE_DIFF_MINIMAL
|
||||
bool "Enable -d option to find smaller sets of changes"
|
||||
default n
|
||||
depends on CONFIG_DIFF
|
||||
depends on DIFF
|
||||
help
|
||||
Enabling this option allows the use of -d to make diff
|
||||
try hard to find the smallest possible set of changes.
|
||||
|
||||
config CONFIG_DIRNAME
|
||||
config DIRNAME
|
||||
bool "dirname"
|
||||
default n
|
||||
help
|
||||
dirname is used to strip a non-directory suffix from
|
||||
a file name.
|
||||
|
||||
config CONFIG_DOS2UNIX
|
||||
config DOS2UNIX
|
||||
bool "dos2unix/unix2dos"
|
||||
default n
|
||||
help
|
||||
dos2unix is used to convert a text file from DOS format to
|
||||
UNIX format, and vice versa.
|
||||
|
||||
config CONFIG_UNIX2DOS
|
||||
config UNIX2DOS
|
||||
bool
|
||||
default y
|
||||
depends on CONFIG_DOS2UNIX
|
||||
depends on DOS2UNIX
|
||||
help
|
||||
unix2dos is used to convert a text file from UNIX format to
|
||||
DOS format, and vice versa.
|
||||
|
||||
config CONFIG_DU
|
||||
config DU
|
||||
bool "du (default blocksize of 512 bytes)"
|
||||
default n
|
||||
help
|
||||
du is used to report the amount of disk space used
|
||||
for specified files.
|
||||
|
||||
config CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
|
||||
config FEATURE_DU_DEFAULT_BLOCKSIZE_1K
|
||||
bool "Use a default blocksize of 1024 bytes (1K)"
|
||||
default y
|
||||
depends on CONFIG_DU
|
||||
depends on DU
|
||||
help
|
||||
Use a blocksize of (1K) instead of the default 512b.
|
||||
|
||||
config CONFIG_ECHO
|
||||
config ECHO
|
||||
bool "echo (basic SuSv3 version taking no options)"
|
||||
default n
|
||||
help
|
||||
echo is used to print a specified string to stdout.
|
||||
|
||||
# this entry also appears in shell/Config.in, next to the echo builtin
|
||||
config CONFIG_FEATURE_FANCY_ECHO
|
||||
config FEATURE_FANCY_ECHO
|
||||
bool "Enable echo options (-n and -e)"
|
||||
default y
|
||||
depends on CONFIG_ECHO
|
||||
depends on ECHO
|
||||
help
|
||||
This adds options (-n and -e) to echo.
|
||||
|
||||
config CONFIG_ENV
|
||||
config ENV
|
||||
bool "env"
|
||||
default n
|
||||
help
|
||||
@@ -232,158 +232,158 @@ config CONFIG_ENV
|
||||
a command; without options it displays the current
|
||||
environment.
|
||||
|
||||
config CONFIG_FEATURE_ENV_LONG_OPTIONS
|
||||
config FEATURE_ENV_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
depends on CONFIG_ENV && CONFIG_GETOPT_LONG
|
||||
depends on ENV && GETOPT_LONG
|
||||
help
|
||||
Support long options for the env applet.
|
||||
|
||||
config CONFIG_EXPR
|
||||
config EXPR
|
||||
bool "expr"
|
||||
default n
|
||||
help
|
||||
expr is used to calculate numbers and print the result
|
||||
to standard output.
|
||||
|
||||
config CONFIG_EXPR_MATH_SUPPORT_64
|
||||
config EXPR_MATH_SUPPORT_64
|
||||
bool "Extend Posix numbers support to 64 bit"
|
||||
default n
|
||||
depends on CONFIG_EXPR
|
||||
depends on EXPR
|
||||
help
|
||||
Enable 64-bit math support in the expr applet. This will make
|
||||
the applet slightly larger, but will allow computation with very
|
||||
large numbers.
|
||||
|
||||
config CONFIG_FALSE
|
||||
config FALSE
|
||||
bool "false"
|
||||
default n
|
||||
help
|
||||
false returns an exit code of FALSE (1).
|
||||
|
||||
config CONFIG_FOLD
|
||||
config FOLD
|
||||
bool "fold"
|
||||
default n
|
||||
help
|
||||
Wrap text to fit a specific width.
|
||||
|
||||
config CONFIG_HEAD
|
||||
config HEAD
|
||||
bool "head"
|
||||
default n
|
||||
help
|
||||
head is used to print the first specified number of lines
|
||||
from files.
|
||||
|
||||
config CONFIG_FEATURE_FANCY_HEAD
|
||||
config FEATURE_FANCY_HEAD
|
||||
bool "Enable head options (-c, -q, and -v)"
|
||||
default n
|
||||
depends on CONFIG_HEAD
|
||||
depends on HEAD
|
||||
help
|
||||
This enables the head options (-c, -q, and -v).
|
||||
|
||||
config CONFIG_HOSTID
|
||||
config HOSTID
|
||||
bool "hostid"
|
||||
default n
|
||||
help
|
||||
hostid prints the numeric identifier (in hexadecimal) for
|
||||
the current host.
|
||||
|
||||
config CONFIG_ID
|
||||
config ID
|
||||
bool "id"
|
||||
default n
|
||||
help
|
||||
id displays the current user and group ID names.
|
||||
|
||||
config CONFIG_INSTALL
|
||||
config INSTALL
|
||||
bool "install"
|
||||
default n
|
||||
help
|
||||
Copy files and set attributes.
|
||||
|
||||
config CONFIG_FEATURE_INSTALL_LONG_OPTIONS
|
||||
config FEATURE_INSTALL_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
depends on CONFIG_INSTALL && CONFIG_GETOPT_LONG
|
||||
depends on INSTALL && GETOPT_LONG
|
||||
help
|
||||
Support long options for the install applet.
|
||||
|
||||
config CONFIG_LENGTH
|
||||
config LENGTH
|
||||
bool "length"
|
||||
default n
|
||||
help
|
||||
length is used to print out the length of a specified string.
|
||||
|
||||
config CONFIG_LN
|
||||
config LN
|
||||
bool "ln"
|
||||
default n
|
||||
help
|
||||
ln is used to create hard or soft links between files.
|
||||
|
||||
config CONFIG_LOGNAME
|
||||
config LOGNAME
|
||||
bool "logname"
|
||||
default n
|
||||
help
|
||||
logname is used to print the current user's login name.
|
||||
|
||||
config CONFIG_LS
|
||||
config LS
|
||||
bool "ls"
|
||||
default n
|
||||
help
|
||||
ls is used to list the contents of directories.
|
||||
|
||||
config CONFIG_FEATURE_LS_FILETYPES
|
||||
config FEATURE_LS_FILETYPES
|
||||
bool "Enable filetyping options (-p and -F)"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
depends on LS
|
||||
help
|
||||
Enable the ls options (-p and -F).
|
||||
|
||||
config CONFIG_FEATURE_LS_FOLLOWLINKS
|
||||
config FEATURE_LS_FOLLOWLINKS
|
||||
bool "Enable symlinks dereferencing (-L)"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
depends on LS
|
||||
help
|
||||
Enable the ls option (-L).
|
||||
|
||||
config CONFIG_FEATURE_LS_RECURSIVE
|
||||
config FEATURE_LS_RECURSIVE
|
||||
bool "Enable recursion (-R)"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
depends on LS
|
||||
help
|
||||
Enable the ls option (-R).
|
||||
|
||||
config CONFIG_FEATURE_LS_SORTFILES
|
||||
config FEATURE_LS_SORTFILES
|
||||
bool "Sort the file names"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
depends on LS
|
||||
help
|
||||
Allow ls to sort file names alphabetically.
|
||||
|
||||
config CONFIG_FEATURE_LS_TIMESTAMPS
|
||||
config FEATURE_LS_TIMESTAMPS
|
||||
bool "Show file timestamps"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
depends on LS
|
||||
help
|
||||
Allow ls to display timestamps for files.
|
||||
|
||||
config CONFIG_FEATURE_LS_USERNAME
|
||||
config FEATURE_LS_USERNAME
|
||||
bool "Show username/groupnames"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
depends on LS
|
||||
help
|
||||
Allow ls to display username/groupname for files.
|
||||
|
||||
config CONFIG_FEATURE_LS_COLOR
|
||||
config FEATURE_LS_COLOR
|
||||
bool "Allow use of color to identify file types"
|
||||
default y
|
||||
depends on CONFIG_LS && CONFIG_GETOPT_LONG
|
||||
depends on LS && GETOPT_LONG
|
||||
help
|
||||
This enables the --color option to ls.
|
||||
|
||||
config CONFIG_FEATURE_LS_COLOR_IS_DEFAULT
|
||||
config FEATURE_LS_COLOR_IS_DEFAULT
|
||||
bool "Produce colored ls output by default"
|
||||
default n
|
||||
depends on CONFIG_FEATURE_LS_COLOR
|
||||
depends on FEATURE_LS_COLOR
|
||||
help
|
||||
Saying yes here will turn coloring on by default,
|
||||
even if no "--color" option is given to the ls command.
|
||||
@@ -391,143 +391,143 @@ config CONFIG_FEATURE_LS_COLOR_IS_DEFAULT
|
||||
configurable, and the output may not be legible on
|
||||
many output screens.
|
||||
|
||||
config CONFIG_MD5SUM
|
||||
config MD5SUM
|
||||
bool "md5sum"
|
||||
default n
|
||||
help
|
||||
md5sum is used to print or check MD5 checksums.
|
||||
|
||||
config CONFIG_MKDIR
|
||||
config MKDIR
|
||||
bool "mkdir"
|
||||
default n
|
||||
help
|
||||
mkdir is used to create directories with the specified names.
|
||||
|
||||
config CONFIG_FEATURE_MKDIR_LONG_OPTIONS
|
||||
config FEATURE_MKDIR_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
depends on CONFIG_MKDIR && CONFIG_GETOPT_LONG
|
||||
depends on MKDIR && GETOPT_LONG
|
||||
help
|
||||
Support long options for the mkdir applet.
|
||||
|
||||
config CONFIG_MKFIFO
|
||||
config MKFIFO
|
||||
bool "mkfifo"
|
||||
default n
|
||||
help
|
||||
mkfifo is used to create FIFOs (named pipes).
|
||||
The `mknod' program can also create FIFOs.
|
||||
|
||||
config CONFIG_MKNOD
|
||||
config MKNOD
|
||||
bool "mknod"
|
||||
default n
|
||||
help
|
||||
mknod is used to create FIFOs or block/character special
|
||||
files with the specified names.
|
||||
|
||||
config CONFIG_MV
|
||||
config MV
|
||||
bool "mv"
|
||||
default n
|
||||
help
|
||||
mv is used to move or rename files or directories.
|
||||
|
||||
config CONFIG_FEATURE_MV_LONG_OPTIONS
|
||||
config FEATURE_MV_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
depends on CONFIG_MV && CONFIG_GETOPT_LONG
|
||||
depends on MV && GETOPT_LONG
|
||||
help
|
||||
Support long options for the mv applet.
|
||||
|
||||
config CONFIG_NICE
|
||||
config NICE
|
||||
bool "nice"
|
||||
default n
|
||||
help
|
||||
nice runs a program with modified scheduling priority.
|
||||
|
||||
config CONFIG_NOHUP
|
||||
config NOHUP
|
||||
bool "nohup"
|
||||
default n
|
||||
help
|
||||
run a command immune to hangups, with output to a non-tty.
|
||||
|
||||
config CONFIG_OD
|
||||
config OD
|
||||
bool "od"
|
||||
default n
|
||||
help
|
||||
od is used to dump binary files in octal and other formats.
|
||||
|
||||
config CONFIG_PRINTENV
|
||||
config PRINTENV
|
||||
bool "printenv"
|
||||
default n
|
||||
help
|
||||
printenv is used to print all or part of environment.
|
||||
|
||||
config CONFIG_PRINTF
|
||||
config PRINTF
|
||||
bool "printf"
|
||||
default n
|
||||
help
|
||||
printf is used to format and print specified strings.
|
||||
It's similar to `echo' except it has more options.
|
||||
|
||||
config CONFIG_PWD
|
||||
config PWD
|
||||
bool "pwd"
|
||||
default n
|
||||
help
|
||||
pwd is used to print the current directory.
|
||||
|
||||
config CONFIG_REALPATH
|
||||
config REALPATH
|
||||
bool "realpath"
|
||||
default n
|
||||
help
|
||||
Return the canonicalized absolute pathname.
|
||||
This isn't provided by GNU shellutils, but where else does it belong.
|
||||
|
||||
config CONFIG_RM
|
||||
config RM
|
||||
bool "rm"
|
||||
default n
|
||||
help
|
||||
rm is used to remove files or directories.
|
||||
|
||||
config CONFIG_RMDIR
|
||||
config RMDIR
|
||||
bool "rmdir"
|
||||
default n
|
||||
help
|
||||
rmdir is used to remove empty directories.
|
||||
|
||||
config CONFIG_SEQ
|
||||
config SEQ
|
||||
bool "seq"
|
||||
default n
|
||||
help
|
||||
print a sequence of numbers
|
||||
|
||||
config CONFIG_SHA1SUM
|
||||
config SHA1SUM
|
||||
bool "sha1sum"
|
||||
default n
|
||||
help
|
||||
Compute and check SHA1 message digest
|
||||
|
||||
config CONFIG_SLEEP
|
||||
config SLEEP
|
||||
bool "sleep (single integer arg with no suffix)"
|
||||
default n
|
||||
help
|
||||
sleep is used to pause for a specified number of seconds,
|
||||
|
||||
config CONFIG_FEATURE_FANCY_SLEEP
|
||||
config FEATURE_FANCY_SLEEP
|
||||
bool "Enable multiple integer args and optional time suffixes"
|
||||
default n
|
||||
depends on CONFIG_SLEEP
|
||||
depends on SLEEP
|
||||
help
|
||||
Allow sleep to pause for specified minutes, hours, and days.
|
||||
|
||||
config CONFIG_SORT
|
||||
config SORT
|
||||
bool "sort"
|
||||
default n
|
||||
help
|
||||
sort is used to sort lines of text in specified files.
|
||||
|
||||
config CONFIG_FEATURE_SORT_BIG
|
||||
config FEATURE_SORT_BIG
|
||||
bool "full SuSv3 compliant sort (Support -ktcsbdfiozgM)"
|
||||
default y
|
||||
depends on CONFIG_SORT
|
||||
depends on SORT
|
||||
help
|
||||
Without this, sort only supports -r, -u, and an integer version
|
||||
of -n. Selecting this adds sort keys, floating point support, and
|
||||
@@ -536,69 +536,69 @@ config CONFIG_FEATURE_SORT_BIG
|
||||
The SuSv3 sort standard is available at:
|
||||
http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
|
||||
|
||||
config CONFIG_STAT
|
||||
config STAT
|
||||
bool "stat"
|
||||
default n
|
||||
help
|
||||
display file or filesystem status.
|
||||
|
||||
config CONFIG_FEATURE_STAT_FORMAT
|
||||
config FEATURE_STAT_FORMAT
|
||||
bool "Enable custom formats (-c)"
|
||||
default n
|
||||
depends on CONFIG_STAT
|
||||
depends on STAT
|
||||
help
|
||||
Without this, stat will not support the '-c format' option where
|
||||
users can pass a custom format string for output. This adds about
|
||||
7k to a nonstatic build on amd64.
|
||||
|
||||
config CONFIG_STTY
|
||||
config STTY
|
||||
bool "stty"
|
||||
default n
|
||||
help
|
||||
stty is used to change and print terminal line settings.
|
||||
|
||||
config CONFIG_SUM
|
||||
config SUM
|
||||
bool "sum"
|
||||
default n
|
||||
help
|
||||
checksum and count the blocks in a file
|
||||
|
||||
config CONFIG_SYNC
|
||||
config SYNC
|
||||
bool "sync"
|
||||
default n
|
||||
help
|
||||
sync is used to flush filesystem buffers.
|
||||
|
||||
config CONFIG_TAIL
|
||||
config TAIL
|
||||
bool "tail"
|
||||
default n
|
||||
help
|
||||
tail is used to print the last specified number of lines
|
||||
from files.
|
||||
|
||||
config CONFIG_FEATURE_FANCY_TAIL
|
||||
config FEATURE_FANCY_TAIL
|
||||
bool "Enable extra tail options (-q, -s, and -v)"
|
||||
default y
|
||||
depends on CONFIG_TAIL
|
||||
depends on TAIL
|
||||
help
|
||||
The options (-q, -s, and -v) are provided by GNU tail, but
|
||||
are not specific in the SUSv3 standard.
|
||||
|
||||
config CONFIG_TEE
|
||||
config TEE
|
||||
bool "tee"
|
||||
default n
|
||||
help
|
||||
tee is used to read from standard input and write
|
||||
to standard output and files.
|
||||
|
||||
config CONFIG_FEATURE_TEE_USE_BLOCK_IO
|
||||
config FEATURE_TEE_USE_BLOCK_IO
|
||||
bool "Enable block i/o (larger/faster) instead of byte i/o."
|
||||
default n
|
||||
depends on CONFIG_TEE
|
||||
depends on TEE
|
||||
help
|
||||
Enable this option for a faster tee, at expense of size.
|
||||
|
||||
config CONFIG_TEST
|
||||
config TEST
|
||||
bool "test"
|
||||
default n
|
||||
help
|
||||
@@ -606,39 +606,39 @@ config CONFIG_TEST
|
||||
returning an appropriate exit code. The bash shell
|
||||
has test built in, ash can build it in optionally.
|
||||
|
||||
config CONFIG_FEATURE_TEST_64
|
||||
config FEATURE_TEST_64
|
||||
bool "Extend test to 64 bit"
|
||||
default n
|
||||
depends on CONFIG_TEST
|
||||
depends on TEST
|
||||
help
|
||||
Enable 64-bit support in test.
|
||||
|
||||
config CONFIG_TOUCH
|
||||
config TOUCH
|
||||
bool "touch"
|
||||
default n
|
||||
help
|
||||
touch is used to create or change the access and/or
|
||||
modification timestamp of specified files.
|
||||
|
||||
config CONFIG_TR
|
||||
config TR
|
||||
bool "tr"
|
||||
default n
|
||||
help
|
||||
tr is used to squeeze, and/or delete characters from standard
|
||||
input, writing to standard output.
|
||||
|
||||
config CONFIG_FEATURE_TR_CLASSES
|
||||
config FEATURE_TR_CLASSES
|
||||
bool "Enable character classes (such as [:upper:])"
|
||||
default n
|
||||
depends on CONFIG_TR
|
||||
depends on TR
|
||||
help
|
||||
Enable character classes, enabling commands such as:
|
||||
tr [:upper:] [:lower:] to convert input into lowercase.
|
||||
|
||||
config CONFIG_FEATURE_TR_EQUIV
|
||||
config FEATURE_TR_EQUIV
|
||||
bool "Enable equivalence classes"
|
||||
default n
|
||||
depends on CONFIG_TR
|
||||
depends on TR
|
||||
help
|
||||
Enable equivalence classes, which essentially add the enclosed
|
||||
character to the current set. For instance, tr [=a=] xyz would
|
||||
@@ -646,79 +646,86 @@ config CONFIG_FEATURE_TR_EQUIV
|
||||
useful for cases when no other way of expressing a character
|
||||
is possible.
|
||||
|
||||
config CONFIG_TRUE
|
||||
config TRUE
|
||||
bool "true"
|
||||
default n
|
||||
help
|
||||
true returns an exit code of TRUE (0).
|
||||
|
||||
config CONFIG_TTY
|
||||
config TTY
|
||||
bool "tty"
|
||||
default n
|
||||
help
|
||||
tty is used to print the name of the current terminal to
|
||||
standard output.
|
||||
|
||||
config CONFIG_UNAME
|
||||
config UNAME
|
||||
bool "uname"
|
||||
default n
|
||||
help
|
||||
uname is used to print system information.
|
||||
|
||||
config CONFIG_UNIQ
|
||||
config UNIQ
|
||||
bool "uniq"
|
||||
default n
|
||||
help
|
||||
uniq is used to remove duplicate lines from a sorted file.
|
||||
|
||||
config CONFIG_USLEEP
|
||||
config USLEEP
|
||||
bool "usleep"
|
||||
default n
|
||||
help
|
||||
usleep is used to pause for a specified number of microseconds.
|
||||
|
||||
config CONFIG_UUDECODE
|
||||
config UUDECODE
|
||||
bool "uudecode"
|
||||
default n
|
||||
help
|
||||
uudecode is used to decode a uuencoded file.
|
||||
|
||||
config CONFIG_UUENCODE
|
||||
config UUENCODE
|
||||
bool "uuencode"
|
||||
default n
|
||||
help
|
||||
uuencode is used to uuencode a file.
|
||||
|
||||
config CONFIG_WATCH
|
||||
config WATCH
|
||||
bool "watch"
|
||||
default n
|
||||
select CONFIG_DATE
|
||||
select DATE
|
||||
help
|
||||
watch is used to execute a program periodically, showing
|
||||
output to the screen.
|
||||
|
||||
config CONFIG_WC
|
||||
config WC
|
||||
bool "wc"
|
||||
default n
|
||||
help
|
||||
wc is used to print the number of bytes, words, and lines,
|
||||
in specified files.
|
||||
|
||||
config CONFIG_WHO
|
||||
config FEATURE_WC_LARGE
|
||||
bool "Support very large files in wc"
|
||||
default n
|
||||
depends on WC
|
||||
help
|
||||
Use "unsigned long long" in wc for count variables
|
||||
|
||||
config WHO
|
||||
bool "who"
|
||||
default n
|
||||
select CONFIG_FEATURE_UTMP
|
||||
select FEATURE_UTMP
|
||||
help
|
||||
who is used to show who is logged on.
|
||||
|
||||
config CONFIG_WHOAMI
|
||||
config WHOAMI
|
||||
bool "whoami"
|
||||
default n
|
||||
help
|
||||
whoami is used to print the username of the current
|
||||
user id (same as id -un).
|
||||
|
||||
config CONFIG_YES
|
||||
config YES
|
||||
bool "yes"
|
||||
default n
|
||||
help
|
||||
@@ -726,46 +733,46 @@ config CONFIG_YES
|
||||
the default string `y'.
|
||||
|
||||
comment "Common options for cp and mv"
|
||||
depends on CONFIG_CP || CONFIG_MV
|
||||
depends on CP || MV
|
||||
|
||||
config CONFIG_FEATURE_PRESERVE_HARDLINKS
|
||||
config FEATURE_PRESERVE_HARDLINKS
|
||||
bool "Preserve hard links"
|
||||
default n
|
||||
depends on CONFIG_CP || CONFIG_MV
|
||||
depends on CP || MV
|
||||
help
|
||||
Allow cp and mv to preserve hard links.
|
||||
|
||||
comment "Common options for ls, more and telnet"
|
||||
depends on CONFIG_LS || CONFIG_MORE || CONFIG_TELNET
|
||||
depends on LS || MORE || TELNET
|
||||
|
||||
config CONFIG_FEATURE_AUTOWIDTH
|
||||
config FEATURE_AUTOWIDTH
|
||||
bool "Calculate terminal & column widths"
|
||||
default y
|
||||
depends on CONFIG_LS || CONFIG_MORE || CONFIG_TELNET
|
||||
depends on LS || MORE || TELNET
|
||||
help
|
||||
This option allows utilities such as 'ls', 'more' and 'telnet'
|
||||
to determine the width of the screen, which can allow them to
|
||||
to determine the width of the screen, which can allow them to
|
||||
display additional text or avoid wrapping text onto the next line.
|
||||
If you leave this disabled, your utilities will be especially
|
||||
If you leave this disabled, your utilities will be especially
|
||||
primitive and will be unable to determine the current screen width.
|
||||
|
||||
comment "Common options for df, du, ls"
|
||||
depends on CONFIG_DF || CONFIG_DU || CONFIG_LS
|
||||
depends on DF || DU || LS
|
||||
|
||||
config CONFIG_FEATURE_HUMAN_READABLE
|
||||
config FEATURE_HUMAN_READABLE
|
||||
bool "Support for human readable output (example 13k, 23M, 235G)"
|
||||
default n
|
||||
depends on CONFIG_DF || CONFIG_DU || CONFIG_LS
|
||||
depends on DF || DU || LS
|
||||
help
|
||||
Allow df, du, and ls to have human readable output.
|
||||
|
||||
comment "Common options for md5sum, sha1sum"
|
||||
depends on CONFIG_MD5SUM || CONFIG_SHA1SUM
|
||||
depends on MD5SUM || SHA1SUM
|
||||
|
||||
config CONFIG_FEATURE_MD5_SHA1_SUM_CHECK
|
||||
config FEATURE_MD5_SHA1_SUM_CHECK
|
||||
bool "Enable -c, -s and -w options"
|
||||
default n
|
||||
depends on CONFIG_MD5SUM || CONFIG_SHA1SUM
|
||||
depends on MD5SUM || SHA1SUM
|
||||
help
|
||||
Enabling the -c options allows files to be checked
|
||||
against pre-calculated hash values.
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
libs-y += libcoreutils/
|
||||
|
||||
lib-y:=
|
||||
lib-$(CONFIG_BASENAME) += basename.o
|
||||
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_CATV) += catv.o
|
||||
lib-$(CONFIG_CHGRP) += chgrp.o chown.o
|
||||
lib-$(CONFIG_CHMOD) += chmod.o
|
||||
lib-$(CONFIG_CHOWN) += chown.o
|
||||
lib-$(CONFIG_CHROOT) += chroot.o
|
||||
lib-$(CONFIG_CKSUM) += cksum.o
|
||||
lib-$(CONFIG_CMP) += cmp.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_DIFF) += diff.o
|
||||
lib-$(CONFIG_DIRNAME) += dirname.o
|
||||
lib-$(CONFIG_DOS2UNIX) += dos2unix.o
|
||||
lib-$(CONFIG_DU) += du.o
|
||||
lib-$(CONFIG_ECHO) += echo.o
|
||||
lib-$(CONFIG_ASH) += echo.o # used by ash
|
||||
lib-$(CONFIG_ENV) += env.o
|
||||
lib-$(CONFIG_EXPR) += expr.o
|
||||
lib-$(CONFIG_FALSE) += false.o
|
||||
lib-$(CONFIG_FOLD) += fold.o
|
||||
lib-$(CONFIG_HEAD) += head.o
|
||||
lib-$(CONFIG_HOSTID) += hostid.o
|
||||
lib-$(CONFIG_ID) += id.o
|
||||
lib-$(CONFIG_INSTALL) += install.o
|
||||
lib-$(CONFIG_LENGTH) += length.o
|
||||
lib-$(CONFIG_LN) += ln.o
|
||||
lib-$(CONFIG_LOGNAME) += logname.o
|
||||
lib-$(CONFIG_LS) += ls.o
|
||||
lib-$(CONFIG_MD5SUM) += md5_sha1_sum.o
|
||||
lib-$(CONFIG_MKDIR) += mkdir.o
|
||||
lib-$(CONFIG_MKFIFO) += mkfifo.o
|
||||
lib-$(CONFIG_MKNOD) += mknod.o
|
||||
lib-$(CONFIG_MV) += mv.o
|
||||
lib-$(CONFIG_NICE) += nice.o
|
||||
lib-$(CONFIG_NOHUP) += nohup.o
|
||||
lib-$(CONFIG_OD) += od.o
|
||||
lib-$(CONFIG_PRINTENV) += printenv.o
|
||||
lib-$(CONFIG_PRINTF) += printf.o
|
||||
lib-$(CONFIG_PWD) += pwd.o
|
||||
lib-$(CONFIG_REALPATH) += realpath.o
|
||||
lib-$(CONFIG_RM) += rm.o
|
||||
lib-$(CONFIG_RMDIR) += rmdir.o
|
||||
lib-$(CONFIG_SEQ) += seq.o
|
||||
lib-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
|
||||
lib-$(CONFIG_SLEEP) += sleep.o
|
||||
lib-$(CONFIG_SORT) += sort.o
|
||||
lib-$(CONFIG_STAT) += stat.o
|
||||
lib-$(CONFIG_STTY) += stty.o
|
||||
lib-$(CONFIG_SUM) += sum.o
|
||||
lib-$(CONFIG_SYNC) += sync.o
|
||||
lib-$(CONFIG_TAIL) += tail.o
|
||||
lib-$(CONFIG_TEE) += tee.o
|
||||
lib-$(CONFIG_TEST) += test.o
|
||||
lib-$(CONFIG_ASH) += test.o # used by ash
|
||||
lib-$(CONFIG_TOUCH) += touch.o
|
||||
lib-$(CONFIG_TR) += tr.o
|
||||
lib-$(CONFIG_TRUE) += true.o
|
||||
lib-$(CONFIG_TTY) += tty.o
|
||||
lib-$(CONFIG_UNAME) += uname.o
|
||||
lib-$(CONFIG_UNIQ) += uniq.o
|
||||
lib-$(CONFIG_USLEEP) += usleep.o
|
||||
lib-$(CONFIG_UUDECODE) += uudecode.o
|
||||
lib-$(CONFIG_UUENCODE) += uuencode.o
|
||||
lib-$(CONFIG_WATCH) += watch.o
|
||||
lib-$(CONFIG_WC) += wc.o
|
||||
lib-$(CONFIG_WHO) += who.o
|
||||
lib-$(CONFIG_WHOAMI) += whoami.o
|
||||
lib-$(CONFIG_YES) += yes.o
|
||||
@@ -1,23 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
ifndef top_srcdir
|
||||
top_srcdir=..
|
||||
endif
|
||||
ifndef top_builddir
|
||||
top_builddir=..
|
||||
endif
|
||||
srcdir=$(top_srcdir)/coreutils
|
||||
SHELLUTILS_DIR:=./
|
||||
include $(top_srcdir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -1,102 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
|
||||
#
|
||||
# Licensed under the GPL v2, see the file LICENSE in this tarball.
|
||||
|
||||
COREUTILS_AR:=coreutils.a
|
||||
ifndef $(COREUTILS_DIR)
|
||||
COREUTILS_DIR:=$(top_builddir)/coreutils/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/coreutils
|
||||
|
||||
COREUTILS-y:=
|
||||
COREUTILS-$(CONFIG_BASENAME) += basename.o
|
||||
COREUTILS-$(CONFIG_CAL) += cal.o
|
||||
COREUTILS-$(CONFIG_CAT) += cat.o
|
||||
COREUTILS-$(CONFIG_CATV) += catv.o
|
||||
COREUTILS-$(CONFIG_CHGRP) += chgrp.o
|
||||
COREUTILS-$(CONFIG_CHMOD) += chmod.o
|
||||
COREUTILS-$(CONFIG_CHOWN) += chown.o
|
||||
COREUTILS-$(CONFIG_CHROOT) += chroot.o
|
||||
COREUTILS-$(CONFIG_CKSUM) += cksum.o
|
||||
COREUTILS-$(CONFIG_CMP) += cmp.o
|
||||
COREUTILS-$(CONFIG_COMM) += comm.o
|
||||
COREUTILS-$(CONFIG_CP) += cp.o
|
||||
COREUTILS-$(CONFIG_CUT) += cut.o
|
||||
COREUTILS-$(CONFIG_DATE) += date.o
|
||||
COREUTILS-$(CONFIG_DD) += dd.o
|
||||
COREUTILS-$(CONFIG_DF) += df.o
|
||||
COREUTILS-$(CONFIG_DIFF) += diff.o
|
||||
COREUTILS-$(CONFIG_DIRNAME) += dirname.o
|
||||
COREUTILS-$(CONFIG_DOS2UNIX) += dos2unix.o
|
||||
COREUTILS-$(CONFIG_DU) += du.o
|
||||
COREUTILS-$(CONFIG_ECHO) += echo.o
|
||||
COREUTILS-$(CONFIG_ENV) += env.o
|
||||
COREUTILS-$(CONFIG_EXPR) += expr.o
|
||||
COREUTILS-$(CONFIG_FALSE) += false.o
|
||||
COREUTILS-$(CONFIG_FOLD) += fold.o
|
||||
COREUTILS-$(CONFIG_HEAD) += head.o
|
||||
COREUTILS-$(CONFIG_HOSTID) += hostid.o
|
||||
COREUTILS-$(CONFIG_ID) += id.o
|
||||
COREUTILS-$(CONFIG_INSTALL) += install.o
|
||||
COREUTILS-$(CONFIG_LENGTH) += length.o
|
||||
COREUTILS-$(CONFIG_LN) += ln.o
|
||||
COREUTILS-$(CONFIG_LOGNAME) += logname.o
|
||||
COREUTILS-$(CONFIG_LS) += ls.o
|
||||
COREUTILS-$(CONFIG_MD5SUM) += md5_sha1_sum.o
|
||||
COREUTILS-$(CONFIG_MKDIR) += mkdir.o
|
||||
COREUTILS-$(CONFIG_MKFIFO) += mkfifo.o
|
||||
COREUTILS-$(CONFIG_MKNOD) += mknod.o
|
||||
COREUTILS-$(CONFIG_MV) += mv.o
|
||||
COREUTILS-$(CONFIG_NICE) += nice.o
|
||||
COREUTILS-$(CONFIG_NOHUP) += nohup.o
|
||||
COREUTILS-$(CONFIG_OD) += od.o
|
||||
COREUTILS-$(CONFIG_PRINTENV) += printenv.o
|
||||
COREUTILS-$(CONFIG_PRINTF) += printf.o
|
||||
COREUTILS-$(CONFIG_PWD) += pwd.o
|
||||
COREUTILS-$(CONFIG_REALPATH) += realpath.o
|
||||
COREUTILS-$(CONFIG_RM) += rm.o
|
||||
COREUTILS-$(CONFIG_RMDIR) += rmdir.o
|
||||
COREUTILS-$(CONFIG_SEQ) += seq.o
|
||||
COREUTILS-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
|
||||
COREUTILS-$(CONFIG_SLEEP) += sleep.o
|
||||
COREUTILS-$(CONFIG_SORT) += sort.o
|
||||
COREUTILS-$(CONFIG_STAT) += stat.o
|
||||
COREUTILS-$(CONFIG_STTY) += stty.o
|
||||
COREUTILS-$(CONFIG_SUM) += sum.o
|
||||
COREUTILS-$(CONFIG_SYNC) += sync.o
|
||||
COREUTILS-$(CONFIG_TAIL) += tail.o
|
||||
COREUTILS-$(CONFIG_TEE) += tee.o
|
||||
COREUTILS-$(CONFIG_TEST) += test.o
|
||||
COREUTILS-$(CONFIG_TOUCH) += touch.o
|
||||
COREUTILS-$(CONFIG_TR) += tr.o
|
||||
COREUTILS-$(CONFIG_TRUE) += true.o
|
||||
COREUTILS-$(CONFIG_TTY) += tty.o
|
||||
COREUTILS-$(CONFIG_UNAME) += uname.o
|
||||
COREUTILS-$(CONFIG_UNIQ) += uniq.o
|
||||
COREUTILS-$(CONFIG_USLEEP) += usleep.o
|
||||
COREUTILS-$(CONFIG_UUDECODE) += uudecode.o
|
||||
COREUTILS-$(CONFIG_UUENCODE) += uuencode.o
|
||||
COREUTILS-$(CONFIG_WATCH) += watch.o
|
||||
COREUTILS-$(CONFIG_WC) += wc.o
|
||||
COREUTILS-$(CONFIG_WHO) += who.o
|
||||
COREUTILS-$(CONFIG_WHOAMI) += whoami.o
|
||||
COREUTILS-$(CONFIG_YES) += yes.o
|
||||
|
||||
COREUTILS-y:=$(sort $(COREUTILS-y))
|
||||
|
||||
ifneq ($(strip $(COREUTILS-y)),)
|
||||
libraries-y+=$(COREUTILS_DIR)$(COREUTILS_AR)
|
||||
endif
|
||||
|
||||
COREUTILS_SRC-y:=$(patsubst %.o,$(srcdir)/%.c,$(COREUTILS-y))
|
||||
COREUTILS_SRC-a:=$(wildcard $(srcdir)/*.c)
|
||||
APPLET_SRC-y+=$(COREUTILS_SRC-y)
|
||||
APPLET_SRC-a+=$(COREUTILS_SRC-a)
|
||||
|
||||
$(COREUTILS_DIR)$(COREUTILS_AR): $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
|
||||
$(do_ar)
|
||||
|
||||
$(COREUTILS_DIR)%.o: $(srcdir)/%.c
|
||||
$(compile.c)
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int basename_main(int argc, char **argv);
|
||||
int basename_main(int argc, char **argv)
|
||||
{
|
||||
size_t m, n;
|
||||
@@ -46,5 +47,5 @@ int basename_main(int argc, char **argv)
|
||||
|
||||
puts(s);
|
||||
|
||||
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
+12
-27
@@ -17,20 +17,8 @@
|
||||
* Major size reduction... over 50% (>1.5k) on i386.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#ifdef CONFIG_LOCALE_SUPPORT
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#define THURSDAY 4 /* for reformation */
|
||||
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
|
||||
|
||||
@@ -45,7 +33,7 @@ static const char days_in_month[] = {
|
||||
};
|
||||
|
||||
static const char sep1752[] = {
|
||||
1, 2, 14, 15, 16,
|
||||
1, 2, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23,
|
||||
24, 25, 26, 27, 28, 29, 30
|
||||
};
|
||||
@@ -89,6 +77,7 @@ static char *build_row(char *p, int *dp);
|
||||
#define J_WEEK_LEN (WEEK_LEN + 7)
|
||||
#define HEAD_SEP 2 /* spaces between day headings */
|
||||
|
||||
int cal_main(int argc, char **argv);
|
||||
int cal_main(int argc, char **argv)
|
||||
{
|
||||
struct tm *local_time;
|
||||
@@ -99,11 +88,7 @@ int cal_main(int argc, char **argv)
|
||||
char day_headings[28]; /* 28 for julian, 21 for nonjulian */
|
||||
char buf[40];
|
||||
|
||||
#ifdef CONFIG_LOCALE_SUPPORT
|
||||
setlocale(LC_TIME, "");
|
||||
#endif
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "jy");
|
||||
flags = getopt32(argc, argv, "jy");
|
||||
|
||||
julian = flags & 1;
|
||||
|
||||
@@ -124,9 +109,9 @@ int cal_main(int argc, char **argv)
|
||||
}
|
||||
} else {
|
||||
if (argc == 2) {
|
||||
month = bb_xgetularg10_bnd(*argv++, 1, 12);
|
||||
month = xatoul_range(*argv++, 1, 12);
|
||||
}
|
||||
year = bb_xgetularg10_bnd(*argv, 1, 9999);
|
||||
year = xatoul_range(*argv, 1, 9999);
|
||||
}
|
||||
|
||||
blank_string(day_headings, sizeof(day_headings) - 7 + 7*julian);
|
||||
@@ -135,7 +120,7 @@ int cal_main(int argc, char **argv)
|
||||
do {
|
||||
zero_tm.tm_mon = i;
|
||||
strftime(buf, sizeof(buf), "%B", &zero_tm);
|
||||
month_names[i] = bb_xstrdup(buf);
|
||||
month_names[i] = xstrdup(buf);
|
||||
|
||||
if (i < 7) {
|
||||
zero_tm.tm_wday = i;
|
||||
@@ -151,7 +136,7 @@ int cal_main(int argc, char **argv)
|
||||
|
||||
day_array(month, year, dp);
|
||||
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
|
||||
bb_printf("%*s%s\n%s\n",
|
||||
printf("%*s%s\n%s\n",
|
||||
((7*julian + WEEK_LEN) - len) / 2, "",
|
||||
lineout, day_headings);
|
||||
for (row = 0; row < 6; row++) {
|
||||
@@ -182,9 +167,9 @@ int cal_main(int argc, char **argv)
|
||||
center(month_names[month + 1], week_len, HEAD_SEP);
|
||||
}
|
||||
center(month_names[month + 2 - julian], week_len, 0);
|
||||
bb_printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings);
|
||||
printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings);
|
||||
if (!julian) {
|
||||
bb_printf("%*s%s", HEAD_SEP, "", day_headings);
|
||||
printf("%*s%s", HEAD_SEP, "", day_headings);
|
||||
}
|
||||
putchar('\n');
|
||||
for (row = 0; row < (6*7); row += 7) {
|
||||
@@ -198,7 +183,7 @@ int cal_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
bb_fflush_stdout_and_exit(0);
|
||||
fflush_stdout_and_exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -219,7 +204,7 @@ static void day_array(int month, int year, int *days)
|
||||
|
||||
if ((month == 9) && (year == 1752)) {
|
||||
size_t oday = 0;
|
||||
|
||||
|
||||
j_offset = julian * 244;
|
||||
do {
|
||||
days[oday+2] = sep1752[oday] + j_offset;
|
||||
@@ -293,7 +278,7 @@ static void center(char *str, int len, int separate)
|
||||
{
|
||||
int n = strlen(str);
|
||||
len -= n;
|
||||
bb_printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
|
||||
printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
|
||||
}
|
||||
|
||||
static void blank_string(char *buf, size_t buflen)
|
||||
|
||||
+17
-14
@@ -4,37 +4,40 @@
|
||||
*
|
||||
* Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file License in this tarball for details.
|
||||
* Licensed under GPLv2, see file License in this tarball for details.
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
|
||||
|
||||
#include "busybox.h"
|
||||
#include <unistd.h>
|
||||
|
||||
int cat_main(int argc, char **argv)
|
||||
int bb_cat(char **argv)
|
||||
{
|
||||
static const char *const argv_dash[] = { "-", NULL };
|
||||
FILE *f;
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
bb_getopt_ulflags(argc, argv, "u");
|
||||
|
||||
argv += optind;
|
||||
if (!*argv) {
|
||||
*--argv = "-";
|
||||
}
|
||||
if (!*argv) argv = (char**) &argv_dash;
|
||||
|
||||
do {
|
||||
if ((f = bb_wfopen_input(*argv)) != NULL) {
|
||||
int r = bb_copyfd_eof(fileno(f), STDOUT_FILENO);
|
||||
bb_fclose_nonstdin(f);
|
||||
if (r >= 0) {
|
||||
f = fopen_or_warn_stdin(*argv);
|
||||
if (f) {
|
||||
off_t r = bb_copyfd_eof(fileno(f), STDOUT_FILENO);
|
||||
fclose_if_not_stdin(f);
|
||||
if (r >= 0)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
retval = EXIT_FAILURE;
|
||||
} while (*++argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int cat_main(int argc, char **argv);
|
||||
int cat_main(int argc, char **argv)
|
||||
{
|
||||
getopt32(argc, argv, "u");
|
||||
argv += optind;
|
||||
return bb_cat(argv);
|
||||
}
|
||||
+25
-20
@@ -11,34 +11,37 @@
|
||||
* http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz */
|
||||
|
||||
#include "busybox.h"
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int catv_main(int argc, char **argv);
|
||||
int catv_main(int argc, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS, fd, flags;
|
||||
int retval = EXIT_SUCCESS, fd;
|
||||
unsigned flags;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "etv");
|
||||
flags ^= 4;
|
||||
|
||||
// Loop through files.
|
||||
flags = getopt32(argc, argv, "etv");
|
||||
#define CATV_OPT_e (1<<0)
|
||||
#define CATV_OPT_t (1<<1)
|
||||
#define CATV_OPT_v (1<<2)
|
||||
flags ^= CATV_OPT_v;
|
||||
|
||||
argv += optind;
|
||||
do {
|
||||
// Read from stdin if there's nothing else to do.
|
||||
|
||||
/* Read from stdin if there's nothing else to do. */
|
||||
fd = 0;
|
||||
if (*argv && 0>(fd = bb_xopen(*argv, O_RDONLY))) retval = EXIT_FAILURE;
|
||||
else for(;;) {
|
||||
if (*argv && 0 > (fd = xopen(*argv, O_RDONLY)))
|
||||
retval = EXIT_FAILURE;
|
||||
else for (;;) {
|
||||
int i, res;
|
||||
|
||||
res = read(fd, bb_common_bufsiz1, sizeof(bb_common_bufsiz1));
|
||||
if (res < 0) retval = EXIT_FAILURE;
|
||||
if (res <1) break;
|
||||
for (i=0; i<res; i++) {
|
||||
char c=bb_common_bufsiz1[i];
|
||||
if (res < 0)
|
||||
retval = EXIT_FAILURE;
|
||||
if (res < 1)
|
||||
break;
|
||||
for (i = 0; i < res; i++) {
|
||||
char c = bb_common_bufsiz1[i];
|
||||
|
||||
if (c > 126 && (flags & 4)) {
|
||||
if (c > 126 && (flags & CATV_OPT_v)) {
|
||||
if (c == 127) {
|
||||
printf("^?");
|
||||
continue;
|
||||
@@ -49,8 +52,9 @@ int catv_main(int argc, char **argv)
|
||||
}
|
||||
if (c < 32) {
|
||||
if (c == 10) {
|
||||
if (flags & 1) putchar('$');
|
||||
} else if (flags & (c==9 ? 2 : 4)) {
|
||||
if (flags & CATV_OPT_e)
|
||||
putchar('$');
|
||||
} else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) {
|
||||
printf("^%c", c+'@');
|
||||
continue;
|
||||
}
|
||||
@@ -58,8 +62,9 @@ int catv_main(int argc, char **argv)
|
||||
putchar(c);
|
||||
}
|
||||
}
|
||||
if (ENABLE_FEATURE_CLEAN_UP && fd) close(fd);
|
||||
if (ENABLE_FEATURE_CLEAN_UP && fd)
|
||||
close(fd);
|
||||
} while (*++argv);
|
||||
|
||||
return retval;
|
||||
fflush_stdout_and_exit(retval);
|
||||
}
|
||||
+11
-43
@@ -7,54 +7,22 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 defects - unsupported options -h, -H, -L, and -P. */
|
||||
/* BB_AUDIT GNU defects - unsupported options -h, -c, -f, -v, and long options. */
|
||||
/* BB_AUDIT Note: gnu chgrp does not support -H, -L, or -P. */
|
||||
/* BB_AUDIT SUSv3 defects - none? */
|
||||
/* BB_AUDIT GNU defects - unsupported long options. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Don't use lchown glibc older then 2.1.x */
|
||||
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
|
||||
#define lchown chown
|
||||
#endif
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (lchown(fileName, statbuf->st_uid, *((long *) junk)) == 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
bb_perror_msg("%s", fileName); /* Avoid multibyte problems. */
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chgrp_main(int argc, char **argv);
|
||||
int chgrp_main(int argc, char **argv)
|
||||
{
|
||||
long gid;
|
||||
int recursiveFlag;
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
recursiveFlag = bb_getopt_ulflags(argc, argv, "R");
|
||||
|
||||
if (argc - optind < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
argv += optind;
|
||||
|
||||
/* Find the selected group */
|
||||
gid = get_ug_id(*argv, bb_xgetgrnam);
|
||||
++argv;
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
do {
|
||||
if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, &gid)) {
|
||||
retval = EXIT_FAILURE;
|
||||
/* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */
|
||||
char **p = argv;
|
||||
while (*++p) {
|
||||
if (p[0][0] != '-') {
|
||||
p[0] = xasprintf(":%s", p[0]);
|
||||
break;
|
||||
}
|
||||
} while (*++argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
return chown_main(argc, argv);
|
||||
}
|
||||
+122
-54
@@ -11,81 +11,149 @@
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* BB_AUDIT GNU defects - unsupported options -c, -f, -v, and long options. */
|
||||
/* BB_AUDIT GNU defects - unsupported long options. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chmod.html */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
#define OPT_RECURSE (option_mask32 & 1)
|
||||
#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 2) SKIP_DESKTOP(0))
|
||||
#define OPT_CHANGED (USE_DESKTOP(option_mask32 & 4) SKIP_DESKTOP(0))
|
||||
#define OPT_QUIET (USE_DESKTOP(option_mask32 & 8) SKIP_DESKTOP(0))
|
||||
#define OPT_STR "R" USE_DESKTOP("vcf")
|
||||
|
||||
/* coreutils:
|
||||
* chmod never changes the permissions of symbolic links; the chmod
|
||||
* system call cannot change their permissions. This is not a problem
|
||||
* since the permissions of symbolic links are never used.
|
||||
* However, for each symbolic link listed on the command line, chmod changes
|
||||
* the permissions of the pointed-to file. In contrast, chmod ignores
|
||||
* symbolic links encountered during recursive directory traversals.
|
||||
*/
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* param, int depth)
|
||||
{
|
||||
if (!bb_parse_mode((char *)junk, &(statbuf->st_mode)))
|
||||
bb_error_msg_and_die( "invalid mode: %s", (char *)junk);
|
||||
if (chmod(fileName, statbuf->st_mode) == 0)
|
||||
return (TRUE);
|
||||
bb_perror_msg("%s", fileName); /* Avoid multibyte problems. */
|
||||
return (FALSE);
|
||||
mode_t newmode;
|
||||
|
||||
/* match coreutils behavior */
|
||||
if (depth == 0) {
|
||||
/* statbuf holds lstat result, but we need stat (follow link) */
|
||||
if (stat(fileName, statbuf))
|
||||
goto err;
|
||||
} else { /* depth > 0: skip links */
|
||||
if (S_ISLNK(statbuf->st_mode))
|
||||
return TRUE;
|
||||
}
|
||||
newmode = statbuf->st_mode;
|
||||
|
||||
if (!bb_parse_mode((char *)param, &newmode))
|
||||
bb_error_msg_and_die("invalid mode: %s", (char *)param);
|
||||
|
||||
if (chmod(fileName, newmode) == 0) {
|
||||
if (OPT_VERBOSE
|
||||
|| (OPT_CHANGED && statbuf->st_mode != newmode)
|
||||
) {
|
||||
printf("mode of '%s' changed to %04o (%s)\n", fileName,
|
||||
newmode & 07777, bb_mode_string(newmode)+1);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
err:
|
||||
if (!OPT_QUIET)
|
||||
bb_perror_msg("%s", fileName);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int chmod_main(int ATTRIBUTE_UNUSED argc, char **argv)
|
||||
int chmod_main(int argc, char **argv);
|
||||
int chmod_main(int argc, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
int recursiveFlag = FALSE;
|
||||
int count;
|
||||
char *arg, **argp;
|
||||
char *smode;
|
||||
char **p;
|
||||
char *p0;
|
||||
char opt = '-';
|
||||
|
||||
++argv;
|
||||
count = 0;
|
||||
|
||||
for (p = argv ; *p ; p++) {
|
||||
p0 = p[0];
|
||||
if (p0[0] == opt) {
|
||||
if ((p0[1] == '-') && !p0[2]) {
|
||||
opt = 0; /* Disable further option processing. */
|
||||
continue;
|
||||
}
|
||||
if (p0[1] == 'R') {
|
||||
char *s = p0 + 2;
|
||||
while (*s == 'R') {
|
||||
++s;
|
||||
}
|
||||
if (*s) {
|
||||
bb_show_usage();
|
||||
}
|
||||
recursiveFlag = TRUE;
|
||||
continue;
|
||||
}
|
||||
if (count) {
|
||||
bb_show_usage();
|
||||
}
|
||||
/* Convert first encountered -r into ar, -w into aw etc
|
||||
* so that getopt would not eat it */
|
||||
argp = argv;
|
||||
while ((arg = *++argp)) {
|
||||
/* Mode spec must be the first arg (sans -R etc) */
|
||||
/* (protect against mishandling e.g. "chmod 644 -r") */
|
||||
if (arg[0] != '-') {
|
||||
arg = NULL;
|
||||
break;
|
||||
}
|
||||
/* An option. Not a -- or valid option? */
|
||||
if (arg[1] && !strchr("-"OPT_STR, arg[1])) {
|
||||
arg[0] = 'a';
|
||||
break;
|
||||
}
|
||||
argv[count] = p0;
|
||||
++count;
|
||||
}
|
||||
|
||||
argv[count] = NULL;
|
||||
/* Parse options */
|
||||
opt_complementary = "-2";
|
||||
getopt32(argc, argv, ("-"OPT_STR) + 1); /* Reuse string */
|
||||
argv += optind;
|
||||
|
||||
if (count < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
smode = *argv;
|
||||
++argv;
|
||||
/* Restore option-like mode if needed */
|
||||
if (arg) arg[0] = '-';
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
smode = *argv++;
|
||||
do {
|
||||
if (! recursive_action (*argv, recursiveFlag, TRUE, FALSE,
|
||||
fileAction, fileAction, smode)) {
|
||||
if (!recursive_action(*argv,
|
||||
OPT_RECURSE, // recurse
|
||||
FALSE, // follow links: coreutils doesn't
|
||||
FALSE, // depth first
|
||||
fileAction, // file action
|
||||
fileAction, // dir action
|
||||
smode, // user data
|
||||
0) // depth
|
||||
) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
} while (*++argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
Security: chmod is too important and too subtle.
|
||||
This is a test script (busybox chmod versus coreutils).
|
||||
Run it in empty directory.
|
||||
|
||||
#!/bin/sh
|
||||
t1="/tmp/busybox chmod"
|
||||
t2="/usr/bin/chmod"
|
||||
create() {
|
||||
rm -rf $1; mkdir $1
|
||||
(
|
||||
cd $1 || exit 1
|
||||
mkdir dir
|
||||
>up
|
||||
>file
|
||||
>dir/file
|
||||
ln -s dir linkdir
|
||||
ln -s file linkfile
|
||||
ln -s ../up dir/up
|
||||
)
|
||||
}
|
||||
tst() {
|
||||
(cd test1; $t1 $1)
|
||||
(cd test2; $t2 $1)
|
||||
(cd test1; ls -lR) >out1
|
||||
(cd test2; ls -lR) >out2
|
||||
echo "chmod $1" >out.diff
|
||||
if ! diff -u out1 out2 >>out.diff; then exit 1; fi
|
||||
rm out.diff
|
||||
}
|
||||
echo "If script produced 'out.diff' file, then at least one testcase failed"
|
||||
create test1; create test2
|
||||
tst "a+w file"
|
||||
tst "a-w dir"
|
||||
tst "a+w linkfile"
|
||||
tst "a-w linkdir"
|
||||
tst "-R a+w file"
|
||||
tst "-R a-w dir"
|
||||
tst "-R a+w linkfile"
|
||||
tst "-R a-w linkdir"
|
||||
tst "a-r,a+x linkfile"
|
||||
*/
|
||||
+128
-39
@@ -7,72 +7,161 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 defects - unsupported options -h, -H, -L, and -P. */
|
||||
/* BB_AUDIT GNU defects - unsupported options -h, -c, -f, -v, and long options. */
|
||||
/* BB_AUDIT Note: gnu chown does not support -H, -L, or -P. */
|
||||
/* BB_AUDIT SUSv3 defects - none? */
|
||||
/* BB_AUDIT GNU defects - unsupported long options. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static uid_t uid = -1;
|
||||
static gid_t gid = -1;
|
||||
#define OPT_STR ("Rh" USE_DESKTOP("vcfLHP"))
|
||||
#define BIT_RECURSE 1
|
||||
#define OPT_RECURSE (option_mask32 & 1)
|
||||
#define OPT_NODEREF (option_mask32 & 2)
|
||||
#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 0x04) SKIP_DESKTOP(0))
|
||||
#define OPT_CHANGED (USE_DESKTOP(option_mask32 & 0x08) SKIP_DESKTOP(0))
|
||||
#define OPT_QUIET (USE_DESKTOP(option_mask32 & 0x10) SKIP_DESKTOP(0))
|
||||
/* POSIX options
|
||||
* -L traverse every symbolic link to a directory encountered
|
||||
* -H if a command line argument is a symbolic link to a directory, traverse it
|
||||
* -P do not traverse any symbolic links (default)
|
||||
* We do not conform to the following:
|
||||
* "Specifying more than one of -H, -L, and -P is not an error.
|
||||
* The last option specified shall determine the behavior of the utility." */
|
||||
/* -L */
|
||||
#define BIT_TRAVERSE 0x20
|
||||
#define OPT_TRAVERSE (USE_DESKTOP(option_mask32 & BIT_TRAVERSE) SKIP_DESKTOP(0))
|
||||
/* -H or -L */
|
||||
#define BIT_TRAVERSE_TOP (0x20|0x40)
|
||||
#define OPT_TRAVERSE_TOP (USE_DESKTOP(option_mask32 & BIT_TRAVERSE_TOP) SKIP_DESKTOP(0))
|
||||
|
||||
static int (*chown_func)(const char *, uid_t, gid_t) = chown;
|
||||
typedef int (*chown_fptr)(const char *, uid_t, gid_t);
|
||||
|
||||
static struct bb_uidgid_t ugid = { -1, -1 };
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf,
|
||||
void ATTRIBUTE_UNUSED *junk)
|
||||
void *cf, int depth)
|
||||
{
|
||||
if (!chown_func(fileName,
|
||||
(uid == (uid_t)-1) ? statbuf->st_uid : uid,
|
||||
(gid == (gid_t)-1) ? statbuf->st_gid : gid)) {
|
||||
uid_t u = (ugid.uid == (uid_t)-1) ? statbuf->st_uid : ugid.uid;
|
||||
gid_t g = (ugid.gid == (gid_t)-1) ? statbuf->st_gid : ugid.gid;
|
||||
|
||||
if (!((chown_fptr)cf)(fileName, u, g)) {
|
||||
if (OPT_VERBOSE
|
||||
|| (OPT_CHANGED && (statbuf->st_uid != u || statbuf->st_gid != g))
|
||||
) {
|
||||
printf("changed ownership of '%s' to %u:%u\n",
|
||||
fileName, (unsigned)u, (unsigned)g);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
bb_perror_msg("%s", fileName); /* A filename could have % in it... */
|
||||
if (!OPT_QUIET)
|
||||
bb_perror_msg("%s", fileName); /* A filename can have % in it... */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#define FLAG_R 1
|
||||
#define FLAG_h 2
|
||||
|
||||
int chown_main(int argc, char **argv);
|
||||
int chown_main(int argc, char **argv)
|
||||
{
|
||||
int flags;
|
||||
int retval = EXIT_SUCCESS;
|
||||
char *groupName;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "Rh");
|
||||
|
||||
if (flags & FLAG_h) chown_func = lchown;
|
||||
|
||||
if (argc - optind < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
chown_fptr chown_func;
|
||||
|
||||
opt_complementary = "-2";
|
||||
getopt32(argc, argv, OPT_STR);
|
||||
argv += optind;
|
||||
|
||||
/* First, check if there is a group name here */
|
||||
if ((groupName = strchr(*argv, '.')) == NULL) {
|
||||
groupName = strchr(*argv, ':');
|
||||
/* This matches coreutils behavior (almost - see below) */
|
||||
chown_func = chown;
|
||||
if (OPT_NODEREF
|
||||
/* || (OPT_RECURSE && !OPT_TRAVERSE_TOP): */
|
||||
USE_DESKTOP( || (option_mask32 & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
|
||||
) {
|
||||
chown_func = lchown;
|
||||
}
|
||||
|
||||
/* Check for the username and groupname */
|
||||
if (groupName) {
|
||||
*groupName++ = '\0';
|
||||
gid = get_ug_id(groupName, bb_xgetgrnam);
|
||||
}
|
||||
if (--groupName != *argv) uid = get_ug_id(*argv, bb_xgetpwnam);
|
||||
++argv;
|
||||
parse_chown_usergroup_or_die(&ugid, argv[0]);
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
argv++;
|
||||
do {
|
||||
if (! recursive_action (*argv, (flags & FLAG_R), FALSE, FALSE,
|
||||
fileAction, fileAction, NULL)) {
|
||||
char *arg = *argv;
|
||||
|
||||
if (OPT_TRAVERSE_TOP) {
|
||||
/* resolves symlink (even recursive) */
|
||||
arg = xmalloc_realpath(arg);
|
||||
if (!arg)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!recursive_action(arg,
|
||||
OPT_RECURSE, // recurse
|
||||
OPT_TRAVERSE, // follow links if -L
|
||||
FALSE, // depth first
|
||||
fileAction, // file action
|
||||
fileAction, // dir action
|
||||
chown_func, // user data
|
||||
0) // depth
|
||||
) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (OPT_TRAVERSE_TOP)
|
||||
free(arg);
|
||||
} while (*++argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
Testcase. Run in empty directory.
|
||||
|
||||
#!/bin/sh
|
||||
t1="/tmp/busybox chown"
|
||||
t2="/usr/bin/chown"
|
||||
create() {
|
||||
rm -rf $1; mkdir $1
|
||||
(
|
||||
cd $1 || exit 1
|
||||
mkdir dir dir2
|
||||
>up
|
||||
>file
|
||||
>dir/file
|
||||
>dir2/file
|
||||
ln -s dir linkdir
|
||||
ln -s file linkfile
|
||||
ln -s ../up dir/linkup
|
||||
ln -s ../dir2 dir/linkupdir2
|
||||
)
|
||||
chown -R 0:0 $1
|
||||
}
|
||||
tst() {
|
||||
create test1
|
||||
create test2
|
||||
(cd test1; $t1 $1)
|
||||
(cd test2; $t2 $1)
|
||||
(cd test1; ls -lnR) >out1
|
||||
(cd test2; ls -lnR) >out2
|
||||
echo "chown $1" >out.diff
|
||||
if ! diff -u out1 out2 >>out.diff; then exit 1; fi
|
||||
rm out.diff
|
||||
}
|
||||
tst_for_each() {
|
||||
tst "$1 1:1 file"
|
||||
tst "$1 1:1 dir"
|
||||
tst "$1 1:1 linkdir"
|
||||
tst "$1 1:1 linkfile"
|
||||
}
|
||||
echo "If script produced 'out.diff' file, then at least one testcase failed"
|
||||
# These match coreutils 6.8:
|
||||
tst_for_each ""
|
||||
tst_for_each "-R"
|
||||
tst_for_each "-RP"
|
||||
tst_for_each "-RL"
|
||||
tst_for_each "-RH"
|
||||
tst_for_each "-h"
|
||||
tst_for_each "-hR"
|
||||
tst_for_each "-hRP"
|
||||
# Below: with "chown linkdir" coreutils 6.8 will chown linkdir _target_,
|
||||
# we lchown _the link_. I believe we are "more correct".
|
||||
#tst_for_each "-hRL"
|
||||
#tst_for_each "-hRH"
|
||||
|
||||
*/
|
||||
+3
-6
@@ -9,12 +9,9 @@
|
||||
|
||||
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int chroot_main(int argc, char **argv);
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
@@ -25,7 +22,7 @@ int chroot_main(int argc, char **argv)
|
||||
if (chroot(*argv)) {
|
||||
bb_perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
bb_xchdir("/");
|
||||
xchdir("/");
|
||||
|
||||
++argv;
|
||||
if (argc == 2) {
|
||||
@@ -36,6 +33,6 @@ int chroot_main(int argc, char **argv)
|
||||
argv[1] = (char *) "-i";
|
||||
}
|
||||
|
||||
execvp(*argv, argv);
|
||||
BB_EXECVP(*argv, argv);
|
||||
bb_perror_msg_and_die("cannot execute %s", *argv);
|
||||
}
|
||||
+21
-22
@@ -3,53 +3,52 @@
|
||||
* cksum - calculate the CRC32 checksum of a file
|
||||
*
|
||||
* Copyright (C) 2006 by Rob Sullivan, with ideas from code by Walter Harms
|
||||
*
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details. */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int cksum_main(int argc, char **argv) {
|
||||
|
||||
uint32_t *crc32_table = bb_crc32_filltable(1);
|
||||
int cksum_main(int argc, char **argv);
|
||||
int cksum_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
uint32_t *crc32_table = crc32_filltable(1);
|
||||
|
||||
FILE *fp;
|
||||
uint32_t crc;
|
||||
long length, filesize;
|
||||
int bytes_read;
|
||||
char *cp;
|
||||
RESERVE_CONFIG_BUFFER(buf, BUFSIZ);
|
||||
|
||||
int inp_stdin = (argc == optind) ? 1 : 0;
|
||||
|
||||
|
||||
do {
|
||||
fp = bb_wfopen_input((inp_stdin) ? bb_msg_standard_input : *++argv);
|
||||
|
||||
fp = fopen_or_warn_stdin((inp_stdin) ? bb_msg_standard_input : *++argv);
|
||||
|
||||
crc = 0;
|
||||
length = 0;
|
||||
|
||||
while ((bytes_read = fread(buf, 1, BUFSIZ, fp)) > 0) {
|
||||
cp = buf;
|
||||
|
||||
while ((bytes_read = fread(bb_common_bufsiz1, 1, BUFSIZ, fp)) > 0) {
|
||||
cp = bb_common_bufsiz1;
|
||||
length += bytes_read;
|
||||
while (bytes_read--)
|
||||
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ (*cp++)) & 0xffL];
|
||||
}
|
||||
|
||||
|
||||
filesize = length;
|
||||
|
||||
|
||||
for (; length; length >>= 8)
|
||||
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xffL];
|
||||
crc ^= 0xffffffffL;
|
||||
|
||||
if (inp_stdin) {
|
||||
printf("%"PRIu32" %li\n", crc, filesize);
|
||||
printf("%" PRIu32 " %li\n", crc, filesize);
|
||||
break;
|
||||
}
|
||||
|
||||
printf("%"PRIu32" %li %s\n", crc, filesize, *argv);
|
||||
|
||||
printf("%" PRIu32 " %li %s\n", crc, filesize, *argv);
|
||||
fclose(fp);
|
||||
} while (*(argv+1));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
} while (*(argv + 1));
|
||||
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
+56
-47
@@ -21,60 +21,66 @@
|
||||
* in the '-l' case.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static FILE *cmp_xfopen_input(const char *filename)
|
||||
static FILE *cmp_xfopen_input(const char * const filename)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = bb_wfopen_input(filename)) != NULL) {
|
||||
fp = fopen_or_warn_stdin(filename);
|
||||
if (fp)
|
||||
return fp;
|
||||
}
|
||||
|
||||
exit(bb_default_error_retval); /* We already output an error message. */
|
||||
exit(xfunc_error_retval); /* We already output an error message. */
|
||||
}
|
||||
|
||||
static const char fmt_eof[] = "cmp: EOF on %s\n";
|
||||
static const char fmt_differ[] = "%s %s differ: char %d, line %d\n";
|
||||
// This fmt_l_opt uses gnu-isms. SUSv3 would be "%.0s%.0s%d %o %o\n"
|
||||
static const char fmt_l_opt[] = "%.0s%.0s%d %3o %3o\n";
|
||||
static const char fmt_differ[] = "%s %s differ: char %"OFF_FMT"d, line %d\n";
|
||||
// This fmt_l_opt uses gnu-isms. SUSv3 would be "%.0s%.0s%"OFF_FMT"d %o %o\n"
|
||||
static const char fmt_l_opt[] = "%.0s%.0s%"OFF_FMT"d %3o %3o\n";
|
||||
|
||||
static const char opt_chars[] = "sl";
|
||||
#define CMP_OPT_s (1<<0)
|
||||
#define CMP_OPT_l (1<<1)
|
||||
|
||||
enum {
|
||||
OPT_s = 1,
|
||||
OPT_l = 2
|
||||
};
|
||||
|
||||
int cmp_main(int argc, char **argv);
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp1, *fp2, *outfile = stdout;
|
||||
const char *filename1, *filename2;
|
||||
const char *filename1, *filename2 = "-";
|
||||
USE_DESKTOP(off_t skip1 = 0, skip2 = 0;)
|
||||
off_t char_pos = 0;
|
||||
int line_pos = 1; /* Hopefully won't overflow... */
|
||||
const char *fmt;
|
||||
int c1, c2, char_pos, line_pos;
|
||||
int opt_flags;
|
||||
int exit_val = 0;
|
||||
int c1, c2;
|
||||
unsigned opt;
|
||||
int retval = 0;
|
||||
|
||||
bb_default_error_retval = 2; /* 1 is returned if files are different. */
|
||||
xfunc_error_retval = 2; /* 1 is returned if files are different. */
|
||||
|
||||
opt_flags = bb_getopt_ulflags(argc, argv, opt_chars);
|
||||
opt_complementary = "?:-1"
|
||||
USE_DESKTOP(":?4")
|
||||
SKIP_DESKTOP(":?2")
|
||||
":l--s:s--l";
|
||||
opt = getopt32(argc, argv, opt_chars);
|
||||
argv += optind;
|
||||
|
||||
if ((opt_flags == 3) || (((unsigned int)(--argc - optind)) > 1)) {
|
||||
bb_show_usage();
|
||||
}
|
||||
filename1 = *argv;
|
||||
fp1 = cmp_xfopen_input(filename1);
|
||||
|
||||
fp1 = cmp_xfopen_input(filename1 = *(argv += optind));
|
||||
|
||||
filename2 = "-";
|
||||
if (*++argv) {
|
||||
filename2 = *argv;
|
||||
#if ENABLE_DESKTOP
|
||||
if (*++argv) {
|
||||
skip1 = XATOOFF(*argv);
|
||||
if (*++argv) {
|
||||
skip2 = XATOOFF(*argv);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
fp2 = cmp_xfopen_input(filename2);
|
||||
|
||||
if (fp1 == fp2) { /* Paranioa check... stdin == stdin? */
|
||||
fp2 = cmp_xfopen_input(filename2);
|
||||
if (fp1 == fp2) { /* Paranoia check... stdin == stdin? */
|
||||
/* Note that we don't bother reading stdin. Neither does gnu wc.
|
||||
* But perhaps we should, so that other apps down the chain don't
|
||||
* get the input. Consider 'echo hello | (cmp - - && cat -)'.
|
||||
@@ -82,19 +88,21 @@ int cmp_main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
fmt = fmt_differ;
|
||||
if (opt_flags == OPT_l) {
|
||||
if (opt & CMP_OPT_l)
|
||||
fmt = fmt_l_opt;
|
||||
}
|
||||
else
|
||||
fmt = fmt_differ;
|
||||
|
||||
char_pos = 0;
|
||||
line_pos = 1;
|
||||
#if ENABLE_DESKTOP
|
||||
while (skip1) { getc(fp1); skip1--; }
|
||||
while (skip2) { getc(fp2); skip2--; }
|
||||
#endif
|
||||
do {
|
||||
c1 = getc(fp1);
|
||||
c2 = getc(fp2);
|
||||
++char_pos;
|
||||
if (c1 != c2) { /* Remember -- a read error may have occurred. */
|
||||
exit_val = 1; /* But assume the files are different for now. */
|
||||
if (c1 != c2) { /* Remember: a read error may have occurred. */
|
||||
retval = 1; /* But assume the files are different for now. */
|
||||
if (c2 == EOF) {
|
||||
/* We know that fp1 isn't at EOF or in an error state. But to
|
||||
* save space below, things are setup to expect an EOF in fp1
|
||||
@@ -105,20 +113,21 @@ int cmp_main(int argc, char **argv)
|
||||
c1 = c2;
|
||||
}
|
||||
if (c1 == EOF) {
|
||||
bb_xferror(fp1, filename1);
|
||||
die_if_ferror(fp1, filename1);
|
||||
fmt = fmt_eof; /* Well, no error, so it must really be EOF. */
|
||||
outfile = stderr;
|
||||
/* There may have been output to stdout (option -l), so
|
||||
* make sure we fflush before writing to stderr. */
|
||||
bb_xfflush_stdout();
|
||||
xfflush_stdout();
|
||||
}
|
||||
if (opt_flags != OPT_s) {
|
||||
if (opt_flags == OPT_l) {
|
||||
if (!(opt & CMP_OPT_s)) {
|
||||
if (opt & CMP_OPT_l) {
|
||||
line_pos = c1; /* line_pos is unused in the -l case. */
|
||||
}
|
||||
bb_fprintf(outfile, fmt, filename1, filename2, char_pos, line_pos, c2);
|
||||
if (opt_flags) { /* This must be -l since not -s. */
|
||||
/* If we encountered and EOF, the while check will catch it. */
|
||||
fprintf(outfile, fmt, filename1, filename2, char_pos, line_pos, c2);
|
||||
if (opt) { /* This must be -l since not -s. */
|
||||
/* If we encountered an EOF,
|
||||
* the while check will catch it. */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -129,8 +138,8 @@ int cmp_main(int argc, char **argv)
|
||||
}
|
||||
} while (c1 != EOF);
|
||||
|
||||
bb_xferror(fp1, filename1);
|
||||
bb_xferror(fp2, filename2);
|
||||
die_if_ferror(fp1, filename1);
|
||||
die_if_ferror(fp2, filename2);
|
||||
|
||||
bb_fflush_stdout_and_exit(exit_val);
|
||||
fflush_stdout_and_exit(retval);
|
||||
}
|
||||
Loaded 100 of 855 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user