Compare commits
1212
Commits
1_4_stable
..
1_8_2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80297d5f0c | ||
|
|
3db254c886 | ||
|
|
6cee58e9cf | ||
|
|
360362dc57 | ||
|
|
06200348be | ||
|
|
bfc3d82256 | ||
|
|
681023650e | ||
|
|
b68979aefa | ||
|
|
9d1afdb571 | ||
|
|
9130340adf | ||
|
|
d059ddc1bb | ||
|
|
1641d614fa | ||
|
|
968dbf9685 | ||
|
|
dfc0740b04 | ||
|
|
15ca51e3e2 | ||
|
|
5a28a25b9d | ||
|
|
63430ae35a | ||
|
|
a59f435b5f | ||
|
|
7ab5e3dfcd | ||
|
|
78ee7c853a | ||
|
|
6fa3ab3cf1 | ||
|
|
e5387a0574 | ||
|
|
037576d77b | ||
|
|
99014e8965 | ||
|
|
a03945aa84 | ||
|
|
2edbc2ab85 | ||
|
|
aa7a888e42 | ||
|
|
85ff862753 | ||
|
|
1a7afb48da | ||
|
|
fcc569637b | ||
|
|
bc7c5d082e | ||
|
|
34cd7afc49 | ||
|
|
f74194e942 | ||
|
|
0363078437 | ||
|
|
73e5ed2206 | ||
|
|
740eae0585 | ||
|
|
e87b8689d2 | ||
|
|
9e23767ef5 | ||
|
|
0de37e10ed | ||
|
|
31acd1ba0a | ||
|
|
16e74b7464 | ||
|
|
aff3a306b8 | ||
|
|
5576136563 | ||
|
|
23c8128916 | ||
|
|
f472b237a1 | ||
|
|
686b0ef7d8 | ||
|
|
008eda2c54 | ||
|
|
2450c450ab | ||
|
|
10916c5c6b | ||
|
|
59d7c43dbe | ||
|
|
d898b8600c | ||
|
|
b6ccd32e3f | ||
|
|
6a9154b6f6 | ||
|
|
3f5fdc7572 | ||
|
|
be039374f3 | ||
|
|
4a4575686e | ||
|
|
9435993b01 | ||
|
|
be5a7b9655 | ||
|
|
ef3aabe906 | ||
|
|
77f1ec1b9b | ||
|
|
11c23d7b99 | ||
|
|
8add068573 | ||
|
|
2ea8c40e8f | ||
|
|
4f95e5aab8 | ||
|
|
f9566d8c29 | ||
|
|
15cb4a4272 | ||
|
|
9b49a5ed85 | ||
|
|
8d82cf72c9 | ||
|
|
52a4388d95 | ||
|
|
db60bcf1b7 | ||
|
|
724d196c75 | ||
|
|
82d38dab91 | ||
|
|
141750e388 | ||
|
|
88ce2748e4 | ||
|
|
42e418292d | ||
|
|
01f3b2c91a | ||
|
|
d19b87ece4 | ||
|
|
8d755adc1a | ||
|
|
e9fd69c8e8 | ||
|
|
d419a9f830 | ||
|
|
ac7d0e375e | ||
|
|
642a52d65e | ||
|
|
d62fd84d4b | ||
|
|
7930bcf736 | ||
|
|
5037b21478 | ||
|
|
41770226bb | ||
|
|
f545be083d | ||
|
|
def8898596 | ||
|
|
76a6b236a9 | ||
|
|
3240474c23 | ||
|
|
e747f62ed6 | ||
|
|
339936be00 | ||
|
|
23e3e25df6 | ||
|
|
91e5203205 | ||
|
|
91e80c2be7 | ||
|
|
226002ea74 | ||
|
|
d21f596ddb | ||
|
|
5dd8a03665 | ||
|
|
368a12efc2 | ||
|
|
ebeaea04dc | ||
|
|
d24d5c84c2 | ||
|
|
feb7ae7f01 | ||
|
|
0c97c9d437 | ||
|
|
d65ea39ffc | ||
|
|
ff0976248a | ||
|
|
8412d7959a | ||
|
|
a0898170d8 | ||
|
|
96e1b38586 | ||
|
|
deabacdf91 | ||
|
|
d7b3350eb3 | ||
|
|
5fb09656ca | ||
|
|
a4f4de9b7e | ||
|
|
605b20e277 | ||
|
|
1eecaf26b0 | ||
|
|
e03c77fe15 | ||
|
|
f60d62638b | ||
|
|
64e619c0c8 | ||
|
|
304a97a1ec | ||
|
|
72e1c89d97 | ||
|
|
2450e4ba44 | ||
|
|
1ebd0a6d91 | ||
|
|
66bbfbd581 | ||
|
|
3d2a9217a7 | ||
|
|
ab8c9378c9 | ||
|
|
6081868ee3 | ||
|
|
e918e155ed | ||
|
|
0afdfdf649 | ||
|
|
920c52a5c8 | ||
|
|
a0ad43b80b | ||
|
|
a7bc9ac8f8 | ||
|
|
b925605441 | ||
|
|
c3122bca53 | ||
|
|
0d3c6afc93 | ||
|
|
8607677529 | ||
|
|
1d31f0f380 | ||
|
|
78e2d4e361 | ||
|
|
a36535b067 | ||
|
|
6124c37135 | ||
|
|
7c654ae9df | ||
|
|
892536f019 | ||
|
|
4daad9004d | ||
|
|
1acdc89e99 | ||
|
|
86b29ea9e8 | ||
|
|
33b900f984 | ||
|
|
5d61e71c3a | ||
|
|
c9dc2ac578 | ||
|
|
a619b85ef5 | ||
|
|
b042bd9514 | ||
|
|
dd5e11bb05 | ||
|
|
7ae209c019 | ||
|
|
137fbe495d | ||
|
|
3982407ba4 | ||
|
|
4dd4e6d6b9 | ||
|
|
6a5377ac14 | ||
|
|
ea7645bab6 | ||
|
|
35465a3f00 | ||
|
|
d9391b15f1 | ||
|
|
a545726d2b | ||
|
|
d9c6a001e3 | ||
|
|
e9b3321b9f | ||
|
|
86e0a22ec6 | ||
|
|
46a530626d | ||
|
|
818322b9b1 | ||
|
|
a7ce207bd8 | ||
|
|
47ddd01b3c | ||
|
|
7710563858 | ||
|
|
06783a5140 | ||
|
|
512a545f0d | ||
|
|
2a1d024333 | ||
|
|
06b3cc2811 | ||
|
|
32a471e4db | ||
|
|
9a4e08eaa8 | ||
|
|
73f56bb76d | ||
|
|
3a252b8c12 | ||
|
|
23856ab8e6 | ||
|
|
f588f70b91 | ||
|
|
f34e821572 | ||
|
|
7b70d78de8 | ||
|
|
f431017535 | ||
|
|
bcceb0c5a4 | ||
|
|
fc5d15912c | ||
|
|
707669501f | ||
|
|
efd3f38f8c | ||
|
|
0beaff8c19 | ||
|
|
9b0a439f02 | ||
|
|
27bd8d7146 | ||
|
|
2535f12cf2 | ||
|
|
32eb1f6cb9 | ||
|
|
a9335eafcf | ||
|
|
fa05074eee | ||
|
|
976690afe0 | ||
|
|
a2f61012b6 | ||
|
|
ac074b3f87 | ||
|
|
04ea11b033 | ||
|
|
476b070036 | ||
|
|
bf8fcaceb7 | ||
|
|
4d7605af86 | ||
|
|
4c1d88daff | ||
|
|
e7c1ad1540 | ||
|
|
ff6e8e2974 | ||
|
|
9382b3809b | ||
|
|
c8d4d2f11d | ||
|
|
d7ecd863c8 | ||
|
|
87f3b26b3a | ||
|
|
40f0bcf9d3 | ||
|
|
dcf9bba3b7 | ||
|
|
fdf9060aa3 | ||
|
|
cef23e0d8b | ||
|
|
3638cc4462 | ||
|
|
211f7f88ae | ||
|
|
beffd43d8e | ||
|
|
7e0fbf9c26 | ||
|
|
f0000653e9 | ||
|
|
21b83cfb27 | ||
|
|
82f3b16713 | ||
|
|
9862e6b056 | ||
|
|
fc202427d5 | ||
|
|
d2bb2d3918 | ||
|
|
8d91c13df5 | ||
|
|
7bc5360bba | ||
|
|
05241802a7 | ||
|
|
fc1e9951c6 | ||
|
|
8bdba4d011 | ||
|
|
fb48f6c982 | ||
|
|
76c476f817 | ||
|
|
b308d81e92 | ||
|
|
7d8de4d55d | ||
|
|
0f214ecef0 | ||
|
|
8a5fab6333 | ||
|
|
512499c8ca | ||
|
|
ec9781d5e4 | ||
|
|
614aca61e5 | ||
|
|
6dd333dfe6 | ||
|
|
30bab71f7b | ||
|
|
737d131e5e | ||
|
|
5222677176 | ||
|
|
6666ac42a5 | ||
|
|
2062fc4155 | ||
|
|
6a7b7ce23e | ||
|
|
3d829627fb | ||
|
|
cab774d6e5 | ||
|
|
46fc23b532 | ||
|
|
30f00a4286 | ||
|
|
66dc9068eb | ||
|
|
e1022a9d6a | ||
|
|
f87f495e65 | ||
|
|
028f2d651c | ||
|
|
6ee023cf62 | ||
|
|
de4c5d3d8c | ||
|
|
c6c2345ca6 | ||
|
|
5750782fca | ||
|
|
7642998190 | ||
|
|
72b6a65b2f | ||
|
|
d6e81c7762 | ||
|
|
18f2a6bc5e | ||
|
|
f7d9e84bc5 | ||
|
|
e58e8d9444 | ||
|
|
45946f8b51 | ||
|
|
63db27f9f4 | ||
|
|
3f1123103c | ||
|
|
d867f32a7a | ||
|
|
921799da4e | ||
|
|
37c3316fd7 | ||
|
|
52e15dc50b | ||
|
|
f9000c51db | ||
|
|
d37f22225b | ||
|
|
b9c02dd791 | ||
|
|
fe7cd642b0 | ||
|
|
d6cd9d7fe9 | ||
|
|
367960ba9a | ||
|
|
9611cb1215 | ||
|
|
a27a11bb2c | ||
|
|
b98c26ad68 | ||
|
|
feac3ce8c0 | ||
|
|
073214f894 | ||
|
|
91adf7d587 | ||
|
|
e45af73dc2 | ||
|
|
241b1567ad | ||
|
|
1b97efd66a | ||
|
|
72d260dbda | ||
|
|
856be770a6 | ||
|
|
7f175ccbc3 | ||
|
|
06b064c28d | ||
|
|
838dacaa00 | ||
|
|
f848305afc | ||
|
|
a0319ba936 | ||
|
|
6a2f7f41cf | ||
|
|
033e592cbc | ||
|
|
ab9c44b1a4 | ||
|
|
bb23c06919 | ||
|
|
9f7b92a2e1 | ||
|
|
384b1d12f9 | ||
|
|
0372f0f199 | ||
|
|
3d17d2b430 | ||
|
|
dbe6e66d6a | ||
|
|
a1120a8ea2 | ||
|
|
3952f20c24 | ||
|
|
08294dbf5b | ||
|
|
319f8ebef8 | ||
|
|
f5635f4d32 | ||
|
|
e324184c05 | ||
|
|
5f1b149d54 | ||
|
|
1b9064d535 | ||
|
|
ff65cd469b | ||
|
|
6ca409e0e4 | ||
|
|
4185548984 | ||
|
|
1ec15cd818 | ||
|
|
e5d37ccb6e | ||
|
|
f893da875a | ||
|
|
501bfe2630 | ||
|
|
22a80d1e7d | ||
|
|
e5dbba22af | ||
|
|
4661117911 | ||
|
|
eea72123a3 | ||
|
|
8e209c3787 | ||
|
|
73f21e9cb3 | ||
|
|
8274e06677 | ||
|
|
e013475830 | ||
|
|
84d71f33f5 | ||
|
|
46340e398e | ||
|
|
0e2c9fb4e0 | ||
|
|
f223efbcde | ||
|
|
9a3b7b1db7 | ||
|
|
80edead5ea | ||
|
|
c01af95c39 | ||
|
|
1caca34aa6 | ||
|
|
fc77eb54e7 | ||
|
|
a1b16f4d5c | ||
|
|
f1f1b69dc1 | ||
|
|
980864de08 | ||
|
|
2b03e5ef31 | ||
|
|
6b74b0241c | ||
|
|
dee82b6b78 | ||
|
|
1bab1de698 | ||
|
|
f868963c67 | ||
|
|
7587870617 | ||
|
|
1d10aaf116 | ||
|
|
3734b946bf | ||
|
|
661f6fad77 | ||
|
|
972fa099e6 | ||
|
|
7ce7594fa3 | ||
|
|
f4cee7a174 | ||
|
|
990d0f63ee | ||
|
|
bcb66ec22e | ||
|
|
1da77728d7 | ||
|
|
3e64e98570 | ||
|
|
65b8cfb2a0 | ||
|
|
64a8a3bd74 | ||
|
|
5bfcb4d5ae | ||
|
|
bdc88fdc68 | ||
|
|
9fe9c1a6d8 | ||
|
|
397137b815 | ||
|
|
845db2acf3 | ||
|
|
b71c668c57 | ||
|
|
82bd9ee645 | ||
|
|
6cd84dac84 | ||
|
|
e8feca085d | ||
|
|
091965768d | ||
|
|
557fb713e0 | ||
|
|
1ec5eaecba | ||
|
|
21d1014b5b | ||
|
|
2f6ae43b9c | ||
|
|
2a86a61c27 | ||
|
|
2414a96faa | ||
|
|
b69e872229 | ||
|
|
d4293c77f1 | ||
|
|
de1c8b2e92 | ||
|
|
960eca66b5 | ||
|
|
af1bd09625 | ||
|
|
b78c782c85 | ||
|
|
91afdf8096 | ||
|
|
a3d15c8be7 | ||
|
|
27da707d06 | ||
|
|
eaabf0675f | ||
|
|
2851082d5d | ||
|
|
49a128a156 | ||
|
|
150d2fa114 | ||
|
|
c5f2426838 | ||
|
|
110967a6f7 | ||
|
|
24c5fbaf42 | ||
|
|
c1166c3a8c | ||
|
|
9109fbeaa1 | ||
|
|
4652daace9 | ||
|
|
8d5aa870a6 | ||
|
|
bdc406d15d | ||
|
|
39125bec38 | ||
|
|
59a1f30450 | ||
|
|
fb79a2e2cf | ||
|
|
fcfaf2e18a | ||
|
|
8fdc4b7b06 | ||
|
|
40ba9984fd | ||
|
|
153cd695e4 | ||
|
|
828e2a95da | ||
|
|
8cc9cb8bc5 | ||
|
|
d611cccd81 | ||
|
|
c540e75d74 | ||
|
|
d166f83d74 | ||
|
|
42b3dea9bf | ||
|
|
54e19da86d | ||
|
|
a48369183b | ||
|
|
e190c16636 | ||
|
|
3483e85f6b | ||
|
|
10aea3e84e | ||
|
|
c6753c1666 | ||
|
|
679b41237c | ||
|
|
4b9b0ced30 | ||
|
|
99fcc62523 | ||
|
|
aba7f49a22 | ||
|
|
e6bce979bf | ||
|
|
c82b5108e1 | ||
|
|
dc7a5eae36 | ||
|
|
16b7cb455d | ||
|
|
98ebab8b76 | ||
|
|
8b1409896d | ||
|
|
dc757aa16c | ||
|
|
f7d07b1723 | ||
|
|
42ee26d00c | ||
|
|
ae7f7ebcb7 | ||
|
|
12d2129d50 | ||
|
|
c965f4b141 | ||
|
|
e8240f19bd | ||
|
|
1fc6238ffa | ||
|
|
80b8b39899 | ||
|
|
1399282b47 | ||
|
|
88308fec80 | ||
|
|
56258b688c | ||
|
|
198badafd8 | ||
|
|
118b81df76 | ||
|
|
2ee028dd5b | ||
|
|
b304eadca8 | ||
|
|
d67a606489 | ||
|
|
931de892cc | ||
|
|
a80b4a0fa7 | ||
|
|
9a33780152 | ||
|
|
b7e61485d6 | ||
|
|
789b87edf5 | ||
|
|
833358798a | ||
|
|
88976d00d8 | ||
|
|
14923db72f | ||
|
|
cd0e80ce90 | ||
|
|
7510384107 | ||
|
|
761ce14fd2 | ||
|
|
ee921393a5 | ||
|
|
bb0baed564 | ||
|
|
bb98db2ed2 | ||
|
|
5ad1048c3d | ||
|
|
a19faf8bb7 | ||
|
|
dcf6de552a | ||
|
|
5b5bcf24f5 | ||
|
|
31789a81d5 | ||
|
|
362c6ec694 | ||
|
|
3afac4ce06 | ||
|
|
08a61180ce | ||
|
|
2d25491ed0 | ||
|
|
a61cb92f2d | ||
|
|
6d9ea24611 | ||
|
|
1b16bdaebf | ||
|
|
91e149a373 | ||
|
|
2c91efb7c2 | ||
|
|
7679145cfa | ||
|
|
ebd27aabaa | ||
|
|
bd7bb299c0 | ||
|
|
459be35234 | ||
|
|
e79dd06782 | ||
|
|
787d92645b | ||
|
|
ea9e798004 | ||
|
|
a6163ca355 | ||
|
|
ab47eeee6a | ||
|
|
85532fc4d4 | ||
|
|
a7825f269d | ||
|
|
7b72fc1200 | ||
|
|
53a0e97196 | ||
|
|
b941129ccb | ||
|
|
d786cc5966 | ||
|
|
be99243945 | ||
|
|
867266059b | ||
|
|
432d69cb41 | ||
|
|
0e0639b702 | ||
|
|
d8540f71ac | ||
|
|
1adf681e87 | ||
|
|
26017b1b04 | ||
|
|
1fd46215b2 | ||
|
|
a6691317e5 | ||
|
|
ca525b4f24 | ||
|
|
b51fd3525e | ||
|
|
a78ef2ccf1 | ||
|
|
d67cef2425 | ||
|
|
f5f75c5e82 | ||
|
|
f312e32662 | ||
|
|
637c975098 | ||
|
|
3ad5d0cbbe | ||
|
|
fdcbc4e709 | ||
|
|
15611bb958 | ||
|
|
16d58d75ee | ||
|
|
cc5e090f12 | ||
|
|
aa198dd39c | ||
|
|
745119605e | ||
|
|
d71e45856e | ||
|
|
a7c5d2c6d9 | ||
|
|
b1e5addfed | ||
|
|
5a65447e30 | ||
|
|
e8a0788b24 | ||
|
|
d4fea900bd | ||
|
|
77e44d60e6 | ||
|
|
66db264a5f | ||
|
|
d6766c71a9 | ||
|
|
9acfed2d14 | ||
|
|
65e14b4588 | ||
|
|
bdbbb7ec49 | ||
|
|
c14d39e83a | ||
|
|
def8260219 | ||
|
|
42bffbf360 | ||
|
|
dc4ab54ea7 | ||
|
|
89bca27158 | ||
|
|
8936a19880 | ||
|
|
bb4b9f1fc9 | ||
|
|
e16e6e79e4 | ||
|
|
4b49512881 | ||
|
|
1622cb8cea | ||
|
|
e8b2bd4d47 | ||
|
|
ae5a8aac26 | ||
|
|
c084d2f205 | ||
|
|
0696b8aae8 | ||
|
|
cd0df46d8c | ||
|
|
5c51a7ca52 | ||
|
|
6c501a71ae | ||
|
|
fa5f20755c | ||
|
|
746204b1b8 | ||
|
|
8c1aaf3297 | ||
|
|
3c8b5ba8e8 | ||
|
|
ef4bb26f93 | ||
|
|
821cc25f43 | ||
|
|
74324c8666 | ||
|
|
4e5f82c76f | ||
|
|
dd6e1f0deb | ||
|
|
3f22b7f718 | ||
|
|
a0d7508748 | ||
|
|
fdcfa2aba7 | ||
|
|
342b0ab945 | ||
|
|
9a7d38fe24 | ||
|
|
fad2b86c9e | ||
|
|
c2f011aa03 | ||
|
|
22a9a3c6f8 | ||
|
|
a1d24a0b6e | ||
|
|
199c0d542b | ||
|
|
0b3b41b62a | ||
|
|
27f79ff03d | ||
|
|
4b924f3a5c | ||
|
|
4ef7d3a2de | ||
|
|
fe3e1776ad | ||
|
|
1c9ad62d26 | ||
|
|
b6adbf1be2 | ||
|
|
5a6aeddfa7 | ||
|
|
6239b1f50a | ||
|
|
ba7cf260fd | ||
|
|
0a83fc3984 | ||
|
|
201c72a8d6 | ||
|
|
28c0f0f4fe | ||
|
|
d76c049cc4 | ||
|
|
163a855731 | ||
|
|
5a1437d835 | ||
|
|
cd7f4d27a2 | ||
|
|
2b6bbad4db | ||
|
|
0fe67b16ce | ||
|
|
b055001b6a | ||
|
|
90e485ce79 | ||
|
|
1744cb1861 | ||
|
|
170435c575 | ||
|
|
1a7358612f | ||
|
|
94dace3016 | ||
|
|
6963eb53a1 | ||
|
|
0681033918 | ||
|
|
8805eeb44a | ||
|
|
219e88d050 | ||
|
|
004baba2d6 | ||
|
|
262d765351 | ||
|
|
14b5dd9943 | ||
|
|
fe52a74ecf | ||
|
|
46846e25a4 | ||
|
|
38ec147a18 | ||
|
|
6d709972cd | ||
|
|
4500c58a07 | ||
|
|
d9b5ab868c | ||
|
|
78e48b2c2c | ||
|
|
ffba941d29 | ||
|
|
5b34083004 | ||
|
|
cd5c7866e3 | ||
|
|
c8be5ee325 | ||
|
|
b6a741ffa7 | ||
|
|
96f67dc69d | ||
|
|
d46e6d1a55 | ||
|
|
a35958d4ad | ||
|
|
c666f71e3b | ||
|
|
831dcc439c | ||
|
|
c29903221d | ||
|
|
3e7b0e6120 | ||
|
|
1f4cf517f5 | ||
|
|
8f6bdb42df | ||
|
|
418a7fb29b | ||
|
|
c2b3e370d6 | ||
|
|
64332bf857 | ||
|
|
d6050949b8 | ||
|
|
764d59d488 | ||
|
|
03eb8bf6ce | ||
|
|
602d13cba5 | ||
|
|
119b995437 | ||
|
|
3e9aaae5dc | ||
|
|
e0a336747c | ||
|
|
53079d494e | ||
|
|
2b54aaa9bf | ||
|
|
389f9d52d5 | ||
|
|
57bf668d11 | ||
|
|
68de720723 | ||
|
|
8465a99ce7 | ||
|
|
bf678d5423 | ||
|
|
a035e9f1a9 | ||
|
|
a04561f5f7 | ||
|
|
7e84e539de | ||
|
|
92c0b8222e | ||
|
|
0cacc80952 | ||
|
|
02f47e9f81 | ||
|
|
21f0d4c55e | ||
|
|
b952835efe | ||
|
|
dd4cb2b31e | ||
|
|
a6c467f6d1 | ||
|
|
734e5ebc93 | ||
|
|
ac0e5ab96a | ||
|
|
3349fc4da9 | ||
|
|
400c5b6fc6 | ||
|
|
6e6d331d97 | ||
|
|
f71d916b60 | ||
|
|
e725bfe6e0 | ||
|
|
f2fffd0014 | ||
|
|
3bc18253b0 | ||
|
|
f92df58d3d | ||
|
|
3c82e48923 | ||
|
|
eda43d7f45 | ||
|
|
d01ff13454 | ||
|
|
dd999a2241 | ||
|
|
bd100b7478 | ||
|
|
4ac530c0ef | ||
|
|
ef36ead370 | ||
|
|
dcf4de20a1 | ||
|
|
f20de5bb42 | ||
|
|
d4728145e3 | ||
|
|
08c8c1d3b3 | ||
|
|
e3f2f89891 | ||
|
|
b81b3df1fa | ||
|
|
0937be5fa6 | ||
|
|
b5eaabb322 | ||
|
|
3ac0e00553 | ||
|
|
18e19f2b0d | ||
|
|
a6a1785a30 | ||
|
|
706fdc98c3 | ||
|
|
1359da6ac7 | ||
|
|
762d35c75f | ||
|
|
52881e9f23 | ||
|
|
2f1bb36a55 | ||
|
|
87cb2db703 | ||
|
|
54e7ffb3a4 | ||
|
|
5f786c24e4 | ||
|
|
f6250a3bee | ||
|
|
d1801a4430 | ||
|
|
9ace613406 | ||
|
|
05a6d9cbb2 | ||
|
|
8581863a1b | ||
|
|
516a0ca2dc | ||
|
|
c34d35557b | ||
|
|
3ace9fa6d8 | ||
|
|
088b959d00 | ||
|
|
2ace1e3f07 | ||
|
|
55b2de71d7 | ||
|
|
517d1aac7f | ||
|
|
198714c0dd | ||
|
|
7d4c44e1b1 | ||
|
|
ac678ec2f1 | ||
|
|
17e3c34aa7 | ||
|
|
bc9d7d788b | ||
|
|
ab51bf4e28 | ||
|
|
e468ef27b7 | ||
|
|
0922192740 | ||
|
|
84f75b0b94 | ||
|
|
8acf521432 | ||
|
|
be1a9d4237 | ||
|
|
91de7c0328 | ||
|
|
58394b1e29 | ||
|
|
e471275813 | ||
|
|
5f9468e996 | ||
|
|
8a28e620ce | ||
|
|
bf3561fd15 | ||
|
|
f5294e1f4c | ||
|
|
16abcd90ae | ||
|
|
334fa9bcb5 | ||
|
|
87468857f6 | ||
|
|
f7fcca4af7 | ||
|
|
1d6a4aec2c | ||
|
|
fbf6dea5a2 | ||
|
|
f03dbeda90 | ||
|
|
b636d8c18c | ||
|
|
beaca811e4 | ||
|
|
62f0479cf1 | ||
|
|
945bd3dee8 | ||
|
|
3211adc184 | ||
|
|
3a62a737f7 | ||
|
|
b69f35effe | ||
|
|
7cced6e574 | ||
|
|
0de3c55b42 | ||
|
|
831a20f512 | ||
|
|
c98c31783c | ||
|
|
b290889f02 | ||
|
|
51742f4bb0 | ||
|
|
50f7f446ec | ||
|
|
d7c8196c1b | ||
|
|
8fd371276f | ||
|
|
6398cf477d | ||
|
|
e4f2d064b0 | ||
|
|
12c96a64a4 | ||
|
|
0d058361e7 | ||
|
|
03fc408de6 | ||
|
|
d571c08c25 | ||
|
|
473dae080a | ||
|
|
f1a7141cfc | ||
|
|
80d14beae9 | ||
|
|
8905496444 | ||
|
|
c6758a07c6 | ||
|
|
335b63d8d1 | ||
|
|
07c394e69b | ||
|
|
99003b8a87 | ||
|
|
f73cac8d3d | ||
|
|
e87d7955f8 | ||
|
|
51f7ab6162 | ||
|
|
246b5c3916 | ||
|
|
b38cf3ff8a | ||
|
|
a9d7d24e1f | ||
|
|
99912ca733 | ||
|
|
ff131b980d | ||
|
|
163516da3a | ||
|
|
de17ece1db | ||
|
|
8b1fab2879 | ||
|
|
7e8a53a335 | ||
|
|
3f3aa2a57d | ||
|
|
cd7001f705 | ||
|
|
1b4b2cb20e | ||
|
|
53d445aa75 | ||
|
|
7e754f12d3 | ||
|
|
2dfdd44d9d | ||
|
|
c44ab01b75 | ||
|
|
95cb3263ae | ||
|
|
32b633aa3f | ||
|
|
786834bcee | ||
|
|
240a1cfbbe | ||
|
|
5694d5f8d2 | ||
|
|
8d9f495d68 | ||
|
|
b04b4357ff | ||
|
|
bbd695d801 | ||
|
|
ca3484103e | ||
|
|
1ae63fc1bc | ||
|
|
9c146a91d3 | ||
|
|
fdf63a30fe | ||
|
|
540a2a1f3b | ||
|
|
fbd2918f5c | ||
|
|
bb5b01c7c7 | ||
|
|
04c99ebb4f | ||
|
|
19507f0869 | ||
|
|
5a30d59c3d | ||
|
|
bf295dd5b6 | ||
|
|
df5bbb938a | ||
|
|
1bb552b1d9 | ||
|
|
9020d850bf | ||
|
|
c7b10dc037 | ||
|
|
2f7b923f5c | ||
|
|
5f42d26865 | ||
|
|
29fe7265b8 | ||
|
|
00c2c4868a | ||
|
|
45aebfd32d | ||
|
|
2e75dcc80d | ||
|
|
6d79dd66cb | ||
|
|
bdd253e450 | ||
|
|
7d6c9296e7 | ||
|
|
56fce00fc7 | ||
|
|
febe3c4211 | ||
|
|
d9c2d5fe4f | ||
|
|
10aed96f14 | ||
|
|
24efe4f15f | ||
|
|
1ca332b367 | ||
|
|
2a47dea263 | ||
|
|
3a60244ae9 | ||
|
|
0e6ab01c5a | ||
|
|
794687947f | ||
|
|
64a15124e7 | ||
|
|
02fd66885c | ||
|
|
b933ac1e25 | ||
|
|
992e05b6f0 | ||
|
|
cea0a8bccb | ||
|
|
8025afad8a | ||
|
|
3c5929a53b | ||
|
|
adb01b1583 | ||
|
|
729bd9e0b0 | ||
|
|
b05a939bcc | ||
|
|
60fadaca28 | ||
|
|
57a426b15b | ||
|
|
ba2fb719b9 | ||
|
|
2856dab477 | ||
|
|
f443bffd3c | ||
|
|
6fa8b8e17f | ||
|
|
9eb51ad6b9 | ||
|
|
ae47cd1da7 | ||
|
|
4caa09a782 | ||
|
|
666c40c9fc | ||
|
|
7b881c7168 | ||
|
|
cc890264d9 | ||
|
|
eceecea568 | ||
|
|
52a9db6bb8 | ||
|
|
2e723237c9 | ||
|
|
53f83d68fb | ||
|
|
5e43d8591b | ||
|
|
a87ed2c716 | ||
|
|
307d27df4f | ||
|
|
557b458767 | ||
|
|
32773aca55 | ||
|
|
3e816c1252 | ||
|
|
3d43edb28c | ||
|
|
c7d4b98cbd | ||
|
|
45cd089df1 | ||
|
|
450196c119 | ||
|
|
b7cffd4bed | ||
|
|
0a537a0c57 | ||
|
|
0864f4d14f | ||
|
|
58a275b303 | ||
|
|
0eec4abb13 | ||
|
|
7c282a2078 | ||
|
|
f1ba749509 | ||
|
|
6a5598c2bc | ||
|
|
ebf48bb80c | ||
|
|
10457b90db | ||
|
|
f4d40c87d3 | ||
|
|
3983bd5593 | ||
|
|
17a1526f9e | ||
|
|
91dd275f05 | ||
|
|
576de34d1c | ||
|
|
afa7023b46 | ||
|
|
4e1361a481 | ||
|
|
b813eaff23 | ||
|
|
53091ecd20 | ||
|
|
ec1a4b5a52 | ||
|
|
af1c84360f | ||
|
|
5a142025d3 | ||
|
|
bb7fcb4229 | ||
|
|
f62c6fa1ca | ||
|
|
cd43dfdeec | ||
|
|
cad04ef4f3 | ||
|
|
10f8f5f443 | ||
|
|
55f30b05ac | ||
|
|
c0415a9833 | ||
|
|
8a503be840 | ||
|
|
7695328575 | ||
|
|
219d14d514 | ||
|
|
644849a3aa | ||
|
|
1fc6e56684 | ||
|
|
5b27fbe990 | ||
|
|
b5b45a91f0 | ||
|
|
d3bac03988 | ||
|
|
9067f13be0 | ||
|
|
1b6fa4c57c | ||
|
|
ce074df814 | ||
|
|
7d10823f6a | ||
|
|
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 |
No files matched your search
@@ -95,7 +95,7 @@ Stephan Linz <linz@li-pro.net>
|
||||
John Lombardo <john@deltanet.com>
|
||||
tr
|
||||
|
||||
Glenn McGrath <bug1@iinet.net.au>
|
||||
Glenn McGrath <glenn.l.mcgrath@gmail.com>
|
||||
Common unarchiving code and unarchiving applets, ifupdown, ftpgetput,
|
||||
nameif, sed, patch, fold, install, uudecode.
|
||||
Various bugfixes, review and apply numerous patches.
|
||||
|
||||
@@ -101,8 +101,7 @@ config FEATURE_INSTALLER
|
||||
help
|
||||
Enable 'busybox --install [-s]' support. This will allow you to use
|
||||
busybox at runtime to create hard links or symlinks for all the
|
||||
applets that are compiled into busybox. This feature requires the
|
||||
/proc filesystem.
|
||||
applets that are compiled into busybox.
|
||||
|
||||
config LOCALE_SUPPORT
|
||||
bool "Enable locale support (system needs locale for this to work)"
|
||||
@@ -141,6 +140,13 @@ config FEATURE_CLEAN_UP
|
||||
Don't enable this unless you have a really good reason to clean
|
||||
things up manually.
|
||||
|
||||
config FEATURE_PIDFILE
|
||||
bool "Support writing pidfiles"
|
||||
default n
|
||||
help
|
||||
This option makes some applets (e.g. crond, syslogd, inetd) write
|
||||
a pidfile in /var/run. Some applications rely on them.
|
||||
|
||||
config FEATURE_SUID
|
||||
bool "Support for SUID/SGID handling"
|
||||
default n
|
||||
@@ -156,13 +162,6 @@ config FEATURE_SUID
|
||||
are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs,
|
||||
and vlock.
|
||||
|
||||
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 FEATURE_SUID
|
||||
@@ -187,10 +186,10 @@ config FEATURE_SUID_CONFIG
|
||||
|
||||
The file has to be owned by user root, group root and has to be
|
||||
writeable only by root:
|
||||
(chown 0.0 /etc/busybox.conf; chmod 600 /etc/busybox.conf)
|
||||
(chown 0.0 /etc/busybox.conf; chmod 600 /etc/busybox.conf)
|
||||
The busybox executable has to be owned by user root, group
|
||||
root and has to be setuid root for this to work:
|
||||
(chown 0.0 /bin/busybox; chmod 4755 /bin/busybox)
|
||||
(chown 0.0 /bin/busybox; chmod 4755 /bin/busybox)
|
||||
|
||||
Robert 'sandman' Griebl has more information here:
|
||||
<url: http://www.softforge.de/bb/suid.html >.
|
||||
@@ -203,14 +202,6 @@ config FEATURE_SUID_CONFIG_QUIET
|
||||
/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 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
|
||||
@@ -231,6 +222,20 @@ config SELINUX
|
||||
|
||||
Most people will leave this set to 'N'.
|
||||
|
||||
config FEATURE_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 PATH. This is typically done by exec'ing
|
||||
/proc/self/exe.
|
||||
This may affect shell, find -exec, xargs and similar applets.
|
||||
They will use applets even if /bin/<applet> -> busybox link
|
||||
is missing (or is not a link to busybox). However, this causes
|
||||
problems in chroot jails without mounted /proc and with ps/top
|
||||
(command name can be shown as 'exe' for applets started this way).
|
||||
|
||||
config BUSYBOX_EXEC_PATH
|
||||
string "Path to BusyBox executable"
|
||||
default "/proc/self/exe"
|
||||
@@ -241,6 +246,22 @@ config BUSYBOX_EXEC_PATH
|
||||
executable. If you haven't got /proc, set this to wherever you
|
||||
want to run BusyBox from.
|
||||
|
||||
# These are auto-selected by other options
|
||||
|
||||
config FEATURE_SYSLOG
|
||||
bool "Support for logging to 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_HAVE_RPC
|
||||
bool "RPC support"
|
||||
default n
|
||||
help
|
||||
This is automatically selected if any of enabled applets need it.
|
||||
You do not need to select it manually.
|
||||
|
||||
endmenu
|
||||
|
||||
menu 'Build Options'
|
||||
@@ -262,41 +283,80 @@ config STATIC
|
||||
config BUILD_LIBBUSYBOX
|
||||
bool "Build shared libbusybox"
|
||||
default n
|
||||
depends on !FEATURE_PREFER_APPLETS
|
||||
help
|
||||
Build a shared library libbusybox.so which contains all
|
||||
libraries used inside busybox.
|
||||
Build a shared library libbusybox.so.N.N.N which contains all
|
||||
busybox code.
|
||||
|
||||
This is an experimental feature intended to support the upcoming
|
||||
"make standalone" mode. Enabling it against the one big busybox
|
||||
binary serves no purpose (and increases the size). You should
|
||||
almost certainly say "no" to this right now.
|
||||
This feature allows every applet to be built as a tiny
|
||||
separate executable. Enabling it for "one big busybox binary"
|
||||
approach serves no purpose and increases code size.
|
||||
You should almost certainly say "no" to this.
|
||||
|
||||
config FEATURE_FULL_LIBBUSYBOX
|
||||
bool "Feature-complete 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.
|
||||
### config FEATURE_FULL_LIBBUSYBOX
|
||||
### bool "Feature-complete 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.
|
||||
###
|
||||
### Normally, libbusybox will only contain the features which are
|
||||
### used by busybox itself. If you plan to write a separate
|
||||
### standalone application which uses libbusybox say 'Y'.
|
||||
###
|
||||
### Note: libbusybox is GPL, not LGPL, and exports no stable API that
|
||||
### might act as a copyright barrier. We can and will modify the
|
||||
### exported function set between releases (even minor version number
|
||||
### changes), and happily break out-of-tree features.
|
||||
###
|
||||
### Say 'N' if in doubt.
|
||||
|
||||
Normally, libbusybox will only contain the features which are
|
||||
used by busybox itself. If you plan to write a separate
|
||||
standalone application which uses libbusybox say 'Y'.
|
||||
|
||||
Note: libbusybox is GPL, not LGPL, and exports no stable API that
|
||||
might act as a copyright barrier. We can and will modify the
|
||||
exported function set between releases (even minor version number
|
||||
changes), and happily break out-of-tree features.
|
||||
|
||||
Say 'N' if in doubt.
|
||||
|
||||
config FEATURE_SHARED_BUSYBOX
|
||||
bool "Use shared libbusybox for busybox"
|
||||
default y if BUILD_LIBBUSYBOX
|
||||
config FEATURE_INDIVIDUAL
|
||||
bool "Produce a binary for each applet, linked against libbusybox"
|
||||
default y
|
||||
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.
|
||||
If your CPU architecture doesn't allow for sharing text/rodata
|
||||
sections of running binaries, but allows for runtime dynamic
|
||||
libraries, this option will allow you to reduce memory footprint
|
||||
when you have many different applets running at once.
|
||||
|
||||
If your CPU architecture allows for sharing text/rodata,
|
||||
having single binary is more optimal.
|
||||
|
||||
Each applet will be a tiny program, dynamically linked
|
||||
against libbusybox.so.N.N.N.
|
||||
|
||||
You need to have a working dynamic linker.
|
||||
|
||||
config FEATURE_SHARED_BUSYBOX
|
||||
bool "Produce additional busybox binary linked against libbusybox"
|
||||
default y
|
||||
depends on !STATIC && BUILD_LIBBUSYBOX
|
||||
help
|
||||
Build busybox, dynamically linked against libbusybox.so.N.N.N.
|
||||
|
||||
You need to have a working dynamic linker.
|
||||
|
||||
### config BUILD_AT_ONCE
|
||||
### bool "Compile all sources at once"
|
||||
### default n
|
||||
### help
|
||||
### Normally each source-file is compiled with one invocation of
|
||||
### the compiler.
|
||||
### If you set this option, all sources are compiled at once.
|
||||
### This gives the compiler more opportunities to optimize which can
|
||||
### result in smaller and/or faster binaries.
|
||||
###
|
||||
### Setting this option will consume alot of memory, e.g. if you
|
||||
### enable all applets with all features, gcc uses more than 300MB
|
||||
### RAM during compilation of busybox.
|
||||
###
|
||||
### This option is most likely only beneficial for newer compilers
|
||||
### such as gcc-4.1 and above.
|
||||
###
|
||||
### Say 'N' unless you know what you are doing.
|
||||
|
||||
config LFS
|
||||
bool "Build with Large File Support (for accessing files > 2 GB)"
|
||||
@@ -310,25 +370,6 @@ 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 BUILD_AT_ONCE
|
||||
bool "Compile all sources at once"
|
||||
default n
|
||||
help
|
||||
Normally each source-file is compiled with one invocation of
|
||||
the compiler.
|
||||
If you set this option, all sources are compiled at once.
|
||||
This gives the compiler more opportunities to optimize which can
|
||||
result in smaller and/or faster binaries.
|
||||
|
||||
Setting this option will consume alot of memory, e.g. if you
|
||||
enable all applets with all features, gcc uses more than 300MB
|
||||
RAM during compilation of busybox.
|
||||
|
||||
This option is most likely only beneficial for newer compilers
|
||||
such as gcc-4.1 and above.
|
||||
|
||||
Say 'N' unless you know what you are doing.
|
||||
|
||||
endmenu
|
||||
|
||||
menu 'Debugging Options'
|
||||
@@ -344,21 +385,29 @@ config DEBUG
|
||||
|
||||
Most people should answer N.
|
||||
|
||||
config DEBUG_PESSIMIZE
|
||||
bool "Disable compiler optimizations."
|
||||
config WERROR
|
||||
bool "Abort compilation on any warning"
|
||||
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.
|
||||
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 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
|
||||
@@ -418,31 +467,59 @@ config INSTALL_NO_USR
|
||||
that you really want this behaviour.
|
||||
|
||||
choice
|
||||
prompt "Applets links"
|
||||
default 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 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.
|
||||
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_HARDLINKS
|
||||
bool "as hard-links"
|
||||
help
|
||||
Install applets as hard-links to the busybox binary. This might count
|
||||
on a filesystem with few inodes.
|
||||
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_SCRIPT_WRAPPERS
|
||||
bool "as script wrappers"
|
||||
help
|
||||
Install applets as script wrappers that call the busybox binary.
|
||||
|
||||
config INSTALL_APPLET_DONT
|
||||
bool
|
||||
prompt "not installed"
|
||||
depends on FEATURE_INSTALLER || FEATURE_SH_STANDALONE_SHELL
|
||||
help
|
||||
Do not install applet links. Useful when using the -install feature
|
||||
or a standalone shell for rescue pruposes.
|
||||
bool "not installed"
|
||||
depends on FEATURE_INSTALLER || FEATURE_SH_STANDALONE || FEATURE_PREFER_APPLETS
|
||||
help
|
||||
Do not install applet links. Useful when using the -install feature
|
||||
or a standalone shell for rescue purposes.
|
||||
|
||||
endchoice
|
||||
|
||||
choice
|
||||
prompt "/bin/sh applet link"
|
||||
default INSTALL_SH_APPLET_SYMLINK
|
||||
depends on INSTALL_APPLET_SCRIPT_WRAPPERS
|
||||
help
|
||||
Choose how you install /bin/sh applet link.
|
||||
|
||||
config INSTALL_SH_APPLET_SYMLINK
|
||||
bool "as soft-link"
|
||||
help
|
||||
Install /bin/sh applet as soft-link to the busybox binary.
|
||||
|
||||
config INSTALL_SH_APPLET_HARDLINK
|
||||
bool "as hard-link"
|
||||
help
|
||||
Install /bin/sh applet as hard-link to the busybox binary.
|
||||
|
||||
config INSTALL_SH_APPLET_SCRIPT_WRAPPER
|
||||
bool "as script wrapper"
|
||||
help
|
||||
Install /bin/sh applet as script wrapper that call the busybox binary.
|
||||
|
||||
endchoice
|
||||
|
||||
@@ -477,3 +554,5 @@ source procps/Config.in
|
||||
source shell/Config.in
|
||||
source sysklogd/Config.in
|
||||
source runit/Config.in
|
||||
source selinux/Config.in
|
||||
source ipsvd/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:
|
||||
|
||||
@@ -114,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,5 +1,5 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 4
|
||||
PATCHLEVEL = 8
|
||||
SUBLEVEL = 2
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
@@ -183,11 +183,6 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
|
||||
else if [ -x /bin/bash ]; then echo /bin/bash; \
|
||||
else echo sh; fi ; fi)
|
||||
|
||||
HOSTCC = gcc
|
||||
HOSTCXX = g++
|
||||
HOSTCFLAGS = -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
|
||||
HOSTCXXFLAGS = -O2
|
||||
|
||||
# Decide whether to build built-in, modular, or both.
|
||||
# Normally, just do built-in.
|
||||
|
||||
@@ -262,9 +257,16 @@ export quiet Q KBUILD_VERBOSE
|
||||
# Look for make include files relative to root of kernel src
|
||||
MAKEFLAGS += --include-dir=$(srctree)
|
||||
|
||||
HOSTCC = gcc
|
||||
HOSTCXX = g++
|
||||
HOSTCFLAGS :=
|
||||
HOSTCXXFLAGS :=
|
||||
# We need some generic definitions
|
||||
include $(srctree)/scripts/Kbuild.include
|
||||
|
||||
HOSTCFLAGS += $(call hostcc-option,-Wall -Wstrict-prototypes -O2 -fomit-frame-pointer,)
|
||||
HOSTCXXFLAGS += -O2
|
||||
|
||||
# For maximum performance (+ possibly random breakage, uncomment
|
||||
# the following)
|
||||
|
||||
@@ -299,9 +301,11 @@ AFLAGS_KERNEL =
|
||||
|
||||
# Use LINUXINCLUDE when you must reference the include/ directory.
|
||||
# Needed to be compatible with the O= option
|
||||
CFLAGS :=
|
||||
CPPFLAGS :=
|
||||
AFLAGS :=
|
||||
CFLAGS := $(CFLAGS)
|
||||
CPPFLAGS := $(CPPFLAGS)
|
||||
AFLAGS := $(AFLAGS)
|
||||
LDFLAGS := $(LDFLAGS)
|
||||
LDLIBS :=
|
||||
|
||||
# Read KERNELRELEASE from .kernelrelease (if it exists)
|
||||
KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null)
|
||||
@@ -315,6 +319,7 @@ export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION \
|
||||
export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
|
||||
export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
|
||||
export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
|
||||
export FLTFLAGS
|
||||
|
||||
# When compiling out-of-tree modules, put MODVERDIR in the module
|
||||
# tree rather than in the kernel tree. The kernel tree might
|
||||
@@ -432,6 +437,7 @@ libs-y := \
|
||||
editors/ \
|
||||
findutils/ \
|
||||
init/ \
|
||||
ipsvd/ \
|
||||
libbb/ \
|
||||
libpwdgrp/ \
|
||||
loginutils/ \
|
||||
@@ -442,6 +448,7 @@ libs-y := \
|
||||
networking/udhcp/ \
|
||||
procps/ \
|
||||
runit/ \
|
||||
selinux/ \
|
||||
shell/ \
|
||||
sysklogd/ \
|
||||
util-linux/ \
|
||||
@@ -480,7 +487,7 @@ endif
|
||||
# The all: target is the default when no target is given on the
|
||||
# command line.
|
||||
# This allow a user to issue only 'make' to build a kernel including modules
|
||||
# Defaults busybox but it is usually overriden in the arch makefile
|
||||
# Defaults busybox but it is usually overridden in the arch makefile
|
||||
all: busybox
|
||||
|
||||
-include $(srctree)/arch/$(ARCH)/Makefile
|
||||
@@ -561,10 +568,13 @@ busybox-all := $(core-y) $(libs-y)
|
||||
# Rule to link busybox - also used during CONFIG_KALLSYMS
|
||||
# May be overridden by arch/$(ARCH)/Makefile
|
||||
quiet_cmd_busybox__ ?= LINK $@
|
||||
cmd_busybox__ ?= $(srctree)/scripts/trylink $(CC) $(LDFLAGS) \
|
||||
-o $@ \
|
||||
-Wl,--warn-common -Wl,--sort-common -Wl,--gc-sections \
|
||||
-Wl,--start-group $(busybox-all) -Wl,--end-group
|
||||
cmd_busybox__ ?= $(srctree)/scripts/trylink \
|
||||
"$@" \
|
||||
"$(CC)" \
|
||||
"$(LDFLAGS) $(EXTRA_LDFLAGS)" \
|
||||
"$(core-y)" \
|
||||
"$(libs-y)" \
|
||||
"$(LDLIBS)"
|
||||
|
||||
# Generate System.map
|
||||
quiet_cmd_sysmap = SYSMAP
|
||||
@@ -671,8 +681,12 @@ busybox_unstripped: $(busybox-all) FORCE
|
||||
$(Q)rm -f .old_version
|
||||
|
||||
busybox: busybox_unstripped
|
||||
ifeq ($(SKIP_STRIP),y)
|
||||
$(Q)cp $< $@
|
||||
else
|
||||
$(Q)$(STRIP) -s --remove-section=.note --remove-section=.comment \
|
||||
busybox_unstripped -o $@
|
||||
endif
|
||||
|
||||
# The actual objects are generated when descending,
|
||||
# make sure no implicit rule kicks in
|
||||
@@ -748,7 +762,7 @@ PHONY += prepare-all
|
||||
# 2) Create the include2 directory, used for the second asm symlink
|
||||
prepare3: .kernelrelease
|
||||
ifneq ($(KBUILD_SRC),)
|
||||
@echo ' Using $(srctree) as source for kernel'
|
||||
@echo ' Using $(srctree) as source for busybox'
|
||||
$(Q)if [ -f $(srctree)/.config ]; then \
|
||||
echo " $(srctree) is not clean, please run 'make mrproper'";\
|
||||
echo " in the '$(srctree)' directory.";\
|
||||
@@ -905,7 +919,7 @@ endif # CONFIG_MODULES
|
||||
|
||||
# Directories & files removed with 'make clean'
|
||||
CLEAN_DIRS += $(MODVERDIR)
|
||||
CLEAN_FILES += busybox* System.map \
|
||||
CLEAN_FILES += busybox* System.map .kernelrelease \
|
||||
.tmp_kallsyms* .tmp_version .tmp_busybox* .tmp_System.map
|
||||
|
||||
# Directories & files removed with 'make mrproper'
|
||||
@@ -956,7 +970,7 @@ distclean: mrproper
|
||||
@find $(srctree) $(RCS_FIND_IGNORE) \
|
||||
\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
|
||||
-o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
|
||||
-o -name '.*.rej' -o -size 0 \
|
||||
-o -name '.*.rej' -o -name '*.tmp' -o -size 0 \
|
||||
-o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
|
||||
-type f -print | xargs rm -f
|
||||
|
||||
|
||||
+19
-4
@@ -2,9 +2,6 @@
|
||||
# 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) $^ >$@
|
||||
|
||||
@@ -15,6 +12,17 @@ endif
|
||||
ifeq ($(CONFIG_INSTALL_APPLET_HARDLINKS),y)
|
||||
INSTALL_OPTS:= --hardlinks
|
||||
endif
|
||||
ifeq ($(CONFIG_INSTALL_APPLET_SCRIPT_WRAPPERS),y)
|
||||
ifeq ($(CONFIG_INSTALL_SH_APPLET_SYMLINK),y)
|
||||
INSTALL_OPTS:= --sw-sh-sym
|
||||
endif
|
||||
ifeq ($(CONFIG_INSTALL_SH_APPLET_HARDLINK),y)
|
||||
INSTALL_OPTS:= --sw-sh-hard
|
||||
endif
|
||||
ifeq ($(CONFIG_INSTALL_SH_APPLET_SCRIPT_WRAPPER),y)
|
||||
INSTALL_OPTS:= --scriptwrapper
|
||||
endif
|
||||
endif
|
||||
install: $(srctree)/applets/install.sh busybox busybox.links
|
||||
$(Q)DO_INSTALL_LIBS="$(strip $(LIBBUSYBOX_SONAME) $(DO_INSTALL_LIBS))" \
|
||||
$(SHELL) $< $(CONFIG_PREFIX) $(INSTALL_OPTS)
|
||||
@@ -70,6 +78,7 @@ sizes: busybox_unstripped
|
||||
.PHONY: bloatcheck
|
||||
bloatcheck: busybox_old busybox_unstripped
|
||||
@$(srctree)/scripts/bloat-o-meter busybox_old busybox_unstripped
|
||||
@$(CROSS_COMPILE)size busybox_old busybox_unstripped
|
||||
|
||||
.PHONY: baseline
|
||||
baseline: busybox_unstripped
|
||||
@@ -79,9 +88,13 @@ baseline: busybox_unstripped
|
||||
objsizes: busybox_unstripped
|
||||
$(srctree)/scripts/objsizes
|
||||
|
||||
.PHONY: stksizes
|
||||
stksizes: busybox_unstripped
|
||||
$(CROSS_COMPILE)objdump -d busybox_unstripped | $(srctree)/scripts/checkstack.pl $(ARCH)
|
||||
|
||||
.PHONY: bigdata
|
||||
bigdata: busybox_unstripped
|
||||
nm --size-sort busybox_unstripped | grep -vi ' [tr] ' | tail -20
|
||||
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [tr] '
|
||||
|
||||
# Documentation Targets
|
||||
.PHONY: doc
|
||||
@@ -143,3 +156,5 @@ SYN_CPPFLAGS := $(subst $(brace_close),\$(brace_close),$(SYN_CPPFLAGS))
|
||||
.PHONY: html
|
||||
html: $(syn)
|
||||
synopsis -f HTML -Wf,title="'BusyBox Documentation'" -o $@ $^
|
||||
|
||||
-include $(srctree)/Makefile.local
|
||||
+76
-7
@@ -3,11 +3,13 @@
|
||||
# ==========================================================================
|
||||
|
||||
BB_VER = $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
|
||||
export BB_VER
|
||||
SKIP_STRIP = n
|
||||
|
||||
# -std=gnu99 needed for [U]LLONG_MAX on some systems
|
||||
CPPFLAGS += $(call cc-option,-std=gnu99,)
|
||||
|
||||
CPPFLAGS += \
|
||||
-std=gnu99 \
|
||||
-Iinclude -Ilibbb \
|
||||
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
|
||||
-include include/autoconf.h \
|
||||
@@ -15,17 +17,84 @@ CPPFLAGS += \
|
||||
$(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
|
||||
|
||||
CFLAGS += \
|
||||
-Wall -Wstrict-prototypes -Wshadow -Werror -Wundef \
|
||||
-funsigned-char -fno-builtin-strlen -finline-limit=0 -static-libgcc \
|
||||
-Os -falign-functions=1 -falign-jumps=1 -falign-loops=1 \
|
||||
-fomit-frame-pointer -ffunction-sections -fdata-sections
|
||||
# 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,)
|
||||
else
|
||||
# for development, warn a little bit about unused results..
|
||||
CPPFLAGS += -D_FORTIFY_SOURCE=2
|
||||
endif
|
||||
# gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
|
||||
CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
|
||||
|
||||
# gcc emits bogus "no prev proto" warning on find.c:alloc_action()
|
||||
ifneq ($(CONFIG_WERROR),y)
|
||||
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
|
||||
endif
|
||||
|
||||
CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
|
||||
# -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 += -g
|
||||
CFLAGS += $(call cc-option,-g)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
|
||||
# on i386: 14% smaller libbusybox.so
|
||||
# (code itself is 9% bigger, we save on relocs/PLT/GOT)
|
||||
CFLAGS += -fpic
|
||||
# and another 4% reduction of libbusybox.so:
|
||||
# (external entry points must be marked EXTERNALLY_VISIBLE)
|
||||
CFLAGS += $(call cc-option,-fvisibility=hidden)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STATIC),y)
|
||||
LDFLAGS += -static
|
||||
endif
|
||||
|
||||
LDLIBS += m crypt
|
||||
|
||||
ifeq ($(CONFIG_PAM),y)
|
||||
LDLIBS += pam pam_misc
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SELINUX),y)
|
||||
LDLIBS += selinux sepol
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_EFENCE),y)
|
||||
LDLIBS += efence
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_DMALLOC),y)
|
||||
LDLIBS += dmalloc
|
||||
endif
|
||||
|
||||
#LDFLAGS += -nostdlib
|
||||
|
||||
LDFLAGS_ELF2FLT = -Wl,-elf2flt
|
||||
ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
|
||||
SKIP_STRIP = y
|
||||
endif
|
||||
|
||||
# Busybox is a stack-fatty so make sure we increase default size
|
||||
# TODO: use "make stksizes" to find & fix big stack users
|
||||
# (we stole scripts/checkstack.pl from the kernel... thanks guys!)
|
||||
FLTFLAGS += -s 20000
|
||||
+3
-1
@@ -27,7 +27,7 @@ help:
|
||||
@echo ' make SED="$(objtree)/sed"'
|
||||
@echo
|
||||
@echo 'Installation:'
|
||||
@echo ' install - install busybox into $(PREFIX)'
|
||||
@echo ' install - install busybox into $(CONFIG_PREFIX)'
|
||||
@echo ' uninstall'
|
||||
@echo
|
||||
@echo 'Development:'
|
||||
@@ -39,4 +39,6 @@ help:
|
||||
@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 ' bigdata - show data objects, biggest first'
|
||||
@echo ' stksizes - show stack users, biggest first'
|
||||
@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").
|
||||
|
||||
----------------
|
||||
|
||||
|
||||
@@ -36,12 +36,7 @@ Rob Landley <rob@landley.net>:
|
||||
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:
|
||||
networking/wget.c:base64enc()
|
||||
coreutils/uudecode.c:read_base64()
|
||||
coreutils/uuencode.c:tbl_base64[]
|
||||
networking/httpd.c:decodeBase64()
|
||||
And probably elsewhere. That needs to be unified into libbb functions.
|
||||
[done]
|
||||
Do a SUSv3 audit
|
||||
Look at the full Single Unix Specification version 3 (available online at
|
||||
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
|
||||
@@ -130,7 +125,6 @@ Bernhard Fischer <busybox@busybox.net> suggests to look at these:
|
||||
make bb_common_bufsiz1 configurable, size wise.
|
||||
make pipesize configurable, size wise.
|
||||
Use bb_common_bufsiz1 throughout applets!
|
||||
Add chrt applet. Please CC Bernhard if you suggest a patch.
|
||||
|
||||
As yet unclaimed:
|
||||
|
||||
@@ -154,6 +148,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
|
||||
@@ -164,11 +162,20 @@ man
|
||||
---
|
||||
ar
|
||||
Write support?
|
||||
----
|
||||
---
|
||||
stty / catv
|
||||
stty's visible() function and catv's guts are identical. Merge them into
|
||||
an appropriate libbb function.
|
||||
----
|
||||
---
|
||||
struct suffix_mult
|
||||
Several duplicate users of: grep -r "1024\*1024" * -B2 -A1
|
||||
Merge to a single size_suffixes[] in libbb.
|
||||
Users: head tail od_bloaty hexdump and (partially as it wouldn't hurt) svlogd
|
||||
---
|
||||
tail
|
||||
./busybox tail -f foo.c~ TODO
|
||||
should not print fmt=header_fmt for subsequent date >> TODO; i.e. only
|
||||
fmt+ if another (not the current) file did change
|
||||
|
||||
Architectural issues:
|
||||
|
||||
|
||||
@@ -0,0 +1,710 @@
|
||||
# This .config compiles for NOMMU.
|
||||
# TODO:
|
||||
# Pick disabled applet, enable & try to make it compile & work on NOMMU
|
||||
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.6.0.svn
|
||||
# Wed Apr 11 01:29:04 2007
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
#
|
||||
# Busybox Settings
|
||||
#
|
||||
|
||||
#
|
||||
# General Configuration
|
||||
#
|
||||
# CONFIG_NITPICK is not set
|
||||
# CONFIG_DESKTOP is not set
|
||||
# CONFIG_FEATURE_BUFFERS_USE_MALLOC is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
CONFIG_SHOW_USAGE=y
|
||||
CONFIG_FEATURE_VERBOSE_USAGE=y
|
||||
CONFIG_FEATURE_COMPRESS_USAGE=y
|
||||
CONFIG_FEATURE_INSTALLER=y
|
||||
# CONFIG_LOCALE_SUPPORT is not set
|
||||
CONFIG_GETOPT_LONG=y
|
||||
CONFIG_FEATURE_DEVPTS=y
|
||||
# CONFIG_FEATURE_CLEAN_UP is not set
|
||||
CONFIG_FEATURE_PIDFILE=y
|
||||
CONFIG_FEATURE_SUID=y
|
||||
CONFIG_FEATURE_SYSLOG=y
|
||||
# CONFIG_FEATURE_SUID_CONFIG is not set
|
||||
# CONFIG_FEATURE_SUID_CONFIG_QUIET is not set
|
||||
# CONFIG_FEATURE_HAVE_RPC is not set
|
||||
# CONFIG_SELINUX is not set
|
||||
CONFIG_FEATURE_PREFER_APPLETS=y
|
||||
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
|
||||
|
||||
#
|
||||
# Build Options
|
||||
#
|
||||
# CONFIG_STATIC is not set
|
||||
# CONFIG_BUILD_LIBBUSYBOX is not set
|
||||
# CONFIG_FEATURE_FULL_LIBBUSYBOX is not set
|
||||
# CONFIG_FEATURE_SHARED_BUSYBOX is not set
|
||||
CONFIG_LFS=y
|
||||
# CONFIG_BUILD_AT_ONCE is not set
|
||||
|
||||
#
|
||||
# Debugging Options
|
||||
#
|
||||
# CONFIG_DEBUG is not set
|
||||
CONFIG_WERROR=y
|
||||
CONFIG_NO_DEBUG_LIB=y
|
||||
# CONFIG_DMALLOC is not set
|
||||
# CONFIG_EFENCE is not set
|
||||
CONFIG_INCLUDE_SUSv2=y
|
||||
|
||||
#
|
||||
# Installation Options
|
||||
#
|
||||
# CONFIG_INSTALL_NO_USR is not set
|
||||
CONFIG_INSTALL_APPLET_SYMLINKS=y
|
||||
# CONFIG_INSTALL_APPLET_HARDLINKS is not set
|
||||
# CONFIG_INSTALL_APPLET_DONT is not set
|
||||
CONFIG_PREFIX="./_install"
|
||||
|
||||
#
|
||||
# Busybox Library Tuning
|
||||
#
|
||||
CONFIG_PASSWORD_MINLEN=6
|
||||
CONFIG_MD5_SIZE_VS_SPEED=2
|
||||
CONFIG_FEATURE_EDITING=y
|
||||
# CONFIG_FEATURE_EDITING_FANCY_KEYS is not set
|
||||
# CONFIG_FEATURE_EDITING_VI is not set
|
||||
CONFIG_FEATURE_EDITING_HISTORY=15
|
||||
# CONFIG_FEATURE_EDITING_SAVEHISTORY is not set
|
||||
# CONFIG_FEATURE_TAB_COMPLETION is not set
|
||||
# CONFIG_FEATURE_USERNAME_COMPLETION is not set
|
||||
# CONFIG_FEATURE_EDITING_FANCY_PROMPT is not set
|
||||
|
||||
#
|
||||
# Applets
|
||||
#
|
||||
|
||||
#
|
||||
# Archival Utilities
|
||||
#
|
||||
CONFIG_AR=y
|
||||
CONFIG_FEATURE_AR_LONG_FILENAMES=y
|
||||
CONFIG_BUNZIP2=y
|
||||
CONFIG_CPIO=y
|
||||
# CONFIG_DPKG is not set
|
||||
# CONFIG_DPKG_DEB is not set
|
||||
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_FEATURE_GUNZIP_UNCOMPRESS=y
|
||||
CONFIG_GZIP=y
|
||||
CONFIG_RPM2CPIO=y
|
||||
# CONFIG_RPM is not set
|
||||
CONFIG_TAR=y
|
||||
CONFIG_FEATURE_TAR_CREATE=y
|
||||
# CONFIG_FEATURE_TAR_BZIP2 is not set
|
||||
# CONFIG_FEATURE_TAR_LZMA is not set
|
||||
CONFIG_FEATURE_TAR_FROM=y
|
||||
# CONFIG_FEATURE_TAR_GZIP is not set
|
||||
# CONFIG_FEATURE_TAR_COMPRESS is not set
|
||||
CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y
|
||||
CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
|
||||
CONFIG_FEATURE_TAR_LONG_OPTIONS=y
|
||||
CONFIG_UNCOMPRESS=y
|
||||
CONFIG_UNLZMA=y
|
||||
CONFIG_FEATURE_LZMA_FAST=y
|
||||
CONFIG_UNZIP=y
|
||||
|
||||
#
|
||||
# Common options for cpio and tar
|
||||
#
|
||||
CONFIG_FEATURE_UNARCHIVE_TAPE=y
|
||||
# CONFIG_FEATURE_DEB_TAR_GZ is not set
|
||||
# CONFIG_FEATURE_DEB_TAR_BZ2 is not set
|
||||
# CONFIG_FEATURE_DEB_TAR_LZMA is not set
|
||||
|
||||
#
|
||||
# Coreutils
|
||||
#
|
||||
CONFIG_BASENAME=y
|
||||
CONFIG_CAL=y
|
||||
CONFIG_CAT=y
|
||||
CONFIG_CATV=y
|
||||
CONFIG_CHGRP=y
|
||||
CONFIG_CHMOD=y
|
||||
CONFIG_CHOWN=y
|
||||
CONFIG_CHROOT=y
|
||||
CONFIG_CKSUM=y
|
||||
CONFIG_CMP=y
|
||||
CONFIG_COMM=y
|
||||
CONFIG_CP=y
|
||||
CONFIG_CUT=y
|
||||
CONFIG_DATE=y
|
||||
CONFIG_FEATURE_DATE_ISOFMT=y
|
||||
CONFIG_DD=y
|
||||
CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
|
||||
CONFIG_FEATURE_DD_IBS_OBS=y
|
||||
CONFIG_DF=y
|
||||
CONFIG_DIFF=y
|
||||
CONFIG_FEATURE_DIFF_BINARY=y
|
||||
CONFIG_FEATURE_DIFF_DIR=y
|
||||
CONFIG_FEATURE_DIFF_MINIMAL=y
|
||||
CONFIG_DIRNAME=y
|
||||
CONFIG_DOS2UNIX=y
|
||||
CONFIG_UNIX2DOS=y
|
||||
CONFIG_DU=y
|
||||
CONFIG_FEATURE_DU_DEFAULT_BLOCKSIZE_1K=y
|
||||
CONFIG_ECHO=y
|
||||
CONFIG_FEATURE_FANCY_ECHO=y
|
||||
CONFIG_ENV=y
|
||||
CONFIG_FEATURE_ENV_LONG_OPTIONS=y
|
||||
CONFIG_EXPR=y
|
||||
CONFIG_EXPR_MATH_SUPPORT_64=y
|
||||
CONFIG_FALSE=y
|
||||
CONFIG_FOLD=y
|
||||
CONFIG_HEAD=y
|
||||
CONFIG_FEATURE_FANCY_HEAD=y
|
||||
CONFIG_HOSTID=y
|
||||
CONFIG_ID=y
|
||||
CONFIG_INSTALL=y
|
||||
CONFIG_FEATURE_INSTALL_LONG_OPTIONS=y
|
||||
CONFIG_LENGTH=y
|
||||
CONFIG_LN=y
|
||||
CONFIG_LOGNAME=y
|
||||
CONFIG_LS=y
|
||||
CONFIG_FEATURE_LS_FILETYPES=y
|
||||
CONFIG_FEATURE_LS_FOLLOWLINKS=y
|
||||
CONFIG_FEATURE_LS_RECURSIVE=y
|
||||
CONFIG_FEATURE_LS_SORTFILES=y
|
||||
CONFIG_FEATURE_LS_TIMESTAMPS=y
|
||||
CONFIG_FEATURE_LS_USERNAME=y
|
||||
CONFIG_FEATURE_LS_COLOR=y
|
||||
CONFIG_FEATURE_LS_COLOR_IS_DEFAULT=y
|
||||
CONFIG_MD5SUM=y
|
||||
CONFIG_MKDIR=y
|
||||
CONFIG_FEATURE_MKDIR_LONG_OPTIONS=y
|
||||
CONFIG_MKFIFO=y
|
||||
CONFIG_MKNOD=y
|
||||
CONFIG_MV=y
|
||||
CONFIG_FEATURE_MV_LONG_OPTIONS=y
|
||||
CONFIG_NICE=y
|
||||
CONFIG_NOHUP=y
|
||||
CONFIG_OD=y
|
||||
CONFIG_PRINTENV=y
|
||||
CONFIG_PRINTF=y
|
||||
CONFIG_PWD=y
|
||||
CONFIG_REALPATH=y
|
||||
CONFIG_RM=y
|
||||
CONFIG_RMDIR=y
|
||||
CONFIG_SEQ=y
|
||||
CONFIG_SHA1SUM=y
|
||||
CONFIG_SLEEP=y
|
||||
CONFIG_FEATURE_FANCY_SLEEP=y
|
||||
CONFIG_SORT=y
|
||||
CONFIG_FEATURE_SORT_BIG=y
|
||||
CONFIG_SPLIT=y
|
||||
CONFIG_FEATURE_SPLIT_FANCY=y
|
||||
CONFIG_STAT=y
|
||||
CONFIG_FEATURE_STAT_FORMAT=y
|
||||
CONFIG_STTY=y
|
||||
CONFIG_SUM=y
|
||||
CONFIG_SYNC=y
|
||||
CONFIG_TAIL=y
|
||||
CONFIG_FEATURE_FANCY_TAIL=y
|
||||
CONFIG_TEE=y
|
||||
CONFIG_FEATURE_TEE_USE_BLOCK_IO=y
|
||||
CONFIG_TEST=y
|
||||
CONFIG_FEATURE_TEST_64=y
|
||||
CONFIG_TOUCH=y
|
||||
CONFIG_TR=y
|
||||
CONFIG_FEATURE_TR_CLASSES=y
|
||||
CONFIG_FEATURE_TR_EQUIV=y
|
||||
CONFIG_TRUE=y
|
||||
CONFIG_TTY=y
|
||||
CONFIG_UNAME=y
|
||||
CONFIG_UNIQ=y
|
||||
CONFIG_USLEEP=y
|
||||
CONFIG_UUDECODE=y
|
||||
CONFIG_UUENCODE=y
|
||||
CONFIG_WATCH=y
|
||||
CONFIG_WC=y
|
||||
CONFIG_FEATURE_WC_LARGE=y
|
||||
CONFIG_WHO=y
|
||||
CONFIG_WHOAMI=y
|
||||
CONFIG_YES=y
|
||||
|
||||
#
|
||||
# Common options for cp and mv
|
||||
#
|
||||
CONFIG_FEATURE_PRESERVE_HARDLINKS=y
|
||||
|
||||
#
|
||||
# Common options for ls, more and telnet
|
||||
#
|
||||
CONFIG_FEATURE_AUTOWIDTH=y
|
||||
|
||||
#
|
||||
# Common options for df, du, ls
|
||||
#
|
||||
CONFIG_FEATURE_HUMAN_READABLE=y
|
||||
|
||||
#
|
||||
# Common options for md5sum, sha1sum
|
||||
#
|
||||
CONFIG_FEATURE_MD5_SHA1_SUM_CHECK=y
|
||||
|
||||
#
|
||||
# Console Utilities
|
||||
#
|
||||
CONFIG_CHVT=y
|
||||
CONFIG_CLEAR=y
|
||||
CONFIG_DEALLOCVT=y
|
||||
CONFIG_DUMPKMAP=y
|
||||
CONFIG_LOADFONT=y
|
||||
CONFIG_LOADKMAP=y
|
||||
CONFIG_OPENVT=y
|
||||
CONFIG_RESET=y
|
||||
CONFIG_RESIZE=y
|
||||
CONFIG_FEATURE_RESIZE_PRINT=y
|
||||
CONFIG_SETCONSOLE=y
|
||||
CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS=y
|
||||
CONFIG_SETKEYCODES=y
|
||||
CONFIG_SETLOGCONS=y
|
||||
|
||||
#
|
||||
# Debian Utilities
|
||||
#
|
||||
CONFIG_MKTEMP=y
|
||||
CONFIG_PIPE_PROGRESS=y
|
||||
CONFIG_READLINK=y
|
||||
CONFIG_FEATURE_READLINK_FOLLOW=y
|
||||
CONFIG_RUN_PARTS=y
|
||||
CONFIG_FEATURE_RUN_PARTS_LONG_OPTIONS=y
|
||||
CONFIG_FEATURE_RUN_PARTS_FANCY=y
|
||||
# CONFIG_START_STOP_DAEMON is not set
|
||||
# CONFIG_FEATURE_START_STOP_DAEMON_FANCY is not set
|
||||
# CONFIG_FEATURE_START_STOP_DAEMON_LONG_OPTIONS is not set
|
||||
CONFIG_WHICH=y
|
||||
|
||||
#
|
||||
# Editors
|
||||
#
|
||||
CONFIG_AWK=y
|
||||
CONFIG_FEATURE_AWK_MATH=y
|
||||
CONFIG_ED=y
|
||||
CONFIG_PATCH=y
|
||||
CONFIG_SED=y
|
||||
CONFIG_VI=y
|
||||
CONFIG_FEATURE_VI_COLON=y
|
||||
CONFIG_FEATURE_VI_YANKMARK=y
|
||||
CONFIG_FEATURE_VI_SEARCH=y
|
||||
CONFIG_FEATURE_VI_USE_SIGNALS=y
|
||||
CONFIG_FEATURE_VI_DOT_CMD=y
|
||||
CONFIG_FEATURE_VI_READONLY=y
|
||||
CONFIG_FEATURE_VI_SETOPTS=y
|
||||
CONFIG_FEATURE_VI_SET=y
|
||||
CONFIG_FEATURE_VI_WIN_RESIZE=y
|
||||
CONFIG_FEATURE_VI_OPTIMIZE_CURSOR=y
|
||||
CONFIG_FEATURE_ALLOW_EXEC=y
|
||||
|
||||
#
|
||||
# Finding Utilities
|
||||
#
|
||||
CONFIG_FIND=y
|
||||
CONFIG_FEATURE_FIND_PRINT0=y
|
||||
CONFIG_FEATURE_FIND_MTIME=y
|
||||
CONFIG_FEATURE_FIND_MMIN=y
|
||||
CONFIG_FEATURE_FIND_PERM=y
|
||||
CONFIG_FEATURE_FIND_TYPE=y
|
||||
CONFIG_FEATURE_FIND_XDEV=y
|
||||
CONFIG_FEATURE_FIND_NEWER=y
|
||||
CONFIG_FEATURE_FIND_INUM=y
|
||||
CONFIG_FEATURE_FIND_EXEC=y
|
||||
CONFIG_FEATURE_FIND_USER=y
|
||||
CONFIG_FEATURE_FIND_GROUP=y
|
||||
CONFIG_FEATURE_FIND_NOT=y
|
||||
CONFIG_FEATURE_FIND_DEPTH=y
|
||||
CONFIG_FEATURE_FIND_PAREN=y
|
||||
CONFIG_FEATURE_FIND_SIZE=y
|
||||
CONFIG_FEATURE_FIND_PRUNE=y
|
||||
CONFIG_GREP=y
|
||||
CONFIG_FEATURE_GREP_EGREP_ALIAS=y
|
||||
CONFIG_FEATURE_GREP_FGREP_ALIAS=y
|
||||
CONFIG_FEATURE_GREP_CONTEXT=y
|
||||
CONFIG_XARGS=y
|
||||
CONFIG_FEATURE_XARGS_SUPPORT_CONFIRMATION=y
|
||||
CONFIG_FEATURE_XARGS_SUPPORT_QUOTES=y
|
||||
CONFIG_FEATURE_XARGS_SUPPORT_TERMOPT=y
|
||||
CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
|
||||
|
||||
#
|
||||
# Init Utilities
|
||||
#
|
||||
# CONFIG_INIT is not set
|
||||
# CONFIG_DEBUG_INIT is not set
|
||||
# CONFIG_FEATURE_USE_INITTAB is not set
|
||||
# CONFIG_FEATURE_INIT_SCTTY is not set
|
||||
# CONFIG_FEATURE_INIT_SYSLOG is not set
|
||||
# CONFIG_FEATURE_EXTRA_QUIET is not set
|
||||
# CONFIG_FEATURE_INIT_COREDUMPS is not set
|
||||
# CONFIG_FEATURE_INITRD is not set
|
||||
CONFIG_HALT=y
|
||||
CONFIG_MESG=y
|
||||
|
||||
#
|
||||
# Login/Password Management Utilities
|
||||
#
|
||||
CONFIG_FEATURE_SHADOWPASSWDS=y
|
||||
CONFIG_USE_BB_SHADOW=y
|
||||
CONFIG_USE_BB_PWD_GRP=y
|
||||
CONFIG_ADDGROUP=y
|
||||
CONFIG_FEATURE_ADDUSER_TO_GROUP=y
|
||||
CONFIG_DELGROUP=y
|
||||
CONFIG_ADDUSER=y
|
||||
CONFIG_DELUSER=y
|
||||
CONFIG_GETTY=y
|
||||
CONFIG_FEATURE_UTMP=y
|
||||
CONFIG_FEATURE_WTMP=y
|
||||
CONFIG_LOGIN=y
|
||||
CONFIG_LOGIN_SCRIPTS=y
|
||||
CONFIG_FEATURE_SECURETTY=y
|
||||
CONFIG_PASSWD=y
|
||||
CONFIG_FEATURE_PASSWD_WEAK_CHECK=y
|
||||
CONFIG_SU=y
|
||||
CONFIG_FEATURE_SU_SYSLOG=y
|
||||
CONFIG_FEATURE_SU_CHECKS_SHELLS=y
|
||||
CONFIG_SULOGIN=y
|
||||
CONFIG_VLOCK=y
|
||||
|
||||
#
|
||||
# Linux Ext2 FS Progs
|
||||
#
|
||||
CONFIG_CHATTR=y
|
||||
CONFIG_FSCK=y
|
||||
CONFIG_LSATTR=y
|
||||
|
||||
#
|
||||
# Linux Module Utilities
|
||||
#
|
||||
CONFIG_INSMOD=y
|
||||
CONFIG_FEATURE_INSMOD_VERSION_CHECKING=y
|
||||
CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS=y
|
||||
CONFIG_FEATURE_INSMOD_LOADINKMEM=y
|
||||
CONFIG_FEATURE_INSMOD_LOAD_MAP=y
|
||||
CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL=y
|
||||
CONFIG_RMMOD=y
|
||||
CONFIG_LSMOD=y
|
||||
CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT=y
|
||||
CONFIG_MODPROBE=y
|
||||
CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS=y
|
||||
CONFIG_FEATURE_MODPROBE_FANCY_ALIAS=y
|
||||
|
||||
#
|
||||
# Options common to multiple modutils
|
||||
#
|
||||
CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
|
||||
CONFIG_FEATURE_2_4_MODULES=y
|
||||
CONFIG_FEATURE_2_6_MODULES=y
|
||||
# CONFIG_FEATURE_QUERY_MODULE_INTERFACE is not set
|
||||
|
||||
#
|
||||
# Linux System Utilities
|
||||
#
|
||||
CONFIG_DMESG=y
|
||||
CONFIG_FEATURE_DMESG_PRETTY=y
|
||||
CONFIG_FBSET=y
|
||||
CONFIG_FEATURE_FBSET_FANCY=y
|
||||
CONFIG_FEATURE_FBSET_READMODE=y
|
||||
CONFIG_FDFLUSH=y
|
||||
CONFIG_FDFORMAT=y
|
||||
CONFIG_FDISK=y
|
||||
CONFIG_FDISK_SUPPORT_LARGE_DISKS=y
|
||||
CONFIG_FEATURE_FDISK_WRITABLE=y
|
||||
CONFIG_FEATURE_AIX_LABEL=y
|
||||
CONFIG_FEATURE_SGI_LABEL=y
|
||||
CONFIG_FEATURE_SUN_LABEL=y
|
||||
CONFIG_FEATURE_OSF_LABEL=y
|
||||
CONFIG_FEATURE_FDISK_ADVANCED=y
|
||||
CONFIG_FREERAMDISK=y
|
||||
CONFIG_FSCK_MINIX=y
|
||||
CONFIG_MKFS_MINIX=y
|
||||
|
||||
#
|
||||
# Minix filesystem support
|
||||
#
|
||||
CONFIG_FEATURE_MINIX2=y
|
||||
CONFIG_GETOPT=y
|
||||
CONFIG_HEXDUMP=y
|
||||
CONFIG_HWCLOCK=y
|
||||
CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS=y
|
||||
CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS=y
|
||||
CONFIG_IPCRM=y
|
||||
CONFIG_IPCS=y
|
||||
CONFIG_LOSETUP=y
|
||||
CONFIG_MDEV=y
|
||||
CONFIG_FEATURE_MDEV_CONF=y
|
||||
CONFIG_FEATURE_MDEV_EXEC=y
|
||||
CONFIG_MKSWAP=y
|
||||
CONFIG_FEATURE_MKSWAP_V0=y
|
||||
CONFIG_MORE=y
|
||||
CONFIG_FEATURE_USE_TERMIOS=y
|
||||
CONFIG_MOUNT=y
|
||||
# CONFIG_FEATURE_MOUNT_NFS is not set
|
||||
CONFIG_FEATURE_MOUNT_CIFS=y
|
||||
CONFIG_FEATURE_MOUNT_FLAGS=y
|
||||
CONFIG_FEATURE_MOUNT_FSTAB=y
|
||||
CONFIG_PIVOT_ROOT=y
|
||||
CONFIG_RDATE=y
|
||||
CONFIG_READPROFILE=y
|
||||
CONFIG_SETARCH=y
|
||||
CONFIG_SWAPONOFF=y
|
||||
CONFIG_SWITCH_ROOT=y
|
||||
CONFIG_UMOUNT=y
|
||||
CONFIG_FEATURE_UMOUNT_ALL=y
|
||||
|
||||
#
|
||||
# Common options for mount/umount
|
||||
#
|
||||
CONFIG_FEATURE_MOUNT_LOOP=y
|
||||
# CONFIG_FEATURE_MTAB_SUPPORT is not set
|
||||
|
||||
#
|
||||
# Miscellaneous Utilities
|
||||
#
|
||||
CONFIG_ADJTIMEX=y
|
||||
# CONFIG_BBCONFIG is not set
|
||||
CONFIG_CHRT=y
|
||||
# CONFIG_CROND is not set
|
||||
# CONFIG_DEBUG_CROND_OPTION is not set
|
||||
# CONFIG_FEATURE_CROND_CALL_SENDMAIL is not set
|
||||
# CONFIG_CRONTAB is not set
|
||||
CONFIG_DC=y
|
||||
# CONFIG_DEVFSD is not set
|
||||
# CONFIG_DEVFSD_MODLOAD is not set
|
||||
# CONFIG_DEVFSD_FG_NP is not set
|
||||
# CONFIG_DEVFSD_VERBOSE is not set
|
||||
# CONFIG_FEATURE_DEVFS is not set
|
||||
CONFIG_EJECT=y
|
||||
CONFIG_LAST=y
|
||||
CONFIG_LESS=y
|
||||
CONFIG_FEATURE_LESS_MAXLINES=9999999
|
||||
CONFIG_FEATURE_LESS_BRACKETS=y
|
||||
CONFIG_FEATURE_LESS_FLAGS=y
|
||||
CONFIG_FEATURE_LESS_FLAGCS=y
|
||||
CONFIG_FEATURE_LESS_MARKS=y
|
||||
CONFIG_FEATURE_LESS_REGEXP=y
|
||||
CONFIG_HDPARM=y
|
||||
CONFIG_FEATURE_HDPARM_GET_IDENTITY=y
|
||||
CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF=y
|
||||
CONFIG_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF=y
|
||||
CONFIG_FEATURE_HDPARM_HDIO_DRIVE_RESET=y
|
||||
CONFIG_FEATURE_HDPARM_HDIO_TRISTATE_HWIF=y
|
||||
CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA=y
|
||||
CONFIG_MAKEDEVS=y
|
||||
# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
|
||||
CONFIG_FEATURE_MAKEDEVS_TABLE=y
|
||||
CONFIG_MOUNTPOINT=y
|
||||
CONFIG_MT=y
|
||||
CONFIG_NMETER=y
|
||||
CONFIG_RAIDAUTORUN=y
|
||||
CONFIG_READAHEAD=y
|
||||
CONFIG_RUNLEVEL=y
|
||||
CONFIG_RX=y
|
||||
CONFIG_STRINGS=y
|
||||
CONFIG_SETSID=y
|
||||
# CONFIG_TASKSET is not set
|
||||
# CONFIG_FEATURE_TASKSET_FANCY is not set
|
||||
CONFIG_TIME=y
|
||||
CONFIG_WATCHDOG=y
|
||||
|
||||
#
|
||||
# Networking Utilities
|
||||
#
|
||||
CONFIG_FEATURE_IPV6=y
|
||||
# CONFIG_VERBOSE_RESOLUTION_ERRORS is not set
|
||||
CONFIG_ARP=y
|
||||
CONFIG_ARPING=y
|
||||
CONFIG_DNSD=y
|
||||
CONFIG_ETHER_WAKE=y
|
||||
CONFIG_FAKEIDENTD=y
|
||||
CONFIG_FTPGET=y
|
||||
CONFIG_FTPPUT=y
|
||||
CONFIG_FEATURE_FTPGETPUT_LONG_OPTIONS=y
|
||||
CONFIG_HOSTNAME=y
|
||||
# CONFIG_HTTPD is not set
|
||||
# CONFIG_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP is not set
|
||||
# CONFIG_FEATURE_HTTPD_SETUID is not set
|
||||
# CONFIG_FEATURE_HTTPD_BASIC_AUTH is not set
|
||||
# CONFIG_FEATURE_HTTPD_AUTH_MD5 is not set
|
||||
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_MIME_TYPES is not set
|
||||
# CONFIG_FEATURE_HTTPD_CGI is not set
|
||||
# CONFIG_FEATURE_HTTPD_CONFIG_WITH_SCRIPT_INTERPR is not set
|
||||
# CONFIG_FEATURE_HTTPD_SET_REMOTE_PORT_TO_ENV is not set
|
||||
# CONFIG_FEATURE_HTTPD_ENCODE_URL_STR is not set
|
||||
CONFIG_IFCONFIG=y
|
||||
CONFIG_FEATURE_IFCONFIG_STATUS=y
|
||||
CONFIG_FEATURE_IFCONFIG_SLIP=y
|
||||
CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ=y
|
||||
CONFIG_FEATURE_IFCONFIG_HW=y
|
||||
CONFIG_FEATURE_IFCONFIG_BROADCAST_PLUS=y
|
||||
# CONFIG_IFUPDOWN is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IP is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IPV4 is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IPV6 is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IPX is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
|
||||
# CONFIG_INETD is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set
|
||||
# CONFIG_FEATURE_INETD_RPC is not set
|
||||
CONFIG_IP=y
|
||||
CONFIG_FEATURE_IP_ADDRESS=y
|
||||
CONFIG_FEATURE_IP_LINK=y
|
||||
CONFIG_FEATURE_IP_ROUTE=y
|
||||
CONFIG_FEATURE_IP_TUNNEL=y
|
||||
CONFIG_FEATURE_IP_RULE=y
|
||||
CONFIG_FEATURE_IP_SHORT_FORMS=y
|
||||
CONFIG_IPADDR=y
|
||||
CONFIG_IPLINK=y
|
||||
CONFIG_IPROUTE=y
|
||||
CONFIG_IPTUNNEL=y
|
||||
CONFIG_IPRULE=y
|
||||
CONFIG_IPCALC=y
|
||||
CONFIG_FEATURE_IPCALC_FANCY=y
|
||||
CONFIG_FEATURE_IPCALC_LONG_OPTIONS=y
|
||||
CONFIG_NAMEIF=y
|
||||
CONFIG_NC=y
|
||||
CONFIG_NC_SERVER=y
|
||||
CONFIG_NC_EXTRA=y
|
||||
CONFIG_NETSTAT=y
|
||||
CONFIG_NSLOOKUP=y
|
||||
CONFIG_PING=y
|
||||
CONFIG_PING6=y
|
||||
CONFIG_FEATURE_FANCY_PING=y
|
||||
CONFIG_ROUTE=y
|
||||
CONFIG_TELNET=y
|
||||
CONFIG_FEATURE_TELNET_TTYPE=y
|
||||
CONFIG_FEATURE_TELNET_AUTOLOGIN=y
|
||||
# CONFIG_TELNETD is not set
|
||||
# CONFIG_FEATURE_TELNETD_STANDALONE is not set
|
||||
CONFIG_TFTP=y
|
||||
CONFIG_FEATURE_TFTP_GET=y
|
||||
CONFIG_FEATURE_TFTP_PUT=y
|
||||
CONFIG_FEATURE_TFTP_BLOCKSIZE=y
|
||||
# CONFIG_DEBUG_TFTP is not set
|
||||
CONFIG_TRACEROUTE=y
|
||||
# CONFIG_FEATURE_TRACEROUTE_VERBOSE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE is not set
|
||||
# CONFIG_FEATURE_TRACEROUTE_USE_ICMP is not set
|
||||
CONFIG_APP_UDHCPD=y
|
||||
CONFIG_APP_DHCPRELAY=y
|
||||
CONFIG_APP_DUMPLEASES=y
|
||||
# CONFIG_APP_UDHCPC is not set
|
||||
# CONFIG_FEATURE_UDHCP_DEBUG is not set
|
||||
CONFIG_FEATURE_RFC3397=y
|
||||
CONFIG_VCONFIG=y
|
||||
CONFIG_WGET=y
|
||||
CONFIG_FEATURE_WGET_STATUSBAR=y
|
||||
CONFIG_FEATURE_WGET_AUTHENTICATION=y
|
||||
CONFIG_FEATURE_WGET_LONG_OPTIONS=y
|
||||
CONFIG_ZCIP=y
|
||||
|
||||
#
|
||||
# Process Utilities
|
||||
#
|
||||
CONFIG_FREE=y
|
||||
CONFIG_FUSER=y
|
||||
CONFIG_KILL=y
|
||||
CONFIG_KILLALL=y
|
||||
CONFIG_KILLALL5=y
|
||||
CONFIG_PIDOF=y
|
||||
CONFIG_FEATURE_PIDOF_SINGLE=y
|
||||
CONFIG_FEATURE_PIDOF_OMIT=y
|
||||
CONFIG_PS=y
|
||||
CONFIG_FEATURE_PS_WIDE=y
|
||||
CONFIG_RENICE=y
|
||||
CONFIG_BB_SYSCTL=y
|
||||
CONFIG_TOP=y
|
||||
CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y
|
||||
CONFIG_UPTIME=y
|
||||
|
||||
#
|
||||
# Shells
|
||||
#
|
||||
# CONFIG_FEATURE_SH_IS_ASH is not set
|
||||
# CONFIG_FEATURE_SH_IS_HUSH is not set
|
||||
# CONFIG_FEATURE_SH_IS_LASH is not set
|
||||
# CONFIG_FEATURE_SH_IS_MSH is not set
|
||||
CONFIG_FEATURE_SH_IS_NONE=y
|
||||
# CONFIG_ASH is not set
|
||||
# CONFIG_ASH_JOB_CONTROL is not set
|
||||
# CONFIG_ASH_READ_NCHARS is not set
|
||||
# CONFIG_ASH_READ_TIMEOUT is not set
|
||||
# CONFIG_ASH_ALIAS is not set
|
||||
# CONFIG_ASH_MATH_SUPPORT is not set
|
||||
# CONFIG_ASH_MATH_SUPPORT_64 is not set
|
||||
# CONFIG_ASH_GETOPTS is not set
|
||||
# CONFIG_ASH_BUILTIN_ECHO is not set
|
||||
# CONFIG_ASH_BUILTIN_TEST is not set
|
||||
# CONFIG_ASH_CMDCMD is not set
|
||||
# CONFIG_ASH_MAIL is not set
|
||||
# CONFIG_ASH_OPTIMIZE_FOR_SIZE is not set
|
||||
# CONFIG_ASH_RANDOM_SUPPORT is not set
|
||||
# CONFIG_ASH_EXPAND_PRMT is not set
|
||||
# CONFIG_HUSH is not set
|
||||
# CONFIG_LASH is not set
|
||||
CONFIG_MSH=y
|
||||
|
||||
#
|
||||
# Bourne Shell Options
|
||||
#
|
||||
CONFIG_FEATURE_SH_EXTRA_QUIET=y
|
||||
CONFIG_FEATURE_SH_STANDALONE=y
|
||||
|
||||
#
|
||||
# System Logging Utilities
|
||||
#
|
||||
CONFIG_SYSLOGD=y
|
||||
CONFIG_FEATURE_ROTATE_LOGFILE=y
|
||||
CONFIG_FEATURE_REMOTE_LOG=y
|
||||
CONFIG_FEATURE_IPC_SYSLOG=y
|
||||
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=16
|
||||
CONFIG_LOGREAD=y
|
||||
CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING=y
|
||||
CONFIG_KLOGD=y
|
||||
CONFIG_LOGGER=y
|
||||
|
||||
#
|
||||
# Runit Utilities
|
||||
#
|
||||
# CONFIG_RUNSV is not set
|
||||
# CONFIG_RUNSVDIR is not set
|
||||
CONFIG_SV=y
|
||||
# CONFIG_SVLOGD is not set
|
||||
CONFIG_CHPST=y
|
||||
CONFIG_SETUIDGID=y
|
||||
CONFIG_ENVUIDGID=y
|
||||
CONFIG_ENVDIR=y
|
||||
CONFIG_SOFTLIMIT=y
|
||||
# CONFIG_CHCON is not set
|
||||
# CONFIG_FEATURE_CHCON_LONG_OPTIONS is not set
|
||||
# CONFIG_GETENFORCE is not set
|
||||
# CONFIG_GETSEBOOL is not set
|
||||
# CONFIG_LOAD_POLICY is not set
|
||||
# CONFIG_MATCHPATHCON is not set
|
||||
# CONFIG_RUNCON is not set
|
||||
# CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set
|
||||
# CONFIG_SELINUXENABLED is not set
|
||||
# CONFIG_SETENFORCE is not set
|
||||
|
||||
#
|
||||
# ipsvd utilities
|
||||
#
|
||||
# CONFIG_TCPSVD is not set
|
||||
# CONFIG_UDPSVD is not set
|
||||
+13
-10
@@ -4,19 +4,22 @@
|
||||
#
|
||||
# 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: include/usage_compressed.h
|
||||
obj-y :=
|
||||
obj-y += applets.o
|
||||
|
||||
hostprogs-y:=
|
||||
hostprogs-y += usage
|
||||
always := $(hostprogs-y)
|
||||
HOSTCFLAGS_usage.o = -I$(srctree)/include
|
||||
|
||||
always:= $(hostprogs-y)
|
||||
|
||||
# Generated files need additional love
|
||||
|
||||
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: $(srctree)/include/usage.h applets/usage
|
||||
|
||||
HOSTCFLAGS_usage.o = -I$(srctree)/include
|
||||
|
||||
applets/applets.o: include/usage_compressed.h
|
||||
applets/usage: .config $(srctree)/applets/usage_compressed
|
||||
include/usage_compressed.h: applets/usage $(srctree)/applets/usage_compressed
|
||||
$(call cmd,gen_usage_compressed)
|
||||
+8
-470
@@ -1,19 +1,14 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Utility routines.
|
||||
* Stub for linking busybox binary against libbusybox.
|
||||
*
|
||||
* Copyright (C) tons of folks. Tracking down who wrote what
|
||||
* isn't something I'm going to worry about... If you wrote something
|
||||
* here, please feel free to acknowledge your work.
|
||||
* Copyright (C) 2007 Denis Vlasenko
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
* 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 <assert.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
|
||||
#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
|
||||
@@ -23,469 +18,12 @@
|
||||
#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.
|
||||
#error Aborting compilation.
|
||||
#endif
|
||||
|
||||
#if ENABLE_SHOW_USAGE && !ENABLE_FEATURE_COMPRESS_USAGE
|
||||
static const char usage_messages[] =
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
#include "applets.h"
|
||||
;
|
||||
#undef MAKE_USAGE
|
||||
#else
|
||||
#define usage_messages 0
|
||||
#endif /* ENABLE_SHOW_USAGE */
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
static struct BB_applet *applet_using;
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
|
||||
const unsigned short NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#define CONFIG_FILE "/etc/busybox.conf"
|
||||
|
||||
/* applets [] is const, so we have to define this "override" structure */
|
||||
static struct BB_suid_config
|
||||
#if ENABLE_BUILD_LIBBUSYBOX
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct BB_applet *m_applet;
|
||||
|
||||
uid_t m_uid;
|
||||
gid_t m_gid;
|
||||
mode_t m_mode;
|
||||
|
||||
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)
|
||||
{
|
||||
struct group *grp = getgrgid(g);
|
||||
|
||||
if (grp) {
|
||||
char **mem;
|
||||
|
||||
for (mem = grp->gr_mem; *mem; mem++) {
|
||||
struct passwd *pwd = getpwnam(*mem);
|
||||
|
||||
if (pwd && (pwd->pw_uid == u))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return lbb_main(argc, argv);
|
||||
}
|
||||
|
||||
/* This should probably be a libbb routine. In that case,
|
||||
* I'd probably rename it to something like bb_trimmed_slice.
|
||||
*/
|
||||
static char *get_trimmed_slice(char *s, char *e)
|
||||
{
|
||||
/* First, consider the value at e to be nul and back up until we
|
||||
* reach a non-space char. Set the char after that (possibly at
|
||||
* the original e) to nul. */
|
||||
while (e-- > s) {
|
||||
if (!isspace(*e)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
e[1] = 0;
|
||||
|
||||
/* Next, advance past all leading space and return a ptr to the
|
||||
* first non-space char; possibly the terminating nul. */
|
||||
return skip_whitespace(s);
|
||||
}
|
||||
|
||||
|
||||
#define parse_error(x) { err=x; goto pe_label; }
|
||||
|
||||
/* Don't depend on the tools to combine strings. */
|
||||
static const char config_file[] = CONFIG_FILE;
|
||||
|
||||
/* There are 4 chars + 1 nul for each of user/group/other. */
|
||||
static const char mode_chars[] = "Ssx-\0Ssx-\0Ttx-";
|
||||
|
||||
/* We don't supply a value for the nul, so an index adjustment is
|
||||
* necessary below. Also, we use unsigned short here to save some
|
||||
* space even though these are really mode_t values. */
|
||||
static const unsigned short mode_mask[] = {
|
||||
/* SST sst xxx --- */
|
||||
S_ISUID, S_ISUID|S_IXUSR, S_IXUSR, 0, /* user */
|
||||
S_ISGID, S_ISGID|S_IXGRP, S_IXGRP, 0, /* group */
|
||||
0, S_IXOTH, S_IXOTH, 0 /* other */
|
||||
};
|
||||
|
||||
static void parse_config_file(void)
|
||||
{
|
||||
struct BB_suid_config *sct_head;
|
||||
struct BB_suid_config *sct;
|
||||
struct BB_applet *applet;
|
||||
FILE *f;
|
||||
char *err;
|
||||
char *s;
|
||||
char *e;
|
||||
int i, lc, section;
|
||||
char buffer[256];
|
||||
struct stat st;
|
||||
|
||||
assert(!suid_config); /* Should be set to NULL by bss init. */
|
||||
|
||||
if ((stat(config_file, &st) != 0) /* No config file? */
|
||||
|| !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")) /* Cannot open? */
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
suid_cfg_readable = 1;
|
||||
sct_head = NULL;
|
||||
section = lc = 0;
|
||||
|
||||
do {
|
||||
s = buffer;
|
||||
|
||||
if (!fgets(s, sizeof(buffer), f)) { /* Are we done? */
|
||||
if (ferror(f)) { /* Make sure it wasn't a read error. */
|
||||
parse_error("reading");
|
||||
}
|
||||
fclose(f);
|
||||
suid_config = sct_head; /* Success, so set the pointer. */
|
||||
return;
|
||||
}
|
||||
|
||||
lc++; /* Got a (partial) line. */
|
||||
|
||||
/* If a line is too long for our buffer, we consider it an error.
|
||||
* The following test does mistreat one corner case though.
|
||||
* If the final line of the file does not end with a newline and
|
||||
* yet exactly fills the buffer, it will be treated as too long
|
||||
* even though there isn't really a problem. But it isn't really
|
||||
* worth adding code to deal with such an unlikely situation, and
|
||||
* we do err on the side of caution. Besides, the line would be
|
||||
* too long if it did end with a newline. */
|
||||
if (!strchr(s, '\n') && !feof(f)) {
|
||||
parse_error("line too long");
|
||||
}
|
||||
|
||||
/* Trim leading and trailing whitespace, ignoring comments, and
|
||||
* check if the resulting string is empty. */
|
||||
if (!*(s = get_trimmed_slice(s, strchrnul(s, '#')))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check for a section header. */
|
||||
|
||||
if (*s == '[') {
|
||||
/* Unlike the old code, we ignore leading and trailing
|
||||
* whitespace for the section name. We also require that
|
||||
* there are no stray characters after the closing bracket. */
|
||||
if (!(e = strchr(s, ']')) /* Missing right bracket? */
|
||||
|| e[1] /* Trailing characters? */
|
||||
|| !*(s = get_trimmed_slice(s+1, e)) /* Missing name? */
|
||||
) {
|
||||
parse_error("section header");
|
||||
}
|
||||
/* Right now we only have one section so just check it.
|
||||
* If more sections are added in the future, please don't
|
||||
* resort to cascading ifs with multiple strcasecmp calls.
|
||||
* That kind of bloated code is all too common. A loop
|
||||
* and a string table would be a better choice unless the
|
||||
* number of sections is very small. */
|
||||
if (strcasecmp(s, "SUID") == 0) {
|
||||
section = 1;
|
||||
continue;
|
||||
}
|
||||
section = -1; /* Unknown section so set to skip. */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Process sections. */
|
||||
|
||||
if (section == 1) { /* SUID */
|
||||
/* Since we trimmed leading and trailing space above, we're
|
||||
* now looking for strings of the form
|
||||
* <key>[::space::]*=[::space::]*<value>
|
||||
* where both key and value could contain inner whitespace. */
|
||||
|
||||
/* First get the key (an applet name in our case). */
|
||||
if (!!(e = strchr(s, '='))) {
|
||||
s = get_trimmed_slice(s, e);
|
||||
}
|
||||
if (!e || !*s) { /* Missing '=' or empty key. */
|
||||
parse_error("keyword");
|
||||
}
|
||||
|
||||
/* Ok, we have an applet name. Process the rhs if this
|
||||
* applet is currently built in and ignore it otherwise.
|
||||
* Note: This can hide config file bugs which only pop
|
||||
* up when the busybox configuration is changed. */
|
||||
if ((applet = find_applet_by_name(s))) {
|
||||
/* Note: We currently don't check for duplicates!
|
||||
* The last config line for each applet will be the
|
||||
* one used since we insert at the head of the list.
|
||||
* I suppose this could be considered a feature. */
|
||||
sct = xmalloc(sizeof(struct BB_suid_config));
|
||||
sct->m_applet = applet;
|
||||
sct->m_mode = 0;
|
||||
sct->m_next = sct_head;
|
||||
sct_head = sct;
|
||||
|
||||
/* Get the specified mode. */
|
||||
|
||||
e = skip_whitespace(e+1);
|
||||
|
||||
for (i=0 ; i < 3 ; i++) {
|
||||
const char *q;
|
||||
if (!*(q = strchrnul(mode_chars + 5*i, *e++))) {
|
||||
parse_error("mode");
|
||||
}
|
||||
/* Adjust by -i to account for nul. */
|
||||
sct->m_mode |= mode_mask[(q - mode_chars) - i];
|
||||
}
|
||||
|
||||
/* Now get the the user/group info. */
|
||||
|
||||
s = skip_whitespace(e);
|
||||
|
||||
/* Note: We require whitespace between the mode and the
|
||||
* user/group info. */
|
||||
if ((s == e) || !(e = strchr(s, '.'))) {
|
||||
parse_error("<uid>.<gid>");
|
||||
}
|
||||
*e++ = 0;
|
||||
|
||||
/* We can't use get_ug_id here since it would exit()
|
||||
* if a uid or gid was not found. Oh well... */
|
||||
{
|
||||
char *e2;
|
||||
|
||||
sct->m_uid = strtoul(s, &e2, 10);
|
||||
if (*e2 || (s == e2)) {
|
||||
struct passwd *pwd = getpwnam(s);
|
||||
if (!pwd) {
|
||||
parse_error("user");
|
||||
}
|
||||
sct->m_uid = pwd->pw_uid;
|
||||
}
|
||||
|
||||
sct->m_gid = strtoul(e, &e2, 10);
|
||||
if (*e2 || (e == e2)) {
|
||||
struct group *grp;
|
||||
if (!(grp = getgrnam(e))) {
|
||||
parse_error("group");
|
||||
}
|
||||
sct->m_gid = grp->gr_gid;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Unknown sections are ignored. */
|
||||
|
||||
/* Encountering configuration lines prior to seeing a
|
||||
* section header is treated as an error. This is how
|
||||
* the old code worked, but it may not be desirable.
|
||||
* We may want to simply ignore such lines in case they
|
||||
* are used in some future version of busybox. */
|
||||
if (!section) {
|
||||
parse_error("keyword outside section");
|
||||
}
|
||||
|
||||
} while (1);
|
||||
|
||||
pe_label:
|
||||
fprintf(stderr, "Parse error in %s, line %d: %s\n",
|
||||
config_file, lc, err);
|
||||
|
||||
fclose(f);
|
||||
/* Release any allocated memory before returning. */
|
||||
while (sct_head) {
|
||||
sct = sct_head->m_next;
|
||||
free(sct_head);
|
||||
sct_head = sct;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#else
|
||||
#define parse_config_file() ((void)0)
|
||||
#endif /* CONFIG_FEATURE_SUID_CONFIG */
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID
|
||||
static void check_suid(struct BB_applet *applet)
|
||||
{
|
||||
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;
|
||||
|
||||
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 (!(m & S_IXOTH)) /* is x bit not set ? */
|
||||
bb_error_msg_and_die("you have no permission to run this applet!");
|
||||
|
||||
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 {
|
||||
#ifndef CONFIG_FEATURE_SUID_CONFIG_QUIET
|
||||
static int onetime = 0;
|
||||
|
||||
if (!onetime) {
|
||||
onetime = 1;
|
||||
fprintf(stderr, "Using fallback suid method\n");
|
||||
}
|
||||
#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);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define check_suid(x)
|
||||
#endif /* CONFIG_FEATURE_SUID */
|
||||
|
||||
|
||||
|
||||
#ifdef CONFIG_FEATURE_COMPRESS_USAGE
|
||||
|
||||
#include "usage_compressed.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
static const char *unpack_usage_messages(void)
|
||||
{
|
||||
int input[2], output[2], pid;
|
||||
char *buf;
|
||||
|
||||
if(pipe(input) < 0 || pipe(output) < 0)
|
||||
exit(1);
|
||||
|
||||
pid = fork();
|
||||
switch (pid) {
|
||||
case -1: /* error */
|
||||
exit(1);
|
||||
case 0: /* child */
|
||||
close(input[1]);
|
||||
close(output[0]);
|
||||
uncompressStream(input[0], output[1]);
|
||||
exit(0);
|
||||
}
|
||||
/* parent */
|
||||
|
||||
close(input[0]);
|
||||
close(output[1]);
|
||||
pid = fork();
|
||||
switch (pid) {
|
||||
case -1: /* error */
|
||||
exit(1);
|
||||
case 0: /* child */
|
||||
full_write(input[1], packed_usage, sizeof(packed_usage));
|
||||
exit(0);
|
||||
}
|
||||
/* parent */
|
||||
close(input[1]);
|
||||
|
||||
buf = xmalloc(SIZEOF_usage_messages);
|
||||
full_read(output[0], buf, SIZEOF_usage_messages);
|
||||
return buf;
|
||||
}
|
||||
|
||||
#else
|
||||
#define unpack_usage_messages() usage_messages
|
||||
#endif /* ENABLE_FEATURE_COMPRESS_USAGE */
|
||||
|
||||
void bb_show_usage(void)
|
||||
{
|
||||
if (ENABLE_SHOW_USAGE) {
|
||||
const char *format_string;
|
||||
const char *usage_string = unpack_usage_messages();
|
||||
int i;
|
||||
|
||||
for (i = applet_using - applets; i > 0;)
|
||||
if (!*usage_string++) --i;
|
||||
|
||||
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,
|
||||
applet_using->name, usage_string);
|
||||
}
|
||||
|
||||
exit(xfunc_error_retval);
|
||||
}
|
||||
|
||||
static int applet_name_compare(const void *name, const void *vapplet)
|
||||
{
|
||||
const struct BB_applet *applet = vapplet;
|
||||
|
||||
return strcmp(name, applet->name);
|
||||
}
|
||||
|
||||
struct BB_applet *find_applet_by_name(const char *name)
|
||||
{
|
||||
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 (!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) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* BusyBox' main applet dispatcher.
|
||||
*
|
||||
* Licensed under GPLv2, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include "busybox.h"
|
||||
|
||||
const char *applet_name ATTRIBUTE_EXTERNALLY_VISIBLE;
|
||||
|
||||
#ifdef CONFIG_FEATURE_INSTALLER
|
||||
/*
|
||||
* directory table
|
||||
* 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* const install_dir[] = {
|
||||
&usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
|
||||
&usr_bin [4], /* "/bin" */
|
||||
&usr_sbin[4], /* "/sbin" */
|
||||
usr_bin,
|
||||
usr_sbin
|
||||
};
|
||||
|
||||
/* abstract link() */
|
||||
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_func lf = link;
|
||||
char *fpc;
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links)
|
||||
lf = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
fpc = concat_path_file(
|
||||
install_dir[applets[i].location],
|
||||
applets[i].name);
|
||||
rc = lf(busybox, fpc);
|
||||
if (rc != 0 && errno != EEXIST) {
|
||||
bb_perror_msg("%s", fpc);
|
||||
}
|
||||
free(fpc);
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
#define install_links(x,y)
|
||||
#endif /* CONFIG_FEATURE_INSTALLER */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *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)
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
bb_error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
/*
|
||||
* This style of argument parsing doesn't scale well
|
||||
* in the event that busybox starts wanting more --options.
|
||||
* If someone has a cleaner approach, by all means implement it.
|
||||
*/
|
||||
if (ENABLE_FEATURE_INSTALLER && argc > 1 && !strcmp(argv[1], "--install")) {
|
||||
int use_symbolic_links = 0;
|
||||
char *busybox;
|
||||
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argc > 2)
|
||||
if (strcmp(argv[2], "-s") == 0)
|
||||
use_symbolic_links = 1;
|
||||
|
||||
/* link */
|
||||
// XXX: FIXME: this is broken. Why not just use argv[0] ?
|
||||
busybox = xreadlink("/proc/self/exe");
|
||||
if (!busybox)
|
||||
return 1;
|
||||
install_links(busybox, use_symbolic_links);
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(busybox);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Deal with --help. (Also print help when called with no arguments) */
|
||||
|
||||
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 -= sizeof("start-stop-daemon, ") + 8;
|
||||
}
|
||||
|
||||
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"
|
||||
"\tutilities into a single executable. Most people will create a\n"
|
||||
"\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);
|
||||
a++;
|
||||
if (col > output_width && a->name) {
|
||||
puts(",");
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
puts("\n");
|
||||
return 0;
|
||||
}
|
||||
} else run_applet_by_name(argv[1], argc - 1, argv + 1);
|
||||
|
||||
bb_error_msg_and_die("applet not found");
|
||||
}
|
||||
@@ -9,12 +9,11 @@ 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[])
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
applet_name=argv[0];
|
||||
applet_name = argv[0];
|
||||
|
||||
return APPLET_main(argc,argv);
|
||||
}
|
||||
|
||||
+51
-35
@@ -5,19 +5,23 @@ export LC_CTYPE=POSIX
|
||||
|
||||
prefix=${1}
|
||||
if [ -z "$prefix" ]; then
|
||||
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks]"
|
||||
echo "usage: applets/install.sh DESTINATION [--symlinks/--hardlinks/--scriptwrapper]"
|
||||
exit 1;
|
||||
fi
|
||||
h=`sort busybox.links | uniq`
|
||||
scriptwrapper="n"
|
||||
cleanup="0"
|
||||
noclobber="0"
|
||||
case "$2" in
|
||||
--hardlinks) linkopts="-f";;
|
||||
--symlinks) linkopts="-fs";;
|
||||
--cleanup) cleanup="1";;
|
||||
--noclobber) noclobber="1";;
|
||||
"") h="";;
|
||||
*) echo "Unknown install option: $2"; exit 1;;
|
||||
--hardlinks) linkopts="-f";;
|
||||
--symlinks) linkopts="-fs";;
|
||||
--scriptwrapper) scriptwrapper="y";swrapall="y";;
|
||||
--sw-sh-hard) scriptwrapper="y";linkopts="-f";;
|
||||
--sw-sh-sym) scriptwrapper="y";linkopts="-fs";;
|
||||
--cleanup) cleanup="1";;
|
||||
--noclobber) noclobber="1";;
|
||||
"") h="";;
|
||||
*) echo "Unknown install option: $2"; exit 1;;
|
||||
esac
|
||||
|
||||
if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
|
||||
@@ -43,7 +47,7 @@ if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then
|
||||
inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'`
|
||||
sub_shell_it=`
|
||||
cd "$prefix"
|
||||
for d in usr/sbin usr/bin sbin bin ; do
|
||||
for d in usr/sbin usr/bin sbin bin; do
|
||||
pd=$PWD
|
||||
if [ -d "$d" ]; then
|
||||
cd $d
|
||||
@@ -52,42 +56,54 @@ if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then
|
||||
cd "$pd"
|
||||
done
|
||||
`
|
||||
exit 0
|
||||
fi
|
||||
|
||||
rm -f $prefix/bin/busybox || exit 1
|
||||
mkdir -p $prefix/bin || exit 1
|
||||
install -m 755 busybox $prefix/bin/busybox || exit 1
|
||||
|
||||
for i in $h ; do
|
||||
for i in $h; do
|
||||
appdir=`dirname $i`
|
||||
mkdir -p $prefix/$appdir || exit 1
|
||||
if [ "$2" = "--hardlinks" ]; then
|
||||
bb_path="$prefix/bin/busybox"
|
||||
if [ "$scriptwrapper" = "y" ]; then
|
||||
if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then
|
||||
ln $linkopts busybox $prefix$i || exit 1
|
||||
else
|
||||
rm -f $prefix$i
|
||||
echo "#!/bin/busybox" > $prefix$i
|
||||
chmod +x $prefix/$i
|
||||
fi
|
||||
echo " $prefix$i"
|
||||
else
|
||||
case "$appdir" in
|
||||
/)
|
||||
bb_path="bin/busybox"
|
||||
;;
|
||||
/bin)
|
||||
bb_path="busybox"
|
||||
;;
|
||||
/sbin)
|
||||
bb_path="../bin/busybox"
|
||||
;;
|
||||
/usr/bin|/usr/sbin)
|
||||
bb_path="../../bin/busybox"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown installation directory: $appdir"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ "$noclobber" = "0" ] || [ ! -e "$prefix$i" ]; then
|
||||
echo " $prefix$i -> $bb_path"
|
||||
ln $linkopts $bb_path $prefix$i || exit 1
|
||||
else
|
||||
echo " $prefix$i already exists"
|
||||
if [ "$2" = "--hardlinks" ]; then
|
||||
bb_path="$prefix/bin/busybox"
|
||||
else
|
||||
case "$appdir" in
|
||||
/)
|
||||
bb_path="bin/busybox"
|
||||
;;
|
||||
/bin)
|
||||
bb_path="busybox"
|
||||
;;
|
||||
/sbin)
|
||||
bb_path="../bin/busybox"
|
||||
;;
|
||||
/usr/bin|/usr/sbin)
|
||||
bb_path="../../bin/busybox"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown installation directory: $appdir"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ "$noclobber" = "0" ] || [ ! -e "$prefix$i" ]; then
|
||||
echo " $prefix$i -> $bb_path"
|
||||
ln $linkopts $bb_path $prefix$i || exit 1
|
||||
else
|
||||
echo " $prefix$i already exists"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include <unistd.h>
|
||||
|
||||
/* Just #include "autoconf.h" doesn't work for builds in separate
|
||||
* object directory */
|
||||
#include "../include/autoconf.h"
|
||||
#include "../include/busybox.h"
|
||||
|
||||
static const char usage_messages[] = ""
|
||||
#define MAKE_USAGE
|
||||
|
||||
@@ -12,8 +12,8 @@ sz=`"$loc/usage" | wc -c` || exit 1
|
||||
|
||||
exec >"$target"
|
||||
|
||||
echo 'static const char packed_usage[] = '
|
||||
echo 'static const char packed_usage[] ALIGN1 = '
|
||||
"$loc/usage" | bzip2 -1 | od -v -t x1 \
|
||||
| $SED -e 's/^[^ ]*//' -e 's/ \(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/'
|
||||
| $SED -e 's/^[^ ]*//' -e 's/ *\(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/'
|
||||
echo ';'
|
||||
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
|
||||
+3
-1
@@ -2,4 +2,6 @@
|
||||
# Build system
|
||||
# ==========================================================================
|
||||
|
||||
CFLAGS += -march=i386 -mpreferred-stack-boundary=2
|
||||
# -mpreferred-stack-boundary=2 is essential in preventing gcc 4.2.x
|
||||
# from aligning stack to 16 bytes. (Which is gcc's way of supporting SSE).
|
||||
CFLAGS += $(call cc-option,-march=i386 -mpreferred-stack-boundary=2,)
|
||||
+29
-3
@@ -48,12 +48,22 @@ config BUNZIP2
|
||||
conventional LZ77/LZ78-based compressors, and approaches the
|
||||
performance of the PPM family of statistical compressors.
|
||||
|
||||
The BusyBox bunzip2 applet is limited to de-compression only.
|
||||
On an x86 system, this applet adds about 11K.
|
||||
|
||||
Unless you have a specific application which requires bunzip2, you
|
||||
should probably say N here.
|
||||
|
||||
config BZIP2
|
||||
bool "bzip2"
|
||||
default n
|
||||
help
|
||||
bzip2 is a compression utility using the Burrows-Wheeler block
|
||||
sorting text compression algorithm, and Huffman coding. Compression
|
||||
is generally considerably better than that achieved by more
|
||||
conventional LZ77/LZ78-based compressors, and approaches the
|
||||
performance of the PPM family of statistical compressors.
|
||||
|
||||
Unless you have a specific application which requires bzip2, you
|
||||
should probably say N here.
|
||||
|
||||
config CPIO
|
||||
bool "cpio"
|
||||
default n
|
||||
@@ -133,6 +143,13 @@ config RPM
|
||||
help
|
||||
Mini RPM applet - queries and extracts RPM packages.
|
||||
|
||||
config FEATURE_RPM_BZ2
|
||||
bool "Enable handling of rpms with bzip2-compressed data inside"
|
||||
default n
|
||||
depends on RPM
|
||||
help
|
||||
Enable handling of rpms with bzip2-compressed data inside.
|
||||
|
||||
config TAR
|
||||
bool "tar"
|
||||
default n
|
||||
@@ -198,6 +215,15 @@ config FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
the old GNU format; help to kill this old format by
|
||||
repacking your ancient archives with the new format.
|
||||
|
||||
config FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
bool "Enable untarring of tarballs with checksums produced by buggy Sun tar"
|
||||
default N
|
||||
depends on TAR
|
||||
help
|
||||
This option is required to unpack archives created by some old
|
||||
version of Sun's tar (it was calculating checksum using signed arithmetic).
|
||||
It is said to be fixed in newer Sun tar, but "old" tarballs still exist.
|
||||
|
||||
config FEATURE_TAR_GNU_EXTENSIONS
|
||||
bool "Enable support for some GNU tar extensions"
|
||||
default y
|
||||
|
||||
+6
-5
@@ -8,15 +8,16 @@ libs-y += libunarchive/
|
||||
|
||||
lib-y:=
|
||||
lib-$(CONFIG_AR) += ar.o
|
||||
lib-$(CONFIG_BUNZIP2) += bunzip2.o
|
||||
lib-$(CONFIG_UNLZMA) += unlzma.o
|
||||
lib-$(CONFIG_BUNZIP2) += bbunzip.o
|
||||
lib-$(CONFIG_BZIP2) += bzip2.o bbunzip.o
|
||||
lib-$(CONFIG_UNLZMA) += bbunzip.o
|
||||
lib-$(CONFIG_CPIO) += cpio.o
|
||||
lib-$(CONFIG_DPKG) += dpkg.o
|
||||
lib-$(CONFIG_DPKG_DEB) += dpkg_deb.o
|
||||
lib-$(CONFIG_GUNZIP) += gunzip.o
|
||||
lib-$(CONFIG_GZIP) += gzip.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) += uncompress.o
|
||||
lib-$(CONFIG_UNCOMPRESS) += bbunzip.o
|
||||
lib-$(CONFIG_UNZIP) += unzip.o
|
||||
+9
-7
@@ -3,7 +3,6 @@
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@iinet.net.au> 1 June 2000
|
||||
*
|
||||
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
|
||||
*
|
||||
@@ -14,7 +13,7 @@
|
||||
* http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
static void header_verbose_list_ar(const file_header_t *file_header)
|
||||
@@ -38,19 +37,21 @@ 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) MAIN_EXTERNALLY_VISIBLE;
|
||||
int ar_main(int argc, char **argv)
|
||||
{
|
||||
static const char msg_unsupported_err[] ALIGN1 =
|
||||
"archive %s is not supported";
|
||||
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned opt;
|
||||
static const char msg_unsupported_err[] =
|
||||
"Archive %s not supported. Install binutils 'ar'.";
|
||||
char magic[8];
|
||||
|
||||
archive_handle = init_handle();
|
||||
|
||||
/* Prepend '-' to the first argument if required */
|
||||
opt_complementary = "--:p:t:x:-1:?:p--tx:t--px:x--pt";
|
||||
opt = getopt32(argc, argv, "ptxovcr");
|
||||
opt_complementary = "--:p:t:x:-1:p--tx:t--px:x--pt";
|
||||
opt = getopt32(argv, "ptxovcr");
|
||||
|
||||
if (opt & AR_CTX_PRINT) {
|
||||
archive_handle->action_data = data_extract_to_stdout;
|
||||
@@ -87,7 +88,8 @@ int ar_main(int argc, char **argv)
|
||||
}
|
||||
archive_handle->offset += 7;
|
||||
|
||||
while (get_header_ar(archive_handle) == EXIT_SUCCESS) /* repeat */;
|
||||
while (get_header_ar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,348 @@
|
||||
/* 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 "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
enum {
|
||||
OPT_STDOUT = 0x1,
|
||||
OPT_FORCE = 0x2,
|
||||
/* gunzip and bunzip2 only: */
|
||||
OPT_VERBOSE = 0x4,
|
||||
OPT_DECOMPRESS = 0x8,
|
||||
OPT_TEST = 0x10,
|
||||
};
|
||||
|
||||
static
|
||||
int open_to_or_warn(int to_fd, const char *filename, int flags, int mode)
|
||||
{
|
||||
int fd = open3_or_warn(filename, flags, mode);
|
||||
if (fd < 0) {
|
||||
return 1;
|
||||
}
|
||||
xmove_fd(fd, to_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_simple_perror_msg(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 does 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)] = '.';
|
||||
}
|
||||
xunlink(del);
|
||||
|
||||
#if 0 /* Currently buggy - wrong name: "a.gz: 261% - replaced with a.gz" */
|
||||
/* Extreme bloat for gunzip compat */
|
||||
if (ENABLE_DESKTOP && (option_mask32 & OPT_VERBOSE) && status >= 0) {
|
||||
fprintf(stderr, "%s: %u%% - replaced with %s\n",
|
||||
filename, (unsigned)(stat_buf.st_size*100 / (status+1)), new_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
free_name:
|
||||
if (new_name != filename)
|
||||
free(new_name);
|
||||
}
|
||||
} 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
|
||||
* 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 unpack_bz2_stream(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
|
||||
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int bunzip2_main(int argc, char **argv)
|
||||
{
|
||||
getopt32(argv, "cfvdt");
|
||||
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
|
||||
*
|
||||
* 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
|
||||
#if ENABLE_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) {
|
||||
status = unpack_gz_stream(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) MAIN_EXTERNALLY_VISIBLE;
|
||||
int gunzip_main(int argc, char **argv)
|
||||
{
|
||||
getopt32(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 unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
|
||||
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int unlzma_main(int argc, char **argv)
|
||||
{
|
||||
getopt32(argv, "cf");
|
||||
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) MAIN_EXTERNALLY_VISIBLE;
|
||||
int uncompress_main(int argc, char **argv)
|
||||
{
|
||||
getopt32(argv, "cf");
|
||||
argv += optind;
|
||||
|
||||
return bbunpack(argv, make_new_name_uncompress, unpack_uncompress);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/bin/sh
|
||||
# Test that concatenated gz files are unpacking correctly.
|
||||
# It also tests that unpacking in general is working right.
|
||||
# Since zip code has many corner cases, run it for a few hours
|
||||
# to get a decent coverage (200000 tests or more).
|
||||
|
||||
gzip="gzip"
|
||||
gunzip="../busybox gunzip"
|
||||
# Or the other way around:
|
||||
#gzip="../busybox gzip"
|
||||
#gunzip="gunzip"
|
||||
|
||||
c=0
|
||||
i=$PID
|
||||
while true; do
|
||||
c=$((c+1))
|
||||
|
||||
# RANDOM is not very random on some shells. Spice it up.
|
||||
# 100003 is prime
|
||||
len1=$(( (((RANDOM*RANDOM)^i) & 0x7ffffff) % 100003 ))
|
||||
i=$((i * 1664525 + 1013904223))
|
||||
len2=$(( (((RANDOM*RANDOM)^i) & 0x7ffffff) % 100003 ))
|
||||
|
||||
# Just using urandom will make gzip use method 0 (store) -
|
||||
# not good for test coverage!
|
||||
cat /dev/urandom | while true; do read junk; echo "junk $c $i $junk"; done \
|
||||
| dd bs=$len1 count=1 >z1 2>/dev/null
|
||||
cat /dev/urandom | while true; do read junk; echo "junk $c $i $junk"; done \
|
||||
| dd bs=$len2 count=1 >z2 2>/dev/null
|
||||
|
||||
$gzip <z1 >zz.gz
|
||||
$gzip <z2 >>zz.gz
|
||||
$gunzip -c zz.gz >z9 || {
|
||||
echo "Exitcode $?"
|
||||
exit
|
||||
}
|
||||
sum=`cat z1 z2 | md5sum`
|
||||
sum9=`md5sum <z9`
|
||||
test "$sum" == "$sum9" || {
|
||||
echo "md5sums don't match"
|
||||
exit
|
||||
}
|
||||
echo "Test $c ok: len1=$len1 len2=$len2 sum=$sum"
|
||||
|
||||
sum=`cat z1 z2 z1 z2 | md5sum`
|
||||
rm z1.gz z2.gz 2>/dev/null
|
||||
$gzip z1
|
||||
$gzip z2
|
||||
cat z1.gz z2.gz z1.gz z2.gz >zz.gz
|
||||
$gunzip -c zz.gz >z9 || {
|
||||
echo "Exitcode $? (2)"
|
||||
exit
|
||||
}
|
||||
sum9=`md5sum <z9`
|
||||
test "$sum" == "$sum9" || {
|
||||
echo "md5sums don't match (1)"
|
||||
exit
|
||||
}
|
||||
|
||||
echo "Test $c ok: len1=$len1 len2=$len2 sum=$sum (2)"
|
||||
done
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
# Leak test for gunzip. Watch top for growing process size.
|
||||
|
||||
# Just using urandom will make gzip use method 0 (store) -
|
||||
# not good for test coverage!
|
||||
|
||||
cat /dev/urandom \
|
||||
| while true; do read junk; echo "junk $RANDOM $junk"; done \
|
||||
| ../busybox gzip \
|
||||
| ../busybox gunzip -c >/dev/null
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
# Leak test for gunzip. Watch top for growing process size.
|
||||
# In this case we look for leaks in "concatenated .gz" code -
|
||||
# we feed gunzip with a stream of .gz files.
|
||||
|
||||
i=$PID
|
||||
c=0
|
||||
while true; do
|
||||
c=$((c + 1))
|
||||
echo "Block# $c" >&2
|
||||
# RANDOM is not very random on some shells. Spice it up.
|
||||
i=$((i * 1664525 + 1013904223))
|
||||
# 100003 is prime
|
||||
len=$(( (((RANDOM*RANDOM)^i) & 0x7ffffff) % 100003 ))
|
||||
|
||||
# Just using urandom will make gzip use method 0 (store) -
|
||||
# not good for test coverage!
|
||||
cat /dev/urandom \
|
||||
| while true; do read junk; echo "junk $c $i $junk"; done \
|
||||
| dd bs=$len count=1 2>/dev/null \
|
||||
| gzip >xxx.gz
|
||||
cat xxx.gz xxx.gz xxx.gz xxx.gz xxx.gz xxx.gz xxx.gz xxx.gz
|
||||
done | ../busybox gunzip -c >/dev/null
|
||||
@@ -1,66 +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 "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define BUNZIP2_OPT_STDOUT 1
|
||||
#define BUNZIP2_OPT_FORCE 2
|
||||
|
||||
int bunzip2_main(int argc, char **argv)
|
||||
{
|
||||
USE_DESKTOP(long long) int status;
|
||||
char *filename;
|
||||
unsigned opt;
|
||||
int src_fd, dst_fd;
|
||||
|
||||
opt = getopt32(argc, argv, "cf");
|
||||
|
||||
/* Set input filename and number */
|
||||
filename = argv[optind];
|
||||
if (filename && NOT_LONE_DASH(filename)) {
|
||||
/* Open input file */
|
||||
src_fd = xopen(filename, O_RDONLY);
|
||||
} else {
|
||||
src_fd = STDIN_FILENO;
|
||||
filename = 0;
|
||||
}
|
||||
|
||||
/* if called as bzcat force the stdout flag */
|
||||
if ((opt & BUNZIP2_OPT_STDOUT) || 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;
|
||||
/* extension = filename+strlen(filename)-4 is buggy:
|
||||
* strlen may be less than 4 */
|
||||
char *extension = strrchr(filename, '.');
|
||||
if (!extension || strcmp(extension, ".bz2") != 0) {
|
||||
bb_error_msg_and_die("invalid extension");
|
||||
}
|
||||
xstat(filename, &stat_buf);
|
||||
*extension = '\0';
|
||||
dst_fd = xopen3(filename, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
stat_buf.st_mode);
|
||||
} else dst_fd = STDOUT_FILENO;
|
||||
status = uncompressStream(src_fd, dst_fd);
|
||||
if (filename) {
|
||||
if (status >= 0) filename[strlen(filename)] = '.';
|
||||
if (unlink(filename) < 0) {
|
||||
bb_error_msg_and_die("cannot remove %s", filename);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
bzip2 applet in busybox is based on lightly-modified source
|
||||
of bzip2 version 1.0.4. bzip2 source is distributed
|
||||
under the following conditions (copied verbatim from LICENSE file)
|
||||
===========================================================
|
||||
|
||||
|
||||
This program, "bzip2", the associated library "libbzip2", and all
|
||||
documentation, are copyright (C) 1996-2006 Julian R Seward. All
|
||||
rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product
|
||||
documentation would be appreciated but is not required.
|
||||
|
||||
3. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
|
||||
4. The name of the author may not be used to endorse or promote
|
||||
products derived from this software without specific prior written
|
||||
permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Julian Seward, Cambridge, UK.
|
||||
jseward@bzip.org
|
||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
||||
@@ -0,0 +1,90 @@
|
||||
This file is an abridged version of README from bizp2 1.0.4
|
||||
Build instructions (which are not relevant to busyboxed bzip2)
|
||||
are removed.
|
||||
===========================================================
|
||||
|
||||
|
||||
This is the README for bzip2/libzip2.
|
||||
This version is fully compatible with the previous public releases.
|
||||
|
||||
------------------------------------------------------------------
|
||||
This file is part of bzip2/libbzip2, a program and library for
|
||||
lossless, block-sorting data compression.
|
||||
|
||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
||||
|
||||
Please read the WARNING, DISCLAIMER and PATENTS sections in this file.
|
||||
|
||||
This program is released under the terms of the license contained
|
||||
in the file LICENSE.
|
||||
------------------------------------------------------------------
|
||||
|
||||
Please read and be aware of the following:
|
||||
|
||||
|
||||
WARNING:
|
||||
|
||||
This program and library (attempts to) compress data by
|
||||
performing several non-trivial transformations on it.
|
||||
Unless you are 100% familiar with *all* the algorithms
|
||||
contained herein, and with the consequences of modifying them,
|
||||
you should NOT meddle with the compression or decompression
|
||||
machinery. Incorrect changes can and very likely *will*
|
||||
lead to disastrous loss of data.
|
||||
|
||||
|
||||
DISCLAIMER:
|
||||
|
||||
I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE
|
||||
USE OF THIS PROGRAM/LIBRARY, HOWSOEVER CAUSED.
|
||||
|
||||
Every compression of a file implies an assumption that the
|
||||
compressed file can be decompressed to reproduce the original.
|
||||
Great efforts in design, coding and testing have been made to
|
||||
ensure that this program works correctly. However, the complexity
|
||||
of the algorithms, and, in particular, the presence of various
|
||||
special cases in the code which occur with very low but non-zero
|
||||
probability make it impossible to rule out the possibility of bugs
|
||||
remaining in the program. DO NOT COMPRESS ANY DATA WITH THIS
|
||||
PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER
|
||||
SMALL, THAT THE DATA WILL NOT BE RECOVERABLE.
|
||||
|
||||
That is not to say this program is inherently unreliable.
|
||||
Indeed, I very much hope the opposite is true. bzip2/libbzip2
|
||||
has been carefully constructed and extensively tested.
|
||||
|
||||
|
||||
PATENTS:
|
||||
|
||||
To the best of my knowledge, bzip2/libbzip2 does not use any
|
||||
patented algorithms. However, I do not have the resources
|
||||
to carry out a patent search. Therefore I cannot give any
|
||||
guarantee of the above statement.
|
||||
|
||||
|
||||
I hope you find bzip2 useful. Feel free to contact me at
|
||||
jseward@bzip.org
|
||||
if you have any suggestions or queries. Many people mailed me with
|
||||
comments, suggestions and patches after the releases of bzip-0.15,
|
||||
bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0, 1.0.1,
|
||||
1.0.2 and 1.0.3, and the changes in bzip2 are largely a result of this
|
||||
feedback. I thank you for your comments.
|
||||
|
||||
bzip2's "home" is http://www.bzip.org/
|
||||
|
||||
Julian Seward
|
||||
jseward@bzip.org
|
||||
Cambridge, UK.
|
||||
|
||||
18 July 1996 (version 0.15)
|
||||
25 August 1996 (version 0.21)
|
||||
7 August 1997 (bzip2, version 0.1)
|
||||
29 August 1997 (bzip2, version 0.1pl2)
|
||||
23 August 1998 (bzip2, version 0.9.0)
|
||||
8 June 1999 (bzip2, version 0.9.5)
|
||||
4 Sept 1999 (bzip2, version 0.9.5d)
|
||||
5 May 2000 (bzip2, version 1.0pre8)
|
||||
30 December 2001 (bzip2, version 1.0.2pre1)
|
||||
15 February 2005 (bzip2, version 1.0.3)
|
||||
20 December 2006 (bzip2, version 1.0.4)
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,429 @@
|
||||
/*
|
||||
* bzip2 is written by Julian Seward <jseward@bzip.org>.
|
||||
* Adapted for busybox by Denys Vlasenko <vda.linux@googlemail.com>.
|
||||
* See README and LICENSE files in this directory for more information.
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- Library top-level functions. ---*/
|
||||
/*--- bzlib.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
This file is part of bzip2/libbzip2, a program and library for
|
||||
lossless, block-sorting data compression.
|
||||
|
||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
||||
|
||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||
README file.
|
||||
|
||||
This program is released under the terms of the license contained
|
||||
in the file LICENSE.
|
||||
------------------------------------------------------------------ */
|
||||
|
||||
/* CHANGES
|
||||
* 0.9.0 -- original version.
|
||||
* 0.9.0a/b -- no changes in this file.
|
||||
* 0.9.0c -- made zero-length BZ_FLUSH work correctly in bzCompress().
|
||||
* fixed bzWrite/bzRead to ignore zero-length requests.
|
||||
* fixed bzread to correctly handle read requests after EOF.
|
||||
* wrong parameter order in call to bzDecompressInit in
|
||||
* bzBuffToBuffDecompress. Fixed.
|
||||
*/
|
||||
|
||||
/* #include "bzlib_private.h" */
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
/*--- Compression stuff ---*/
|
||||
/*---------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
#if BZ_LIGHT_DEBUG
|
||||
static
|
||||
void bz_assert_fail(int errcode)
|
||||
{
|
||||
/* if (errcode == 1007) bb_error_msg_and_die("probably bad RAM"); */
|
||||
bb_error_msg_and_die("internal error %d", errcode);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void prepare_new_block(EState* s)
|
||||
{
|
||||
int i;
|
||||
s->nblock = 0;
|
||||
s->numZ = 0;
|
||||
s->state_out_pos = 0;
|
||||
BZ_INITIALISE_CRC(s->blockCRC);
|
||||
/* inlined memset would be nice to have here */
|
||||
for (i = 0; i < 256; i++)
|
||||
s->inUse[i] = 0;
|
||||
s->blockNo++;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
ALWAYS_INLINE
|
||||
void init_RL(EState* s)
|
||||
{
|
||||
s->state_in_ch = 256;
|
||||
s->state_in_len = 0;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
int isempty_RL(EState* s)
|
||||
{
|
||||
return (s->state_in_ch >= 256 || s->state_in_len <= 0);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void BZ2_bzCompressInit(bz_stream *strm, int blockSize100k)
|
||||
{
|
||||
int32_t n;
|
||||
EState* s;
|
||||
|
||||
s = xzalloc(sizeof(EState));
|
||||
s->strm = strm;
|
||||
|
||||
n = 100000 * blockSize100k;
|
||||
s->arr1 = xmalloc(n * sizeof(uint32_t));
|
||||
s->mtfv = (uint16_t*)s->arr1;
|
||||
s->ptr = (uint32_t*)s->arr1;
|
||||
s->arr2 = xmalloc((n + BZ_N_OVERSHOOT) * sizeof(uint32_t));
|
||||
s->block = (uint8_t*)s->arr2;
|
||||
s->ftab = xmalloc(65537 * sizeof(uint32_t));
|
||||
|
||||
s->crc32table = crc32_filltable(NULL, 1);
|
||||
|
||||
s->state = BZ_S_INPUT;
|
||||
s->mode = BZ_M_RUNNING;
|
||||
s->blockSize100k = blockSize100k;
|
||||
s->nblockMAX = n - 19;
|
||||
|
||||
strm->state = s;
|
||||
/*strm->total_in = 0;*/
|
||||
strm->total_out = 0;
|
||||
init_RL(s);
|
||||
prepare_new_block(s);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void add_pair_to_block(EState* s)
|
||||
{
|
||||
int32_t i;
|
||||
uint8_t ch = (uint8_t)(s->state_in_ch);
|
||||
for (i = 0; i < s->state_in_len; i++) {
|
||||
BZ_UPDATE_CRC(s, s->blockCRC, ch);
|
||||
}
|
||||
s->inUse[s->state_in_ch] = 1;
|
||||
switch (s->state_in_len) {
|
||||
case 3:
|
||||
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
|
||||
/* fall through */
|
||||
case 2:
|
||||
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
|
||||
/* fall through */
|
||||
case 1:
|
||||
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
|
||||
break;
|
||||
default:
|
||||
s->inUse[s->state_in_len - 4] = 1;
|
||||
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
|
||||
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
|
||||
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
|
||||
s->block[s->nblock] = (uint8_t)ch; s->nblock++;
|
||||
s->block[s->nblock] = (uint8_t)(s->state_in_len - 4);
|
||||
s->nblock++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void flush_RL(EState* s)
|
||||
{
|
||||
if (s->state_in_ch < 256) add_pair_to_block(s);
|
||||
init_RL(s);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
#define ADD_CHAR_TO_BLOCK(zs, zchh0) \
|
||||
{ \
|
||||
uint32_t zchh = (uint32_t)(zchh0); \
|
||||
/*-- fast track the common case --*/ \
|
||||
if (zchh != zs->state_in_ch && zs->state_in_len == 1) { \
|
||||
uint8_t ch = (uint8_t)(zs->state_in_ch); \
|
||||
BZ_UPDATE_CRC(zs, zs->blockCRC, ch); \
|
||||
zs->inUse[zs->state_in_ch] = 1; \
|
||||
zs->block[zs->nblock] = (uint8_t)ch; \
|
||||
zs->nblock++; \
|
||||
zs->state_in_ch = zchh; \
|
||||
} \
|
||||
else \
|
||||
/*-- general, uncommon cases --*/ \
|
||||
if (zchh != zs->state_in_ch || zs->state_in_len == 255) { \
|
||||
if (zs->state_in_ch < 256) \
|
||||
add_pair_to_block(zs); \
|
||||
zs->state_in_ch = zchh; \
|
||||
zs->state_in_len = 1; \
|
||||
} else { \
|
||||
zs->state_in_len++; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void /*Bool*/ copy_input_until_stop(EState* s)
|
||||
{
|
||||
/*Bool progress_in = False;*/
|
||||
|
||||
#ifdef SAME_CODE_AS_BELOW
|
||||
if (s->mode == BZ_M_RUNNING) {
|
||||
/*-- fast track the common case --*/
|
||||
while (1) {
|
||||
/*-- no input? --*/
|
||||
if (s->strm->avail_in == 0) break;
|
||||
/*-- block full? --*/
|
||||
if (s->nblock >= s->nblockMAX) break;
|
||||
/*progress_in = True;*/
|
||||
ADD_CHAR_TO_BLOCK(s, (uint32_t)(*(uint8_t*)(s->strm->next_in)));
|
||||
s->strm->next_in++;
|
||||
s->strm->avail_in--;
|
||||
/*s->strm->total_in++;*/
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/*-- general, uncommon case --*/
|
||||
while (1) {
|
||||
/*-- no input? --*/
|
||||
if (s->strm->avail_in == 0) break;
|
||||
/*-- block full? --*/
|
||||
if (s->nblock >= s->nblockMAX) break;
|
||||
//# /*-- flush/finish end? --*/
|
||||
//# if (s->avail_in_expect == 0) break;
|
||||
/*progress_in = True;*/
|
||||
ADD_CHAR_TO_BLOCK(s, *(uint8_t*)(s->strm->next_in));
|
||||
s->strm->next_in++;
|
||||
s->strm->avail_in--;
|
||||
/*s->strm->total_in++;*/
|
||||
//# s->avail_in_expect--;
|
||||
}
|
||||
}
|
||||
/*return progress_in;*/
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void /*Bool*/ copy_output_until_stop(EState* s)
|
||||
{
|
||||
/*Bool progress_out = False;*/
|
||||
|
||||
while (1) {
|
||||
/*-- no output space? --*/
|
||||
if (s->strm->avail_out == 0) break;
|
||||
|
||||
/*-- block done? --*/
|
||||
if (s->state_out_pos >= s->numZ) break;
|
||||
|
||||
/*progress_out = True;*/
|
||||
*(s->strm->next_out) = s->zbits[s->state_out_pos];
|
||||
s->state_out_pos++;
|
||||
s->strm->avail_out--;
|
||||
s->strm->next_out++;
|
||||
s->strm->total_out++;
|
||||
}
|
||||
/*return progress_out;*/
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void /*Bool*/ handle_compress(bz_stream *strm)
|
||||
{
|
||||
/*Bool progress_in = False;*/
|
||||
/*Bool progress_out = False;*/
|
||||
EState* s = strm->state;
|
||||
|
||||
while (1) {
|
||||
if (s->state == BZ_S_OUTPUT) {
|
||||
/*progress_out |=*/ copy_output_until_stop(s);
|
||||
if (s->state_out_pos < s->numZ) break;
|
||||
if (s->mode == BZ_M_FINISHING
|
||||
//# && s->avail_in_expect == 0
|
||||
&& s->strm->avail_in == 0
|
||||
&& isempty_RL(s))
|
||||
break;
|
||||
prepare_new_block(s);
|
||||
s->state = BZ_S_INPUT;
|
||||
#ifdef FLUSH_IS_UNUSED
|
||||
if (s->mode == BZ_M_FLUSHING
|
||||
&& s->avail_in_expect == 0
|
||||
&& isempty_RL(s))
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (s->state == BZ_S_INPUT) {
|
||||
/*progress_in |=*/ copy_input_until_stop(s);
|
||||
//#if (s->mode != BZ_M_RUNNING && s->avail_in_expect == 0) {
|
||||
if (s->mode != BZ_M_RUNNING && s->strm->avail_in == 0) {
|
||||
flush_RL(s);
|
||||
BZ2_compressBlock(s, (s->mode == BZ_M_FINISHING));
|
||||
s->state = BZ_S_OUTPUT;
|
||||
} else
|
||||
if (s->nblock >= s->nblockMAX) {
|
||||
BZ2_compressBlock(s, 0);
|
||||
s->state = BZ_S_OUTPUT;
|
||||
} else
|
||||
if (s->strm->avail_in == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*return progress_in || progress_out;*/
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
int BZ2_bzCompress(bz_stream *strm, int action)
|
||||
{
|
||||
/*Bool progress;*/
|
||||
EState* s;
|
||||
|
||||
s = strm->state;
|
||||
|
||||
switch (s->mode) {
|
||||
case BZ_M_RUNNING:
|
||||
if (action == BZ_RUN) {
|
||||
/*progress =*/ handle_compress(strm);
|
||||
/*return progress ? BZ_RUN_OK : BZ_PARAM_ERROR;*/
|
||||
return BZ_RUN_OK;
|
||||
}
|
||||
#ifdef FLUSH_IS_UNUSED
|
||||
else
|
||||
if (action == BZ_FLUSH) {
|
||||
//#s->avail_in_expect = strm->avail_in;
|
||||
s->mode = BZ_M_FLUSHING;
|
||||
goto case_BZ_M_FLUSHING;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
/*if (action == BZ_FINISH)*/ {
|
||||
//#s->avail_in_expect = strm->avail_in;
|
||||
s->mode = BZ_M_FINISHING;
|
||||
goto case_BZ_M_FINISHING;
|
||||
}
|
||||
|
||||
#ifdef FLUSH_IS_UNUSED
|
||||
case_BZ_M_FLUSHING:
|
||||
case BZ_M_FLUSHING:
|
||||
/*if (s->avail_in_expect != s->strm->avail_in)
|
||||
return BZ_SEQUENCE_ERROR;*/
|
||||
/*progress =*/ handle_compress(strm);
|
||||
if (s->avail_in_expect > 0 || !isempty_RL(s) || s->state_out_pos < s->numZ)
|
||||
return BZ_FLUSH_OK;
|
||||
s->mode = BZ_M_RUNNING;
|
||||
return BZ_RUN_OK;
|
||||
#endif
|
||||
|
||||
case_BZ_M_FINISHING:
|
||||
/*case BZ_M_FINISHING:*/
|
||||
default:
|
||||
/*if (s->avail_in_expect != s->strm->avail_in)
|
||||
return BZ_SEQUENCE_ERROR;*/
|
||||
/*progress =*/ handle_compress(strm);
|
||||
/*if (!progress) return BZ_SEQUENCE_ERROR;*/
|
||||
//#if (s->avail_in_expect > 0 || !isempty_RL(s) || s->state_out_pos < s->numZ)
|
||||
//# return BZ_FINISH_OK;
|
||||
if (s->strm->avail_in > 0 || !isempty_RL(s) || s->state_out_pos < s->numZ)
|
||||
return BZ_FINISH_OK;
|
||||
/*s->mode = BZ_M_IDLE;*/
|
||||
return BZ_STREAM_END;
|
||||
}
|
||||
/* return BZ_OK; --not reached--*/
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
#if ENABLE_FEATURE_CLEAN_UP
|
||||
static
|
||||
void BZ2_bzCompressEnd(bz_stream *strm)
|
||||
{
|
||||
EState* s;
|
||||
|
||||
s = strm->state;
|
||||
free(s->arr1);
|
||||
free(s->arr2);
|
||||
free(s->ftab);
|
||||
free(s->crc32table);
|
||||
free(strm->state);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
/*--- Misc convenience stuff ---*/
|
||||
/*---------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
#ifdef EXAMPLE_CODE_FOR_MEM_TO_MEM_COMPRESSION
|
||||
static
|
||||
int BZ2_bzBuffToBuffCompress(char* dest,
|
||||
unsigned int* destLen,
|
||||
char* source,
|
||||
unsigned int sourceLen,
|
||||
int blockSize100k)
|
||||
{
|
||||
bz_stream strm;
|
||||
int ret;
|
||||
|
||||
if (dest == NULL || destLen == NULL ||
|
||||
source == NULL ||
|
||||
blockSize100k < 1 || blockSize100k > 9)
|
||||
return BZ_PARAM_ERROR;
|
||||
|
||||
BZ2_bzCompressInit(&strm, blockSize100k);
|
||||
|
||||
strm.next_in = source;
|
||||
strm.next_out = dest;
|
||||
strm.avail_in = sourceLen;
|
||||
strm.avail_out = *destLen;
|
||||
|
||||
ret = BZ2_bzCompress(&strm, BZ_FINISH);
|
||||
if (ret == BZ_FINISH_OK) goto output_overflow;
|
||||
if (ret != BZ_STREAM_END) goto errhandler;
|
||||
|
||||
/* normal termination */
|
||||
*destLen -= strm.avail_out;
|
||||
BZ2_bzCompressEnd(&strm);
|
||||
return BZ_OK;
|
||||
|
||||
output_overflow:
|
||||
BZ2_bzCompressEnd(&strm);
|
||||
return BZ_OUTBUFF_FULL;
|
||||
|
||||
errhandler:
|
||||
BZ2_bzCompressEnd(&strm);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end bzlib.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* bzip2 is written by Julian Seward <jseward@bzip.org>.
|
||||
* Adapted for busybox by Denys Vlasenko <vda.linux@googlemail.com>.
|
||||
* See README and LICENSE files in this directory for more information.
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- Public header file for the library. ---*/
|
||||
/*--- bzlib.h ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
This file is part of bzip2/libbzip2, a program and library for
|
||||
lossless, block-sorting data compression.
|
||||
|
||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
||||
|
||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||
README file.
|
||||
|
||||
This program is released under the terms of the license contained
|
||||
in the file LICENSE.
|
||||
------------------------------------------------------------------ */
|
||||
|
||||
#define BZ_RUN 0
|
||||
#define BZ_FLUSH 1
|
||||
#define BZ_FINISH 2
|
||||
|
||||
#define BZ_OK 0
|
||||
#define BZ_RUN_OK 1
|
||||
#define BZ_FLUSH_OK 2
|
||||
#define BZ_FINISH_OK 3
|
||||
#define BZ_STREAM_END 4
|
||||
#define BZ_SEQUENCE_ERROR (-1)
|
||||
#define BZ_PARAM_ERROR (-2)
|
||||
#define BZ_MEM_ERROR (-3)
|
||||
#define BZ_DATA_ERROR (-4)
|
||||
#define BZ_DATA_ERROR_MAGIC (-5)
|
||||
#define BZ_IO_ERROR (-6)
|
||||
#define BZ_UNEXPECTED_EOF (-7)
|
||||
#define BZ_OUTBUFF_FULL (-8)
|
||||
#define BZ_CONFIG_ERROR (-9)
|
||||
|
||||
typedef struct bz_stream {
|
||||
void *state;
|
||||
char *next_in;
|
||||
char *next_out;
|
||||
unsigned avail_in;
|
||||
unsigned avail_out;
|
||||
/*unsigned long long total_in;*/
|
||||
unsigned long long total_out;
|
||||
} bz_stream;
|
||||
|
||||
/*-- Core (low-level) library functions --*/
|
||||
|
||||
static void BZ2_bzCompressInit(bz_stream *strm, int blockSize100k);
|
||||
static int BZ2_bzCompress(bz_stream *strm, int action);
|
||||
#if ENABLE_FEATURE_CLEAN_UP
|
||||
static void BZ2_bzCompressEnd(bz_stream *strm);
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end bzlib.h ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* bzip2 is written by Julian Seward <jseward@bzip.org>.
|
||||
* Adapted for busybox by Denys Vlasenko <vda.linux@googlemail.com>.
|
||||
* See README and LICENSE files in this directory for more information.
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- Private header file for the library. ---*/
|
||||
/*--- bzlib_private.h ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
This file is part of bzip2/libbzip2, a program and library for
|
||||
lossless, block-sorting data compression.
|
||||
|
||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
||||
|
||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||
README file.
|
||||
|
||||
This program is released under the terms of the license contained
|
||||
in the file LICENSE.
|
||||
------------------------------------------------------------------ */
|
||||
|
||||
/* #include "bzlib.h" */
|
||||
|
||||
/*-- General stuff. --*/
|
||||
|
||||
typedef unsigned char Bool;
|
||||
|
||||
#define True ((Bool)1)
|
||||
#define False ((Bool)0)
|
||||
|
||||
#if BZ_LIGHT_DEBUG
|
||||
static void bz_assert_fail(int errcode) ATTRIBUTE_NORETURN;
|
||||
#define AssertH(cond, errcode) \
|
||||
do { \
|
||||
if (!(cond)) \
|
||||
bz_assert_fail(errcode); \
|
||||
} while (0)
|
||||
#else
|
||||
#define AssertH(cond, msg) do { } while (0)
|
||||
#endif
|
||||
|
||||
#if BZ_DEBUG
|
||||
#define AssertD(cond, msg) \
|
||||
do { \
|
||||
if (!(cond)) \
|
||||
bb_error_msg_and_die("(debug build): internal error %s", msg); \
|
||||
} while (0)
|
||||
#else
|
||||
#define AssertD(cond, msg) do { } while (0)
|
||||
#endif
|
||||
|
||||
|
||||
/*-- Header bytes. --*/
|
||||
|
||||
#define BZ_HDR_B 0x42 /* 'B' */
|
||||
#define BZ_HDR_Z 0x5a /* 'Z' */
|
||||
#define BZ_HDR_h 0x68 /* 'h' */
|
||||
#define BZ_HDR_0 0x30 /* '0' */
|
||||
|
||||
#define BZ_HDR_BZh0 0x425a6830
|
||||
|
||||
/*-- Constants for the back end. --*/
|
||||
|
||||
#define BZ_MAX_ALPHA_SIZE 258
|
||||
#define BZ_MAX_CODE_LEN 23
|
||||
|
||||
#define BZ_RUNA 0
|
||||
#define BZ_RUNB 1
|
||||
|
||||
#define BZ_N_GROUPS 6
|
||||
#define BZ_G_SIZE 50
|
||||
#define BZ_N_ITERS 4
|
||||
|
||||
#define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE))
|
||||
|
||||
|
||||
/*-- Stuff for doing CRCs. --*/
|
||||
|
||||
#define BZ_INITIALISE_CRC(crcVar) \
|
||||
{ \
|
||||
crcVar = 0xffffffffL; \
|
||||
}
|
||||
|
||||
#define BZ_FINALISE_CRC(crcVar) \
|
||||
{ \
|
||||
crcVar = ~(crcVar); \
|
||||
}
|
||||
|
||||
#define BZ_UPDATE_CRC(s, crcVar, cha) \
|
||||
{ \
|
||||
crcVar = (crcVar << 8) ^ s->crc32table[(crcVar >> 24) ^ ((uint8_t)cha)]; \
|
||||
}
|
||||
|
||||
|
||||
/*-- States and modes for compression. --*/
|
||||
|
||||
#define BZ_M_IDLE 1
|
||||
#define BZ_M_RUNNING 2
|
||||
#define BZ_M_FLUSHING 3
|
||||
#define BZ_M_FINISHING 4
|
||||
|
||||
#define BZ_S_OUTPUT 1
|
||||
#define BZ_S_INPUT 2
|
||||
|
||||
#define BZ_N_RADIX 2
|
||||
#define BZ_N_QSORT 12
|
||||
#define BZ_N_SHELL 18
|
||||
#define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2)
|
||||
|
||||
|
||||
/*-- Structure holding all the compression-side stuff. --*/
|
||||
|
||||
typedef struct EState {
|
||||
/* pointer back to the struct bz_stream */
|
||||
bz_stream *strm;
|
||||
|
||||
/* mode this stream is in, and whether inputting */
|
||||
/* or outputting data */
|
||||
int32_t mode;
|
||||
int32_t state;
|
||||
|
||||
/* remembers avail_in when flush/finish requested */
|
||||
/* bbox: not needed, strm->avail_in always has the same value */
|
||||
/* commented out with '//#' throughout the code */
|
||||
/* uint32_t avail_in_expect; */
|
||||
|
||||
/* for doing the block sorting */
|
||||
int32_t origPtr;
|
||||
uint32_t *arr1;
|
||||
uint32_t *arr2;
|
||||
uint32_t *ftab;
|
||||
|
||||
/* aliases for arr1 and arr2 */
|
||||
uint32_t *ptr;
|
||||
uint8_t *block;
|
||||
uint16_t *mtfv;
|
||||
uint8_t *zbits;
|
||||
|
||||
/* guess what */
|
||||
uint32_t *crc32table;
|
||||
|
||||
/* run-length-encoding of the input */
|
||||
uint32_t state_in_ch;
|
||||
int32_t state_in_len;
|
||||
|
||||
/* input and output limits and current posns */
|
||||
int32_t nblock;
|
||||
int32_t nblockMAX;
|
||||
int32_t numZ;
|
||||
int32_t state_out_pos;
|
||||
|
||||
/* the buffer for bit stream creation */
|
||||
uint32_t bsBuff;
|
||||
int32_t bsLive;
|
||||
|
||||
/* block and combined CRCs */
|
||||
uint32_t blockCRC;
|
||||
uint32_t combinedCRC;
|
||||
|
||||
/* misc administratium */
|
||||
int32_t blockNo;
|
||||
int32_t blockSize100k;
|
||||
|
||||
/* stuff for coding the MTF values */
|
||||
int32_t nMTF;
|
||||
|
||||
/* map of bytes used in block */
|
||||
int32_t nInUse;
|
||||
Bool inUse[256] __attribute__(( aligned(sizeof(long)) ));
|
||||
uint8_t unseqToSeq[256];
|
||||
|
||||
/* stuff for coding the MTF values */
|
||||
int32_t mtfFreq [BZ_MAX_ALPHA_SIZE];
|
||||
uint8_t selector [BZ_MAX_SELECTORS];
|
||||
uint8_t selectorMtf[BZ_MAX_SELECTORS];
|
||||
|
||||
uint8_t len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
int32_t code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
int32_t rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
#if CONFIG_BZIP2_FEATURE_SPEED >= 5
|
||||
/* second dimension: only 3 needed; 4 makes index calculations faster */
|
||||
uint32_t len_pack[BZ_MAX_ALPHA_SIZE][4];
|
||||
#endif
|
||||
} EState;
|
||||
|
||||
|
||||
/*-- compression. --*/
|
||||
|
||||
static void
|
||||
BZ2_blockSort(EState*);
|
||||
|
||||
static void
|
||||
BZ2_compressBlock(EState*, int);
|
||||
|
||||
static void
|
||||
BZ2_bsInitWrite(EState*);
|
||||
|
||||
static void
|
||||
BZ2_hbAssignCodes(int32_t*, uint8_t*, int32_t, int32_t, int32_t);
|
||||
|
||||
static void
|
||||
BZ2_hbMakeCodeLengths(uint8_t*, int32_t*, int32_t, int32_t);
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end bzlib_private.h ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
@@ -0,0 +1,681 @@
|
||||
/*
|
||||
* bzip2 is written by Julian Seward <jseward@bzip.org>.
|
||||
* Adapted for busybox by Denys Vlasenko <vda.linux@googlemail.com>.
|
||||
* See README and LICENSE files in this directory for more information.
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- Compression machinery (not incl block sorting) ---*/
|
||||
/*--- compress.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
This file is part of bzip2/libbzip2, a program and library for
|
||||
lossless, block-sorting data compression.
|
||||
|
||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
||||
|
||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||
README file.
|
||||
|
||||
This program is released under the terms of the license contained
|
||||
in the file LICENSE.
|
||||
------------------------------------------------------------------ */
|
||||
|
||||
/* CHANGES
|
||||
* 0.9.0 -- original version.
|
||||
* 0.9.0a/b -- no changes in this file.
|
||||
* 0.9.0c -- changed setting of nGroups in sendMTFValues()
|
||||
* so as to do a bit better on small files
|
||||
*/
|
||||
|
||||
/* #include "bzlib_private.h" */
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
/*--- Bit stream I/O ---*/
|
||||
/*---------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void BZ2_bsInitWrite(EState* s)
|
||||
{
|
||||
s->bsLive = 0;
|
||||
s->bsBuff = 0;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static NOINLINE
|
||||
void bsFinishWrite(EState* s)
|
||||
{
|
||||
while (s->bsLive > 0) {
|
||||
s->zbits[s->numZ] = (uint8_t)(s->bsBuff >> 24);
|
||||
s->numZ++;
|
||||
s->bsBuff <<= 8;
|
||||
s->bsLive -= 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
/* Helps only on level 5, on other levels hurts. ? */
|
||||
#if CONFIG_BZIP2_FEATURE_SPEED >= 5
|
||||
ALWAYS_INLINE
|
||||
#endif
|
||||
void bsW(EState* s, int32_t n, uint32_t v)
|
||||
{
|
||||
while (s->bsLive >= 8) {
|
||||
s->zbits[s->numZ] = (uint8_t)(s->bsBuff >> 24);
|
||||
s->numZ++;
|
||||
s->bsBuff <<= 8;
|
||||
s->bsLive -= 8;
|
||||
}
|
||||
s->bsBuff |= (v << (32 - s->bsLive - n));
|
||||
s->bsLive += n;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void bsPutU32(EState* s, unsigned u)
|
||||
{
|
||||
bsW(s, 8, (u >> 24) & 0xff);
|
||||
bsW(s, 8, (u >> 16) & 0xff);
|
||||
bsW(s, 8, (u >> 8) & 0xff);
|
||||
bsW(s, 8, u & 0xff);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void bsPutU16(EState* s, unsigned u)
|
||||
{
|
||||
bsW(s, 8, (u >> 8) & 0xff);
|
||||
bsW(s, 8, u & 0xff);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
/*--- The back end proper ---*/
|
||||
/*---------------------------------------------------*/
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void makeMaps_e(EState* s)
|
||||
{
|
||||
int i;
|
||||
s->nInUse = 0;
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (s->inUse[i]) {
|
||||
s->unseqToSeq[i] = s->nInUse;
|
||||
s->nInUse++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static NOINLINE
|
||||
void generateMTFValues(EState* s)
|
||||
{
|
||||
uint8_t yy[256];
|
||||
int32_t i, j;
|
||||
int32_t zPend;
|
||||
int32_t wr;
|
||||
int32_t EOB;
|
||||
|
||||
/*
|
||||
* After sorting (eg, here),
|
||||
* s->arr1[0 .. s->nblock-1] holds sorted order,
|
||||
* and
|
||||
* ((uint8_t*)s->arr2)[0 .. s->nblock-1]
|
||||
* holds the original block data.
|
||||
*
|
||||
* The first thing to do is generate the MTF values,
|
||||
* and put them in
|
||||
* ((uint16_t*)s->arr1)[0 .. s->nblock-1].
|
||||
* Because there are strictly fewer or equal MTF values
|
||||
* than block values, ptr values in this area are overwritten
|
||||
* with MTF values only when they are no longer needed.
|
||||
*
|
||||
* The final compressed bitstream is generated into the
|
||||
* area starting at
|
||||
* &((uint8_t*)s->arr2)[s->nblock]
|
||||
*
|
||||
* These storage aliases are set up in bzCompressInit(),
|
||||
* except for the last one, which is arranged in
|
||||
* compressBlock().
|
||||
*/
|
||||
uint32_t* ptr = s->ptr;
|
||||
uint8_t* block = s->block;
|
||||
uint16_t* mtfv = s->mtfv;
|
||||
|
||||
makeMaps_e(s);
|
||||
EOB = s->nInUse+1;
|
||||
|
||||
for (i = 0; i <= EOB; i++)
|
||||
s->mtfFreq[i] = 0;
|
||||
|
||||
wr = 0;
|
||||
zPend = 0;
|
||||
for (i = 0; i < s->nInUse; i++)
|
||||
yy[i] = (uint8_t) i;
|
||||
|
||||
for (i = 0; i < s->nblock; i++) {
|
||||
uint8_t ll_i;
|
||||
AssertD(wr <= i, "generateMTFValues(1)");
|
||||
j = ptr[i] - 1;
|
||||
if (j < 0)
|
||||
j += s->nblock;
|
||||
ll_i = s->unseqToSeq[block[j]];
|
||||
AssertD(ll_i < s->nInUse, "generateMTFValues(2a)");
|
||||
|
||||
if (yy[0] == ll_i) {
|
||||
zPend++;
|
||||
} else {
|
||||
if (zPend > 0) {
|
||||
zPend--;
|
||||
while (1) {
|
||||
if (zPend & 1) {
|
||||
mtfv[wr] = BZ_RUNB; wr++;
|
||||
s->mtfFreq[BZ_RUNB]++;
|
||||
} else {
|
||||
mtfv[wr] = BZ_RUNA; wr++;
|
||||
s->mtfFreq[BZ_RUNA]++;
|
||||
}
|
||||
if (zPend < 2) break;
|
||||
zPend = (uint32_t)(zPend - 2) / 2;
|
||||
/* bbox: unsigned div is easier */
|
||||
};
|
||||
zPend = 0;
|
||||
}
|
||||
{
|
||||
register uint8_t rtmp;
|
||||
register uint8_t* ryy_j;
|
||||
register uint8_t rll_i;
|
||||
rtmp = yy[1];
|
||||
yy[1] = yy[0];
|
||||
ryy_j = &(yy[1]);
|
||||
rll_i = ll_i;
|
||||
while (rll_i != rtmp) {
|
||||
register uint8_t rtmp2;
|
||||
ryy_j++;
|
||||
rtmp2 = rtmp;
|
||||
rtmp = *ryy_j;
|
||||
*ryy_j = rtmp2;
|
||||
};
|
||||
yy[0] = rtmp;
|
||||
j = ryy_j - &(yy[0]);
|
||||
mtfv[wr] = j+1;
|
||||
wr++;
|
||||
s->mtfFreq[j+1]++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (zPend > 0) {
|
||||
zPend--;
|
||||
while (1) {
|
||||
if (zPend & 1) {
|
||||
mtfv[wr] = BZ_RUNB;
|
||||
wr++;
|
||||
s->mtfFreq[BZ_RUNB]++;
|
||||
} else {
|
||||
mtfv[wr] = BZ_RUNA;
|
||||
wr++;
|
||||
s->mtfFreq[BZ_RUNA]++;
|
||||
}
|
||||
if (zPend < 2)
|
||||
break;
|
||||
zPend = (uint32_t)(zPend - 2) / 2;
|
||||
/* bbox: unsigned div is easier */
|
||||
};
|
||||
zPend = 0;
|
||||
}
|
||||
|
||||
mtfv[wr] = EOB;
|
||||
wr++;
|
||||
s->mtfFreq[EOB]++;
|
||||
|
||||
s->nMTF = wr;
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
#define BZ_LESSER_ICOST 0
|
||||
#define BZ_GREATER_ICOST 15
|
||||
|
||||
static NOINLINE
|
||||
void sendMTFValues(EState* s)
|
||||
{
|
||||
int32_t v, t, i, j, gs, ge, totc, bt, bc, iter;
|
||||
int32_t nSelectors, alphaSize, minLen, maxLen, selCtr;
|
||||
int32_t nGroups, nBytes;
|
||||
|
||||
/*
|
||||
* uint8_t len[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
* is a global since the decoder also needs it.
|
||||
*
|
||||
* int32_t code[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
* int32_t rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE];
|
||||
* are also globals only used in this proc.
|
||||
* Made global to keep stack frame size small.
|
||||
*/
|
||||
|
||||
uint16_t cost[BZ_N_GROUPS];
|
||||
int32_t fave[BZ_N_GROUPS];
|
||||
|
||||
uint16_t* mtfv = s->mtfv;
|
||||
|
||||
alphaSize = s->nInUse+2;
|
||||
for (t = 0; t < BZ_N_GROUPS; t++)
|
||||
for (v = 0; v < alphaSize; v++)
|
||||
s->len[t][v] = BZ_GREATER_ICOST;
|
||||
|
||||
/*--- Decide how many coding tables to use ---*/
|
||||
AssertH(s->nMTF > 0, 3001);
|
||||
if (s->nMTF < 200) nGroups = 2; else
|
||||
if (s->nMTF < 600) nGroups = 3; else
|
||||
if (s->nMTF < 1200) nGroups = 4; else
|
||||
if (s->nMTF < 2400) nGroups = 5; else
|
||||
nGroups = 6;
|
||||
|
||||
/*--- Generate an initial set of coding tables ---*/
|
||||
{
|
||||
int32_t nPart, remF, tFreq, aFreq;
|
||||
|
||||
nPart = nGroups;
|
||||
remF = s->nMTF;
|
||||
gs = 0;
|
||||
while (nPart > 0) {
|
||||
tFreq = remF / nPart;
|
||||
ge = gs - 1;
|
||||
aFreq = 0;
|
||||
while (aFreq < tFreq && ge < alphaSize-1) {
|
||||
ge++;
|
||||
aFreq += s->mtfFreq[ge];
|
||||
}
|
||||
|
||||
if (ge > gs
|
||||
&& nPart != nGroups && nPart != 1
|
||||
&& ((nGroups - nPart) % 2 == 1) /* bbox: can this be replaced by x & 1? */
|
||||
) {
|
||||
aFreq -= s->mtfFreq[ge];
|
||||
ge--;
|
||||
}
|
||||
|
||||
for (v = 0; v < alphaSize; v++)
|
||||
if (v >= gs && v <= ge)
|
||||
s->len[nPart-1][v] = BZ_LESSER_ICOST;
|
||||
else
|
||||
s->len[nPart-1][v] = BZ_GREATER_ICOST;
|
||||
|
||||
nPart--;
|
||||
gs = ge + 1;
|
||||
remF -= aFreq;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Iterate up to BZ_N_ITERS times to improve the tables.
|
||||
*/
|
||||
for (iter = 0; iter < BZ_N_ITERS; iter++) {
|
||||
for (t = 0; t < nGroups; t++)
|
||||
fave[t] = 0;
|
||||
|
||||
for (t = 0; t < nGroups; t++)
|
||||
for (v = 0; v < alphaSize; v++)
|
||||
s->rfreq[t][v] = 0;
|
||||
|
||||
#if CONFIG_BZIP2_FEATURE_SPEED >= 5
|
||||
/*
|
||||
* Set up an auxiliary length table which is used to fast-track
|
||||
* the common case (nGroups == 6).
|
||||
*/
|
||||
if (nGroups == 6) {
|
||||
for (v = 0; v < alphaSize; v++) {
|
||||
s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v];
|
||||
s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v];
|
||||
s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
nSelectors = 0;
|
||||
totc = 0;
|
||||
gs = 0;
|
||||
while (1) {
|
||||
/*--- Set group start & end marks. --*/
|
||||
if (gs >= s->nMTF)
|
||||
break;
|
||||
ge = gs + BZ_G_SIZE - 1;
|
||||
if (ge >= s->nMTF)
|
||||
ge = s->nMTF-1;
|
||||
|
||||
/*
|
||||
* Calculate the cost of this group as coded
|
||||
* by each of the coding tables.
|
||||
*/
|
||||
for (t = 0; t < nGroups; t++)
|
||||
cost[t] = 0;
|
||||
#if CONFIG_BZIP2_FEATURE_SPEED >= 5
|
||||
if (nGroups == 6 && 50 == ge-gs+1) {
|
||||
/*--- fast track the common case ---*/
|
||||
register uint32_t cost01, cost23, cost45;
|
||||
register uint16_t icv;
|
||||
cost01 = cost23 = cost45 = 0;
|
||||
#define BZ_ITER(nn) \
|
||||
icv = mtfv[gs+(nn)]; \
|
||||
cost01 += s->len_pack[icv][0]; \
|
||||
cost23 += s->len_pack[icv][1]; \
|
||||
cost45 += s->len_pack[icv][2];
|
||||
BZ_ITER(0); BZ_ITER(1); BZ_ITER(2); BZ_ITER(3); BZ_ITER(4);
|
||||
BZ_ITER(5); BZ_ITER(6); BZ_ITER(7); BZ_ITER(8); BZ_ITER(9);
|
||||
BZ_ITER(10); BZ_ITER(11); BZ_ITER(12); BZ_ITER(13); BZ_ITER(14);
|
||||
BZ_ITER(15); BZ_ITER(16); BZ_ITER(17); BZ_ITER(18); BZ_ITER(19);
|
||||
BZ_ITER(20); BZ_ITER(21); BZ_ITER(22); BZ_ITER(23); BZ_ITER(24);
|
||||
BZ_ITER(25); BZ_ITER(26); BZ_ITER(27); BZ_ITER(28); BZ_ITER(29);
|
||||
BZ_ITER(30); BZ_ITER(31); BZ_ITER(32); BZ_ITER(33); BZ_ITER(34);
|
||||
BZ_ITER(35); BZ_ITER(36); BZ_ITER(37); BZ_ITER(38); BZ_ITER(39);
|
||||
BZ_ITER(40); BZ_ITER(41); BZ_ITER(42); BZ_ITER(43); BZ_ITER(44);
|
||||
BZ_ITER(45); BZ_ITER(46); BZ_ITER(47); BZ_ITER(48); BZ_ITER(49);
|
||||
#undef BZ_ITER
|
||||
cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16;
|
||||
cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16;
|
||||
cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16;
|
||||
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/*--- slow version which correctly handles all situations ---*/
|
||||
for (i = gs; i <= ge; i++) {
|
||||
uint16_t icv = mtfv[i];
|
||||
for (t = 0; t < nGroups; t++)
|
||||
cost[t] += s->len[t][icv];
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Find the coding table which is best for this group,
|
||||
* and record its identity in the selector table.
|
||||
*/
|
||||
/*bc = 999999999;*/
|
||||
/*bt = -1;*/
|
||||
bc = cost[0];
|
||||
bt = 0;
|
||||
for (t = 1 /*0*/; t < nGroups; t++) {
|
||||
if (cost[t] < bc) {
|
||||
bc = cost[t];
|
||||
bt = t;
|
||||
}
|
||||
}
|
||||
totc += bc;
|
||||
fave[bt]++;
|
||||
s->selector[nSelectors] = bt;
|
||||
nSelectors++;
|
||||
|
||||
/*
|
||||
* Increment the symbol frequencies for the selected table.
|
||||
*/
|
||||
/* 1% faster compress. +800 bytes */
|
||||
#if CONFIG_BZIP2_FEATURE_SPEED >= 4
|
||||
if (nGroups == 6 && 50 == ge-gs+1) {
|
||||
/*--- fast track the common case ---*/
|
||||
#define BZ_ITUR(nn) s->rfreq[bt][mtfv[gs + (nn)]]++
|
||||
BZ_ITUR(0); BZ_ITUR(1); BZ_ITUR(2); BZ_ITUR(3); BZ_ITUR(4);
|
||||
BZ_ITUR(5); BZ_ITUR(6); BZ_ITUR(7); BZ_ITUR(8); BZ_ITUR(9);
|
||||
BZ_ITUR(10); BZ_ITUR(11); BZ_ITUR(12); BZ_ITUR(13); BZ_ITUR(14);
|
||||
BZ_ITUR(15); BZ_ITUR(16); BZ_ITUR(17); BZ_ITUR(18); BZ_ITUR(19);
|
||||
BZ_ITUR(20); BZ_ITUR(21); BZ_ITUR(22); BZ_ITUR(23); BZ_ITUR(24);
|
||||
BZ_ITUR(25); BZ_ITUR(26); BZ_ITUR(27); BZ_ITUR(28); BZ_ITUR(29);
|
||||
BZ_ITUR(30); BZ_ITUR(31); BZ_ITUR(32); BZ_ITUR(33); BZ_ITUR(34);
|
||||
BZ_ITUR(35); BZ_ITUR(36); BZ_ITUR(37); BZ_ITUR(38); BZ_ITUR(39);
|
||||
BZ_ITUR(40); BZ_ITUR(41); BZ_ITUR(42); BZ_ITUR(43); BZ_ITUR(44);
|
||||
BZ_ITUR(45); BZ_ITUR(46); BZ_ITUR(47); BZ_ITUR(48); BZ_ITUR(49);
|
||||
#undef BZ_ITUR
|
||||
gs = ge + 1;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/*--- slow version which correctly handles all situations ---*/
|
||||
while (gs <= ge) {
|
||||
s->rfreq[bt][mtfv[gs]]++;
|
||||
gs++;
|
||||
}
|
||||
/* already is: gs = ge + 1; */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Recompute the tables based on the accumulated frequencies.
|
||||
*/
|
||||
/* maxLen was changed from 20 to 17 in bzip2-1.0.3. See
|
||||
* comment in huffman.c for details. */
|
||||
for (t = 0; t < nGroups; t++)
|
||||
BZ2_hbMakeCodeLengths(&(s->len[t][0]), &(s->rfreq[t][0]), alphaSize, 17 /*20*/);
|
||||
}
|
||||
|
||||
AssertH(nGroups < 8, 3002);
|
||||
AssertH(nSelectors < 32768 && nSelectors <= (2 + (900000 / BZ_G_SIZE)), 3003);
|
||||
|
||||
/*--- Compute MTF values for the selectors. ---*/
|
||||
{
|
||||
uint8_t pos[BZ_N_GROUPS], ll_i, tmp2, tmp;
|
||||
|
||||
for (i = 0; i < nGroups; i++)
|
||||
pos[i] = i;
|
||||
for (i = 0; i < nSelectors; i++) {
|
||||
ll_i = s->selector[i];
|
||||
j = 0;
|
||||
tmp = pos[j];
|
||||
while (ll_i != tmp) {
|
||||
j++;
|
||||
tmp2 = tmp;
|
||||
tmp = pos[j];
|
||||
pos[j] = tmp2;
|
||||
};
|
||||
pos[0] = tmp;
|
||||
s->selectorMtf[i] = j;
|
||||
}
|
||||
};
|
||||
|
||||
/*--- Assign actual codes for the tables. --*/
|
||||
for (t = 0; t < nGroups; t++) {
|
||||
minLen = 32;
|
||||
maxLen = 0;
|
||||
for (i = 0; i < alphaSize; i++) {
|
||||
if (s->len[t][i] > maxLen) maxLen = s->len[t][i];
|
||||
if (s->len[t][i] < minLen) minLen = s->len[t][i];
|
||||
}
|
||||
AssertH(!(maxLen > 17 /*20*/), 3004);
|
||||
AssertH(!(minLen < 1), 3005);
|
||||
BZ2_hbAssignCodes(&(s->code[t][0]), &(s->len[t][0]), minLen, maxLen, alphaSize);
|
||||
}
|
||||
|
||||
/*--- Transmit the mapping table. ---*/
|
||||
{
|
||||
/* bbox: optimized a bit more than in bzip2 */
|
||||
int inUse16 = 0;
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (sizeof(long) <= 4) {
|
||||
inUse16 = inUse16*2 +
|
||||
((*(uint32_t*)&(s->inUse[i * 16 + 0])
|
||||
| *(uint32_t*)&(s->inUse[i * 16 + 4])
|
||||
| *(uint32_t*)&(s->inUse[i * 16 + 8])
|
||||
| *(uint32_t*)&(s->inUse[i * 16 + 12])) != 0);
|
||||
} else { /* Our CPU can do better */
|
||||
inUse16 = inUse16*2 +
|
||||
((*(uint64_t*)&(s->inUse[i * 16 + 0])
|
||||
| *(uint64_t*)&(s->inUse[i * 16 + 8])) != 0);
|
||||
}
|
||||
}
|
||||
|
||||
nBytes = s->numZ;
|
||||
bsW(s, 16, inUse16);
|
||||
|
||||
inUse16 <<= (sizeof(int)*8 - 16); /* move 15th bit into sign bit */
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (inUse16 < 0) {
|
||||
unsigned v16 = 0;
|
||||
for (j = 0; j < 16; j++)
|
||||
v16 = v16*2 + s->inUse[i * 16 + j];
|
||||
bsW(s, 16, v16);
|
||||
}
|
||||
inUse16 <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*--- Now the selectors. ---*/
|
||||
nBytes = s->numZ;
|
||||
bsW(s, 3, nGroups);
|
||||
bsW(s, 15, nSelectors);
|
||||
for (i = 0; i < nSelectors; i++) {
|
||||
for (j = 0; j < s->selectorMtf[i]; j++)
|
||||
bsW(s, 1, 1);
|
||||
bsW(s, 1, 0);
|
||||
}
|
||||
|
||||
/*--- Now the coding tables. ---*/
|
||||
nBytes = s->numZ;
|
||||
|
||||
for (t = 0; t < nGroups; t++) {
|
||||
int32_t curr = s->len[t][0];
|
||||
bsW(s, 5, curr);
|
||||
for (i = 0; i < alphaSize; i++) {
|
||||
while (curr < s->len[t][i]) { bsW(s, 2, 2); curr++; /* 10 */ };
|
||||
while (curr > s->len[t][i]) { bsW(s, 2, 3); curr--; /* 11 */ };
|
||||
bsW(s, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*--- And finally, the block data proper ---*/
|
||||
nBytes = s->numZ;
|
||||
selCtr = 0;
|
||||
gs = 0;
|
||||
while (1) {
|
||||
if (gs >= s->nMTF)
|
||||
break;
|
||||
ge = gs + BZ_G_SIZE - 1;
|
||||
if (ge >= s->nMTF)
|
||||
ge = s->nMTF-1;
|
||||
AssertH(s->selector[selCtr] < nGroups, 3006);
|
||||
|
||||
/* Costs 1300 bytes and is _slower_ (on Intel Core 2) */
|
||||
#if 0
|
||||
if (nGroups == 6 && 50 == ge-gs+1) {
|
||||
/*--- fast track the common case ---*/
|
||||
uint16_t mtfv_i;
|
||||
uint8_t* s_len_sel_selCtr = &(s->len[s->selector[selCtr]][0]);
|
||||
int32_t* s_code_sel_selCtr = &(s->code[s->selector[selCtr]][0]);
|
||||
#define BZ_ITAH(nn) \
|
||||
mtfv_i = mtfv[gs+(nn)]; \
|
||||
bsW(s, s_len_sel_selCtr[mtfv_i], s_code_sel_selCtr[mtfv_i])
|
||||
BZ_ITAH(0); BZ_ITAH(1); BZ_ITAH(2); BZ_ITAH(3); BZ_ITAH(4);
|
||||
BZ_ITAH(5); BZ_ITAH(6); BZ_ITAH(7); BZ_ITAH(8); BZ_ITAH(9);
|
||||
BZ_ITAH(10); BZ_ITAH(11); BZ_ITAH(12); BZ_ITAH(13); BZ_ITAH(14);
|
||||
BZ_ITAH(15); BZ_ITAH(16); BZ_ITAH(17); BZ_ITAH(18); BZ_ITAH(19);
|
||||
BZ_ITAH(20); BZ_ITAH(21); BZ_ITAH(22); BZ_ITAH(23); BZ_ITAH(24);
|
||||
BZ_ITAH(25); BZ_ITAH(26); BZ_ITAH(27); BZ_ITAH(28); BZ_ITAH(29);
|
||||
BZ_ITAH(30); BZ_ITAH(31); BZ_ITAH(32); BZ_ITAH(33); BZ_ITAH(34);
|
||||
BZ_ITAH(35); BZ_ITAH(36); BZ_ITAH(37); BZ_ITAH(38); BZ_ITAH(39);
|
||||
BZ_ITAH(40); BZ_ITAH(41); BZ_ITAH(42); BZ_ITAH(43); BZ_ITAH(44);
|
||||
BZ_ITAH(45); BZ_ITAH(46); BZ_ITAH(47); BZ_ITAH(48); BZ_ITAH(49);
|
||||
#undef BZ_ITAH
|
||||
gs = ge+1;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/*--- slow version which correctly handles all situations ---*/
|
||||
/* code is bit bigger, but moves multiply out of the loop */
|
||||
uint8_t* s_len_sel_selCtr = &(s->len [s->selector[selCtr]][0]);
|
||||
int32_t* s_code_sel_selCtr = &(s->code[s->selector[selCtr]][0]);
|
||||
while (gs <= ge) {
|
||||
bsW(s,
|
||||
s_len_sel_selCtr[mtfv[gs]],
|
||||
s_code_sel_selCtr[mtfv[gs]]
|
||||
);
|
||||
gs++;
|
||||
}
|
||||
/* already is: gs = ge+1; */
|
||||
}
|
||||
selCtr++;
|
||||
}
|
||||
AssertH(selCtr == nSelectors, 3007);
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void BZ2_compressBlock(EState* s, int is_last_block)
|
||||
{
|
||||
if (s->nblock > 0) {
|
||||
BZ_FINALISE_CRC(s->blockCRC);
|
||||
s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31);
|
||||
s->combinedCRC ^= s->blockCRC;
|
||||
if (s->blockNo > 1)
|
||||
s->numZ = 0;
|
||||
|
||||
BZ2_blockSort(s);
|
||||
}
|
||||
|
||||
s->zbits = &((uint8_t*)s->arr2)[s->nblock];
|
||||
|
||||
/*-- If this is the first block, create the stream header. --*/
|
||||
if (s->blockNo == 1) {
|
||||
BZ2_bsInitWrite(s);
|
||||
/*bsPutU8(s, BZ_HDR_B);*/
|
||||
/*bsPutU8(s, BZ_HDR_Z);*/
|
||||
/*bsPutU8(s, BZ_HDR_h);*/
|
||||
/*bsPutU8(s, BZ_HDR_0 + s->blockSize100k);*/
|
||||
bsPutU32(s, BZ_HDR_BZh0 + s->blockSize100k);
|
||||
}
|
||||
|
||||
if (s->nblock > 0) {
|
||||
/*bsPutU8(s, 0x31);*/
|
||||
/*bsPutU8(s, 0x41);*/
|
||||
/*bsPutU8(s, 0x59);*/
|
||||
/*bsPutU8(s, 0x26);*/
|
||||
bsPutU32(s, 0x31415926);
|
||||
/*bsPutU8(s, 0x53);*/
|
||||
/*bsPutU8(s, 0x59);*/
|
||||
bsPutU16(s, 0x5359);
|
||||
|
||||
/*-- Now the block's CRC, so it is in a known place. --*/
|
||||
bsPutU32(s, s->blockCRC);
|
||||
|
||||
/*
|
||||
* Now a single bit indicating (non-)randomisation.
|
||||
* As of version 0.9.5, we use a better sorting algorithm
|
||||
* which makes randomisation unnecessary. So always set
|
||||
* the randomised bit to 'no'. Of course, the decoder
|
||||
* still needs to be able to handle randomised blocks
|
||||
* so as to maintain backwards compatibility with
|
||||
* older versions of bzip2.
|
||||
*/
|
||||
bsW(s, 1, 0);
|
||||
|
||||
bsW(s, 24, s->origPtr);
|
||||
generateMTFValues(s);
|
||||
sendMTFValues(s);
|
||||
}
|
||||
|
||||
/*-- If this is the last block, add the stream trailer. --*/
|
||||
if (is_last_block) {
|
||||
/*bsPutU8(s, 0x17);*/
|
||||
/*bsPutU8(s, 0x72);*/
|
||||
/*bsPutU8(s, 0x45);*/
|
||||
/*bsPutU8(s, 0x38);*/
|
||||
bsPutU32(s, 0x17724538);
|
||||
/*bsPutU8(s, 0x50);*/
|
||||
/*bsPutU8(s, 0x90);*/
|
||||
bsPutU16(s, 0x5090);
|
||||
bsPutU32(s, s->combinedCRC);
|
||||
bsFinishWrite(s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end compress.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
@@ -0,0 +1,220 @@
|
||||
/*
|
||||
* bzip2 is written by Julian Seward <jseward@bzip.org>.
|
||||
* Adapted for busybox by Denys Vlasenko <vda.linux@googlemail.com>.
|
||||
* See README and LICENSE files in this directory for more information.
|
||||
*/
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- Huffman coding low-level stuff ---*/
|
||||
/*--- huffman.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
/* ------------------------------------------------------------------
|
||||
This file is part of bzip2/libbzip2, a program and library for
|
||||
lossless, block-sorting data compression.
|
||||
|
||||
bzip2/libbzip2 version 1.0.4 of 20 December 2006
|
||||
Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
|
||||
|
||||
Please read the WARNING, DISCLAIMER and PATENTS sections in the
|
||||
README file.
|
||||
|
||||
This program is released under the terms of the license contained
|
||||
in the file LICENSE.
|
||||
------------------------------------------------------------------ */
|
||||
|
||||
/* #include "bzlib_private.h" */
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
#define WEIGHTOF(zz0) ((zz0) & 0xffffff00)
|
||||
#define DEPTHOF(zz1) ((zz1) & 0x000000ff)
|
||||
#define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3))
|
||||
|
||||
#define ADDWEIGHTS(zw1,zw2) \
|
||||
(WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \
|
||||
(1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2)))
|
||||
|
||||
#define UPHEAP(z) \
|
||||
{ \
|
||||
int32_t zz, tmp; \
|
||||
zz = z; \
|
||||
tmp = heap[zz]; \
|
||||
while (weight[tmp] < weight[heap[zz >> 1]]) { \
|
||||
heap[zz] = heap[zz >> 1]; \
|
||||
zz >>= 1; \
|
||||
} \
|
||||
heap[zz] = tmp; \
|
||||
}
|
||||
|
||||
|
||||
/* 90 bytes, 0.3% of overall compress speed */
|
||||
#if CONFIG_BZIP2_FEATURE_SPEED >= 1
|
||||
|
||||
/* macro works better than inline (gcc 4.2.1) */
|
||||
#define DOWNHEAP1(heap, weight, Heap) \
|
||||
{ \
|
||||
int32_t zz, yy, tmp; \
|
||||
zz = 1; \
|
||||
tmp = heap[zz]; \
|
||||
while (1) { \
|
||||
yy = zz << 1; \
|
||||
if (yy > nHeap) \
|
||||
break; \
|
||||
if (yy < nHeap \
|
||||
&& weight[heap[yy+1]] < weight[heap[yy]]) \
|
||||
yy++; \
|
||||
if (weight[tmp] < weight[heap[yy]]) \
|
||||
break; \
|
||||
heap[zz] = heap[yy]; \
|
||||
zz = yy; \
|
||||
} \
|
||||
heap[zz] = tmp; \
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static
|
||||
void DOWNHEAP1(int32_t *heap, int32_t *weight, int32_t nHeap)
|
||||
{
|
||||
int32_t zz, yy, tmp;
|
||||
zz = 1;
|
||||
tmp = heap[zz];
|
||||
while (1) {
|
||||
yy = zz << 1;
|
||||
if (yy > nHeap)
|
||||
break;
|
||||
if (yy < nHeap
|
||||
&& weight[heap[yy + 1]] < weight[heap[yy]])
|
||||
yy++;
|
||||
if (weight[tmp] < weight[heap[yy]])
|
||||
break;
|
||||
heap[zz] = heap[yy];
|
||||
zz = yy;
|
||||
}
|
||||
heap[zz] = tmp;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void BZ2_hbMakeCodeLengths(uint8_t *len,
|
||||
int32_t *freq,
|
||||
int32_t alphaSize,
|
||||
int32_t maxLen)
|
||||
{
|
||||
/*
|
||||
* Nodes and heap entries run from 1. Entry 0
|
||||
* for both the heap and nodes is a sentinel.
|
||||
*/
|
||||
int32_t nNodes, nHeap, n1, n2, i, j, k;
|
||||
Bool tooLong;
|
||||
|
||||
int32_t heap [BZ_MAX_ALPHA_SIZE + 2];
|
||||
int32_t weight[BZ_MAX_ALPHA_SIZE * 2];
|
||||
int32_t parent[BZ_MAX_ALPHA_SIZE * 2];
|
||||
|
||||
for (i = 0; i < alphaSize; i++)
|
||||
weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8;
|
||||
|
||||
while (1) {
|
||||
nNodes = alphaSize;
|
||||
nHeap = 0;
|
||||
|
||||
heap[0] = 0;
|
||||
weight[0] = 0;
|
||||
parent[0] = -2;
|
||||
|
||||
for (i = 1; i <= alphaSize; i++) {
|
||||
parent[i] = -1;
|
||||
nHeap++;
|
||||
heap[nHeap] = i;
|
||||
UPHEAP(nHeap);
|
||||
}
|
||||
|
||||
AssertH(nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001);
|
||||
|
||||
while (nHeap > 1) {
|
||||
n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP1(heap, weight, nHeap);
|
||||
n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP1(heap, weight, nHeap);
|
||||
nNodes++;
|
||||
parent[n1] = parent[n2] = nNodes;
|
||||
weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]);
|
||||
parent[nNodes] = -1;
|
||||
nHeap++;
|
||||
heap[nHeap] = nNodes;
|
||||
UPHEAP(nHeap);
|
||||
}
|
||||
|
||||
AssertH(nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002);
|
||||
|
||||
tooLong = False;
|
||||
for (i = 1; i <= alphaSize; i++) {
|
||||
j = 0;
|
||||
k = i;
|
||||
while (parent[k] >= 0) {
|
||||
k = parent[k];
|
||||
j++;
|
||||
}
|
||||
len[i-1] = j;
|
||||
if (j > maxLen)
|
||||
tooLong = True;
|
||||
}
|
||||
|
||||
if (!tooLong)
|
||||
break;
|
||||
|
||||
/* 17 Oct 04: keep-going condition for the following loop used
|
||||
to be 'i < alphaSize', which missed the last element,
|
||||
theoretically leading to the possibility of the compressor
|
||||
looping. However, this count-scaling step is only needed if
|
||||
one of the generated Huffman code words is longer than
|
||||
maxLen, which up to and including version 1.0.2 was 20 bits,
|
||||
which is extremely unlikely. In version 1.0.3 maxLen was
|
||||
changed to 17 bits, which has minimal effect on compression
|
||||
ratio, but does mean this scaling step is used from time to
|
||||
time, enough to verify that it works.
|
||||
|
||||
This means that bzip2-1.0.3 and later will only produce
|
||||
Huffman codes with a maximum length of 17 bits. However, in
|
||||
order to preserve backwards compatibility with bitstreams
|
||||
produced by versions pre-1.0.3, the decompressor must still
|
||||
handle lengths of up to 20. */
|
||||
|
||||
for (i = 1; i <= alphaSize; i++) {
|
||||
j = weight[i] >> 8;
|
||||
/* bbox: yes, it is a signed division.
|
||||
* don't replace with shift! */
|
||||
j = 1 + (j / 2);
|
||||
weight[i] = j << 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*---------------------------------------------------*/
|
||||
static
|
||||
void BZ2_hbAssignCodes(int32_t *code,
|
||||
uint8_t *length,
|
||||
int32_t minLen,
|
||||
int32_t maxLen,
|
||||
int32_t alphaSize)
|
||||
{
|
||||
int32_t n, vec, i;
|
||||
|
||||
vec = 0;
|
||||
for (n = minLen; n <= maxLen; n++) {
|
||||
for (i = 0; i < alphaSize; i++) {
|
||||
if (length[i] == n) {
|
||||
code[i] = vec;
|
||||
vec++;
|
||||
};
|
||||
}
|
||||
vec <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/*--- end huffman.c ---*/
|
||||
/*-------------------------------------------------------------*/
|
||||
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Copyright (C) 2007 Denys Vlasenko <vda.linux@googlemail.com>
|
||||
*
|
||||
* This file uses bzip2 library code which is written
|
||||
* by Julian Seward <jseward@bzip.org>.
|
||||
* See README and LICENSE files in bz/ directory for more information
|
||||
* about bzip2 library code.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
#define CONFIG_BZIP2_FEATURE_SPEED 1
|
||||
|
||||
/* Speed test:
|
||||
* Compiled with gcc 4.2.1, run on Athlon 64 1800 MHz (512K L2 cache).
|
||||
* Stock bzip2 is 26.4% slower than bbox bzip2 at SPEED 1
|
||||
* (time to compress gcc-4.2.1.tar is 126.4% compared to bbox).
|
||||
* At SPEED 5 difference is 32.7%.
|
||||
*
|
||||
* Test run of all CONFIG_BZIP2_FEATURE_SPEED values on a 11Mb text file:
|
||||
* Size Time (3 runs)
|
||||
* 0: 10828 4.145 4.146 4.148
|
||||
* 1: 11097 3.845 3.860 3.861
|
||||
* 2: 11392 3.763 3.767 3.768
|
||||
* 3: 11892 3.722 3.724 3.727
|
||||
* 4: 12740 3.637 3.640 3.644
|
||||
* 5: 17273 3.497 3.509 3.509
|
||||
*/
|
||||
|
||||
|
||||
#define BZ_DEBUG 0
|
||||
/* Takes ~300 bytes, detects corruption caused by bad RAM etc */
|
||||
#define BZ_LIGHT_DEBUG 0
|
||||
|
||||
#include "bz/bzlib.h"
|
||||
|
||||
#include "bz/bzlib_private.h"
|
||||
|
||||
#include "bz/blocksort.c"
|
||||
#include "bz/bzlib.c"
|
||||
#include "bz/compress.c"
|
||||
#include "bz/huffman.c"
|
||||
|
||||
/* No point in being shy and having very small buffer here.
|
||||
* bzip2 internal buffers are much bigger anyway, hundreds of kbytes.
|
||||
* If iobuf is several pages long, malloc() may use mmap,
|
||||
* making iobuf is page aligned and thus (maybe) have one memcpy less
|
||||
* if kernel is clever enough.
|
||||
*/
|
||||
enum {
|
||||
IOBUF_SIZE = 8 * 1024
|
||||
};
|
||||
|
||||
static uint8_t level;
|
||||
|
||||
/* NB: compressStream() has to return -1 on errors, not die.
|
||||
* bbunpack() will correctly clean up in this case
|
||||
* (delete incomplete .bz2 file)
|
||||
*/
|
||||
|
||||
/* Returns:
|
||||
* -1 on errors
|
||||
* total written bytes so far otherwise
|
||||
*/
|
||||
static
|
||||
USE_DESKTOP(long long) int bz_write(bz_stream *strm, void* rbuf, ssize_t rlen, void *wbuf)
|
||||
{
|
||||
int n, n2, ret;
|
||||
|
||||
strm->avail_in = rlen;
|
||||
strm->next_in = rbuf;
|
||||
while (1) {
|
||||
strm->avail_out = IOBUF_SIZE;
|
||||
strm->next_out = wbuf;
|
||||
|
||||
ret = BZ2_bzCompress(strm, rlen ? BZ_RUN : BZ_FINISH);
|
||||
if (ret != BZ_RUN_OK /* BZ_RUNning */
|
||||
&& ret != BZ_FINISH_OK /* BZ_FINISHing, but not done yet */
|
||||
&& ret != BZ_STREAM_END /* BZ_FINISHed */
|
||||
) {
|
||||
bb_error_msg_and_die("internal error %d", ret);
|
||||
}
|
||||
|
||||
n = IOBUF_SIZE - strm->avail_out;
|
||||
if (n) {
|
||||
n2 = full_write(STDOUT_FILENO, wbuf, n);
|
||||
if (n2 != n) {
|
||||
if (n2 >= 0)
|
||||
errno = 0; /* prevent bogus error message */
|
||||
bb_perror_msg(n2 >= 0 ? "short write" : "write error");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret == BZ_STREAM_END)
|
||||
break;
|
||||
if (rlen && strm->avail_in == 0)
|
||||
break;
|
||||
}
|
||||
return 0 USE_DESKTOP( + strm->total_out );
|
||||
}
|
||||
|
||||
static
|
||||
USE_DESKTOP(long long) int compressStream(void)
|
||||
{
|
||||
USE_DESKTOP(long long) int total;
|
||||
ssize_t count;
|
||||
bz_stream bzs; /* it's small */
|
||||
#define strm (&bzs)
|
||||
char *iobuf;
|
||||
#define rbuf iobuf
|
||||
#define wbuf (iobuf + IOBUF_SIZE)
|
||||
|
||||
iobuf = xmalloc(2 * IOBUF_SIZE);
|
||||
BZ2_bzCompressInit(strm, level);
|
||||
|
||||
while (1) {
|
||||
count = full_read(STDIN_FILENO, rbuf, IOBUF_SIZE);
|
||||
if (count < 0) {
|
||||
bb_perror_msg("read error");
|
||||
total = -1;
|
||||
break;
|
||||
}
|
||||
/* if count == 0, bz_write finalizes compression */
|
||||
total = bz_write(strm, rbuf, count, wbuf);
|
||||
if (count == 0 || total < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_CLEAN_UP
|
||||
BZ2_bzCompressEnd(strm);
|
||||
free(iobuf);
|
||||
#endif
|
||||
return total;
|
||||
}
|
||||
|
||||
static
|
||||
char* make_new_name_bzip2(char *filename)
|
||||
{
|
||||
return xasprintf("%s.bz2", filename);
|
||||
}
|
||||
|
||||
int bzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int bzip2_main(int argc, char **argv)
|
||||
{
|
||||
unsigned opt;
|
||||
|
||||
/* standard bzip2 flags
|
||||
* -d --decompress force decompression
|
||||
* -z --compress force compression
|
||||
* -k --keep keep (don't delete) input files
|
||||
* -f --force overwrite existing output files
|
||||
* -t --test test compressed file integrity
|
||||
* -c --stdout output to standard out
|
||||
* -q --quiet suppress noncritical error messages
|
||||
* -v --verbose be verbose (a 2nd -v gives more)
|
||||
* -s --small use less memory (at most 2500k)
|
||||
* -1 .. -9 set block size to 100k .. 900k
|
||||
* --fast alias for -1
|
||||
* --best alias for -9
|
||||
*/
|
||||
|
||||
opt_complementary = "s2"; /* -s means -2 (compatibility) */
|
||||
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
|
||||
opt = getopt32(argv, "cfv" USE_BUNZIP2("d") "123456789qzs" );
|
||||
#if ENABLE_BUNZIP2 /* bunzip2_main may not be visible... */
|
||||
if (opt & 0x8) // -d
|
||||
return bunzip2_main(argc, argv);
|
||||
opt >>= 4;
|
||||
#else
|
||||
opt >>= 3;
|
||||
#endif
|
||||
opt = (uint8_t)opt; /* isolate bits for -1..-8 */
|
||||
opt |= 0x100; /* if nothing else, assume -9 */
|
||||
level = 1;
|
||||
while (!(opt & 1)) {
|
||||
level++;
|
||||
opt >>= 1;
|
||||
}
|
||||
|
||||
argv += optind;
|
||||
option_mask32 &= 0x7; /* ignore all except -cfv */
|
||||
return bbunpack(argv, make_new_name_bzip2, compressStream);
|
||||
}
|
||||
+10
-13
@@ -11,21 +11,18 @@
|
||||
* Only supports new ASCII and CRC formats
|
||||
*
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
#define CPIO_OPT_EXTRACT 0x01
|
||||
#define CPIO_OPT_TEST 0x02
|
||||
#define CPIO_OPT_UNCONDITIONAL 0x04
|
||||
#define CPIO_OPT_VERBOSE 0x08
|
||||
#define CPIO_OPT_FILE 0x10
|
||||
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
|
||||
#define CPIO_OPT_PRESERVE_MTIME 0x40
|
||||
#define CPIO_OPT_EXTRACT 0x01
|
||||
#define CPIO_OPT_TEST 0x02
|
||||
#define CPIO_OPT_UNCONDITIONAL 0x04
|
||||
#define CPIO_OPT_VERBOSE 0x08
|
||||
#define CPIO_OPT_FILE 0x10
|
||||
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
|
||||
#define CPIO_OPT_PRESERVE_MTIME 0x40
|
||||
|
||||
int cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int cpio_main(int argc, char **argv)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
@@ -38,7 +35,7 @@ int cpio_main(int argc, char **argv)
|
||||
archive_handle->seek = seek_by_read;
|
||||
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
|
||||
|
||||
opt = getopt32(argc, argv, "ituvF:dm", &cpio_filename);
|
||||
opt = getopt32(argv, "ituvF:dm", &cpio_filename);
|
||||
|
||||
/* One of either extract or test options must be given */
|
||||
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
|
||||
|
||||
+111
-121
@@ -24,7 +24,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/* note: if you vary hash_prime sizes be aware,
|
||||
@@ -53,16 +53,16 @@
|
||||
* and available file */
|
||||
#define PACKAGE_HASH_PRIME 10007
|
||||
typedef struct edge_s {
|
||||
unsigned operator:3;
|
||||
unsigned operator:4; /* was:3 */
|
||||
unsigned type:4;
|
||||
unsigned name:14;
|
||||
unsigned version:14;
|
||||
unsigned name:16; /* was:14 */
|
||||
unsigned version:16; /* was:14 */
|
||||
} edge_t;
|
||||
|
||||
typedef struct common_node_s {
|
||||
unsigned name:14;
|
||||
unsigned version:14;
|
||||
unsigned num_of_edges:14;
|
||||
unsigned name:16; /* was:14 */
|
||||
unsigned version:16; /* was:14 */
|
||||
unsigned num_of_edges:16; /* was:14 */
|
||||
edge_t **edge;
|
||||
} common_node_t;
|
||||
|
||||
@@ -71,8 +71,8 @@ typedef struct common_node_s {
|
||||
* likely to be installed at any one time, so there is a bit of leeway here */
|
||||
#define STATUS_HASH_PRIME 8191
|
||||
typedef struct status_node_s {
|
||||
unsigned package:14; /* has to fit PACKAGE_HASH_PRIME */
|
||||
unsigned status:14; /* has to fit STATUS_HASH_PRIME */
|
||||
unsigned package:16; /* was:14 */ /* has to fit PACKAGE_HASH_PRIME */
|
||||
unsigned status:16; /* was:14 */ /* has to fit STATUS_HASH_PRIME */
|
||||
} status_node_t;
|
||||
|
||||
/* Were statically declared here, but such a big bss is nommu-unfriendly */
|
||||
@@ -107,13 +107,13 @@ enum operator_e {
|
||||
typedef struct deb_file_s {
|
||||
char *control_file;
|
||||
char *filename;
|
||||
unsigned package:14;
|
||||
unsigned package:16; /* was:14 */
|
||||
} deb_file_t;
|
||||
|
||||
|
||||
static void make_hash(const char *key, unsigned *start, unsigned *decrement, const int hash_prime)
|
||||
{
|
||||
unsigned long int hash_num = key[0];
|
||||
unsigned long hash_num = key[0];
|
||||
int len = strlen(key);
|
||||
int i;
|
||||
|
||||
@@ -352,7 +352,8 @@ static int search_package_hashtable(const unsigned name, const unsigned version,
|
||||
* FIXME: I don't think this is very efficient, but I thought I'd keep
|
||||
* it simple for now until it proves to be a problem.
|
||||
*/
|
||||
static int search_for_provides(int needle, int start_at) {
|
||||
static int search_for_provides(int needle, int start_at)
|
||||
{
|
||||
int i, j;
|
||||
common_node_t *p;
|
||||
for (i = start_at + 1; i < PACKAGE_HASH_PRIME; i++) {
|
||||
@@ -412,7 +413,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
|
||||
or_edge = xmalloc(sizeof(edge_t));
|
||||
or_edge->type = edge_type + 1;
|
||||
or_edge->name = search_name_hashtable(field);
|
||||
or_edge->version = 0; // tracks the number of altenatives
|
||||
or_edge->version = 0; // tracks the number of alternatives
|
||||
add_edge_to_node(parent_node, or_edge);
|
||||
}
|
||||
|
||||
@@ -431,7 +432,7 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
|
||||
edge->version = search_name_hashtable("ANY");
|
||||
} else {
|
||||
/* Skip leading ' ' or '(' */
|
||||
version += strspn(field2, " (");
|
||||
version += strspn(version, " (");
|
||||
/* Calculate length of any operator characters */
|
||||
offset_ch = strspn(version, "<=>");
|
||||
/* Determine operator */
|
||||
@@ -472,9 +473,13 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
|
||||
or_edge->version++;
|
||||
|
||||
add_edge_to_node(parent_node, edge);
|
||||
} while ((field2 = strtok_r(NULL, "|", &line_ptr2)) != NULL);
|
||||
field2 = strtok_r(NULL, "|", &line_ptr2);
|
||||
} while (field2 != NULL);
|
||||
|
||||
free(line2);
|
||||
} while ((field = strtok_r(NULL, ",", &line_ptr1)) != NULL);
|
||||
field = strtok_r(NULL, ",", &line_ptr1);
|
||||
} while (field != NULL);
|
||||
|
||||
free(line);
|
||||
}
|
||||
|
||||
@@ -577,10 +582,10 @@ static int read_package_field(const char *package_buffer, char **field_name, cha
|
||||
|
||||
static unsigned fill_package_struct(char *control_buffer)
|
||||
{
|
||||
static const char *const field_names[] = { "Package", "Version",
|
||||
"Pre-Depends", "Depends","Replaces", "Provides",
|
||||
"Conflicts", "Suggests", "Recommends", "Enhances", 0
|
||||
};
|
||||
static const char field_names[] ALIGN1 =
|
||||
"Package\0""Version\0"
|
||||
"Pre-Depends\0""Depends\0""Replaces\0""Provides\0"
|
||||
"Conflicts\0""Suggests\0""Recommends\0""Enhances\0";
|
||||
|
||||
common_node_t *new_node = xzalloc(sizeof(common_node_t));
|
||||
char *field_name;
|
||||
@@ -597,10 +602,10 @@ static unsigned fill_package_struct(char *control_buffer)
|
||||
&field_name, &field_value);
|
||||
|
||||
if (field_name == NULL) {
|
||||
goto fill_package_struct_cleanup; /* Oh no, the dreaded goto statement ! */
|
||||
goto fill_package_struct_cleanup; /* Oh no, the dreaded goto statement! */
|
||||
}
|
||||
|
||||
field_num = index_in_str_array(field_names, field_name);
|
||||
field_num = index_in_strings(field_names, field_name);
|
||||
switch (field_num) {
|
||||
case 0: /* Package */
|
||||
new_node->name = search_name_hashtable(field_value);
|
||||
@@ -643,11 +648,8 @@ static unsigned fill_package_struct(char *control_buffer)
|
||||
return -1;
|
||||
}
|
||||
num = search_package_hashtable(new_node->name, new_node->version, VER_EQUAL);
|
||||
if (package_hashtable[num] == NULL) {
|
||||
package_hashtable[num] = new_node;
|
||||
} else {
|
||||
free_package(new_node);
|
||||
}
|
||||
free_package(package_hashtable[num]);
|
||||
package_hashtable[num] = new_node;
|
||||
return num;
|
||||
}
|
||||
|
||||
@@ -706,13 +708,13 @@ static void set_status(const unsigned status_node_num, const char *new_value, co
|
||||
new_status = xasprintf("%s %s %s", name_hashtable[want], name_hashtable[flag], name_hashtable[status]);
|
||||
status_hashtable[status_node_num]->status = search_name_hashtable(new_status);
|
||||
free(new_status);
|
||||
return;
|
||||
}
|
||||
|
||||
static const char *describe_status(int status_num) {
|
||||
int status_want, status_state ;
|
||||
static const char *describe_status(int status_num)
|
||||
{
|
||||
int status_want, status_state;
|
||||
if (status_hashtable[status_num] == NULL || status_hashtable[status_num]->status == 0)
|
||||
return "is not installed or flagged to be installed\n";
|
||||
return "is not installed or flagged to be installed";
|
||||
|
||||
status_want = get_status(status_num, 1);
|
||||
status_state = get_status(status_num, 3);
|
||||
@@ -725,7 +727,7 @@ static const char *describe_status(int status_num) {
|
||||
if (status_want == search_name_hashtable("purge"))
|
||||
return "is marked to be purged";
|
||||
}
|
||||
if (status_want == search_name_hashtable("unknown"))
|
||||
if (status_want == search_name_hashtable("unknown"))
|
||||
return "is in an indeterminate state";
|
||||
if (status_want == search_name_hashtable("install"))
|
||||
return "is marked to be installed";
|
||||
@@ -763,7 +765,6 @@ static void index_status_file(const char *filename)
|
||||
free(control_buffer);
|
||||
}
|
||||
fclose(status_file);
|
||||
return;
|
||||
}
|
||||
|
||||
static void write_buffer_no_status(FILE *new_status_file, const char *control_buffer)
|
||||
@@ -780,7 +781,6 @@ static void write_buffer_no_status(FILE *new_status_file, const char *control_bu
|
||||
fprintf(new_status_file, "%s: %s\n", name, value);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* This could do with a cleanup */
|
||||
@@ -799,7 +799,8 @@ static void write_status_file(deb_file_t **deb_file)
|
||||
|
||||
/* Update previously known packages */
|
||||
while ((control_buffer = xmalloc_fgets_str(old_status_file, "\n\n")) != NULL) {
|
||||
if ((tmp_string = strstr(control_buffer, "Package:")) == NULL) {
|
||||
tmp_string = strstr(control_buffer, "Package:");
|
||||
if (tmp_string == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -824,8 +825,9 @@ static void write_status_file(deb_file_t **deb_file)
|
||||
if (strcmp(status_from_file, status_from_hashtable) != 0) {
|
||||
/* New status isnt exactly the same as old status */
|
||||
const int state_status = get_status(status_num, 3);
|
||||
if ((strcmp("installed", name_hashtable[state_status]) == 0) ||
|
||||
(strcmp("unpacked", name_hashtable[state_status]) == 0)) {
|
||||
if ((strcmp("installed", name_hashtable[state_status]) == 0)
|
||||
|| (strcmp("unpacked", name_hashtable[state_status]) == 0)
|
||||
) {
|
||||
/* We need to add the control file from the package */
|
||||
i = 0;
|
||||
while (deb_file[i] != NULL) {
|
||||
@@ -890,7 +892,7 @@ static void write_status_file(deb_file_t **deb_file)
|
||||
}
|
||||
}
|
||||
/* If the package from the status file wasnt handle above, do it now*/
|
||||
if (! write_flag) {
|
||||
if (!write_flag) {
|
||||
fprintf(new_status_file, "%s\n\n", control_buffer);
|
||||
}
|
||||
|
||||
@@ -1071,12 +1073,14 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
const edge_t *package_edge = package_node->edge[j];
|
||||
unsigned package_num;
|
||||
|
||||
if (package_edge->type == EDGE_OR_PRE_DEPENDS ||
|
||||
package_edge->type == EDGE_OR_DEPENDS) { /* start an EDGE_OR_ list */
|
||||
if (package_edge->type == EDGE_OR_PRE_DEPENDS
|
||||
|| package_edge->type == EDGE_OR_DEPENDS
|
||||
) { /* start an EDGE_OR_ list */
|
||||
number_of_alternatives = package_edge->version;
|
||||
root_of_alternatives = package_edge;
|
||||
continue;
|
||||
} else if (number_of_alternatives == 0) { /* not in the middle of an EDGE_OR_ list */
|
||||
}
|
||||
if (number_of_alternatives == 0) { /* not in the middle of an EDGE_OR_ list */
|
||||
number_of_alternatives = 1;
|
||||
root_of_alternatives = NULL;
|
||||
}
|
||||
@@ -1126,14 +1130,14 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
name_hashtable[package_node->name],
|
||||
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
|
||||
name_hashtable[root_of_alternatives->name]);
|
||||
else
|
||||
bb_error_msg_and_die(
|
||||
"package %s %sdepends on %s, which %s\n",
|
||||
name_hashtable[package_node->name],
|
||||
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
|
||||
name_hashtable[package_edge->name],
|
||||
describe_status(status_num));
|
||||
} else if (result == 0 && number_of_alternatives) {
|
||||
bb_error_msg_and_die(
|
||||
"package %s %sdepends on %s, which %s\n",
|
||||
name_hashtable[package_node->name],
|
||||
package_edge->type == EDGE_PRE_DEPENDS ? "pre-" : "",
|
||||
name_hashtable[package_edge->name],
|
||||
describe_status(status_num));
|
||||
}
|
||||
if (result == 0 && number_of_alternatives) {
|
||||
/* we've found a package which
|
||||
* satisfies the dependency,
|
||||
* so skip over the rest of
|
||||
@@ -1171,49 +1175,42 @@ static char **create_list(const char *filename)
|
||||
|
||||
if (count == 0) {
|
||||
return NULL;
|
||||
} else {
|
||||
file_list[count] = NULL;
|
||||
return file_list;
|
||||
}
|
||||
file_list[count] = NULL;
|
||||
return file_list;
|
||||
}
|
||||
|
||||
/* maybe i should try and hook this into remove_file.c somehow */
|
||||
static int remove_file_array(char **remove_names, char **exclude_names)
|
||||
{
|
||||
struct stat path_stat;
|
||||
int match_flag;
|
||||
int remove_flag = FALSE;
|
||||
int i,j;
|
||||
int remove_flag = 1; /* not removed anything yet */
|
||||
int i, j;
|
||||
|
||||
if (remove_names == NULL) {
|
||||
return FALSE;
|
||||
return 0;
|
||||
}
|
||||
for (i = 0; remove_names[i] != NULL; i++) {
|
||||
match_flag = FALSE;
|
||||
if (exclude_names != NULL) {
|
||||
for (j = 0; exclude_names[j] != 0; j++) {
|
||||
for (j = 0; exclude_names[j] != NULL; j++) {
|
||||
if (strcmp(remove_names[i], exclude_names[j]) == 0) {
|
||||
match_flag = TRUE;
|
||||
break;
|
||||
goto skip;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!match_flag) {
|
||||
if (lstat(remove_names[i], &path_stat) < 0) {
|
||||
continue;
|
||||
}
|
||||
if (S_ISDIR(path_stat.st_mode)) {
|
||||
if (rmdir(remove_names[i]) != -1) {
|
||||
remove_flag = TRUE;
|
||||
}
|
||||
} else {
|
||||
if (unlink(remove_names[i]) != -1) {
|
||||
remove_flag = TRUE;
|
||||
}
|
||||
}
|
||||
/* TODO: why we are checking lstat? we can just try rm/rmdir */
|
||||
if (lstat(remove_names[i], &path_stat) < 0) {
|
||||
continue;
|
||||
}
|
||||
if (S_ISDIR(path_stat.st_mode)) {
|
||||
remove_flag &= rmdir(remove_names[i]); /* 0 if no error */
|
||||
} else {
|
||||
remove_flag &= unlink(remove_names[i]); /* 0 if no error */
|
||||
}
|
||||
skip:
|
||||
continue;
|
||||
}
|
||||
return remove_flag;
|
||||
return (remove_flag == 0);
|
||||
}
|
||||
|
||||
static int run_package_script(const char *package_name, const char *script_type)
|
||||
@@ -1230,8 +1227,11 @@ static int run_package_script(const char *package_name, const char *script_type)
|
||||
return result;
|
||||
}
|
||||
|
||||
static const char *all_control_files[] = {"preinst", "postinst", "prerm", "postrm",
|
||||
"list", "md5sums", "shlibs", "conffiles", "config", "templates", NULL };
|
||||
static const char *const all_control_files[] = {
|
||||
"preinst", "postinst", "prerm", "postrm",
|
||||
"list", "md5sums", "shlibs", "conffiles",
|
||||
"config", "templates", NULL
|
||||
};
|
||||
|
||||
static char **all_control_list(const char *package_name)
|
||||
{
|
||||
@@ -1250,7 +1250,6 @@ static char **all_control_list(const char *package_name)
|
||||
|
||||
static void free_array(char **array)
|
||||
{
|
||||
|
||||
if (array) {
|
||||
unsigned i = 0;
|
||||
while (array[i]) {
|
||||
@@ -1273,8 +1272,7 @@ static void list_packages(void)
|
||||
puts("+++-==============-==============");
|
||||
|
||||
/* go through status hash, dereference package hash and finally strings */
|
||||
for (i=0; i<STATUS_HASH_PRIME+1; i++) {
|
||||
|
||||
for (i = 0; i < STATUS_HASH_PRIME+1; i++) {
|
||||
if (status_hashtable[i]) {
|
||||
const char *stat_str; /* status string */
|
||||
const char *name_str; /* package name */
|
||||
@@ -1291,7 +1289,7 @@ static void list_packages(void)
|
||||
s1 = stat_str[0] == 'i' ? 'i' : 'r';
|
||||
|
||||
/* get abbreviation for status field 2 */
|
||||
for (j=0, spccnt=0; stat_str[j] && spccnt<2; j++) {
|
||||
for (j = 0, spccnt = 0; stat_str[j] && spccnt < 2; j++) {
|
||||
if (stat_str[j] == ' ') spccnt++;
|
||||
}
|
||||
s2 = stat_str[j];
|
||||
@@ -1299,7 +1297,7 @@ static void list_packages(void)
|
||||
/* print out the line formatted like Debian dpkg */
|
||||
printf("%c%c %-14s %s\n", s1, s2, name_str, vers_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void remove_package(const unsigned package_num, int noisy)
|
||||
@@ -1312,14 +1310,12 @@ static void remove_package(const unsigned package_num, int noisy)
|
||||
char **exclude_files;
|
||||
char list_name[package_name_length + 25];
|
||||
char conffile_name[package_name_length + 30];
|
||||
int return_value;
|
||||
|
||||
if (noisy)
|
||||
printf("Removing %s (%s)...\n", package_name, package_version);
|
||||
|
||||
/* run prerm script */
|
||||
return_value = run_package_script(package_name, "prerm");
|
||||
if (return_value == -1) {
|
||||
if (run_package_script(package_name, "prerm") != 0) {
|
||||
bb_error_msg_and_die("script failed, prerm failure");
|
||||
}
|
||||
|
||||
@@ -1387,8 +1383,8 @@ static void purge_package(const unsigned package_num)
|
||||
free(exclude_files);
|
||||
|
||||
/* run postrm script */
|
||||
if (run_package_script(package_name, "postrm") == -1) {
|
||||
bb_error_msg_and_die("postrm fialure.. set status to what?");
|
||||
if (run_package_script(package_name, "postrm") != 0) {
|
||||
bb_error_msg_and_die("postrm failure.. set status to what?");
|
||||
}
|
||||
|
||||
/* Change package status */
|
||||
@@ -1416,17 +1412,15 @@ static void init_archive_deb_control(archive_handle_t *ar_handle)
|
||||
tar_handle->src_fd = ar_handle->src_fd;
|
||||
|
||||
/* We don't care about data.tar.* or debian-binary, just control.tar.* */
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
llist_add_to(&(ar_handle->accept), "control.tar.gz");
|
||||
#if ENABLE_FEATURE_DEB_TAR_GZ
|
||||
llist_add_to(&(ar_handle->accept), (char*)"control.tar.gz");
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
llist_add_to(&(ar_handle->accept), "control.tar.bz2");
|
||||
#if ENABLE_FEATURE_DEB_TAR_BZ2
|
||||
llist_add_to(&(ar_handle->accept), (char*)"control.tar.bz2");
|
||||
#endif
|
||||
|
||||
/* Assign the tar handle as a subarchive of the ar handle */
|
||||
ar_handle->sub_archive = tar_handle;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void init_archive_deb_data(archive_handle_t *ar_handle)
|
||||
@@ -1438,17 +1432,15 @@ static void init_archive_deb_data(archive_handle_t *ar_handle)
|
||||
tar_handle->src_fd = ar_handle->src_fd;
|
||||
|
||||
/* We don't care about control.tar.* or debian-binary, just data.tar.* */
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
llist_add_to(&(ar_handle->accept), "data.tar.gz");
|
||||
#if ENABLE_FEATURE_DEB_TAR_GZ
|
||||
llist_add_to(&(ar_handle->accept), (char*)"data.tar.gz");
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
llist_add_to(&(ar_handle->accept), "data.tar.bz2");
|
||||
#if ENABLE_FEATURE_DEB_TAR_BZ2
|
||||
llist_add_to(&(ar_handle->accept), (char*)"data.tar.bz2");
|
||||
#endif
|
||||
|
||||
/* Assign the tar handle as a subarchive of the ar handle */
|
||||
ar_handle->sub_archive = tar_handle;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, llist_t *myaccept)
|
||||
@@ -1472,7 +1464,6 @@ static void data_extract_all_prefix(archive_handle_t *archive_handle)
|
||||
archive_handle->file_header->name = xasprintf("%s%s", archive_handle->buffer, name_ptr);
|
||||
data_extract_all(archive_handle);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void unpack_package(deb_file_t *deb_file)
|
||||
@@ -1525,7 +1516,7 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
archive_handle = init_archive_deb_ar(deb_file->filename);
|
||||
init_archive_deb_data(archive_handle);
|
||||
archive_handle->sub_archive->action_data = data_extract_all_prefix;
|
||||
archive_handle->sub_archive->buffer = "/";
|
||||
archive_handle->sub_archive->buffer = (char*)"/"; /* huh? */
|
||||
archive_handle->sub_archive->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
unpack_ar_archive(archive_handle);
|
||||
|
||||
@@ -1559,13 +1550,14 @@ static void configure_package(deb_file_t *deb_file)
|
||||
/* Run the postinst script */
|
||||
if (run_package_script(package_name, "postinst") != 0) {
|
||||
/* TODO: handle failure gracefully */
|
||||
bb_error_msg_and_die("postrm failure.. set status to what?");
|
||||
bb_error_msg_and_die("postinst failure.. set status to what?");
|
||||
}
|
||||
/* Change status to reflect success */
|
||||
set_status(status_num, "install", 1);
|
||||
set_status(status_num, "installed", 3);
|
||||
}
|
||||
|
||||
int dpkg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int dpkg_main(int argc, char **argv)
|
||||
{
|
||||
deb_file_t **deb_file = NULL;
|
||||
@@ -1585,21 +1577,19 @@ int dpkg_main(int argc, char **argv)
|
||||
OPT_purge = 0x10,
|
||||
OPT_remove = 0x20,
|
||||
OPT_unpack = 0x40,
|
||||
REQ_package_name = 0x8000,
|
||||
REQ_filename = 0x4000,
|
||||
};
|
||||
|
||||
opt = getopt32(argc, argv, "CF:ilPru", &str_f);
|
||||
if (opt & OPT_configure) opt |= REQ_package_name; // -C
|
||||
opt = getopt32(argv, "CF:ilPru", &str_f);
|
||||
//if (opt & OPT_configure) ... // -C
|
||||
if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg)
|
||||
if (strcmp(str_f, "depends"))
|
||||
opt &= ~OPT_force_ignore_depends;
|
||||
}
|
||||
if (opt & OPT_install) opt |= REQ_filename; // -i
|
||||
//if (opt & OPT_install) ... // -i
|
||||
//if (opt & OPT_list_installed) ... // -l
|
||||
if (opt & OPT_purge) opt |= REQ_package_name; // -P
|
||||
if (opt & OPT_remove) opt |= REQ_package_name; // -r
|
||||
if (opt & OPT_unpack) opt |= REQ_filename; // -u (--unpack in official dpkg)
|
||||
//if (opt & OPT_purge) ... // -P
|
||||
//if (opt & OPT_remove) ... // -r
|
||||
//if (opt & OPT_unpack) ... // -u (--unpack in official dpkg)
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
/* check for non-option argument if expected */
|
||||
@@ -1622,14 +1612,15 @@ int dpkg_main(int argc, char **argv)
|
||||
/* Read arguments and store relevant info in structs */
|
||||
while (*argv) {
|
||||
/* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */
|
||||
deb_file = xrealloc(deb_file, sizeof(deb_file_t *) * (deb_count + 2));
|
||||
deb_file[deb_count] = xzalloc(sizeof(deb_file_t));
|
||||
if (opt & REQ_filename) {
|
||||
deb_file = xrealloc(deb_file, sizeof(deb_file[0]) * (deb_count + 2));
|
||||
deb_file[deb_count] = xzalloc(sizeof(deb_file[0][0]));
|
||||
if (opt & (OPT_install | OPT_unpack)) {
|
||||
/* -i/-u: require filename */
|
||||
archive_handle_t *archive_handle;
|
||||
llist_t *control_list = NULL;
|
||||
|
||||
/* Extract the control file */
|
||||
llist_add_to(&control_list, "./control");
|
||||
llist_add_to(&control_list, (char*)"./control");
|
||||
archive_handle = init_archive_deb_ar(argv[0]);
|
||||
init_archive_deb_control(archive_handle);
|
||||
deb_file[deb_count]->control_file = deb_extract_control_file_to_buffer(archive_handle, control_list);
|
||||
@@ -1647,7 +1638,7 @@ int dpkg_main(int argc, char **argv)
|
||||
deb_file[deb_count]->package = (unsigned) package_num;
|
||||
|
||||
/* Add the package to the status hashtable */
|
||||
if (opt & (OPT_unpack|OPT_install)) {
|
||||
if (opt & (OPT_unpack | OPT_install)) {
|
||||
/* Try and find a currently installed version of this package */
|
||||
status_num = search_status_hashtable(name_hashtable[package_hashtable[deb_file[deb_count]->package]->name]);
|
||||
/* If no previous entry was found initialise a new entry */
|
||||
@@ -1665,8 +1656,8 @@ int dpkg_main(int argc, char **argv)
|
||||
set_status(status_num, "reinstreq", 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (opt & REQ_package_name) {
|
||||
} else if (opt & (OPT_configure | OPT_purge | OPT_remove)) {
|
||||
/* -C/-p/-r: require package name */
|
||||
deb_file[deb_count]->package = search_package_hashtable(
|
||||
search_name_hashtable(argv[0]),
|
||||
search_name_hashtable("ANY"), VER_ANY);
|
||||
@@ -1685,8 +1676,7 @@ int dpkg_main(int argc, char **argv)
|
||||
bb_error_msg_and_die("%s is already removed", name_hashtable[package_hashtable[package_num]->name]);
|
||||
}
|
||||
set_status(status_num, "deinstall", 1);
|
||||
}
|
||||
else if (opt & OPT_purge) {
|
||||
} else if (opt & OPT_purge) {
|
||||
/* if package status is "conf-files" then its ok */
|
||||
if (strcmp(name_hashtable[state_status], "not-installed") == 0) {
|
||||
bb_error_msg_and_die("%s is already purged", name_hashtable[package_hashtable[package_num]->name]);
|
||||
@@ -1697,6 +1687,8 @@ int dpkg_main(int argc, char **argv)
|
||||
deb_count++;
|
||||
argv++;
|
||||
}
|
||||
if (!deb_count)
|
||||
bb_error_msg_and_die("no package files specified");
|
||||
deb_file[deb_count] = NULL;
|
||||
|
||||
/* Check that the deb file arguments are installable */
|
||||
@@ -1748,9 +1740,7 @@ int dpkg_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
for (i = 0; i < PACKAGE_HASH_PRIME; i++) {
|
||||
if (package_hashtable[i] != NULL) {
|
||||
free_package(package_hashtable[i]);
|
||||
}
|
||||
free_package(package_hashtable[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < STATUS_HASH_PRIME; i++) {
|
||||
|
||||
+11
-10
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define DPKG_DEB_OPT_CONTENTS 1
|
||||
@@ -13,13 +13,14 @@
|
||||
#define DPKG_DEB_OPT_EXTRACT 8
|
||||
#define DPKG_DEB_OPT_EXTRACT_VERBOSE 16
|
||||
|
||||
int dpkg_deb_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
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 opt;
|
||||
char *extract_dir = NULL;
|
||||
const char *extract_dir = NULL;
|
||||
short argcount = 1;
|
||||
|
||||
/* Setup the tar archive handle */
|
||||
@@ -30,18 +31,18 @@ int dpkg_deb_main(int argc, char **argv)
|
||||
ar_archive->sub_archive = tar_archive;
|
||||
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");
|
||||
#if ENABLE_FEATURE_DEB_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");
|
||||
#if ENABLE_FEATURE_DEB_TAR_BZ2
|
||||
llist_add_to(&(ar_archive->accept), (char*)"data.tar.bz2");
|
||||
llist_add_to(&control_tar_llist, (char*)"control.tar.bz2");
|
||||
#endif
|
||||
|
||||
opt_complementary = "?c--efXx:e--cfXx:f--ceXx:X--cefx:x--cefX";
|
||||
opt = getopt32(argc, argv, "cefXx");
|
||||
opt = getopt32(argv, "cefXx");
|
||||
|
||||
if (opt & DPKG_DEB_OPT_CONTENTS) {
|
||||
tar_archive->action_header = header_verbose_list;
|
||||
@@ -60,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;
|
||||
}
|
||||
|
||||
@@ -1,162 +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 "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
|
||||
#define GUNZIP_OPT_VERBOSE 0x10
|
||||
|
||||
int gunzip_main(int argc, char **argv)
|
||||
{
|
||||
USE_DESKTOP(long long) int status;
|
||||
int exitcode = 0;
|
||||
unsigned opt;
|
||||
|
||||
opt = getopt32(argc, argv, "cftdv");
|
||||
/* if called as zcat */
|
||||
if (strcmp(applet_name, "zcat") == 0) {
|
||||
opt |= GUNZIP_OPT_STDOUT;
|
||||
}
|
||||
|
||||
do {
|
||||
struct stat stat_buf;
|
||||
char *old_path = argv[optind];
|
||||
char *delete_path = NULL;
|
||||
char *new_path = NULL;
|
||||
int src_fd;
|
||||
int dst_fd;
|
||||
|
||||
optind++;
|
||||
|
||||
if (old_path == NULL || LONE_DASH(old_path)) {
|
||||
src_fd = STDIN_FILENO;
|
||||
opt |= GUNZIP_OPT_STDOUT;
|
||||
USE_DESKTOP(opt &= ~GUNZIP_OPT_VERBOSE;)
|
||||
optind = argc; /* we don't handle "gunzip - a.gz b.gz" */
|
||||
} else {
|
||||
src_fd = xopen(old_path, O_RDONLY);
|
||||
/* Get the time stamp on the input file. */
|
||||
fstat(src_fd, &stat_buf);
|
||||
}
|
||||
|
||||
/* Check that the input is sane. */
|
||||
if (isatty(src_fd) && !(opt & GUNZIP_OPT_FORCE)) {
|
||||
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 = 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 = 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 {
|
||||
// FIXME: should we die or just skip to next?
|
||||
bb_error_msg_and_die("invalid extension");
|
||||
}
|
||||
|
||||
/* Open output file (with correct permissions) */
|
||||
dst_fd = xopen3(new_path, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
stat_buf.st_mode);
|
||||
|
||||
/* If unzip succeeds remove the old file */
|
||||
delete_path = old_path;
|
||||
}
|
||||
|
||||
status = -1;
|
||||
/* do the decompression, and cleanup */
|
||||
if (xread_char(src_fd) == 0x1f) {
|
||||
unsigned char magic2;
|
||||
|
||||
magic2 = xread_char(src_fd);
|
||||
if (ENABLE_FEATURE_GUNZIP_UNCOMPRESS && magic2 == 0x9d) {
|
||||
status = uncompress(src_fd, dst_fd);
|
||||
} else if (magic2 == 0x8b) {
|
||||
check_header_gzip(src_fd); // FIXME: xfunc? _or_die?
|
||||
status = inflate_gunzip(src_fd, dst_fd);
|
||||
} else {
|
||||
bb_error_msg("invalid magic");
|
||||
exitcode = 1;
|
||||
}
|
||||
if (status < 0) {
|
||||
bb_error_msg("error inflating");
|
||||
exitcode = 1;
|
||||
}
|
||||
else if (ENABLE_DESKTOP && (opt & GUNZIP_OPT_VERBOSE)) {
|
||||
fprintf(stderr, "%s: %u%% - replaced with %s\n",
|
||||
old_path, (unsigned)(stat_buf.st_size*100 / (status+1)), new_path);
|
||||
}
|
||||
} else {
|
||||
bb_error_msg("invalid magic");
|
||||
exitcode = 1;
|
||||
}
|
||||
if (status < 0 && 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("cannot remove %s", delete_path);
|
||||
exitcode = 1;
|
||||
}
|
||||
|
||||
free(new_path);
|
||||
|
||||
} while (optind < argc);
|
||||
|
||||
return exitcode;
|
||||
}
|
||||
+451
-591
File diff suppressed because it is too large.
Load diff
@@ -26,34 +26,42 @@ lib-y:= \
|
||||
\
|
||||
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
|
||||
lib-$(CONFIG_RPM) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_BZIP2) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_LZMA) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_GZIP) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_GZ) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_BZ2) += open_transformer.o
|
||||
lib-$(CONFIG_FEATURE_DEB_TAR_LZMA) += open_transformer.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) += decompress_unzip.o 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) += decompress_unzip.o
|
||||
lib-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_RPM2CPIO) += decompress_unzip.o get_header_cpio.o
|
||||
lib-$(CONFIG_RPM) += decompress_unzip.o get_header_cpio.o
|
||||
lib-$(CONFIG_FEATURE_RPM_BZ2) += decompress_bunzip2.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) += decompress_unzip.o get_header_tar_gz.o
|
||||
lib-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
|
||||
lib-$(CONFIG_UNZIP) += decompress_unzip.o
|
||||
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
|
||||
@@ -3,8 +3,8 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
ssize_t archive_xread_all_eof(archive_handle_t *archive_handle,
|
||||
unsigned char *buf, size_t count)
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* 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)
|
||||
{
|
||||
union {
|
||||
unsigned char raw[8];
|
||||
struct {
|
||||
unsigned char method;
|
||||
unsigned char flags;
|
||||
unsigned int mtime;
|
||||
unsigned char xtra_flags;
|
||||
unsigned char os_flags;
|
||||
} formatted;
|
||||
} header;
|
||||
|
||||
xread(src_fd, header.raw, 8);
|
||||
|
||||
/* Check the compression method */
|
||||
if (header.formatted.method != 8) {
|
||||
bb_error_msg_and_die("unknown compression method %d",
|
||||
header.formatted.method);
|
||||
}
|
||||
|
||||
if (header.formatted.flags & 0x04) {
|
||||
/* bit 2 set: extra field present */
|
||||
unsigned char extra_short;
|
||||
|
||||
extra_short = xread_char(src_fd) + (xread_char(src_fd) << 8);
|
||||
while (extra_short > 0) {
|
||||
/* Ignore extra field */
|
||||
xread_char(src_fd);
|
||||
extra_short--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Discard original name if any */
|
||||
if (header.formatted.flags & 0x08) {
|
||||
/* bit 3 set: original file name present */
|
||||
while (xread_char(src_fd) != 0);
|
||||
}
|
||||
|
||||
/* Discard file comment if any */
|
||||
if (header.formatted.flags & 0x10) {
|
||||
/* bit 4 set: file comment present */
|
||||
while (xread_char(src_fd) != 0);
|
||||
}
|
||||
|
||||
/* Read the header checksum */
|
||||
if (header.formatted.flags & 0x02) {
|
||||
xread_char(src_fd);
|
||||
xread_char(src_fd);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -3,10 +3,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
//#include <sys/types.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;
|
||||
}
|
||||
@@ -25,7 +25,8 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
&& (unlink(file_header->name) == -1)
|
||||
&& (errno != ENOENT)
|
||||
) {
|
||||
bb_perror_msg_and_die("cannot remove old file");
|
||||
bb_perror_msg_and_die("cannot remove old file %s",
|
||||
file_header->name);
|
||||
}
|
||||
}
|
||||
else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) {
|
||||
@@ -52,13 +53,16 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
|
||||
/* Handle hard links separately
|
||||
* We identified hard links as regular files of size 0 with a symlink */
|
||||
if (S_ISREG(file_header->mode) && (file_header->link_name)
|
||||
if (S_ISREG(file_header->mode) && (file_header->link_target)
|
||||
&& (file_header->size == 0)
|
||||
) {
|
||||
/* hard link */
|
||||
res = link(file_header->link_name, file_header->name);
|
||||
res = link(file_header->link_target, file_header->name);
|
||||
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("cannot create hard link");
|
||||
bb_perror_msg("cannot create %slink "
|
||||
"from %s to %s", "hard",
|
||||
file_header->name,
|
||||
file_header->link_target);
|
||||
}
|
||||
} else {
|
||||
/* Create the filesystem entry */
|
||||
@@ -73,22 +77,22 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
}
|
||||
case S_IFDIR:
|
||||
res = mkdir(file_header->name, file_header->mode);
|
||||
if ((errno != EISDIR) && (res == -1)
|
||||
if ((res == -1) && (errno != EISDIR)
|
||||
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("extract_archive: %s", file_header->name);
|
||||
bb_perror_msg("cannot make dir %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
case S_IFLNK:
|
||||
/* Symlink */
|
||||
res = symlink(file_header->link_name, file_header->name);
|
||||
res = symlink(file_header->link_target, file_header->name);
|
||||
if ((res == -1)
|
||||
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("cannot create symlink "
|
||||
"from %s to '%s'",
|
||||
bb_perror_msg("cannot create %slink "
|
||||
"from %s to %s", "sym",
|
||||
file_header->name,
|
||||
file_header->link_name);
|
||||
file_header->link_target);
|
||||
}
|
||||
break;
|
||||
case S_IFSOCK:
|
||||
@@ -110,10 +114,18 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) {
|
||||
lchown(file_header->name, file_header->uid, file_header->gid);
|
||||
}
|
||||
|
||||
if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) {
|
||||
struct utimbuf t;
|
||||
t.actime = t.modtime = file_header->mtime;
|
||||
utime(file_header->name, &t);
|
||||
if ((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)) {
|
||||
chmod(file_header->name, file_header->mode);
|
||||
}
|
||||
/* same for utime */
|
||||
if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) {
|
||||
struct utimbuf t;
|
||||
t.actime = t.modtime = file_header->mtime;
|
||||
utime(file_header->name, &t);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void data_extract_to_stdout(archive_handle_t *archive_handle)
|
||||
|
||||
@@ -3,12 +3,8 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void data_skip(archive_handle_t *archive_handle)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#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_SHORT_WRITE (-4)
|
||||
#define RETVAL_DATA_ERROR (-5)
|
||||
#define RETVAL_OUT_OF_MEMORY (-6)
|
||||
#define RETVAL_OBSOLETE_INPUT (-7)
|
||||
@@ -54,82 +54,86 @@
|
||||
|
||||
/* This is what we know about each Huffman coding group */
|
||||
struct group_data {
|
||||
/* We have an extra slot at the end of limit[] for a sentinal value. */
|
||||
int limit[MAX_HUFCODE_BITS+1],base[MAX_HUFCODE_BITS],permute[MAX_SYMBOLS];
|
||||
/* We have an extra slot at the end of limit[] for a sentinel value. */
|
||||
int limit[MAX_HUFCODE_BITS+1], base[MAX_HUFCODE_BITS], permute[MAX_SYMBOLS];
|
||||
int minLen, maxLen;
|
||||
};
|
||||
|
||||
/* Structure holding all the housekeeping data, including IO buffers and
|
||||
memory that persists between calls to bunzip */
|
||||
|
||||
typedef struct {
|
||||
/* State for interrupting output loop */
|
||||
|
||||
int writeCopies,writePos,writeRunCountdown,writeCount,writeCurrent;
|
||||
* memory that persists between calls to bunzip
|
||||
* Found the most used member:
|
||||
* cat this_file.c | sed -e 's/"/ /g' -e "s/'/ /g" | xargs -n1 \
|
||||
* | grep 'bd->' | sed 's/^.*bd->/bd->/' | sort | $PAGER
|
||||
* and moved it (inbufBitCount) to offset 0.
|
||||
*/
|
||||
|
||||
struct bunzip_data {
|
||||
/* I/O tracking data (file handles, buffers, positions, etc.) */
|
||||
|
||||
int in_fd,out_fd,inbufCount,inbufPos /*,outbufPos*/;
|
||||
unsigned inbufBitCount, inbufBits;
|
||||
int in_fd, out_fd, inbufCount, inbufPos /*, outbufPos*/;
|
||||
unsigned char *inbuf /*,*outbuf*/;
|
||||
unsigned int inbufBitCount, inbufBits;
|
||||
|
||||
/* State for interrupting output loop */
|
||||
int writeCopies, writePos, writeRunCountdown, writeCount, writeCurrent;
|
||||
|
||||
/* The CRC values stored in the block header and calculated from the data */
|
||||
|
||||
uint32_t headerCRC, totalCRC, writeCRC;
|
||||
uint32_t *crc32Table;
|
||||
|
||||
/* Intermediate buffer and its size (in bytes) */
|
||||
|
||||
unsigned int *dbuf, dbufSize;
|
||||
|
||||
/* These things are a bit too big to go on the stack */
|
||||
|
||||
unsigned char selectors[32768]; /* nSelectors=15 bits */
|
||||
struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */
|
||||
unsigned *dbuf, dbufSize;
|
||||
|
||||
/* For I/O error handling */
|
||||
|
||||
jmp_buf jmpbuf;
|
||||
} bunzip_data;
|
||||
|
||||
/* Big things go last (register-relative addressing can be larger for big offsets) */
|
||||
uint32_t crc32Table[256];
|
||||
unsigned char selectors[32768]; /* nSelectors=15 bits */
|
||||
struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */
|
||||
};
|
||||
/* typedef struct bunzip_data bunzip_data; -- done in .h file */
|
||||
|
||||
|
||||
/* Return the next nnn bits of input. All reads from the compressed input
|
||||
are done through this function. All reads are big endian */
|
||||
|
||||
static unsigned int get_bits(bunzip_data *bd, char bits_wanted)
|
||||
static unsigned get_bits(bunzip_data *bd, int bits_wanted)
|
||||
{
|
||||
unsigned int bits=0;
|
||||
unsigned bits = 0;
|
||||
|
||||
/* If we need to get more data from the byte buffer, do so. (Loop getting
|
||||
one byte at a time to enforce endianness and avoid unaligned access.) */
|
||||
|
||||
while (bd->inbufBitCount<bits_wanted) {
|
||||
while (bd->inbufBitCount < bits_wanted) {
|
||||
|
||||
/* If we need to read more data from file into byte buffer, do so */
|
||||
|
||||
if(bd->inbufPos==bd->inbufCount) {
|
||||
if((bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE)) <= 0)
|
||||
longjmp(bd->jmpbuf,RETVAL_UNEXPECTED_INPUT_EOF);
|
||||
bd->inbufPos=0;
|
||||
if (bd->inbufPos == bd->inbufCount) {
|
||||
/* if "no input fd" case: in_fd == -1, read fails, we jump */
|
||||
bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE);
|
||||
if (bd->inbufCount <= 0)
|
||||
longjmp(bd->jmpbuf, RETVAL_UNEXPECTED_INPUT_EOF);
|
||||
bd->inbufPos = 0;
|
||||
}
|
||||
|
||||
/* Avoid 32-bit overflow (dump bit buffer to top of output) */
|
||||
|
||||
if(bd->inbufBitCount>=24) {
|
||||
bits=bd->inbufBits&((1<<bd->inbufBitCount)-1);
|
||||
bits_wanted-=bd->inbufBitCount;
|
||||
bits<<=bits_wanted;
|
||||
bd->inbufBitCount=0;
|
||||
if (bd->inbufBitCount >= 24) {
|
||||
bits = bd->inbufBits & ((1 << bd->inbufBitCount) - 1);
|
||||
bits_wanted -= bd->inbufBitCount;
|
||||
bits <<= bits_wanted;
|
||||
bd->inbufBitCount = 0;
|
||||
}
|
||||
|
||||
/* Grab next 8 bits of input from buffer. */
|
||||
|
||||
bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++];
|
||||
bd->inbufBitCount+=8;
|
||||
bd->inbufBits = (bd->inbufBits << 8) | bd->inbuf[bd->inbufPos++];
|
||||
bd->inbufBitCount += 8;
|
||||
}
|
||||
|
||||
/* Calculate result */
|
||||
|
||||
bd->inbufBitCount-=bits_wanted;
|
||||
bits|=(bd->inbufBits>>bd->inbufBitCount)&((1<<bits_wanted)-1);
|
||||
bd->inbufBitCount -= bits_wanted;
|
||||
bits |= (bd->inbufBits >> bd->inbufBitCount) & ((1 << bits_wanted) - 1);
|
||||
|
||||
return bits;
|
||||
}
|
||||
@@ -139,26 +143,26 @@ static unsigned int get_bits(bunzip_data *bd, char bits_wanted)
|
||||
static int get_next_block(bunzip_data *bd)
|
||||
{
|
||||
struct group_data *hufGroup;
|
||||
int dbufCount,nextSym,dbufSize,groupCount,*base,*limit,selector,
|
||||
i,j,k,t,runPos,symCount,symTotal,nSelectors,byteCount[256];
|
||||
int dbufCount, nextSym, dbufSize, groupCount, *base, *limit, selector,
|
||||
i, j, k, t, runPos, symCount, symTotal, nSelectors, byteCount[256];
|
||||
unsigned char uc, symToByte[256], mtfSymbol[256], *selectors;
|
||||
unsigned int *dbuf,origPtr;
|
||||
unsigned *dbuf, origPtr;
|
||||
|
||||
dbuf=bd->dbuf;
|
||||
dbufSize=bd->dbufSize;
|
||||
selectors=bd->selectors;
|
||||
dbuf = bd->dbuf;
|
||||
dbufSize = bd->dbufSize;
|
||||
selectors = bd->selectors;
|
||||
|
||||
/* Reset longjmp I/O error handling */
|
||||
|
||||
i=setjmp(bd->jmpbuf);
|
||||
i = setjmp(bd->jmpbuf);
|
||||
if (i) return i;
|
||||
|
||||
/* Read in header signature and CRC, then validate signature.
|
||||
(last block signature means CRC is for whole file, return now) */
|
||||
|
||||
i = get_bits(bd,24);
|
||||
j = get_bits(bd,24);
|
||||
bd->headerCRC=get_bits(bd,32);
|
||||
i = get_bits(bd, 24);
|
||||
j = get_bits(bd, 24);
|
||||
bd->headerCRC = get_bits(bd, 32);
|
||||
if ((i == 0x177245) && (j == 0x385090)) return RETVAL_LAST_BLOCK;
|
||||
if ((i != 0x314159) || (j != 0x265359)) return RETVAL_NOT_BZIP_DATA;
|
||||
|
||||
@@ -166,8 +170,9 @@ 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;
|
||||
origPtr = get_bits(bd, 24);
|
||||
if (origPtr > dbufSize) return RETVAL_DATA_ERROR;
|
||||
|
||||
/* mapping table: if some byte values are never used (encoding things
|
||||
like ascii text), the compression code removes the gaps to have fewer
|
||||
@@ -175,48 +180,52 @@ static int get_next_block(bunzip_data *bd)
|
||||
values were present. We make a translation table to convert the symbols
|
||||
back to the corresponding bytes. */
|
||||
|
||||
t=get_bits(bd, 16);
|
||||
symTotal=0;
|
||||
for (i=0;i<16;i++) {
|
||||
if(t&(1<<(15-i))) {
|
||||
k=get_bits(bd,16);
|
||||
for (j=0;j<16;j++)
|
||||
if(k&(1<<(15-j))) symToByte[symTotal++]=(16*i)+j;
|
||||
t = get_bits(bd, 16);
|
||||
symTotal = 0;
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (t & (1 << (15-i))) {
|
||||
k = get_bits(bd, 16);
|
||||
for (j = 0; j < 16; j++)
|
||||
if (k & (1 << (15-j)))
|
||||
symToByte[symTotal++] = (16*i) + j;
|
||||
}
|
||||
}
|
||||
|
||||
/* How many different Huffman coding groups does this block use? */
|
||||
|
||||
groupCount=get_bits(bd,3);
|
||||
if (groupCount<2 || groupCount>MAX_GROUPS) return RETVAL_DATA_ERROR;
|
||||
groupCount = get_bits(bd, 3);
|
||||
if (groupCount < 2 || groupCount > MAX_GROUPS)
|
||||
return RETVAL_DATA_ERROR;
|
||||
|
||||
/* nSelectors: Every GROUP_SIZE many symbols we select a new Huffman coding
|
||||
group. Read in the group selector list, which is stored as MTF encoded
|
||||
bit runs. (MTF=Move To Front, as each value is used it's moved to the
|
||||
start of the list.) */
|
||||
|
||||
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++) {
|
||||
nSelectors = get_bits(bd, 15);
|
||||
if (!nSelectors) return RETVAL_DATA_ERROR;
|
||||
for (i = 0; i < groupCount; i++) mtfSymbol[i] = i;
|
||||
for (i = 0; i < nSelectors; i++) {
|
||||
|
||||
/* Get next value */
|
||||
|
||||
for (j=0;get_bits(bd,1);j++) if (j>=groupCount) return RETVAL_DATA_ERROR;
|
||||
for (j = 0; get_bits(bd, 1); j++)
|
||||
if (j >= groupCount) return RETVAL_DATA_ERROR;
|
||||
|
||||
/* Decode MTF to get the next selector */
|
||||
|
||||
uc = mtfSymbol[j];
|
||||
for (;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
|
||||
mtfSymbol[0]=selectors[i]=uc;
|
||||
mtfSymbol[0] = selectors[i] = uc;
|
||||
}
|
||||
|
||||
/* Read the Huffman coding tables for each group, which code for symTotal
|
||||
literal symbols, plus two run symbols (RUNA, RUNB) */
|
||||
|
||||
symCount=symTotal+2;
|
||||
for (j=0; j<groupCount; j++) {
|
||||
unsigned char length[MAX_SYMBOLS],temp[MAX_HUFCODE_BITS+1];
|
||||
int minLen, maxLen, pp;
|
||||
symCount = symTotal + 2;
|
||||
for (j = 0; j < groupCount; j++) {
|
||||
unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1];
|
||||
int minLen, maxLen, pp;
|
||||
|
||||
/* Read Huffman code lengths for each symbol. They're stored in
|
||||
a way similar to mtf; record a starting value for the first symbol,
|
||||
@@ -225,17 +234,17 @@ static int get_next_block(bunzip_data *bd)
|
||||
an optimization that makes the test inside the loop simpler: symbol
|
||||
length 0 becomes negative, so an unsigned inequality catches it.) */
|
||||
|
||||
t=get_bits(bd, 5)-1;
|
||||
t = get_bits(bd, 5) - 1;
|
||||
for (i = 0; i < symCount; i++) {
|
||||
for (;;) {
|
||||
if (((unsigned)t) > (MAX_HUFCODE_BITS-1))
|
||||
if ((unsigned)t > (MAX_HUFCODE_BITS-1))
|
||||
return RETVAL_DATA_ERROR;
|
||||
|
||||
/* If first bit is 0, stop. Else second bit indicates whether
|
||||
to increment or decrement the value. Optimization: grab 2
|
||||
bits and unget the second if the first was 0. */
|
||||
|
||||
k = get_bits(bd,2);
|
||||
k = get_bits(bd, 2);
|
||||
if (k < 2) {
|
||||
bd->inbufBitCount++;
|
||||
break;
|
||||
@@ -243,20 +252,20 @@ static int get_next_block(bunzip_data *bd)
|
||||
|
||||
/* Add one if second bit 1, else subtract 1. Avoids if/else */
|
||||
|
||||
t+=(((k+1)&2)-1);
|
||||
t += (((k+1) & 2) - 1);
|
||||
}
|
||||
|
||||
/* Correct for the initial -1, to get the final symbol length */
|
||||
|
||||
length[i]=t+1;
|
||||
length[i] = t + 1;
|
||||
}
|
||||
|
||||
/* Find largest and smallest lengths in this group */
|
||||
|
||||
minLen=maxLen=length[0];
|
||||
minLen = maxLen = length[0];
|
||||
for (i = 1; i < symCount; i++) {
|
||||
if(length[i] > maxLen) maxLen = length[i];
|
||||
else if(length[i] < minLen) minLen = length[i];
|
||||
if (length[i] > maxLen) maxLen = length[i];
|
||||
else if (length[i] < minLen) minLen = length[i];
|
||||
}
|
||||
|
||||
/* Calculate permute[], base[], and limit[] tables from length[].
|
||||
@@ -270,7 +279,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
* length: each code with a value>limit[length] needs another bit.
|
||||
*/
|
||||
|
||||
hufGroup=bd->groups+j;
|
||||
hufGroup = bd->groups + j;
|
||||
hufGroup->minLen = minLen;
|
||||
hufGroup->maxLen = maxLen;
|
||||
|
||||
@@ -278,30 +287,31 @@ static int get_next_block(bunzip_data *bd)
|
||||
and limit array pointers so we're not always wasting the first
|
||||
entry. We do this again when using them (during symbol decoding).*/
|
||||
|
||||
base=hufGroup->base-1;
|
||||
limit=hufGroup->limit-1;
|
||||
base = hufGroup->base - 1;
|
||||
limit = hufGroup->limit - 1;
|
||||
|
||||
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
|
||||
|
||||
pp=0;
|
||||
for (i=minLen;i<=maxLen;i++) {
|
||||
temp[i]=limit[i]=0;
|
||||
for (t=0;t<symCount;t++)
|
||||
if(length[t]==i) hufGroup->permute[pp++] = t;
|
||||
pp = 0;
|
||||
for (i = minLen; i <= maxLen; i++) {
|
||||
temp[i] = limit[i] = 0;
|
||||
for (t = 0; t < symCount; t++)
|
||||
if (length[t] == i)
|
||||
hufGroup->permute[pp++] = t;
|
||||
}
|
||||
|
||||
/* Count symbols coded for at each bit length */
|
||||
|
||||
for (i=0;i<symCount;i++) temp[length[i]]++;
|
||||
for (i = 0; i < symCount; i++) temp[length[i]]++;
|
||||
|
||||
/* Calculate limit[] (the largest symbol-coding value at each bit
|
||||
* length, which is (previous limit<<1)+symbols at this level), and
|
||||
* base[] (number of symbols to ignore at each bit length, which is
|
||||
* limit minus the cumulative count of symbols coded for already). */
|
||||
|
||||
pp=t=0;
|
||||
for (i=minLen; i<maxLen; i++) {
|
||||
pp+=temp[i];
|
||||
pp = t = 0;
|
||||
for (i = minLen; i < maxLen; i++) {
|
||||
pp += temp[i];
|
||||
|
||||
/* We read the largest possible symbol size and then unget bits
|
||||
after determining how many we need, and those extra bits could
|
||||
@@ -310,39 +320,41 @@ static int get_next_block(bunzip_data *bd)
|
||||
so here we set all the trailing to-be-ignored bits to 1 so they
|
||||
don't affect the value>limit[length] comparison. */
|
||||
|
||||
limit[i]= (pp << (maxLen - i)) - 1;
|
||||
pp<<=1;
|
||||
base[i+1]=pp-(t+=temp[i]);
|
||||
limit[i] = (pp << (maxLen - i)) - 1;
|
||||
pp <<= 1;
|
||||
t += temp[i];
|
||||
base[i+1] = pp - t;
|
||||
}
|
||||
limit[maxLen+1] = INT_MAX; /* Sentinal value for reading next sym. */
|
||||
limit[maxLen]=pp+temp[maxLen]-1;
|
||||
base[minLen]=0;
|
||||
limit[maxLen+1] = INT_MAX; /* Sentinel value for reading next sym. */
|
||||
limit[maxLen] = pp + temp[maxLen] - 1;
|
||||
base[minLen] = 0;
|
||||
}
|
||||
|
||||
/* We've finished reading and digesting the block header. Now read this
|
||||
block's Huffman coded symbols from the file and undo the Huffman coding
|
||||
and run length encoding, saving the result into dbuf[dbufCount++]=uc */
|
||||
and run length encoding, saving the result into dbuf[dbufCount++] = uc */
|
||||
|
||||
/* Initialize symbol occurrence counters and symbol Move To Front table */
|
||||
|
||||
for (i=0;i<256;i++) {
|
||||
byteCount[i] = 0;
|
||||
mtfSymbol[i]=(unsigned char)i;
|
||||
memset(byteCount, 0, sizeof(byteCount)); /* smaller, maybe slower? */
|
||||
for (i = 0; i < 256; i++) {
|
||||
//byteCount[i] = 0;
|
||||
mtfSymbol[i] = (unsigned char)i;
|
||||
}
|
||||
|
||||
/* Loop through compressed symbols. */
|
||||
|
||||
runPos=dbufCount=selector=0;
|
||||
runPos = dbufCount = selector = 0;
|
||||
for (;;) {
|
||||
|
||||
/* fetch next Huffman coding group from list. */
|
||||
|
||||
symCount=GROUP_SIZE-1;
|
||||
if(selector>=nSelectors) return RETVAL_DATA_ERROR;
|
||||
hufGroup=bd->groups+selectors[selector++];
|
||||
base=hufGroup->base-1;
|
||||
limit=hufGroup->limit-1;
|
||||
continue_this_group:
|
||||
symCount = GROUP_SIZE - 1;
|
||||
if (selector >= nSelectors) return RETVAL_DATA_ERROR;
|
||||
hufGroup = bd->groups + selectors[selector++];
|
||||
base = hufGroup->base - 1;
|
||||
limit = hufGroup->limit - 1;
|
||||
continue_this_group:
|
||||
|
||||
/* Read next Huffman-coded symbol. */
|
||||
|
||||
@@ -353,33 +365,34 @@ continue_this_group:
|
||||
valid compressed file. As a further optimization, we do the read
|
||||
inline (falling back to a call to get_bits if the buffer runs
|
||||
dry). The following (up to got_huff_bits:) is equivalent to
|
||||
j=get_bits(bd,hufGroup->maxLen);
|
||||
j = get_bits(bd, hufGroup->maxLen);
|
||||
*/
|
||||
|
||||
while (bd->inbufBitCount<hufGroup->maxLen) {
|
||||
if(bd->inbufPos==bd->inbufCount) {
|
||||
j = get_bits(bd,hufGroup->maxLen);
|
||||
while (bd->inbufBitCount < hufGroup->maxLen) {
|
||||
if (bd->inbufPos == bd->inbufCount) {
|
||||
j = get_bits(bd, hufGroup->maxLen);
|
||||
goto got_huff_bits;
|
||||
}
|
||||
bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++];
|
||||
bd->inbufBitCount+=8;
|
||||
bd->inbufBits = (bd->inbufBits << 8) | bd->inbuf[bd->inbufPos++];
|
||||
bd->inbufBitCount += 8;
|
||||
};
|
||||
bd->inbufBitCount-=hufGroup->maxLen;
|
||||
j = (bd->inbufBits>>bd->inbufBitCount)&((1<<hufGroup->maxLen)-1);
|
||||
bd->inbufBitCount -= hufGroup->maxLen;
|
||||
j = (bd->inbufBits >> bd->inbufBitCount) & ((1 << hufGroup->maxLen) - 1);
|
||||
|
||||
got_huff_bits:
|
||||
got_huff_bits:
|
||||
|
||||
/* Figure how how many bits are in next symbol and unget extras */
|
||||
|
||||
i=hufGroup->minLen;
|
||||
while (j>limit[i]) ++i;
|
||||
i = hufGroup->minLen;
|
||||
while (j > limit[i]) ++i;
|
||||
bd->inbufBitCount += (hufGroup->maxLen - i);
|
||||
|
||||
/* Huffman decode value to get nextSym (with bounds checking) */
|
||||
|
||||
if ((i > hufGroup->maxLen)
|
||||
|| (((unsigned)(j=(j>>(hufGroup->maxLen-i))-base[i]))
|
||||
>= MAX_SYMBOLS))
|
||||
if (i > hufGroup->maxLen)
|
||||
return RETVAL_DATA_ERROR;
|
||||
j = (j >> (hufGroup->maxLen - i)) - base[i];
|
||||
if ((unsigned)j >= MAX_SYMBOLS)
|
||||
return RETVAL_DATA_ERROR;
|
||||
nextSym = hufGroup->permute[j];
|
||||
|
||||
@@ -388,11 +401,11 @@ got_huff_bits:
|
||||
check if nextSym indicates a repeated run, and if so loop collecting
|
||||
how many times to repeat the last literal. */
|
||||
|
||||
if (((unsigned)nextSym) <= SYMBOL_RUNB) { /* RUNA or RUNB */
|
||||
if ((unsigned)nextSym <= SYMBOL_RUNB) { /* RUNA or RUNB */
|
||||
|
||||
/* If this is the start of a new run, zero out counter */
|
||||
|
||||
if(!runPos) {
|
||||
if (!runPos) {
|
||||
runPos = 1;
|
||||
t = 0;
|
||||
}
|
||||
@@ -406,7 +419,7 @@ got_huff_bits:
|
||||
context). Thus space is saved. */
|
||||
|
||||
t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
|
||||
if(runPos < dbufSize) runPos <<= 1;
|
||||
if (runPos < dbufSize) runPos <<= 1;
|
||||
goto end_of_huffman_loop;
|
||||
}
|
||||
|
||||
@@ -415,18 +428,18 @@ got_huff_bits:
|
||||
copies to our buffer of decoded symbols (dbuf) now. (The last
|
||||
literal used is the one at the head of the mtfSymbol array.) */
|
||||
|
||||
if(runPos) {
|
||||
runPos=0;
|
||||
if(dbufCount+t>=dbufSize) return RETVAL_DATA_ERROR;
|
||||
if (runPos) {
|
||||
runPos = 0;
|
||||
if (dbufCount + t >= dbufSize) return RETVAL_DATA_ERROR;
|
||||
|
||||
uc = symToByte[mtfSymbol[0]];
|
||||
byteCount[uc] += t;
|
||||
while (t--) dbuf[dbufCount++]=uc;
|
||||
while (t--) dbuf[dbufCount++] = uc;
|
||||
}
|
||||
|
||||
/* Is this the terminating symbol? */
|
||||
|
||||
if(nextSym>symTotal) break;
|
||||
if (nextSym > symTotal) break;
|
||||
|
||||
/* At this point, nextSym indicates a new literal character. Subtract
|
||||
one to get the position in the MTF array at which this literal is
|
||||
@@ -436,7 +449,7 @@ got_huff_bits:
|
||||
as part of a run above. Therefore 1 unused mtf position minus
|
||||
2 non-literal nextSym values equals -1.) */
|
||||
|
||||
if(dbufCount>=dbufSize) return RETVAL_DATA_ERROR;
|
||||
if (dbufCount >= dbufSize) return RETVAL_DATA_ERROR;
|
||||
i = nextSym - 1;
|
||||
uc = mtfSymbol[i];
|
||||
|
||||
@@ -449,22 +462,22 @@ got_huff_bits:
|
||||
mtfSymbol[i] = mtfSymbol[i-1];
|
||||
} while (--i);
|
||||
mtfSymbol[0] = uc;
|
||||
uc=symToByte[uc];
|
||||
uc = symToByte[uc];
|
||||
|
||||
/* We have our literal byte. Save it into dbuf. */
|
||||
|
||||
byteCount[uc]++;
|
||||
dbuf[dbufCount++] = (unsigned int)uc;
|
||||
dbuf[dbufCount++] = (unsigned)uc;
|
||||
|
||||
/* Skip group initialization if we're not done with this group. Done
|
||||
* this way to avoid compiler warning. */
|
||||
|
||||
end_of_huffman_loop:
|
||||
if(symCount--) goto continue_this_group;
|
||||
end_of_huffman_loop:
|
||||
if (symCount--) goto continue_this_group;
|
||||
}
|
||||
|
||||
/* At this point, we've read all the Huffman-coded symbols (and repeated
|
||||
runs) for this block from the input stream, and decoded them into the
|
||||
runs) for this block from the input stream, and decoded them into the
|
||||
intermediate buffer. There are dbufCount many decoded bytes in dbuf[].
|
||||
Now undo the Burrows-Wheeler transform on dbuf.
|
||||
See http://dogma.net/markn/articles/bwt/bwt.htm
|
||||
@@ -472,17 +485,17 @@ end_of_huffman_loop:
|
||||
|
||||
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
|
||||
|
||||
j=0;
|
||||
for (i=0;i<256;i++) {
|
||||
k=j+byteCount[i];
|
||||
j = 0;
|
||||
for (i = 0; i < 256; i++) {
|
||||
k = j + byteCount[i];
|
||||
byteCount[i] = j;
|
||||
j=k;
|
||||
j = k;
|
||||
}
|
||||
|
||||
/* Figure out what order dbuf would be in if we sorted it. */
|
||||
|
||||
for (i=0;i<dbufCount;i++) {
|
||||
uc=(unsigned char)(dbuf[i] & 0xff);
|
||||
for (i = 0; i < dbufCount; i++) {
|
||||
uc = (unsigned char)(dbuf[i] & 0xff);
|
||||
dbuf[byteCount[uc]] |= (i << 8);
|
||||
byteCount[uc]++;
|
||||
}
|
||||
@@ -491,14 +504,14 @@ end_of_huffman_loop:
|
||||
doesn't get output, and if the first three characters are identical
|
||||
it doesn't qualify as a run (hence writeRunCountdown=5). */
|
||||
|
||||
if(dbufCount) {
|
||||
if(origPtr>=dbufCount) return RETVAL_DATA_ERROR;
|
||||
bd->writePos=dbuf[origPtr];
|
||||
bd->writeCurrent=(unsigned char)(bd->writePos&0xff);
|
||||
bd->writePos>>=8;
|
||||
bd->writeRunCountdown=5;
|
||||
if (dbufCount) {
|
||||
if (origPtr >= dbufCount) return RETVAL_DATA_ERROR;
|
||||
bd->writePos = dbuf[origPtr];
|
||||
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
|
||||
bd->writePos >>= 8;
|
||||
bd->writeRunCountdown = 5;
|
||||
}
|
||||
bd->writeCount=dbufCount;
|
||||
bd->writeCount = dbufCount;
|
||||
|
||||
return RETVAL_OK;
|
||||
}
|
||||
@@ -510,18 +523,18 @@ end_of_huffman_loop:
|
||||
are ignored, data is written to out_fd and return is RETVAL_OK or error.
|
||||
*/
|
||||
|
||||
static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
{
|
||||
const unsigned int *dbuf;
|
||||
int pos,current,previous,gotcount;
|
||||
const unsigned *dbuf;
|
||||
int pos, current, previous, gotcount;
|
||||
|
||||
/* If last read was short due to end of file, return last block now */
|
||||
if(bd->writeCount<0) return bd->writeCount;
|
||||
if (bd->writeCount < 0) return bd->writeCount;
|
||||
|
||||
gotcount = 0;
|
||||
dbuf=bd->dbuf;
|
||||
pos=bd->writePos;
|
||||
current=bd->writeCurrent;
|
||||
dbuf = bd->dbuf;
|
||||
pos = bd->writePos;
|
||||
current = bd->writeCurrent;
|
||||
|
||||
/* We will always have pending decoded data to write into the output
|
||||
buffer unless this is the very first call (in which case we haven't
|
||||
@@ -539,9 +552,9 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
|
||||
/* If the output buffer is full, snapshot state and return */
|
||||
|
||||
if(gotcount >= len) {
|
||||
bd->writePos=pos;
|
||||
bd->writeCurrent=current;
|
||||
if (gotcount >= len) {
|
||||
bd->writePos = pos;
|
||||
bd->writeCurrent = current;
|
||||
bd->writeCopies++;
|
||||
return len;
|
||||
}
|
||||
@@ -549,8 +562,8 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
/* Write next byte into output buffer, updating CRC */
|
||||
|
||||
outbuf[gotcount++] = current;
|
||||
bd->writeCRC=(((bd->writeCRC)<<8)
|
||||
^bd->crc32Table[((bd->writeCRC)>>24)^current]);
|
||||
bd->writeCRC = (bd->writeCRC << 8)
|
||||
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
|
||||
|
||||
/* Loop now if we're outputting multiple copies of this byte */
|
||||
|
||||
@@ -558,31 +571,32 @@ static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
--bd->writeCopies;
|
||||
continue;
|
||||
}
|
||||
decode_next_byte:
|
||||
decode_next_byte:
|
||||
if (!bd->writeCount--) break;
|
||||
/* Follow sequence vector to undo Burrows-Wheeler transform */
|
||||
previous=current;
|
||||
pos=dbuf[pos];
|
||||
current=pos&0xff;
|
||||
pos>>=8;
|
||||
previous = current;
|
||||
pos = dbuf[pos];
|
||||
current = pos & 0xff;
|
||||
pos >>= 8;
|
||||
|
||||
/* After 3 consecutive copies of the same byte, the 4th is a repeat
|
||||
count. We count down from 4 instead
|
||||
/* After 3 consecutive copies of the same byte, the 4th
|
||||
* is a repeat count. We count down from 4 instead
|
||||
* of counting up because testing for non-zero is faster */
|
||||
|
||||
if(--bd->writeRunCountdown) {
|
||||
if(current!=previous) bd->writeRunCountdown=4;
|
||||
if (--bd->writeRunCountdown) {
|
||||
if (current != previous)
|
||||
bd->writeRunCountdown = 4;
|
||||
} else {
|
||||
|
||||
/* We have a repeated run, this byte indicates the count */
|
||||
|
||||
bd->writeCopies=current;
|
||||
current=previous;
|
||||
bd->writeRunCountdown=5;
|
||||
bd->writeCopies = current;
|
||||
current = previous;
|
||||
bd->writeRunCountdown = 5;
|
||||
|
||||
/* Sometimes there are just 3 bytes (run length 0) */
|
||||
|
||||
if(!bd->writeCopies) goto decode_next_byte;
|
||||
if (!bd->writeCopies) goto decode_next_byte;
|
||||
|
||||
/* Subtract the 1 copy we'd output anyway to get extras */
|
||||
|
||||
@@ -592,13 +606,13 @@ decode_next_byte:
|
||||
|
||||
/* Decompression of this block completed successfully */
|
||||
|
||||
bd->writeCRC=~bd->writeCRC;
|
||||
bd->totalCRC=((bd->totalCRC<<1) | (bd->totalCRC>>31)) ^ bd->writeCRC;
|
||||
bd->writeCRC = ~bd->writeCRC;
|
||||
bd->totalCRC = ((bd->totalCRC << 1) | (bd->totalCRC >> 31)) ^ bd->writeCRC;
|
||||
|
||||
/* If this block had a CRC error, force file level CRC error. */
|
||||
|
||||
if(bd->writeCRC!=bd->headerCRC) {
|
||||
bd->totalCRC=bd->headerCRC+1;
|
||||
if (bd->writeCRC != bd->headerCRC) {
|
||||
bd->totalCRC = bd->headerCRC + 1;
|
||||
return RETVAL_LAST_BLOCK;
|
||||
}
|
||||
}
|
||||
@@ -606,86 +620,107 @@ decode_next_byte:
|
||||
/* Refill the intermediate buffer by Huffman-decoding next block of input */
|
||||
/* (previous is just a convenient unused temp variable here) */
|
||||
|
||||
previous=get_next_block(bd);
|
||||
if(previous) {
|
||||
bd->writeCount=previous;
|
||||
return (previous!=RETVAL_LAST_BLOCK) ? previous : gotcount;
|
||||
previous = get_next_block(bd);
|
||||
if (previous) {
|
||||
bd->writeCount = previous;
|
||||
return (previous != RETVAL_LAST_BLOCK) ? previous : gotcount;
|
||||
}
|
||||
bd->writeCRC=~0;
|
||||
pos=bd->writePos;
|
||||
current=bd->writeCurrent;
|
||||
bd->writeCRC = ~0;
|
||||
pos = bd->writePos;
|
||||
current = bd->writeCurrent;
|
||||
goto decode_next_byte;
|
||||
}
|
||||
|
||||
|
||||
/* Allocate the structure, read file header. If in_fd==-1, inbuf must contain
|
||||
a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are
|
||||
ignored, and data is read from file handle into temporary buffer. */
|
||||
|
||||
static int start_bunzip(bunzip_data **bdp, int in_fd, unsigned char *inbuf,
|
||||
/* Because bunzip2 is used for help text unpacking, and because bb_show_usage()
|
||||
should work for NOFORK applets too, we must be extremely careful to not leak
|
||||
any allocations! */
|
||||
|
||||
int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
|
||||
int len)
|
||||
{
|
||||
bunzip_data *bd;
|
||||
unsigned int i;
|
||||
const unsigned int BZh0=(((unsigned int)'B')<<24)+(((unsigned int)'Z')<<16)
|
||||
+(((unsigned int)'h')<<8)+(unsigned int)'0';
|
||||
unsigned i;
|
||||
enum {
|
||||
BZh0 = ('B' << 24) + ('Z' << 16) + ('h' << 8) + '0'
|
||||
};
|
||||
|
||||
/* Figure out how much data to allocate */
|
||||
|
||||
i=sizeof(bunzip_data);
|
||||
if(in_fd!=-1) i+=IOBUF_SIZE;
|
||||
i = sizeof(bunzip_data);
|
||||
if (in_fd != -1) i += IOBUF_SIZE;
|
||||
|
||||
/* Allocate bunzip_data. Most fields initialize to zero. */
|
||||
|
||||
bd=*bdp=xzalloc(i);
|
||||
bd = *bdp = xzalloc(i);
|
||||
|
||||
/* Setup input buffer */
|
||||
|
||||
if(-1==(bd->in_fd=in_fd)) {
|
||||
bd->inbuf=inbuf;
|
||||
bd->inbufCount=len;
|
||||
} else bd->inbuf=(unsigned char *)(bd+1);
|
||||
bd->in_fd = in_fd;
|
||||
if (-1 == in_fd) {
|
||||
/* in this case, bd->inbuf is read-only */
|
||||
bd->inbuf = (void*)inbuf; /* cast away const-ness */
|
||||
bd->inbufCount = len;
|
||||
} else
|
||||
bd->inbuf = (unsigned char *)(bd + 1);
|
||||
|
||||
/* Init the CRC32 table (big endian) */
|
||||
|
||||
bd->crc32Table = crc32_filltable(1);
|
||||
crc32_filltable(bd->crc32Table, 1);
|
||||
|
||||
/* Setup for I/O error handling via longjmp */
|
||||
|
||||
i=setjmp(bd->jmpbuf);
|
||||
if(i) return i;
|
||||
i = setjmp(bd->jmpbuf);
|
||||
if (i) return i;
|
||||
|
||||
/* Ensure that file starts with "BZh['1'-'9']." */
|
||||
|
||||
i = get_bits(bd,32);
|
||||
if (((unsigned int)(i-BZh0-1)) >= 9) return RETVAL_NOT_BZIP_DATA;
|
||||
i = get_bits(bd, 32);
|
||||
if ((unsigned)(i - BZh0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA;
|
||||
|
||||
/* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
|
||||
uncompressed data. Allocate intermediate buffer for block. */
|
||||
|
||||
bd->dbufSize=100000*(i-BZh0);
|
||||
bd->dbufSize = 100000 * (i - BZh0);
|
||||
|
||||
bd->dbuf=xmalloc(bd->dbufSize * sizeof(int));
|
||||
/* Cannot use xmalloc - may leak bd in NOFORK case! */
|
||||
bd->dbuf = malloc_or_warn(bd->dbufSize * sizeof(int));
|
||||
if (!bd->dbuf) {
|
||||
free(bd);
|
||||
xfunc_die();
|
||||
}
|
||||
return RETVAL_OK;
|
||||
}
|
||||
|
||||
/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip data,
|
||||
not end of file.) */
|
||||
void dealloc_bunzip(bunzip_data *bd)
|
||||
{
|
||||
free(bd->dbuf);
|
||||
free(bd);
|
||||
}
|
||||
|
||||
|
||||
/* Decompress src_fd to dst_fd. Stops at end of bzip data, not end of file. */
|
||||
|
||||
USE_DESKTOP(long long) int
|
||||
uncompressStream(int src_fd, int dst_fd)
|
||||
unpack_bz2_stream(int src_fd, int dst_fd)
|
||||
{
|
||||
USE_DESKTOP(long long total_written = 0;)
|
||||
char *outbuf;
|
||||
bunzip_data *bd;
|
||||
int i;
|
||||
|
||||
outbuf=xmalloc(IOBUF_SIZE);
|
||||
i=start_bunzip(&bd,src_fd,0,0);
|
||||
if(!i) {
|
||||
outbuf = xmalloc(IOBUF_SIZE);
|
||||
i = start_bunzip(&bd, src_fd, NULL, 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;
|
||||
i = read_bunzip(bd, outbuf, IOBUF_SIZE);
|
||||
if (i <= 0) break;
|
||||
if (i != full_write(dst_fd, outbuf, i)) {
|
||||
i = RETVAL_SHORT_WRITE;
|
||||
break;
|
||||
}
|
||||
USE_DESKTOP(total_written += i;)
|
||||
@@ -694,19 +729,18 @@ uncompressStream(int src_fd, int dst_fd)
|
||||
|
||||
/* Check CRC and release memory */
|
||||
|
||||
if(i==RETVAL_LAST_BLOCK) {
|
||||
if (bd->headerCRC!=bd->totalCRC) {
|
||||
bb_error_msg("data integrity error when decompressing");
|
||||
if (i == RETVAL_LAST_BLOCK) {
|
||||
if (bd->headerCRC != bd->totalCRC) {
|
||||
bb_error_msg("CRC error");
|
||||
} else {
|
||||
i=RETVAL_OK;
|
||||
i = RETVAL_OK;
|
||||
}
|
||||
} else if (i==RETVAL_UNEXPECTED_OUTPUT_EOF) {
|
||||
bb_error_msg("compressed file ends unexpectedly");
|
||||
} else if (i == RETVAL_SHORT_WRITE) {
|
||||
bb_error_msg("short write");
|
||||
} else {
|
||||
bb_error_msg("decompression failed");
|
||||
bb_error_msg("bunzip error %d", i);
|
||||
}
|
||||
free(bd->dbuf);
|
||||
free(bd);
|
||||
dealloc_bunzip(bd);
|
||||
free(outbuf);
|
||||
|
||||
return i ? i : USE_DESKTOP(total_written) + 0;
|
||||
@@ -714,18 +748,22 @@ uncompressStream(int src_fd, int dst_fd)
|
||||
|
||||
#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."};
|
||||
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"
|
||||
};
|
||||
|
||||
/* Dumb little test thing, decompress stdin to stdout */
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i=uncompressStream(0,1);
|
||||
int i = unpack_bz2_stream(0, 1);
|
||||
char c;
|
||||
|
||||
if(i<0) 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
|
||||
@@ -7,7 +7,6 @@
|
||||
* (see disclaimer below)
|
||||
*/
|
||||
|
||||
|
||||
/* (N)compress42.c - File compression ala IEEE Computer, Mar 1992.
|
||||
*
|
||||
* Authors:
|
||||
@@ -26,9 +25,6 @@
|
||||
* [... History snipped ...]
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Default input buffer size */
|
||||
#define IBUFSIZ 2048
|
||||
@@ -37,72 +33,67 @@
|
||||
#define OBUFSIZ 2048
|
||||
|
||||
/* Defines for third byte of header */
|
||||
#define MAGIC_1 (char_type)'\037' /* First byte of compressed file */
|
||||
#define MAGIC_2 (char_type)'\235' /* Second byte of compressed file */
|
||||
#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */
|
||||
/* Masks 0x20 and 0x40 are free. */
|
||||
/* I think 0x20 should mean that there is */
|
||||
/* a fourth header byte (for expansion). */
|
||||
#define BLOCK_MODE 0x80 /* Block compresssion if table is full and */
|
||||
/* compression rate is dropping flush tables */
|
||||
/* the next two codes should not be changed lightly, as they must not */
|
||||
/* lie within the contiguous general code space. */
|
||||
#define FIRST 257 /* first free entry */
|
||||
#define CLEAR 256 /* table clear output code */
|
||||
#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */
|
||||
/* Masks 0x20 and 0x40 are free. */
|
||||
/* I think 0x20 should mean that there is */
|
||||
/* a fourth header byte (for expansion). */
|
||||
#define BLOCK_MODE 0x80 /* Block compression if table is full and */
|
||||
/* compression rate is dropping flush tables */
|
||||
/* the next two codes should not be changed lightly, as they must not */
|
||||
/* lie within the contiguous general code space. */
|
||||
#define FIRST 257 /* first free entry */
|
||||
#define CLEAR 256 /* table clear output code */
|
||||
|
||||
#define INIT_BITS 9 /* initial number of bits/code */
|
||||
#define INIT_BITS 9 /* initial number of bits/code */
|
||||
|
||||
|
||||
/* machine variants which require cc -Dmachine: pdp11, z8000, DOS */
|
||||
#define FAST
|
||||
|
||||
#define HBITS 17 /* 50% occupancy */
|
||||
#define HSIZE (1<<HBITS)
|
||||
#define HMASK (HSIZE-1)
|
||||
#define HPRIME 9941
|
||||
#define BITS 16
|
||||
#undef MAXSEG_64K
|
||||
#define MAXCODE(n) (1L << (n))
|
||||
|
||||
#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, HSIZE)
|
||||
#define clear_tab_prefixof() memset(codetab, 0, 256);
|
||||
#define HBITS 17 /* 50% occupancy */
|
||||
#define HSIZE (1<<HBITS)
|
||||
#define HMASK (HSIZE-1) /* unused */
|
||||
#define HPRIME 9941 /* unused */
|
||||
#define BITS 16
|
||||
#define BITS_STR "16"
|
||||
#undef MAXSEG_64K /* unused */
|
||||
#define MAXCODE(n) (1L << (n))
|
||||
|
||||
#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_tab_prefixof() memset(codetab, 0, 256)
|
||||
|
||||
/*
|
||||
* Decompress stdin to stdout. This routine adapts to the codes in the
|
||||
* file building the "string" table on-the-fly; requiring no table to
|
||||
* be stored in the compressed file. The tables used herein are shared
|
||||
* with those of the compress() routine. See the definitions above.
|
||||
* be stored in the compressed file.
|
||||
*/
|
||||
|
||||
USE_DESKTOP(long long) int
|
||||
uncompress(int fd_in, int fd_out)
|
||||
{
|
||||
USE_DESKTOP(long long total_written = 0;)
|
||||
USE_DESKTOP(long long) int retval = -1;
|
||||
unsigned char *stackp;
|
||||
long int code;
|
||||
long code;
|
||||
int finchar;
|
||||
long int oldcode;
|
||||
long int incode;
|
||||
long oldcode;
|
||||
long incode;
|
||||
int inbits;
|
||||
int posbits;
|
||||
int outpos;
|
||||
int insize;
|
||||
int bitmask;
|
||||
long int free_ent;
|
||||
long int maxcode;
|
||||
long int maxmaxcode;
|
||||
long free_ent;
|
||||
long maxcode;
|
||||
long 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];
|
||||
unsigned char *inbuf; /* were eating insane amounts of stack - */
|
||||
unsigned char *outbuf; /* bad for some embedded targets */
|
||||
unsigned char *htab;
|
||||
unsigned short *codetab;
|
||||
|
||||
/* Hmm, these were statics - why?! */
|
||||
/* user settable max # bits/code */
|
||||
@@ -110,8 +101,10 @@ uncompress(int fd_in, int fd_out)
|
||||
/* block compress mode -C compatible with 2.0 */
|
||||
int block_mode; /* = BLOCK_MODE; */
|
||||
|
||||
memset(inbuf, 0, IBUFSIZ + 64);
|
||||
memset(outbuf, 0, OBUFSIZ + 2048);
|
||||
inbuf = xzalloc(IBUFSIZ + 64);
|
||||
outbuf = xzalloc(OBUFSIZ + 2048);
|
||||
htab = xzalloc(HSIZE); /* wsn't zeroed out before, maybe can xmalloc? */
|
||||
codetab = xzalloc(HSIZE * sizeof(codetab[0]));
|
||||
|
||||
insize = 0;
|
||||
|
||||
@@ -119,7 +112,7 @@ uncompress(int fd_in, int fd_out)
|
||||
* 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;
|
||||
goto err;
|
||||
}
|
||||
|
||||
maxbits = inbuf[0] & BIT_MASK;
|
||||
@@ -128,8 +121,8 @@ uncompress(int fd_in, int fd_out)
|
||||
|
||||
if (maxbits > BITS) {
|
||||
bb_error_msg("compressed with %d bits, can only handle "
|
||||
"%d bits", maxbits, BITS);
|
||||
return -1;
|
||||
BITS_STR" bits", maxbits);
|
||||
goto err;
|
||||
}
|
||||
|
||||
n_bits = INIT_BITS;
|
||||
@@ -143,7 +136,7 @@ uncompress(int fd_in, int fd_out)
|
||||
free_ent = ((block_mode) ? FIRST : 256);
|
||||
|
||||
/* As above, initialize the first 256 entries in the table. */
|
||||
clear_tab_prefixof();
|
||||
/*clear_tab_prefixof(); - done by xzalloc */
|
||||
|
||||
for (code = 255; code >= 0; --code) {
|
||||
tab_suffixof(code) = (unsigned char) code;
|
||||
@@ -235,7 +228,7 @@ uncompress(int fd_in, int fd_out)
|
||||
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
|
||||
(posbits & 07));
|
||||
bb_error_msg("uncompress: corrupt input");
|
||||
return -1;
|
||||
goto err;
|
||||
}
|
||||
|
||||
*--stackp = (unsigned char) finchar;
|
||||
@@ -243,7 +236,7 @@ uncompress(int fd_in, int fd_out)
|
||||
}
|
||||
|
||||
/* Generate output characters in reverse order */
|
||||
while ((long int) code >= (long int) 256) {
|
||||
while ((long) code >= (long) 256) {
|
||||
*--stackp = tab_suffixof(code);
|
||||
code = tab_prefixof(code);
|
||||
}
|
||||
@@ -302,7 +295,11 @@ uncompress(int fd_in, int fd_out)
|
||||
USE_DESKTOP(total_written += outpos;)
|
||||
}
|
||||
|
||||
RELEASE_CONFIG_BUFFER(inbuf);
|
||||
RELEASE_CONFIG_BUFFER(outbuf);
|
||||
return USE_DESKTOP(total_written) + 0;
|
||||
retval = USE_DESKTOP(total_written) + 0;
|
||||
err:
|
||||
free(inbuf);
|
||||
free(outbuf);
|
||||
free(htab);
|
||||
free(codetab);
|
||||
return retval;
|
||||
}
|
||||
@@ -12,8 +12,8 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#ifdef CONFIG_FEATURE_LZMA_FAST
|
||||
# define speed_inline ATTRIBUTE_ALWAYS_INLINE
|
||||
#if ENABLE_FEATURE_LZMA_FAST
|
||||
# define speed_inline ALWAYS_INLINE
|
||||
#else
|
||||
# define speed_inline
|
||||
#endif
|
||||
@@ -78,7 +78,7 @@ static rc_t* rc_init(int fd) /*, int buffer_size) */
|
||||
}
|
||||
|
||||
/* Called once */
|
||||
static ATTRIBUTE_ALWAYS_INLINE void rc_free(rc_t * rc)
|
||||
static ALWAYS_INLINE void rc_free(rc_t * rc)
|
||||
{
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(rc);
|
||||
@@ -92,16 +92,18 @@ static void rc_do_normalize(rc_t * rc)
|
||||
rc->range <<= 8;
|
||||
rc->code = (rc->code << 8) | *rc->ptr++;
|
||||
}
|
||||
static ATTRIBUTE_ALWAYS_INLINE void rc_normalize(rc_t * rc)
|
||||
static ALWAYS_INLINE void rc_normalize(rc_t * rc)
|
||||
{
|
||||
if (rc->range < (1 << RC_TOP_BITS)) {
|
||||
rc_do_normalize(rc);
|
||||
}
|
||||
}
|
||||
|
||||
/* Called 9 times */
|
||||
/* rc_is_bit_0 is called 9 times */
|
||||
/* Why rc_is_bit_0_helper exists?
|
||||
* Because we want to always expose (rc->code < rc->bound) to optimizer
|
||||
* Because we want to always expose (rc->code < rc->bound) to optimizer.
|
||||
* Thus rc_is_bit_0 is always inlined, and rc_is_bit_0_helper is inlined
|
||||
* only if we compile for speed.
|
||||
*/
|
||||
static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
|
||||
{
|
||||
@@ -109,7 +111,7 @@ static speed_inline uint32_t rc_is_bit_0_helper(rc_t * rc, uint16_t * p)
|
||||
rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
|
||||
return rc->bound;
|
||||
}
|
||||
static ATTRIBUTE_ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
|
||||
static ALWAYS_INLINE int rc_is_bit_0(rc_t * rc, uint16_t * p)
|
||||
{
|
||||
uint32_t t = rc_is_bit_0_helper(rc, p);
|
||||
return rc->code < t;
|
||||
@@ -143,7 +145,7 @@ static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
|
||||
}
|
||||
|
||||
/* Called once */
|
||||
static ATTRIBUTE_ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
|
||||
static ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
|
||||
{
|
||||
rc_normalize(rc);
|
||||
rc->range >>= 1;
|
||||
@@ -228,7 +230,7 @@ enum {
|
||||
|
||||
|
||||
USE_DESKTOP(long long) int
|
||||
unlzma(int src_fd, int dst_fd)
|
||||
unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
{
|
||||
USE_DESKTOP(long long total_written = 0;)
|
||||
lzma_header_t header;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -5,7 +5,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/* Accept any non-null name, its not really a filter at all */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -23,13 +23,13 @@ char filter_accept_list_reassign(archive_handle_t *archive_handle)
|
||||
name_ptr = strrchr(archive_handle->file_header->name, '.');
|
||||
|
||||
/* Modify the subarchive handler based on the extension */
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
#if ENABLE_FEATURE_DEB_TAR_GZ
|
||||
if (strcmp(name_ptr, ".gz") == 0) {
|
||||
archive_handle->action_data_subarchive = get_header_tar_gz;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
#if ENABLE_FEATURE_DEB_TAR_BZ2
|
||||
if (strcmp(name_ptr, ".bz2") == 0) {
|
||||
archive_handle->action_data_subarchive = get_header_tar_bz2;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/*
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <stdlib.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/* Find a string in a shell pattern list */
|
||||
|
||||
@@ -23,9 +23,9 @@ char get_header_ar(archive_handle_t *archive_handle)
|
||||
char magic[2];
|
||||
} formatted;
|
||||
} ar;
|
||||
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
|
||||
#if ENABLE_FEATURE_AR_LONG_FILENAMES
|
||||
static char *ar_long_names;
|
||||
static unsigned int ar_long_name_size;
|
||||
static unsigned ar_long_name_size;
|
||||
#endif
|
||||
|
||||
/* dont use xread as we want to handle the error ourself */
|
||||
@@ -66,7 +66,9 @@ char get_header_ar(archive_handle_t *archive_handle)
|
||||
|
||||
/* long filenames have '/' as the first character */
|
||||
if (ar.formatted.name[0] == '/') {
|
||||
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
|
||||
#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
|
||||
@@ -78,20 +80,22 @@ char get_header_ar(archive_handle_t *archive_handle)
|
||||
/* 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.formatted.name[1] == ' ') {
|
||||
}
|
||||
|
||||
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.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);
|
||||
}
|
||||
|
||||
/* 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
|
||||
|
||||
@@ -16,8 +16,9 @@ typedef struct hardlinks_s {
|
||||
char get_header_cpio(archive_handle_t *archive_handle)
|
||||
{
|
||||
static hardlinks_t *saved_hardlinks = NULL;
|
||||
static unsigned short pending_hardlinks = 0;
|
||||
static unsigned pending_hardlinks = 0;
|
||||
static int inode;
|
||||
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
char cpio_header[110];
|
||||
int namesize;
|
||||
@@ -30,7 +31,7 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
tmp = saved_hardlinks;
|
||||
oldtmp = NULL;
|
||||
|
||||
file_header->link_name = file_header->name;
|
||||
file_header->link_target = file_header->name;
|
||||
file_header->size = 0;
|
||||
|
||||
while (tmp) {
|
||||
@@ -56,7 +57,7 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
saved_hardlinks = tmp;
|
||||
}
|
||||
|
||||
file_header->name = file_header->link_name;
|
||||
file_header->name = file_header->link_target;
|
||||
|
||||
if (pending_hardlinks > 1) {
|
||||
bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?");
|
||||
@@ -122,12 +123,12 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
}
|
||||
|
||||
if (S_ISLNK(file_header->mode)) {
|
||||
file_header->link_name = xzalloc(file_header->size + 1);
|
||||
xread(archive_handle->src_fd, file_header->link_name, file_header->size);
|
||||
file_header->link_target = xzalloc(file_header->size + 1);
|
||||
xread(archive_handle->src_fd, file_header->link_target, file_header->size);
|
||||
archive_handle->offset += file_header->size;
|
||||
file_header->size = 0; /* Stop possible seeks in future */
|
||||
} else {
|
||||
file_header->link_name = NULL;
|
||||
file_header->link_target = NULL;
|
||||
}
|
||||
if (nlink > 1 && !S_ISDIR(file_header->mode)) {
|
||||
if (file_header->size == 0) { /* Put file on a linked list for later */
|
||||
@@ -154,7 +155,7 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
free(file_header->link_name);
|
||||
free(file_header->link_target);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ static unsigned long long getOctal(char *str, int len)
|
||||
*/
|
||||
str[len] = '\0';
|
||||
v = strtoull(str, &str, 8);
|
||||
if (*str)
|
||||
if (*str && (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY || *str != ' '))
|
||||
bb_error_msg_and_die("corrupted octal value in tar header");
|
||||
return v;
|
||||
}
|
||||
@@ -45,7 +45,7 @@ static unsigned long long getOctal(char *str, int len)
|
||||
void BUG_tar_header_size(void);
|
||||
char get_header_tar(archive_handle_t *archive_handle)
|
||||
{
|
||||
static int end;
|
||||
static smallint end;
|
||||
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
struct {
|
||||
@@ -59,8 +59,9 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char linkname[100]; /* 157-256 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char version[2]; /* 263-264 */
|
||||
/* POSIX: "ustar" NUL "00" */
|
||||
/* GNU tar: "ustar " NUL */
|
||||
char magic[8]; /* 257-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char devmajor[8]; /* 329-336 */
|
||||
@@ -69,7 +70,10 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
char padding[12]; /* 500-512 */
|
||||
} tar;
|
||||
char *cp;
|
||||
int sum, i;
|
||||
int i, sum_u, sum;
|
||||
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
int sum_s;
|
||||
#endif
|
||||
int parse_names;
|
||||
|
||||
if (sizeof(tar) != 512)
|
||||
@@ -110,18 +114,41 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
#endif
|
||||
bb_error_msg_and_die("invalid tar magic");
|
||||
}
|
||||
/* Do checksum on headers */
|
||||
sum = ' ' * sizeof(tar.chksum);
|
||||
for (i = 0; i < 148 ; i++) {
|
||||
sum += ((char*)&tar)[i];
|
||||
|
||||
/* 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. */
|
||||
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
sum_s = ' ' * sizeof(tar.chksum);
|
||||
#endif
|
||||
sum_u = ' ' * sizeof(tar.chksum);
|
||||
for (i = 0; i < 148; i++) {
|
||||
sum_u += ((unsigned char*)&tar)[i];
|
||||
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
sum_s += ((signed char*)&tar)[i];
|
||||
#endif
|
||||
}
|
||||
for (i = 156; i < 512 ; i++) {
|
||||
sum += ((char*)&tar)[i];
|
||||
for (i = 156; i < 512; i++) {
|
||||
sum_u += ((unsigned char*)&tar)[i];
|
||||
#if ENABLE_FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
sum_s += ((signed char*)&tar)[i];
|
||||
#endif
|
||||
}
|
||||
/* This field does not need special treatment (getOctal) */
|
||||
if (sum != xstrtoul(tar.chksum, 8)) {
|
||||
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
sum = strtoul(tar.chksum, &cp, 8);
|
||||
if ((*cp && *cp != ' ')
|
||||
|| (sum_u != sum USE_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum))
|
||||
) {
|
||||
bb_error_msg_and_die("invalid tar header checksum");
|
||||
}
|
||||
#else
|
||||
/* This field does not need special treatment (getOctal) */
|
||||
sum = xstrtoul(tar.chksum, 8);
|
||||
if (sum_u != sum USE_FEATURE_TAR_OLDSUN_COMPATIBILITY(&& sum_s != sum)) {
|
||||
bb_error_msg_and_die("invalid tar header checksum");
|
||||
}
|
||||
#endif
|
||||
|
||||
/* 0 is reserved for high perf file, treat as normal file */
|
||||
if (!tar.typeflag) tar.typeflag = '0';
|
||||
@@ -134,13 +161,13 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
unsigned major = GET_OCTAL(tar.devmajor);
|
||||
file_header->device = makedev(major, minor);
|
||||
}
|
||||
file_header->link_name = NULL;
|
||||
file_header->link_target = NULL;
|
||||
if (!linkname && parse_names && tar.linkname[0]) {
|
||||
/* we trash magic[0] here, it's ok */
|
||||
tar.linkname[sizeof(tar.linkname)] = '\0';
|
||||
file_header->link_name = xstrdup(tar.linkname);
|
||||
/* FIXME: what if we have non-link object with link_name? */
|
||||
/* Will link_name be free()ed? */
|
||||
file_header->link_target = xstrdup(tar.linkname);
|
||||
/* FIXME: what if we have non-link object with link_target? */
|
||||
/* Will link_target be free()ed? */
|
||||
}
|
||||
file_header->mtime = GET_OCTAL(tar.mtime);
|
||||
file_header->size = GET_OCTAL(tar.size);
|
||||
@@ -241,7 +268,7 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
longname = NULL;
|
||||
}
|
||||
if (linkname) {
|
||||
file_header->link_name = linkname;
|
||||
file_header->link_target = linkname;
|
||||
linkname = NULL;
|
||||
}
|
||||
#endif
|
||||
@@ -270,7 +297,7 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
}
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
free(file_header->link_name);
|
||||
free(file_header->link_target);
|
||||
/* Do not free(file_header->name)! */
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -11,9 +11,10 @@ char get_header_tar_bz2(archive_handle_t *archive_handle)
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompressStream);
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_bz2_stream, "bunzip2", "bunzip2", "-cf", "-", NULL);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
/* Can only do one file at a time */
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@@ -3,28 +3,32 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
char get_header_tar_gz(archive_handle_t *archive_handle)
|
||||
{
|
||||
#if BB_MMU
|
||||
unsigned char magic[2];
|
||||
#endif
|
||||
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
/* Check gzip magic only if open_transformer will invoke unpack_gz_stream (MMU case).
|
||||
* Otherwise, it will invoke an external helper "gunzip -cf" (NOMMU case) which will
|
||||
* need the header. */
|
||||
#if BB_MMU
|
||||
xread(archive_handle->src_fd, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("invalid gzip magic");
|
||||
}
|
||||
#endif
|
||||
|
||||
check_header_gzip(archive_handle->src_fd);
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip", "gunzip", "-cf", "-", NULL);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
/* Can only do one file at a time */
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
* Licensed under GPL v2, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
char get_header_tar_lzma(archive_handle_t * archive_handle)
|
||||
@@ -13,9 +14,10 @@ char get_header_tar_lzma(archive_handle_t * archive_handle)
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unlzma);
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma", "unlzma", "-cf", "-", NULL);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS) /**/;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
/* Can only do one file at a time */
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void header_list(const file_header_t *file_header)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void header_skip(const file_header_t *file_header ATTRIBUTE_UNUSED)
|
||||
|
||||
@@ -23,9 +23,8 @@ void header_verbose_list(const file_header_t *file_header)
|
||||
mtime->tm_sec,
|
||||
file_header->name);
|
||||
|
||||
if (file_header->link_name) {
|
||||
printf(" -> %s", file_header->link_name);
|
||||
if (file_header->link_target) {
|
||||
printf(" -> %s", file_header->link_target);
|
||||
}
|
||||
/* putchar isnt used anywhere else i dont think */
|
||||
puts("");
|
||||
bb_putchar('\n');
|
||||
}
|
||||
@@ -3,37 +3,53 @@
|
||||
* 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"
|
||||
|
||||
/* transformer(), more than meets the eye */
|
||||
/*
|
||||
* On MMU machine, the transform_prog and ... are stripped
|
||||
* by a macro in include/unarchive.h. On NOMMU, transformer is stripped.
|
||||
*/
|
||||
int open_transformer(int src_fd,
|
||||
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd))
|
||||
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd),
|
||||
const char *transform_prog, ...)
|
||||
{
|
||||
int fd_pipe[2];
|
||||
int pid;
|
||||
|
||||
if (pipe(fd_pipe) != 0) {
|
||||
bb_perror_msg_and_die("can't create pipe");
|
||||
}
|
||||
xpipe(fd_pipe);
|
||||
|
||||
#if BB_MMU
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
#else
|
||||
pid = vfork();
|
||||
#endif
|
||||
if (pid == -1)
|
||||
bb_perror_msg_and_die("fork failed");
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
#if !BB_MMU
|
||||
va_list ap;
|
||||
#endif
|
||||
/* child process */
|
||||
close(fd_pipe[0]); /* We don't wan't to read from the parent */
|
||||
// FIXME: error check?
|
||||
#if BB_MMU
|
||||
transformer(src_fd, fd_pipe[1]);
|
||||
close(fd_pipe[1]); /* Send EOF */
|
||||
close(src_fd);
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(fd_pipe[1]); /* Send EOF */
|
||||
close(src_fd);
|
||||
}
|
||||
exit(0);
|
||||
#else
|
||||
xmove_fd(src_fd, 0);
|
||||
xmove_fd(fd_pipe[1], 1);
|
||||
va_start(ap, transform_prog);
|
||||
/* hoping that va_list -> char** on our CPU is working... */
|
||||
BB_EXECVP(transform_prog, (void*)ap);
|
||||
bb_perror_msg_and_die("exec failed");
|
||||
#endif
|
||||
/* notreached */
|
||||
}
|
||||
|
||||
|
||||
@@ -3,18 +3,13 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount)
|
||||
{
|
||||
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
|
||||
#ifdef CONFIG_FEATURE_UNARCHIVE_TAPE
|
||||
#if ENABLE_FEATURE_UNARCHIVE_TAPE
|
||||
if (errno == ESPIPE) {
|
||||
seek_by_read(archive_handle, amount);
|
||||
} else
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/* 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.
|
||||
|
||||
@@ -2,11 +2,9 @@
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void unpack_ar_archive(archive_handle_t *ar_archive)
|
||||
{
|
||||
|
||||
+40
-8
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
@@ -80,6 +80,7 @@ static void fileaction_dobackup(char *filename, int fileref);
|
||||
static void fileaction_setowngrp(char *filename, int fileref);
|
||||
static void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref));
|
||||
|
||||
int rpm_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int rpm_main(int argc, char **argv)
|
||||
{
|
||||
int opt = 0, func = 0, rpm_fd, offset;
|
||||
@@ -184,11 +185,19 @@ int rpm_main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void extract_cpio_gz(int fd) {
|
||||
static void extract_cpio_gz(int fd)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned char magic[2];
|
||||
#if BB_MMU
|
||||
USE_DESKTOP(long long) int (*xformer)(int src_fd, int dst_fd);
|
||||
enum { xformer_prog = 0 };
|
||||
#else
|
||||
enum { xformer = 0 };
|
||||
const char *xformer_prog;
|
||||
#endif
|
||||
|
||||
/* Initialise */
|
||||
/* Initialize */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->seek = seek_by_read;
|
||||
//archive_handle->action_header = header_list;
|
||||
@@ -199,16 +208,39 @@ static void extract_cpio_gz(int fd) {
|
||||
archive_handle->offset = 0;
|
||||
|
||||
xread(archive_handle->src_fd, &magic, 2);
|
||||
#if BB_MMU
|
||||
xformer = unpack_gz_stream;
|
||||
#else
|
||||
xformer_prog = "gunzip";
|
||||
#endif
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("invalid gzip magic");
|
||||
if (ENABLE_FEATURE_RPM_BZ2
|
||||
&& (magic[0] == 0x42) && (magic[1] == 0x5a)) {
|
||||
#if BB_MMU
|
||||
xformer = unpack_bz2_stream;
|
||||
#else
|
||||
xformer_prog = "bunzip2";
|
||||
#endif
|
||||
/* We can do better, need modifying unpack_bz2_stream to not require
|
||||
* first 2 bytes. Not very hard to do... I mean, TODO :) */
|
||||
xlseek(archive_handle->src_fd, -2, SEEK_CUR);
|
||||
} else
|
||||
bb_error_msg_and_die("no gzip"
|
||||
USE_FEATURE_RPM_BZ2("/bzip")
|
||||
" magic");
|
||||
} else {
|
||||
#if !BB_MMU
|
||||
/* NOMMU version of open_transformer execs an external unzipper that should
|
||||
* have the file position at the start of the file */
|
||||
xlseek(archive_handle->src_fd, 0, SEEK_SET);
|
||||
#endif
|
||||
}
|
||||
check_header_gzip(archive_handle->src_fd);
|
||||
xchdir("/"); /* Install RPM's to root */
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
|
||||
xchdir("/"); /* Install RPM's to root */
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog, xformer_prog, "-cf", "-", NULL);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
|
||||
/* loop */;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define RPM_MAGIC "\355\253\356\333"
|
||||
@@ -49,6 +49,7 @@ static void skip_header(int rpm_fd)
|
||||
}
|
||||
|
||||
/* No getopt required */
|
||||
int rpm2cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int rpm2cpio_main(int argc, char **argv)
|
||||
{
|
||||
struct rpm_lead lead;
|
||||
@@ -78,8 +79,7 @@ int rpm2cpio_main(int argc, char **argv)
|
||||
bb_error_msg_and_die("invalid gzip magic");
|
||||
}
|
||||
|
||||
check_header_gzip(rpm_fd);
|
||||
if (inflate_gunzip(rpm_fd, STDOUT_FILENO) < 0) {
|
||||
if (unpack_gz_stream(rpm_fd, STDOUT_FILENO) < 0) {
|
||||
bb_error_msg("error inflating");
|
||||
}
|
||||
|
||||
|
||||
+127
-109
@@ -3,7 +3,7 @@
|
||||
* Mini tar implementation for busybox
|
||||
*
|
||||
* Modified to use common extraction code used by ar, cpio, dpkg-deb, dpkg
|
||||
* Glenn McGrath <bug1@iinet.net.au>
|
||||
* by Glenn McGrath
|
||||
*
|
||||
* Note, that as of BusyBox-0.43, tar has been completely rewritten from the
|
||||
* ground up. It still has remnants of the old code lying about, but it is
|
||||
@@ -25,9 +25,11 @@
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define block_buf bb_common_bufsiz1
|
||||
|
||||
#if ENABLE_FEATURE_TAR_CREATE
|
||||
|
||||
/* Tar file constants */
|
||||
@@ -48,8 +50,9 @@ struct TarHeader { /* byte offset */
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char linkname[NAME_SIZE]; /* 157-256 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char version[2]; /* 263-264 */
|
||||
/* POSIX: "ustar" NUL "00" */
|
||||
/* GNU tar: "ustar " NUL */
|
||||
char magic[8]; /* 257-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char devmajor[8]; /* 329-336 */
|
||||
@@ -104,7 +107,7 @@ enum TarFileType {
|
||||
typedef enum TarFileType TarFileType;
|
||||
|
||||
/* Might be faster (and bigger) if the dev/ino were stored in numeric order;) */
|
||||
static void addHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr,
|
||||
static void addHardLinkInfo(HardLinkInfo **hlInfoHeadPtr,
|
||||
struct stat *statbuf,
|
||||
const char *fileName)
|
||||
{
|
||||
@@ -120,7 +123,7 @@ static void addHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr,
|
||||
strcpy(hlInfo->name, fileName);
|
||||
}
|
||||
|
||||
static void freeHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr)
|
||||
static void freeHardLinkInfo(HardLinkInfo **hlInfoHeadPtr)
|
||||
{
|
||||
HardLinkInfo *hlInfo;
|
||||
HardLinkInfo *hlInfoNext;
|
||||
@@ -134,11 +137,10 @@ static void freeHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr)
|
||||
}
|
||||
*hlInfoHeadPtr = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Might be faster (and bigger) if the dev/ino were stored in numeric order;) */
|
||||
static HardLinkInfo *findHardLinkInfo(HardLinkInfo * hlInfo, struct stat *statbuf)
|
||||
static HardLinkInfo *findHardLinkInfo(HardLinkInfo *hlInfo, struct stat *statbuf)
|
||||
{
|
||||
while (hlInfo) {
|
||||
if ((statbuf->st_ino == hlInfo->ino) && (statbuf->st_dev == hlInfo->dev))
|
||||
@@ -173,6 +175,9 @@ static void putOctal(char *cp, int len, off_t value)
|
||||
|
||||
static void chksum_and_xwrite(int fd, struct TarHeader* hp)
|
||||
{
|
||||
/* POSIX says that checksum is done on unsigned bytes
|
||||
* (Sun and HP-UX gets it wrong... more details in
|
||||
* GNU tar source) */
|
||||
const unsigned char *cp;
|
||||
int chksum, size;
|
||||
|
||||
@@ -273,8 +278,8 @@ static int writeTarHeader(struct TarBallInfo *tbInfo,
|
||||
tbInfo->hlInfo->name, 0);
|
||||
#endif
|
||||
} else if (S_ISLNK(statbuf->st_mode)) {
|
||||
char *lpath = xreadlink(fileName);
|
||||
if (!lpath) /* Already printed err msg inside xreadlink() */
|
||||
char *lpath = xmalloc_readlink_or_warn(fileName);
|
||||
if (!lpath)
|
||||
return FALSE;
|
||||
header.typeflag = SYMTYPE;
|
||||
strncpy(header.linkname, lpath, sizeof(header.linkname));
|
||||
@@ -382,6 +387,27 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
const char *header_name;
|
||||
int inputFileFd = -1;
|
||||
|
||||
/* Strip leading '/' (must be before memorizing hardlink's name) */
|
||||
header_name = fileName;
|
||||
while (header_name[0] == '/') {
|
||||
static smallint warned;
|
||||
|
||||
if (!warned) {
|
||||
bb_error_msg("removing leading '/' from member names");
|
||||
warned = 1;
|
||||
}
|
||||
header_name++;
|
||||
}
|
||||
|
||||
if (header_name[0] == '\0')
|
||||
return TRUE;
|
||||
|
||||
/* It is against the rules to archive a socket */
|
||||
if (S_ISSOCK(statbuf->st_mode)) {
|
||||
bb_error_msg("%s: socket ignored", fileName);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see if we are dealing with a hard link.
|
||||
* If so -
|
||||
@@ -393,54 +419,34 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
if (statbuf->st_nlink > 1) {
|
||||
tbInfo->hlInfo = findHardLinkInfo(tbInfo->hlInfoHead, statbuf);
|
||||
if (tbInfo->hlInfo == NULL)
|
||||
addHardLinkInfo(&tbInfo->hlInfoHead, statbuf, fileName);
|
||||
}
|
||||
|
||||
/* It is against the rules to archive a socket */
|
||||
if (S_ISSOCK(statbuf->st_mode)) {
|
||||
bb_error_msg("%s: socket ignored", fileName);
|
||||
return TRUE;
|
||||
addHardLinkInfo(&tbInfo->hlInfoHead, statbuf, header_name);
|
||||
}
|
||||
|
||||
/* It is a bad idea to store the archive we are in the process of creating,
|
||||
* so check the device and inode to be sure that this particular file isn't
|
||||
* the new tarball */
|
||||
if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
|
||||
tbInfo->statBuf.st_ino == statbuf->st_ino) {
|
||||
if (tbInfo->statBuf.st_dev == statbuf->st_dev
|
||||
&& tbInfo->statBuf.st_ino == statbuf->st_ino
|
||||
) {
|
||||
bb_error_msg("%s: file is the archive; skipping", fileName);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
header_name = fileName;
|
||||
while (header_name[0] == '/') {
|
||||
static int alreadyWarned = FALSE;
|
||||
|
||||
if (alreadyWarned == FALSE) {
|
||||
bb_error_msg("removing leading '/' from member names");
|
||||
alreadyWarned = TRUE;
|
||||
}
|
||||
header_name++;
|
||||
}
|
||||
if (exclude_file(tbInfo->excludeList, header_name))
|
||||
return SKIP;
|
||||
|
||||
#if !ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
if (strlen(fileName) >= NAME_SIZE) {
|
||||
if (strlen(header_name) >= NAME_SIZE) {
|
||||
bb_error_msg("names longer than "NAME_SIZE_STR" chars not supported");
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (header_name[0] == '\0')
|
||||
return TRUE;
|
||||
|
||||
if (exclude_file(tbInfo->excludeList, header_name))
|
||||
return SKIP;
|
||||
|
||||
/* Is this a regular file? */
|
||||
if (tbInfo->hlInfo == NULL && S_ISREG(statbuf->st_mode)) {
|
||||
/* open the file we want to archive, and make sure all is well */
|
||||
inputFileFd = open(fileName, O_RDONLY);
|
||||
inputFileFd = open_or_warn(fileName, O_RDONLY);
|
||||
if (inputFileFd < 0) {
|
||||
bb_perror_msg("%s: cannot open", fileName);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -453,7 +459,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
/* If it was a regular file, write out the body */
|
||||
if (inputFileFd >= 0) {
|
||||
size_t readSize;
|
||||
/* Wwrite the file to the archive. */
|
||||
/* Write the file to the archive. */
|
||||
/* We record size into header first, */
|
||||
/* and then write out file. If file shrinks in between, */
|
||||
/* tar will be corrupted. So we don't allow for that. */
|
||||
@@ -474,8 +480,8 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
/* Pad the file up to the tar block size */
|
||||
/* (a few tricks here in the name of code size) */
|
||||
readSize = (-(int)statbuf->st_size) & (TAR_BLOCK_SIZE-1);
|
||||
memset(bb_common_bufsiz1, 0, readSize);
|
||||
xwrite(tbInfo->tarFd, bb_common_bufsiz1, readSize);
|
||||
memset(block_buf, 0, readSize);
|
||||
xwrite(tbInfo->tarFd, block_buf, readSize);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -501,13 +507,21 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
bb_perror_msg_and_die("cannot stat tar file");
|
||||
|
||||
if ((ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2) && gzip) {
|
||||
int gzipDataPipe[2] = { -1, -1 };
|
||||
int gzipStatusPipe[2] = { -1, -1 };
|
||||
volatile int vfork_exec_errno = 0;
|
||||
char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
|
||||
// On Linux, vfork never unpauses parent early, although standard
|
||||
// allows for that. Do we want to waste bytes checking for it?
|
||||
#define WAIT_FOR_CHILD 0
|
||||
|
||||
if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0)
|
||||
bb_perror_msg_and_die("pipe");
|
||||
volatile int vfork_exec_errno = 0;
|
||||
#if WAIT_FOR_CHILD
|
||||
struct { int rd; int wr; } gzipStatusPipe;
|
||||
#endif
|
||||
struct { int rd; int wr; } gzipDataPipe;
|
||||
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
|
||||
|
||||
xpipe(&gzipDataPipe.rd);
|
||||
#if WAIT_FOR_CHILD
|
||||
xpipe(&gzipStatusPipe.rd);
|
||||
#endif
|
||||
|
||||
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
|
||||
|
||||
@@ -519,57 +533,62 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
#endif
|
||||
|
||||
gzipPid = vfork();
|
||||
if (gzipPid < 0)
|
||||
bb_perror_msg_and_die("vfork gzip");
|
||||
|
||||
if (gzipPid == 0) {
|
||||
dup2(gzipDataPipe[0], 0);
|
||||
close(gzipDataPipe[1]);
|
||||
|
||||
dup2(tbInfo.tarFd, 1);
|
||||
|
||||
close(gzipStatusPipe[0]);
|
||||
fcntl(gzipStatusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows success */
|
||||
|
||||
execlp(zip_exec, zip_exec, "-f", NULL);
|
||||
/* child */
|
||||
xmove_fd(tbInfo.tarFd, 1);
|
||||
xmove_fd(gzipDataPipe.rd, 0);
|
||||
close(gzipDataPipe.wr);
|
||||
#if WAIT_FOR_CHILD
|
||||
close(gzipStatusPipe.rd);
|
||||
fcntl(gzipStatusPipe.wr, F_SETFD, FD_CLOEXEC);
|
||||
#endif
|
||||
/* exec gzip/bzip2 program/applet */
|
||||
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
|
||||
vfork_exec_errno = errno;
|
||||
_exit(1);
|
||||
}
|
||||
|
||||
close(gzipStatusPipe[1]);
|
||||
exit(-1);
|
||||
} else if (gzipPid > 0) {
|
||||
close(gzipDataPipe[0]);
|
||||
close(gzipStatusPipe[1]);
|
||||
/* parent */
|
||||
xmove_fd(gzipDataPipe.wr, tbInfo.tarFd);
|
||||
close(gzipDataPipe.rd);
|
||||
#if WAIT_FOR_CHILD
|
||||
close(gzipStatusPipe.wr);
|
||||
while (1) {
|
||||
char buf;
|
||||
int n;
|
||||
|
||||
while (1) {
|
||||
char buf;
|
||||
/* Wait until child execs (or fails to) */
|
||||
n = full_read(gzipStatusPipe.rd, &buf, 1);
|
||||
if ((n < 0) && (/*errno == EAGAIN ||*/ errno == EINTR))
|
||||
continue; /* try it again */
|
||||
|
||||
int n = full_read(gzipStatusPipe[0], &buf, 1);
|
||||
|
||||
if (n == 0 && vfork_exec_errno != 0) {
|
||||
errno = vfork_exec_errno;
|
||||
bb_perror_msg_and_die("cannot exec %s", zip_exec);
|
||||
} else if ((n < 0) && (errno == EAGAIN || errno == EINTR))
|
||||
continue; /* try it again */
|
||||
break;
|
||||
}
|
||||
close(gzipStatusPipe[0]);
|
||||
|
||||
tbInfo.tarFd = gzipDataPipe[1];
|
||||
} else bb_perror_msg_and_die("vfork gzip");
|
||||
}
|
||||
close(gzipStatusPipe.rd);
|
||||
#endif
|
||||
if (vfork_exec_errno) {
|
||||
errno = vfork_exec_errno;
|
||||
bb_perror_msg_and_die("cannot exec %s", zip_exec);
|
||||
}
|
||||
}
|
||||
|
||||
tbInfo.excludeList = exclude;
|
||||
|
||||
/* Read the directory/files and iterate over them one at a time */
|
||||
while (include) {
|
||||
if (!recursive_action(include->data, TRUE, dereferenceFlag,
|
||||
FALSE, writeFileToTarball, writeFileToTarball, &tbInfo, 0))
|
||||
if (!recursive_action(include->data, ACTION_RECURSE |
|
||||
(dereferenceFlag ? ACTION_FOLLOWLINKS : 0),
|
||||
writeFileToTarball, writeFileToTarball, &tbInfo, 0))
|
||||
{
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
include = include->link;
|
||||
}
|
||||
/* Write two empty blocks to the end of the archive */
|
||||
memset(bb_common_bufsiz1, 0, 2*TAR_BLOCK_SIZE);
|
||||
xwrite(tbInfo.tarFd, bb_common_bufsiz1, 2*TAR_BLOCK_SIZE);
|
||||
memset(block_buf, 0, 2*TAR_BLOCK_SIZE);
|
||||
xwrite(tbInfo.tarFd, block_buf, 2*TAR_BLOCK_SIZE);
|
||||
|
||||
/* To be pedantically correct, we would check if the tarball
|
||||
* is smaller than 20 tar blocks, and pad it if it was smaller,
|
||||
@@ -644,10 +663,10 @@ static char get_header_tar_Z(archive_handle_t *archive_handle)
|
||||
bb_error_msg_and_die("invalid magic");
|
||||
}
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress);
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress, "uncompress", "uncompress", "-cf", "-", NULL);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
/* nothing */;
|
||||
continue;
|
||||
|
||||
/* Can only do one file at a time */
|
||||
return EXIT_FAILURE;
|
||||
@@ -674,7 +693,7 @@ static void handle_SIGCHLD(int status)
|
||||
/* child exited with 0 */
|
||||
return;
|
||||
/* Cannot happen?
|
||||
if(!WIFSIGNALED(status) && !WIFEXITED(status)) return; */
|
||||
if (!WIFSIGNALED(status) && !WIFEXITED(status)) return; */
|
||||
child_error = 1;
|
||||
}
|
||||
#endif
|
||||
@@ -711,47 +730,47 @@ enum {
|
||||
OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions
|
||||
};
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||
static const struct option tar_long_options[] = {
|
||||
{ "list", 0, NULL, 't' },
|
||||
{ "extract", 0, NULL, 'x' },
|
||||
{ "directory", 1, NULL, 'C' },
|
||||
{ "file", 1, NULL, 'f' },
|
||||
{ "to-stdout", 0, NULL, 'O' },
|
||||
{ "same-permissions", 0, NULL, 'p' },
|
||||
{ "verbose", 0, NULL, 'v' },
|
||||
{ "keep-old", 0, NULL, 'k' },
|
||||
static const char tar_longopts[] ALIGN1 =
|
||||
"list\0" No_argument "t"
|
||||
"extract\0" No_argument "x"
|
||||
"directory\0" Required_argument "C"
|
||||
"file\0" Required_argument "f"
|
||||
"to-stdout\0" No_argument "O"
|
||||
"same-permissions\0" No_argument "p"
|
||||
"verbose\0" No_argument "v"
|
||||
"keep-old\0" No_argument "k"
|
||||
# if ENABLE_FEATURE_TAR_CREATE
|
||||
{ "create", 0, NULL, 'c' },
|
||||
{ "dereference", 0, NULL, 'h' },
|
||||
"create\0" No_argument "c"
|
||||
"dereference\0" No_argument "h"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_BZIP2
|
||||
{ "bzip2", 0, NULL, 'j' },
|
||||
"bzip2\0" No_argument "j"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_LZMA
|
||||
{ "lzma", 0, NULL, 'a' },
|
||||
"lzma\0" No_argument "a"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_FROM
|
||||
{ "files-from", 1, NULL, 'T' },
|
||||
{ "exclude-from", 1, NULL, 'X' },
|
||||
"files-from\0" Required_argument "T"
|
||||
"exclude-from\0" Required_argument "X"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_GZIP
|
||||
{ "gzip", 0, NULL, 'z' },
|
||||
"gzip\0" No_argument "z"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_COMPRESS
|
||||
{ "compress", 0, NULL, 'Z' },
|
||||
"compress\0" No_argument "Z"
|
||||
# endif
|
||||
{ "no-same-owner", 0, NULL, 0xfd },
|
||||
{ "no-same-permissions",0, NULL, 0xfe },
|
||||
"no-same-owner\0" No_argument "\xfd"
|
||||
"no-same-permissions\0" No_argument "\xfe"
|
||||
/* --exclude takes next bit position in option mask, */
|
||||
/* therefore we have to either put it _after_ --no-same-perm */
|
||||
/* or add OPT[BIT]_EXCLUDE before OPT[BIT]_NOPRESERVE_OWN */
|
||||
# if ENABLE_FEATURE_TAR_FROM
|
||||
{ "exclude", 1, NULL, 0xff },
|
||||
"exclude\0" Required_argument "\xff"
|
||||
# endif
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
;
|
||||
#endif
|
||||
|
||||
int tar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int tar_main(int argc, char **argv)
|
||||
{
|
||||
char (*get_header_ptr)(archive_handle_t *) = get_header_tar;
|
||||
@@ -782,9 +801,9 @@ int tar_main(int argc, char **argv)
|
||||
USE_FEATURE_TAR_CREATE("c--tx:t--cx:x--ct") // mutually exclusive
|
||||
SKIP_FEATURE_TAR_CREATE("t--x:x--t"); // mutually exclusive
|
||||
#if ENABLE_FEATURE_TAR_LONG_OPTIONS
|
||||
applet_long_options = tar_long_options;
|
||||
applet_long_options = tar_longopts;
|
||||
#endif
|
||||
opt = getopt32(argc, argv,
|
||||
opt = getopt32(argv,
|
||||
"txC:f:Opvk"
|
||||
USE_FEATURE_TAR_CREATE( "ch" )
|
||||
USE_FEATURE_TAR_BZIP2( "j" )
|
||||
@@ -860,10 +879,9 @@ int tar_main(int argc, char **argv)
|
||||
char *cp = last_char_is(argv[optind], '/');
|
||||
if (cp > argv[optind])
|
||||
*cp = '\0';
|
||||
llist_add_to(&tar_handle->accept, argv[optind]);
|
||||
llist_add_to_end(&tar_handle->accept, argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
tar_handle->accept = rev_llist(tar_handle->accept);
|
||||
|
||||
if (tar_handle->accept || tar_handle->reject)
|
||||
tar_handle->filter = filter_accept_reject_list;
|
||||
|
||||
@@ -1,94 +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 "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 = getopt32(argc, argv, "cf");
|
||||
|
||||
while (optind < argc) {
|
||||
char *compressed_file = argv[optind++];
|
||||
char *delete_path = NULL;
|
||||
char *uncompressed_file = NULL;
|
||||
int src_fd;
|
||||
int dst_fd;
|
||||
|
||||
if (LONE_DASH(compressed_file)) {
|
||||
src_fd = STDIN_FILENO;
|
||||
flags |= GUNZIP_TO_STDOUT;
|
||||
} else {
|
||||
src_fd = 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 = 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 = xopen3(uncompressed_file,
|
||||
O_WRONLY | O_CREAT | O_TRUNC,
|
||||
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("cannot remove %s", delete_path);
|
||||
}
|
||||
|
||||
free(uncompressed_file);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -1,64 +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.
|
||||
*/
|
||||
|
||||
/* Why our g[un]zip/bunzip2 are so ugly compared to this beauty? */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define UNLZMA_OPT_STDOUT 1
|
||||
|
||||
int unlzma_main(int argc, char **argv)
|
||||
{
|
||||
USE_DESKTOP(long long) int status;
|
||||
char *filename;
|
||||
unsigned opt;
|
||||
int src_fd, dst_fd;
|
||||
|
||||
opt = getopt32(argc, argv, "c");
|
||||
|
||||
/* Set input filename and number */
|
||||
filename = argv[optind];
|
||||
if (filename && NOT_LONE_DASH(filename)) {
|
||||
/* Open input file */
|
||||
src_fd = xopen(filename, O_RDONLY);
|
||||
} else {
|
||||
src_fd = STDIN_FILENO;
|
||||
filename = 0;
|
||||
}
|
||||
|
||||
/* if called as lzmacat force the stdout flag */
|
||||
if ((opt & UNLZMA_OPT_STDOUT) || applet_name[4] == 'c')
|
||||
filename = 0;
|
||||
|
||||
if (filename) {
|
||||
struct stat stat_buf;
|
||||
/* bug: char *extension = filename + strlen(filename) - 5; */
|
||||
char *extension = strrchr(filename, '.');
|
||||
if (!extension || strcmp(extension, ".lzma") != 0) {
|
||||
bb_error_msg_and_die("invalid extension");
|
||||
}
|
||||
xstat(filename, &stat_buf);
|
||||
*extension = '\0';
|
||||
dst_fd = xopen3(filename, O_WRONLY | O_CREAT | O_TRUNC,
|
||||
stat_buf.st_mode);
|
||||
} else
|
||||
dst_fd = STDOUT_FILENO;
|
||||
status = unlzma(src_fd, dst_fd);
|
||||
if (filename) {
|
||||
if (status >= 0) /* if success delete src, else delete dst */
|
||||
filename[strlen(filename)] = '.';
|
||||
if (unlink(filename) < 0) {
|
||||
bb_error_msg_and_die("cannot remove %s", filename);
|
||||
}
|
||||
}
|
||||
|
||||
return (status < 0);
|
||||
}
|
||||
+143
-110
@@ -24,40 +24,70 @@
|
||||
* - central directory
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.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)
|
||||
enum {
|
||||
#if BB_BIG_ENDIAN
|
||||
ZIP_FILEHEADER_MAGIC = 0x504b0304,
|
||||
ZIP_CDS_MAGIC = 0x504b0102,
|
||||
ZIP_CDS_END_MAGIC = 0x504b0506,
|
||||
ZIP_DD_MAGIC = 0x504b0708,
|
||||
#else
|
||||
ZIP_FILEHEADER_MAGIC = 0x04034b50,
|
||||
ZIP_CDS_MAGIC = 0x02014b50,
|
||||
ZIP_CDS_END_MAGIC = 0x06054b50,
|
||||
ZIP_DD_MAGIC = 0x08074b50,
|
||||
#endif
|
||||
};
|
||||
|
||||
#define ZIP_HEADER_LEN 26
|
||||
|
||||
typedef union {
|
||||
unsigned char raw[26];
|
||||
uint8_t raw[ZIP_HEADER_LEN];
|
||||
struct {
|
||||
unsigned short version; /* 0-1 */
|
||||
unsigned short flags; /* 2-3 */
|
||||
unsigned short method; /* 4-5 */
|
||||
unsigned short modtime; /* 6-7 */
|
||||
unsigned short moddate; /* 8-9 */
|
||||
unsigned int crc32 ATTRIBUTE_PACKED; /* 10-13 */
|
||||
unsigned int cmpsize ATTRIBUTE_PACKED; /* 14-17 */
|
||||
unsigned int ucmpsize ATTRIBUTE_PACKED; /* 18-21 */
|
||||
unsigned short filename_len; /* 22-23 */
|
||||
unsigned short extra_len; /* 24-25 */
|
||||
uint16_t version; /* 0-1 */
|
||||
uint16_t flags; /* 2-3 */
|
||||
uint16_t method; /* 4-5 */
|
||||
uint16_t modtime; /* 6-7 */
|
||||
uint16_t moddate; /* 8-9 */
|
||||
uint32_t crc32 ATTRIBUTE_PACKED; /* 10-13 */
|
||||
uint32_t cmpsize ATTRIBUTE_PACKED; /* 14-17 */
|
||||
uint32_t ucmpsize ATTRIBUTE_PACKED; /* 18-21 */
|
||||
uint16_t filename_len; /* 22-23 */
|
||||
uint16_t extra_len; /* 24-25 */
|
||||
} formatted ATTRIBUTE_PACKED;
|
||||
} zip_header_t;
|
||||
|
||||
/* Check the offset of the last element, not the length. This leniency
|
||||
* allows for poor packing, whereby the overall struct may be too long,
|
||||
* even though the elements are all in the right place.
|
||||
*/
|
||||
struct BUG_zip_header_must_be_26_bytes {
|
||||
char BUG_zip_header_must_be_26_bytes[
|
||||
offsetof(zip_header_t, formatted.extra_len) + 2 ==
|
||||
ZIP_HEADER_LEN ? 1 : -1];
|
||||
};
|
||||
|
||||
#define FIX_ENDIANNESS(zip_header) do { \
|
||||
(zip_header).formatted.version = SWAP_LE16((zip_header).formatted.version ); \
|
||||
(zip_header).formatted.flags = SWAP_LE16((zip_header).formatted.flags ); \
|
||||
(zip_header).formatted.method = SWAP_LE16((zip_header).formatted.method ); \
|
||||
(zip_header).formatted.modtime = SWAP_LE16((zip_header).formatted.modtime ); \
|
||||
(zip_header).formatted.moddate = SWAP_LE16((zip_header).formatted.moddate ); \
|
||||
(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_LE16((zip_header).formatted.filename_len); \
|
||||
(zip_header).formatted.extra_len = SWAP_LE16((zip_header).formatted.extra_len ); \
|
||||
} while (0)
|
||||
|
||||
static void unzip_skip(int fd, off_t skip)
|
||||
{
|
||||
if (lseek(fd, skip, SEEK_CUR) == (off_t)-1) {
|
||||
if (errno != ESPIPE)
|
||||
bb_error_msg_and_die("seek failure");
|
||||
bb_copyfd_exact_size(fd, -1, skip);
|
||||
}
|
||||
bb_copyfd_exact_size(fd, -1, skip);
|
||||
}
|
||||
|
||||
static void unzip_create_leading_dirs(char *fn)
|
||||
static void unzip_create_leading_dirs(const char *fn)
|
||||
{
|
||||
/* Create all leading directories */
|
||||
char *name = xstrdup(fn);
|
||||
@@ -67,7 +97,7 @@ static void unzip_create_leading_dirs(char *fn)
|
||||
free(name);
|
||||
}
|
||||
|
||||
static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
|
||||
static void unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
|
||||
{
|
||||
if (zip_header->formatted.method == 0) {
|
||||
/* Method 0 - stored (not compressed) */
|
||||
@@ -77,63 +107,72 @@ static int unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
|
||||
} else {
|
||||
/* Method 8 - inflate */
|
||||
inflate_unzip_result res;
|
||||
/* err = */ inflate_unzip(&res, zip_header->formatted.cmpsize, src_fd, dst_fd);
|
||||
// we should check for -1 error return
|
||||
if (inflate_unzip(&res, zip_header->formatted.cmpsize, src_fd, dst_fd) < 0)
|
||||
bb_error_msg_and_die("inflate error");
|
||||
/* Validate decompression - crc */
|
||||
if (zip_header->formatted.crc32 != (res.crc ^ 0xffffffffL)) {
|
||||
bb_error_msg("invalid compressed data--%s error", "crc");
|
||||
return 1;
|
||||
bb_error_msg_and_die("crc error");
|
||||
}
|
||||
/* Validate decompression - size */
|
||||
if (zip_header->formatted.ucmpsize != res.bytes_out) {
|
||||
bb_error_msg("invalid compressed data--%s error", "length");
|
||||
return 1;
|
||||
/* Don't die. Who knows, maybe len calculation
|
||||
* was botched somewhere. After all, crc matched! */
|
||||
bb_error_msg("bad length");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int unzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int unzip_main(int argc, char **argv)
|
||||
{
|
||||
enum { O_PROMPT, O_NEVER, O_ALWAYS };
|
||||
|
||||
zip_header_t zip_header;
|
||||
enum {v_silent, v_normal, v_list} verbosity = v_normal;
|
||||
enum {o_prompt, o_never, o_always} overwrite = o_prompt;
|
||||
unsigned int total_size = 0;
|
||||
unsigned int total_entries = 0;
|
||||
int src_fd = -1, dst_fd = -1;
|
||||
char *src_fn = NULL, *dst_fn = NULL;
|
||||
smallint verbose = 1;
|
||||
smallint listing = 0;
|
||||
smallint overwrite = O_PROMPT;
|
||||
unsigned total_size;
|
||||
unsigned total_entries;
|
||||
int src_fd = -1;
|
||||
int dst_fd = -1;
|
||||
char *src_fn = NULL;
|
||||
char *dst_fn = NULL;
|
||||
llist_t *zaccept = NULL;
|
||||
llist_t *zreject = NULL;
|
||||
char *base_dir = NULL;
|
||||
int failed, i, opt, opt_range = 0, list_header_done = 0;
|
||||
char key_buf[512];
|
||||
int i, opt;
|
||||
int opt_range = 0;
|
||||
char key_buf[80];
|
||||
struct stat stat_buf;
|
||||
|
||||
/* '-' makes getopt return 1 for non-options */
|
||||
while ((opt = getopt(argc, argv, "-d:lnopqx")) != -1) {
|
||||
switch (opt_range) {
|
||||
case 0: /* Options */
|
||||
switch (opt) {
|
||||
case 'l': /* List */
|
||||
verbosity = v_list;
|
||||
listing = 1;
|
||||
break;
|
||||
|
||||
case 'n': /* Never overwrite existing files */
|
||||
overwrite = o_never;
|
||||
overwrite = O_NEVER;
|
||||
break;
|
||||
|
||||
case 'o': /* Always overwrite existing files */
|
||||
overwrite = o_always;
|
||||
overwrite = O_ALWAYS;
|
||||
break;
|
||||
|
||||
case 'p': /* Extract files to stdout and fall through to set verbosity */
|
||||
dst_fd = STDOUT_FILENO;
|
||||
|
||||
case 'q': /* Be quiet */
|
||||
verbosity = (verbosity == v_normal) ? v_silent : verbosity;
|
||||
verbose = 0;
|
||||
break;
|
||||
|
||||
case 1 : /* The zip file */
|
||||
src_fn = xstrndup(optarg, strlen(optarg)+4);
|
||||
case 1: /* The zip file */
|
||||
/* +5: space for ".zip" and NUL */
|
||||
src_fn = xmalloc(strlen(optarg) + 5);
|
||||
strcpy(src_fn, optarg);
|
||||
opt_range++;
|
||||
break;
|
||||
|
||||
@@ -146,31 +185,30 @@ int unzip_main(int argc, char **argv)
|
||||
case 1: /* Include files */
|
||||
if (opt == 1) {
|
||||
llist_add_to(&zaccept, optarg);
|
||||
|
||||
} else if (opt == 'd') {
|
||||
break;
|
||||
}
|
||||
if (opt == 'd') {
|
||||
base_dir = optarg;
|
||||
opt_range += 2;
|
||||
|
||||
} else if (opt == 'x') {
|
||||
opt_range++;
|
||||
|
||||
} else {
|
||||
bb_show_usage();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
if (opt == 'x') {
|
||||
opt_range++;
|
||||
break;
|
||||
}
|
||||
bb_show_usage();
|
||||
|
||||
case 2 : /* Exclude files */
|
||||
if (opt == 1) {
|
||||
llist_add_to(&zreject, optarg);
|
||||
|
||||
} else if (opt == 'd') { /* Extract to base directory */
|
||||
break;
|
||||
}
|
||||
if (opt == 'd') { /* Extract to base directory */
|
||||
base_dir = optarg;
|
||||
opt_range++;
|
||||
|
||||
} else {
|
||||
bb_show_usage();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
/* fall through */
|
||||
|
||||
default:
|
||||
bb_show_usage();
|
||||
@@ -185,17 +223,19 @@ int unzip_main(int argc, char **argv)
|
||||
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;
|
||||
if (overwrite == O_PROMPT)
|
||||
overwrite = O_NEVER;
|
||||
} else {
|
||||
static const char *const extn[] = {"", ".zip", ".ZIP"};
|
||||
static const char extn[][5] = {"", ".zip", ".ZIP"};
|
||||
int orig_src_fn_len = strlen(src_fn);
|
||||
|
||||
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);
|
||||
src_fn[orig_src_fn_len] = '\0';
|
||||
bb_error_msg_and_die("can't open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,36 +243,31 @@ int unzip_main(int argc, char **argv)
|
||||
if (base_dir)
|
||||
xchdir(base_dir);
|
||||
|
||||
if (verbosity != v_silent)
|
||||
if (verbose) {
|
||||
printf("Archive: %s\n", src_fn);
|
||||
if (listing){
|
||||
puts(" Length Date Time Name\n"
|
||||
" -------- ---- ---- ----");
|
||||
}
|
||||
}
|
||||
|
||||
failed = 0;
|
||||
|
||||
total_size = 0;
|
||||
total_entries = 0;
|
||||
while (1) {
|
||||
unsigned int magic;
|
||||
uint32_t magic;
|
||||
|
||||
/* Check magic number */
|
||||
xread(src_fd, &magic, 4);
|
||||
if (magic == ZIP_CDS_MAGIC) {
|
||||
if (magic == ZIP_CDS_MAGIC)
|
||||
break;
|
||||
} else if (magic != ZIP_FILEHEADER_MAGIC) {
|
||||
if (magic != ZIP_FILEHEADER_MAGIC)
|
||||
bb_error_msg_and_die("invalid zip magic %08X", magic);
|
||||
}
|
||||
|
||||
/* Read the file header */
|
||||
xread(src_fd, zip_header.raw, 26);
|
||||
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);
|
||||
xread(src_fd, zip_header.raw, ZIP_HEADER_LEN);
|
||||
FIX_ENDIANNESS(zip_header);
|
||||
if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) {
|
||||
bb_error_msg_and_die("unsupported compression method %d", zip_header.formatted.method);
|
||||
bb_error_msg_and_die("unsupported method %d", zip_header.formatted.method);
|
||||
}
|
||||
|
||||
/* Read filename */
|
||||
@@ -243,23 +278,17 @@ int unzip_main(int argc, char **argv)
|
||||
/* Skip extra header bytes */
|
||||
unzip_skip(src_fd, zip_header.formatted.extra_len);
|
||||
|
||||
if ((verbosity == v_list) && !list_header_done){
|
||||
puts(" Length Date Time Name\n"
|
||||
" -------- ---- ---- ----");
|
||||
list_header_done = 1;
|
||||
}
|
||||
|
||||
/* Filter zip entries */
|
||||
if (find_list_entry(zreject, dst_fn) ||
|
||||
(zaccept && !find_list_entry(zaccept, dst_fn))) { /* Skip entry */
|
||||
if (find_list_entry(zreject, dst_fn)
|
||||
|| (zaccept && !find_list_entry(zaccept, dst_fn))
|
||||
) { /* Skip entry */
|
||||
i = 'n';
|
||||
|
||||
} else { /* Extract entry */
|
||||
total_size += zip_header.formatted.ucmpsize;
|
||||
|
||||
if (verbosity == v_list) { /* List entry */
|
||||
unsigned int dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
|
||||
printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
|
||||
if (listing) { /* List entry */
|
||||
if (verbose) {
|
||||
unsigned dostime = zip_header.formatted.modtime | (zip_header.formatted.moddate << 16);
|
||||
printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
|
||||
zip_header.formatted.ucmpsize,
|
||||
(dostime & 0x01e00000) >> 21,
|
||||
(dostime & 0x001f0000) >> 16,
|
||||
@@ -267,7 +296,12 @@ int unzip_main(int argc, char **argv)
|
||||
(dostime & 0x0000f800) >> 11,
|
||||
(dostime & 0x000007e0) >> 5,
|
||||
dst_fn);
|
||||
total_entries++;
|
||||
total_size += zip_header.formatted.ucmpsize;
|
||||
total_entries++;
|
||||
} else {
|
||||
/* short listing -- filenames only */
|
||||
puts(dst_fn);
|
||||
}
|
||||
i = 'n';
|
||||
} else if (dst_fd == STDOUT_FILENO) { /* Extracting to STDOUT */
|
||||
i = -1;
|
||||
@@ -276,7 +310,7 @@ int unzip_main(int argc, char **argv)
|
||||
if (errno != ENOENT) {
|
||||
bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
|
||||
}
|
||||
if (verbosity == v_normal) {
|
||||
if (verbose) {
|
||||
printf(" creating: %s\n", dst_fn);
|
||||
}
|
||||
unzip_create_leading_dirs(dst_fn);
|
||||
@@ -298,14 +332,14 @@ int unzip_main(int argc, char **argv)
|
||||
}
|
||||
i = 'y';
|
||||
} else { /* File already exists */
|
||||
if (overwrite == o_never) {
|
||||
if (overwrite == O_NEVER) {
|
||||
i = 'n';
|
||||
} else if (S_ISREG(stat_buf.st_mode)) { /* File is regular file */
|
||||
if (overwrite == o_always) {
|
||||
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)) {
|
||||
if (!fgets(key_buf, sizeof(key_buf), stdin)) {
|
||||
bb_perror_msg_and_die("cannot read input");
|
||||
}
|
||||
i = key_buf[0];
|
||||
@@ -319,17 +353,15 @@ int unzip_main(int argc, char **argv)
|
||||
|
||||
switch (i) {
|
||||
case 'A':
|
||||
overwrite = o_always;
|
||||
overwrite = O_ALWAYS;
|
||||
case 'y': /* Open file and fall into unzip */
|
||||
unzip_create_leading_dirs(dst_fn);
|
||||
dst_fd = xopen(dst_fn, O_WRONLY | O_CREAT | O_TRUNC);
|
||||
case -1: /* Unzip */
|
||||
if (verbosity == v_normal) {
|
||||
if (verbose) {
|
||||
printf(" inflating: %s\n", dst_fn);
|
||||
}
|
||||
if (unzip_extract(&zip_header, src_fd, dst_fd)) {
|
||||
failed = 1;
|
||||
}
|
||||
unzip_extract(&zip_header, src_fd, dst_fd);
|
||||
if (dst_fd != STDOUT_FILENO) {
|
||||
/* closing STDOUT is potentially bad for future business */
|
||||
close(dst_fd);
|
||||
@@ -337,7 +369,7 @@ int unzip_main(int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'N':
|
||||
overwrite = o_never;
|
||||
overwrite = O_NEVER;
|
||||
case 'n':
|
||||
/* Skip entry data */
|
||||
unzip_skip(src_fd, zip_header.formatted.cmpsize);
|
||||
@@ -346,7 +378,7 @@ int unzip_main(int argc, char **argv)
|
||||
case 'r':
|
||||
/* Prompt for new name */
|
||||
printf("new name: ");
|
||||
if (!fgets(key_buf, 512, stdin)) {
|
||||
if (!fgets(key_buf, sizeof(key_buf), stdin)) {
|
||||
bb_perror_msg_and_die("cannot read input");
|
||||
}
|
||||
free(dst_fn);
|
||||
@@ -366,10 +398,11 @@ int unzip_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (verbosity == v_list) {
|
||||
if (listing && verbose) {
|
||||
printf(" -------- -------\n"
|
||||
"%9d %d files\n", total_size, total_entries);
|
||||
"%9d %d files\n",
|
||||
total_size, total_entries);
|
||||
}
|
||||
|
||||
return failed;
|
||||
return 0;
|
||||
}
|
||||
@@ -31,6 +31,12 @@ config DUMPKMAP
|
||||
This program dumps the kernel's keyboard translation table to
|
||||
stdout, in binary format. You can then use loadkmap to load it.
|
||||
|
||||
config KBD_MODE
|
||||
bool "kbd_mode"
|
||||
default n
|
||||
help
|
||||
This program reports and sets keyboard mode.
|
||||
|
||||
config LOADFONT
|
||||
bool "loadfont"
|
||||
default n
|
||||
@@ -85,7 +91,7 @@ config SETCONSOLE
|
||||
config FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
depends on SET_CONSOLE && GETOPT_LONG
|
||||
depends on SETCONSOLE && GETOPT_LONG
|
||||
help
|
||||
Support long options for the setconsole applet.
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ lib-$(CONFIG_CLEAR) += clear.o
|
||||
lib-$(CONFIG_DEALLOCVT) += deallocvt.o
|
||||
lib-$(CONFIG_DUMPKMAP) += dumpkmap.o
|
||||
lib-$(CONFIG_SETCONSOLE) += setconsole.o
|
||||
lib-$(CONFIG_KBD_MODE) += kbd_mode.o
|
||||
lib-$(CONFIG_LOADFONT) += loadfont.o
|
||||
lib-$(CONFIG_LOADKMAP) += loadkmap.o
|
||||
lib-$(CONFIG_OPENVT) += openvt.o
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
enum {
|
||||
@@ -15,6 +15,7 @@ enum {
|
||||
VT_WAITACTIVE = 0x5607 /* wait for vt active */
|
||||
};
|
||||
|
||||
int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
@@ -24,10 +25,9 @@ int chvt_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
fd = get_console_fd();
|
||||
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");
|
||||
}
|
||||
num = xatou_range(argv[1], 1, 63);
|
||||
/* double cast suppresses "cast to ptr from int of different size" */
|
||||
xioctl(fd, VT_ACTIVATE, (void *)(ptrdiff_t)num);
|
||||
xioctl(fd, VT_WAITACTIVE, (void *)(ptrdiff_t)num);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -10,11 +10,9 @@
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int clear_main(int argc, char **argv)
|
||||
{
|
||||
return printf("\033[H\033[J") != 6;
|
||||
|
||||
@@ -10,19 +10,20 @@
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.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) MAIN_EXTERNALLY_VISIBLE;
|
||||
int deallocvt_main(int argc, char **argv)
|
||||
{
|
||||
/* num = 0 deallocate all unused consoles */
|
||||
int num = 0;
|
||||
|
||||
switch (argc) {
|
||||
case 2:
|
||||
num = xatoul_range(argv[1], 1, 63);
|
||||
num = xatou_range(argv[1], 1, 63);
|
||||
/* Fallthrough */
|
||||
case 1:
|
||||
break;
|
||||
@@ -30,8 +31,7 @@ int deallocvt_main(int argc, char *argv[])
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if (-1 == ioctl(get_console_fd(), VT_DISALLOCATE, num)) {
|
||||
bb_perror_msg_and_die("VT_DISALLOCATE");
|
||||
}
|
||||
/* double cast suppresses "cast to ptr from int of different size" */
|
||||
xioctl(get_console_fd(), VT_DISALLOCATE, (void *)(ptrdiff_t)num);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbentry {
|
||||
@@ -22,18 +22,19 @@ struct kbentry {
|
||||
#define NR_KEYS 128
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int dumpkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
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 = 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] */
|
||||
@@ -49,12 +50,12 @@ int dumpkmap_main(int argc, char **argv)
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
if (ioctl(fd, KDGKBENT, &ke) < 0) {
|
||||
bb_perror_msg("ioctl failed with %s, %s, %p",
|
||||
if (!ioctl_or_perror(fd, KDGKBENT, &ke,
|
||||
"ioctl failed with %s, %s, %p",
|
||||
(char *)&ke.kb_index,
|
||||
(char *)&ke.kb_table,
|
||||
&ke.kb_value);
|
||||
} else {
|
||||
&ke.kb_value)
|
||||
) {
|
||||
write(1, (void*)&ke.kb_value, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini loadkmap implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2007 Loïc Grenié <loic.grenie@gmail.com>
|
||||
* written using Andries Brouwer <aeb@cwi.nl>'s kbd_mode from
|
||||
* console-utils v0.2.3, licensed under GNU GPLv2
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include "libbb.h"
|
||||
#include <linux/kd.h>
|
||||
|
||||
int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int kbd_mode_main(int argc, char **argv)
|
||||
{
|
||||
static const char opts[] = "saku";
|
||||
|
||||
const char *opt = argv[1];
|
||||
const char *p;
|
||||
int fd;
|
||||
|
||||
fd = get_console_fd();
|
||||
if (fd < 0) /* get_console_fd() already complained */
|
||||
return EXIT_FAILURE;
|
||||
|
||||
if (opt == NULL) {
|
||||
/* No arg */
|
||||
const char *msg = "unknown";
|
||||
int mode;
|
||||
|
||||
ioctl(fd, KDGKBMODE, &mode);
|
||||
switch(mode) {
|
||||
case K_RAW:
|
||||
msg = "raw (scancode)";
|
||||
break;
|
||||
case K_XLATE:
|
||||
msg = "default (ASCII)";
|
||||
break;
|
||||
case K_MEDIUMRAW:
|
||||
msg = "mediumraw (keycode)";
|
||||
break;
|
||||
case K_UNICODE:
|
||||
msg = "Unicode (UTF-8)";
|
||||
break;
|
||||
}
|
||||
printf("The keyboard is in %s mode\n", msg);
|
||||
}
|
||||
else if (argc > 2 /* more than 1 arg */
|
||||
|| *opt != '-' /* not an option */
|
||||
|| (p = strchr(opts, opt[1])) == NULL /* not an option we expect */
|
||||
|| opt[2] != '\0' /* more than one option char */
|
||||
) {
|
||||
bb_show_usage();
|
||||
/* return EXIT_FAILURE; - not reached */
|
||||
}
|
||||
else {
|
||||
#if K_RAW != 0 || K_XLATE != 1 || K_MEDIUMRAW != 2 || K_UNICODE != 3
|
||||
#error kbd_mode must be changed
|
||||
#endif
|
||||
/* The options are in the order of the various K_xxx */
|
||||
ioctl(fd, KDSKBMODE, p - opts);
|
||||
}
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
close(fd);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+41
-53
@@ -7,7 +7,7 @@
|
||||
* Loads the console font, and possibly the corresponding screen map(s).
|
||||
* (Adapted for busybox by Matej Vela.)
|
||||
*/
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
#include <sys/kd.h>
|
||||
|
||||
enum {
|
||||
@@ -21,42 +21,27 @@ enum {
|
||||
};
|
||||
|
||||
struct psf_header {
|
||||
unsigned char magic1, magic2; /* Magic number */
|
||||
unsigned char mode; /* PSF font mode */
|
||||
unsigned char charsize; /* Character size */
|
||||
unsigned char magic1, magic2; /* Magic number */
|
||||
unsigned char mode; /* PSF font mode */
|
||||
unsigned char charsize; /* Character size */
|
||||
};
|
||||
|
||||
#define PSF_MAGIC_OK(x) ((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2)
|
||||
|
||||
static void loadnewfont(int fd);
|
||||
|
||||
int loadfont_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (argc != 1)
|
||||
bb_show_usage();
|
||||
|
||||
fd = xopen(CURRENT_VC, O_RDWR);
|
||||
loadnewfont(fd);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
|
||||
{
|
||||
char buf[16384];
|
||||
char *buf;
|
||||
int i;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (unit < 1 || unit > 32)
|
||||
bb_error_msg_and_die("bad character size %d", unit);
|
||||
|
||||
buf = xzalloc(16 * 1024);
|
||||
/*memset(buf, 0, 16 * 1024);*/
|
||||
for (i = 0; i < fontsize; i++)
|
||||
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
|
||||
|
||||
#if defined( PIO_FONTX ) && !defined( __sparc__ )
|
||||
#if defined(PIO_FONTX) && !defined(__sparc__)
|
||||
{
|
||||
struct consolefontdesc cfd;
|
||||
|
||||
@@ -64,13 +49,13 @@ static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
|
||||
cfd.charheight = unit;
|
||||
cfd.chardata = buf;
|
||||
|
||||
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
|
||||
return; /* success */
|
||||
bb_perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
|
||||
if (!ioctl_or_perror(fd, PIO_FONTX, &cfd, "PIO_FONTX ioctl failed (will try PIO_FONT)"))
|
||||
goto ret; /* success */
|
||||
}
|
||||
#endif
|
||||
if (ioctl(fd, PIO_FONT, buf))
|
||||
bb_perror_msg_and_die("PIO_FONT ioctl error");
|
||||
xioctl(fd, PIO_FONT, buf);
|
||||
ret:
|
||||
free(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -105,49 +90,38 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
advice.advised_hashsize = 0;
|
||||
advice.advised_hashstep = 0;
|
||||
advice.advised_hashlevel = 0;
|
||||
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");
|
||||
} else
|
||||
#endif
|
||||
bb_perror_msg_and_die("PIO_UNIMAPCLR");
|
||||
}
|
||||
xioctl(fd, PIO_UNIMAPCLR, &advice);
|
||||
ud.entry_ct = ct;
|
||||
ud.entries = up;
|
||||
if (ioctl(fd, PIO_UNIMAP, &ud)) {
|
||||
bb_perror_msg_and_die("PIO_UNIMAP");
|
||||
}
|
||||
xioctl(fd, PIO_UNIMAP, &ud);
|
||||
}
|
||||
|
||||
static void loadnewfont(int fd)
|
||||
{
|
||||
enum { INBUF_SIZE = 32*1024 + 1 };
|
||||
|
||||
int unit;
|
||||
unsigned char inbuf[32768]; /* primitive */
|
||||
unsigned int inputlth, offset;
|
||||
unsigned inputlth, offset;
|
||||
/* Was on stack, but 32k is a bit too much: */
|
||||
unsigned char *inbuf = xmalloc(INBUF_SIZE);
|
||||
|
||||
/*
|
||||
* We used to look at the length of the input file
|
||||
* with stat(); now that we accept compressed files,
|
||||
* just read the entire file.
|
||||
*/
|
||||
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
|
||||
if (ferror(stdin))
|
||||
inputlth = full_read(STDIN_FILENO, inbuf, INBUF_SIZE);
|
||||
if (inputlth < 0)
|
||||
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");
|
||||
if (inputlth >= INBUF_SIZE)
|
||||
bb_error_msg_and_die("font too large");
|
||||
|
||||
/* test for psf first */
|
||||
{
|
||||
struct psf_header psfhdr;
|
||||
int fontsize;
|
||||
int hastable;
|
||||
unsigned int head0, head;
|
||||
unsigned head0, head;
|
||||
|
||||
if (inputlth < sizeof(struct psf_header))
|
||||
goto no_psf;
|
||||
@@ -160,7 +134,7 @@ static void loadnewfont(int fd)
|
||||
if (psfhdr.mode > PSF_MAXMODE)
|
||||
bb_error_msg_and_die("unsupported psf file mode");
|
||||
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
|
||||
#if !defined( PIO_FONTX ) || defined( __sparc__ )
|
||||
#if !defined(PIO_FONTX) || defined(__sparc__)
|
||||
if (fontsize != 256)
|
||||
bb_error_msg_and_die("only fontsize 256 supported");
|
||||
#endif
|
||||
@@ -176,8 +150,8 @@ static void loadnewfont(int fd)
|
||||
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
|
||||
return;
|
||||
}
|
||||
no_psf:
|
||||
|
||||
no_psf:
|
||||
/* file with three code pages? */
|
||||
if (inputlth == 9780) {
|
||||
offset = 40;
|
||||
@@ -191,3 +165,17 @@ static void loadnewfont(int fd)
|
||||
}
|
||||
do_loadfont(fd, inbuf + offset, unit, 256);
|
||||
}
|
||||
|
||||
int loadfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int loadfont_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (argc != 1)
|
||||
bb_show_usage();
|
||||
|
||||
fd = xopen(CURRENT_VC, O_RDWR);
|
||||
loadnewfont(fd);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#define BINARY_KEYMAP_MAGIC "bkeymap"
|
||||
|
||||
@@ -25,6 +25,7 @@ struct kbentry {
|
||||
#define NR_KEYS 128
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int loadkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int loadkmap_main(int argc, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
|
||||
+13
-20
@@ -10,33 +10,26 @@
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int openvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int openvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
char vtname[sizeof(VC_FORMAT) + 2];
|
||||
|
||||
if (argc < 3) {
|
||||
if (argc < 3)
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
/* check for illegal vt number: < 1 or > 63 */
|
||||
sprintf(vtname, VC_FORMAT, (int)xatoul_range(argv[1], 1, 63));
|
||||
sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63));
|
||||
|
||||
if (fork() == 0) {
|
||||
/* child */
|
||||
/* leave current vt (controlling tty) */
|
||||
setsid();
|
||||
/* and grab new one */
|
||||
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--);
|
||||
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
|
||||
/* grab new one */
|
||||
close(0);
|
||||
xopen(vtname, O_RDWR);
|
||||
dup2(0, STDOUT_FILENO);
|
||||
dup2(0, STDERR_FILENO);
|
||||
|
||||
execvp(argv[2], &argv[2]);
|
||||
_exit(1);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
BB_EXECVP(argv[2], &argv[2]);
|
||||
_exit(1);
|
||||
}
|
||||
@@ -10,11 +10,9 @@
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int reset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int reset_main(int argc, char **argv)
|
||||
{
|
||||
if (isatty(1)) {
|
||||
|
||||
+42
-11
@@ -7,32 +7,63 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
/* no options, no getopt */
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#define ESC "\033"
|
||||
|
||||
#define old_termios (*(struct termios*)&bb_common_bufsiz1)
|
||||
|
||||
static void
|
||||
onintr(int sig ATTRIBUTE_UNUSED)
|
||||
{
|
||||
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int resize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int resize_main(int argc, char **argv)
|
||||
{
|
||||
struct termios old, new;
|
||||
struct winsize w = {0,0,0,0};
|
||||
struct termios new;
|
||||
struct winsize w = { 0,0,0,0 };
|
||||
int ret;
|
||||
|
||||
tcgetattr(STDOUT_FILENO, &old); /* fiddle echo */
|
||||
new = old;
|
||||
/* 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_termios); /* fiddle echo */
|
||||
new = old_termios;
|
||||
new.c_cflag |= (CLOCAL | CREAD);
|
||||
new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
||||
tcsetattr(STDOUT_FILENO, TCSANOW, &new);
|
||||
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
|
||||
*/
|
||||
printf("\0337\033[r\033[999;999H\033[6n");
|
||||
scanf("\033[%hu;%huR", &w.ws_row, &w.ws_col);
|
||||
ret = ioctl(STDOUT_FILENO, TIOCSWINSZ, &w);
|
||||
printf("\0338");
|
||||
tcsetattr(STDOUT_FILENO, TCSANOW, &old);
|
||||
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_termios);
|
||||
|
||||
if (ENABLE_FEATURE_RESIZE_PRINT)
|
||||
printf("COLUMNS=%d;LINES=%d;export COLUMNS LINES;\n",
|
||||
w.ws_col, w.ws_row);
|
||||
|
||||
return ret;
|
||||
}
|
||||
+10
-11
@@ -7,26 +7,27 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <getopt.h>
|
||||
#include "libbb.h"
|
||||
|
||||
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
static const struct option setconsole_long_options[] = {
|
||||
{ "reset", 0, NULL, 'r' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
static const char setconsole_longopts[] ALIGN1 =
|
||||
"reset\0" No_argument "r"
|
||||
;
|
||||
#endif
|
||||
|
||||
#define OPT_SETCONS_RESET 1
|
||||
|
||||
int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setconsole_main(int argc, char **argv)
|
||||
{
|
||||
unsigned long flags;
|
||||
const char *device = CURRENT_TTY;
|
||||
|
||||
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
applet_long_options = setconsole_long_options;
|
||||
applet_long_options = setconsole_longopts;
|
||||
#endif
|
||||
flags = getopt32(argc, argv, "r");
|
||||
flags = getopt32(argv, "r");
|
||||
|
||||
if (argc - optind > 1)
|
||||
bb_show_usage();
|
||||
@@ -37,11 +38,9 @@ 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(xopen(device, O_RDONLY), TIOCCONS)) {
|
||||
bb_perror_msg_and_die("TIOCCONS");
|
||||
}
|
||||
xioctl(xopen(device, O_RDONLY), TIOCCONS, NULL);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -9,12 +9,8 @@
|
||||
* 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"
|
||||
|
||||
//#include <sys/ioctl.h>
|
||||
#include "libbb.h"
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbkeycode {
|
||||
@@ -24,8 +20,8 @@ enum {
|
||||
KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
|
||||
};
|
||||
|
||||
extern int
|
||||
setkeycodes_main(int argc, char** argv)
|
||||
int setkeycodes_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setkeycodes_main(int argc, char **argv)
|
||||
{
|
||||
int fd, sc;
|
||||
struct kbkeycode a;
|
||||
@@ -43,9 +39,9 @@ setkeycodes_main(int argc, char** argv)
|
||||
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);
|
||||
}
|
||||
ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
|
||||
"failed to set SCANCODE %x to KEYCODE %d",
|
||||
sc, a.keycode);
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
}
|
||||
|
||||
@@ -9,9 +9,10 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
extern int setlogcons_main(int argc, char **argv)
|
||||
int setlogcons_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setlogcons_main(int argc, char **argv)
|
||||
{
|
||||
struct {
|
||||
char fn;
|
||||
@@ -24,8 +25,7 @@ extern int setlogcons_main(int argc, char **argv)
|
||||
if (argc == 2)
|
||||
arg.subarg = xatoul_range(argv[1], 0, 63);
|
||||
|
||||
if (ioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg))
|
||||
bb_perror_msg_and_die("TIOCLINUX");
|
||||
xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+55
-47
@@ -65,13 +65,6 @@ config CKSUM
|
||||
help
|
||||
cksum is used to calculate the CRC32 checksum of a file.
|
||||
|
||||
config CMP
|
||||
bool "cmp"
|
||||
default n
|
||||
help
|
||||
cmp is used to compare two files and returns the result
|
||||
to standard output.
|
||||
|
||||
config COMM
|
||||
bool "comm"
|
||||
default n
|
||||
@@ -142,38 +135,6 @@ config DF
|
||||
df reports the amount of disk space used and available
|
||||
on filesystems.
|
||||
|
||||
config DIFF
|
||||
bool "diff"
|
||||
default n
|
||||
help
|
||||
diff compares two files or directories and outputs the
|
||||
differences between them in a form that can be given to
|
||||
the patch command.
|
||||
|
||||
config FEATURE_DIFF_BINARY
|
||||
bool "Enable checks for binary files"
|
||||
default y
|
||||
depends on DIFF
|
||||
help
|
||||
This option enables support for checking for binary files
|
||||
before a comparison is carried out.
|
||||
|
||||
config FEATURE_DIFF_DIR
|
||||
bool "Enable directory support"
|
||||
default y
|
||||
depends on DIFF
|
||||
help
|
||||
This option enables support for directory and subdirectory
|
||||
comparison.
|
||||
|
||||
config FEATURE_DIFF_MINIMAL
|
||||
bool "Enable -d option to find smaller sets of changes"
|
||||
default n
|
||||
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 DIRNAME
|
||||
bool "dirname"
|
||||
default n
|
||||
@@ -239,6 +200,19 @@ config FEATURE_ENV_LONG_OPTIONS
|
||||
help
|
||||
Support long options for the env applet.
|
||||
|
||||
config EXPAND
|
||||
bool "expand"
|
||||
default n
|
||||
help
|
||||
By default, convert all tabs to spaces.
|
||||
|
||||
config FEATURE_EXPAND_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
depends on EXPAND && GETOPT_LONG
|
||||
help
|
||||
Support long options for the expand applet.
|
||||
|
||||
config EXPR
|
||||
bool "expr"
|
||||
default n
|
||||
@@ -474,6 +448,20 @@ config PWD
|
||||
help
|
||||
pwd is used to print the current directory.
|
||||
|
||||
config READLINK
|
||||
bool "readlink"
|
||||
default n
|
||||
help
|
||||
This program reads a symbolic link and returns the name
|
||||
of the file it points to
|
||||
|
||||
config FEATURE_READLINK_FOLLOW
|
||||
bool "Enable canonicalization by following all symlinks (-f)"
|
||||
default n
|
||||
depends on READLINK
|
||||
help
|
||||
Enable the readlink option (-f).
|
||||
|
||||
config REALPATH
|
||||
bool "realpath"
|
||||
default n
|
||||
@@ -536,6 +524,21 @@ config FEATURE_SORT_BIG
|
||||
The SuSv3 sort standard is available at:
|
||||
http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
|
||||
|
||||
config SPLIT
|
||||
bool "split"
|
||||
default n
|
||||
help
|
||||
split a file into pieces.
|
||||
|
||||
config FEATURE_SPLIT_FANCY
|
||||
bool "fancy extensions"
|
||||
default n
|
||||
depends on SPLIT
|
||||
help
|
||||
Add support for features not required by SUSv3.
|
||||
Supports additional suffixes 'b' for 512 bytes,
|
||||
'g' for 1GiB for the -b option.
|
||||
|
||||
config STAT
|
||||
bool "stat"
|
||||
default n
|
||||
@@ -665,6 +668,19 @@ config UNAME
|
||||
help
|
||||
uname is used to print system information.
|
||||
|
||||
config UNEXPAND
|
||||
bool "unexpand"
|
||||
default n
|
||||
help
|
||||
By default, convert only leading sequences of blanks to tabs.
|
||||
|
||||
config FEATURE_UNEXPAND_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
depends on UNEXPAND && GETOPT_LONG
|
||||
help
|
||||
Support long options for the unexpand applet.
|
||||
|
||||
config UNIQ
|
||||
bool "uniq"
|
||||
default n
|
||||
@@ -689,14 +705,6 @@ config UUENCODE
|
||||
help
|
||||
uuencode is used to uuencode a file.
|
||||
|
||||
config WATCH
|
||||
bool "watch"
|
||||
default n
|
||||
select DATE
|
||||
help
|
||||
watch is used to execute a program periodically, showing
|
||||
output to the screen.
|
||||
|
||||
config WC
|
||||
bool "wc"
|
||||
default n
|
||||
|
||||
+6
-4
@@ -10,21 +10,20 @@ lib-y:=
|
||||
lib-$(CONFIG_BASENAME) += basename.o
|
||||
lib-$(CONFIG_CAL) += cal.o
|
||||
lib-$(CONFIG_CAT) += cat.o
|
||||
lib-$(CONFIG_LESS) += cat.o # less uses it if stdout isn't a tty
|
||||
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
|
||||
@@ -32,6 +31,7 @@ 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_EXPAND) += expand.o
|
||||
lib-$(CONFIG_FALSE) += false.o
|
||||
lib-$(CONFIG_FOLD) += fold.o
|
||||
lib-$(CONFIG_HEAD) += head.o
|
||||
@@ -53,12 +53,14 @@ lib-$(CONFIG_OD) += od.o
|
||||
lib-$(CONFIG_PRINTENV) += printenv.o
|
||||
lib-$(CONFIG_PRINTF) += printf.o
|
||||
lib-$(CONFIG_PWD) += pwd.o
|
||||
lib-$(CONFIG_READLINK) += readlink.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_SPLIT) += split.o
|
||||
lib-$(CONFIG_SORT) += sort.o
|
||||
lib-$(CONFIG_STAT) += stat.o
|
||||
lib-$(CONFIG_STTY) += stty.o
|
||||
@@ -73,11 +75,11 @@ lib-$(CONFIG_TR) += tr.o
|
||||
lib-$(CONFIG_TRUE) += true.o
|
||||
lib-$(CONFIG_TTY) += tty.o
|
||||
lib-$(CONFIG_UNAME) += uname.o
|
||||
lib-$(CONFIG_UNEXPAND) += expand.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
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
* 3) Save some space by using strcmp(). Calling strncmp() here was silly.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int basename_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int basename_main(int argc, char **argv)
|
||||
{
|
||||
size_t m, n;
|
||||
@@ -34,7 +34,8 @@ int basename_main(int argc, char **argv)
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
s = bb_get_last_path_component(*++argv);
|
||||
/* It should strip slash: /abc/def/ -> def */
|
||||
s = bb_get_last_path_component_strip(*++argv);
|
||||
|
||||
if (*++argv) {
|
||||
n = strlen(*argv);
|
||||
@@ -46,5 +47,5 @@ int basename_main(int argc, char **argv)
|
||||
|
||||
puts(s);
|
||||
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
return fflush(stdout);
|
||||
}
|
||||
+54
-58
@@ -17,7 +17,9 @@
|
||||
* Major size reduction... over 50% (>1.5k) on i386.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* We often use "unsigned" intead of "int", it's easier to div on most CPUs */
|
||||
|
||||
#define THURSDAY 4 /* for reformation */
|
||||
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
|
||||
@@ -28,29 +30,25 @@
|
||||
#define MAXDAYS 42 /* max slots in a month array */
|
||||
#define SPACE -1 /* used in day array */
|
||||
|
||||
static const char days_in_month[] = {
|
||||
static const unsigned char days_in_month[] ALIGN1 = {
|
||||
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
|
||||
};
|
||||
|
||||
static const char sep1752[] = {
|
||||
static const unsigned char sep1752[] ALIGN1 = {
|
||||
1, 2, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23,
|
||||
24, 25, 26, 27, 28, 29, 30
|
||||
};
|
||||
|
||||
static int julian;
|
||||
static unsigned julian;
|
||||
|
||||
/* leap year -- account for Gregorian reformation in 1752 */
|
||||
#define leap_year(yr) \
|
||||
((yr) <= 1752 ? !((yr) % 4) : \
|
||||
(!((yr) % 4) && ((yr) % 100)) || !((yr) % 400))
|
||||
|
||||
static int is_leap_year(int year)
|
||||
static int leap_year(unsigned yr)
|
||||
{
|
||||
return leap_year(year);
|
||||
if (yr <= 1752)
|
||||
return !(yr % 4);
|
||||
return (!(yr % 4) && (yr % 100)) || !(yr % 400);
|
||||
}
|
||||
#undef leap_year
|
||||
#define leap_year(yr) is_leap_year(yr)
|
||||
|
||||
/* number of centuries since 1700, not inclusive */
|
||||
#define centuries_since_1700(yr) \
|
||||
@@ -64,12 +62,12 @@ static int is_leap_year(int year)
|
||||
#define leap_years_since_year_1(yr) \
|
||||
((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
|
||||
|
||||
static void center (char *, int, int);
|
||||
static void day_array (int, int, int *);
|
||||
static void trim_trailing_spaces_and_print (char *);
|
||||
static void center(char *, unsigned, unsigned);
|
||||
static void day_array(unsigned, unsigned, unsigned *);
|
||||
static void trim_trailing_spaces_and_print(char *);
|
||||
|
||||
static void blank_string(char *buf, size_t buflen);
|
||||
static char *build_row(char *p, int *dp);
|
||||
static char *build_row(char *p, unsigned *dp);
|
||||
|
||||
#define DAY_LEN 3 /* 3 spaces per day */
|
||||
#define J_DAY_LEN (DAY_LEN + 1)
|
||||
@@ -77,25 +75,24 @@ 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) MAIN_EXTERNALLY_VISIBLE;
|
||||
int cal_main(int argc, char **argv)
|
||||
{
|
||||
struct tm *local_time;
|
||||
struct tm zero_tm;
|
||||
time_t now;
|
||||
int month, year, flags, i;
|
||||
unsigned month, year, flags, i;
|
||||
char *month_names[12];
|
||||
char day_headings[28]; /* 28 for julian, 21 for nonjulian */
|
||||
char buf[40];
|
||||
|
||||
flags = getopt32(argc, argv, "jy");
|
||||
|
||||
flags = getopt32(argv, "jy");
|
||||
julian = flags & 1;
|
||||
|
||||
argv += optind;
|
||||
|
||||
month = 0;
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
|
||||
if ((argc -= optind) > 2) {
|
||||
if (argc > 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
@@ -108,12 +105,12 @@ int cal_main(int argc, char **argv)
|
||||
}
|
||||
} else {
|
||||
if (argc == 2) {
|
||||
month = xatoul_range(*argv++, 1, 12);
|
||||
month = xatou_range(*argv++, 1, 12);
|
||||
}
|
||||
year = xatoul_range(*argv, 1, 9999);
|
||||
year = xatou_range(*argv, 1, 9999);
|
||||
}
|
||||
|
||||
blank_string(day_headings, sizeof(day_headings) - 7 + 7*julian);
|
||||
blank_string(day_headings, sizeof(day_headings) - 7 + 7*julian);
|
||||
|
||||
i = 0;
|
||||
do {
|
||||
@@ -129,8 +126,8 @@ int cal_main(int argc, char **argv)
|
||||
} while (++i < 12);
|
||||
|
||||
if (month) {
|
||||
int row, len, days[MAXDAYS];
|
||||
int *dp = days;
|
||||
unsigned row, len, days[MAXDAYS];
|
||||
unsigned *dp = days;
|
||||
char lineout[30];
|
||||
|
||||
day_array(month, year, dp);
|
||||
@@ -144,8 +141,8 @@ int cal_main(int argc, char **argv)
|
||||
trim_trailing_spaces_and_print(lineout);
|
||||
}
|
||||
} else {
|
||||
int row, which_cal, week_len, days[12][MAXDAYS];
|
||||
int *dp;
|
||||
unsigned row, which_cal, week_len, days[12][MAXDAYS];
|
||||
unsigned *dp;
|
||||
char lineout[80];
|
||||
|
||||
sprintf(lineout, "%d", year);
|
||||
@@ -170,7 +167,7 @@ int cal_main(int argc, char **argv)
|
||||
if (!julian) {
|
||||
printf("%*s%s", HEAD_SEP, "", day_headings);
|
||||
}
|
||||
putchar('\n');
|
||||
bb_putchar('\n');
|
||||
for (row = 0; row < (6*7); row += 7) {
|
||||
for (which_cal = 0; which_cal < 3-julian; which_cal++) {
|
||||
dp = days[month + which_cal] + row;
|
||||
@@ -192,19 +189,21 @@ int cal_main(int argc, char **argv)
|
||||
* out end to end. You would have 42 numbers or spaces. This routine
|
||||
* builds that array for any month from Jan. 1 through Dec. 9999.
|
||||
*/
|
||||
static void day_array(int month, int year, int *days)
|
||||
static void day_array(unsigned month, unsigned year, unsigned *days)
|
||||
{
|
||||
long temp;
|
||||
int i;
|
||||
int j_offset;
|
||||
int day, dw, dm;
|
||||
unsigned long temp;
|
||||
unsigned i;
|
||||
unsigned day, dw, dm;
|
||||
|
||||
memset(days, SPACE, MAXDAYS * sizeof(int));
|
||||
|
||||
if ((month == 9) && (year == 1752)) {
|
||||
/* Assumes the Gregorian reformation eliminates
|
||||
* 3 Sep. 1752 through 13 Sep. 1752.
|
||||
*/
|
||||
unsigned j_offset = julian * 244;
|
||||
size_t oday = 0;
|
||||
|
||||
j_offset = julian * 244;
|
||||
do {
|
||||
days[oday+2] = sep1752[oday] + j_offset;
|
||||
} while (++oday < sizeof(sep1752));
|
||||
@@ -213,7 +212,7 @@ static void day_array(int month, int year, int *days)
|
||||
}
|
||||
|
||||
/* day_in_year
|
||||
* return the 1 based day number within the year
|
||||
* return the 1 based day number within the year
|
||||
*/
|
||||
day = 1;
|
||||
if ((month > 2) && leap_year(year)) {
|
||||
@@ -226,17 +225,15 @@ static void day_array(int month, int year, int *days)
|
||||
}
|
||||
|
||||
/* day_in_week
|
||||
* return the 0 based day number for any date from 1 Jan. 1 to
|
||||
* 31 Dec. 9999. Assumes the Gregorian reformation eliminates
|
||||
* 3 Sep. 1752 through 13 Sep. 1752. Returns Thursday for all
|
||||
* missing days.
|
||||
* return the 0 based day number for any date from 1 Jan. 1 to
|
||||
* 31 Dec. 9999. Assumes the Gregorian reformation eliminates
|
||||
* 3 Sep. 1752 through 13 Sep. 1752. Returns Thursday for all
|
||||
* missing days.
|
||||
*/
|
||||
dw = THURSDAY;
|
||||
temp = (long)(year - 1) * 365 + leap_years_since_year_1(year - 1)
|
||||
+ day;
|
||||
temp = (long)(year - 1) * 365 + leap_years_since_year_1(year - 1) + day;
|
||||
if (temp < FIRST_MISSING_DAY) {
|
||||
dw = ((temp - 1 + SATURDAY) % 7);
|
||||
} else if (temp >= (FIRST_MISSING_DAY + NUMBER_MISSING_DAYS)) {
|
||||
} else {
|
||||
dw = (((temp - 1 + SATURDAY) - NUMBER_MISSING_DAYS) % 7);
|
||||
}
|
||||
|
||||
@@ -249,10 +246,9 @@ static void day_array(int month, int year, int *days)
|
||||
++dm;
|
||||
}
|
||||
|
||||
while (dm) {
|
||||
do {
|
||||
days[dw++] = day++;
|
||||
--dm;
|
||||
}
|
||||
} while (--dm);
|
||||
}
|
||||
|
||||
static void trim_trailing_spaces_and_print(char *s)
|
||||
@@ -262,7 +258,7 @@ static void trim_trailing_spaces_and_print(char *s)
|
||||
while (*p) {
|
||||
++p;
|
||||
}
|
||||
while (p > s) {
|
||||
while (p != s) {
|
||||
--p;
|
||||
if (!(isspace)(*p)) { /* We want the function... not the inline. */
|
||||
p[1] = '\0';
|
||||
@@ -273,9 +269,9 @@ static void trim_trailing_spaces_and_print(char *s)
|
||||
puts(s);
|
||||
}
|
||||
|
||||
static void center(char *str, int len, int separate)
|
||||
static void center(char *str, unsigned len, unsigned separate)
|
||||
{
|
||||
int n = strlen(str);
|
||||
unsigned n = strlen(str);
|
||||
len -= n;
|
||||
printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
|
||||
}
|
||||
@@ -286,15 +282,16 @@ static void blank_string(char *buf, size_t buflen)
|
||||
buf[buflen-1] = '\0';
|
||||
}
|
||||
|
||||
static char *build_row(char *p, int *dp)
|
||||
static char *build_row(char *p, unsigned *dp)
|
||||
{
|
||||
int col, val, day;
|
||||
unsigned col, val, day;
|
||||
|
||||
memset(p, ' ', (julian + DAY_LEN) * 7);
|
||||
|
||||
col = 0;
|
||||
do {
|
||||
if ((day = *dp++) != SPACE) {
|
||||
day = *dp++;
|
||||
if (day != SPACE) {
|
||||
if (julian) {
|
||||
++p;
|
||||
if (day >= 100) {
|
||||
@@ -303,7 +300,8 @@ static char *build_row(char *p, int *dp)
|
||||
day %= 100;
|
||||
}
|
||||
}
|
||||
if ((val = day / 10) > 0) {
|
||||
val = day / 10;
|
||||
if (val > 0) {
|
||||
*p = val + '0';
|
||||
}
|
||||
*++p = day % 10 + '0';
|
||||
@@ -347,5 +345,3 @@ static char *build_row(char *p, int *dp)
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
+19
-9
@@ -10,21 +10,30 @@
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
|
||||
int bb_cat(char **argv)
|
||||
{
|
||||
static char *const argv_dash[] = { "-", NULL };
|
||||
FILE *f;
|
||||
static const char *const argv_dash[] = { "-", NULL };
|
||||
|
||||
int fd;
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
if (!*argv) argv = (char**) &argv_dash;
|
||||
if (!*argv)
|
||||
argv = (char**) &argv_dash;
|
||||
|
||||
do {
|
||||
f = fopen_or_warn_stdin(*argv);
|
||||
if (f) {
|
||||
off_t r = bb_copyfd_eof(fileno(f), STDOUT_FILENO);
|
||||
fclose_if_not_stdin(f);
|
||||
fd = STDIN_FILENO;
|
||||
if (!LONE_DASH(*argv))
|
||||
fd = open_or_warn(*argv, O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
/* This is not an xfunc - never exits */
|
||||
off_t r = bb_copyfd_eof(fd, STDOUT_FILENO);
|
||||
if (fd != STDIN_FILENO)
|
||||
close(fd);
|
||||
if (r >= 0)
|
||||
continue;
|
||||
}
|
||||
@@ -34,9 +43,10 @@ int bb_cat(char **argv)
|
||||
return retval;
|
||||
}
|
||||
|
||||
int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int cat_main(int argc, char **argv)
|
||||
{
|
||||
getopt32(argc, argv, "u");
|
||||
getopt32(argv, "u");
|
||||
argv += optind;
|
||||
return bb_cat(argv);
|
||||
}
|
||||
+25
-15
@@ -10,55 +10,65 @@
|
||||
/* See "Cat -v considered harmful" at
|
||||
* http://cm.bell-labs.com/cm/cs/doc/84/kp.ps.gz */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int catv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int catv_main(int argc, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS, fd;
|
||||
int retval = EXIT_SUCCESS;
|
||||
int fd;
|
||||
unsigned flags;
|
||||
|
||||
flags = getopt32(argc, argv, "etv");
|
||||
flags = getopt32(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;
|
||||
|
||||
/* Read from stdin if there's nothing else to do. */
|
||||
fd = 0;
|
||||
if (!argv[0]) {
|
||||
argv--;
|
||||
goto jump_in;
|
||||
}
|
||||
do {
|
||||
/* Read from stdin if there's nothing else to do. */
|
||||
fd = 0;
|
||||
if (*argv && 0 > (fd = xopen(*argv, O_RDONLY)))
|
||||
fd = open_or_warn(*argv, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
retval = EXIT_FAILURE;
|
||||
else for (;;) {
|
||||
continue;
|
||||
}
|
||||
jump_in:
|
||||
for (;;) {
|
||||
int i, res;
|
||||
|
||||
res = read(fd, bb_common_bufsiz1, sizeof(bb_common_bufsiz1));
|
||||
#define read_buf bb_common_bufsiz1
|
||||
res = read(fd, read_buf, COMMON_BUFSIZE);
|
||||
if (res < 0)
|
||||
retval = EXIT_FAILURE;
|
||||
if (res < 1)
|
||||
break;
|
||||
for (i = 0; i < res; i++) {
|
||||
char c = bb_common_bufsiz1[i];
|
||||
unsigned char c = read_buf[i];
|
||||
|
||||
if (c > 126 && (flags & CATV_OPT_v)) {
|
||||
if (c == 127) {
|
||||
printf("^?");
|
||||
continue;
|
||||
} else {
|
||||
printf("M-");
|
||||
c -= 128;
|
||||
}
|
||||
printf("M-");
|
||||
c -= 128;
|
||||
}
|
||||
if (c < 32) {
|
||||
if (c == 10) {
|
||||
if (flags & CATV_OPT_e)
|
||||
putchar('$');
|
||||
bb_putchar('$');
|
||||
} else if (flags & (c==9 ? CATV_OPT_t : CATV_OPT_v)) {
|
||||
printf("^%c", c+'@');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
putchar(c);
|
||||
bb_putchar(c);
|
||||
}
|
||||
}
|
||||
if (ENABLE_FEATURE_CLEAN_UP && fd)
|
||||
|
||||
+5
-4
@@ -7,15 +7,16 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 defects - unsupported options -H, -L, and -P. */
|
||||
/* BB_AUDIT SUSv3 defects - none? */
|
||||
/* BB_AUDIT GNU defects - unsupported long options. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* FIXME - move to .h */
|
||||
extern int chown_main(int argc, char **argv);
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
int chgrp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int chgrp_main(int argc, char **argv)
|
||||
{
|
||||
/* "chgrp [opts] abc file(s)" == "chown [opts] :abc file(s)" */
|
||||
|
||||
+17
-14
@@ -14,7 +14,10 @@
|
||||
/* BB_AUDIT GNU defects - unsupported long options. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chmod.html */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
#define OPT_RECURSE (option_mask32 & 1)
|
||||
#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 2) SKIP_DESKTOP(0))
|
||||
@@ -31,7 +34,7 @@
|
||||
* symbolic links encountered during recursive directory traversals.
|
||||
*/
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk, int depth)
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* param, int depth)
|
||||
{
|
||||
mode_t newmode;
|
||||
|
||||
@@ -46,8 +49,8 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk, in
|
||||
}
|
||||
newmode = statbuf->st_mode;
|
||||
|
||||
if (!bb_parse_mode((char *)junk, &newmode))
|
||||
bb_error_msg_and_die("invalid mode: %s", (char *)junk);
|
||||
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
|
||||
@@ -60,10 +63,11 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* junk, in
|
||||
}
|
||||
err:
|
||||
if (!OPT_QUIET)
|
||||
bb_perror_msg("%s", fileName);
|
||||
bb_simple_perror_msg(fileName);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int chmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int chmod_main(int argc, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
@@ -89,7 +93,7 @@ int chmod_main(int argc, char **argv)
|
||||
|
||||
/* Parse options */
|
||||
opt_complementary = "-2";
|
||||
getopt32(argc, argv, ("-"OPT_STR) + 1); /* Reuse string */
|
||||
getopt32(argv, ("-"OPT_STR) + 1); /* Reuse string */
|
||||
argv += optind;
|
||||
|
||||
/* Restore option-like mode if needed */
|
||||
@@ -100,8 +104,6 @@ int chmod_main(int argc, char **argv)
|
||||
do {
|
||||
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
|
||||
@@ -117,10 +119,12 @@ int chmod_main(int argc, char **argv)
|
||||
/*
|
||||
Security: chmod is too important and too subtle.
|
||||
This is a test script (busybox chmod versus coreutils).
|
||||
Run it in empty dir. Probably requires bash.
|
||||
Run it in empty directory.
|
||||
|
||||
#!/bin/sh
|
||||
function create() {
|
||||
t1="/tmp/busybox chmod"
|
||||
t2="/usr/bin/chmod"
|
||||
create() {
|
||||
rm -rf $1; mkdir $1
|
||||
(
|
||||
cd $1 || exit 1
|
||||
@@ -133,17 +137,16 @@ function create() {
|
||||
ln -s ../up dir/up
|
||||
)
|
||||
}
|
||||
function tst() {
|
||||
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
|
||||
mv out.diff out1.diff
|
||||
rm out.diff
|
||||
}
|
||||
t1="/tmp/busybox chmod"
|
||||
t2="/usr/bin/chmod"
|
||||
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"
|
||||
|
||||
+123
-55
@@ -7,93 +7,99 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 defects - unsupported options -H, -L, and -P. */
|
||||
/* BB_AUDIT SUSv3 defects - none? */
|
||||
/* BB_AUDIT GNU defects - unsupported long options. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chown.html */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
|
||||
#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))
|
||||
|
||||
typedef int (*chown_fptr)(const char *, uid_t, gid_t);
|
||||
|
||||
static struct bb_uidgid_t ugid = { -1, -1 };
|
||||
|
||||
static int (*chown_func)(const char *, uid_t, gid_t) = chown;
|
||||
|
||||
#define OPT_RECURSE (option_mask32 & 1)
|
||||
#define OPT_NODEREF (option_mask32 & 2)
|
||||
#define OPT_VERBOSE (USE_DESKTOP(option_mask32 & 4) SKIP_DESKTOP(0))
|
||||
#define OPT_CHANGED (USE_DESKTOP(option_mask32 & 8) SKIP_DESKTOP(0))
|
||||
#define OPT_QUIET (USE_DESKTOP(option_mask32 & 0x10) SKIP_DESKTOP(0))
|
||||
#define OPT_STR ("Rh" USE_DESKTOP("vcf"))
|
||||
|
||||
/* TODO:
|
||||
* -H if a command line argument is a symbolic link to a directory, traverse it
|
||||
* -L traverse every symbolic link to a directory encountered
|
||||
* -P do not traverse any symbolic links (default)
|
||||
*/
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf,
|
||||
void ATTRIBUTE_UNUSED *junk, int depth)
|
||||
void *cf, int depth)
|
||||
{
|
||||
// TODO: -H/-L/-P
|
||||
// if (depth ... && S_ISLNK(statbuf->st_mode)) ....
|
||||
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_func(fileName,
|
||||
(ugid.uid == (uid_t)-1) ? statbuf->st_uid : ugid.uid,
|
||||
(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 != ugid.uid || statbuf->st_gid != ugid.gid))
|
||||
|| (OPT_CHANGED && (statbuf->st_uid != u || statbuf->st_gid != g))
|
||||
) {
|
||||
printf("changed ownership of '%s' to %u:%u\n",
|
||||
fileName, ugid.uid, ugid.gid);
|
||||
fileName, (unsigned)u, (unsigned)g);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
if (!OPT_QUIET)
|
||||
bb_perror_msg("%s", fileName); /* A filename can have % in it... */
|
||||
bb_simple_perror_msg(fileName); /* A filename can have % in it... */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int chown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int chown_main(int argc, char **argv)
|
||||
{
|
||||
char *groupName;
|
||||
int retval = EXIT_SUCCESS;
|
||||
int flags;
|
||||
chown_fptr chown_func;
|
||||
|
||||
opt_complementary = "-2";
|
||||
getopt32(argc, argv, OPT_STR);
|
||||
getopt32(argv, OPT_STR);
|
||||
argv += optind;
|
||||
|
||||
if (OPT_NODEREF) chown_func = lchown;
|
||||
|
||||
/* First, check if there is a group name here */
|
||||
groupName = strchr(*argv, '.'); /* deprecated? */
|
||||
if (!groupName)
|
||||
groupName = strchr(*argv, ':');
|
||||
else
|
||||
*groupName = ':'; /* replace '.' with ':' */
|
||||
|
||||
/* First, try parsing "user[:[group]]" */
|
||||
if (!groupName) { /* "user" */
|
||||
ugid.uid = get_ug_id(*argv, xuname2uid);
|
||||
} else if (groupName == *argv) { /* ":group" */
|
||||
ugid.gid = get_ug_id(groupName + 1, xgroup2gid);
|
||||
} else {
|
||||
if (!groupName[1]) /* "user:" */
|
||||
*groupName = '\0';
|
||||
if (!get_uidgid(&ugid, *argv, 1))
|
||||
bb_error_msg_and_die("unknown user/group %s", *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;
|
||||
}
|
||||
|
||||
flags = ACTION_DEPTHFIRST; /* match coreutils order */
|
||||
if (OPT_RECURSE)
|
||||
flags |= ACTION_RECURSE;
|
||||
if (OPT_TRAVERSE_TOP)
|
||||
flags |= ACTION_FOLLOWLINKS_L0; /* -H/-L: follow links on depth 0 */
|
||||
if (OPT_TRAVERSE)
|
||||
flags |= ACTION_FOLLOWLINKS; /* follow links if -L */
|
||||
|
||||
parse_chown_usergroup_or_die(&ugid, argv[0]);
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
argv++;
|
||||
do {
|
||||
if (!recursive_action(*argv,
|
||||
OPT_RECURSE, // recurse
|
||||
FALSE, // follow links: TODO: -H/-L/-P
|
||||
FALSE, // depth first
|
||||
fileAction, // file action
|
||||
fileAction, // dir action
|
||||
NULL, // user data
|
||||
0) // depth
|
||||
flags, /* flags */
|
||||
fileAction, /* file action */
|
||||
fileAction, /* dir action */
|
||||
chown_func, /* user data */
|
||||
0) /* depth */
|
||||
) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
@@ -101,3 +107,65 @@ int chown_main(int argc, char **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
|
||||
echo "[$1]" >>test1.out
|
||||
echo "[$1]" >>test2.out
|
||||
(cd test1; $t1 $1) >>test1.out 2>&1
|
||||
(cd test2; $t2 $1) >>test2.out 2>&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"
|
||||
>test1.out
|
||||
>test2.out
|
||||
# These match coreutils 6.8:
|
||||
tst_for_each "-v"
|
||||
tst_for_each "-vR"
|
||||
tst_for_each "-vRP"
|
||||
tst_for_each "-vRL"
|
||||
tst_for_each "-vRH"
|
||||
tst_for_each "-vh"
|
||||
tst_for_each "-vhR"
|
||||
tst_for_each "-vhRP"
|
||||
tst_for_each "-vhRL"
|
||||
tst_for_each "-vhRH"
|
||||
# Fix `name' in coreutils output
|
||||
sed 's/`/'"'"'/g' -i test2.out
|
||||
# Compare us with coreutils output
|
||||
diff -u test1.out test2.out
|
||||
|
||||
*/
|
||||
+6
-4
@@ -9,8 +9,9 @@
|
||||
|
||||
/* BB_AUDIT SUSv3 N/A -- Matches GNU behavior. */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "libbb.h"
|
||||
|
||||
int chroot_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
if (argc < 2) {
|
||||
@@ -26,12 +27,13 @@ int chroot_main(int argc, char **argv)
|
||||
++argv;
|
||||
if (argc == 2) {
|
||||
argv -= 2;
|
||||
if (!(*argv = getenv("SHELL"))) {
|
||||
*argv = (char *) DEFAULT_SHELL;
|
||||
argv[0] = getenv("SHELL");
|
||||
if (!argv[0]) {
|
||||
argv[0] = (char *) DEFAULT_SHELL;
|
||||
}
|
||||
argv[1] = (char *) "-i";
|
||||
}
|
||||
|
||||
execvp(*argv, argv);
|
||||
BB_EXECVP(*argv, argv);
|
||||
bb_perror_msg_and_die("cannot execute %s", *argv);
|
||||
}
|
||||
Loaded 100 of 668 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user