Compare commits
1059
Commits
1_9_2
...
1_12_stable
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b8f810d38 | ||
|
|
9343da45d3 | ||
|
|
84641942e5 | ||
|
|
bacaff6e54 | ||
|
|
261cf4784f | ||
|
|
e417be6697 | ||
|
|
b9c262b029 | ||
|
|
99b4083647 | ||
|
|
b9f5d59893 | ||
|
|
f31c3b677d | ||
|
|
4301616b27 | ||
|
|
1c45a505eb | ||
|
|
6c4eb44113 | ||
|
|
625ed8e027 | ||
|
|
c77e843c09 | ||
|
|
d7cc2e601d | ||
|
|
c8d02aa959 | ||
|
|
eb084779d7 | ||
|
|
34c73c499b | ||
|
|
8334db13c3 | ||
|
|
69ed30928e | ||
|
|
ec7e7aec8a | ||
|
|
c80191c1d9 | ||
|
|
11152e30e3 | ||
|
|
cd785fb716 | ||
|
|
ee777c4e5f | ||
|
|
8d07560eef | ||
|
|
63e49fa56f | ||
|
|
69f4f9a6f4 | ||
|
|
3fd15e197e | ||
|
|
fb5902ca5c | ||
|
|
1dbc643dd3 | ||
|
|
8e80411151 | ||
|
|
728161b556 | ||
|
|
9ddc0045ec | ||
|
|
2afd5ab62c | ||
|
|
e0143a1aad | ||
|
|
db29f5e73e | ||
|
|
e6ce824edd | ||
|
|
ec73d30322 | ||
|
|
0e7f28d674 | ||
|
|
e2a09de415 | ||
|
|
22b0bd85fd | ||
|
|
540baf646a | ||
|
|
e9ad84dfd4 | ||
|
|
9b44613202 | ||
|
|
35d8c47987 | ||
|
|
82ad032e26 | ||
|
|
855ff6f503 | ||
|
|
5db861a9eb | ||
|
|
27842288b3 | ||
|
|
2b576b8e76 | ||
|
|
c8bec9a085 | ||
|
|
b2dc913527 | ||
|
|
7ce47e698e | ||
|
|
c45b53940a | ||
|
|
cc08ad26fe | ||
|
|
1e28f6171f | ||
|
|
cfe2936a73 | ||
|
|
9ef1a5ddc1 | ||
|
|
e1fa817995 | ||
|
|
d498131168 | ||
|
|
f173607520 | ||
|
|
fbeeb328b8 | ||
|
|
20be63fe71 | ||
|
|
b357149867 | ||
|
|
c90e1be01b | ||
|
|
4f504a9e57 | ||
|
|
87a8655f46 | ||
|
|
ff29b4fc42 | ||
|
|
4554b721ad | ||
|
|
45cb9f9581 | ||
|
|
fcf37c3183 | ||
|
|
d91afa33fd | ||
|
|
dadfb4975b | ||
|
|
e1ee48e0fd | ||
|
|
2f86d13dff | ||
|
|
043d15da31 | ||
|
|
918a34b9e0 | ||
|
|
6a2d40f239 | ||
|
|
bcb25537d0 | ||
|
|
cf22c89f9a | ||
|
|
12acec5ad4 | ||
|
|
5e052cab17 | ||
|
|
38c89210d6 | ||
|
|
be709c24d4 | ||
|
|
8d523cbcd7 | ||
|
|
09f5ecfa47 | ||
|
|
2c7a1fd6d4 | ||
|
|
cf8b1ef845 | ||
|
|
6e69e4237d | ||
|
|
94d03f0da0 | ||
|
|
c24033eebe | ||
|
|
084266ed52 | ||
|
|
8895c2073e | ||
|
|
5e40070d38 | ||
|
|
df96df9c7c | ||
|
|
48a9971bd4 | ||
|
|
c2dcb7cf63 | ||
|
|
8dbea7dbb1 | ||
|
|
160e6fa53a | ||
|
|
5c13270359 | ||
|
|
87d5fd984e | ||
|
|
4e19a9c81a | ||
|
|
2b2e267b43 | ||
|
|
6a0ad25061 | ||
|
|
0f99d49ae6 | ||
|
|
22f7414843 | ||
|
|
5a867317bb | ||
|
|
6fbb43bc3c | ||
|
|
6514c5e35c | ||
|
|
8d924ecf38 | ||
|
|
0b76964ae1 | ||
|
|
2dc240c0d6 | ||
|
|
49a5eba9ae | ||
|
|
040e32f84c | ||
|
|
f54e62a3f2 | ||
|
|
41660c5b2d | ||
|
|
0f293b96dc | ||
|
|
68a192c007 | ||
|
|
c445758708 | ||
|
|
e99a92dc2f | ||
|
|
3e8669f359 | ||
|
|
08d120e6e1 | ||
|
|
9e3a540b1b | ||
|
|
a5254032f5 | ||
|
|
b62bd7b261 | ||
|
|
5415c856ea | ||
|
|
b74a2dba57 | ||
|
|
1d4cd606a1 | ||
|
|
d73cbd31a2 | ||
|
|
a53de7f7c2 | ||
|
|
e1e5174942 | ||
|
|
5259361957 | ||
|
|
ef9876a40e | ||
|
|
0328b40aee | ||
|
|
ad2fa65fc0 | ||
|
|
1101d1c980 | ||
|
|
84c8daa11f | ||
|
|
395410b748 | ||
|
|
7ae1cc16b4 | ||
|
|
2b68c8f744 | ||
|
|
eb7512984a | ||
|
|
9b366f4136 | ||
|
|
a34f1ed737 | ||
|
|
1e8034e614 | ||
|
|
09aaf78ad5 | ||
|
|
adc772a5f2 | ||
|
|
b9bbc40f64 | ||
|
|
4a717e0c19 | ||
|
|
dcb3fcb042 | ||
|
|
c29684afd6 | ||
|
|
2e157ddf9e | ||
|
|
bd28f6bf7f | ||
|
|
5f116629d8 | ||
|
|
f19817ddc2 | ||
|
|
a48656b441 | ||
|
|
1a715e487d | ||
|
|
7b54dc788c | ||
|
|
7354244c4a | ||
|
|
3b3ca113ed | ||
|
|
18875bf772 | ||
|
|
bc06fb27d2 | ||
|
|
a474b68991 | ||
|
|
02a1c6a7c3 | ||
|
|
54d50a0b47 | ||
|
|
679212836a | ||
|
|
0f683f818c | ||
|
|
416914fc61 | ||
|
|
627052e75d | ||
|
|
c185e290ee | ||
|
|
fb1642f2ca | ||
|
|
c01340fe26 | ||
|
|
38e54f1c13 | ||
|
|
4d0cd28947 | ||
|
|
d6817f5d8b | ||
|
|
83cea0ef04 | ||
|
|
55f7912dda | ||
|
|
8ddb6410ed | ||
|
|
bd9874db74 | ||
|
|
018bee6afb | ||
|
|
97faf531c8 | ||
|
|
5e476bab9c | ||
|
|
e559e0a757 | ||
|
|
0ed090e184 | ||
|
|
2132e02213 | ||
|
|
bb13079c8e | ||
|
|
51f1b6c0e0 | ||
|
|
4b8171cd7a | ||
|
|
09ce45fd10 | ||
|
|
757361f9f5 | ||
|
|
395ae45216 | ||
|
|
17f02e79f4 | ||
|
|
3177ba0852 | ||
|
|
ad6d6ffcdc | ||
|
|
52ec4b98d5 | ||
|
|
a8374a1916 | ||
|
|
adbb73bda7 | ||
|
|
34e8f6a7ac | ||
|
|
13afb2acda | ||
|
|
a87045ce37 | ||
|
|
d9860487e0 | ||
|
|
6b7971805c | ||
|
|
a46dd89e94 | ||
|
|
39acf45335 | ||
|
|
e7067e38ea | ||
|
|
ee1b3b1042 | ||
|
|
e18d21dda4 | ||
|
|
29ec0b94a4 | ||
|
|
2b407b12be | ||
|
|
abe49fa54f | ||
|
|
94884eb486 | ||
|
|
0e52541917 | ||
|
|
88643a86d0 | ||
|
|
ff814f821a | ||
|
|
86090e2599 | ||
|
|
3e8fd18037 | ||
|
|
0381d422d9 | ||
|
|
b6052724ff | ||
|
|
0e2c93fc0b | ||
|
|
7f950a93ff | ||
|
|
784369987f | ||
|
|
7621ac20f2 | ||
|
|
4131d855a1 | ||
|
|
fc5e80651f | ||
|
|
9764d6908a | ||
|
|
6bdff08e6c | ||
|
|
7c053262af | ||
|
|
d38d38eed3 | ||
|
|
96c45b0e0b | ||
|
|
5606b1c4f3 | ||
|
|
24a131ea4d | ||
|
|
f62ab2d774 | ||
|
|
dbef1173b0 | ||
|
|
8b393e5999 | ||
|
|
deeed59de0 | ||
|
|
493829207c | ||
|
|
5d62462a8c | ||
|
|
580ce2d138 | ||
|
|
67075bb95f | ||
|
|
58f59a25ee | ||
|
|
cee0dfcc6a | ||
|
|
733e3fbc2f | ||
|
|
d48e81f0cd | ||
|
|
ff182a3d68 | ||
|
|
afdcd12ed7 | ||
|
|
a60f84ebf0 | ||
|
|
f6efccc065 | ||
|
|
fec8b42317 | ||
|
|
4cbffc0f34 | ||
|
|
9835d47acc | ||
|
|
a8a3b497fc | ||
|
|
671691cf21 | ||
|
|
8ae5b28b4b | ||
|
|
f8e8783a92 | ||
|
|
e0a7fc54eb | ||
|
|
d4f72438e4 | ||
|
|
fa0b56db76 | ||
|
|
82604e9730 | ||
|
|
b111917972 | ||
|
|
58d60c3333 | ||
|
|
49b5c516b5 | ||
|
|
3da5572bfa | ||
|
|
148f67af9d | ||
|
|
7987a1844b | ||
|
|
3bb2bbd684 | ||
|
|
0a65692048 | ||
|
|
c94d3564c2 | ||
|
|
bc2fd37227 | ||
|
|
0db2c2eb71 | ||
|
|
270d5d75f1 | ||
|
|
6eaf0a9883 | ||
|
|
ce13b76002 | ||
|
|
540ab7097c | ||
|
|
259c9a6e90 | ||
|
|
befd5eaec8 | ||
|
|
333aa0c04a | ||
|
|
6ea75e2f5d | ||
|
|
78ff8197cc | ||
|
|
86d88c0990 | ||
|
|
a60936da06 | ||
|
|
9579d87be4 | ||
|
|
dbcf3275ec | ||
|
|
ed90bdabb4 | ||
|
|
b75fe798bb | ||
|
|
ce02b157be | ||
|
|
55da0be405 | ||
|
|
3dee8e2bac | ||
|
|
bbd55c9ec7 | ||
|
|
2bbdda09df | ||
|
|
ac2b50ebea | ||
|
|
d699544205 | ||
|
|
42b8daf88a | ||
|
|
defc1ea340 | ||
|
|
26bc57d8b2 | ||
|
|
448d30ee17 | ||
|
|
843cbd54d1 | ||
|
|
9092f754bd | ||
|
|
5fb79535ee | ||
|
|
f5d8c90d73 | ||
|
|
2649f215ae | ||
|
|
a04cc47f1c | ||
|
|
6e18f9a6ea | ||
|
|
21278dff70 | ||
|
|
f4cfa1bd5a | ||
|
|
f54256ec6f | ||
|
|
dabe36e4a0 | ||
|
|
e06f61d273 | ||
|
|
7049ff8696 | ||
|
|
f26e3d2e41 | ||
|
|
d0cc3f4ade | ||
|
|
fe733a9744 | ||
|
|
70685bd022 | ||
|
|
5ec6132c98 | ||
|
|
003f9fb213 | ||
|
|
cc3f20b9bd | ||
|
|
211b59be43 | ||
|
|
2f5d0cd511 | ||
|
|
2b75a94118 | ||
|
|
ef527f50e6 | ||
|
|
a80d0e4bf7 | ||
|
|
8124a96c34 | ||
|
|
e3eae0d445 | ||
|
|
50b5cac59f | ||
|
|
2a210e5df2 | ||
|
|
b07a496229 | ||
|
|
c87339d584 | ||
|
|
d235f58ac2 | ||
|
|
20273138fc | ||
|
|
3387538bbe | ||
|
|
b175946ba4 | ||
|
|
b67004b2ae | ||
|
|
dd9c072846 | ||
|
|
1363f0df15 | ||
|
|
d5736c5607 | ||
|
|
9cd4c76b50 | ||
|
|
1ba323e5b6 | ||
|
|
324a3fdf87 | ||
|
|
4a689e9b49 | ||
|
|
55789c6646 | ||
|
|
ab876cd107 | ||
|
|
985de15bf3 | ||
|
|
c1c63b622d | ||
|
|
4954d47ab0 | ||
|
|
619b87dfa5 | ||
|
|
16c2fea280 | ||
|
|
13436ea0dd | ||
|
|
6eaf8deddd | ||
|
|
b6926109b7 | ||
|
|
988339259f | ||
|
|
30c9cc5b17 | ||
|
|
c7985b76c5 | ||
|
|
b61e13d247 | ||
|
|
ccce59d562 | ||
|
|
32d8423e63 | ||
|
|
82dfec3e4e | ||
|
|
31e1286365 | ||
|
|
8474cd38f3 | ||
|
|
f45c4f41b7 | ||
|
|
57c899e4c2 | ||
|
|
1dba30f2de | ||
|
|
f54a088429 | ||
|
|
b4c5bf615e | ||
|
|
5703c22a51 | ||
|
|
ff7cd6f925 | ||
|
|
f716a6da9a | ||
|
|
5cdc247ba4 | ||
|
|
04087c6bbd | ||
|
|
d50dda8c35 | ||
|
|
873b895d50 | ||
|
|
e235285c3a | ||
|
|
7a762f9dbf | ||
|
|
f8d01d3f66 | ||
|
|
dd316dd283 | ||
|
|
a84420062a | ||
|
|
6108dc4df6 | ||
|
|
29038c06d6 | ||
|
|
2659c63213 | ||
|
|
a1767a1f5d | ||
|
|
21765fa063 | ||
|
|
76f812803b | ||
|
|
aa9cd89c67 | ||
|
|
7504f2f5d2 | ||
|
|
e773be0428 | ||
|
|
eee4f55a65 | ||
|
|
c7497ea31b | ||
|
|
25b463079d | ||
|
|
0eb406caa8 | ||
|
|
bd8390a872 | ||
|
|
fdddab0c61 | ||
|
|
4ea83bf562 | ||
|
|
9de4622055 | ||
|
|
7e3d33b6ce | ||
|
|
76db5adbf7 | ||
|
|
bd1aeeb850 | ||
|
|
87f40bac14 | ||
|
|
43360e5178 | ||
|
|
2e76c3f901 | ||
|
|
895bea2303 | ||
|
|
46ccdcb96e | ||
|
|
7b4f3f13d3 | ||
|
|
76d50418b3 | ||
|
|
3fe4f986a0 | ||
|
|
98a6f56d49 | ||
|
|
598bb732e8 | ||
|
|
2d0529c9bc | ||
|
|
ed9d621cf4 | ||
|
|
f2cccbce37 | ||
|
|
b8c9354114 | ||
|
|
048897c971 | ||
|
|
52a8d975da | ||
|
|
b597564e4c | ||
|
|
09c0a749a1 | ||
|
|
c8fa04f9b1 | ||
|
|
0876822ded | ||
|
|
dd6f570fa3 | ||
|
|
53354ac47d | ||
|
|
f0d6c25586 | ||
|
|
c0cd9f29d2 | ||
|
|
a05c0716c2 | ||
|
|
401de648a7 | ||
|
|
7bdf0c82da | ||
|
|
797c96d8ce | ||
|
|
593f8baeb0 | ||
|
|
9b6f4aa8e8 | ||
|
|
f592aa36f3 | ||
|
|
f0d6068086 | ||
|
|
c05b1684a0 | ||
|
|
66d56c565e | ||
|
|
50120dab4e | ||
|
|
7d60fc1c0a | ||
|
|
bedfabd500 | ||
|
|
b6fe10091d | ||
|
|
e7860e358e | ||
|
|
1a9bbfb96f | ||
|
|
1da86d2f40 | ||
|
|
1e93f3c585 | ||
|
|
3b162ecdf6 | ||
|
|
630a7f75e8 | ||
|
|
85571d8d01 | ||
|
|
6075b2aee0 | ||
|
|
c2741e1f72 | ||
|
|
ef729dd90c | ||
|
|
d42816763f | ||
|
|
beac1bd58e | ||
|
|
9af7aba579 | ||
|
|
b8e653bfbf | ||
|
|
cd2663f15e | ||
|
|
d78920675f | ||
|
|
62d8503589 | ||
|
|
e0fd13e901 | ||
|
|
a76669c595 | ||
|
|
f4e6bd0bf3 | ||
|
|
1d1bba4e99 | ||
|
|
d12fcc20da | ||
|
|
3e57adb731 | ||
|
|
8f74094548 | ||
|
|
447bd66837 | ||
|
|
f9a0784144 | ||
|
|
db508e3b82 | ||
|
|
cd9d4c85a4 | ||
|
|
634b022108 | ||
|
|
17282292c2 | ||
|
|
5de8a13b08 | ||
|
|
ea9f7a6a7f | ||
|
|
417e240abb | ||
|
|
10be1a787f | ||
|
|
c21d9c7290 | ||
|
|
1510216a55 | ||
|
|
55fb9da5b8 | ||
|
|
b85fb693c1 | ||
|
|
4fec346966 | ||
|
|
9cf0f62b15 | ||
|
|
9474830006 | ||
|
|
1ea2568469 | ||
|
|
7a5f494cab | ||
|
|
c47e8978fe | ||
|
|
fc9e108032 | ||
|
|
6bb55cfb99 | ||
|
|
cf18010ca9 | ||
|
|
dc5d7fec35 | ||
|
|
423465cd5e | ||
|
|
55e547eb6f | ||
|
|
a0e17f7df6 | ||
|
|
b267ed95bc | ||
|
|
4830fc565a | ||
|
|
af6cca50af | ||
|
|
30f892a0ee | ||
|
|
69dc325397 | ||
|
|
bd23fbbd0a | ||
|
|
8e2c9e1518 | ||
|
|
e94a87134d | ||
|
|
ff9234948e | ||
|
|
cf575ca856 | ||
|
|
61082ec1cc | ||
|
|
69d5ba2f95 | ||
|
|
a959a2abdd | ||
|
|
4801441e9a | ||
|
|
e9b76e1f1e | ||
|
|
ae84b11467 | ||
|
|
dfd8282464 | ||
|
|
7b3863986d | ||
|
|
b22a8059cb | ||
|
|
869d3d318f | ||
|
|
7bd8d8fd26 | ||
|
|
49bdf28c32 | ||
|
|
6de8994440 | ||
|
|
19903f0d44 | ||
|
|
b23429198e | ||
|
|
54b90b5988 | ||
|
|
38100a4ebe | ||
|
|
0953336951 | ||
|
|
eaad910655 | ||
|
|
f02efd11c9 | ||
|
|
5e25ddb7d3 | ||
|
|
636a1f85e8 | ||
|
|
cb83abd7b6 | ||
|
|
3576bed2f9 | ||
|
|
ae4342ca3e | ||
|
|
ee56e013cf | ||
|
|
5599502a55 | ||
|
|
e125a683a7 | ||
|
|
faf334aeb8 | ||
|
|
9ddc8d54d1 | ||
|
|
b6c4855f1d | ||
|
|
29eb3599e4 | ||
|
|
d04e1fc309 | ||
|
|
2794c9bb93 | ||
|
|
85e015c7c8 | ||
|
|
29952d79fc | ||
|
|
51a06c07da | ||
|
|
b8635e28b5 | ||
|
|
dff6190112 | ||
|
|
f3b778a4dc | ||
|
|
825968f92c | ||
|
|
1b23773e26 | ||
|
|
9c3052aab6 | ||
|
|
81e97a1380 | ||
|
|
e251337a4d | ||
|
|
6b06cb80be | ||
|
|
43d5d429fd | ||
|
|
b81f97bbd2 | ||
|
|
9305cdddbf | ||
|
|
77ad97f199 | ||
|
|
c4f12f59cc | ||
|
|
023dc6798e | ||
|
|
98636eb08c | ||
|
|
50dbed95fb | ||
|
|
b89e2027d9 | ||
|
|
f3aa4a8ec5 | ||
|
|
4579e9c1c8 | ||
|
|
4b04f543a1 | ||
|
|
35d1683ce9 | ||
|
|
2af860464e | ||
|
|
6253880450 | ||
|
|
6e38d52120 | ||
|
|
647c20cfc2 | ||
|
|
6bf05cf1ff | ||
|
|
b153ace939 | ||
|
|
06ebc16461 | ||
|
|
dddfaff363 | ||
|
|
380bcfc9f7 | ||
|
|
c8f7a97f89 | ||
|
|
8abae88410 | ||
|
|
96b99b860c | ||
|
|
687a26fe0d | ||
|
|
4e79049e10 | ||
|
|
32dcc53b71 | ||
|
|
6da9b00f4f | ||
|
|
2dea01ca11 | ||
|
|
57be4abcf8 | ||
|
|
e061226668 | ||
|
|
812870a2e7 | ||
|
|
dcbd350ccf | ||
|
|
a2dcb50175 | ||
|
|
3c07e4b877 | ||
|
|
b34266b42b | ||
|
|
a0c103a30a | ||
|
|
05efca90d2 | ||
|
|
d93400bffb | ||
|
|
c450379ff0 | ||
|
|
10f6fb1d46 | ||
|
|
e4ed64067e | ||
|
|
e6520f0532 | ||
|
|
c0431ed455 | ||
|
|
4809a9f78e | ||
|
|
7dff4333d6 | ||
|
|
5d0f4aaa99 | ||
|
|
92a6f878e9 | ||
|
|
64d5bfda1a | ||
|
|
16afa38a7b | ||
|
|
b140eddc41 | ||
|
|
2c84495184 | ||
|
|
44f0821259 | ||
|
|
95842fbc16 | ||
|
|
a6b3a1f0bf | ||
|
|
4d89a8bd1d | ||
|
|
ad6cab1834 | ||
|
|
c6191e9a0a | ||
|
|
15ce7f5b58 | ||
|
|
019d299f01 | ||
|
|
b520271f65 | ||
|
|
a50a9b0fdf | ||
|
|
765c1c3c31 | ||
|
|
71e3ab327a | ||
|
|
58dc274a7a | ||
|
|
fa5b05ab07 | ||
|
|
ffdcb41fd2 | ||
|
|
9d4a17e0b6 | ||
|
|
be002adb2f | ||
|
|
1f228985b2 | ||
|
|
5d89fbaa2e | ||
|
|
9137341851 | ||
|
|
5a07a1d255 | ||
|
|
a4a93fdf18 | ||
|
|
2d94992235 | ||
|
|
376003bbbe | ||
|
|
5bb2fc2dc1 | ||
|
|
01eaee9309 | ||
|
|
0a1446275d | ||
|
|
fe493479e2 | ||
|
|
25cfe4996e | ||
|
|
5b3adae7e8 | ||
|
|
85d788e491 | ||
|
|
daeddee442 | ||
|
|
f3745ea489 | ||
|
|
d9c51e9fa7 | ||
|
|
6c10657c4a | ||
|
|
5a96c3eab6 | ||
|
|
a4e55ab840 | ||
|
|
33b92f2fdb | ||
|
|
9a7af9fc17 | ||
|
|
d2095fd903 | ||
|
|
1b2d0b2821 | ||
|
|
50d068cb76 | ||
|
|
e96dcb4dcf | ||
|
|
250aa5bb01 | ||
|
|
c033d5196d | ||
|
|
4437d19fb4 | ||
|
|
aca10f852a | ||
|
|
bc1918a7a2 | ||
|
|
3cfebe44c7 | ||
|
|
7089c31d57 | ||
|
|
c7131c3e58 | ||
|
|
b15ebe46fc | ||
|
|
4f98e19382 | ||
|
|
6d1ebecf65 | ||
|
|
24f824edb3 | ||
|
|
ffa4499c9f | ||
|
|
867bd37c7f | ||
|
|
7465dbcf2a | ||
|
|
f78a656f7c | ||
|
|
033424a213 | ||
|
|
9bc80d7062 | ||
|
|
4a9ca13fe7 | ||
|
|
55e06c1edf | ||
|
|
eecd588c53 | ||
|
|
1d690db720 | ||
|
|
3bc7d7df3d | ||
|
|
0f5dfd6b9a | ||
|
|
93b8263652 | ||
|
|
80f647c21c | ||
|
|
119f87be2a | ||
|
|
da616dbfa8 | ||
|
|
37bb6ada96 | ||
|
|
b75a1c3c2a | ||
|
|
fcc6347976 | ||
|
|
b3f39f0cfa | ||
|
|
858ebf130a | ||
|
|
b12b1c87b5 | ||
|
|
79cedcb2c0 | ||
|
|
643dcf00e3 | ||
|
|
ed23adce72 | ||
|
|
6fa1ba3972 | ||
|
|
90c31b3d4b | ||
|
|
278a1c2264 | ||
|
|
ad4da989e3 | ||
|
|
0a38bcf570 | ||
|
|
1af00eda92 | ||
|
|
1a95e3960c | ||
|
|
261f237024 | ||
|
|
7f8f0fafdb | ||
|
|
7b6d9d687d | ||
|
|
a7f4e4bbd8 | ||
|
|
2e4c3c4cc3 | ||
|
|
0edbdd8ac8 | ||
|
|
c59d802a5a | ||
|
|
9895dfdb9a | ||
|
|
9dedf72e71 | ||
|
|
468aea2d88 | ||
|
|
165f5b394f | ||
|
|
d943af058b | ||
|
|
5297809c03 | ||
|
|
1b2058fe98 | ||
|
|
f2f3868e0d | ||
|
|
aa8a601084 | ||
|
|
02f12f53e8 | ||
|
|
cae11b51aa | ||
|
|
4461564c77 | ||
|
|
7cb808e1c5 | ||
|
|
0e7940ae90 | ||
|
|
6c615a6c07 | ||
|
|
b9ad75fa60 | ||
|
|
a38ba59cc3 | ||
|
|
c4523c2b3d | ||
|
|
2570b2e575 | ||
|
|
cf26ab70c1 | ||
|
|
e1caabbb75 | ||
|
|
95891fc016 | ||
|
|
72b3442aeb | ||
|
|
11b9f26610 | ||
|
|
8ee649a02e | ||
|
|
ce7eb4443c | ||
|
|
25a9c17f55 | ||
|
|
c6dbb85c9e | ||
|
|
08ec67bc62 | ||
|
|
cc2965fd23 | ||
|
|
80591b0a00 | ||
|
|
b02cea1212 | ||
|
|
a1acfc8f37 | ||
|
|
0c3b0d501e | ||
|
|
f7d5665969 | ||
|
|
68e5e2b1c7 | ||
|
|
fa076d491f | ||
|
|
9ce4ae8142 | ||
|
|
92e13c2a11 | ||
|
|
59f351ccda | ||
|
|
f39653e306 | ||
|
|
cee01cfb2e | ||
|
|
dccfe05e17 | ||
|
|
64a76d7b44 | ||
|
|
c4c2cd44d2 | ||
|
|
e9d67a81c8 | ||
|
|
7fe0ebac5f | ||
|
|
73132b9c12 | ||
|
|
04211fd204 | ||
|
|
dc1cbf839d | ||
|
|
c693840fe8 | ||
|
|
42cc304e90 | ||
|
|
39c77c3738 | ||
|
|
0b6c6a9c9f | ||
|
|
a79428998d | ||
|
|
c93b162248 | ||
|
|
324d26f9aa | ||
|
|
715c16ab0a | ||
|
|
69ca5a70fd | ||
|
|
c8bac033f3 | ||
|
|
45ecfc2f5c | ||
|
|
b9d0f0c762 | ||
|
|
74f8208f18 | ||
|
|
ffa5d76602 | ||
|
|
45911a60c3 | ||
|
|
31567c1c70 | ||
|
|
68d09697c9 | ||
|
|
4824ccae8e | ||
|
|
0dc490bda2 | ||
|
|
f90ab183d6 | ||
|
|
275b929e01 | ||
|
|
9e1f92d0bb | ||
|
|
9230582315 | ||
|
|
c52248e41c | ||
|
|
3c96d0258c | ||
|
|
0f3a580c4f | ||
|
|
027271e5a9 | ||
|
|
0a0180cdc5 | ||
|
|
104d544fd7 | ||
|
|
dd5702d696 | ||
|
|
a7d6c8bab9 | ||
|
|
cf7cf62204 | ||
|
|
0764a7f72d | ||
|
|
7a60133c6c | ||
|
|
403a5a298e | ||
|
|
71c9f015e9 | ||
|
|
dd9228b861 | ||
|
|
c0183e6e0d | ||
|
|
6aa7696e28 | ||
|
|
2a7a451391 | ||
|
|
d7e6af2dda | ||
|
|
78c5656530 | ||
|
|
e421b5ebf6 | ||
|
|
2724fa9d8a | ||
|
|
fb274df079 | ||
|
|
9c8c038981 | ||
|
|
d1277c6052 | ||
|
|
d0a071a528 | ||
|
|
b44c790e41 | ||
|
|
d25c33f186 | ||
|
|
c5b737231d | ||
|
|
592d4fe772 | ||
|
|
4866e905d7 | ||
|
|
4ee7cd4f6f | ||
|
|
aa9b1828b9 | ||
|
|
1d42665b6b | ||
|
|
62a90cdd74 | ||
|
|
d02db89244 | ||
|
|
85c247161b | ||
|
|
081eb71ebd | ||
|
|
68404f13d4 | ||
|
|
a55bd05f3c | ||
|
|
397de617f3 | ||
|
|
a4522c5a66 | ||
|
|
afc4113ed7 | ||
|
|
cdf62770af | ||
|
|
107fe7c081 | ||
|
|
aefed941c2 | ||
|
|
9f153f610f | ||
|
|
3f165fa5b3 | ||
|
|
8e2cfec1cd | ||
|
|
4cf1d08fc2 | ||
|
|
4e6d5117b8 | ||
|
|
4e6c8120a5 | ||
|
|
35e9c5d83a | ||
|
|
c51fc7bed6 | ||
|
|
b4a5087ee0 | ||
|
|
4917c11432 | ||
|
|
a43dba76ea | ||
|
|
444639cc21 | ||
|
|
c3fff877e1 | ||
|
|
4aafd5f4e3 | ||
|
|
d18f52bd18 | ||
|
|
fb29038b59 | ||
|
|
509697f00d | ||
|
|
da8ae75340 | ||
|
|
fe2188378c | ||
|
|
8a2e421f26 | ||
|
|
19fb67eee4 | ||
|
|
b29028e351 | ||
|
|
f39c7c0c86 | ||
|
|
cd174d1f31 | ||
|
|
32fd76c1d5 | ||
|
|
93e1a215af | ||
|
|
3444bd4fc2 | ||
|
|
51f421a55c | ||
|
|
1acb4ef87e | ||
|
|
574f2f4394 | ||
|
|
fe66a0eca1 | ||
|
|
c8f2f74ddd | ||
|
|
5014dada3f | ||
|
|
8195d20e36 | ||
|
|
17db1a9ac1 | ||
|
|
7be1030dcc | ||
|
|
be048f21e6 | ||
|
|
06aed4316e | ||
|
|
04bb2d2d06 | ||
|
|
d4f0b9476a | ||
|
|
d686482d05 | ||
|
|
6f1713f216 | ||
|
|
394eebed66 | ||
|
|
38b8831b32 | ||
|
|
f99afb5dff | ||
|
|
a2f47358eb | ||
|
|
6d8112cc24 | ||
|
|
8f8a420f12 | ||
|
|
b78d1c045f | ||
|
|
4f82bdb050 | ||
|
|
52feee9b1f | ||
|
|
28b29916cb | ||
|
|
400d8bb45e | ||
|
|
d553faf5a5 | ||
|
|
a7259b64e8 | ||
|
|
d2172c04e6 | ||
|
|
33196372be | ||
|
|
86620756d2 | ||
|
|
32b2a9fd6a | ||
|
|
68444b9f0c | ||
|
|
6aa74fcf5b | ||
|
|
838ffd5be2 | ||
|
|
2f518b078b | ||
|
|
081efd1232 | ||
|
|
a523e2efad | ||
|
|
84da0bf475 | ||
|
|
e376d454bb | ||
|
|
ae86a338b8 | ||
|
|
597906c436 | ||
|
|
e7b43cf59f | ||
|
|
c12d51e94e | ||
|
|
624188aec0 | ||
|
|
671ca33aa1 | ||
|
|
a58a637bed | ||
|
|
99a61842df | ||
|
|
8617454027 | ||
|
|
e93550866b | ||
|
|
53ce7f0d71 | ||
|
|
431a7c9c53 | ||
|
|
a37e7134f7 | ||
|
|
92657d484f | ||
|
|
e8419c90f1 | ||
|
|
5233cd3800 | ||
|
|
6f04391cec | ||
|
|
de7684a309 | ||
|
|
27dd495b98 | ||
|
|
b4133683a4 | ||
|
|
f732e96757 | ||
|
|
c9ca0a3274 | ||
|
|
56244736ec | ||
|
|
542963685c | ||
|
|
03b4c14bd4 | ||
|
|
b3b0753593 | ||
|
|
cb448fe01b | ||
|
|
ffae845cfd | ||
|
|
b1d8e7db0f | ||
|
|
25591c322c | ||
|
|
7fc294cdfe | ||
|
|
3718832a15 | ||
|
|
1e18f1bab3 | ||
|
|
284d0faed6 | ||
|
|
069e347863 | ||
|
|
cd5c61cd3b | ||
|
|
753f42ab8d | ||
|
|
0e6f661e23 | ||
|
|
977bc6a137 | ||
|
|
ea915363e7 | ||
|
|
6b160e490d | ||
|
|
be7d2a8ded | ||
|
|
25cd7fd702 | ||
|
|
1e47c429bf | ||
|
|
e00e5025ec | ||
|
|
39487e2d6a | ||
|
|
94e87bc83d | ||
|
|
28bf671d6d | ||
|
|
f1d93ec420 | ||
|
|
b2e578a1f2 | ||
|
|
773f6710c1 | ||
|
|
12c0622231 | ||
|
|
b5ee8db9b5 | ||
|
|
65eb550024 | ||
|
|
81887e2342 | ||
|
|
23ffb6a4a2 | ||
|
|
6dd03f04ea | ||
|
|
87cf2ee8ab | ||
|
|
d5fe880a57 | ||
|
|
9d96af2e83 | ||
|
|
3b92eaac53 | ||
|
|
75cddd8eb5 | ||
|
|
0a4624aece | ||
|
|
59bb4a4f50 | ||
|
|
7c5258b1c4 | ||
|
|
3d3d698594 | ||
|
|
fee2d0c256 | ||
|
|
7e497527ea | ||
|
|
e26b2783a5 | ||
|
|
648b44fd78 | ||
|
|
a5f2cd30c9 | ||
|
|
fc21305892 | ||
|
|
f536b99d26 | ||
|
|
a985d306a1 | ||
|
|
83177991c8 | ||
|
|
08126f665d | ||
|
|
459a5ad410 | ||
|
|
4ecfcdcced | ||
|
|
c04163a289 | ||
|
|
04e11c9209 | ||
|
|
9304d6ea92 | ||
|
|
991a1da148 | ||
|
|
0ef240d979 | ||
|
|
05743d7949 | ||
|
|
68e8e96d7f | ||
|
|
d56e3ccf96 | ||
|
|
937b10f35d | ||
|
|
761e1d1462 | ||
|
|
65581f3ed1 | ||
|
|
1e2a7e4ed1 | ||
|
|
6d52c1ee24 | ||
|
|
dc1c45795b | ||
|
|
97bd0e05cc | ||
|
|
7dbf1b4d9e | ||
|
|
afdad653ac | ||
|
|
534b8d0483 | ||
|
|
9412ec7555 | ||
|
|
22876c797c | ||
|
|
b386c1c614 | ||
|
|
d55fe3e595 | ||
|
|
e8ef7ec7de | ||
|
|
f3f33ebb0b | ||
|
|
f8157cafcb | ||
|
|
32d49bc70f | ||
|
|
c85bfcad52 | ||
|
|
5c3d2b334a | ||
|
|
95dc672326 | ||
|
|
30eb319103 | ||
|
|
6e602c4931 | ||
|
|
80667e30fb | ||
|
|
a2980c6249 | ||
|
|
5de754a395 | ||
|
|
7cff01ec2d | ||
|
|
0b2b5842a1 | ||
|
|
f0044c480c | ||
|
|
c348e0bc7b | ||
|
|
8c69afd992 | ||
|
|
c882f341ce | ||
|
|
8c638cbf09 | ||
|
|
c96d37050f | ||
|
|
36fc3cd8bc | ||
|
|
ddd42cb064 | ||
|
|
9772816570 | ||
|
|
73032ca04b | ||
|
|
847fa779af | ||
|
|
0effc2410b | ||
|
|
b5c60fc787 | ||
|
|
da42bd5bbe | ||
|
|
ef67c5758a | ||
|
|
c4e4be9414 | ||
|
|
f470196a41 | ||
|
|
61160dd0a1 | ||
|
|
b76b9a4328 | ||
|
|
893988182a | ||
|
|
ca9635b19d | ||
|
|
a5549c9617 | ||
|
|
680b86afbb | ||
|
|
1d290d1e24 | ||
|
|
9e58921e7e | ||
|
|
314820e595 | ||
|
|
8e8200a772 | ||
|
|
46ef46aefb | ||
|
|
46904bfbcc | ||
|
|
518d8dd979 | ||
|
|
52432f2b06 | ||
|
|
2b11fb483e | ||
|
|
c2f0de5eef | ||
|
|
1aac3ab49f | ||
|
|
78e1d58d3a | ||
|
|
c44c21060e | ||
|
|
ce34cccf28 | ||
|
|
d27d925a6d | ||
|
|
481ce92bdf | ||
|
|
84bbac5a09 | ||
|
|
ee8e3ee919 | ||
|
|
de24bd960f | ||
|
|
d2c450ce81 | ||
|
|
474d1c57c8 | ||
|
|
9b4c072a04 | ||
|
|
766f65919b | ||
|
|
482f2b31e7 | ||
|
|
6b404431aa | ||
|
|
4e9ca75281 | ||
|
|
bcd5fc12ec | ||
|
|
56ea65ca5f | ||
|
|
5fee2e1a79 | ||
|
|
9cd30d30a0 | ||
|
|
83c44229d2 | ||
|
|
21e20cb4ad | ||
|
|
4dada747e5 | ||
|
|
4f2e8bc765 | ||
|
|
fb0eba706c | ||
|
|
27963980db | ||
|
|
d3c042fc60 | ||
|
|
fcd878efcd | ||
|
|
3f9c848576 | ||
|
|
ddc865fb0d | ||
|
|
c03e872112 | ||
|
|
abee3d0e0d | ||
|
|
d55268d0d4 | ||
|
|
5adfa44101 | ||
|
|
1d61416b5a | ||
|
|
08137c28c4 | ||
|
|
bb50fdfe07 | ||
|
|
ec5631b6d6 | ||
|
|
7b55c7f97d | ||
|
|
8e5b6f58a2 |
No files matched your search
@@ -13,22 +13,6 @@ menu "Busybox Settings"
|
||||
|
||||
menu "General Configuration"
|
||||
|
||||
config NITPICK
|
||||
bool "See lots more (probably unnecessary) configuration options."
|
||||
default n
|
||||
help
|
||||
Some BusyBox applets have more configuration options than anyone
|
||||
will ever care about. To avoid drowining people in complexity, most
|
||||
of the applet features that can be set to a sane default value are
|
||||
hidden, unless you hit the above switch.
|
||||
|
||||
This is better than to telling people to edit the busybox source
|
||||
code, but not by much.
|
||||
|
||||
See http://en.wikipedia.org/wiki/Fibber_McGee_and_Molly#The_Closet
|
||||
|
||||
You have been warned.
|
||||
|
||||
config DESKTOP
|
||||
bool "Enable options for full-blown desktop systems"
|
||||
default n
|
||||
@@ -37,15 +21,35 @@ config DESKTOP
|
||||
Select this only if you plan to use busybox on full-blown
|
||||
desktop machine with common Linux distro, not on an embedded box.
|
||||
|
||||
config EXTRA_COMPAT
|
||||
bool "Provide compatible behavior for rare corner cases (bigger code)"
|
||||
default n
|
||||
help
|
||||
This option makes grep, sed etc handle rare corner cases
|
||||
(embedded NUL bytes and such). This makes code bigger and uses
|
||||
some GNU extensions in libc. You probably only need this option
|
||||
if you plan to run busybox on desktop.
|
||||
|
||||
config FEATURE_ASSUME_UNICODE
|
||||
bool "Assume that 1:1 char/glyph correspondence is not true"
|
||||
default n
|
||||
help
|
||||
This makes various applets aware that one byte is not
|
||||
one character on screen.
|
||||
|
||||
Busybox aims to eventually work correctly with Unicode displays.
|
||||
Any older encodings are not guaranteed to work.
|
||||
Probably by the time when busybox will be fully Unicode-clean,
|
||||
other encodings will be mainly of historic interest.
|
||||
|
||||
choice
|
||||
prompt "Buffer allocation policy"
|
||||
default FEATURE_BUFFERS_USE_MALLOC
|
||||
depends on NITPICK
|
||||
help
|
||||
There are 3 ways BusyBox can handle buffer allocations:
|
||||
- Use malloc. This costs code size for the call to xmalloc.
|
||||
- Put them on stack. For some very small machines with limited stack
|
||||
space, this can be deadly. For most folks, this works just fine.
|
||||
space, this can be deadly. For most folks, this works just fine.
|
||||
- Put them in BSS. This works beautifully for computers with a real
|
||||
MMU (and OS support), but wastes runtime RAM for uCLinux. This
|
||||
behavior was the only one available for BusyBox versions 0.48 and
|
||||
@@ -77,8 +81,8 @@ config FEATURE_VERBOSE_USAGE
|
||||
select SHOW_USAGE
|
||||
help
|
||||
All BusyBox applets will show more verbose help messages when
|
||||
busybox is invoked with --help. This will add a lot of text to the
|
||||
busybox binary. In the default configuration, this will add about
|
||||
busybox is invoked with --help. This will add a lot of text to the
|
||||
busybox binary. In the default configuration, this will add about
|
||||
13k, but it can add much more depending on your configuration.
|
||||
|
||||
config FEATURE_COMPRESS_USAGE
|
||||
@@ -91,15 +95,15 @@ config FEATURE_COMPRESS_USAGE
|
||||
|
||||
If you have a really tiny busybox with few applets enabled (and
|
||||
bunzip2 isn't one of them), the overhead of the decompressor might
|
||||
be noticeable. Also, if you run executables directly from ROM
|
||||
and have very little memory, this might not be a win. Otherwise,
|
||||
be noticeable. Also, if you run executables directly from ROM
|
||||
and have very little memory, this might not be a win. Otherwise,
|
||||
you probably want this.
|
||||
|
||||
config FEATURE_INSTALLER
|
||||
bool "Support --install [-s] to install applet links at runtime"
|
||||
default n
|
||||
help
|
||||
Enable 'busybox --install [-s]' support. This will allow you to use
|
||||
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.
|
||||
|
||||
@@ -111,7 +115,7 @@ config LOCALE_SUPPORT
|
||||
busybox to support locale settings.
|
||||
|
||||
config GETOPT_LONG
|
||||
bool "Enable support for --long-options"
|
||||
bool "Support for --long-options"
|
||||
default y
|
||||
help
|
||||
Enable this if you want busybox applets to use the gnu --long-option
|
||||
@@ -123,17 +127,16 @@ config FEATURE_DEVPTS
|
||||
help
|
||||
Enable if you want BusyBox to use Unix98 PTY support. If enabled,
|
||||
busybox will use /dev/ptmx for the master side of the pseudoterminal
|
||||
and /dev/pts/<number> for the slave side. Otherwise, BSD style
|
||||
and /dev/pts/<number> for the slave side. Otherwise, BSD style
|
||||
/dev/ttyp<number> will be used. To use this option, you should have
|
||||
devpts mounted.
|
||||
|
||||
config FEATURE_CLEAN_UP
|
||||
bool "Clean up all memory before exiting (usually not needed)"
|
||||
default n
|
||||
depends on NITPICK
|
||||
help
|
||||
As a size optimization, busybox normally exits without explicitly
|
||||
freeing dynamically allocated memory or closing files. This saves
|
||||
freeing dynamically allocated memory or closing files. This saves
|
||||
space since the OS will clean up for us, but it can confuse debuggers
|
||||
like valgrind, which report tons of memory and resource leaks.
|
||||
|
||||
@@ -158,7 +161,7 @@ config FEATURE_SUID
|
||||
If you're really paranoid and don't want to do this, build two
|
||||
busybox binaries with different applets in them (and the appropriate
|
||||
symlinks pointing to each binary), and only set the suid bit on the
|
||||
one that needs it. The applets currently marked to need the suid bit
|
||||
one that needs it. The applets currently marked to need the suid bit
|
||||
are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs,
|
||||
and vlock.
|
||||
|
||||
@@ -168,7 +171,7 @@ config FEATURE_SUID_CONFIG
|
||||
depends on FEATURE_SUID
|
||||
help
|
||||
Allow the SUID / SGID state of an applet to be determined at runtime
|
||||
by checking /etc/busybox.conf. (This is sort of a poor man's sudo.)
|
||||
by checking /etc/busybox.conf. (This is sort of a poor man's sudo.)
|
||||
The format of this file is as follows:
|
||||
|
||||
<applet> = [Ssx-][Ssx-][x-] (<username>|<uid>).(<groupname>|<gid>)
|
||||
@@ -176,11 +179,12 @@ config FEATURE_SUID_CONFIG
|
||||
An example might help:
|
||||
|
||||
[SUID]
|
||||
su = ssx root.0 # applet su can be run by anyone and runs with euid=0/egid=0
|
||||
su = ssx root.0 # applet su can be run by anyone and runs with
|
||||
# euid=0/egid=0
|
||||
su = ssx # exactly the same
|
||||
|
||||
mount = sx- root.disk # applet mount can be run by root and members of group disk
|
||||
# and runs with euid=0
|
||||
mount = sx- root.disk # applet mount can be run by root and members
|
||||
# of group disk and runs with euid=0
|
||||
|
||||
cp = --- # disable applet cp for everyone
|
||||
|
||||
@@ -199,14 +203,15 @@ config FEATURE_SUID_CONFIG_QUIET
|
||||
default y
|
||||
depends on FEATURE_SUID_CONFIG
|
||||
help
|
||||
/etc/busybox.conf should be readable by the user needing the SUID, check
|
||||
this option to avoid users to be notified about missing permissions.
|
||||
/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 SELINUX
|
||||
bool "Support NSA Security Enhanced Linux"
|
||||
default n
|
||||
help
|
||||
Enable support for SELinux in applets ls, ps, and id. Also provide
|
||||
Enable support for SELinux in applets ls, ps, and id. Also provide
|
||||
the option of compiling in SELinux applets.
|
||||
|
||||
If you do not have a complete SELinux userland installed, this stuff
|
||||
@@ -241,9 +246,9 @@ config BUSYBOX_EXEC_PATH
|
||||
default "/proc/self/exe"
|
||||
help
|
||||
When Busybox applets need to run other busybox applets, BusyBox
|
||||
sometimes needs to exec() itself. When the /proc filesystem is
|
||||
sometimes needs to exec() itself. When the /proc filesystem is
|
||||
mounted, /proc/self/exe always points to the currently running
|
||||
executable. If you haven't got /proc, set this to wherever you
|
||||
executable. If you haven't got /proc, set this to wherever you
|
||||
want to run BusyBox from.
|
||||
|
||||
# These are auto-selected by other options
|
||||
@@ -280,16 +285,37 @@ config STATIC
|
||||
|
||||
Most people will leave this set to 'N'.
|
||||
|
||||
config PIE
|
||||
bool "Build BusyBox as a position independent executable"
|
||||
default n
|
||||
depends on !STATIC
|
||||
help
|
||||
(TODO: what is it and why/when is it useful?)
|
||||
Most people will leave this set to 'N'.
|
||||
|
||||
config NOMMU
|
||||
bool "Force NOMMU build"
|
||||
default n
|
||||
help
|
||||
Busybox tries to detect whether architecture it is being
|
||||
built against supports MMU or not. If this detection fails,
|
||||
or if you want to build NOMMU version of busybox for testing,
|
||||
you may force NOMMU build here.
|
||||
|
||||
Most people will leave this set to 'N'.
|
||||
|
||||
# PIE can be made to work with BUILD_LIBBUSYBOX, but currently
|
||||
# build system does not support that
|
||||
config BUILD_LIBBUSYBOX
|
||||
bool "Build shared libbusybox"
|
||||
default n
|
||||
depends on !FEATURE_PREFER_APPLETS
|
||||
depends on !FEATURE_PREFER_APPLETS && !PIE && !STATIC
|
||||
help
|
||||
Build a shared library libbusybox.so.N.N.N which contains all
|
||||
busybox code.
|
||||
|
||||
This feature allows every applet to be built as a tiny
|
||||
separate executable. Enabling it for "one big busybox binary"
|
||||
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.
|
||||
|
||||
@@ -306,7 +332,7 @@ config BUILD_LIBBUSYBOX
|
||||
### 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
|
||||
### 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.
|
||||
###
|
||||
@@ -315,7 +341,7 @@ config BUILD_LIBBUSYBOX
|
||||
config FEATURE_INDIVIDUAL
|
||||
bool "Produce a binary for each applet, linked against libbusybox"
|
||||
default y
|
||||
depends on !STATIC && BUILD_LIBBUSYBOX
|
||||
depends on BUILD_LIBBUSYBOX
|
||||
help
|
||||
If your CPU architecture doesn't allow for sharing text/rodata
|
||||
sections of running binaries, but allows for runtime dynamic
|
||||
@@ -333,7 +359,7 @@ config FEATURE_INDIVIDUAL
|
||||
config FEATURE_SHARED_BUSYBOX
|
||||
bool "Produce additional busybox binary linked against libbusybox"
|
||||
default y
|
||||
depends on !STATIC && BUILD_LIBBUSYBOX
|
||||
depends on BUILD_LIBBUSYBOX
|
||||
help
|
||||
Build busybox, dynamically linked against libbusybox.so.N.N.N.
|
||||
|
||||
@@ -364,11 +390,21 @@ config LFS
|
||||
select FDISK_SUPPORT_LARGE_DISKS
|
||||
help
|
||||
If you want to build BusyBox with large file support, then enable
|
||||
this option. This will have no effect if your kernel or your C
|
||||
library lacks large file support for large files. Some of the
|
||||
this option. This will have no effect if your kernel or your C
|
||||
library lacks large file support for large files. Some of the
|
||||
programs that can benefit from large file support include dd, gzip,
|
||||
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'.
|
||||
cp, mount, tar, and many others. If you want to access files larger
|
||||
than 2 Gigabytes, enable this option. Otherwise, leave it set to 'N'.
|
||||
|
||||
config CROSS_COMPILER_PREFIX
|
||||
string "Cross Compiler prefix"
|
||||
default ""
|
||||
help
|
||||
If you want to build BusyBox with a cross compiler, then you
|
||||
will need to set this to the cross-compiler prefix, for example,
|
||||
"i386-uclibc-". Note that CROSS_COMPILE environment variable
|
||||
or "make CROSS_COMPILE=xxx ..." will override this selection.
|
||||
For native build leave it empty.
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -379,12 +415,23 @@ config DEBUG
|
||||
default n
|
||||
help
|
||||
Say Y here if you wish to examine BusyBox internals while applets are
|
||||
running. This increases the size of the binary considerably, and
|
||||
should only be used when doing development. If you are doing
|
||||
running. This increases the size of the binary considerably, and
|
||||
should only be used when doing development. If you are doing
|
||||
development and want to debug BusyBox, answer Y.
|
||||
|
||||
Most people should answer N.
|
||||
|
||||
config DEBUG_PESSIMIZE
|
||||
bool "Disable compiler optimizations"
|
||||
default n
|
||||
depends on DEBUG
|
||||
help
|
||||
The compiler's optimization of source code can eliminate and reorder
|
||||
code, resulting in an executable that's hard to understand when
|
||||
stepping through it with a debugger. This switches it off, resulting
|
||||
in a much bigger executable that more closely matches the source
|
||||
code.
|
||||
|
||||
config WERROR
|
||||
bool "Abort compilation on any warning"
|
||||
default n
|
||||
@@ -393,44 +440,33 @@ config WERROR
|
||||
|
||||
Most people should answer N.
|
||||
|
||||
# Seems to be unused
|
||||
#config DEBUG_PESSIMIZE
|
||||
# bool "Disable compiler optimizations."
|
||||
# default n
|
||||
# depends on DEBUG
|
||||
# help
|
||||
# The compiler's optimization of source code can eliminate and reorder
|
||||
# code, resulting in an executable that's hard to understand when
|
||||
# stepping through it with a debugger. This switches it off, resulting
|
||||
# in a much bigger executable that more closely matches the source
|
||||
# code.
|
||||
|
||||
choice
|
||||
prompt "Additional debugging library"
|
||||
default NO_DEBUG_LIB
|
||||
help
|
||||
Using an additional debugging library will make BusyBox become
|
||||
considerable larger and will cause it to run more slowly. You
|
||||
considerable larger and will cause it to run more slowly. You
|
||||
should always leave this option disabled for production use.
|
||||
|
||||
dmalloc support:
|
||||
----------------
|
||||
This enables compiling with dmalloc ( http://dmalloc.com/ )
|
||||
which is an excellent public domain mem leak and malloc problem
|
||||
detector. To enable dmalloc, before running busybox you will
|
||||
detector. To enable dmalloc, before running busybox you will
|
||||
want to properly set your environment, for example:
|
||||
export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
|
||||
The 'debug=' value is generated using the following command
|
||||
dmalloc -p log-stats -p log-non-free -p log-bad-space -p log-elapsed-time \
|
||||
-p check-fence -p check-heap -p check-lists -p check-blank \
|
||||
-p check-funcs -p realloc-copy -p allow-free-null
|
||||
dmalloc -p log-stats -p log-non-free -p log-bad-space \
|
||||
-p log-elapsed-time -p check-fence -p check-heap \
|
||||
-p check-lists -p check-blank -p check-funcs -p realloc-copy \
|
||||
-p allow-free-null
|
||||
|
||||
Electric-fence support:
|
||||
-----------------------
|
||||
This enables compiling with Electric-fence support. Electric
|
||||
This enables compiling with Electric-fence support. Electric
|
||||
fence is another very useful malloc debugging library which uses
|
||||
your computer's virtual memory hardware to detect illegal memory
|
||||
accesses. This support will make BusyBox be considerable larger
|
||||
accesses. This support will make BusyBox be considerable larger
|
||||
and run slower, so you should leave this option disabled unless
|
||||
you are hunting a hard to find memory problem.
|
||||
|
||||
@@ -452,9 +488,12 @@ config INCLUDE_SUSv2
|
||||
help
|
||||
This option will enable backwards compatibility with SuSv2,
|
||||
specifically, old-style numeric options ('command -1 <file>')
|
||||
will be supported in head, tail, and fold. (Note: should
|
||||
will be supported in head, tail, and fold. (Note: should
|
||||
affect renice too.)
|
||||
|
||||
config PARSE
|
||||
bool "Uniform config file parser debugging applet: parse"
|
||||
|
||||
endmenu
|
||||
|
||||
menu 'Installation Options'
|
||||
@@ -482,8 +521,8 @@ config INSTALL_APPLET_SYMLINKS
|
||||
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.
|
||||
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"
|
||||
@@ -519,7 +558,8 @@ config INSTALL_SH_APPLET_HARDLINK
|
||||
config INSTALL_SH_APPLET_SCRIPT_WRAPPER
|
||||
bool "as script wrapper"
|
||||
help
|
||||
Install /bin/sh applet as script wrapper that call the busybox binary.
|
||||
Install /bin/sh applet as script wrapper that call the busybox
|
||||
binary.
|
||||
|
||||
endchoice
|
||||
|
||||
@@ -555,4 +595,4 @@ source shell/Config.in
|
||||
source sysklogd/Config.in
|
||||
source runit/Config.in
|
||||
source selinux/Config.in
|
||||
source ipsvd/Config.in
|
||||
source printutils/Config.in
|
||||
@@ -1,6 +1,6 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 9
|
||||
SUBLEVEL = 0
|
||||
PATCHLEVEL = 12
|
||||
SUBLEVEL = 4
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
@@ -142,17 +142,6 @@ VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
|
||||
export srctree objtree VPATH TOPDIR
|
||||
|
||||
|
||||
# SUBARCH tells the usermode build what the underlying arch is. That is set
|
||||
# first, and if a usermode build is happening, the "ARCH=um" on the command
|
||||
# line overrides the setting of ARCH below. If a native build is happening,
|
||||
# then ARCH is assigned, getting whatever value it gets normally, and
|
||||
# SUBARCH is subsequently ignored.
|
||||
|
||||
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
|
||||
-e s/arm.*/arm/ -e s/sa110/arm/ \
|
||||
-e s/s390x/s390/ -e s/parisc64/parisc/ \
|
||||
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
|
||||
|
||||
# Cross compiling and selecting different set of gcc/bin-utils
|
||||
# ---------------------------------------------------------------------------
|
||||
#
|
||||
@@ -172,8 +161,32 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
|
||||
# Default value for CROSS_COMPILE is not to prefix executables
|
||||
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
|
||||
|
||||
ARCH ?= $(SUBARCH)
|
||||
CROSS_COMPILE ?=
|
||||
CROSS_COMPILE ?=
|
||||
# bbox: we may have CONFIG_CROSS_COMPILER_PREFIX in .config,
|
||||
# and it has not been included yet... thus using an awkward syntax.
|
||||
ifeq ($(CROSS_COMPILE),)
|
||||
CROSS_COMPILE := $(shell grep ^CONFIG_CROSS_COMPILER_PREFIX .config 2>/dev/null)
|
||||
CROSS_COMPILE := $(subst CONFIG_CROSS_COMPILER_PREFIX=,,$(CROSS_COMPILE))
|
||||
CROSS_COMPILE := $(subst ",,$(CROSS_COMPILE))
|
||||
endif
|
||||
|
||||
# SUBARCH tells the usermode build what the underlying arch is. That is set
|
||||
# first, and if a usermode build is happening, the "ARCH=um" on the command
|
||||
# line overrides the setting of ARCH below. If a native build is happening,
|
||||
# then ARCH is assigned, getting whatever value it gets normally, and
|
||||
# SUBARCH is subsequently ignored.
|
||||
|
||||
ifneq ($(CROSS_COMPILE),)
|
||||
SUBARCH := $(shell echo $(CROSS_COMPILE) | cut -d- -f1)
|
||||
else
|
||||
SUBARCH := $(shell uname -m)
|
||||
endif
|
||||
SUBARCH := $(shell echo $(SUBARCH) | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
|
||||
-e s/arm.*/arm/ -e s/sa110/arm/ \
|
||||
-e s/s390x/s390/ -e s/parisc64/parisc/ \
|
||||
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
|
||||
|
||||
ARCH ?= $(SUBARCH)
|
||||
|
||||
# Architecture as present in compile.h
|
||||
UTS_MACHINE := $(ARCH)
|
||||
@@ -302,6 +315,8 @@ AFLAGS_KERNEL =
|
||||
# Use LINUXINCLUDE when you must reference the include/ directory.
|
||||
# Needed to be compatible with the O= option
|
||||
CFLAGS := $(CFLAGS)
|
||||
# Added only to final link stage of busybox binary
|
||||
CFLAGS_busybox := $(CFLAGS_busybox)
|
||||
CPPFLAGS := $(CPPFLAGS)
|
||||
AFLAGS := $(AFLAGS)
|
||||
LDFLAGS := $(LDFLAGS)
|
||||
@@ -361,7 +376,8 @@ endif
|
||||
# of make so .config is not included in this case either (for *config).
|
||||
|
||||
no-dot-config-targets := clean mrproper distclean \
|
||||
cscope TAGS tags help %docs check%
|
||||
cscope TAGS tags help %docs
|
||||
#bbox# check% is removed from above
|
||||
|
||||
config-targets := 0
|
||||
mixed-targets := 0
|
||||
@@ -437,7 +453,6 @@ libs-y := \
|
||||
editors/ \
|
||||
findutils/ \
|
||||
init/ \
|
||||
ipsvd/ \
|
||||
libbb/ \
|
||||
libpwdgrp/ \
|
||||
loginutils/ \
|
||||
@@ -446,12 +461,14 @@ libs-y := \
|
||||
networking/ \
|
||||
networking/libiproute/ \
|
||||
networking/udhcp/ \
|
||||
printutils/ \
|
||||
procps/ \
|
||||
runit/ \
|
||||
selinux/ \
|
||||
shell/ \
|
||||
sysklogd/ \
|
||||
util-linux/ \
|
||||
util-linux/volume_id/ \
|
||||
|
||||
endif # KBUILD_EXTMOD
|
||||
|
||||
@@ -496,12 +513,6 @@ all: busybox
|
||||
#bbox# NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
|
||||
CHECKFLAGS += $(NOSTDINC_FLAGS)
|
||||
|
||||
# warn about C99 declaration after statement
|
||||
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
|
||||
|
||||
# disable pointer signedness warnings in gcc 4.0
|
||||
CFLAGS += $(call cc-option,-Wno-pointer-sign,)
|
||||
|
||||
# Default kernel image to build when no specific target is given.
|
||||
# KBUILD_IMAGE may be overruled on the commandline or
|
||||
# set in the environment
|
||||
@@ -571,6 +582,7 @@ quiet_cmd_busybox__ ?= LINK $@
|
||||
cmd_busybox__ ?= $(srctree)/scripts/trylink \
|
||||
"$@" \
|
||||
"$(CC)" \
|
||||
"$(CFLAGS) $(CFLAGS_busybox)" \
|
||||
"$(LDFLAGS) $(EXTRA_LDFLAGS)" \
|
||||
"$(core-y)" \
|
||||
"$(libs-y)" \
|
||||
@@ -686,6 +698,8 @@ ifeq ($(SKIP_STRIP),y)
|
||||
else
|
||||
$(Q)$(STRIP) -s --remove-section=.note --remove-section=.comment \
|
||||
busybox_unstripped -o $@
|
||||
# strip is confused by PIE executable and does not set exec bits
|
||||
$(Q)chmod a+x $@
|
||||
endif
|
||||
|
||||
# The actual objects are generated when descending,
|
||||
@@ -729,7 +743,7 @@ localver = $(subst $(space),, \
|
||||
# Currently, only git is supported.
|
||||
# Other SCMs can edit scripts/setlocalversion and add the appropriate
|
||||
# checks as needed.
|
||||
ifdef CONFIG_LOCALVERSION_AUTO
|
||||
ifdef _BB_DISABLED_CONFIG_LOCALVERSION_AUTO
|
||||
_localver-auto = $(shell $(CONFIG_SHELL) \
|
||||
$(srctree)/scripts/setlocalversion $(srctree))
|
||||
localver-auto = $(LOCALVERSION)$(_localver-auto)
|
||||
@@ -842,7 +856,7 @@ depend dep:
|
||||
# ---------------------------------------------------------------------------
|
||||
# Modules
|
||||
|
||||
ifdef CONFIG_MODULES
|
||||
ifdef _BB_DISABLED_CONFIG_MODULES
|
||||
|
||||
# By default, build modules as well
|
||||
|
||||
@@ -918,8 +932,9 @@ endif # CONFIG_MODULES
|
||||
# make distclean Remove editor backup files, patch leftover files and the like
|
||||
|
||||
# Directories & files removed with 'make clean'
|
||||
CLEAN_DIRS += $(MODVERDIR)
|
||||
CLEAN_FILES += busybox* System.map .kernelrelease \
|
||||
CLEAN_DIRS += $(MODVERDIR) _install 0_lib
|
||||
CLEAN_FILES += busybox busybox_unstripped* busybox.links \
|
||||
System.map .kernelrelease \
|
||||
.tmp_kallsyms* .tmp_version .tmp_busybox* .tmp_System.map
|
||||
|
||||
# Directories & files removed with 'make mrproper'
|
||||
@@ -930,7 +945,8 @@ MRPROPER_FILES += .config .config.old include/asm .version .old_version \
|
||||
include/usage_compressed.h \
|
||||
include/applet_tables.h \
|
||||
applets/usage \
|
||||
.kernelrelease Module.symvers tags TAGS cscope*
|
||||
.kernelrelease Module.symvers tags TAGS cscope* \
|
||||
busybox_old
|
||||
|
||||
# clean - Delete most, but leave enough to build external modules
|
||||
#
|
||||
@@ -946,7 +962,7 @@ clean: archclean $(clean-dirs)
|
||||
$(call cmd,rmdirs)
|
||||
$(call cmd,rmfiles)
|
||||
@find . $(RCS_FIND_IGNORE) \
|
||||
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
|
||||
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
|
||||
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
|
||||
-type f -print | xargs rm -f
|
||||
|
||||
@@ -970,9 +986,9 @@ PHONY += distclean
|
||||
|
||||
distclean: mrproper
|
||||
@find $(srctree) $(RCS_FIND_IGNORE) \
|
||||
\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
|
||||
\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
|
||||
-o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
|
||||
-o -name '.*.rej' -o -name '*.tmp' -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
|
||||
|
||||
@@ -1076,7 +1092,7 @@ clean: rm-dirs := $(MODVERDIR)
|
||||
clean: $(clean-dirs)
|
||||
$(call cmd,rmdirs)
|
||||
@find $(KBUILD_EXTMOD) $(RCS_FIND_IGNORE) \
|
||||
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
|
||||
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
|
||||
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \) \
|
||||
-type f -print | xargs rm -f
|
||||
|
||||
|
||||
+9
-4
@@ -46,15 +46,20 @@ ifneq ($(strip $(DO_INSTALL_LIBS)),n)
|
||||
done
|
||||
endif
|
||||
|
||||
# Not very elegant: copies testsuite to objdir...
|
||||
# (cp -pPR is POSIX-compliant (cp -dpR or cp -a would not be))
|
||||
.PHONY: check
|
||||
.PHONY: test
|
||||
check test: busybox busybox.links
|
||||
bindir=$(objtree) srcdir=$(srctree)/testsuite SED="$(SED)" \
|
||||
$(SHELL) $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)
|
||||
test -d $(objtree)/testsuite || cp -pPR $(srctree)/testsuite $(objtree)
|
||||
bindir=$(objtree) srcdir=$(srctree)/testsuite \
|
||||
$(SHELL) -c "cd $(objtree)/testsuite && $(srctree)/testsuite/runtest $(if $(KBUILD_VERBOSE:0=),-v)"
|
||||
|
||||
.PHONY: release
|
||||
release: distclean
|
||||
cd ..; \
|
||||
rm -r -f busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION); \
|
||||
cp -a busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
|
||||
cp -pPR busybox busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) && { \
|
||||
find busybox-$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)/ -type d \
|
||||
-name .svn \
|
||||
-print \
|
||||
@@ -94,7 +99,7 @@ stksizes: busybox_unstripped
|
||||
|
||||
.PHONY: bigdata
|
||||
bigdata: busybox_unstripped
|
||||
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [tr] '
|
||||
$(CROSS_COMPILE)nm --size-sort busybox_unstripped | grep -vi ' [trw] '
|
||||
|
||||
# Documentation Targets
|
||||
.PHONY: doc
|
||||
|
||||
+43
-28
@@ -11,37 +11,31 @@ CPPFLAGS += $(call cc-option,-std=gnu99,)
|
||||
|
||||
CPPFLAGS += \
|
||||
-Iinclude -Ilibbb \
|
||||
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) -I$(srctree)/libbb \
|
||||
$(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include -I$(srctree)/libbb) \
|
||||
-include include/autoconf.h \
|
||||
-D_GNU_SOURCE -DNDEBUG \
|
||||
$(if $(CONFIG_LFS),-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64) \
|
||||
-D"BB_VER=KBUILD_STR($(BB_VER))" -DBB_BT=AUTOCONF_TIMESTAMP
|
||||
|
||||
# flag checks are grouped together to speed the checks up a bit..
|
||||
CFLAGS += $(call cc-option,-Wall -Wshadow -Wwrite-strings,)
|
||||
CFLAGS += $(call cc-option,-Wundef -Wstrict-prototypes,)
|
||||
# If you want to add "-Wmissing-prototypes -Wmissing-declarations" above
|
||||
# (or anything else for that matter) make sure that it is still possible
|
||||
# to build bbox without warnings. Current offender: find.c:alloc_action().
|
||||
# Looks more like gcc bug: gcc will warn on it with or without prototype.
|
||||
# But still, warning-free compile is a must, or else we will drown
|
||||
# in warnings pretty soon.
|
||||
CFLAGS += $(call cc-option,-Wall,)
|
||||
CFLAGS += $(call cc-option,-Wshadow,)
|
||||
CFLAGS += $(call cc-option,-Wwrite-strings,)
|
||||
CFLAGS += $(call cc-option,-Wundef,)
|
||||
CFLAGS += $(call cc-option,-Wstrict-prototypes,)
|
||||
CFLAGS += $(call cc-option,-Wunused -Wunused-parameter,)
|
||||
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
|
||||
# warn about C99 declaration after statement
|
||||
CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
|
||||
# If you want to add more -Wsomething above, make sure that it is
|
||||
# still possible to build bbox without warnings.
|
||||
|
||||
ifeq ($(CONFIG_WERROR),y)
|
||||
CFLAGS += $(call cc-option,-Werror,)
|
||||
else
|
||||
# for development, warn a little bit about unused results..
|
||||
CPPFLAGS += -D_FORTIFY_SOURCE=2
|
||||
endif
|
||||
# gcc 3.x emits bogus "old style proto" warning on find.c:alloc_action()
|
||||
CFLAGS += $(call cc-ifversion, -ge, 0400, -Wold-style-definition)
|
||||
|
||||
# gcc emits bogus "no prev proto" warning on find.c:alloc_action()
|
||||
ifneq ($(CONFIG_WERROR),y)
|
||||
CFLAGS += $(call cc-option,-Wmissing-prototypes -Wmissing-declarations,)
|
||||
endif
|
||||
|
||||
CFLAGS += $(call cc-option,-Os -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
|
||||
CFLAGS += $(call cc-option,-fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections,)
|
||||
# -fno-guess-branch-probability: prohibit pseudo-random guessing
|
||||
# of branch probabilities (hopefully makes bloatcheck more stable):
|
||||
CFLAGS += $(call cc-option,-fno-guess-branch-probability,)
|
||||
@@ -50,23 +44,41 @@ CFLAGS += $(call cc-option,-falign-functions=1 -falign-jumps=1 -falign-labels=1
|
||||
|
||||
# FIXME: These warnings are at least partially to be concerned about and should
|
||||
# be fixed..
|
||||
#CFLAGS+=$(call cc-option,-Wconversion,)
|
||||
#CFLAGS += $(call cc-option,-Wconversion,)
|
||||
|
||||
ifeq ($(CONFIG_DEBUG),y)
|
||||
CFLAGS += $(call cc-option,-g)
|
||||
ifneq ($(CONFIG_DEBUG),y)
|
||||
CFLAGS += $(call cc-option,-Os,)
|
||||
else
|
||||
CFLAGS += $(call cc-option,-g,)
|
||||
#CFLAGS += "-D_FORTIFY_SOURCE=2"
|
||||
ifeq ($(CONFIG_DEBUG_PESSIMIZE),y)
|
||||
CFLAGS += $(call cc-option,-O0,)
|
||||
else
|
||||
CFLAGS += $(call cc-option,-Os,)
|
||||
endif
|
||||
endif
|
||||
|
||||
# If arch/$(ARCH)/Makefile did not override it (with, say, -fPIC)...
|
||||
ARCH_FPIC ?= -fpic
|
||||
ARCH_FPIE ?= -fpie
|
||||
ARCH_PIE ?= -pie
|
||||
|
||||
ifeq ($(CONFIG_BUILD_LIBBUSYBOX),y)
|
||||
# on i386: 14% smaller libbusybox.so
|
||||
# (code itself is 9% bigger, we save on relocs/PLT/GOT)
|
||||
CFLAGS += -fpic
|
||||
CFLAGS += $(ARCH_FPIC)
|
||||
# and another 4% reduction of libbusybox.so:
|
||||
# (external entry points must be marked EXTERNALLY_VISIBLE)
|
||||
CFLAGS += $(call cc-option,-fvisibility=hidden)
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_STATIC),y)
|
||||
LDFLAGS += -static
|
||||
CFLAGS_busybox += -static
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_PIE),y)
|
||||
CFLAGS_busybox += $(ARCH_PIE)
|
||||
CFLAGS += $(ARCH_FPIE)
|
||||
endif
|
||||
|
||||
LDLIBS += m crypt
|
||||
@@ -87,10 +99,13 @@ ifeq ($(CONFIG_DMALLOC),y)
|
||||
LDLIBS += dmalloc
|
||||
endif
|
||||
|
||||
#LDFLAGS += -nostdlib
|
||||
|
||||
LDFLAGS_ELF2FLT = -Wl,-elf2flt
|
||||
ifneq (,$(findstring $(LDFLAGS_ELF2FLT),$(LDFLAGS)))
|
||||
# If a flat binary should be built, CFLAGS_busybox="-Wl,-elf2flt"
|
||||
# env var should be set for make invocation.
|
||||
# Here we check whether CFLAGS_busybox indeed contains that flag.
|
||||
# (For historical reasons, we also check LDFLAGS, which doesn't
|
||||
# seem to be entirely correct variable to put "-Wl,-elf2flt" into).
|
||||
W_ELF2FLT = -Wl,-elf2flt
|
||||
ifneq (,$(findstring $(W_ELF2FLT),$(LDFLAGS) $(CFLAGS_busybox)))
|
||||
SKIP_STRIP = y
|
||||
endif
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ help:
|
||||
@echo 'Configuration:'
|
||||
@echo ' allnoconfig - disable all symbols in .config'
|
||||
@echo ' allyesconfig - enable all symbols in .config (see defconfig)'
|
||||
@echo ' allbareconfig - enable all applets without any sub-features'
|
||||
@echo ' config - text based configurator (of last resort)'
|
||||
@echo ' defconfig - set .config to largest generic configuration'
|
||||
@echo ' menuconfig - interactive curses-based configurator'
|
||||
|
||||
@@ -82,6 +82,9 @@ Downloading the current source code:
|
||||
is generally a faster way of getting it fixed, and the complete archive of
|
||||
what happened is the subversion changelog.
|
||||
|
||||
Note: if you want to compile busybox in a busybox environment you must
|
||||
select ENABLE_DESKTOP.
|
||||
|
||||
----------------
|
||||
|
||||
getting help:
|
||||
@@ -119,7 +122,7 @@ bugs:
|
||||
illegal instruction
|
||||
|
||||
i am using debian unstable, kernel version 2.4.25-vrs2 on a netwinder,
|
||||
and the latest uclibc from cvs. thanks for the wonderful program!
|
||||
and the latest uclibc from cvs.
|
||||
|
||||
-diligent
|
||||
|
||||
@@ -170,10 +173,8 @@ Portability:
|
||||
you're into that sort of thing, start small (selecting just a few applets)
|
||||
and work your way up.
|
||||
|
||||
Shaun Jackman has recently (2005) ported busybox to a combination of newlib
|
||||
and libgloss, and some of his patches have been integrated. This platform
|
||||
may join glibc/uclibc and Linux as a supported combination with the 1.1
|
||||
release, but is not supported in 1.0.
|
||||
In 2005 Shaun Jackman has ported busybox to a combination of newlib
|
||||
and libgloss, and some of his patches have been integrated.
|
||||
|
||||
Supported hardware:
|
||||
|
||||
@@ -194,5 +195,5 @@ Supported hardware:
|
||||
|
||||
Please feed suggestions, bug reports, insults, and bribes back to the busybox
|
||||
maintainer:
|
||||
Denis Vlasenko
|
||||
Denys Vlasenko
|
||||
<vda.linux@googlemail.com>
|
||||
@@ -6,20 +6,17 @@ do one of these bounce an email off the person it's listed under to see if they
|
||||
have any suggestions how they plan to go about it, and to minimize conflicts
|
||||
between your work and theirs. But otherwise, all of these are fair game.
|
||||
|
||||
Rob Landley <rob@landley.net>:
|
||||
Add BB_NOMMU to platform.h and migrate __uClinux__ tests to that.
|
||||
#if defined __UCLIBC__ && !defined __ARCH_USE_MMU__
|
||||
Rob Landley suggested these:
|
||||
Add a libbb/platform.c
|
||||
Implement fdprintf() for platforms that haven't got one.
|
||||
Implement bb_realpath() that can handle NULL on non-glibc.
|
||||
Cleanup bb_asprintf()
|
||||
|
||||
Migrate calloc() and bb_calloc() occurrences to bb_xzalloc().
|
||||
Remove obsolete _() wrapper crud for internationalization we don't do.
|
||||
Figure out where we need utf8 support, and add it.
|
||||
|
||||
sh
|
||||
The command shell situation is a big mess. We have three or four different
|
||||
The command shell situation is a big mess. We have three different
|
||||
shells that don't really share any code, and the "standalone shell" doesn't
|
||||
work all that well (especially not in a chroot environment), due to apps not
|
||||
being reentrant.
|
||||
@@ -27,11 +24,6 @@ Rob Landley <rob@landley.net>:
|
||||
but less buggy :)
|
||||
init
|
||||
General cleanup (should use ENABLE_FEATURE_INIT_SYSLOG and ENABLE_FEATURE_INIT_DEBUG).
|
||||
depmod
|
||||
busybox lacks a way to update module deps when running from firmware without the
|
||||
use of the depmod.pl (perl is to bloated for most embedded setups) and or orig
|
||||
modutils. The orig depmod is rather pointless to have to add to a firmware image
|
||||
in when we already have a insmod/rmmod and friends.
|
||||
Do a SUSv3 audit
|
||||
Look at the full Single Unix Specification version 3 (available online at
|
||||
"http://www.opengroup.org/onlinepubs/009695399/nfindex.html") and
|
||||
@@ -123,9 +115,6 @@ Bernhard Fischer <busybox@busybox.net> suggests to look at these:
|
||||
|
||||
As yet unclaimed:
|
||||
|
||||
----
|
||||
find
|
||||
doesn't understand (), lots of susv3 stuff.
|
||||
----
|
||||
diff
|
||||
Make sure we handle empty files properly:
|
||||
@@ -143,10 +132,6 @@ patch
|
||||
And while we're at it, a new patch filename quoting format is apparently
|
||||
coming soon: http://marc.theaimsgroup.com/?l=git&m=112927316408690&w=2
|
||||
---
|
||||
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
|
||||
@@ -156,7 +141,7 @@ man
|
||||
(How doclifter might work into this is anybody's guess.)
|
||||
---
|
||||
ar
|
||||
Write support?
|
||||
Write support!
|
||||
---
|
||||
stty / catv
|
||||
stty's visible() function and catv's guts are identical. Merge them into
|
||||
@@ -292,24 +277,22 @@ Minor stuff:
|
||||
---
|
||||
use bb_perror_msg where appropriate: See
|
||||
egrep "[^_]perror"
|
||||
---
|
||||
Remove superfluous fmt occurances: e.g.
|
||||
fprintf(stderr, "%s: %s not found\n", "unalias", *argptr);
|
||||
-> fprintf(stderr, "unalias: %s not found\n", *argptr);
|
||||
---
|
||||
possible code duplication ingroup() and is_a_group_member()
|
||||
---
|
||||
Move __get_hz() to a better place and (re)use it in route.c, ash.c, msh.c
|
||||
---
|
||||
See grep -r strtod
|
||||
Alot of duplication that wants cleanup.
|
||||
---
|
||||
in_ether duplicated in network/{interface,ifconfig}.c
|
||||
---
|
||||
|
||||
|
||||
Code cleanup:
|
||||
|
||||
Replace deprecated functions.
|
||||
|
||||
bzero() -> memset()
|
||||
---
|
||||
sigblock(), siggetmask(), sigsetmask(), sigmask() -> sigprocmask et al
|
||||
---
|
||||
vdprintf() -> similar sized functionality
|
||||
---
|
||||
+181
-104
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.9.0.svn
|
||||
# Mon Dec 24 14:21:28 2007
|
||||
# Busybox version: 1.12.0.svn
|
||||
# Wed Aug 20 00:24:07 2008
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
@@ -12,8 +12,9 @@ CONFIG_HAVE_DOT_CONFIG=y
|
||||
#
|
||||
# General Configuration
|
||||
#
|
||||
CONFIG_NITPICK=y
|
||||
CONFIG_DESKTOP=y
|
||||
# CONFIG_EXTRA_COMPAT is not set
|
||||
CONFIG_FEATURE_ASSUME_UNICODE=y
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
@@ -29,7 +30,7 @@ CONFIG_FEATURE_PIDFILE=y
|
||||
CONFIG_FEATURE_SUID=y
|
||||
CONFIG_FEATURE_SUID_CONFIG=y
|
||||
CONFIG_FEATURE_SUID_CONFIG_QUIET=y
|
||||
# CONFIG_SELINUX is not set
|
||||
CONFIG_SELINUX=y
|
||||
CONFIG_FEATURE_PREFER_APPLETS=y
|
||||
CONFIG_BUSYBOX_EXEC_PATH="/proc/self/exe"
|
||||
CONFIG_FEATURE_SYSLOG=y
|
||||
@@ -39,20 +40,25 @@ CONFIG_FEATURE_HAVE_RPC=y
|
||||
# Build Options
|
||||
#
|
||||
# CONFIG_STATIC is not set
|
||||
# CONFIG_PIE is not set
|
||||
CONFIG_NOMMU=y
|
||||
# CONFIG_BUILD_LIBBUSYBOX is not set
|
||||
# CONFIG_FEATURE_INDIVIDUAL is not set
|
||||
# CONFIG_FEATURE_SHARED_BUSYBOX is not set
|
||||
CONFIG_LFS=y
|
||||
CONFIG_CROSS_COMPILER_PREFIX=""
|
||||
|
||||
#
|
||||
# Debugging Options
|
||||
#
|
||||
# CONFIG_DEBUG is not set
|
||||
CONFIG_WERROR=y
|
||||
# CONFIG_DEBUG_PESSIMIZE is not set
|
||||
# CONFIG_WERROR is not set
|
||||
CONFIG_NO_DEBUG_LIB=y
|
||||
# CONFIG_DMALLOC is not set
|
||||
# CONFIG_EFENCE is not set
|
||||
CONFIG_INCLUDE_SUSv2=y
|
||||
# CONFIG_PARSE is not set
|
||||
|
||||
#
|
||||
# Installation Options
|
||||
@@ -72,20 +78,21 @@ CONFIG_PREFIX="./_install"
|
||||
#
|
||||
CONFIG_PASSWORD_MINLEN=6
|
||||
CONFIG_MD5_SIZE_VS_SPEED=2
|
||||
# CONFIG_FEATURE_FAST_TOP is not set
|
||||
# CONFIG_FEATURE_ETC_NETWORKS is not set
|
||||
CONFIG_FEATURE_FAST_TOP=y
|
||||
CONFIG_FEATURE_ETC_NETWORKS=y
|
||||
CONFIG_FEATURE_EDITING=y
|
||||
CONFIG_FEATURE_EDITING_MAX_LEN=1024
|
||||
# CONFIG_FEATURE_EDITING_FANCY_KEYS is not set
|
||||
# CONFIG_FEATURE_EDITING_VI is not set
|
||||
CONFIG_FEATURE_EDITING_VI=y
|
||||
CONFIG_FEATURE_EDITING_HISTORY=15
|
||||
# CONFIG_FEATURE_EDITING_SAVEHISTORY is not set
|
||||
CONFIG_FEATURE_TAB_COMPLETION=y
|
||||
CONFIG_FEATURE_USERNAME_COMPLETION=y
|
||||
CONFIG_FEATURE_EDITING_FANCY_PROMPT=y
|
||||
CONFIG_FEATURE_VERBOSE_CP_MESSAGE=y
|
||||
CONFIG_FEATURE_COPYBUF_KB=4
|
||||
CONFIG_MONOTONIC_SYSCALL=y
|
||||
CONFIG_IOCTL_HEX2STR_ERROR=y
|
||||
CONFIG_FEATURE_HWIB=y
|
||||
|
||||
#
|
||||
# Applets
|
||||
@@ -94,48 +101,37 @@ CONFIG_IOCTL_HEX2STR_ERROR=y
|
||||
#
|
||||
# Archival Utilities
|
||||
#
|
||||
CONFIG_FEATURE_SEAMLESS_LZMA=y
|
||||
CONFIG_FEATURE_SEAMLESS_BZ2=y
|
||||
CONFIG_FEATURE_SEAMLESS_GZ=y
|
||||
CONFIG_FEATURE_SEAMLESS_Z=y
|
||||
CONFIG_AR=y
|
||||
CONFIG_FEATURE_AR_LONG_FILENAMES=y
|
||||
CONFIG_BUNZIP2=y
|
||||
CONFIG_BZIP2=y
|
||||
CONFIG_CPIO=y
|
||||
CONFIG_FEATURE_CPIO_O=y
|
||||
CONFIG_DPKG=y
|
||||
CONFIG_DPKG_DEB=y
|
||||
# CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY is not set
|
||||
CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY=y
|
||||
CONFIG_GUNZIP=y
|
||||
CONFIG_FEATURE_GUNZIP_UNCOMPRESS=y
|
||||
CONFIG_GZIP=y
|
||||
CONFIG_RPM2CPIO=y
|
||||
CONFIG_RPM=y
|
||||
CONFIG_FEATURE_RPM_BZ2=y
|
||||
CONFIG_TAR=y
|
||||
CONFIG_FEATURE_TAR_CREATE=y
|
||||
CONFIG_FEATURE_TAR_BZIP2=y
|
||||
CONFIG_FEATURE_TAR_LZMA=y
|
||||
CONFIG_FEATURE_TAR_AUTODETECT=y
|
||||
CONFIG_FEATURE_TAR_FROM=y
|
||||
CONFIG_FEATURE_TAR_GZIP=y
|
||||
CONFIG_FEATURE_TAR_COMPRESS=y
|
||||
CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y
|
||||
CONFIG_FEATURE_TAR_OLDSUN_COMPATIBILITY=y
|
||||
CONFIG_FEATURE_TAR_GNU_EXTENSIONS=y
|
||||
CONFIG_FEATURE_TAR_LONG_OPTIONS=y
|
||||
CONFIG_FEATURE_TAR_UNAME_GNAME=y
|
||||
CONFIG_UNCOMPRESS=y
|
||||
CONFIG_UNLZMA=y
|
||||
CONFIG_FEATURE_LZMA_FAST=y
|
||||
CONFIG_UNZIP=y
|
||||
|
||||
#
|
||||
# Common options for cpio and tar
|
||||
#
|
||||
CONFIG_FEATURE_UNARCHIVE_TAPE=y
|
||||
|
||||
#
|
||||
# Common options for dpkg and dpkg_deb
|
||||
#
|
||||
CONFIG_FEATURE_DEB_TAR_GZ=y
|
||||
CONFIG_FEATURE_DEB_TAR_BZ2=y
|
||||
CONFIG_FEATURE_DEB_TAR_LZMA=y
|
||||
|
||||
#
|
||||
# Coreutils
|
||||
#
|
||||
@@ -209,10 +205,12 @@ CONFIG_FEATURE_READLINK_FOLLOW=y
|
||||
CONFIG_REALPATH=y
|
||||
CONFIG_RM=y
|
||||
CONFIG_RMDIR=y
|
||||
CONFIG_FEATURE_RMDIR_LONG_OPTIONS=y
|
||||
CONFIG_SEQ=y
|
||||
CONFIG_SHA1SUM=y
|
||||
CONFIG_SLEEP=y
|
||||
CONFIG_FEATURE_FANCY_SLEEP=y
|
||||
CONFIG_FEATURE_FLOAT_SLEEP=y
|
||||
CONFIG_SORT=y
|
||||
CONFIG_FEATURE_SORT_BIG=y
|
||||
CONFIG_SPLIT=y
|
||||
@@ -222,6 +220,7 @@ CONFIG_FEATURE_STAT_FORMAT=y
|
||||
CONFIG_STTY=y
|
||||
CONFIG_SUM=y
|
||||
CONFIG_SYNC=y
|
||||
CONFIG_TAC=y
|
||||
CONFIG_TAIL=y
|
||||
CONFIG_FEATURE_FANCY_TAIL=y
|
||||
CONFIG_TEE=y
|
||||
@@ -283,8 +282,10 @@ CONFIG_RESIZE=y
|
||||
CONFIG_FEATURE_RESIZE_PRINT=y
|
||||
CONFIG_SETCONSOLE=y
|
||||
CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS=y
|
||||
CONFIG_SETFONT=y
|
||||
CONFIG_SETKEYCODES=y
|
||||
CONFIG_SETLOGCONS=y
|
||||
CONFIG_SHOWKEY=y
|
||||
|
||||
#
|
||||
# Debian Utilities
|
||||
@@ -314,7 +315,7 @@ CONFIG_PATCH=y
|
||||
CONFIG_SED=y
|
||||
CONFIG_VI=y
|
||||
CONFIG_FEATURE_VI_MAX_LEN=4096
|
||||
# CONFIG_FEATURE_VI_8BIT is not set
|
||||
CONFIG_FEATURE_VI_8BIT=y
|
||||
CONFIG_FEATURE_VI_COLON=y
|
||||
CONFIG_FEATURE_VI_YANKMARK=y
|
||||
CONFIG_FEATURE_VI_SEARCH=y
|
||||
@@ -351,7 +352,7 @@ CONFIG_FEATURE_FIND_PRUNE=y
|
||||
CONFIG_FEATURE_FIND_DELETE=y
|
||||
CONFIG_FEATURE_FIND_PATH=y
|
||||
CONFIG_FEATURE_FIND_REGEX=y
|
||||
# CONFIG_FEATURE_FIND_CONTEXT is not set
|
||||
CONFIG_FEATURE_FIND_CONTEXT=y
|
||||
CONFIG_GREP=y
|
||||
CONFIG_FEATURE_GREP_EGREP_ALIAS=y
|
||||
CONFIG_FEATURE_GREP_FGREP_ALIAS=y
|
||||
@@ -365,14 +366,16 @@ CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
|
||||
#
|
||||
# Init Utilities
|
||||
#
|
||||
# CONFIG_INIT is not set
|
||||
CONFIG_INIT=y
|
||||
# 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_FEATURE_USE_INITTAB=y
|
||||
CONFIG_FEATURE_KILL_REMOVED=y
|
||||
CONFIG_FEATURE_KILL_DELAY=1
|
||||
CONFIG_FEATURE_INIT_SCTTY=y
|
||||
CONFIG_FEATURE_INIT_SYSLOG=y
|
||||
CONFIG_FEATURE_EXTRA_QUIET=y
|
||||
CONFIG_FEATURE_INIT_COREDUMPS=y
|
||||
CONFIG_FEATURE_INITRD=y
|
||||
CONFIG_HALT=y
|
||||
CONFIG_MESG=y
|
||||
|
||||
@@ -380,13 +383,16 @@ CONFIG_MESG=y
|
||||
# Login/Password Management Utilities
|
||||
#
|
||||
CONFIG_FEATURE_SHADOWPASSWDS=y
|
||||
CONFIG_USE_BB_SHADOW=y
|
||||
CONFIG_USE_BB_PWD_GRP=y
|
||||
CONFIG_USE_BB_SHADOW=y
|
||||
CONFIG_USE_BB_CRYPT=y
|
||||
CONFIG_ADDGROUP=y
|
||||
CONFIG_FEATURE_ADDUSER_TO_GROUP=y
|
||||
CONFIG_DELGROUP=y
|
||||
CONFIG_FEATURE_DEL_USER_FROM_GROUP=y
|
||||
CONFIG_FEATURE_CHECK_NAMES=y
|
||||
CONFIG_ADDUSER=y
|
||||
CONFIG_FEATURE_ADDUSER_LONG_OPTIONS=y
|
||||
CONFIG_DELUSER=y
|
||||
CONFIG_GETTY=y
|
||||
CONFIG_FEATURE_UTMP=y
|
||||
@@ -394,7 +400,7 @@ CONFIG_FEATURE_WTMP=y
|
||||
CONFIG_LOGIN=y
|
||||
# CONFIG_PAM is not set
|
||||
CONFIG_LOGIN_SCRIPTS=y
|
||||
# CONFIG_FEATURE_NOLOGIN is not set
|
||||
CONFIG_FEATURE_NOLOGIN=y
|
||||
CONFIG_FEATURE_SECURETTY=y
|
||||
CONFIG_PASSWD=y
|
||||
CONFIG_FEATURE_PASSWD_WEAK_CHECK=y
|
||||
@@ -416,25 +422,30 @@ 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_MODPROBE_SMALL=y
|
||||
CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
|
||||
CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
|
||||
# CONFIG_DEPMOD is not set
|
||||
# CONFIG_FEATURE_DEPMOD_PRUNE_FANCY is not set
|
||||
# CONFIG_FEATURE_DEPMOD_ALIAS is not set
|
||||
# CONFIG_INSMOD is not set
|
||||
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
|
||||
# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
|
||||
# CONFIG_RMMOD is not set
|
||||
# CONFIG_LSMOD is not set
|
||||
# CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
|
||||
# CONFIG_MODPROBE is not set
|
||||
# CONFIG_FEATURE_MODPROBE_MULTIPLE_OPTIONS is not set
|
||||
# CONFIG_FEATURE_MODPROBE_FANCY_ALIAS is not set
|
||||
# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
|
||||
# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
|
||||
# CONFIG_FEATURE_2_4_MODULES is not set
|
||||
# CONFIG_FEATURE_2_6_MODULES is not set
|
||||
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
|
||||
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
|
||||
# CONFIG_FEATURE_QUERY_MODULE_INTERFACE is not set
|
||||
|
||||
#
|
||||
@@ -455,6 +466,7 @@ CONFIG_FEATURE_SGI_LABEL=y
|
||||
CONFIG_FEATURE_SUN_LABEL=y
|
||||
CONFIG_FEATURE_OSF_LABEL=y
|
||||
CONFIG_FEATURE_FDISK_ADVANCED=y
|
||||
CONFIG_FINDFS=y
|
||||
CONFIG_FREERAMDISK=y
|
||||
CONFIG_FSCK_MINIX=y
|
||||
CONFIG_MKFS_MINIX=y
|
||||
@@ -465,8 +477,8 @@ CONFIG_MKFS_MINIX=y
|
||||
CONFIG_FEATURE_MINIX2=y
|
||||
CONFIG_GETOPT=y
|
||||
CONFIG_HEXDUMP=y
|
||||
CONFIG_HD=y
|
||||
CONFIG_FEATURE_HEXDUMP_REVERSE=y
|
||||
CONFIG_HD=y
|
||||
CONFIG_HWCLOCK=y
|
||||
CONFIG_FEATURE_HWCLOCK_LONG_OPTIONS=y
|
||||
CONFIG_FEATURE_HWCLOCK_ADJTIME_FHS=y
|
||||
@@ -475,23 +487,49 @@ CONFIG_IPCS=y
|
||||
CONFIG_LOSETUP=y
|
||||
CONFIG_MDEV=y
|
||||
CONFIG_FEATURE_MDEV_CONF=y
|
||||
CONFIG_FEATURE_MDEV_RENAME=y
|
||||
CONFIG_FEATURE_MDEV_RENAME_REGEXP=y
|
||||
CONFIG_FEATURE_MDEV_EXEC=y
|
||||
CONFIG_FEATURE_MDEV_LOAD_FIRMWARE=y
|
||||
CONFIG_MKSWAP=y
|
||||
CONFIG_FEATURE_MKSWAP_V0=y
|
||||
CONFIG_MORE=y
|
||||
CONFIG_FEATURE_USE_TERMIOS=y
|
||||
CONFIG_VOLUMEID=y
|
||||
CONFIG_FEATURE_VOLUMEID_EXT=y
|
||||
CONFIG_FEATURE_VOLUMEID_REISERFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_FAT=y
|
||||
CONFIG_FEATURE_VOLUMEID_HFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_JFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_XFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_NTFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_ISO9660=y
|
||||
CONFIG_FEATURE_VOLUMEID_UDF=y
|
||||
CONFIG_FEATURE_VOLUMEID_LUKS=y
|
||||
CONFIG_FEATURE_VOLUMEID_LINUXSWAP=y
|
||||
CONFIG_FEATURE_VOLUMEID_CRAMFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_ROMFS=y
|
||||
CONFIG_FEATURE_VOLUMEID_SYSV=y
|
||||
CONFIG_FEATURE_VOLUMEID_OCFS2=y
|
||||
CONFIG_FEATURE_VOLUMEID_LINUXRAID=y
|
||||
CONFIG_MOUNT=y
|
||||
CONFIG_FEATURE_MOUNT_FAKE=y
|
||||
CONFIG_FEATURE_MOUNT_VERBOSE=y
|
||||
CONFIG_FEATURE_MOUNT_HELPERS=y
|
||||
CONFIG_FEATURE_MOUNT_LABEL=y
|
||||
CONFIG_FEATURE_MOUNT_NFS=y
|
||||
CONFIG_FEATURE_MOUNT_CIFS=y
|
||||
CONFIG_FEATURE_MOUNT_FLAGS=y
|
||||
CONFIG_FEATURE_MOUNT_FSTAB=y
|
||||
CONFIG_PIVOT_ROOT=y
|
||||
CONFIG_RDATE=y
|
||||
CONFIG_RDEV=y
|
||||
CONFIG_READPROFILE=y
|
||||
CONFIG_RTCWAKE=y
|
||||
CONFIG_SCRIPT=y
|
||||
CONFIG_SETARCH=y
|
||||
CONFIG_SWAPONOFF=y
|
||||
CONFIG_FEATURE_SWAPON_PRI=y
|
||||
CONFIG_SWITCH_ROOT=y
|
||||
CONFIG_UMOUNT=y
|
||||
CONFIG_FEATURE_UMOUNT_ALL=y
|
||||
@@ -506,12 +544,20 @@ CONFIG_FEATURE_MOUNT_LOOP=y
|
||||
# Miscellaneous Utilities
|
||||
#
|
||||
CONFIG_ADJTIMEX=y
|
||||
# CONFIG_BBCONFIG is not set
|
||||
CONFIG_BBCONFIG=y
|
||||
CONFIG_CHAT=y
|
||||
CONFIG_FEATURE_CHAT_NOFAIL=y
|
||||
CONFIG_FEATURE_CHAT_TTY_HIFI=y
|
||||
CONFIG_FEATURE_CHAT_IMPLICIT_CR=y
|
||||
CONFIG_FEATURE_CHAT_SWALLOW_OPTS=y
|
||||
CONFIG_FEATURE_CHAT_SEND_ESCAPES=y
|
||||
CONFIG_FEATURE_CHAT_VAR_ABORT_LEN=y
|
||||
CONFIG_FEATURE_CHAT_CLR_ABORT=y
|
||||
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_CROND=y
|
||||
CONFIG_DEBUG_CROND_OPTION=y
|
||||
CONFIG_FEATURE_CROND_CALL_SENDMAIL=y
|
||||
CONFIG_CRONTAB=y
|
||||
CONFIG_DC=y
|
||||
# CONFIG_DEVFSD is not set
|
||||
# CONFIG_DEVFSD_MODLOAD is not set
|
||||
@@ -519,7 +565,12 @@ CONFIG_DC=y
|
||||
# CONFIG_DEVFSD_VERBOSE is not set
|
||||
# CONFIG_FEATURE_DEVFS is not set
|
||||
CONFIG_EJECT=y
|
||||
CONFIG_FEATURE_EJECT_SCSI=y
|
||||
CONFIG_FBSPLASH=y
|
||||
CONFIG_INOTIFYD=y
|
||||
CONFIG_LAST=y
|
||||
CONFIG_FEATURE_LAST_SMALL=y
|
||||
# CONFIG_FEATURE_LAST_FANCY is not set
|
||||
CONFIG_LESS=y
|
||||
CONFIG_FEATURE_LESS_MAXLINES=9999999
|
||||
CONFIG_FEATURE_LESS_BRACKETS=y
|
||||
@@ -537,6 +588,7 @@ CONFIG_FEATURE_HDPARM_HDIO_GETSET_DMA=y
|
||||
CONFIG_MAKEDEVS=y
|
||||
# CONFIG_FEATURE_MAKEDEVS_LEAF is not set
|
||||
CONFIG_FEATURE_MAKEDEVS_TABLE=y
|
||||
CONFIG_MAN=y
|
||||
CONFIG_MICROCOM=y
|
||||
CONFIG_MOUNTPOINT=y
|
||||
CONFIG_MT=y
|
||||
@@ -544,8 +596,8 @@ CONFIG_RAIDAUTORUN=y
|
||||
CONFIG_READAHEAD=y
|
||||
CONFIG_RUNLEVEL=y
|
||||
CONFIG_RX=y
|
||||
CONFIG_STRINGS=y
|
||||
CONFIG_SETSID=y
|
||||
CONFIG_STRINGS=y
|
||||
CONFIG_TASKSET=y
|
||||
CONFIG_FEATURE_TASKSET_FANCY=y
|
||||
CONFIG_TIME=y
|
||||
@@ -560,6 +612,9 @@ CONFIG_FEATURE_PREFER_IPV4_ADDRESS=y
|
||||
CONFIG_VERBOSE_RESOLUTION_ERRORS=y
|
||||
CONFIG_ARP=y
|
||||
CONFIG_ARPING=y
|
||||
CONFIG_BRCTL=y
|
||||
CONFIG_FEATURE_BRCTL_FANCY=y
|
||||
CONFIG_FEATURE_BRCTL_SHOW=y
|
||||
CONFIG_DNSD=y
|
||||
CONFIG_ETHER_WAKE=y
|
||||
CONFIG_FAKEIDENTD=y
|
||||
@@ -587,22 +642,23 @@ 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_IFUPDOWN_IFSTATE_PATH=""
|
||||
# CONFIG_FEATURE_IFUPDOWN_IP is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN is not set
|
||||
CONFIG_IFENSLAVE=y
|
||||
CONFIG_IFUPDOWN=y
|
||||
CONFIG_IFUPDOWN_IFSTATE_PATH="/var/run/ifstate"
|
||||
CONFIG_FEATURE_IFUPDOWN_IP=y
|
||||
CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN=y
|
||||
# CONFIG_FEATURE_IFUPDOWN_IFCONFIG_BUILTIN is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IPV4 is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_IPV6 is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_MAPPING is not set
|
||||
# CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP is not set
|
||||
# CONFIG_INETD is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME is not set
|
||||
# CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN is not set
|
||||
# CONFIG_FEATURE_INETD_RPC is not set
|
||||
CONFIG_FEATURE_IFUPDOWN_IPV4=y
|
||||
CONFIG_FEATURE_IFUPDOWN_IPV6=y
|
||||
CONFIG_FEATURE_IFUPDOWN_MAPPING=y
|
||||
CONFIG_FEATURE_IFUPDOWN_EXTERNAL_DHCP=y
|
||||
CONFIG_INETD=y
|
||||
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_ECHO=y
|
||||
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DISCARD=y
|
||||
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_TIME=y
|
||||
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_DAYTIME=y
|
||||
CONFIG_FEATURE_INETD_SUPPORT_BUILTIN_CHARGEN=y
|
||||
CONFIG_FEATURE_INETD_RPC=y
|
||||
CONFIG_IP=y
|
||||
CONFIG_FEATURE_IP_ADDRESS=y
|
||||
CONFIG_FEATURE_IP_LINK=y
|
||||
@@ -626,12 +682,15 @@ CONFIG_NC_SERVER=y
|
||||
CONFIG_NC_EXTRA=y
|
||||
CONFIG_NETSTAT=y
|
||||
CONFIG_FEATURE_NETSTAT_WIDE=y
|
||||
CONFIG_FEATURE_NETSTAT_PRG=y
|
||||
CONFIG_NSLOOKUP=y
|
||||
CONFIG_PING=y
|
||||
CONFIG_PING6=y
|
||||
CONFIG_PSCAN=y
|
||||
CONFIG_FEATURE_FANCY_PING=y
|
||||
CONFIG_PSCAN=y
|
||||
CONFIG_ROUTE=y
|
||||
CONFIG_SENDMAIL=y
|
||||
CONFIG_FETCHMAIL=y
|
||||
CONFIG_SLATTACH=y
|
||||
CONFIG_TELNET=y
|
||||
CONFIG_FEATURE_TELNET_TTYPE=y
|
||||
@@ -639,10 +698,11 @@ CONFIG_FEATURE_TELNET_AUTOLOGIN=y
|
||||
CONFIG_TELNETD=y
|
||||
CONFIG_FEATURE_TELNETD_STANDALONE=y
|
||||
CONFIG_TFTP=y
|
||||
CONFIG_TFTPD=y
|
||||
CONFIG_FEATURE_TFTP_GET=y
|
||||
CONFIG_FEATURE_TFTP_PUT=y
|
||||
CONFIG_FEATURE_TFTP_BLOCKSIZE=y
|
||||
# CONFIG_DEBUG_TFTP is not set
|
||||
CONFIG_DEBUG_TFTP=y
|
||||
CONFIG_TRACEROUTE=y
|
||||
CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
|
||||
CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE=y
|
||||
@@ -651,10 +711,13 @@ CONFIG_APP_UDHCPD=y
|
||||
CONFIG_APP_DHCPRELAY=y
|
||||
CONFIG_APP_DUMPLEASES=y
|
||||
CONFIG_FEATURE_UDHCPD_WRITE_LEASES_EARLY=y
|
||||
CONFIG_DHCPD_LEASES_FILE="/var/lib/misc/udhcpd.leases"
|
||||
CONFIG_APP_UDHCPC=y
|
||||
CONFIG_FEATURE_UDHCPC_ARPING=y
|
||||
CONFIG_FEATURE_UDHCP_PORT=y
|
||||
CONFIG_FEATURE_UDHCP_DEBUG=y
|
||||
CONFIG_FEATURE_RFC3397=y
|
||||
CONFIG_DHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
|
||||
CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80
|
||||
CONFIG_VCONFIG=y
|
||||
CONFIG_WGET=y
|
||||
@@ -662,6 +725,8 @@ CONFIG_FEATURE_WGET_STATUSBAR=y
|
||||
CONFIG_FEATURE_WGET_AUTHENTICATION=y
|
||||
CONFIG_FEATURE_WGET_LONG_OPTIONS=y
|
||||
CONFIG_ZCIP=y
|
||||
CONFIG_TCPSVD=y
|
||||
CONFIG_UDPSVD=y
|
||||
|
||||
#
|
||||
# Process Utilities
|
||||
@@ -679,6 +744,8 @@ CONFIG_FEATURE_PIDOF_OMIT=y
|
||||
CONFIG_PKILL=y
|
||||
CONFIG_PS=y
|
||||
CONFIG_FEATURE_PS_WIDE=y
|
||||
CONFIG_FEATURE_PS_TIME=y
|
||||
CONFIG_FEATURE_PS_UNUSUAL_SYSTEMS=y
|
||||
CONFIG_RENICE=y
|
||||
CONFIG_BB_SYSCTL=y
|
||||
CONFIG_TOP=y
|
||||
@@ -697,6 +764,7 @@ CONFIG_WATCH=y
|
||||
# CONFIG_FEATURE_SH_IS_MSH is not set
|
||||
CONFIG_FEATURE_SH_IS_NONE=y
|
||||
# CONFIG_ASH is not set
|
||||
# CONFIG_ASH_BASH_COMPAT is not set
|
||||
# CONFIG_ASH_JOB_CONTROL is not set
|
||||
# CONFIG_ASH_READ_NCHARS is not set
|
||||
# CONFIG_ASH_READ_TIMEOUT is not set
|
||||
@@ -705,6 +773,7 @@ CONFIG_FEATURE_SH_IS_NONE=y
|
||||
# CONFIG_ASH_MATH_SUPPORT_64 is not set
|
||||
# CONFIG_ASH_GETOPTS is not set
|
||||
# CONFIG_ASH_BUILTIN_ECHO is not set
|
||||
# CONFIG_ASH_BUILTIN_PRINTF is not set
|
||||
# CONFIG_ASH_BUILTIN_TEST is not set
|
||||
# CONFIG_ASH_CMDCMD is not set
|
||||
# CONFIG_ASH_MAIL is not set
|
||||
@@ -713,11 +782,12 @@ CONFIG_FEATURE_SH_IS_NONE=y
|
||||
# CONFIG_ASH_EXPAND_PRMT is not set
|
||||
CONFIG_HUSH=y
|
||||
CONFIG_HUSH_HELP=y
|
||||
# CONFIG_HUSH_INTERACTIVE is not set
|
||||
# CONFIG_HUSH_JOB is not set
|
||||
CONFIG_HUSH_INTERACTIVE=y
|
||||
CONFIG_HUSH_JOB=y
|
||||
CONFIG_HUSH_TICK=y
|
||||
CONFIG_HUSH_IF=y
|
||||
CONFIG_HUSH_LOOPS=y
|
||||
CONFIG_HUSH_CASE=y
|
||||
CONFIG_LASH=y
|
||||
CONFIG_MSH=y
|
||||
|
||||
@@ -726,6 +796,7 @@ CONFIG_MSH=y
|
||||
#
|
||||
CONFIG_FEATURE_SH_EXTRA_QUIET=y
|
||||
CONFIG_FEATURE_SH_STANDALONE=y
|
||||
CONFIG_FEATURE_SH_NOFORK=y
|
||||
CONFIG_CTTYHACK=y
|
||||
|
||||
#
|
||||
@@ -734,6 +805,7 @@ CONFIG_CTTYHACK=y
|
||||
CONFIG_SYSLOGD=y
|
||||
CONFIG_FEATURE_ROTATE_LOGFILE=y
|
||||
CONFIG_FEATURE_REMOTE_LOG=y
|
||||
CONFIG_FEATURE_SYSLOGD_DUP=y
|
||||
CONFIG_FEATURE_IPC_SYSLOG=y
|
||||
CONFIG_FEATURE_IPC_SYSLOG_BUFFER_SIZE=16
|
||||
CONFIG_LOGREAD=y
|
||||
@@ -744,33 +816,38 @@ CONFIG_LOGGER=y
|
||||
#
|
||||
# Runit Utilities
|
||||
#
|
||||
# CONFIG_RUNSV is not set
|
||||
CONFIG_RUNSV=y
|
||||
CONFIG_RUNSVDIR=y
|
||||
CONFIG_SV=y
|
||||
# CONFIG_SVLOGD is not set
|
||||
CONFIG_SVLOGD=y
|
||||
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_RESTORECON is not set
|
||||
# CONFIG_RUNCON is not set
|
||||
# CONFIG_FEATURE_RUNCON_LONG_OPTIONS is not set
|
||||
# CONFIG_SELINUXENABLED is not set
|
||||
# CONFIG_SETENFORCE is not set
|
||||
# CONFIG_SETFILES is not set
|
||||
# CONFIG_FEATURE_SETFILES_CHECK_OPTION is not set
|
||||
# CONFIG_SETSEBOOL is not set
|
||||
# CONFIG_SESTATUS is not set
|
||||
|
||||
#
|
||||
# ipsvd utilities
|
||||
# Selinux Utilities
|
||||
#
|
||||
# CONFIG_TCPSVD is not set
|
||||
# CONFIG_UDPSVD is not set
|
||||
CONFIG_CHCON=y
|
||||
CONFIG_FEATURE_CHCON_LONG_OPTIONS=y
|
||||
CONFIG_GETENFORCE=y
|
||||
CONFIG_GETSEBOOL=y
|
||||
CONFIG_LOAD_POLICY=y
|
||||
CONFIG_MATCHPATHCON=y
|
||||
CONFIG_RESTORECON=y
|
||||
CONFIG_RUNCON=y
|
||||
CONFIG_FEATURE_RUNCON_LONG_OPTIONS=y
|
||||
CONFIG_SELINUXENABLED=y
|
||||
CONFIG_SETENFORCE=y
|
||||
CONFIG_SETFILES=y
|
||||
CONFIG_FEATURE_SETFILES_CHECK_OPTION=y
|
||||
CONFIG_SETSEBOOL=y
|
||||
CONFIG_SESTATUS=y
|
||||
|
||||
#
|
||||
# Print Utilities
|
||||
#
|
||||
CONFIG_LPD=y
|
||||
CONFIG_LPR=y
|
||||
CONFIG_LPQ=y
|
||||
+17
-6
@@ -32,7 +32,7 @@ struct bb_applet {
|
||||
/* Define struct bb_applet applets[] */
|
||||
#include "../include/applets.h"
|
||||
|
||||
enum { NUM_APPLETS = sizeof(applets)/sizeof(applets[0]) };
|
||||
enum { NUM_APPLETS = ARRAY_SIZE(applets) };
|
||||
|
||||
static int offset[NUM_APPLETS];
|
||||
|
||||
@@ -47,6 +47,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int ofs;
|
||||
unsigned MAX_APPLET_NAME_LEN = 1;
|
||||
|
||||
qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name);
|
||||
|
||||
@@ -69,15 +70,23 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Keep in sync with include/busybox.h! */
|
||||
|
||||
puts("/* This is a generated file, don't edit */");
|
||||
puts("/* This is a generated file, don't edit */\n");
|
||||
|
||||
puts("const char applet_names[] ALIGN1 =");
|
||||
printf("#define NUM_APPLETS %u\n", NUM_APPLETS);
|
||||
if (NUM_APPLETS == 1) {
|
||||
printf("#define SINGLE_APPLET_STR \"%s\"\n", applets[0].name);
|
||||
printf("#define SINGLE_APPLET_MAIN %s_main\n", applets[0].name);
|
||||
}
|
||||
|
||||
puts("\nconst char applet_names[] ALIGN1 = \"\"");
|
||||
for (i = 0; i < NUM_APPLETS; i++) {
|
||||
printf("\"%s\" \"\\0\"\n", applets[i].name);
|
||||
if (MAX_APPLET_NAME_LEN < strlen(applets[i].name))
|
||||
MAX_APPLET_NAME_LEN = strlen(applets[i].name);
|
||||
}
|
||||
puts(";");
|
||||
|
||||
puts("int (*const applet_main[])(int argc, char **argv) = {");
|
||||
puts("\nint (*const applet_main[])(int argc, char **argv) = {");
|
||||
for (i = 0; i < NUM_APPLETS; i++) {
|
||||
printf("%s_main,\n", applets[i].main);
|
||||
}
|
||||
@@ -92,7 +101,7 @@ int main(int argc, char **argv)
|
||||
+ (applets[i].noexec << 13)
|
||||
#endif
|
||||
#if ENABLE_FEATURE_SUID
|
||||
+ (applets[i].need_suid << 14) /* 2 bits */
|
||||
+ (applets[i].need_suid << 14) /* 2 bits */
|
||||
#endif
|
||||
);
|
||||
}
|
||||
@@ -108,8 +117,10 @@ int main(int argc, char **argv)
|
||||
printf("0x%02x,\n", v);
|
||||
i++;
|
||||
}
|
||||
puts("};");
|
||||
puts("};\n");
|
||||
#endif
|
||||
|
||||
printf("#define MAX_APPLET_NAME_LEN %u\n", MAX_APPLET_NAME_LEN);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+2
-13
@@ -10,20 +10,9 @@
|
||||
#include <assert.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Apparently uclibc defines __GLIBC__ (compat trick?). Oh well. */
|
||||
#if ENABLE_STATIC && defined(__GLIBC__) && !defined(__UCLIBC__)
|
||||
#warning Static linking against glibc produces buggy executables
|
||||
#warning (glibc does not cope well with ld --gc-sections).
|
||||
#warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
|
||||
#warning Note that glibc is unsuitable for static linking anyway.
|
||||
#warning If you still want to do it, remove -Wl,--gc-sections
|
||||
#warning from scripts/trylink and remove this warning.
|
||||
#error Aborting compilation.
|
||||
#endif
|
||||
|
||||
#if ENABLE_BUILD_LIBBUSYBOX
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
return lbb_main(argc, argv);
|
||||
return lbb_main(argv);
|
||||
}
|
||||
#endif
|
||||
@@ -14,13 +14,11 @@ const char *applet_name;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
applet_name = argv[0];
|
||||
|
||||
return APPLET_main(argc,argv);
|
||||
}
|
||||
|
||||
void bb_show_usage(void)
|
||||
{
|
||||
printf(APPLET_full_usage "\n");
|
||||
|
||||
exit(1);
|
||||
fputs(APPLET_full_usage "\n", stdout);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
+1
-1
@@ -37,7 +37,7 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
|
||||
for i in $DO_INSTALL_LIBS; do
|
||||
rm -f $prefix/$libdir/$i || exit 1
|
||||
if [ -f $i ]; then
|
||||
cp -a $i $prefix/$libdir/ || exit 1
|
||||
cp -pPR $i $prefix/$libdir/ || exit 1
|
||||
chmod 0644 $prefix/$libdir/$i || exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
+12
-1
@@ -5,6 +5,17 @@
|
||||
* object directory */
|
||||
#include "../include/autoconf.h"
|
||||
|
||||
/* Since we can't use platform.h, have to do this again by hand: */
|
||||
#if ENABLE_NOMMU
|
||||
#define BB_MMU 0
|
||||
#define USE_FOR_NOMMU(...) __VA_ARGS__
|
||||
#define USE_FOR_MMU(...)
|
||||
#else
|
||||
#define BB_MMU 1
|
||||
#define USE_FOR_NOMMU(...)
|
||||
#define USE_FOR_MMU(...) __VA_ARGS__
|
||||
#endif
|
||||
|
||||
static const char usage_messages[] = ""
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
@@ -13,6 +24,6 @@ static const char usage_messages[] = ""
|
||||
|
||||
int main(void)
|
||||
{
|
||||
write(1, usage_messages, sizeof(usage_messages));
|
||||
write(STDOUT_FILENO, usage_messages, sizeof(usage_messages));
|
||||
return 0;
|
||||
}
|
||||
@@ -12,8 +12,23 @@ sz=`"$loc/usage" | wc -c` || exit 1
|
||||
|
||||
exec >"$target"
|
||||
|
||||
echo 'static const char packed_usage[] ALIGN1 = '
|
||||
echo 'static const char packed_usage[] ALIGN1 = {'
|
||||
|
||||
## Breaks on big-endian systems!
|
||||
## # Extra effort to avoid using "od -t x1": -t is not available
|
||||
## # in non-CONFIG_DESKTOPed busybox od
|
||||
##
|
||||
## "$loc/usage" | bzip2 -1 | od -v -x \
|
||||
## | $SED -e 's/^[^ ]*//' \
|
||||
## | $SED -e 's/ //g' \
|
||||
## | grep -v '^$' \
|
||||
## | $SED -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
|
||||
|
||||
"$loc/usage" | bzip2 -1 | od -v -t x1 \
|
||||
| $SED -e 's/^[^ ]*//' -e 's/ *\(..\)/\\x\1/g' -e 's/^\(.*\)$/"\1"/'
|
||||
echo ';'
|
||||
| $SED -e 's/^[^ ]*//' \
|
||||
| $SED -e 's/ //g' \
|
||||
| grep -v '^$' \
|
||||
| $SED -e 's/\(..\)/0x\1,/g'
|
||||
|
||||
echo '};'
|
||||
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
|
||||
+81
-116
@@ -5,12 +5,36 @@
|
||||
|
||||
menu "Archival Utilities"
|
||||
|
||||
config FEATURE_SEAMLESS_LZMA
|
||||
bool "Make tar, rpm, modprobe etc understand .lzma data"
|
||||
default n
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .lzma data.
|
||||
|
||||
config FEATURE_SEAMLESS_BZ2
|
||||
bool "Make tar, rpm, modprobe etc understand .bz2 data"
|
||||
default n
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .bz2 data.
|
||||
|
||||
config FEATURE_SEAMLESS_GZ
|
||||
bool "Make tar, rpm, modprobe etc understand .gz data"
|
||||
default n
|
||||
help
|
||||
Make tar, rpm, modprobe etc understand .gz data.
|
||||
|
||||
config FEATURE_SEAMLESS_Z
|
||||
bool "Make tar and gunzip understand .Z data"
|
||||
default n
|
||||
help
|
||||
Make tar and gunzip understand .Z data.
|
||||
|
||||
config AR
|
||||
bool "ar"
|
||||
default n
|
||||
help
|
||||
ar is an archival utility program used to create, modify, and
|
||||
extract contents from archives. An archive is a single file holding
|
||||
extract contents from archives. An archive is a single file holding
|
||||
a collection of other files in a structure that makes it possible to
|
||||
retrieve the original individual files (called archive members).
|
||||
The original files' contents, mode (permissions), timestamp, owner,
|
||||
@@ -29,12 +53,12 @@ config AR
|
||||
probably say N here.
|
||||
|
||||
config FEATURE_AR_LONG_FILENAMES
|
||||
bool "Enable support for long filenames (not need for debs)"
|
||||
bool "Support for long filenames (not need for debs)"
|
||||
default n
|
||||
depends on AR
|
||||
help
|
||||
By default the ar format can only store the first 15 characters of the
|
||||
filename, this option removes that limitation.
|
||||
By default the ar format can only store the first 15 characters of
|
||||
the filename, this option removes that limitation.
|
||||
It supports the GNU ar long filename method which moves multiple long
|
||||
filenames into a the data section of a new ar entry.
|
||||
|
||||
@@ -43,7 +67,7 @@ config BUNZIP2
|
||||
default n
|
||||
help
|
||||
bunzip2 is a compression utility using the Burrows-Wheeler block
|
||||
sorting text compression algorithm, and Huffman coding. Compression
|
||||
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.
|
||||
@@ -56,7 +80,7 @@ config BZIP2
|
||||
default n
|
||||
help
|
||||
bzip2 is a compression utility using the Burrows-Wheeler block
|
||||
sorting text compression algorithm, and Huffman coding. Compression
|
||||
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.
|
||||
@@ -68,44 +92,55 @@ config CPIO
|
||||
bool "cpio"
|
||||
default n
|
||||
help
|
||||
cpio is an archival utility program used to create, modify, and extract
|
||||
contents from archives.
|
||||
cpio is an archival utility program used to create, modify, and
|
||||
extract contents from archives.
|
||||
cpio has 110 bytes of overheads for every stored file.
|
||||
|
||||
This implementation of cpio can extract cpio archives created in the
|
||||
"newc" or "crc" format, it cannot create or modify them.
|
||||
|
||||
Unless you have a specific application which requires cpio, you should
|
||||
probably say N here.
|
||||
Unless you have a specific application which requires cpio, you
|
||||
should probably say N here.
|
||||
|
||||
config FEATURE_CPIO_O
|
||||
bool "Support for archive creation"
|
||||
default n
|
||||
depends on CPIO
|
||||
help
|
||||
This implementation of cpio can create cpio archives in the "newc"
|
||||
format only.
|
||||
|
||||
config DPKG
|
||||
bool "dpkg"
|
||||
default n
|
||||
help
|
||||
dpkg is a medium-level tool to install, build, remove and manage Debian packages.
|
||||
dpkg is a medium-level tool to install, build, remove and manage
|
||||
Debian packages.
|
||||
|
||||
This implementation of dpkg has a number of limitations, you should use the
|
||||
official dpkg if possible.
|
||||
This implementation of dpkg has a number of limitations,
|
||||
you should use the official dpkg if possible.
|
||||
|
||||
config DPKG_DEB
|
||||
bool "dpkg_deb"
|
||||
default n
|
||||
help
|
||||
dpkg-deb packs, unpacks and provides information about Debian archives.
|
||||
dpkg-deb packs, unpacks and provides information about Debian
|
||||
archives.
|
||||
|
||||
This implementation of dpkg-deb cannot pack archives.
|
||||
|
||||
Unless you have a specific application which requires dpkg-deb, you should
|
||||
probably say N here.
|
||||
Unless you have a specific application which requires dpkg-deb,
|
||||
say N here.
|
||||
|
||||
config FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
bool "extract only (-x)"
|
||||
bool "Extract only (-x)"
|
||||
default n
|
||||
depends on DPKG_DEB
|
||||
help
|
||||
This reduces dpkg-deb to the equivalent of "ar -p <deb> data.tar.gz | tar -zx".
|
||||
However it saves space as none of the extra dpkg-deb, ar or tar options are
|
||||
needed, they are linked to internally.
|
||||
This reduces dpkg-deb to the equivalent of
|
||||
"ar -p <deb> data.tar.gz | tar -zx". However it saves space as none
|
||||
of the extra dpkg-deb, ar or tar options are needed, they are linked
|
||||
to internally.
|
||||
|
||||
config GUNZIP
|
||||
bool "gunzip"
|
||||
@@ -115,15 +150,6 @@ config GUNZIP
|
||||
You can use the `-t' option to test the integrity of
|
||||
an archive, without decompressing it.
|
||||
|
||||
config FEATURE_GUNZIP_UNCOMPRESS
|
||||
bool "Uncompress support"
|
||||
default n
|
||||
depends on GUNZIP
|
||||
help
|
||||
Enable if you want gunzip to have the ability to decompress
|
||||
archives created by the program compress (not much
|
||||
used anymore).
|
||||
|
||||
config GZIP
|
||||
bool "gzip"
|
||||
default n
|
||||
@@ -143,13 +169,6 @@ 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
|
||||
@@ -158,6 +177,8 @@ config TAR
|
||||
create compressed archives. It's probably the most widely used
|
||||
UNIX archive program.
|
||||
|
||||
if TAR
|
||||
|
||||
config FEATURE_TAR_CREATE
|
||||
bool "Enable archive creation"
|
||||
default y
|
||||
@@ -166,21 +187,13 @@ config FEATURE_TAR_CREATE
|
||||
If you enable this option you'll be able to create
|
||||
tar archives using the `-c' option.
|
||||
|
||||
config FEATURE_TAR_BZIP2
|
||||
bool "Enable -j option to handle .tar.bz2 files"
|
||||
config FEATURE_TAR_AUTODETECT
|
||||
bool "Autodetect gz/bz2 compressed tarballs"
|
||||
default n
|
||||
depends on TAR
|
||||
depends on FEATURE_SEAMLESS_Z || FEATURE_SEAMLESS_GZ || FEATURE_SEAMLESS_BZ2 || FEATURE_SEAMLESS_LZMA
|
||||
help
|
||||
If you enable this option you'll be able to extract
|
||||
archives compressed with bzip2.
|
||||
|
||||
config FEATURE_TAR_LZMA
|
||||
bool "Enable -a option to handle .tar.lzma files"
|
||||
default n
|
||||
depends on TAR
|
||||
help
|
||||
If you enable this option you'll be able to extract
|
||||
archives compressed with lzma.
|
||||
With this option tar can automatically detect gzip/bzip2 compressed
|
||||
tarballs. Currently it works only on files (not pipes etc).
|
||||
|
||||
config FEATURE_TAR_FROM
|
||||
bool "Enable -X (exclude from) and -T (include from) options)"
|
||||
@@ -190,24 +203,8 @@ config FEATURE_TAR_FROM
|
||||
If you enable this option you'll be able to specify
|
||||
a list of files to include or exclude from an archive.
|
||||
|
||||
config FEATURE_TAR_GZIP
|
||||
bool "Enable -z option"
|
||||
default y
|
||||
depends on TAR
|
||||
help
|
||||
If you enable this option tar will be able to call gzip,
|
||||
when creating or extracting tar gziped archives.
|
||||
|
||||
config FEATURE_TAR_COMPRESS
|
||||
bool "Enable -Z option"
|
||||
default n
|
||||
depends on TAR
|
||||
help
|
||||
If you enable this option tar will be able to call uncompress,
|
||||
when extracting .tar.Z archives.
|
||||
|
||||
config FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
bool "Enable support for old tar header format"
|
||||
bool "Support for old tar header format"
|
||||
default N
|
||||
depends on TAR
|
||||
help
|
||||
@@ -221,11 +218,12 @@ config FEATURE_TAR_OLDSUN_COMPATIBILITY
|
||||
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.
|
||||
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"
|
||||
bool "Support for GNU tar extensions (long filenames)"
|
||||
default y
|
||||
depends on TAR
|
||||
help
|
||||
@@ -237,7 +235,18 @@ config FEATURE_TAR_LONG_OPTIONS
|
||||
default n
|
||||
depends on TAR && GETOPT_LONG
|
||||
help
|
||||
Enable use of long options, increases size by about 400 Bytes
|
||||
Enable use of long options, increases size by about 400 Bytes
|
||||
|
||||
config FEATURE_TAR_UNAME_GNAME
|
||||
bool "Enable use of user and group names"
|
||||
default n
|
||||
depends on TAR
|
||||
help
|
||||
Enables use of user and group names in tar. This affects contents
|
||||
listings (-t) and preserving permissions when unpacking (-p).
|
||||
+200 bytes.
|
||||
|
||||
endif #tar
|
||||
|
||||
config UNCOMPRESS
|
||||
bool "uncompress"
|
||||
@@ -251,7 +260,7 @@ config UNLZMA
|
||||
default n
|
||||
help
|
||||
unlzma is a compression utility using the Lempel-Ziv-Markov chain
|
||||
compression algorithm, and range coding. Compression
|
||||
compression algorithm, and range coding. Compression
|
||||
is generally considerably better than that achieved by the bzip2
|
||||
compressors.
|
||||
|
||||
@@ -262,7 +271,7 @@ config UNLZMA
|
||||
should probably say N here.
|
||||
|
||||
config FEATURE_LZMA_FAST
|
||||
bool "Optimze unlzma for speed"
|
||||
bool "Optimize unlzma for speed"
|
||||
default n
|
||||
depends on UNLZMA
|
||||
help
|
||||
@@ -279,48 +288,4 @@ config UNZIP
|
||||
current directory. Use the `-d' option to extract to a
|
||||
directory of your choice.
|
||||
|
||||
comment "Common options for cpio and tar"
|
||||
depends on CPIO || TAR
|
||||
|
||||
config FEATURE_UNARCHIVE_TAPE
|
||||
bool "Enable tape drive support"
|
||||
default n
|
||||
depends on CPIO || TAR
|
||||
help
|
||||
I don't think this is needed anymore.
|
||||
|
||||
comment "Common options for dpkg and dpkg_deb"
|
||||
depends on DPKG || DPKG_DEB
|
||||
|
||||
config FEATURE_DEB_TAR_GZ
|
||||
bool "gzip debian packages (normal)"
|
||||
default y if DPKG || DPKG_DEB
|
||||
depends on DPKG || DPKG_DEB
|
||||
help
|
||||
This is the default compression method inside the debian ar file.
|
||||
|
||||
If you want compatibility with standard .deb's you should say yes here.
|
||||
|
||||
config FEATURE_DEB_TAR_BZ2
|
||||
bool "bzip2 debian packages"
|
||||
default n
|
||||
depends on DPKG || DPKG_DEB
|
||||
help
|
||||
This allows dpkg and dpkg-deb to extract deb's that are compressed internally
|
||||
with bzip2 instead of gzip.
|
||||
|
||||
You only want this if you are creating your own custom debian packages that
|
||||
use an internal control.tar.bz2 or data.tar.bz2.
|
||||
|
||||
config FEATURE_DEB_TAR_LZMA
|
||||
bool "lzma debian packages"
|
||||
default n
|
||||
depends on DPKG || DPKG_DEB
|
||||
help
|
||||
This allows dpkg and dpkg-deb to extract deb's that are compressed
|
||||
internally with lzma instead of gzip.
|
||||
|
||||
You only want this if you are creating your own custom debian
|
||||
packages that use an internal control.tar.lzma or data.tar.lzma.
|
||||
|
||||
endmenu
|
||||
+3
-11
@@ -16,7 +16,7 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
static void header_verbose_list_ar(const file_header_t *file_header)
|
||||
static void FAST_FUNC header_verbose_list_ar(const file_header_t *file_header)
|
||||
{
|
||||
const char *mode = bb_mode_string(file_header->mode);
|
||||
char *mtime;
|
||||
@@ -45,7 +45,6 @@ int ar_main(int argc, char **argv)
|
||||
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned opt;
|
||||
char magic[8];
|
||||
|
||||
archive_handle = init_handle();
|
||||
|
||||
@@ -63,7 +62,7 @@ int ar_main(int argc, char **argv)
|
||||
archive_handle->action_data = data_extract_all;
|
||||
}
|
||||
if (opt & AR_OPT_PRESERVE_DATE) {
|
||||
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
|
||||
archive_handle->ah_flags |= ARCHIVE_PRESERVE_DATE;
|
||||
}
|
||||
if (opt & AR_OPT_VERBOSE) {
|
||||
archive_handle->action_header = header_verbose_list_ar;
|
||||
@@ -82,14 +81,7 @@ int ar_main(int argc, char **argv)
|
||||
llist_add_to(&(archive_handle->accept), argv[optind++]);
|
||||
}
|
||||
|
||||
xread(archive_handle->src_fd, magic, 7);
|
||||
if (strncmp(magic, "!<arch>", 7) != 0) {
|
||||
bb_error_msg_and_die("invalid ar magic");
|
||||
}
|
||||
archive_handle->offset += 7;
|
||||
|
||||
while (get_header_ar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
unpack_ar_archive(archive_handle);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+32
-12
@@ -28,7 +28,7 @@ int open_to_or_warn(int to_fd, const char *filename, int flags, int mode)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bbunpack(char **argv,
|
||||
int FAST_FUNC bbunpack(char **argv,
|
||||
char* (*make_new_name)(char *filename),
|
||||
USE_DESKTOP(long long) int (*unpacker)(void)
|
||||
)
|
||||
@@ -73,6 +73,12 @@ int bbunpack(char **argv,
|
||||
bb_error_msg("%s: unknown suffix - ignored", filename);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* -f: overwrite existing output files */
|
||||
if (option_mask32 & OPT_FORCE) {
|
||||
unlink(new_name);
|
||||
}
|
||||
|
||||
/* 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,
|
||||
@@ -155,11 +161,11 @@ char* make_new_name_bunzip2(char *filename)
|
||||
static
|
||||
USE_DESKTOP(long long) int unpack_bunzip2(void)
|
||||
{
|
||||
return unpack_bz2_stream(STDIN_FILENO, STDOUT_FILENO);
|
||||
return unpack_bz2_stream_prime(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
|
||||
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int bunzip2_main(int argc, char **argv)
|
||||
int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cfvdt");
|
||||
argv += optind;
|
||||
@@ -212,8 +218,8 @@ char* make_new_name_gunzip(char *filename)
|
||||
|
||||
extension++;
|
||||
if (strcmp(extension, "tgz" + 1) == 0
|
||||
#if ENABLE_FEATURE_GUNZIP_UNCOMPRESS
|
||||
|| strcmp(extension, "Z") == 0
|
||||
#if ENABLE_FEATURE_SEAMLESS_Z
|
||||
|| (extension[0] == 'Z' && extension[1] == '\0')
|
||||
#endif
|
||||
) {
|
||||
extension[-1] = '\0';
|
||||
@@ -238,8 +244,8 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
|
||||
unsigned char magic2;
|
||||
|
||||
magic2 = xread_char(STDIN_FILENO);
|
||||
if (ENABLE_FEATURE_GUNZIP_UNCOMPRESS && magic2 == 0x9d) {
|
||||
status = uncompress(STDIN_FILENO, STDOUT_FILENO);
|
||||
if (ENABLE_FEATURE_SEAMLESS_Z && magic2 == 0x9d) {
|
||||
status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO);
|
||||
} else if (magic2 == 0x8b) {
|
||||
status = unpack_gz_stream(STDIN_FILENO, STDOUT_FILENO);
|
||||
} else {
|
||||
@@ -256,10 +262,24 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* Linux kernel build uses gzip -d -n. We accept and ignore it.
|
||||
* Man page says:
|
||||
* -n --no-name
|
||||
* gzip: do not save the original file name and time stamp.
|
||||
* (The original name is always saved if the name had to be truncated.)
|
||||
* gunzip: do not restore the original file name/time even if present
|
||||
* (remove only the gzip suffix from the compressed file name).
|
||||
* This option is the default when decompressing.
|
||||
* -N --name
|
||||
* gzip: always save the original file name and time stamp (this is the default)
|
||||
* gunzip: restore the original file name and time stamp if present.
|
||||
*/
|
||||
|
||||
int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int gunzip_main(int argc, char **argv)
|
||||
int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cfvdt");
|
||||
getopt32(argv, "cfvdtn");
|
||||
argv += optind;
|
||||
/* if called as zcat */
|
||||
if (applet_name[1] == 'c')
|
||||
@@ -295,7 +315,7 @@ USE_DESKTOP(long long) int unpack_unlzma(void)
|
||||
}
|
||||
|
||||
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int unlzma_main(int argc, char **argv)
|
||||
int unlzma_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cf");
|
||||
argv += optind;
|
||||
@@ -331,13 +351,13 @@ USE_DESKTOP(long long) int unpack_uncompress(void)
|
||||
if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) {
|
||||
bb_error_msg("invalid magic");
|
||||
} else {
|
||||
status = uncompress(STDIN_FILENO, STDOUT_FILENO);
|
||||
status = unpack_Z_stream(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int uncompress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int uncompress_main(int argc, char **argv)
|
||||
int uncompress_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cf");
|
||||
argv += optind;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
This file is an abridged version of README from bizp2 1.0.4
|
||||
This file is an abridged version of README from bzip2 1.0.4
|
||||
Build instructions (which are not relevant to busyboxed bzip2)
|
||||
are removed.
|
||||
===========================================================
|
||||
|
||||
@@ -33,7 +33,7 @@ typedef unsigned char Bool;
|
||||
#define False ((Bool)0)
|
||||
|
||||
#if BZ_LIGHT_DEBUG
|
||||
static void bz_assert_fail(int errcode) ATTRIBUTE_NORETURN;
|
||||
static void bz_assert_fail(int errcode) NORETURN;
|
||||
#define AssertH(cond, errcode) \
|
||||
do { \
|
||||
if (!(cond)) \
|
||||
@@ -170,7 +170,7 @@ typedef struct EState {
|
||||
|
||||
/* map of bytes used in block */
|
||||
int32_t nInUse;
|
||||
Bool inUse[256] __attribute__(( aligned(sizeof(long)) ));
|
||||
Bool inUse[256] ALIGNED(sizeof(long));
|
||||
uint8_t unseqToSeq[256];
|
||||
|
||||
/* stuff for coding the MTF values */
|
||||
|
||||
+4
-4
@@ -141,7 +141,7 @@ char* make_new_name_bzip2(char *filename)
|
||||
}
|
||||
|
||||
int bzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int bzip2_main(int argc, char **argv)
|
||||
int bzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
unsigned opt;
|
||||
|
||||
@@ -162,11 +162,11 @@ int bzip2_main(int argc, char **argv)
|
||||
|
||||
opt_complementary = "s2"; /* -s means -2 (compatibility) */
|
||||
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
|
||||
opt = getopt32(argv, "cfv" USE_BUNZIP2("d") "123456789qzs" );
|
||||
opt = getopt32(argv, "cfv" USE_BUNZIP2("dt") "123456789qzs");
|
||||
#if ENABLE_BUNZIP2 /* bunzip2_main may not be visible... */
|
||||
if (opt & 0x8) // -d
|
||||
if (opt & 0x18) // -d and/or -t
|
||||
return bunzip2_main(argc, argv);
|
||||
opt >>= 4;
|
||||
opt >>= 5;
|
||||
#else
|
||||
opt >>= 3;
|
||||
#endif
|
||||
|
||||
+286
-21
@@ -7,35 +7,296 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
* Limitations:
|
||||
* Doesn't check CRC's
|
||||
* Only supports new ASCII and CRC formats
|
||||
* Doesn't check CRC's
|
||||
* Only supports new ASCII and CRC formats
|
||||
*
|
||||
*/
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define CPIO_OPT_EXTRACT 0x01
|
||||
#define CPIO_OPT_TEST 0x02
|
||||
#define CPIO_OPT_UNCONDITIONAL 0x04
|
||||
#define CPIO_OPT_VERBOSE 0x08
|
||||
#define CPIO_OPT_FILE 0x10
|
||||
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
|
||||
#define CPIO_OPT_PRESERVE_MTIME 0x40
|
||||
#if ENABLE_FEATURE_CPIO_O
|
||||
static off_t cpio_pad4(off_t size)
|
||||
{
|
||||
int i;
|
||||
|
||||
i = (- size) & 3;
|
||||
size += i;
|
||||
while (--i >= 0)
|
||||
bb_putchar('\0');
|
||||
return size;
|
||||
}
|
||||
|
||||
/* Return value will become exit code.
|
||||
* It's ok to exit instead of return. */
|
||||
static int cpio_o(void)
|
||||
{
|
||||
struct name_s {
|
||||
struct name_s *next;
|
||||
char name[1];
|
||||
};
|
||||
struct inodes_s {
|
||||
struct inodes_s *next;
|
||||
struct name_s *names;
|
||||
struct stat st;
|
||||
};
|
||||
|
||||
struct inodes_s *links = NULL;
|
||||
off_t bytes = 0; /* output bytes count */
|
||||
|
||||
while (1) {
|
||||
const char *name;
|
||||
char *line;
|
||||
struct stat st;
|
||||
|
||||
line = xmalloc_fgetline(stdin);
|
||||
|
||||
if (line) {
|
||||
/* Strip leading "./[./]..." from the filename */
|
||||
name = line;
|
||||
while (name[0] == '.' && name[1] == '/') {
|
||||
while (*++name == '/')
|
||||
continue;
|
||||
}
|
||||
if (!*name) { /* line is empty */
|
||||
free(line);
|
||||
continue;
|
||||
}
|
||||
if (lstat(name, &st)) {
|
||||
abort_cpio_o:
|
||||
bb_simple_perror_msg_and_die(name);
|
||||
}
|
||||
|
||||
if (!(S_ISLNK(st.st_mode) || S_ISREG(st.st_mode)))
|
||||
st.st_size = 0; /* paranoia */
|
||||
|
||||
/* Store hardlinks for later processing, dont output them */
|
||||
if (!S_ISDIR(st.st_mode) && st.st_nlink > 1) {
|
||||
struct name_s *n;
|
||||
struct inodes_s *l;
|
||||
|
||||
/* Do we have this hardlink remembered? */
|
||||
l = links;
|
||||
while (1) {
|
||||
if (l == NULL) {
|
||||
/* Not found: add new item to "links" list */
|
||||
l = xzalloc(sizeof(*l));
|
||||
l->st = st;
|
||||
l->next = links;
|
||||
links = l;
|
||||
break;
|
||||
}
|
||||
if (l->st.st_ino == st.st_ino) {
|
||||
/* found */
|
||||
break;
|
||||
}
|
||||
l = l->next;
|
||||
}
|
||||
/* Add new name to "l->names" list */
|
||||
n = xmalloc(sizeof(*n) + strlen(name));
|
||||
strcpy(n->name, name);
|
||||
n->next = l->names;
|
||||
l->names = n;
|
||||
|
||||
free(line);
|
||||
continue;
|
||||
}
|
||||
|
||||
} else { /* line == NULL: EOF */
|
||||
next_link:
|
||||
if (links) {
|
||||
/* Output hardlink's data */
|
||||
st = links->st;
|
||||
name = links->names->name;
|
||||
links->names = links->names->next;
|
||||
/* GNU cpio is reported to emit file data
|
||||
* only for the last instance. Mimic that. */
|
||||
if (links->names == NULL)
|
||||
links = links->next;
|
||||
else
|
||||
st.st_size = 0;
|
||||
/* NB: we leak links->names and/or links,
|
||||
* this is intended (we exit soon anyway) */
|
||||
} else {
|
||||
/* If no (more) hardlinks to output,
|
||||
* output "trailer" entry */
|
||||
name = "TRAILER!!!";
|
||||
/* st.st_size == 0 is a must, but for uniformity
|
||||
* in the output, we zero out everything */
|
||||
memset(&st, 0, sizeof(st));
|
||||
/* st.st_nlink = 1; - GNU cpio does this */
|
||||
}
|
||||
}
|
||||
|
||||
bytes += printf("070701"
|
||||
"%08X%08X%08X%08X%08X%08X%08X"
|
||||
"%08X%08X%08X%08X" /* GNU cpio uses uppercase hex */
|
||||
/* strlen+1: */ "%08X"
|
||||
/* chksum: */ "00000000" /* (only for "070702" files) */
|
||||
/* name,NUL: */ "%s%c",
|
||||
(unsigned)(uint32_t) st.st_ino,
|
||||
(unsigned)(uint32_t) st.st_mode,
|
||||
(unsigned)(uint32_t) st.st_uid,
|
||||
(unsigned)(uint32_t) st.st_gid,
|
||||
(unsigned)(uint32_t) st.st_nlink,
|
||||
(unsigned)(uint32_t) st.st_mtime,
|
||||
(unsigned)(uint32_t) st.st_size,
|
||||
(unsigned)(uint32_t) major(st.st_dev),
|
||||
(unsigned)(uint32_t) minor(st.st_dev),
|
||||
(unsigned)(uint32_t) major(st.st_rdev),
|
||||
(unsigned)(uint32_t) minor(st.st_rdev),
|
||||
(unsigned)(strlen(name) + 1),
|
||||
name, '\0');
|
||||
bytes = cpio_pad4(bytes);
|
||||
|
||||
if (st.st_size) {
|
||||
if (S_ISLNK(st.st_mode)) {
|
||||
char *lpath = xmalloc_readlink_or_warn(name);
|
||||
if (!lpath)
|
||||
goto abort_cpio_o;
|
||||
bytes += printf("%s", lpath);
|
||||
free(lpath);
|
||||
} else { /* S_ISREG */
|
||||
int fd = xopen(name, O_RDONLY);
|
||||
fflush(stdout);
|
||||
/* We must abort if file got shorter too! */
|
||||
bb_copyfd_exact_size(fd, STDOUT_FILENO, st.st_size);
|
||||
bytes += st.st_size;
|
||||
close(fd);
|
||||
}
|
||||
bytes = cpio_pad4(bytes);
|
||||
}
|
||||
|
||||
if (!line) {
|
||||
if (links)
|
||||
goto next_link;
|
||||
/* TODO: GNU cpio pads trailer to 512 bytes, do we want that? */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
free(line);
|
||||
} /* end of "while (1)" */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* GNU cpio 2.9 --help (abridged):
|
||||
|
||||
Modes:
|
||||
-i, --extract Extract files from an archive
|
||||
-o, --create Create the archive
|
||||
-p, --pass-through Copy-pass mode [was ist das?!]
|
||||
-t, --list List the archive
|
||||
|
||||
Options valid in any mode:
|
||||
--block-size=SIZE I/O block size = SIZE * 512 bytes
|
||||
-B I/O block size = 5120 bytes
|
||||
-c Use the old portable (ASCII) archive format
|
||||
-C, --io-size=NUMBER I/O block size in bytes
|
||||
-f, --nonmatching Only copy files that do not match given pattern
|
||||
-F, --file=FILE Use FILE instead of standard input or output
|
||||
-H, --format=FORMAT Use given archive FORMAT
|
||||
-M, --message=STRING Print STRING when the end of a volume of the
|
||||
backup media is reached
|
||||
-n, --numeric-uid-gid If -v, show numeric UID and GID
|
||||
--quiet Do not print the number of blocks copied
|
||||
--rsh-command=COMMAND Use remote COMMAND instead of rsh
|
||||
-v, --verbose Verbosely list the files processed
|
||||
-V, --dot Print a "." for each file processed
|
||||
-W, --warning=FLAG Control warning display: 'none','truncate','all';
|
||||
multiple options accumulate
|
||||
|
||||
Options valid only in --extract mode:
|
||||
-b, --swap Swap both halfwords of words and bytes of
|
||||
halfwords in the data (equivalent to -sS)
|
||||
-r, --rename Interactively rename files
|
||||
-s, --swap-bytes Swap the bytes of each halfword in the files
|
||||
-S, --swap-halfwords Swap the halfwords of each word (4 bytes)
|
||||
--to-stdout Extract files to standard output
|
||||
-E, --pattern-file=FILE Read additional patterns specifying filenames to
|
||||
extract or list from FILE
|
||||
--only-verify-crc Verify CRC's, don't actually extract the files
|
||||
|
||||
Options valid only in --create mode:
|
||||
-A, --append Append to an existing archive
|
||||
-O FILE File to use instead of standard output
|
||||
|
||||
Options valid only in --pass-through mode:
|
||||
-l, --link Link files instead of copying them, when possible
|
||||
|
||||
Options valid in --extract and --create modes:
|
||||
--absolute-filenames Do not strip file system prefix components from
|
||||
the file names
|
||||
--no-absolute-filenames Create all files relative to the current dir
|
||||
|
||||
Options valid in --create and --pass-through modes:
|
||||
-0, --null A list of filenames is terminated by a NUL
|
||||
-a, --reset-access-time Reset the access times of files after reading them
|
||||
-I FILE File to use instead of standard input
|
||||
-L, --dereference Dereference symbolic links (copy the files
|
||||
that they point to instead of copying the links)
|
||||
-R, --owner=[USER][:.][GROUP] Set owner of created files
|
||||
|
||||
Options valid in --extract and --pass-through modes:
|
||||
-d, --make-directories Create leading directories where needed
|
||||
-m, --preserve-modification-time Retain mtime when creating files
|
||||
--no-preserve-owner Do not change the ownership of the files
|
||||
--sparse Write files with blocks of zeros as sparse files
|
||||
-u, --unconditional Replace all files unconditionally
|
||||
*/
|
||||
|
||||
int cpio_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int cpio_main(int argc, char **argv)
|
||||
int cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
char *cpio_filename = NULL;
|
||||
char *cpio_filename;
|
||||
USE_FEATURE_CPIO_O(const char *cpio_fmt = "";)
|
||||
unsigned opt;
|
||||
enum {
|
||||
CPIO_OPT_EXTRACT = (1 << 0),
|
||||
CPIO_OPT_TEST = (1 << 1),
|
||||
CPIO_OPT_UNCONDITIONAL = (1 << 2),
|
||||
CPIO_OPT_VERBOSE = (1 << 3),
|
||||
CPIO_OPT_FILE = (1 << 4),
|
||||
CPIO_OPT_CREATE_LEADING_DIR = (1 << 5),
|
||||
CPIO_OPT_PRESERVE_MTIME = (1 << 6),
|
||||
CPIO_OPT_CREATE = (1 << 7),
|
||||
CPIO_OPT_FORMAT = (1 << 8),
|
||||
};
|
||||
|
||||
/* Initialise */
|
||||
#if ENABLE_GETOPT_LONG
|
||||
applet_long_options =
|
||||
"extract\0" No_argument "i"
|
||||
"list\0" No_argument "t"
|
||||
#if ENABLE_FEATURE_CPIO_O
|
||||
"create\0" No_argument "o"
|
||||
"format\0" Required_argument "H"
|
||||
#endif
|
||||
;
|
||||
#endif
|
||||
|
||||
/* Initialize */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->src_fd = STDIN_FILENO;
|
||||
archive_handle->seek = seek_by_read;
|
||||
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
|
||||
archive_handle->ah_flags = ARCHIVE_EXTRACT_NEWER;
|
||||
|
||||
#if ENABLE_FEATURE_CPIO_O
|
||||
opt = getopt32(argv, "ituvF:dmoH:", &cpio_filename, &cpio_fmt);
|
||||
|
||||
if (opt & CPIO_OPT_CREATE) {
|
||||
if (*cpio_fmt != 'n')
|
||||
bb_show_usage();
|
||||
if (opt & CPIO_OPT_FILE) {
|
||||
fclose(stdout);
|
||||
stdout = fopen_for_write(cpio_filename);
|
||||
/* Paranoia: I don't trust libc that much */
|
||||
xdup2(fileno(stdout), STDOUT_FILENO);
|
||||
}
|
||||
return cpio_o();
|
||||
}
|
||||
#else
|
||||
opt = getopt32(argv, "ituvF:dm", &cpio_filename);
|
||||
#endif
|
||||
argv += optind;
|
||||
|
||||
/* One of either extract or test options must be given */
|
||||
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
|
||||
@@ -53,8 +314,8 @@ int cpio_main(int argc, char **argv)
|
||||
archive_handle->action_data = data_extract_all;
|
||||
}
|
||||
if (opt & CPIO_OPT_UNCONDITIONAL) {
|
||||
archive_handle->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
archive_handle->flags &= ~ARCHIVE_EXTRACT_NEWER;
|
||||
archive_handle->ah_flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
archive_handle->ah_flags &= ~ARCHIVE_EXTRACT_NEWER;
|
||||
}
|
||||
if (opt & CPIO_OPT_VERBOSE) {
|
||||
if (archive_handle->action_header == header_list) {
|
||||
@@ -63,21 +324,25 @@ int cpio_main(int argc, char **argv)
|
||||
archive_handle->action_header = header_list;
|
||||
}
|
||||
}
|
||||
if (cpio_filename) { /* CPIO_OPT_FILE */
|
||||
if (opt & CPIO_OPT_FILE) { /* -F */
|
||||
archive_handle->src_fd = xopen(cpio_filename, O_RDONLY);
|
||||
archive_handle->seek = seek_by_jump;
|
||||
}
|
||||
if (opt & CPIO_OPT_CREATE_LEADING_DIR) {
|
||||
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
|
||||
archive_handle->ah_flags |= ARCHIVE_CREATE_LEADING_DIRS;
|
||||
}
|
||||
if (opt & CPIO_OPT_PRESERVE_MTIME) {
|
||||
archive_handle->ah_flags |= ARCHIVE_PRESERVE_DATE;
|
||||
}
|
||||
|
||||
while (optind < argc) {
|
||||
while (*argv) {
|
||||
archive_handle->filter = filter_accept_list;
|
||||
llist_add_to(&(archive_handle->accept), argv[optind]);
|
||||
optind++;
|
||||
llist_add_to(&(archive_handle->accept), *argv);
|
||||
argv++;
|
||||
}
|
||||
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+132
-111
@@ -75,10 +75,21 @@ typedef struct status_node_s {
|
||||
unsigned status:16; /* was:14 */ /* has to fit STATUS_HASH_PRIME */
|
||||
} status_node_t;
|
||||
|
||||
/* Were statically declared here, but such a big bss is nommu-unfriendly */
|
||||
static char **name_hashtable; /* [NAME_HASH_PRIME + 1] */
|
||||
static common_node_t **package_hashtable; /* [PACKAGE_HASH_PRIME + 1] */
|
||||
static status_node_t **status_hashtable; /* [STATUS_HASH_PRIME + 1] */
|
||||
|
||||
/* Globals */
|
||||
struct globals {
|
||||
char *name_hashtable[NAME_HASH_PRIME + 1];
|
||||
common_node_t *package_hashtable[PACKAGE_HASH_PRIME + 1];
|
||||
status_node_t *status_hashtable[STATUS_HASH_PRIME + 1];
|
||||
};
|
||||
#define G (*ptr_to_globals)
|
||||
#define name_hashtable (G.name_hashtable )
|
||||
#define package_hashtable (G.package_hashtable)
|
||||
#define status_hashtable (G.status_hashtable )
|
||||
#define INIT_G() do { \
|
||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/* Even numbers are for 'extras', like ored dependencies or null */
|
||||
enum edge_type_e {
|
||||
@@ -124,7 +135,7 @@ static void make_hash(const char *key, unsigned *start, unsigned *decrement, con
|
||||
* shift amount is mod 24 because long int is 32 bit and data
|
||||
* to be shifted is 8, don't want to shift data to where it has
|
||||
* no effect*/
|
||||
hash_num += ((key[i] + key[i-1]) << ((key[i] * i) % 24));
|
||||
hash_num += (key[i] + key[i-1]) << ((key[i] * i) % 24);
|
||||
}
|
||||
*start = (unsigned) hash_num % hash_prime;
|
||||
*decrement = (unsigned) 1 + (hash_num % (hash_prime - 1));
|
||||
@@ -133,8 +144,8 @@ static void make_hash(const char *key, unsigned *start, unsigned *decrement, con
|
||||
/* this adds the key to the hash table */
|
||||
static int search_name_hashtable(const char *key)
|
||||
{
|
||||
unsigned probe_address = 0;
|
||||
unsigned probe_decrement = 0;
|
||||
unsigned probe_address;
|
||||
unsigned probe_decrement;
|
||||
|
||||
make_hash(key, &probe_address, &probe_decrement, NAME_HASH_PRIME);
|
||||
while (name_hashtable[probe_address] != NULL) {
|
||||
@@ -155,8 +166,8 @@ static int search_name_hashtable(const char *key)
|
||||
*/
|
||||
static unsigned search_status_hashtable(const char *key)
|
||||
{
|
||||
unsigned probe_address = 0;
|
||||
unsigned probe_decrement = 0;
|
||||
unsigned probe_address;
|
||||
unsigned probe_decrement;
|
||||
|
||||
make_hash(key, &probe_address, &probe_decrement, STATUS_HASH_PRIME);
|
||||
while (status_hashtable[probe_address] != NULL) {
|
||||
@@ -312,11 +323,10 @@ static int test_version(const unsigned version1, const unsigned version2, const
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
static int search_package_hashtable(const unsigned name, const unsigned version, const unsigned operator)
|
||||
{
|
||||
unsigned probe_address = 0;
|
||||
unsigned probe_decrement = 0;
|
||||
unsigned probe_address;
|
||||
unsigned probe_decrement;
|
||||
|
||||
make_hash(name_hashtable[name], &probe_address, &probe_decrement, PACKAGE_HASH_PRIME);
|
||||
while (package_hashtable[probe_address] != NULL) {
|
||||
@@ -372,9 +382,8 @@ static int search_for_provides(int needle, int start_at)
|
||||
*/
|
||||
static void add_edge_to_node(common_node_t *node, edge_t *edge)
|
||||
{
|
||||
node->num_of_edges++;
|
||||
node->edge = xrealloc(node->edge, sizeof(edge_t) * (node->num_of_edges + 1));
|
||||
node->edge[node->num_of_edges - 1] = edge;
|
||||
node->edge = xrealloc_vector(node->edge, 2, node->num_of_edges);
|
||||
node->edge[node->num_of_edges++] = edge;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -410,10 +419,10 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
|
||||
if ((edge_type == EDGE_DEPENDS || edge_type == EDGE_PRE_DEPENDS)
|
||||
&& (strcmp(field, field2) != 0)
|
||||
) {
|
||||
or_edge = xmalloc(sizeof(edge_t));
|
||||
or_edge = xzalloc(sizeof(edge_t));
|
||||
or_edge->type = edge_type + 1;
|
||||
or_edge->name = search_name_hashtable(field);
|
||||
or_edge->version = 0; // tracks the number of alternatives
|
||||
//or_edge->version = 0; // tracks the number of alternatives
|
||||
add_edge_to_node(parent_node, or_edge);
|
||||
}
|
||||
|
||||
@@ -439,17 +448,13 @@ static void add_split_dependencies(common_node_t *parent_node, const char *whole
|
||||
if (offset_ch > 0) {
|
||||
if (strncmp(version, "=", offset_ch) == 0) {
|
||||
edge->operator = VER_EQUAL;
|
||||
}
|
||||
else if (strncmp(version, "<<", offset_ch) == 0) {
|
||||
} else if (strncmp(version, "<<", offset_ch) == 0) {
|
||||
edge->operator = VER_LESS;
|
||||
}
|
||||
else if (strncmp(version, "<=", offset_ch) == 0) {
|
||||
} else if (strncmp(version, "<=", offset_ch) == 0) {
|
||||
edge->operator = VER_LESS_EQUAL;
|
||||
}
|
||||
else if (strncmp(version, ">>", offset_ch) == 0) {
|
||||
} else if (strncmp(version, ">>", offset_ch) == 0) {
|
||||
edge->operator = VER_MORE;
|
||||
}
|
||||
else if (strncmp(version, ">=", offset_ch) == 0) {
|
||||
} else if (strncmp(version, ">=", offset_ch) == 0) {
|
||||
edge->operator = VER_MORE_EQUAL;
|
||||
} else {
|
||||
bb_error_msg_and_die("illegal operator");
|
||||
@@ -602,7 +607,7 @@ 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;
|
||||
}
|
||||
|
||||
field_num = index_in_strings(field_names, field_name);
|
||||
@@ -735,7 +740,6 @@ static const char *describe_status(int status_num)
|
||||
return "is not installed or flagged to be installed";
|
||||
}
|
||||
|
||||
|
||||
static void index_status_file(const char *filename)
|
||||
{
|
||||
FILE *status_file;
|
||||
@@ -744,8 +748,8 @@ static void index_status_file(const char *filename)
|
||||
status_node_t *status_node = NULL;
|
||||
unsigned status_num;
|
||||
|
||||
status_file = xfopen(filename, "r");
|
||||
while ((control_buffer = xmalloc_fgets_str(status_file, "\n\n")) != NULL) {
|
||||
status_file = xfopen_for_read(filename);
|
||||
while ((control_buffer = xmalloc_fgetline_str(status_file, "\n\n")) != NULL) {
|
||||
const unsigned package_num = fill_package_struct(control_buffer);
|
||||
if (package_num != -1) {
|
||||
status_node = xmalloc(sizeof(status_node_t));
|
||||
@@ -786,8 +790,8 @@ static void write_buffer_no_status(FILE *new_status_file, const char *control_bu
|
||||
/* This could do with a cleanup */
|
||||
static void write_status_file(deb_file_t **deb_file)
|
||||
{
|
||||
FILE *old_status_file = xfopen("/var/lib/dpkg/status", "r");
|
||||
FILE *new_status_file = xfopen("/var/lib/dpkg/status.udeb", "w");
|
||||
FILE *old_status_file = xfopen_for_read("/var/lib/dpkg/status");
|
||||
FILE *new_status_file = xfopen_for_write("/var/lib/dpkg/status.udeb");
|
||||
char *package_name;
|
||||
char *status_from_file;
|
||||
char *control_buffer = NULL;
|
||||
@@ -798,7 +802,7 @@ static void write_status_file(deb_file_t **deb_file)
|
||||
int i = 0;
|
||||
|
||||
/* Update previously known packages */
|
||||
while ((control_buffer = xmalloc_fgets_str(old_status_file, "\n\n")) != NULL) {
|
||||
while ((control_buffer = xmalloc_fgetline_str(old_status_file, "\n\n")) != NULL) {
|
||||
tmp_string = strstr(control_buffer, "Package:");
|
||||
if (tmp_string == NULL) {
|
||||
continue;
|
||||
@@ -913,20 +917,16 @@ static void write_status_file(deb_file_t **deb_file)
|
||||
fclose(old_status_file);
|
||||
fclose(new_status_file);
|
||||
|
||||
|
||||
/* Create a separate backfile to dpkg */
|
||||
if (rename("/var/lib/dpkg/status", "/var/lib/dpkg/status.udeb.bak") == -1) {
|
||||
struct stat stat_buf;
|
||||
xstat("/var/lib/dpkg/status", &stat_buf);
|
||||
if (errno != ENOENT)
|
||||
bb_error_msg_and_die("cannot create backup status file");
|
||||
/* Its ok if renaming the status file fails because status
|
||||
* file doesnt exist, maybe we are starting from scratch */
|
||||
bb_error_msg("no status file found, creating new one");
|
||||
}
|
||||
|
||||
if (rename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status") == -1) {
|
||||
bb_error_msg_and_die("DANGER: cannot create status file, "
|
||||
"you need to manually repair your status file");
|
||||
}
|
||||
xrename("/var/lib/dpkg/status.udeb", "/var/lib/dpkg/status");
|
||||
}
|
||||
|
||||
/* This function returns TRUE if the given package can satisfy a
|
||||
@@ -953,7 +953,7 @@ static int package_satisfies_dependency(int package, int depend_type)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count - ?? */)
|
||||
{
|
||||
int *conflicts = NULL;
|
||||
int conflicts_num = 0;
|
||||
@@ -971,7 +971,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
* installed package for conflicts*/
|
||||
while (deb_file[i] != NULL) {
|
||||
const unsigned package_num = deb_file[i]->package;
|
||||
conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1));
|
||||
conflicts = xrealloc_vector(conflicts, 2, conflicts_num);
|
||||
conflicts[conflicts_num] = package_num;
|
||||
conflicts_num++;
|
||||
/* add provides to conflicts list */
|
||||
@@ -988,7 +988,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
new_node->version = package_hashtable[package_num]->edge[j]->version;
|
||||
package_hashtable[conflicts_package_num] = new_node;
|
||||
}
|
||||
conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1));
|
||||
conflicts = xrealloc_vector(conflicts, 2, conflicts_num);
|
||||
conflicts[conflicts_num] = conflicts_package_num;
|
||||
conflicts_num++;
|
||||
}
|
||||
@@ -1156,27 +1156,25 @@ static int check_deps(deb_file_t **deb_file, int deb_start, int dep_max_count)
|
||||
static char **create_list(const char *filename)
|
||||
{
|
||||
FILE *list_stream;
|
||||
char **file_list = NULL;
|
||||
char *line = NULL;
|
||||
int count = 0;
|
||||
char **file_list;
|
||||
char *line;
|
||||
int count;
|
||||
|
||||
/* don't use [xw]fopen here, handle error ourself */
|
||||
list_stream = fopen(filename, "r");
|
||||
list_stream = fopen_for_read(filename);
|
||||
if (list_stream == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while ((line = xmalloc_getline(list_stream)) != NULL) {
|
||||
file_list = xrealloc(file_list, sizeof(char *) * (count + 2));
|
||||
file_list[count] = line;
|
||||
count++;
|
||||
file_list = NULL;
|
||||
count = 0;
|
||||
while ((line = xmalloc_fgetline(list_stream)) != NULL) {
|
||||
file_list = xrealloc_vector(file_list, 2, count);
|
||||
file_list[count++] = line;
|
||||
/*file_list[count] = NULL; - xrealloc_vector did it */
|
||||
}
|
||||
fclose(list_stream);
|
||||
|
||||
if (count == 0) {
|
||||
return NULL;
|
||||
}
|
||||
file_list[count] = NULL;
|
||||
return file_list;
|
||||
}
|
||||
|
||||
@@ -1213,24 +1211,54 @@ static int remove_file_array(char **remove_names, char **exclude_names)
|
||||
return (remove_flag == 0);
|
||||
}
|
||||
|
||||
static int run_package_script(const char *package_name, const char *script_type)
|
||||
static void run_package_script_or_die(const char *package_name, const char *script_type)
|
||||
{
|
||||
struct stat path_stat;
|
||||
char *script_path;
|
||||
int result;
|
||||
|
||||
script_path = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, script_type);
|
||||
|
||||
/* If the file doesnt exist is isnt a fatal */
|
||||
result = lstat(script_path, &path_stat) < 0 ? EXIT_SUCCESS : system(script_path);
|
||||
/* If the file doesnt exist is isnt fatal */
|
||||
result = access(script_path, F_OK) ? EXIT_SUCCESS : system(script_path);
|
||||
free(script_path);
|
||||
return result;
|
||||
if (result)
|
||||
bb_error_msg_and_die("%s failed, exit code %d", script_type, result);
|
||||
}
|
||||
|
||||
/*
|
||||
The policy manual defines what scripts get called when and with
|
||||
what arguments. I realize that busybox does not support all of
|
||||
these scenarios, but it does support some of them; it does not,
|
||||
however, run them with any parameters in run_package_script_or_die().
|
||||
Here are the scripts:
|
||||
|
||||
preinst install
|
||||
preinst install <old_version>
|
||||
preinst upgrade <old_version>
|
||||
preinst abort_upgrade <new_version>
|
||||
postinst configure <most_recent_version>
|
||||
postinst abort-upgade <new_version>
|
||||
postinst abort-remove
|
||||
postinst abort-remove in-favour <package> <version>
|
||||
postinst abort-deconfigure in-favor <failed_install_package> removing <conflicting_package> <version>
|
||||
prerm remove
|
||||
prerm upgrade <new_version>
|
||||
prerm failed-upgrade <old_version>
|
||||
prerm remove in-favor <package> <new_version>
|
||||
prerm deconfigure in-favour <package> <version> removing <package> <version>
|
||||
postrm remove
|
||||
postrm purge
|
||||
postrm upgrade <new_version>
|
||||
postrm failed-upgrade <old_version>
|
||||
postrm abort-install
|
||||
postrm abort-install <old_version>
|
||||
postrm abort-upgrade <old_version>
|
||||
postrm disappear <overwriter> <version>
|
||||
*/
|
||||
static const char *const all_control_files[] = {
|
||||
"preinst", "postinst", "prerm", "postrm",
|
||||
"list", "md5sums", "shlibs", "conffiles",
|
||||
"config", "templates", NULL
|
||||
"config", "templates"
|
||||
};
|
||||
|
||||
static char **all_control_list(const char *package_name)
|
||||
@@ -1239,9 +1267,10 @@ static char **all_control_list(const char *package_name)
|
||||
char **remove_files;
|
||||
|
||||
/* Create a list of all /var/lib/dpkg/info/<package> files */
|
||||
remove_files = xzalloc(sizeof(all_control_files));
|
||||
while (all_control_files[i]) {
|
||||
remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, all_control_files[i]);
|
||||
remove_files = xzalloc(sizeof(all_control_files) + sizeof(char*));
|
||||
while (i < ARRAY_SIZE(all_control_files)) {
|
||||
remove_files[i] = xasprintf("/var/lib/dpkg/info/%s.%s",
|
||||
package_name, all_control_files[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
@@ -1314,27 +1343,26 @@ static void remove_package(const unsigned package_num, int noisy)
|
||||
if (noisy)
|
||||
printf("Removing %s (%s)...\n", package_name, package_version);
|
||||
|
||||
/* run prerm script */
|
||||
if (run_package_script(package_name, "prerm") != 0) {
|
||||
bb_error_msg_and_die("script failed, prerm failure");
|
||||
}
|
||||
/* Run prerm script */
|
||||
run_package_script_or_die(package_name, "prerm");
|
||||
|
||||
/* Create a list of files to remove, and a separate list of those to keep */
|
||||
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
|
||||
sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
|
||||
remove_files = create_list(list_name);
|
||||
|
||||
sprintf(conffile_name, "/var/lib/dpkg/info/%s.conffiles", package_name);
|
||||
sprintf(conffile_name, "/var/lib/dpkg/info/%s.%s", package_name, "conffiles");
|
||||
exclude_files = create_list(conffile_name);
|
||||
|
||||
/* Some directories can't be removed straight away, so do multiple passes */
|
||||
while (remove_file_array(remove_files, exclude_files)) /*repeat */;
|
||||
while (remove_file_array(remove_files, exclude_files))
|
||||
continue;
|
||||
free_array(exclude_files);
|
||||
free_array(remove_files);
|
||||
|
||||
/* Create a list of files in /var/lib/dpkg/info/<package>.* to keep */
|
||||
exclude_files = xzalloc(sizeof(char*) * 3);
|
||||
exclude_files[0] = xstrdup(conffile_name);
|
||||
exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.postrm", package_name);
|
||||
exclude_files[1] = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "postrm");
|
||||
|
||||
/* Create a list of all /var/lib/dpkg/info/<package> files */
|
||||
remove_files = all_control_list(package_name);
|
||||
@@ -1343,7 +1371,9 @@ static void remove_package(const unsigned package_num, int noisy)
|
||||
free_array(remove_files);
|
||||
free_array(exclude_files);
|
||||
|
||||
/* rename <package>.conffile to <package>.list */
|
||||
/* rename <package>.conffiles to <package>.list
|
||||
* The conffiles control file isn't required in Debian packages, so don't
|
||||
* error out if it's missing. */
|
||||
rename(conffile_name, list_name);
|
||||
|
||||
/* Change package status */
|
||||
@@ -1361,13 +1391,11 @@ static void purge_package(const unsigned package_num)
|
||||
|
||||
printf("Purging %s (%s)...\n", package_name, package_version);
|
||||
|
||||
/* run prerm script */
|
||||
if (run_package_script(package_name, "prerm") != 0) {
|
||||
bb_error_msg_and_die("script failed, prerm failure");
|
||||
}
|
||||
/* Run prerm script */
|
||||
run_package_script_or_die(package_name, "prerm");
|
||||
|
||||
/* Create a list of files to remove */
|
||||
sprintf(list_name, "/var/lib/dpkg/info/%s.list", package_name);
|
||||
sprintf(list_name, "/var/lib/dpkg/info/%s.%s", package_name, "list");
|
||||
remove_files = create_list(list_name);
|
||||
|
||||
exclude_files = xzalloc(sizeof(char*));
|
||||
@@ -1382,10 +1410,8 @@ static void purge_package(const unsigned package_num)
|
||||
free_array(remove_files);
|
||||
free(exclude_files);
|
||||
|
||||
/* run postrm script */
|
||||
if (run_package_script(package_name, "postrm") != 0) {
|
||||
bb_error_msg_and_die("postrm failure.. set status to what?");
|
||||
}
|
||||
/* Run postrm script */
|
||||
run_package_script_or_die(package_name, "postrm");
|
||||
|
||||
/* Change package status */
|
||||
set_status(status_num, "not-installed", 3);
|
||||
@@ -1412,10 +1438,10 @@ 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.* */
|
||||
#if ENABLE_FEATURE_DEB_TAR_GZ
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ
|
||||
llist_add_to(&(ar_handle->accept), (char*)"control.tar.gz");
|
||||
#endif
|
||||
#if ENABLE_FEATURE_DEB_TAR_BZ2
|
||||
#if ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
llist_add_to(&(ar_handle->accept), (char*)"control.tar.bz2");
|
||||
#endif
|
||||
|
||||
@@ -1432,10 +1458,10 @@ 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.* */
|
||||
#if ENABLE_FEATURE_DEB_TAR_GZ
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ
|
||||
llist_add_to(&(ar_handle->accept), (char*)"data.tar.gz");
|
||||
#endif
|
||||
#if ENABLE_FEATURE_DEB_TAR_BZ2
|
||||
#if ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
llist_add_to(&(ar_handle->accept), (char*)"data.tar.bz2");
|
||||
#endif
|
||||
|
||||
@@ -1455,7 +1481,7 @@ static char *deb_extract_control_file_to_buffer(archive_handle_t *ar_handle, lli
|
||||
return ar_handle->sub_archive->buffer;
|
||||
}
|
||||
|
||||
static void data_extract_all_prefix(archive_handle_t *archive_handle)
|
||||
static void FAST_FUNC data_extract_all_prefix(archive_handle_t *archive_handle)
|
||||
{
|
||||
char *name_ptr = archive_handle->file_header->name;
|
||||
|
||||
@@ -1475,8 +1501,8 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
char *list_filename;
|
||||
archive_handle_t *archive_handle;
|
||||
FILE *out_stream;
|
||||
llist_t *accept_list = NULL;
|
||||
int i = 0;
|
||||
llist_t *accept_list;
|
||||
int i;
|
||||
|
||||
/* If existing version, remove it first */
|
||||
if (strcmp(name_hashtable[get_status(status_num, 3)], "installed") == 0) {
|
||||
@@ -1490,11 +1516,13 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
}
|
||||
|
||||
/* Extract control.tar.gz to /var/lib/dpkg/info/<package>.filename */
|
||||
info_prefix = xasprintf("/var/lib/dpkg/info/%s.", package_name);
|
||||
info_prefix = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "");
|
||||
archive_handle = init_archive_deb_ar(deb_file->filename);
|
||||
init_archive_deb_control(archive_handle);
|
||||
|
||||
while (all_control_files[i]) {
|
||||
accept_list = NULL;
|
||||
i = 0;
|
||||
while (i < ARRAY_SIZE(all_control_files)) {
|
||||
char *c = xasprintf("./%s", all_control_files[i]);
|
||||
llist_add_to(&accept_list, c);
|
||||
i++;
|
||||
@@ -1503,26 +1531,23 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
archive_handle->sub_archive->filter = filter_accept_list;
|
||||
archive_handle->sub_archive->action_data = data_extract_all_prefix;
|
||||
archive_handle->sub_archive->buffer = info_prefix;
|
||||
archive_handle->sub_archive->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
archive_handle->sub_archive->ah_flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
unpack_ar_archive(archive_handle);
|
||||
|
||||
/* Run the preinst prior to extracting */
|
||||
if (run_package_script(package_name, "preinst") != 0) {
|
||||
/* when preinst returns exit code != 0 then quit installation process */
|
||||
bb_error_msg_and_die("subprocess pre-installation script returned error");
|
||||
}
|
||||
run_package_script_or_die(package_name, "preinst");
|
||||
|
||||
/* Extract data.tar.gz to the root directory */
|
||||
archive_handle = init_archive_deb_ar(deb_file->filename);
|
||||
init_archive_deb_data(archive_handle);
|
||||
archive_handle->sub_archive->action_data = data_extract_all_prefix;
|
||||
archive_handle->sub_archive->buffer = (char*)"/"; /* huh? */
|
||||
archive_handle->sub_archive->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
archive_handle->sub_archive->ah_flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
unpack_ar_archive(archive_handle);
|
||||
|
||||
/* Create the list file */
|
||||
list_filename = xasprintf("/var/lib/dpkg/info/%s.list", package_name);
|
||||
out_stream = xfopen(list_filename, "w");
|
||||
list_filename = xasprintf("/var/lib/dpkg/info/%s.%s", package_name, "list");
|
||||
out_stream = xfopen_for_write(list_filename);
|
||||
while (archive_handle->sub_archive->passed) {
|
||||
/* the leading . has been stripped by data_extract_all_prefix already */
|
||||
fputs(archive_handle->sub_archive->passed->data, out_stream);
|
||||
@@ -1548,17 +1573,16 @@ static void configure_package(deb_file_t *deb_file)
|
||||
printf("Setting up %s (%s)...\n", package_name, package_version);
|
||||
|
||||
/* Run the postinst script */
|
||||
if (run_package_script(package_name, "postinst") != 0) {
|
||||
/* TODO: handle failure gracefully */
|
||||
bb_error_msg_and_die("postinst failure.. set status to what?");
|
||||
}
|
||||
/* TODO: handle failure gracefully */
|
||||
run_package_script_or_die(package_name, "postinst");
|
||||
|
||||
/* Change status to reflect success */
|
||||
set_status(status_num, "install", 1);
|
||||
set_status(status_num, "installed", 3);
|
||||
}
|
||||
|
||||
int dpkg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int dpkg_main(int argc, char **argv)
|
||||
int dpkg_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
deb_file_t **deb_file = NULL;
|
||||
status_node_t *status_node;
|
||||
@@ -1579,6 +1603,8 @@ int dpkg_main(int argc, char **argv)
|
||||
OPT_unpack = 0x40,
|
||||
};
|
||||
|
||||
INIT_G();
|
||||
|
||||
opt = getopt32(argv, "CF:ilPru", &str_f);
|
||||
//if (opt & OPT_configure) ... // -C
|
||||
if (opt & OPT_force_ignore_depends) { // -F (--force in official dpkg)
|
||||
@@ -1590,16 +1616,11 @@ int dpkg_main(int argc, char **argv)
|
||||
//if (opt & OPT_purge) ... // -P
|
||||
//if (opt & OPT_remove) ... // -r
|
||||
//if (opt & OPT_unpack) ... // -u (--unpack in official dpkg)
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
/* check for non-option argument if expected */
|
||||
if (!opt || (!argc && !(opt && OPT_list_installed)))
|
||||
if (!opt || (!argv[0] && !(opt && OPT_list_installed)))
|
||||
bb_show_usage();
|
||||
|
||||
name_hashtable = xzalloc(sizeof(name_hashtable[0]) * (NAME_HASH_PRIME + 1));
|
||||
package_hashtable = xzalloc(sizeof(package_hashtable[0]) * (PACKAGE_HASH_PRIME + 1));
|
||||
status_hashtable = xzalloc(sizeof(status_hashtable[0]) * (STATUS_HASH_PRIME + 1));
|
||||
|
||||
/* puts("(Reading database ... xxxxx files and directories installed.)"); */
|
||||
index_status_file("/var/lib/dpkg/status");
|
||||
|
||||
@@ -1612,7 +1633,7 @@ 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[0]) * (deb_count + 2));
|
||||
deb_file = xrealloc_vector(deb_file, 2, deb_count);
|
||||
deb_file[deb_count] = xzalloc(sizeof(deb_file[0][0]));
|
||||
if (opt & (OPT_install | OPT_unpack)) {
|
||||
/* -i/-u: require filename */
|
||||
@@ -1693,7 +1714,7 @@ int dpkg_main(int argc, char **argv)
|
||||
|
||||
/* Check that the deb file arguments are installable */
|
||||
if (!(opt & OPT_force_ignore_depends)) {
|
||||
if (!check_deps(deb_file, 0, deb_count)) {
|
||||
if (!check_deps(deb_file, 0 /*, deb_count*/)) {
|
||||
bb_error_msg_and_die("dependency check failed");
|
||||
}
|
||||
}
|
||||
|
||||
+20
-13
@@ -20,8 +20,8 @@ int dpkg_deb_main(int argc, char **argv)
|
||||
archive_handle_t *tar_archive;
|
||||
llist_t *control_tar_llist = NULL;
|
||||
unsigned opt;
|
||||
const char *extract_dir = NULL;
|
||||
short argcount = 1;
|
||||
const char *extract_dir;
|
||||
int need_args;
|
||||
|
||||
/* Setup the tar archive handle */
|
||||
tar_archive = init_handle();
|
||||
@@ -31,29 +31,33 @@ int dpkg_deb_main(int argc, char **argv)
|
||||
ar_archive->sub_archive = tar_archive;
|
||||
ar_archive->filter = filter_accept_list_reassign;
|
||||
|
||||
#if ENABLE_FEATURE_DEB_TAR_GZ
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ
|
||||
llist_add_to(&(ar_archive->accept), (char*)"data.tar.gz");
|
||||
llist_add_to(&control_tar_llist, (char*)"control.tar.gz");
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_DEB_TAR_BZ2
|
||||
#if ENABLE_FEATURE_SEAMLESS_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(argv, "cefXx");
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
|
||||
if (opt & DPKG_DEB_OPT_CONTENTS) {
|
||||
tar_archive->action_header = header_verbose_list;
|
||||
}
|
||||
extract_dir = NULL;
|
||||
need_args = 1;
|
||||
if (opt & DPKG_DEB_OPT_CONTROL) {
|
||||
ar_archive->accept = control_tar_llist;
|
||||
tar_archive->action_data = data_extract_all;
|
||||
if (optind + 1 == argc) {
|
||||
if (1 == argc) {
|
||||
extract_dir = "./DEBIAN";
|
||||
} else {
|
||||
argcount++;
|
||||
need_args++;
|
||||
}
|
||||
}
|
||||
if (opt & DPKG_DEB_OPT_FIELD) {
|
||||
@@ -70,28 +74,31 @@ int dpkg_deb_main(int argc, char **argv)
|
||||
}
|
||||
if (opt & (DPKG_DEB_OPT_EXTRACT_VERBOSE | DPKG_DEB_OPT_EXTRACT)) {
|
||||
tar_archive->action_data = data_extract_all;
|
||||
argcount = 2;
|
||||
need_args = 2;
|
||||
}
|
||||
|
||||
if ((optind + argcount) != argc) {
|
||||
if (need_args != argc) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
tar_archive->src_fd = ar_archive->src_fd = xopen(argv[optind++], O_RDONLY);
|
||||
tar_archive->src_fd = ar_archive->src_fd = xopen(argv[0], O_RDONLY);
|
||||
|
||||
/* Workout where to extract the files */
|
||||
/* Work out where to extract the files */
|
||||
/* 2nd argument is a dir name */
|
||||
if (argv[optind]) {
|
||||
extract_dir = argv[optind];
|
||||
if (argv[1]) {
|
||||
extract_dir = argv[1];
|
||||
}
|
||||
if (extract_dir) {
|
||||
mkdir(extract_dir, 0777); /* bb_make_directory(extract_dir, 0777, 0) */
|
||||
xchdir(extract_dir);
|
||||
}
|
||||
|
||||
/* Do it */
|
||||
unpack_ar_archive(ar_archive);
|
||||
|
||||
/* Cleanup */
|
||||
close(ar_archive->src_fd);
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
close(ar_archive->src_fd);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+23
-4
@@ -2025,15 +2025,33 @@ USE_DESKTOP(long long) int pack_gzip(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Linux kernel build uses gzip -d -n. We accept and ignore it.
|
||||
* Man page says:
|
||||
* -n --no-name
|
||||
* gzip: do not save the original file name and time stamp.
|
||||
* (The original name is always saved if the name had to be truncated.)
|
||||
* gunzip: do not restore the original file name/time even if present
|
||||
* (remove only the gzip suffix from the compressed file name).
|
||||
* This option is the default when decompressing.
|
||||
* -N --name
|
||||
* gzip: always save the original file name and time stamp (this is the default)
|
||||
* gunzip: restore the original file name and time stamp if present.
|
||||
*/
|
||||
|
||||
int gzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
#if ENABLE_GUNZIP
|
||||
int gzip_main(int argc, char **argv)
|
||||
#else
|
||||
int gzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
#endif
|
||||
{
|
||||
unsigned opt;
|
||||
|
||||
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
|
||||
opt = getopt32(argv, "cfv" USE_GUNZIP("d") "q123456789" );
|
||||
opt = getopt32(argv, "cfv" USE_GUNZIP("dt") "q123456789n");
|
||||
#if ENABLE_GUNZIP /* gunzip_main may not be visible... */
|
||||
if (opt & 0x8) // -d
|
||||
if (opt & 0x18) // -d and/or -t
|
||||
return gunzip_main(argc, argv);
|
||||
#endif
|
||||
option_mask32 &= 0x7; /* ignore -q, -0..9 */
|
||||
@@ -2042,8 +2060,9 @@ int gzip_main(int argc, char **argv)
|
||||
//if (opt & 0x4) // -v
|
||||
argv += optind;
|
||||
|
||||
PTR_TO_GLOBALS = xzalloc(sizeof(struct globals) + sizeof(struct globals2))
|
||||
+ sizeof(struct globals);
|
||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(struct globals) + sizeof(struct globals2))
|
||||
+ sizeof(struct globals));
|
||||
barrier();
|
||||
G2.l_desc.dyn_tree = G2.dyn_ltree;
|
||||
G2.l_desc.static_tree = G2.static_ltree;
|
||||
G2.l_desc.extra_bits = extra_lbits;
|
||||
|
||||
@@ -18,8 +18,6 @@ lib-y:= \
|
||||
header_skip.o \
|
||||
header_list.o \
|
||||
header_verbose_list.o \
|
||||
\
|
||||
archive_xread_all_eof.o \
|
||||
\
|
||||
seek_by_read.o \
|
||||
seek_by_jump.o \
|
||||
@@ -34,34 +32,20 @@ DPKG_FILES:= \
|
||||
get_header_tar.o \
|
||||
filter_accept_list_reassign.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_RPM) += open_transformer.o decompress_unzip.o 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) += 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_SEAMLESS_Z) += open_transformer.o decompress_uncompress.o
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_GZ) += open_transformer.o decompress_unzip.o get_header_tar_gz.o
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_BZ2) += open_transformer.o decompress_bunzip2.o get_header_tar_bz2.o
|
||||
lib-$(CONFIG_FEATURE_SEAMLESS_LZMA) += open_transformer.o decompress_unlzma.o get_header_tar_lzma.o
|
||||
lib-$(CONFIG_FEATURE_COMPRESS_USAGE) += decompress_bunzip2.o
|
||||
@@ -1,20 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
ssize_t archive_xread_all_eof(archive_handle_t *archive_handle,
|
||||
unsigned char *buf, size_t count)
|
||||
{
|
||||
ssize_t size;
|
||||
|
||||
size = full_read(archive_handle->src_fd, buf, count);
|
||||
if (size != 0 && size != count) {
|
||||
bb_error_msg_and_die("short read: %u of %u",
|
||||
(unsigned)size, (unsigned)count);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
@@ -3,14 +3,12 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
//#include <sys/types.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void data_align(archive_handle_t *archive_handle, const unsigned short boundary)
|
||||
void FAST_FUNC data_align(archive_handle_t *archive_handle, unsigned boundary)
|
||||
{
|
||||
const unsigned short skip_amount = (boundary - (archive_handle->offset % boundary)) % boundary;
|
||||
unsigned skip_amount = (boundary - (archive_handle->offset % boundary)) % boundary;
|
||||
|
||||
archive_handle->seek(archive_handle, skip_amount);
|
||||
archive_handle->offset += skip_amount;
|
||||
|
||||
@@ -6,21 +6,21 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void data_extract_all(archive_handle_t *archive_handle)
|
||||
void FAST_FUNC data_extract_all(archive_handle_t *archive_handle)
|
||||
{
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
int dst_fd;
|
||||
int res;
|
||||
|
||||
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
|
||||
if (archive_handle->ah_flags & ARCHIVE_CREATE_LEADING_DIRS) {
|
||||
char *name = xstrdup(file_header->name);
|
||||
bb_make_directory(dirname(name), -1, FILEUTILS_RECUR);
|
||||
free(name);
|
||||
}
|
||||
|
||||
/* Check if the file already exists */
|
||||
if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
|
||||
/* Remove the existing entry if it exists */
|
||||
if (archive_handle->ah_flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
|
||||
/* Remove the entry if it exists */
|
||||
if (((file_header->mode & S_IFMT) != S_IFDIR)
|
||||
&& (unlink(file_header->name) == -1)
|
||||
&& (errno != ENOENT)
|
||||
@@ -29,7 +29,7 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
file_header->name);
|
||||
}
|
||||
}
|
||||
else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) {
|
||||
else if (archive_handle->ah_flags & ARCHIVE_EXTRACT_NEWER) {
|
||||
/* Remove the existing entry if its older than the extracted entry */
|
||||
struct stat statbuf;
|
||||
if (lstat(file_header->name, &statbuf) == -1) {
|
||||
@@ -38,7 +38,7 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
}
|
||||
}
|
||||
else if (statbuf.st_mtime <= file_header->mtime) {
|
||||
if (!(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
if (!(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_error_msg("%s not created: newer or "
|
||||
"same age file exists", file_header->name);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
) {
|
||||
/* hard link */
|
||||
res = link(file_header->link_target, file_header->name);
|
||||
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
if ((res == -1) && !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("cannot create %slink "
|
||||
"from %s to %s", "hard",
|
||||
file_header->name,
|
||||
@@ -78,7 +78,7 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
case S_IFDIR:
|
||||
res = mkdir(file_header->name, file_header->mode);
|
||||
if ((res == -1) && (errno != EISDIR)
|
||||
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("cannot make dir %s", file_header->name);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
/* Symlink */
|
||||
res = symlink(file_header->link_target, file_header->name);
|
||||
if ((res == -1)
|
||||
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("cannot create %slink "
|
||||
"from %s to %s", "sym",
|
||||
@@ -101,7 +101,7 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
case S_IFIFO:
|
||||
res = mknod(file_header->name, file_header->mode, file_header->device);
|
||||
if ((res == -1)
|
||||
&& !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("cannot create node %s", file_header->name);
|
||||
}
|
||||
@@ -111,18 +111,33 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
}
|
||||
}
|
||||
|
||||
if (!(archive_handle->flags & ARCHIVE_NOPRESERVE_OWN)) {
|
||||
if (!(archive_handle->ah_flags & ARCHIVE_NOPRESERVE_OWN)) {
|
||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||
uid_t uid = file_header->uid;
|
||||
gid_t gid = file_header->gid;
|
||||
|
||||
if (file_header->uname) {
|
||||
struct passwd *pwd = getpwnam(file_header->uname);
|
||||
if (pwd) uid = pwd->pw_uid;
|
||||
}
|
||||
if (file_header->gname) {
|
||||
struct group *grp = getgrnam(file_header->gname);
|
||||
if (grp) gid = grp->gr_gid;
|
||||
}
|
||||
lchown(file_header->name, uid, gid);
|
||||
#else
|
||||
lchown(file_header->name, file_header->uid, file_header->gid);
|
||||
#endif
|
||||
}
|
||||
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)) {
|
||||
if (!(archive_handle->ah_flags & ARCHIVE_NOPRESERVE_PERM)) {
|
||||
chmod(file_header->name, file_header->mode);
|
||||
}
|
||||
/* same for utime */
|
||||
if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) {
|
||||
if (archive_handle->ah_flags & ARCHIVE_PRESERVE_DATE) {
|
||||
struct utimbuf t;
|
||||
t.actime = t.modtime = file_header->mtime;
|
||||
utime(file_header->name, &t);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void data_extract_to_buffer(archive_handle_t *archive_handle)
|
||||
void FAST_FUNC data_extract_to_buffer(archive_handle_t *archive_handle)
|
||||
{
|
||||
unsigned int size = archive_handle->file_header->size;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void data_extract_to_stdout(archive_handle_t *archive_handle)
|
||||
void FAST_FUNC data_extract_to_stdout(archive_handle_t *archive_handle)
|
||||
{
|
||||
bb_copyfd_exact_size(archive_handle->src_fd,
|
||||
STDOUT_FILENO,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void data_skip(archive_handle_t *archive_handle)
|
||||
void FAST_FUNC data_skip(archive_handle_t *archive_handle)
|
||||
{
|
||||
archive_handle->seek(archive_handle, archive_handle->file_header->size);
|
||||
}
|
||||
@@ -66,7 +66,6 @@ struct group_data {
|
||||
* | grep 'bd->' | sed 's/^.*bd->/bd->/' | sort | $PAGER
|
||||
* and moved it (inbufBitCount) to offset 0.
|
||||
*/
|
||||
|
||||
struct bunzip_data {
|
||||
/* I/O tracking data (file handles, buffers, positions, etc.) */
|
||||
unsigned inbufBitCount, inbufBits;
|
||||
@@ -102,11 +101,9 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
|
||||
|
||||
/* If we need to get more data from the byte buffer, do so. (Loop getting
|
||||
one byte at a time to enforce endianness and avoid unaligned access.) */
|
||||
|
||||
while (bd->inbufBitCount < bits_wanted) {
|
||||
while ((int)(bd->inbufBitCount) < bits_wanted) {
|
||||
|
||||
/* If we need to read more data from file into byte buffer, do so */
|
||||
|
||||
if (bd->inbufPos == bd->inbufCount) {
|
||||
/* if "no input fd" case: in_fd == -1, read fails, we jump */
|
||||
bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE);
|
||||
@@ -116,7 +113,6 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
|
||||
}
|
||||
|
||||
/* Avoid 32-bit overflow (dump bit buffer to top of output) */
|
||||
|
||||
if (bd->inbufBitCount >= 24) {
|
||||
bits = bd->inbufBits & ((1 << bd->inbufBitCount) - 1);
|
||||
bits_wanted -= bd->inbufBitCount;
|
||||
@@ -125,13 +121,11 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
|
||||
}
|
||||
|
||||
/* Grab next 8 bits of input from buffer. */
|
||||
|
||||
bd->inbufBits = (bd->inbufBits << 8) | bd->inbuf[bd->inbufPos++];
|
||||
bd->inbufBitCount += 8;
|
||||
}
|
||||
|
||||
/* Calculate result */
|
||||
|
||||
bd->inbufBitCount -= bits_wanted;
|
||||
bits |= (bd->inbufBits >> bd->inbufBitCount) & ((1 << bits_wanted) - 1);
|
||||
|
||||
@@ -139,7 +133,6 @@ static unsigned get_bits(bunzip_data *bd, int bits_wanted)
|
||||
}
|
||||
|
||||
/* Unpacks the next block and sets up for the inverse burrows-wheeler step. */
|
||||
|
||||
static int get_next_block(bunzip_data *bd)
|
||||
{
|
||||
struct group_data *hufGroup;
|
||||
@@ -153,13 +146,11 @@ static int get_next_block(bunzip_data *bd)
|
||||
selectors = bd->selectors;
|
||||
|
||||
/* Reset longjmp I/O error handling */
|
||||
|
||||
i = setjmp(bd->jmpbuf);
|
||||
if (i) return i;
|
||||
|
||||
/* Read in header signature and CRC, then validate signature.
|
||||
(last block signature means CRC is for whole file, return now) */
|
||||
|
||||
i = get_bits(bd, 24);
|
||||
j = get_bits(bd, 24);
|
||||
bd->headerCRC = get_bits(bd, 32);
|
||||
@@ -169,17 +160,15 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* We can add support for blockRandomised if anybody complains. There was
|
||||
some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
|
||||
it didn't actually work. */
|
||||
|
||||
if (get_bits(bd, 1)) return RETVAL_OBSOLETE_INPUT;
|
||||
origPtr = get_bits(bd, 24);
|
||||
if (origPtr > dbufSize) return RETVAL_DATA_ERROR;
|
||||
if ((int)origPtr > dbufSize) return RETVAL_DATA_ERROR;
|
||||
|
||||
/* mapping table: if some byte values are never used (encoding things
|
||||
like ascii text), the compression code removes the gaps to have fewer
|
||||
symbols to deal with, and writes a sparse bitfield indicating which
|
||||
values were present. We make a translation table to convert the symbols
|
||||
back to the corresponding bytes. */
|
||||
|
||||
t = get_bits(bd, 16);
|
||||
symTotal = 0;
|
||||
for (i = 0; i < 16; i++) {
|
||||
@@ -192,7 +181,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
}
|
||||
|
||||
/* How many different Huffman coding groups does this block use? */
|
||||
|
||||
groupCount = get_bits(bd, 3);
|
||||
if (groupCount < 2 || groupCount > MAX_GROUPS)
|
||||
return RETVAL_DATA_ERROR;
|
||||
@@ -201,19 +189,16 @@ static int get_next_block(bunzip_data *bd)
|
||||
group. Read in the group selector list, which is stored as MTF encoded
|
||||
bit runs. (MTF=Move To Front, as each value is used it's moved to the
|
||||
start of the list.) */
|
||||
|
||||
nSelectors = get_bits(bd, 15);
|
||||
if (!nSelectors) return RETVAL_DATA_ERROR;
|
||||
for (i = 0; i < groupCount; i++) mtfSymbol[i] = i;
|
||||
for (i = 0; i < nSelectors; i++) {
|
||||
|
||||
/* Get next value */
|
||||
|
||||
for (j = 0; get_bits(bd, 1); j++)
|
||||
if (j >= groupCount) return RETVAL_DATA_ERROR;
|
||||
|
||||
/* Decode MTF to get the next selector */
|
||||
|
||||
uc = mtfSymbol[j];
|
||||
for (;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
|
||||
mtfSymbol[0] = selectors[i] = uc;
|
||||
@@ -221,10 +206,11 @@ static int get_next_block(bunzip_data *bd)
|
||||
|
||||
/* Read the Huffman coding tables for each group, which code for symTotal
|
||||
literal symbols, plus two run symbols (RUNA, RUNB) */
|
||||
|
||||
symCount = symTotal + 2;
|
||||
for (j = 0; j < groupCount; j++) {
|
||||
unsigned char length[MAX_SYMBOLS], temp[MAX_HUFCODE_BITS+1];
|
||||
unsigned char length[MAX_SYMBOLS];
|
||||
/* 8 bits is ALMOST enough for temp[], see below */
|
||||
unsigned temp[MAX_HUFCODE_BITS+1];
|
||||
int minLen, maxLen, pp;
|
||||
|
||||
/* Read Huffman code lengths for each symbol. They're stored in
|
||||
@@ -233,7 +219,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
(Subtracting 1 before the loop and then adding it back at the end is
|
||||
an optimization that makes the test inside the loop simpler: symbol
|
||||
length 0 becomes negative, so an unsigned inequality catches it.) */
|
||||
|
||||
t = get_bits(bd, 5) - 1;
|
||||
for (i = 0; i < symCount; i++) {
|
||||
for (;;) {
|
||||
@@ -243,7 +228,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* If first bit is 0, stop. Else second bit indicates whether
|
||||
to increment or decrement the value. Optimization: grab 2
|
||||
bits and unget the second if the first was 0. */
|
||||
|
||||
k = get_bits(bd, 2);
|
||||
if (k < 2) {
|
||||
bd->inbufBitCount++;
|
||||
@@ -251,17 +235,14 @@ static int get_next_block(bunzip_data *bd)
|
||||
}
|
||||
|
||||
/* Add one if second bit 1, else subtract 1. Avoids if/else */
|
||||
|
||||
t += (((k+1) & 2) - 1);
|
||||
}
|
||||
|
||||
/* Correct for the initial -1, to get the final symbol length */
|
||||
|
||||
length[i] = t + 1;
|
||||
}
|
||||
|
||||
/* Find largest and smallest lengths in this group */
|
||||
|
||||
minLen = maxLen = length[0];
|
||||
for (i = 1; i < symCount; i++) {
|
||||
if (length[i] > maxLen) maxLen = length[i];
|
||||
@@ -278,7 +259,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
* number of bits can have. This is how the Huffman codes can vary in
|
||||
* length: each code with a value>limit[length] needs another bit.
|
||||
*/
|
||||
|
||||
hufGroup = bd->groups + j;
|
||||
hufGroup->minLen = minLen;
|
||||
hufGroup->maxLen = maxLen;
|
||||
@@ -286,12 +266,10 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* Note that minLen can't be smaller than 1, so we adjust the base
|
||||
and limit array pointers so we're not always wasting the first
|
||||
entry. We do this again when using them (during symbol decoding).*/
|
||||
|
||||
base = hufGroup->base - 1;
|
||||
limit = hufGroup->limit - 1;
|
||||
|
||||
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
|
||||
|
||||
pp = 0;
|
||||
for (i = minLen; i <= maxLen; i++) {
|
||||
temp[i] = limit[i] = 0;
|
||||
@@ -301,14 +279,14 @@ static int get_next_block(bunzip_data *bd)
|
||||
}
|
||||
|
||||
/* Count symbols coded for at each bit length */
|
||||
|
||||
/* NB: in pathological cases, temp[8] can end ip being 256.
|
||||
* That's why uint8_t is too small for temp[]. */
|
||||
for (i = 0; i < symCount; i++) temp[length[i]]++;
|
||||
|
||||
/* Calculate limit[] (the largest symbol-coding value at each bit
|
||||
* length, which is (previous limit<<1)+symbols at this level), and
|
||||
* base[] (number of symbols to ignore at each bit length, which is
|
||||
* limit minus the cumulative count of symbols coded for already). */
|
||||
|
||||
pp = t = 0;
|
||||
for (i = minLen; i < maxLen; i++) {
|
||||
pp += temp[i];
|
||||
@@ -319,7 +297,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
each level we're really only interested in the first few bits,
|
||||
so here we set all the trailing to-be-ignored bits to 1 so they
|
||||
don't affect the value>limit[length] comparison. */
|
||||
|
||||
limit[i] = (pp << (maxLen - i)) - 1;
|
||||
pp <<= 1;
|
||||
t += temp[i];
|
||||
@@ -335,7 +312,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
and run length encoding, saving the result into dbuf[dbufCount++] = uc */
|
||||
|
||||
/* Initialize symbol occurrence counters and symbol Move To Front table */
|
||||
|
||||
memset(byteCount, 0, sizeof(byteCount)); /* smaller, maybe slower? */
|
||||
for (i = 0; i < 256; i++) {
|
||||
//byteCount[i] = 0;
|
||||
@@ -347,8 +323,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
runPos = dbufCount = selector = 0;
|
||||
for (;;) {
|
||||
|
||||
/* fetch next Huffman coding group from list. */
|
||||
|
||||
/* Fetch next Huffman coding group from list. */
|
||||
symCount = GROUP_SIZE - 1;
|
||||
if (selector >= nSelectors) return RETVAL_DATA_ERROR;
|
||||
hufGroup = bd->groups + selectors[selector++];
|
||||
@@ -367,8 +342,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
dry). The following (up to got_huff_bits:) is equivalent to
|
||||
j = get_bits(bd, hufGroup->maxLen);
|
||||
*/
|
||||
|
||||
while (bd->inbufBitCount < hufGroup->maxLen) {
|
||||
while ((int)(bd->inbufBitCount) < hufGroup->maxLen) {
|
||||
if (bd->inbufPos == bd->inbufCount) {
|
||||
j = get_bits(bd, hufGroup->maxLen);
|
||||
goto got_huff_bits;
|
||||
@@ -382,13 +356,11 @@ static int get_next_block(bunzip_data *bd)
|
||||
got_huff_bits:
|
||||
|
||||
/* Figure how how many bits are in next symbol and unget extras */
|
||||
|
||||
i = hufGroup->minLen;
|
||||
while (j > limit[i]) ++i;
|
||||
bd->inbufBitCount += (hufGroup->maxLen - i);
|
||||
|
||||
/* Huffman decode value to get nextSym (with bounds checking) */
|
||||
|
||||
if (i > hufGroup->maxLen)
|
||||
return RETVAL_DATA_ERROR;
|
||||
j = (j >> (hufGroup->maxLen - i)) - base[i];
|
||||
@@ -400,11 +372,9 @@ static int get_next_block(bunzip_data *bd)
|
||||
byte, or a repeated run of the most recent literal byte. First,
|
||||
check if nextSym indicates a repeated run, and if so loop collecting
|
||||
how many times to repeat the last literal. */
|
||||
|
||||
if ((unsigned)nextSym <= SYMBOL_RUNB) { /* RUNA or RUNB */
|
||||
|
||||
/* If this is the start of a new run, zero out counter */
|
||||
|
||||
if (!runPos) {
|
||||
runPos = 1;
|
||||
t = 0;
|
||||
@@ -417,7 +387,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
the basic or 0/1 method (except all bits 0, which would use no
|
||||
symbols, but a run of length 0 doesn't mean anything in this
|
||||
context). Thus space is saved. */
|
||||
|
||||
t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
|
||||
if (runPos < dbufSize) runPos <<= 1;
|
||||
goto end_of_huffman_loop;
|
||||
@@ -427,7 +396,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
how many times to repeat the last literal, so append that many
|
||||
copies to our buffer of decoded symbols (dbuf) now. (The last
|
||||
literal used is the one at the head of the mtfSymbol array.) */
|
||||
|
||||
if (runPos) {
|
||||
runPos = 0;
|
||||
if (dbufCount + t >= dbufSize) return RETVAL_DATA_ERROR;
|
||||
@@ -438,7 +406,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
}
|
||||
|
||||
/* Is this the terminating symbol? */
|
||||
|
||||
if (nextSym > symTotal) break;
|
||||
|
||||
/* At this point, nextSym indicates a new literal character. Subtract
|
||||
@@ -448,7 +415,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
first symbol in the mtf array, position 0, would have been handled
|
||||
as part of a run above. Therefore 1 unused mtf position minus
|
||||
2 non-literal nextSym values equals -1.) */
|
||||
|
||||
if (dbufCount >= dbufSize) return RETVAL_DATA_ERROR;
|
||||
i = nextSym - 1;
|
||||
uc = mtfSymbol[i];
|
||||
@@ -457,7 +423,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
* small number of symbols, and are bound by 256 in any case, using
|
||||
* memmove here would typically be bigger and slower due to function
|
||||
* call overhead and other assorted setup costs. */
|
||||
|
||||
do {
|
||||
mtfSymbol[i] = mtfSymbol[i-1];
|
||||
} while (--i);
|
||||
@@ -465,13 +430,11 @@ static int get_next_block(bunzip_data *bd)
|
||||
uc = symToByte[uc];
|
||||
|
||||
/* We have our literal byte. Save it into dbuf. */
|
||||
|
||||
byteCount[uc]++;
|
||||
dbuf[dbufCount++] = (unsigned)uc;
|
||||
|
||||
/* Skip group initialization if we're not done with this group. Done
|
||||
* this way to avoid compiler warning. */
|
||||
|
||||
end_of_huffman_loop:
|
||||
if (symCount--) goto continue_this_group;
|
||||
}
|
||||
@@ -484,7 +447,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
*/
|
||||
|
||||
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
|
||||
|
||||
j = 0;
|
||||
for (i = 0; i < 256; i++) {
|
||||
k = j + byteCount[i];
|
||||
@@ -493,7 +455,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
}
|
||||
|
||||
/* Figure out what order dbuf would be in if we sorted it. */
|
||||
|
||||
for (i = 0; i < dbufCount; i++) {
|
||||
uc = (unsigned char)(dbuf[i] & 0xff);
|
||||
dbuf[byteCount[uc]] |= (i << 8);
|
||||
@@ -503,11 +464,10 @@ static int get_next_block(bunzip_data *bd)
|
||||
/* Decode first byte by hand to initialize "previous" byte. Note that it
|
||||
doesn't get output, and if the first three characters are identical
|
||||
it doesn't qualify as a run (hence writeRunCountdown=5). */
|
||||
|
||||
if (dbufCount) {
|
||||
if (origPtr >= dbufCount) return RETVAL_DATA_ERROR;
|
||||
if ((int)origPtr >= dbufCount) return RETVAL_DATA_ERROR;
|
||||
bd->writePos = dbuf[origPtr];
|
||||
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
|
||||
bd->writeCurrent = (unsigned char)(bd->writePos & 0xff);
|
||||
bd->writePos >>= 8;
|
||||
bd->writeRunCountdown = 5;
|
||||
}
|
||||
@@ -522,8 +482,7 @@ static int get_next_block(bunzip_data *bd)
|
||||
error (all errors are negative numbers). If out_fd!=-1, outbuf and len
|
||||
are ignored, data is written to out_fd and return is RETVAL_OK or error.
|
||||
*/
|
||||
|
||||
int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
int FAST_FUNC read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
{
|
||||
const unsigned *dbuf;
|
||||
int pos, current, previous, gotcount;
|
||||
@@ -539,19 +498,15 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
/* We will always have pending decoded data to write into the output
|
||||
buffer unless this is the very first call (in which case we haven't
|
||||
Huffman-decoded a block into the intermediate buffer yet). */
|
||||
|
||||
if (bd->writeCopies) {
|
||||
|
||||
/* Inside the loop, writeCopies means extra copies (beyond 1) */
|
||||
|
||||
--bd->writeCopies;
|
||||
|
||||
/* Loop outputting bytes */
|
||||
|
||||
for (;;) {
|
||||
|
||||
/* If the output buffer is full, snapshot state and return */
|
||||
|
||||
if (gotcount >= len) {
|
||||
bd->writePos = pos;
|
||||
bd->writeCurrent = current;
|
||||
@@ -560,13 +515,11 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
}
|
||||
|
||||
/* Write next byte into output buffer, updating CRC */
|
||||
|
||||
outbuf[gotcount++] = current;
|
||||
bd->writeCRC = (bd->writeCRC << 8)
|
||||
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
|
||||
^ bd->crc32Table[(bd->writeCRC >> 24) ^ current];
|
||||
|
||||
/* Loop now if we're outputting multiple copies of this byte */
|
||||
|
||||
if (bd->writeCopies) {
|
||||
--bd->writeCopies;
|
||||
continue;
|
||||
@@ -582,35 +535,29 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
/* After 3 consecutive copies of the same byte, the 4th
|
||||
* is a repeat count. We count down from 4 instead
|
||||
* of counting up because testing for non-zero is faster */
|
||||
|
||||
if (--bd->writeRunCountdown) {
|
||||
if (current != previous)
|
||||
bd->writeRunCountdown = 4;
|
||||
} else {
|
||||
|
||||
/* We have a repeated run, this byte indicates the count */
|
||||
|
||||
bd->writeCopies = current;
|
||||
current = previous;
|
||||
bd->writeRunCountdown = 5;
|
||||
|
||||
/* Sometimes there are just 3 bytes (run length 0) */
|
||||
|
||||
if (!bd->writeCopies) goto decode_next_byte;
|
||||
|
||||
/* Subtract the 1 copy we'd output anyway to get extras */
|
||||
|
||||
--bd->writeCopies;
|
||||
}
|
||||
}
|
||||
|
||||
/* Decompression of this block completed successfully */
|
||||
|
||||
bd->writeCRC = ~bd->writeCRC;
|
||||
bd->totalCRC = ((bd->totalCRC << 1) | (bd->totalCRC >> 31)) ^ bd->writeCRC;
|
||||
|
||||
/* If this block had a CRC error, force file level CRC error. */
|
||||
|
||||
if (bd->writeCRC != bd->headerCRC) {
|
||||
bd->totalCRC = bd->headerCRC + 1;
|
||||
return RETVAL_LAST_BLOCK;
|
||||
@@ -619,7 +566,6 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
|
||||
/* Refill the intermediate buffer by Huffman-decoding next block of input */
|
||||
/* (previous is just a convenient unused temp variable here) */
|
||||
|
||||
previous = get_next_block(bd);
|
||||
if (previous) {
|
||||
bd->writeCount = previous;
|
||||
@@ -631,7 +577,6 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
goto decode_next_byte;
|
||||
}
|
||||
|
||||
|
||||
/* Allocate the structure, read file header. If in_fd==-1, inbuf must contain
|
||||
a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are
|
||||
ignored, and data is read from file handle into temporary buffer. */
|
||||
@@ -639,27 +584,24 @@ int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
/* Because bunzip2 is used for help text unpacking, and because bb_show_usage()
|
||||
should work for NOFORK applets too, we must be extremely careful to not leak
|
||||
any allocations! */
|
||||
|
||||
int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
|
||||
int FAST_FUNC start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
|
||||
int len)
|
||||
{
|
||||
bunzip_data *bd;
|
||||
unsigned i;
|
||||
enum {
|
||||
BZh0 = ('B' << 24) + ('Z' << 16) + ('h' << 8) + '0'
|
||||
BZh0 = ('B' << 24) + ('Z' << 16) + ('h' << 8) + '0',
|
||||
h0 = ('h' << 8) + '0',
|
||||
};
|
||||
|
||||
/* Figure out how much data to allocate */
|
||||
|
||||
i = sizeof(bunzip_data);
|
||||
if (in_fd != -1) i += IOBUF_SIZE;
|
||||
|
||||
/* Allocate bunzip_data. Most fields initialize to zero. */
|
||||
|
||||
bd = *bdp = xzalloc(i);
|
||||
|
||||
/* Setup input buffer */
|
||||
|
||||
bd->in_fd = in_fd;
|
||||
if (-1 == in_fd) {
|
||||
/* in this case, bd->inbuf is read-only */
|
||||
@@ -669,23 +611,25 @@ int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
|
||||
bd->inbuf = (unsigned char *)(bd + 1);
|
||||
|
||||
/* Init the CRC32 table (big endian) */
|
||||
|
||||
crc32_filltable(bd->crc32Table, 1);
|
||||
|
||||
/* Setup for I/O error handling via longjmp */
|
||||
|
||||
i = setjmp(bd->jmpbuf);
|
||||
if (i) return i;
|
||||
|
||||
/* Ensure that file starts with "BZh['1'-'9']." */
|
||||
/* Update: now caller verifies 1st two bytes, makes .gz/.bz2
|
||||
* integration easier */
|
||||
/* was: */
|
||||
/* i = get_bits(bd, 32); */
|
||||
/* if ((unsigned)(i - BZh0 - 1) >= 9) return RETVAL_NOT_BZIP_DATA; */
|
||||
i = get_bits(bd, 16);
|
||||
if ((unsigned)(i - h0 - 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
|
||||
/* 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->dbufSize = 100000 * (i - h0);
|
||||
|
||||
/* Cannot use xmalloc - may leak bd in NOFORK case! */
|
||||
bd->dbuf = malloc_or_warn(bd->dbufSize * sizeof(int));
|
||||
@@ -696,7 +640,7 @@ int start_bunzip(bunzip_data **bdp, int in_fd, const unsigned char *inbuf,
|
||||
return RETVAL_OK;
|
||||
}
|
||||
|
||||
void dealloc_bunzip(bunzip_data *bd)
|
||||
void FAST_FUNC dealloc_bunzip(bunzip_data *bd)
|
||||
{
|
||||
free(bd->dbuf);
|
||||
free(bd);
|
||||
@@ -704,8 +648,7 @@ void dealloc_bunzip(bunzip_data *bd)
|
||||
|
||||
|
||||
/* Decompress src_fd to dst_fd. Stops at end of bzip data, not end of file. */
|
||||
|
||||
USE_DESKTOP(long long) int
|
||||
USE_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_bz2_stream(int src_fd, int dst_fd)
|
||||
{
|
||||
USE_DESKTOP(long long total_written = 0;)
|
||||
@@ -746,6 +689,17 @@ unpack_bz2_stream(int src_fd, int dst_fd)
|
||||
return i ? i : USE_DESKTOP(total_written) + 0;
|
||||
}
|
||||
|
||||
USE_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_bz2_stream_prime(int src_fd, int dst_fd)
|
||||
{
|
||||
unsigned char magic[2];
|
||||
xread(src_fd, magic, 2);
|
||||
if (magic[0] != 'B' || magic[1] != 'Z') {
|
||||
bb_error_msg_and_die("invalid magic");
|
||||
}
|
||||
return unpack_bz2_stream(src_fd, dst_fd);
|
||||
}
|
||||
|
||||
#ifdef TESTING
|
||||
|
||||
static char *const bunzip_errors[] = {
|
||||
@@ -757,13 +711,14 @@ static char *const bunzip_errors[] = {
|
||||
/* Dumb little test thing, decompress stdin to stdout */
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int i = unpack_bz2_stream(0, 1);
|
||||
int i;
|
||||
char c;
|
||||
|
||||
int i = unpack_bz2_stream_prime(0, 1);
|
||||
if (i < 0)
|
||||
fprintf(stderr,"%s\n", bunzip_errors[-i]);
|
||||
else if (read(0, &c, 1))
|
||||
fprintf(stderr,"Trailing garbage ignored\n");
|
||||
fprintf(stderr, "%s\n", bunzip_errors[-i]);
|
||||
else if (read(STDIN_FILENO, &c, 1))
|
||||
fprintf(stderr, "Trailing garbage ignored\n");
|
||||
return -i;
|
||||
}
|
||||
#endif
|
||||
@@ -1,6 +1,4 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include "libbb.h"
|
||||
|
||||
/* uncompress for busybox -- (c) 2002 Robert Griebl
|
||||
*
|
||||
* based on the original compress42.c source
|
||||
@@ -26,6 +24,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
|
||||
/* Default input buffer size */
|
||||
#define IBUFSIZ 2048
|
||||
|
||||
@@ -70,8 +72,8 @@
|
||||
* be stored in the compressed file.
|
||||
*/
|
||||
|
||||
USE_DESKTOP(long long) int
|
||||
uncompress(int fd_in, int fd_out)
|
||||
USE_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_Z_stream(int fd_in, int fd_out)
|
||||
{
|
||||
USE_DESKTOP(long long total_written = 0;)
|
||||
USE_DESKTOP(long long) int retval = -1;
|
||||
|
||||
@@ -45,7 +45,7 @@ typedef struct {
|
||||
|
||||
|
||||
/* Called twice: once at startup and once in rc_normalize() */
|
||||
static void rc_read(rc_t * rc)
|
||||
static void rc_read(rc_t *rc)
|
||||
{
|
||||
int buffer_size = safe_read(rc->fd, RC_BUFFER, RC_BUFFER_SIZE);
|
||||
if (buffer_size <= 0)
|
||||
@@ -58,9 +58,9 @@ static void rc_read(rc_t * rc)
|
||||
static rc_t* rc_init(int fd) /*, int buffer_size) */
|
||||
{
|
||||
int i;
|
||||
rc_t* rc;
|
||||
rc_t *rc;
|
||||
|
||||
rc = xmalloc(sizeof(rc_t) + RC_BUFFER_SIZE);
|
||||
rc = xmalloc(sizeof(*rc) + RC_BUFFER_SIZE);
|
||||
|
||||
rc->fd = fd;
|
||||
/* rc->buffer_size = buffer_size; */
|
||||
@@ -78,21 +78,20 @@ static rc_t* rc_init(int fd) /*, int buffer_size) */
|
||||
}
|
||||
|
||||
/* Called once */
|
||||
static ALWAYS_INLINE void rc_free(rc_t * rc)
|
||||
static ALWAYS_INLINE void rc_free(rc_t *rc)
|
||||
{
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(rc);
|
||||
free(rc);
|
||||
}
|
||||
|
||||
/* Called twice, but one callsite is in speed_inline'd rc_is_bit_0_helper() */
|
||||
static void rc_do_normalize(rc_t * rc)
|
||||
static void rc_do_normalize(rc_t *rc)
|
||||
{
|
||||
if (rc->ptr >= rc->buffer_end)
|
||||
rc_read(rc);
|
||||
rc->range <<= 8;
|
||||
rc->code = (rc->code << 8) | *rc->ptr++;
|
||||
}
|
||||
static 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);
|
||||
@@ -105,25 +104,25 @@ static ALWAYS_INLINE void rc_normalize(rc_t * rc)
|
||||
* 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)
|
||||
static speed_inline uint32_t rc_is_bit_0_helper(rc_t *rc, uint16_t *p)
|
||||
{
|
||||
rc_normalize(rc);
|
||||
rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
|
||||
return rc->bound;
|
||||
}
|
||||
static 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;
|
||||
}
|
||||
|
||||
/* Called ~10 times, but very small, thus inlined */
|
||||
static speed_inline void rc_update_bit_0(rc_t * rc, uint16_t * p)
|
||||
static speed_inline void rc_update_bit_0(rc_t *rc, uint16_t *p)
|
||||
{
|
||||
rc->range = rc->bound;
|
||||
*p += ((1 << RC_MODEL_TOTAL_BITS) - *p) >> RC_MOVE_BITS;
|
||||
}
|
||||
static speed_inline void rc_update_bit_1(rc_t * rc, uint16_t * p)
|
||||
static speed_inline void rc_update_bit_1(rc_t *rc, uint16_t *p)
|
||||
{
|
||||
rc->range -= rc->bound;
|
||||
rc->code -= rc->bound;
|
||||
@@ -131,7 +130,7 @@ static speed_inline void rc_update_bit_1(rc_t * rc, uint16_t * p)
|
||||
}
|
||||
|
||||
/* Called 4 times in unlzma loop */
|
||||
static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
|
||||
static int rc_get_bit(rc_t *rc, uint16_t *p, int *symbol)
|
||||
{
|
||||
if (rc_is_bit_0(rc, p)) {
|
||||
rc_update_bit_0(rc, p);
|
||||
@@ -145,7 +144,7 @@ static int rc_get_bit(rc_t * rc, uint16_t * p, int *symbol)
|
||||
}
|
||||
|
||||
/* Called once */
|
||||
static 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;
|
||||
@@ -158,7 +157,7 @@ static ALWAYS_INLINE int rc_direct_bit(rc_t * rc)
|
||||
|
||||
/* Called twice */
|
||||
static speed_inline void
|
||||
rc_bit_tree_decode(rc_t * rc, uint16_t * p, int num_levels, int *symbol)
|
||||
rc_bit_tree_decode(rc_t *rc, uint16_t *p, int num_levels, int *symbol)
|
||||
{
|
||||
int i = num_levels;
|
||||
|
||||
@@ -229,7 +228,7 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
USE_DESKTOP(long long) int
|
||||
USE_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
{
|
||||
USE_DESKTOP(long long total_written = 0;)
|
||||
@@ -282,14 +281,16 @@ unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
while (global_pos + buffer_pos < header.dst_size) {
|
||||
int pos_state = (buffer_pos + global_pos) & pos_state_mask;
|
||||
|
||||
prob =
|
||||
p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state;
|
||||
prob = p + LZMA_IS_MATCH + (state << LZMA_NUM_POS_BITS_MAX) + pos_state;
|
||||
if (rc_is_bit_0(rc, prob)) {
|
||||
mi = 1;
|
||||
rc_update_bit_0(rc, prob);
|
||||
prob = (p + LZMA_LITERAL + (LZMA_LIT_SIZE
|
||||
* ((((buffer_pos + global_pos) & literal_pos_mask) << lc)
|
||||
+ (previous_byte >> (8 - lc)))));
|
||||
prob = (p + LZMA_LITERAL
|
||||
+ (LZMA_LIT_SIZE * ((((buffer_pos + global_pos) & literal_pos_mask) << lc)
|
||||
+ (previous_byte >> (8 - lc))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if (state >= LZMA_NUM_LIT_STATES) {
|
||||
int match_byte;
|
||||
@@ -304,35 +305,37 @@ unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
match_byte <<= 1;
|
||||
bit = match_byte & 0x100;
|
||||
prob_lit = prob + 0x100 + bit + mi;
|
||||
if (rc_get_bit(rc, prob_lit, &mi)) {
|
||||
if (!bit)
|
||||
break;
|
||||
} else {
|
||||
if (bit)
|
||||
break;
|
||||
}
|
||||
bit ^= (rc_get_bit(rc, prob_lit, &mi) << 8); /* 0x100 or 0 */
|
||||
if (bit)
|
||||
break;
|
||||
} while (mi < 0x100);
|
||||
}
|
||||
while (mi < 0x100) {
|
||||
prob_lit = prob + mi;
|
||||
rc_get_bit(rc, prob_lit, &mi);
|
||||
}
|
||||
previous_byte = (uint8_t) mi;
|
||||
|
||||
state -= 3;
|
||||
if (state < 4-3)
|
||||
state = 0;
|
||||
if (state >= 10-3)
|
||||
state -= 6-3;
|
||||
|
||||
previous_byte = (uint8_t) mi;
|
||||
#if ENABLE_FEATURE_LZMA_FAST
|
||||
one_byte1:
|
||||
buffer[buffer_pos++] = previous_byte;
|
||||
if (buffer_pos == header.dict_size) {
|
||||
buffer_pos = 0;
|
||||
global_pos += header.dict_size;
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)
|
||||
goto bad;
|
||||
USE_DESKTOP(total_written += header.dict_size;)
|
||||
}
|
||||
if (state < 4)
|
||||
state = 0;
|
||||
else if (state < 10)
|
||||
state -= 3;
|
||||
else
|
||||
state -= 6;
|
||||
#else
|
||||
len = 1;
|
||||
goto one_byte2;
|
||||
#endif
|
||||
} else {
|
||||
int offset;
|
||||
uint16_t *prob_len;
|
||||
@@ -352,24 +355,23 @@ unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
if (rc_is_bit_0(rc, prob)) {
|
||||
rc_update_bit_0(rc, prob);
|
||||
prob = (p + LZMA_IS_REP_0_LONG
|
||||
+ (state << LZMA_NUM_POS_BITS_MAX) + pos_state);
|
||||
+ (state << LZMA_NUM_POS_BITS_MAX)
|
||||
+ pos_state
|
||||
);
|
||||
if (rc_is_bit_0(rc, prob)) {
|
||||
rc_update_bit_0(rc, prob);
|
||||
|
||||
state = state < LZMA_NUM_LIT_STATES ? 9 : 11;
|
||||
#if ENABLE_FEATURE_LZMA_FAST
|
||||
pos = buffer_pos - rep0;
|
||||
while (pos >= header.dict_size)
|
||||
pos += header.dict_size;
|
||||
previous_byte = buffer[pos];
|
||||
buffer[buffer_pos++] = previous_byte;
|
||||
if (buffer_pos == header.dict_size) {
|
||||
buffer_pos = 0;
|
||||
global_pos += header.dict_size;
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
|
||||
goto bad;
|
||||
USE_DESKTOP(total_written += header.dict_size;)
|
||||
}
|
||||
continue;
|
||||
goto one_byte1;
|
||||
#else
|
||||
len = 1;
|
||||
goto string;
|
||||
#endif
|
||||
} else {
|
||||
rc_update_bit_1(rc, prob);
|
||||
}
|
||||
@@ -405,7 +407,7 @@ unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
if (rc_is_bit_0(rc, prob_len)) {
|
||||
rc_update_bit_0(rc, prob_len);
|
||||
prob_len = (prob + LZMA_LEN_LOW
|
||||
+ (pos_state << LZMA_LEN_NUM_LOW_BITS));
|
||||
+ (pos_state << LZMA_LEN_NUM_LOW_BITS));
|
||||
offset = 0;
|
||||
num_bits = LZMA_LEN_NUM_LOW_BITS;
|
||||
} else {
|
||||
@@ -414,14 +416,14 @@ unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
if (rc_is_bit_0(rc, prob_len)) {
|
||||
rc_update_bit_0(rc, prob_len);
|
||||
prob_len = (prob + LZMA_LEN_MID
|
||||
+ (pos_state << LZMA_LEN_NUM_MID_BITS));
|
||||
+ (pos_state << LZMA_LEN_NUM_MID_BITS));
|
||||
offset = 1 << LZMA_LEN_NUM_LOW_BITS;
|
||||
num_bits = LZMA_LEN_NUM_MID_BITS;
|
||||
} else {
|
||||
rc_update_bit_1(rc, prob_len);
|
||||
prob_len = prob + LZMA_LEN_HIGH;
|
||||
offset = ((1 << LZMA_LEN_NUM_LOW_BITS)
|
||||
+ (1 << LZMA_LEN_NUM_MID_BITS));
|
||||
+ (1 << LZMA_LEN_NUM_MID_BITS));
|
||||
num_bits = LZMA_LEN_NUM_HIGH_BITS;
|
||||
}
|
||||
}
|
||||
@@ -432,12 +434,10 @@ unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
int pos_slot;
|
||||
|
||||
state += LZMA_NUM_LIT_STATES;
|
||||
prob =
|
||||
p + LZMA_POS_SLOT +
|
||||
((len <
|
||||
LZMA_NUM_LEN_TO_POS_STATES ? len :
|
||||
LZMA_NUM_LEN_TO_POS_STATES - 1)
|
||||
<< LZMA_NUM_POS_SLOT_BITS);
|
||||
prob = p + LZMA_POS_SLOT +
|
||||
((len < LZMA_NUM_LEN_TO_POS_STATES ? len :
|
||||
LZMA_NUM_LEN_TO_POS_STATES - 1)
|
||||
<< LZMA_NUM_POS_SLOT_BITS);
|
||||
rc_bit_tree_decode(rc, prob, LZMA_NUM_POS_SLOT_BITS,
|
||||
&pos_slot);
|
||||
if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
|
||||
@@ -468,17 +468,18 @@ unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
}
|
||||
|
||||
len += LZMA_MATCH_MIN_LEN;
|
||||
|
||||
SKIP_FEATURE_LZMA_FAST(string:)
|
||||
do {
|
||||
pos = buffer_pos - rep0;
|
||||
while (pos >= header.dict_size)
|
||||
pos += header.dict_size;
|
||||
previous_byte = buffer[pos];
|
||||
SKIP_FEATURE_LZMA_FAST(one_byte2:)
|
||||
buffer[buffer_pos++] = previous_byte;
|
||||
if (buffer_pos == header.dict_size) {
|
||||
buffer_pos = 0;
|
||||
global_pos += header.dict_size;
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != header.dict_size)
|
||||
if (full_write(dst_fd, buffer, header.dict_size) != (ssize_t)header.dict_size)
|
||||
goto bad;
|
||||
USE_DESKTOP(total_written += header.dict_size;)
|
||||
}
|
||||
@@ -487,13 +488,16 @@ unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (full_write(dst_fd, buffer, buffer_pos) != buffer_pos) {
|
||||
{
|
||||
SKIP_DESKTOP(int total_written = 0; /* success */)
|
||||
USE_DESKTOP(total_written += buffer_pos;)
|
||||
if (full_write(dst_fd, buffer, buffer_pos) != (ssize_t)buffer_pos) {
|
||||
bad:
|
||||
total_written = -1; /* failure */
|
||||
}
|
||||
rc_free(rc);
|
||||
return -1;
|
||||
free(p);
|
||||
free(buffer);
|
||||
return total_written;
|
||||
}
|
||||
rc_free(rc);
|
||||
USE_DESKTOP(total_written += buffer_pos;)
|
||||
return USE_DESKTOP(total_written) + 0;
|
||||
}
|
||||
@@ -85,7 +85,8 @@ typedef struct state_t {
|
||||
|
||||
/* input (compressed) data */
|
||||
unsigned char *bytebuffer; /* buffer itself */
|
||||
unsigned bytebuffer_max; /* buffer size */
|
||||
off_t to_read; /* compressed bytes to read (unzip only, -1 for gunzip) */
|
||||
// unsigned bytebuffer_max; /* buffer size */
|
||||
unsigned bytebuffer_offset; /* buffer position */
|
||||
unsigned bytebuffer_size; /* how much data is there (size <= max) */
|
||||
|
||||
@@ -126,7 +127,10 @@ typedef struct state_t {
|
||||
#define gunzip_crc_table (S()gunzip_crc_table )
|
||||
#define gunzip_bb (S()gunzip_bb )
|
||||
#define gunzip_bk (S()gunzip_bk )
|
||||
#define bytebuffer_max (S()bytebuffer_max )
|
||||
#define to_read (S()to_read )
|
||||
// #define bytebuffer_max (S()bytebuffer_max )
|
||||
// Both gunzip and unzip can use constant buffer size now (16k):
|
||||
#define bytebuffer_max 0x4000
|
||||
#define bytebuffer (S()bytebuffer )
|
||||
#define bytebuffer_offset (S()bytebuffer_offset )
|
||||
#define bytebuffer_size (S()bytebuffer_size )
|
||||
@@ -240,7 +244,7 @@ static void huft_free_all(STATE_PARAM_ONLY)
|
||||
inflate_codes_td = NULL;
|
||||
}
|
||||
|
||||
static void abort_unzip(STATE_PARAM_ONLY) ATTRIBUTE_NORETURN;
|
||||
static void abort_unzip(STATE_PARAM_ONLY) NORETURN;
|
||||
static void abort_unzip(STATE_PARAM_ONLY)
|
||||
{
|
||||
huft_free_all(PASS_STATE_ONLY);
|
||||
@@ -251,13 +255,18 @@ static unsigned fill_bitbuffer(STATE_PARAM unsigned bitbuffer, unsigned *current
|
||||
{
|
||||
while (*current < required) {
|
||||
if (bytebuffer_offset >= bytebuffer_size) {
|
||||
unsigned sz = bytebuffer_max - 4;
|
||||
if (to_read >= 0 && to_read < sz) /* unzip only */
|
||||
sz = to_read;
|
||||
/* Leave the first 4 bytes empty so we can always unwind the bitbuffer
|
||||
* to the front of the bytebuffer */
|
||||
bytebuffer_size = safe_read(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 4);
|
||||
bytebuffer_size = safe_read(gunzip_src_fd, &bytebuffer[4], sz);
|
||||
if ((int)bytebuffer_size < 1) {
|
||||
error_msg = "unexpected end of file";
|
||||
abort_unzip(PASS_STATE_ONLY);
|
||||
}
|
||||
if (to_read >= 0) /* unzip only */
|
||||
to_read -= bytebuffer_size;
|
||||
bytebuffer_size += 4;
|
||||
bytebuffer_offset = 4;
|
||||
}
|
||||
@@ -913,7 +922,7 @@ static int inflate_block(STATE_PARAM smallint *e)
|
||||
/* Two callsites, both in inflate_get_next_window */
|
||||
static void calculate_gunzip_crc(STATE_PARAM_ONLY)
|
||||
{
|
||||
int n;
|
||||
unsigned n;
|
||||
for (n = 0; n < gunzip_outbuf_count; n++) {
|
||||
gunzip_crc = gunzip_crc_table[((int) gunzip_crc ^ (gunzip_window[n])) & 0xff] ^ (gunzip_crc >> 8);
|
||||
}
|
||||
@@ -994,7 +1003,7 @@ inflate_unzip_internal(STATE_PARAM int in, int out)
|
||||
while (1) {
|
||||
int r = inflate_get_next_window(PASS_STATE_ONLY);
|
||||
nwrote = full_write(out, gunzip_window, gunzip_outbuf_count);
|
||||
if (nwrote != gunzip_outbuf_count) {
|
||||
if (nwrote != (ssize_t)gunzip_outbuf_count) {
|
||||
bb_perror_msg("write");
|
||||
n = -1;
|
||||
goto ret;
|
||||
@@ -1024,15 +1033,16 @@ inflate_unzip_internal(STATE_PARAM int in, int out)
|
||||
|
||||
/* For unzip */
|
||||
|
||||
USE_DESKTOP(long long) int
|
||||
inflate_unzip(inflate_unzip_result *res, unsigned bufsize, int in, int out)
|
||||
USE_DESKTOP(long long) int FAST_FUNC
|
||||
inflate_unzip(inflate_unzip_result *res, off_t compr_size, int in, int out)
|
||||
{
|
||||
USE_DESKTOP(long long) int n;
|
||||
DECLARE_STATE;
|
||||
|
||||
ALLOC_STATE;
|
||||
|
||||
bytebuffer_max = bufsize + 4;
|
||||
to_read = compr_size;
|
||||
// bytebuffer_max = 0x8000;
|
||||
bytebuffer_offset = 4;
|
||||
bytebuffer = xmalloc(bytebuffer_max);
|
||||
n = inflate_unzip_internal(PASS_STATE in, out);
|
||||
@@ -1054,7 +1064,7 @@ static int top_up(STATE_PARAM unsigned n)
|
||||
{
|
||||
int count = bytebuffer_size - bytebuffer_offset;
|
||||
|
||||
if (count < n) {
|
||||
if (count < (int)n) {
|
||||
memmove(bytebuffer, &bytebuffer[bytebuffer_offset], count);
|
||||
bytebuffer_offset = 0;
|
||||
bytebuffer_size = full_read(gunzip_src_fd, &bytebuffer[count], bytebuffer_max - count);
|
||||
@@ -1166,7 +1176,7 @@ static int check_header_gzip(STATE_PARAM_ONLY)
|
||||
return 1;
|
||||
}
|
||||
|
||||
USE_DESKTOP(long long) int
|
||||
USE_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_gz_stream(int in, int out)
|
||||
{
|
||||
uint32_t v32;
|
||||
@@ -1176,7 +1186,8 @@ unpack_gz_stream(int in, int out)
|
||||
n = 0;
|
||||
|
||||
ALLOC_STATE;
|
||||
bytebuffer_max = 0x8000;
|
||||
to_read = -1;
|
||||
// bytebuffer_max = 0x8000;
|
||||
bytebuffer = xmalloc(bytebuffer_max);
|
||||
gunzip_src_fd = in;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "unarchive.h"
|
||||
|
||||
/* Accept any non-null name, its not really a filter at all */
|
||||
char filter_accept_all(archive_handle_t *archive_handle)
|
||||
char FAST_FUNC filter_accept_all(archive_handle_t *archive_handle)
|
||||
{
|
||||
if (archive_handle->file_header->name)
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/*
|
||||
* Accept names that are in the accept list, ignoring reject list.
|
||||
*/
|
||||
char filter_accept_list(archive_handle_t *archive_handle)
|
||||
char FAST_FUNC filter_accept_list(archive_handle_t *archive_handle)
|
||||
{
|
||||
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name))
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
@@ -8,34 +8,41 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/* Built and used only if ENABLE_DPKG || ENABLE_DPKG_DEB */
|
||||
|
||||
/*
|
||||
* Reassign the subarchive metadata parser based on the filename extension
|
||||
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz
|
||||
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
|
||||
*/
|
||||
char filter_accept_list_reassign(archive_handle_t *archive_handle)
|
||||
char FAST_FUNC filter_accept_list_reassign(archive_handle_t *archive_handle)
|
||||
{
|
||||
/* Check the file entry is in the accept list */
|
||||
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
|
||||
const char *name_ptr;
|
||||
|
||||
/* Extract the last 2 extensions */
|
||||
/* Find extension */
|
||||
name_ptr = strrchr(archive_handle->file_header->name, '.');
|
||||
if (!name_ptr)
|
||||
return EXIT_FAILURE;
|
||||
name_ptr++;
|
||||
|
||||
/* Modify the subarchive handler based on the extension */
|
||||
#if ENABLE_FEATURE_DEB_TAR_GZ
|
||||
if (strcmp(name_ptr, ".gz") == 0) {
|
||||
if (ENABLE_FEATURE_SEAMLESS_GZ
|
||||
&& strcmp(name_ptr, "gz") == 0
|
||||
) {
|
||||
archive_handle->action_data_subarchive = get_header_tar_gz;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_FEATURE_DEB_TAR_BZ2
|
||||
if (strcmp(name_ptr, ".bz2") == 0) {
|
||||
if (ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
&& strcmp(name_ptr, "bz2") == 0
|
||||
) {
|
||||
archive_handle->action_data_subarchive = get_header_tar_bz2;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
if (ENABLE_FEATURE_DEB_TAR_LZMA && !strcmp(name_ptr, ".lzma")) {
|
||||
if (ENABLE_FEATURE_SEAMLESS_LZMA
|
||||
&& strcmp(name_ptr, "lzma") == 0
|
||||
) {
|
||||
archive_handle->action_data_subarchive = get_header_tar_lzma;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -11,13 +11,16 @@
|
||||
/*
|
||||
* Accept names that are in the accept list and not in the reject list
|
||||
*/
|
||||
char filter_accept_reject_list(archive_handle_t *archive_handle)
|
||||
char FAST_FUNC filter_accept_reject_list(archive_handle_t *archive_handle)
|
||||
{
|
||||
const char *key = archive_handle->file_header->name;
|
||||
const llist_t *reject_entry = find_list_entry2(archive_handle->reject, key);
|
||||
const char *key;
|
||||
const llist_t *reject_entry;
|
||||
const llist_t *accept_entry;
|
||||
|
||||
key = archive_handle->file_header->name;
|
||||
|
||||
/* If the key is in a reject list fail */
|
||||
reject_entry = find_list_entry2(archive_handle->reject, key);
|
||||
if (reject_entry) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "unarchive.h"
|
||||
|
||||
/* Find a string in a shell pattern list */
|
||||
const llist_t *find_list_entry(const llist_t *list, const char *filename)
|
||||
const llist_t* FAST_FUNC find_list_entry(const llist_t *list, const char *filename)
|
||||
{
|
||||
while (list) {
|
||||
if (fnmatch(list->data, filename, 0) == 0) {
|
||||
@@ -24,7 +24,7 @@ const llist_t *find_list_entry(const llist_t *list, const char *filename)
|
||||
/* Same, but compares only path components present in pattern
|
||||
* (extra trailing path components in filename are assumed to match)
|
||||
*/
|
||||
const llist_t *find_list_entry2(const llist_t *list, const char *filename)
|
||||
const llist_t* FAST_FUNC find_list_entry2(const llist_t *list, const char *filename)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
int pattern_slash_cnt;
|
||||
@@ -38,7 +38,7 @@ const llist_t *find_list_entry2(const llist_t *list, const char *filename)
|
||||
if (*c++ == '/') pattern_slash_cnt++;
|
||||
c = filename;
|
||||
d = buf;
|
||||
/* paranoia is better that buffer overflows */
|
||||
/* paranoia is better than buffer overflows */
|
||||
while (*c && d != buf + sizeof(buf)-1) {
|
||||
if (*c == '/' && --pattern_slash_cnt < 0)
|
||||
break;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
char get_header_ar(archive_handle_t *archive_handle)
|
||||
char FAST_FUNC get_header_ar(archive_handle_t *archive_handle)
|
||||
{
|
||||
int err;
|
||||
file_header_t *typed = archive_handle->file_header;
|
||||
@@ -108,12 +108,13 @@ char get_header_ar(archive_handle_t *archive_handle)
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_header(typed);
|
||||
#if ENABLE_DPKG || ENABLE_DPKG_DEB
|
||||
if (archive_handle->sub_archive) {
|
||||
while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS)
|
||||
/* repeat */;
|
||||
} else {
|
||||
continue;
|
||||
} else
|
||||
#endif
|
||||
archive_handle->action_data(archive_handle);
|
||||
}
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
}
|
||||
|
||||
@@ -7,71 +7,41 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
typedef struct hardlinks_s {
|
||||
char *name;
|
||||
int inode;
|
||||
struct hardlinks_s *next;
|
||||
typedef struct hardlinks_t {
|
||||
struct hardlinks_t *next;
|
||||
int inode; /* TODO: must match maj/min too! */
|
||||
int mode ;
|
||||
int mtime; /* These three are useful only in corner case */
|
||||
int uid ; /* of hardlinks with zero size body */
|
||||
int gid ;
|
||||
char name[1];
|
||||
} hardlinks_t;
|
||||
|
||||
char get_header_cpio(archive_handle_t *archive_handle)
|
||||
char FAST_FUNC get_header_cpio(archive_handle_t *archive_handle)
|
||||
{
|
||||
static hardlinks_t *saved_hardlinks = NULL;
|
||||
static unsigned pending_hardlinks = 0;
|
||||
static int inode;
|
||||
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
char cpio_header[110];
|
||||
int namesize;
|
||||
char dummy[16];
|
||||
int major, minor, nlink;
|
||||
int major, minor, nlink, mode, inode;
|
||||
unsigned size, uid, gid, mtime;
|
||||
|
||||
if (pending_hardlinks) { /* Deal with any pending hardlinks */
|
||||
hardlinks_t *tmp, *oldtmp;
|
||||
|
||||
tmp = saved_hardlinks;
|
||||
oldtmp = NULL;
|
||||
|
||||
file_header->link_target = file_header->name;
|
||||
file_header->size = 0;
|
||||
|
||||
while (tmp) {
|
||||
if (tmp->inode != inode) {
|
||||
tmp = tmp->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
file_header->name = tmp->name;
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_data(archive_handle);
|
||||
archive_handle->action_header(archive_handle->file_header);
|
||||
}
|
||||
|
||||
pending_hardlinks--;
|
||||
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
free(oldtmp->name);
|
||||
free(oldtmp);
|
||||
if (oldtmp == saved_hardlinks)
|
||||
saved_hardlinks = tmp;
|
||||
}
|
||||
|
||||
file_header->name = file_header->link_target;
|
||||
|
||||
if (pending_hardlinks > 1) {
|
||||
bb_error_msg("error resolving hardlink: archive made by GNU cpio 2.0-2.2?");
|
||||
}
|
||||
|
||||
/* No more pending hardlinks, read next file entry */
|
||||
pending_hardlinks = 0;
|
||||
}
|
||||
#define hardlinks_to_create (*(hardlinks_t **)(&archive_handle->ah_priv[0]))
|
||||
#define created_hardlinks (*(hardlinks_t **)(&archive_handle->ah_priv[1]))
|
||||
// if (!archive_handle->ah_priv_inited) {
|
||||
// archive_handle->ah_priv_inited = 1;
|
||||
// hardlinks_to_create = NULL;
|
||||
// created_hardlinks = NULL;
|
||||
// }
|
||||
|
||||
/* There can be padding before archive header */
|
||||
data_align(archive_handle, 4);
|
||||
|
||||
if (archive_xread_all_eof(archive_handle, (unsigned char*)cpio_header, 110) == 0) {
|
||||
return EXIT_FAILURE;
|
||||
size = full_read(archive_handle->src_fd, cpio_header, 110);
|
||||
if (size == 0) {
|
||||
goto create_hardlinks;
|
||||
}
|
||||
if (size != 110) {
|
||||
bb_error_msg_and_die("short read");
|
||||
}
|
||||
archive_handle->offset += 110;
|
||||
|
||||
@@ -81,17 +51,21 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
bb_error_msg_and_die("unsupported cpio format, use newc or crc");
|
||||
}
|
||||
|
||||
{
|
||||
unsigned long tmpsize;
|
||||
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
|
||||
dummy, &inode, (unsigned int*)&file_header->mode,
|
||||
(unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
|
||||
&nlink, &file_header->mtime, &tmpsize,
|
||||
dummy, &major, &minor, &namesize, dummy);
|
||||
file_header->size = tmpsize;
|
||||
}
|
||||
if (sscanf(cpio_header + 6,
|
||||
"%8x" "%8x" "%8x" "%8x"
|
||||
"%8x" "%8x" "%8x" /*maj,min:*/ "%*16c"
|
||||
/*rmaj,rmin:*/"%8x" "%8x" "%8x" /*chksum: "%*8c"*/,
|
||||
&inode, &mode, &uid, &gid,
|
||||
&nlink, &mtime, &size,
|
||||
&major, &minor, &namesize) != 10)
|
||||
bb_error_msg_and_die("damaged cpio file");
|
||||
file_header->mode = mode;
|
||||
file_header->uid = uid;
|
||||
file_header->gid = gid;
|
||||
file_header->mtime = mtime;
|
||||
file_header->size = size;
|
||||
|
||||
free(file_header->name);
|
||||
namesize &= 0x1fff; /* paranoia: limit names to 8k chars */
|
||||
file_header->name = xzalloc(namesize + 1);
|
||||
/* Read in filename */
|
||||
xread(archive_handle->src_fd, file_header->name, namesize);
|
||||
@@ -101,54 +75,46 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
data_align(archive_handle, 4);
|
||||
|
||||
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
|
||||
/* Always round up */
|
||||
printf("%d blocks\n", (int) (archive_handle->offset % 512 ?
|
||||
archive_handle->offset / 512 + 1 :
|
||||
archive_handle->offset / 512
|
||||
));
|
||||
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
|
||||
hardlinks_t *tmp = saved_hardlinks;
|
||||
hardlinks_t *oldtmp = NULL;
|
||||
while (tmp) {
|
||||
bb_error_msg("%s not created: cannot resolve hardlink", tmp->name);
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
free(oldtmp->name);
|
||||
free(oldtmp);
|
||||
}
|
||||
saved_hardlinks = NULL;
|
||||
pending_hardlinks = 0;
|
||||
}
|
||||
return EXIT_FAILURE;
|
||||
/* Always round up. ">> 9" divides by 512 */
|
||||
printf("%"OFF_FMT"u blocks\n", (archive_handle->offset + 511) >> 9);
|
||||
goto create_hardlinks;
|
||||
}
|
||||
|
||||
file_header->link_target = NULL;
|
||||
if (S_ISLNK(file_header->mode)) {
|
||||
file_header->size &= 0x1fff; /* paranoia: limit names to 8k chars */
|
||||
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_target = NULL;
|
||||
}
|
||||
if (nlink > 1 && !S_ISDIR(file_header->mode)) {
|
||||
if (file_header->size == 0) { /* Put file on a linked list for later */
|
||||
hardlinks_t *new = xmalloc(sizeof(hardlinks_t));
|
||||
new->next = saved_hardlinks;
|
||||
new->inode = inode;
|
||||
/* name current allocated, freed later */
|
||||
new->name = file_header->name;
|
||||
file_header->name = NULL;
|
||||
saved_hardlinks = new;
|
||||
|
||||
// TODO: data_extract_all can't deal with hardlinks to non-files...
|
||||
// when fixed, change S_ISREG to !S_ISDIR here
|
||||
|
||||
if (nlink > 1 && S_ISREG(file_header->mode)) {
|
||||
hardlinks_t *new = xmalloc(sizeof(*new) + namesize);
|
||||
new->inode = inode;
|
||||
new->mode = mode ;
|
||||
new->mtime = mtime;
|
||||
new->uid = uid ;
|
||||
new->gid = gid ;
|
||||
strcpy(new->name, file_header->name);
|
||||
/* Put file on a linked list for later */
|
||||
if (size == 0) {
|
||||
new->next = hardlinks_to_create;
|
||||
hardlinks_to_create = new;
|
||||
return EXIT_SUCCESS; /* Skip this one */
|
||||
/* TODO: this breaks cpio -t (it does not show hardlinks) */
|
||||
}
|
||||
/* Found the file with data in */
|
||||
pending_hardlinks = nlink;
|
||||
new->next = created_hardlinks;
|
||||
created_hardlinks = new;
|
||||
}
|
||||
file_header->device = makedev(major, minor);
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_data(archive_handle);
|
||||
archive_handle->action_header(archive_handle->file_header);
|
||||
archive_handle->action_header(file_header);
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
}
|
||||
@@ -156,6 +122,60 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
free(file_header->link_target);
|
||||
free(file_header->name);
|
||||
file_header->link_target = NULL;
|
||||
file_header->name = NULL;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
create_hardlinks:
|
||||
free(file_header->link_target);
|
||||
free(file_header->name);
|
||||
|
||||
while (hardlinks_to_create) {
|
||||
hardlinks_t *cur;
|
||||
hardlinks_t *make_me = hardlinks_to_create;
|
||||
|
||||
hardlinks_to_create = make_me->next;
|
||||
|
||||
memset(file_header, 0, sizeof(*file_header));
|
||||
file_header->mtime = make_me->mtime;
|
||||
file_header->name = make_me->name;
|
||||
file_header->mode = make_me->mode;
|
||||
file_header->uid = make_me->uid;
|
||||
file_header->gid = make_me->gid;
|
||||
/*file_header->size = 0;*/
|
||||
/*file_header->link_target = NULL;*/
|
||||
|
||||
/* Try to find a file we are hardlinked to */
|
||||
cur = created_hardlinks;
|
||||
while (cur) {
|
||||
/* TODO: must match maj/min too! */
|
||||
if (cur->inode == make_me->inode) {
|
||||
file_header->link_target = cur->name;
|
||||
/* link_target != NULL, size = 0: "I am a hardlink" */
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS)
|
||||
archive_handle->action_data(archive_handle);
|
||||
free(make_me);
|
||||
goto next_link;
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
/* Oops... no file with such inode was created... do it now
|
||||
* (happens when hardlinked files are empty (zero length)) */
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS)
|
||||
archive_handle->action_data(archive_handle);
|
||||
/* Move to the list of created hardlinked files */
|
||||
make_me->next = created_hardlinks;
|
||||
created_hardlinks = make_me;
|
||||
next_link: ;
|
||||
}
|
||||
|
||||
while (created_hardlinks) {
|
||||
hardlinks_t *p = created_hardlinks;
|
||||
created_hardlinks = p->next;
|
||||
free(p);
|
||||
}
|
||||
|
||||
return EXIT_FAILURE; /* "No more files to process" */
|
||||
}
|
||||
@@ -14,26 +14,13 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
static char *longname;
|
||||
static char *linkname;
|
||||
#else
|
||||
enum {
|
||||
longname = 0,
|
||||
linkname = 0,
|
||||
};
|
||||
#endif
|
||||
|
||||
/* NB: _DESTROYS_ str[len] character! */
|
||||
static unsigned long long getOctal(char *str, int len)
|
||||
{
|
||||
unsigned long long v;
|
||||
/* Actually, tar header allows leading spaces also.
|
||||
* Oh well, we will be liberal and skip this...
|
||||
* The only downside probably is that we allow "-123" too :)
|
||||
if (*str < '0' || *str > '7')
|
||||
bb_error_msg_and_die("corrupted octal value in tar header");
|
||||
*/
|
||||
/* NB: leading spaces are allowed. Using strtoull to handle that.
|
||||
* The downside is that we accept e.g. "-123" too :)
|
||||
*/
|
||||
str[len] = '\0';
|
||||
v = strtoull(str, &str, 8);
|
||||
if (*str && (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY || *str != ' '))
|
||||
@@ -43,10 +30,8 @@ static unsigned long long getOctal(char *str, int len)
|
||||
#define GET_OCTAL(a) getOctal((a), sizeof(a))
|
||||
|
||||
void BUG_tar_header_size(void);
|
||||
char get_header_tar(archive_handle_t *archive_handle)
|
||||
char FAST_FUNC get_header_tar(archive_handle_t *archive_handle)
|
||||
{
|
||||
static smallint end;
|
||||
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
struct {
|
||||
/* ustar header, Posix 1003.1 */
|
||||
@@ -62,7 +47,7 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
/* POSIX: "ustar" NUL "00" */
|
||||
/* GNU tar: "ustar " NUL */
|
||||
/* Normally it's defined as magic[6] followed by
|
||||
* version[2], but we put them together to save code.
|
||||
* version[2], but we put them together to simplify code
|
||||
*/
|
||||
char magic[8]; /* 257-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
@@ -79,6 +64,22 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
#endif
|
||||
int parse_names;
|
||||
|
||||
/* Our "private data" */
|
||||
#define p_end (*(smallint *)(&archive_handle->ah_priv[0]))
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
#define p_longname (*(char* *)(&archive_handle->ah_priv[1]))
|
||||
#define p_linkname (*(char* *)(&archive_handle->ah_priv[2]))
|
||||
#else
|
||||
#define p_longname 0
|
||||
#define p_linkname 0
|
||||
#endif
|
||||
// if (!archive_handle->ah_priv_inited) {
|
||||
// archive_handle->ah_priv_inited = 1;
|
||||
// p_end = 0;
|
||||
// USE_FEATURE_TAR_GNU_EXTENSIONS(p_longname = NULL;)
|
||||
// USE_FEATURE_TAR_GNU_EXTENSIONS(p_linkname = NULL;)
|
||||
// }
|
||||
|
||||
if (sizeof(tar) != 512)
|
||||
BUG_tar_header_size();
|
||||
|
||||
@@ -90,32 +91,87 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
|
||||
again_after_align:
|
||||
|
||||
xread(archive_handle->src_fd, &tar, 512);
|
||||
archive_handle->offset += 512;
|
||||
#if ENABLE_DESKTOP
|
||||
/* to prevent misdetection of bz2 sig */
|
||||
*(uint32_t*)(&tar) = 0;
|
||||
i = full_read(archive_handle->src_fd, &tar, 512);
|
||||
/* If GNU tar sees EOF in above read, it says:
|
||||
* "tar: A lone zero block at N", where N = kilobyte
|
||||
* where EOF was met (not EOF block, actual EOF!),
|
||||
* and exits with EXIT_SUCCESS.
|
||||
* We will mimic exit(EXIT_SUCCESS), although we will not mimic
|
||||
* the message and we don't check whether we indeed
|
||||
* saw zero block directly before this. */
|
||||
if (i == 0) {
|
||||
xfunc_error_retval = 0;
|
||||
short_read:
|
||||
bb_error_msg_and_die("short read");
|
||||
}
|
||||
if (i != 512) {
|
||||
USE_FEATURE_TAR_AUTODETECT(goto autodetect;)
|
||||
goto short_read;
|
||||
}
|
||||
|
||||
#else
|
||||
i = 512;
|
||||
xread(archive_handle->src_fd, &tar, i);
|
||||
#endif
|
||||
archive_handle->offset += i;
|
||||
|
||||
/* If there is no filename its an empty header */
|
||||
if (tar.name[0] == 0) {
|
||||
if (end) {
|
||||
/* This is the second consecutive empty header! End of archive!
|
||||
if (tar.name[0] == 0 && tar.prefix[0] == 0) {
|
||||
if (p_end) {
|
||||
/* Second consecutive empty header - end of archive.
|
||||
* Read until the end to empty the pipe from gz or bz2
|
||||
*/
|
||||
while (full_read(archive_handle->src_fd, &tar, 512) == 512)
|
||||
/* repeat */;
|
||||
continue;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
end = 1;
|
||||
p_end = 1;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
end = 0;
|
||||
p_end = 0;
|
||||
|
||||
/* Check header has valid magic, "ustar" is for the proper tar
|
||||
* 0's are for the old tar format
|
||||
*/
|
||||
if (strncmp(tar.magic, "ustar", 5) != 0) {
|
||||
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
if (memcmp(tar.magic, "\0\0\0\0", 5) != 0)
|
||||
/* Check header has valid magic, "ustar" is for the proper tar,
|
||||
* five NULs are for the old tar format */
|
||||
if (strncmp(tar.magic, "ustar", 5) != 0
|
||||
&& (!ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
|| memcmp(tar.magic, "\0\0\0\0", 5) != 0)
|
||||
) {
|
||||
#if ENABLE_FEATURE_TAR_AUTODETECT
|
||||
char FAST_FUNC (*get_header_ptr)(archive_handle_t *);
|
||||
|
||||
USE_DESKTOP(autodetect:)
|
||||
/* tar gz/bz autodetect: check for gz/bz2 magic.
|
||||
* If we see the magic, and it is the very first block,
|
||||
* we can switch to get_header_tar_gz/bz2/lzma().
|
||||
* Needs seekable fd. I wish recv(MSG_PEEK) works
|
||||
* on any fd... */
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ
|
||||
if (tar.name[0] == 0x1f && tar.name[1] == (char)0x8b) { /* gzip */
|
||||
get_header_ptr = get_header_tar_gz;
|
||||
} else
|
||||
#endif
|
||||
bb_error_msg_and_die("invalid tar magic");
|
||||
#if ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
if (tar.name[0] == 'B' && tar.name[1] == 'Z'
|
||||
&& tar.name[2] == 'h' && isdigit(tar.name[3])
|
||||
) { /* bzip2 */
|
||||
get_header_ptr = get_header_tar_bz2;
|
||||
} else
|
||||
#endif
|
||||
goto err;
|
||||
/* Two different causes for lseek() != 0:
|
||||
* unseekable fd (would like to support that too, but...),
|
||||
* or not first block (false positive, it's not .gz/.bz2!) */
|
||||
if (lseek(archive_handle->src_fd, -i, SEEK_CUR) != 0)
|
||||
goto err;
|
||||
while (get_header_ptr(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
return EXIT_FAILURE;
|
||||
err:
|
||||
#endif /* FEATURE_TAR_AUTODETECT */
|
||||
bb_error_msg_and_die("invalid tar magic");
|
||||
}
|
||||
|
||||
/* Do checksum on headers.
|
||||
@@ -160,18 +216,23 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
/* getOctal trashes subsequent field, therefore we call it
|
||||
* on fields in reverse order */
|
||||
if (tar.devmajor[0]) {
|
||||
char t = tar.prefix[0];
|
||||
/* we trash prefix[0] here, but we DO need it later! */
|
||||
unsigned minor = GET_OCTAL(tar.devminor);
|
||||
unsigned major = GET_OCTAL(tar.devmajor);
|
||||
file_header->device = makedev(major, minor);
|
||||
tar.prefix[0] = t;
|
||||
}
|
||||
file_header->link_target = NULL;
|
||||
if (!linkname && parse_names && tar.linkname[0]) {
|
||||
/* we trash magic[0] here, it's ok */
|
||||
tar.linkname[sizeof(tar.linkname)] = '\0';
|
||||
file_header->link_target = xstrdup(tar.linkname);
|
||||
if (!p_linkname && parse_names && tar.linkname[0]) {
|
||||
file_header->link_target = xstrndup(tar.linkname, sizeof(tar.linkname));
|
||||
/* FIXME: what if we have non-link object with link_target? */
|
||||
/* Will link_target be free()ed? */
|
||||
}
|
||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||
file_header->uname = tar.uname[0] ? xstrndup(tar.uname, sizeof(tar.uname)) : NULL;
|
||||
file_header->gname = tar.gname[0] ? xstrndup(tar.gname, sizeof(tar.gname)) : NULL;
|
||||
#endif
|
||||
file_header->mtime = GET_OCTAL(tar.mtime);
|
||||
file_header->size = GET_OCTAL(tar.size);
|
||||
file_header->gid = GET_OCTAL(tar.gid);
|
||||
@@ -180,12 +241,14 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
file_header->mode = 07777 & GET_OCTAL(tar.mode);
|
||||
|
||||
file_header->name = NULL;
|
||||
if (!longname && parse_names) {
|
||||
if (!p_longname && parse_names) {
|
||||
/* we trash mode[0] here, it's ok */
|
||||
tar.name[sizeof(tar.name)] = '\0';
|
||||
//tar.name[sizeof(tar.name)] = '\0'; - gcc 4.3.0 would complain
|
||||
tar.mode[0] = '\0';
|
||||
if (tar.prefix[0]) {
|
||||
/* and padding[0] */
|
||||
tar.prefix[sizeof(tar.prefix)] = '\0';
|
||||
//tar.prefix[sizeof(tar.prefix)] = '\0'; - gcc 4.3.0 would complain
|
||||
tar.padding[0] = '\0';
|
||||
file_header->name = concat_path_file(tar.prefix, tar.name);
|
||||
} else
|
||||
file_header->name = xstrdup(tar.name);
|
||||
@@ -203,43 +266,48 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
case '0':
|
||||
#if ENABLE_FEATURE_TAR_OLDGNU_COMPATIBILITY
|
||||
if (last_char_is(file_header->name, '/')) {
|
||||
file_header->mode |= S_IFDIR;
|
||||
} else
|
||||
goto set_dir;
|
||||
}
|
||||
#endif
|
||||
file_header->mode |= S_IFREG;
|
||||
break;
|
||||
case '2':
|
||||
file_header->mode |= S_IFLNK;
|
||||
/* have seen tarballs with size field containing
|
||||
* the size of the link target's name */
|
||||
size0:
|
||||
file_header->size = 0;
|
||||
break;
|
||||
case '3':
|
||||
file_header->mode |= S_IFCHR;
|
||||
break;
|
||||
goto size0; /* paranoia */
|
||||
case '4':
|
||||
file_header->mode |= S_IFBLK;
|
||||
break;
|
||||
goto size0;
|
||||
case '5':
|
||||
USE_FEATURE_TAR_OLDGNU_COMPATIBILITY(set_dir:)
|
||||
file_header->mode |= S_IFDIR;
|
||||
break;
|
||||
goto size0;
|
||||
case '6':
|
||||
file_header->mode |= S_IFIFO;
|
||||
break;
|
||||
goto size0;
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
case 'L':
|
||||
/* free: paranoia: tar with several consecutive longnames */
|
||||
free(longname);
|
||||
free(p_longname);
|
||||
/* For paranoia reasons we allocate extra NUL char */
|
||||
longname = xzalloc(file_header->size + 1);
|
||||
p_longname = xzalloc(file_header->size + 1);
|
||||
/* We read ASCIZ string, including NUL */
|
||||
xread(archive_handle->src_fd, longname, file_header->size);
|
||||
xread(archive_handle->src_fd, p_longname, file_header->size);
|
||||
archive_handle->offset += file_header->size;
|
||||
/* return get_header_tar(archive_handle); */
|
||||
/* gcc 4.1.1 didn't optimize it into jump */
|
||||
/* so we will do it ourself, this also saves stack */
|
||||
goto again;
|
||||
case 'K':
|
||||
free(linkname);
|
||||
linkname = xzalloc(file_header->size + 1);
|
||||
xread(archive_handle->src_fd, linkname, file_header->size);
|
||||
free(p_linkname);
|
||||
p_linkname = xzalloc(file_header->size + 1);
|
||||
xread(archive_handle->src_fd, p_linkname, file_header->size);
|
||||
archive_handle->offset += file_header->size;
|
||||
/* return get_header_tar(archive_handle); */
|
||||
goto again;
|
||||
@@ -266,16 +334,16 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_TAR_GNU_EXTENSIONS
|
||||
if (longname) {
|
||||
file_header->name = longname;
|
||||
longname = NULL;
|
||||
if (p_longname) {
|
||||
file_header->name = p_longname;
|
||||
p_longname = NULL;
|
||||
}
|
||||
if (linkname) {
|
||||
file_header->link_target = linkname;
|
||||
linkname = NULL;
|
||||
if (p_linkname) {
|
||||
file_header->link_target = p_linkname;
|
||||
p_linkname = NULL;
|
||||
}
|
||||
#endif
|
||||
if (!strncmp(file_header->name, "/../"+1, 3)
|
||||
if (strncmp(file_header->name, "/../"+1, 3) == 0
|
||||
|| strstr(file_header->name, "/../")
|
||||
) {
|
||||
bb_error_msg_and_die("name with '..' encountered: '%s'",
|
||||
@@ -287,11 +355,11 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
cp = last_char_is(file_header->name, '/');
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_header(archive_handle->file_header);
|
||||
archive_handle->action_header(/*archive_handle->*/ file_header);
|
||||
/* Note that we kill the '/' only after action_header() */
|
||||
/* (like GNU tar 1.15.1: verbose mode outputs "dir/dir/") */
|
||||
if (cp) *cp = '\0';
|
||||
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
|
||||
archive_handle->ah_flags |= ARCHIVE_EXTRACT_QUIET;
|
||||
archive_handle->action_data(archive_handle);
|
||||
llist_add_to(&(archive_handle->passed), file_header->name);
|
||||
} else {
|
||||
@@ -301,7 +369,10 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
free(file_header->link_target);
|
||||
/* Do not free(file_header->name)! */
|
||||
|
||||
/* Do not free(file_header->name)! (why?) */
|
||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||
free(file_header->uname);
|
||||
free(file_header->gname);
|
||||
#endif
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -6,12 +6,12 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
char get_header_tar_bz2(archive_handle_t *archive_handle)
|
||||
char FAST_FUNC 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, unpack_bz2_stream, "bunzip2");
|
||||
open_transformer(archive_handle->src_fd, unpack_bz2_stream_prime, "bunzip2");
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
char get_header_tar_gz(archive_handle_t *archive_handle)
|
||||
char FAST_FUNC get_header_tar_gz(archive_handle_t *archive_handle)
|
||||
{
|
||||
#if BB_MMU
|
||||
unsigned char magic[2];
|
||||
@@ -20,12 +20,13 @@ char get_header_tar_gz(archive_handle_t *archive_handle)
|
||||
* need the header. */
|
||||
#if BB_MMU
|
||||
xread(archive_handle->src_fd, &magic, 2);
|
||||
/* Can skip this check, but error message will be less clear */
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("invalid gzip magic");
|
||||
}
|
||||
#endif
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip");
|
||||
open_transformer(archive_handle->src_fd, unpack_gz_stream, "gunzip");
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
char get_header_tar_lzma(archive_handle_t * archive_handle)
|
||||
char FAST_FUNC 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, unpack_lzma_stream, "unlzma");
|
||||
open_transformer(archive_handle->src_fd, unpack_lzma_stream, "unlzma");
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void header_list(const file_header_t *file_header)
|
||||
void FAST_FUNC header_list(const file_header_t *file_header)
|
||||
{
|
||||
puts(file_header->name);
|
||||
}
|
||||
@@ -5,6 +5,6 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void header_skip(const file_header_t *file_header ATTRIBUTE_UNUSED)
|
||||
void FAST_FUNC header_skip(const file_header_t *file_header UNUSED_PARAM)
|
||||
{
|
||||
}
|
||||
@@ -6,10 +6,37 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void header_verbose_list(const file_header_t *file_header)
|
||||
void FAST_FUNC header_verbose_list(const file_header_t *file_header)
|
||||
{
|
||||
struct tm *mtime = localtime(&(file_header->mtime));
|
||||
|
||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||
char uid[8];
|
||||
char gid[8];
|
||||
char *user = file_header->uname;
|
||||
char *group = file_header->gname;
|
||||
|
||||
if (user == NULL) {
|
||||
snprintf(uid, sizeof(uid), "%u", (unsigned)file_header->uid);
|
||||
user = uid;
|
||||
}
|
||||
if (group == NULL) {
|
||||
snprintf(gid, sizeof(gid), "%u", (unsigned)file_header->gid);
|
||||
group = gid;
|
||||
}
|
||||
printf("%s %s/%s %9u %4u-%02u-%02u %02u:%02u:%02u %s",
|
||||
bb_mode_string(file_header->mode),
|
||||
user,
|
||||
group,
|
||||
(unsigned int) file_header->size,
|
||||
1900 + mtime->tm_year,
|
||||
1 + mtime->tm_mon,
|
||||
mtime->tm_mday,
|
||||
mtime->tm_hour,
|
||||
mtime->tm_min,
|
||||
mtime->tm_sec,
|
||||
file_header->name);
|
||||
#else /* !FEATURE_TAR_UNAME_GNAME */
|
||||
printf("%s %d/%d %9"OFF_FMT"u %4u-%02u-%02u %02u:%02u:%02u %s",
|
||||
bb_mode_string(file_header->mode),
|
||||
file_header->uid,
|
||||
@@ -22,6 +49,7 @@ void header_verbose_list(const file_header_t *file_header)
|
||||
mtime->tm_min,
|
||||
mtime->tm_sec,
|
||||
file_header->name);
|
||||
#endif /* FEATURE_TAR_UNAME_GNAME */
|
||||
|
||||
if (file_header->link_target) {
|
||||
printf(" -> %s", file_header->link_target);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
archive_handle_t *init_handle(void)
|
||||
archive_handle_t* FAST_FUNC init_handle(void)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
|
||||
|
||||
@@ -11,52 +11,54 @@
|
||||
* On MMU machine, the transform_prog is removed by macro magic
|
||||
* in include/unarchive.h. On NOMMU, transformer is removed.
|
||||
*/
|
||||
int open_transformer(int src_fd,
|
||||
USE_DESKTOP(long long) int (*transformer)(int src_fd, int dst_fd),
|
||||
void FAST_FUNC open_transformer(int fd,
|
||||
USE_DESKTOP(long long) int FAST_FUNC (*transformer)(int src_fd, int dst_fd),
|
||||
const char *transform_prog)
|
||||
{
|
||||
int fd_pipe[2];
|
||||
struct fd_pair fd_pipe;
|
||||
int pid;
|
||||
|
||||
xpipe(fd_pipe);
|
||||
xpiped_pair(fd_pipe);
|
||||
|
||||
#if BB_MMU
|
||||
pid = fork();
|
||||
if (pid == -1)
|
||||
bb_perror_msg_and_die("vfork" + 1);
|
||||
#else
|
||||
pid = vfork();
|
||||
#endif
|
||||
if (pid == -1)
|
||||
bb_perror_msg_and_die("fork failed");
|
||||
bb_perror_msg_and_die("vfork");
|
||||
#endif
|
||||
|
||||
if (pid == 0) {
|
||||
/* child process */
|
||||
close(fd_pipe[0]); /* We don't wan't to read from the parent */
|
||||
close(fd_pipe.rd); /* we don't want to read from the parent */
|
||||
// FIXME: error check?
|
||||
#if BB_MMU
|
||||
transformer(src_fd, fd_pipe[1]);
|
||||
transformer(fd, fd_pipe.wr);
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(fd_pipe[1]); /* Send EOF */
|
||||
close(src_fd);
|
||||
close(fd_pipe.wr); /* send EOF */
|
||||
close(fd);
|
||||
}
|
||||
exit(0);
|
||||
/* must be _exit! bug was actually seen here */
|
||||
_exit(EXIT_SUCCESS);
|
||||
#else
|
||||
{
|
||||
char *argv[4];
|
||||
xmove_fd(src_fd, 0);
|
||||
xmove_fd(fd_pipe[1], 1);
|
||||
xmove_fd(fd, 0);
|
||||
xmove_fd(fd_pipe.wr, 1);
|
||||
argv[0] = (char*)transform_prog;
|
||||
argv[1] = (char*)"-cf";
|
||||
argv[2] = (char*)"-";
|
||||
argv[3] = NULL;
|
||||
BB_EXECVP(transform_prog, argv);
|
||||
bb_perror_msg_and_die("exec failed");
|
||||
bb_perror_msg_and_die("can't exec %s", transform_prog);
|
||||
}
|
||||
#endif
|
||||
/* notreached */
|
||||
}
|
||||
|
||||
/* parent process */
|
||||
close(fd_pipe[1]); /* Don't want to write to the child */
|
||||
|
||||
return fd_pipe[0];
|
||||
close(fd_pipe.wr); /* don't want to write to the child */
|
||||
xmove_fd(fd_pipe.rd, fd);
|
||||
}
|
||||
@@ -6,14 +6,14 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount)
|
||||
void FAST_FUNC seek_by_jump(const archive_handle_t *archive_handle, unsigned amount)
|
||||
{
|
||||
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
|
||||
#if ENABLE_FEATURE_UNARCHIVE_TAPE
|
||||
if (errno == ESPIPE) {
|
||||
if (amount
|
||||
&& lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1
|
||||
) {
|
||||
if (errno == ESPIPE)
|
||||
seek_by_read(archive_handle, amount);
|
||||
} else
|
||||
#endif
|
||||
else
|
||||
bb_perror_msg_and_die("seek failure");
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,10 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/* If we are reading through a pipe(), or from stdin then we can't lseek,
|
||||
/* If we are reading through a pipe, or from stdin then we can't lseek,
|
||||
* we must read and discard the data to skip over it.
|
||||
*/
|
||||
void seek_by_read(const archive_handle_t *archive_handle, const unsigned int jump_size)
|
||||
void FAST_FUNC seek_by_read(const archive_handle_t *archive_handle, unsigned jump_size)
|
||||
{
|
||||
if (jump_size)
|
||||
bb_copyfd_exact_size(archive_handle->src_fd, -1, jump_size);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void unpack_ar_archive(archive_handle_t *ar_archive)
|
||||
void FAST_FUNC unpack_ar_archive(archive_handle_t *ar_archive)
|
||||
{
|
||||
char magic[7];
|
||||
|
||||
@@ -16,5 +16,6 @@ void unpack_ar_archive(archive_handle_t *ar_archive)
|
||||
}
|
||||
ar_archive->offset += 7;
|
||||
|
||||
while (get_header_ar(ar_archive) == EXIT_SUCCESS);
|
||||
while (get_header_ar(ar_archive) == EXIT_SUCCESS)
|
||||
continue;
|
||||
}
|
||||
+19
-20
@@ -190,7 +190,7 @@ 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);
|
||||
USE_DESKTOP(long long) int FAST_FUNC (*xformer)(int src_fd, int dst_fd);
|
||||
enum { xformer_prog = 0 };
|
||||
#else
|
||||
enum { xformer = 0 };
|
||||
@@ -202,10 +202,11 @@ static void extract_cpio_gz(int fd)
|
||||
archive_handle->seek = seek_by_read;
|
||||
//archive_handle->action_header = header_list;
|
||||
archive_handle->action_data = data_extract_all;
|
||||
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
|
||||
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
|
||||
archive_handle->ah_flags = ARCHIVE_PRESERVE_DATE | ARCHIVE_CREATE_LEADING_DIRS;
|
||||
archive_handle->src_fd = fd;
|
||||
archive_handle->offset = 0;
|
||||
/*archive_handle->offset = 0; - init_handle() did it */
|
||||
|
||||
// TODO: open_zipped does the same
|
||||
|
||||
xread(archive_handle->src_fd, &magic, 2);
|
||||
#if BB_MMU
|
||||
@@ -213,21 +214,19 @@ static void extract_cpio_gz(int fd)
|
||||
#else
|
||||
xformer_prog = "gunzip";
|
||||
#endif
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
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
|
||||
if (magic[0] != 0x1f || magic[1] != 0x8b) {
|
||||
if (!ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
|| magic[0] != 'B' || magic[1] != 'Z'
|
||||
) {
|
||||
bb_error_msg_and_die("no gzip"
|
||||
USE_FEATURE_RPM_BZ2("/bzip")
|
||||
USE_FEATURE_SEAMLESS_BZ2("/bzip2")
|
||||
" magic");
|
||||
}
|
||||
#if BB_MMU
|
||||
xformer = unpack_bz2_stream;
|
||||
#else
|
||||
xformer_prog = "bunzip2";
|
||||
#endif
|
||||
} else {
|
||||
#if !BB_MMU
|
||||
/* NOMMU version of open_transformer execs an external unzipper that should
|
||||
@@ -237,7 +236,7 @@ static void extract_cpio_gz(int fd)
|
||||
}
|
||||
|
||||
xchdir("/"); /* Install RPM's to root */
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, xformer, xformer_prog);
|
||||
open_transformer(archive_handle->src_fd, xformer, xformer_prog);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
@@ -280,12 +279,12 @@ static rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
tmpindex->type = ntohl(tmpindex->type);
|
||||
tmpindex->count = ntohl(tmpindex->count);
|
||||
tmpindex->offset = storepos + ntohl(tmpindex->offset);
|
||||
if (pass==0)
|
||||
if (pass == 0)
|
||||
tmpindex->tag -= 743;
|
||||
}
|
||||
xlseek(fd, header.size, SEEK_CUR); /* Seek past store */
|
||||
/* Skip padding to 8 byte boundary after reading signature headers */
|
||||
if (pass==0)
|
||||
if (pass == 0)
|
||||
xlseek(fd, (8 - (xlseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR);
|
||||
}
|
||||
tags = xrealloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */
|
||||
|
||||
+8
-8
@@ -13,14 +13,14 @@
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
|
||||
struct rpm_lead {
|
||||
unsigned char magic[4];
|
||||
uint8_t major, minor;
|
||||
uint16_t type;
|
||||
uint16_t archnum;
|
||||
char name[66];
|
||||
uint16_t osnum;
|
||||
uint16_t signature_type;
|
||||
char reserved[16];
|
||||
unsigned char magic[4];
|
||||
uint8_t major, minor;
|
||||
uint16_t type;
|
||||
uint16_t archnum;
|
||||
char name[66];
|
||||
uint16_t osnum;
|
||||
uint16_t signature_type;
|
||||
char reserved[16];
|
||||
};
|
||||
|
||||
struct rpm_header {
|
||||
|
||||
+185
-156
@@ -24,12 +24,25 @@
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <getopt.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/* FIXME: Stop using this non-standard feature */
|
||||
#ifndef FNM_LEADING_DIR
|
||||
#define FNM_LEADING_DIR 0
|
||||
#endif
|
||||
|
||||
|
||||
#define block_buf bb_common_bufsiz1
|
||||
|
||||
|
||||
#if !ENABLE_FEATURE_SEAMLESS_GZ && !ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
/* Do not pass gzip flag to writeTarFile() */
|
||||
#define writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude, gzip) \
|
||||
writeTarFile(tar_fd, verboseFlag, dereferenceFlag, include, exclude)
|
||||
#endif
|
||||
|
||||
|
||||
#if ENABLE_FEATURE_TAR_CREATE
|
||||
|
||||
/* Tar file constants */
|
||||
@@ -71,26 +84,26 @@ struct TarHeader { /* byte offset */
|
||||
*/
|
||||
typedef struct HardLinkInfo HardLinkInfo;
|
||||
struct HardLinkInfo {
|
||||
HardLinkInfo *next; /* Next entry in list */
|
||||
dev_t dev; /* Device number */
|
||||
ino_t ino; /* Inode number */
|
||||
short linkCount; /* (Hard) Link Count */
|
||||
char name[1]; /* Start of filename (must be last) */
|
||||
HardLinkInfo *next; /* Next entry in list */
|
||||
dev_t dev; /* Device number */
|
||||
ino_t ino; /* Inode number */
|
||||
short linkCount; /* (Hard) Link Count */
|
||||
char name[1]; /* Start of filename (must be last) */
|
||||
};
|
||||
|
||||
/* Some info to be carried along when creating a new tarball */
|
||||
typedef struct TarBallInfo TarBallInfo;
|
||||
struct TarBallInfo {
|
||||
int tarFd; /* Open-for-write file descriptor
|
||||
for the tarball */
|
||||
struct stat statBuf; /* Stat info for the tarball, letting
|
||||
us know the inode and device that the
|
||||
tarball lives, so we can avoid trying
|
||||
to include the tarball into itself */
|
||||
int verboseFlag; /* Whether to print extra stuff or not */
|
||||
const llist_t *excludeList; /* List of files to not include */
|
||||
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
|
||||
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
|
||||
int tarFd; /* Open-for-write file descriptor
|
||||
* for the tarball */
|
||||
struct stat statBuf; /* Stat info for the tarball, letting
|
||||
* us know the inode and device that the
|
||||
* tarball lives, so we can avoid trying
|
||||
* to include the tarball into itself */
|
||||
int verboseFlag; /* Whether to print extra stuff or not */
|
||||
const llist_t *excludeList; /* List of files to not include */
|
||||
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
|
||||
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
|
||||
};
|
||||
|
||||
/* A nice enum with all the possible tar file content types */
|
||||
@@ -383,8 +396,8 @@ static int exclude_file(const llist_t *excluded_files, const char *file)
|
||||
#define exclude_file(excluded_files, file) 0
|
||||
#endif
|
||||
|
||||
static int writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
void *userData, int depth ATTRIBUTE_UNUSED)
|
||||
static int FAST_FUNC writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
void *userData, int depth UNUSED_PARAM)
|
||||
{
|
||||
struct TarBallInfo *tbInfo = (struct TarBallInfo *) userData;
|
||||
const char *header_name;
|
||||
@@ -490,11 +503,90 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
const unsigned long dereferenceFlag, const llist_t *include,
|
||||
const llist_t *exclude, const int gzip)
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
#if !(ENABLE_FEATURE_SEAMLESS_GZ && ENABLE_FEATURE_SEAMLESS_BZ2)
|
||||
#define vfork_compressor(tar_fd, gzip) vfork_compressor(tar_fd)
|
||||
#endif
|
||||
/* Don't inline: vfork scares gcc and pessimizes code */
|
||||
static void NOINLINE vfork_compressor(int tar_fd, int gzip)
|
||||
{
|
||||
pid_t gzipPid;
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ && ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
|
||||
#elif ENABLE_FEATURE_SEAMLESS_GZ
|
||||
const char *zip_exec = "gzip";
|
||||
#else /* only ENABLE_FEATURE_SEAMLESS_BZ2 */
|
||||
const char *zip_exec = "bzip2";
|
||||
#endif
|
||||
// On Linux, vfork never unpauses parent early, although standard
|
||||
// allows for that. Do we want to waste bytes checking for it?
|
||||
#define WAIT_FOR_CHILD 0
|
||||
volatile int vfork_exec_errno = 0;
|
||||
struct fd_pair gzipDataPipe;
|
||||
#if WAIT_FOR_CHILD
|
||||
struct fd_pair gzipStatusPipe;
|
||||
xpiped_pair(gzipStatusPipe);
|
||||
#endif
|
||||
xpiped_pair(gzipDataPipe);
|
||||
|
||||
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
/* Avoid vfork clobbering */
|
||||
(void) &zip_exec;
|
||||
#endif
|
||||
|
||||
gzipPid = vfork();
|
||||
if (gzipPid < 0)
|
||||
bb_perror_msg_and_die("vfork");
|
||||
|
||||
if (gzipPid == 0) {
|
||||
/* child */
|
||||
/* NB: close _first_, then move fds! */
|
||||
close(gzipDataPipe.wr);
|
||||
#if WAIT_FOR_CHILD
|
||||
close(gzipStatusPipe.rd);
|
||||
/* gzipStatusPipe.wr will close only on exec -
|
||||
* parent waits for this close to happen */
|
||||
fcntl(gzipStatusPipe.wr, F_SETFD, FD_CLOEXEC);
|
||||
#endif
|
||||
xmove_fd(gzipDataPipe.rd, 0);
|
||||
xmove_fd(tar_fd, 1);
|
||||
/* exec gzip/bzip2 program/applet */
|
||||
BB_EXECLP(zip_exec, zip_exec, "-f", NULL);
|
||||
vfork_exec_errno = errno;
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* parent */
|
||||
xmove_fd(gzipDataPipe.wr, tar_fd);
|
||||
close(gzipDataPipe.rd);
|
||||
#if WAIT_FOR_CHILD
|
||||
close(gzipStatusPipe.wr);
|
||||
while (1) {
|
||||
char buf;
|
||||
int n;
|
||||
|
||||
/* Wait until child execs (or fails to) */
|
||||
n = full_read(gzipStatusPipe.rd, &buf, 1);
|
||||
if (n < 0 /* && errno == EAGAIN */)
|
||||
continue; /* try it again */
|
||||
}
|
||||
close(gzipStatusPipe.rd);
|
||||
#endif
|
||||
if (vfork_exec_errno) {
|
||||
errno = vfork_exec_errno;
|
||||
bb_perror_msg_and_die("cannot exec %s", zip_exec);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 */
|
||||
|
||||
|
||||
/* gcc 4.2.1 inlines it, making code bigger */
|
||||
static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
|
||||
int dereferenceFlag, const llist_t *include,
|
||||
const llist_t *exclude, int gzip)
|
||||
{
|
||||
pid_t gzipPid = 0;
|
||||
int errorFlag = FALSE;
|
||||
struct TarBallInfo tbInfo;
|
||||
|
||||
@@ -509,73 +601,10 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
|
||||
bb_perror_msg_and_die("cannot stat tar file");
|
||||
|
||||
if ((ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2) && gzip) {
|
||||
// On Linux, vfork never unpauses parent early, although standard
|
||||
// allows for that. Do we want to waste bytes checking for it?
|
||||
#define WAIT_FOR_CHILD 0
|
||||
|
||||
volatile int vfork_exec_errno = 0;
|
||||
#if WAIT_FOR_CHILD
|
||||
struct { int rd; int wr; } gzipStatusPipe;
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
if (gzip)
|
||||
vfork_compressor(tbInfo.tarFd, gzip);
|
||||
#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 */
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__
|
||||
/* Avoid vfork clobbering */
|
||||
(void) &include;
|
||||
(void) &errorFlag;
|
||||
(void) &zip_exec;
|
||||
#endif
|
||||
|
||||
gzipPid = vfork();
|
||||
if (gzipPid < 0)
|
||||
bb_perror_msg_and_die("vfork gzip");
|
||||
|
||||
if (gzipPid == 0) {
|
||||
/* child */
|
||||
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);
|
||||
}
|
||||
|
||||
/* parent */
|
||||
xmove_fd(gzipDataPipe.wr, tbInfo.tarFd);
|
||||
close(gzipDataPipe.rd);
|
||||
#if WAIT_FOR_CHILD
|
||||
close(gzipStatusPipe.wr);
|
||||
while (1) {
|
||||
char buf;
|
||||
int n;
|
||||
|
||||
/* Wait until child execs (or fails to) */
|
||||
n = full_read(gzipStatusPipe.rd, &buf, 1);
|
||||
if ((n < 0) && (/*errno == EAGAIN ||*/ errno == EINTR))
|
||||
continue; /* try it again */
|
||||
|
||||
}
|
||||
close(gzipStatusPipe.rd);
|
||||
#endif
|
||||
if (vfork_exec_errno) {
|
||||
errno = vfork_exec_errno;
|
||||
bb_perror_msg_and_die("cannot exec %s", zip_exec);
|
||||
}
|
||||
}
|
||||
|
||||
tbInfo.excludeList = exclude;
|
||||
|
||||
@@ -608,37 +637,34 @@ static int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
if (errorFlag)
|
||||
bb_error_msg("error exit delayed from previous errors");
|
||||
|
||||
if (gzipPid) {
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
if (gzip) {
|
||||
int status;
|
||||
if (waitpid(gzipPid, &status, 0) == -1)
|
||||
if (safe_waitpid(-1, &status, 0) == -1)
|
||||
bb_perror_msg("waitpid");
|
||||
else if (!WIFEXITED(status) || WEXITSTATUS(status))
|
||||
/* gzip was killed or has exited with nonzero! */
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
#endif
|
||||
return errorFlag;
|
||||
}
|
||||
#else
|
||||
int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
const unsigned long dereferenceFlag, const llist_t *include,
|
||||
const llist_t *exclude, const int gzip);
|
||||
int writeTarFile(int tar_fd, int verboseFlag,
|
||||
int dereferenceFlag, const llist_t *include,
|
||||
const llist_t *exclude, int gzip);
|
||||
#endif /* FEATURE_TAR_CREATE */
|
||||
|
||||
#if ENABLE_FEATURE_TAR_FROM
|
||||
static llist_t *append_file_list_to_list(llist_t *list)
|
||||
{
|
||||
FILE *src_stream;
|
||||
llist_t *cur = list;
|
||||
llist_t *tmp;
|
||||
char *line;
|
||||
llist_t *newlist = NULL;
|
||||
|
||||
while (cur) {
|
||||
src_stream = xfopen(cur->data, "r");
|
||||
tmp = cur;
|
||||
cur = cur->link;
|
||||
free(tmp);
|
||||
while ((line = xmalloc_getline(src_stream)) != NULL) {
|
||||
while (list) {
|
||||
src_stream = xfopen_for_read(llist_pop(&list));
|
||||
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
|
||||
/* kill trailing '/' unless the string is just "/" */
|
||||
char *cp = last_char_is(line, '/');
|
||||
if (cp > line)
|
||||
@@ -653,8 +679,8 @@ static llist_t *append_file_list_to_list(llist_t *list)
|
||||
#define append_file_list_to_list(x) 0
|
||||
#endif
|
||||
|
||||
#if ENABLE_FEATURE_TAR_COMPRESS
|
||||
static char get_header_tar_Z(archive_handle_t *archive_handle)
|
||||
#if ENABLE_FEATURE_SEAMLESS_Z
|
||||
static char FAST_FUNC get_header_tar_Z(archive_handle_t *archive_handle)
|
||||
{
|
||||
/* Can't lseek over pipes */
|
||||
archive_handle->seek = seek_by_read;
|
||||
@@ -666,7 +692,7 @@ 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, "uncompress");
|
||||
open_transformer(archive_handle->src_fd, unpack_Z_stream, "uncompress");
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
@@ -688,7 +714,7 @@ static void handle_SIGCHLD(int status)
|
||||
/* Actually, 'status' is a signo. We reuse it for other needs */
|
||||
|
||||
/* Wait for any child without blocking */
|
||||
if (waitpid(-1, &status, WNOHANG) < 0)
|
||||
if (wait_any_nohang(&status) < 0)
|
||||
/* wait failed?! I'm confused... */
|
||||
return;
|
||||
|
||||
@@ -703,14 +729,14 @@ static void handle_SIGCHLD(int status)
|
||||
|
||||
enum {
|
||||
OPTBIT_KEEP_OLD = 7,
|
||||
USE_FEATURE_TAR_CREATE( OPTBIT_CREATE ,)
|
||||
USE_FEATURE_TAR_CREATE( OPTBIT_DEREFERENCE ,)
|
||||
USE_FEATURE_TAR_BZIP2( OPTBIT_BZIP2 ,)
|
||||
USE_FEATURE_TAR_LZMA( OPTBIT_LZMA ,)
|
||||
USE_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,)
|
||||
USE_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,)
|
||||
USE_FEATURE_TAR_GZIP( OPTBIT_GZIP ,)
|
||||
USE_FEATURE_TAR_COMPRESS(OPTBIT_COMPRESS ,)
|
||||
USE_FEATURE_TAR_CREATE( OPTBIT_CREATE ,)
|
||||
USE_FEATURE_TAR_CREATE( OPTBIT_DEREFERENCE ,)
|
||||
USE_FEATURE_SEAMLESS_BZ2( OPTBIT_BZIP2 ,)
|
||||
USE_FEATURE_SEAMLESS_LZMA(OPTBIT_LZMA ,)
|
||||
USE_FEATURE_TAR_FROM( OPTBIT_INCLUDE_FROM,)
|
||||
USE_FEATURE_TAR_FROM( OPTBIT_EXCLUDE_FROM,)
|
||||
USE_FEATURE_SEAMLESS_GZ( OPTBIT_GZIP ,)
|
||||
USE_FEATURE_SEAMLESS_Z( OPTBIT_COMPRESS ,)
|
||||
OPTBIT_NOPRESERVE_OWN,
|
||||
OPTBIT_NOPRESERVE_PERM,
|
||||
OPT_TEST = 1 << 0, // t
|
||||
@@ -721,14 +747,14 @@ enum {
|
||||
OPT_P = 1 << 5, // p
|
||||
OPT_VERBOSE = 1 << 6, // v
|
||||
OPT_KEEP_OLD = 1 << 7, // k
|
||||
OPT_CREATE = USE_FEATURE_TAR_CREATE( (1<<OPTBIT_CREATE )) + 0, // c
|
||||
OPT_DEREFERENCE = USE_FEATURE_TAR_CREATE( (1<<OPTBIT_DEREFERENCE )) + 0, // h
|
||||
OPT_BZIP2 = USE_FEATURE_TAR_BZIP2( (1<<OPTBIT_BZIP2 )) + 0, // j
|
||||
OPT_LZMA = USE_FEATURE_TAR_LZMA( (1<<OPTBIT_LZMA )) + 0, // a
|
||||
OPT_INCLUDE_FROM = USE_FEATURE_TAR_FROM( (1<<OPTBIT_INCLUDE_FROM)) + 0, // T
|
||||
OPT_EXCLUDE_FROM = USE_FEATURE_TAR_FROM( (1<<OPTBIT_EXCLUDE_FROM)) + 0, // X
|
||||
OPT_GZIP = USE_FEATURE_TAR_GZIP( (1<<OPTBIT_GZIP )) + 0, // z
|
||||
OPT_COMPRESS = USE_FEATURE_TAR_COMPRESS((1<<OPTBIT_COMPRESS )) + 0, // Z
|
||||
OPT_CREATE = USE_FEATURE_TAR_CREATE( (1 << OPTBIT_CREATE )) + 0, // c
|
||||
OPT_DEREFERENCE = USE_FEATURE_TAR_CREATE( (1 << OPTBIT_DEREFERENCE )) + 0, // h
|
||||
OPT_BZIP2 = USE_FEATURE_SEAMLESS_BZ2( (1 << OPTBIT_BZIP2 )) + 0, // j
|
||||
OPT_LZMA = USE_FEATURE_SEAMLESS_LZMA((1 << OPTBIT_LZMA )) + 0, // a
|
||||
OPT_INCLUDE_FROM = USE_FEATURE_TAR_FROM( (1 << OPTBIT_INCLUDE_FROM)) + 0, // T
|
||||
OPT_EXCLUDE_FROM = USE_FEATURE_TAR_FROM( (1 << OPTBIT_EXCLUDE_FROM)) + 0, // X
|
||||
OPT_GZIP = USE_FEATURE_SEAMLESS_GZ( (1 << OPTBIT_GZIP )) + 0, // z
|
||||
OPT_COMPRESS = USE_FEATURE_SEAMLESS_Z( (1 << OPTBIT_COMPRESS )) + 0, // Z
|
||||
OPT_NOPRESERVE_OWN = 1 << OPTBIT_NOPRESERVE_OWN , // no-same-owner
|
||||
OPT_NOPRESERVE_PERM = 1 << OPTBIT_NOPRESERVE_PERM, // no-same-permissions
|
||||
};
|
||||
@@ -746,20 +772,20 @@ static const char tar_longopts[] ALIGN1 =
|
||||
"create\0" No_argument "c"
|
||||
"dereference\0" No_argument "h"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_BZIP2
|
||||
# if ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
"bzip2\0" No_argument "j"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_LZMA
|
||||
# if ENABLE_FEATURE_SEAMLESS_LZMA
|
||||
"lzma\0" No_argument "a"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_FROM
|
||||
"files-from\0" Required_argument "T"
|
||||
"exclude-from\0" Required_argument "X"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_GZIP
|
||||
# if ENABLE_FEATURE_SEAMLESS_GZ
|
||||
"gzip\0" No_argument "z"
|
||||
# endif
|
||||
# if ENABLE_FEATURE_TAR_COMPRESS
|
||||
# if ENABLE_FEATURE_SEAMLESS_Z
|
||||
"compress\0" No_argument "Z"
|
||||
# endif
|
||||
"no-same-owner\0" No_argument "\xfd"
|
||||
@@ -774,9 +800,9 @@ static const char tar_longopts[] ALIGN1 =
|
||||
#endif
|
||||
|
||||
int tar_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int tar_main(int argc, char **argv)
|
||||
int tar_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
char (*get_header_ptr)(archive_handle_t *) = get_header_tar;
|
||||
char FAST_FUNC (*get_header_ptr)(archive_handle_t *) = get_header_tar;
|
||||
archive_handle_t *tar_handle;
|
||||
char *base_dir = NULL;
|
||||
const char *tar_filename = "-";
|
||||
@@ -788,9 +814,9 @@ int tar_main(int argc, char **argv)
|
||||
|
||||
/* Initialise default values */
|
||||
tar_handle = init_handle();
|
||||
tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS
|
||||
| ARCHIVE_PRESERVE_DATE
|
||||
| ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
tar_handle->ah_flags = ARCHIVE_CREATE_LEADING_DIRS
|
||||
| ARCHIVE_PRESERVE_DATE
|
||||
| ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
|
||||
/* Prepend '-' to the first argument if required */
|
||||
opt_complementary = "--:" // first arg is options
|
||||
@@ -808,12 +834,12 @@ int tar_main(int argc, char **argv)
|
||||
#endif
|
||||
opt = getopt32(argv,
|
||||
"txC:f:Opvk"
|
||||
USE_FEATURE_TAR_CREATE( "ch" )
|
||||
USE_FEATURE_TAR_BZIP2( "j" )
|
||||
USE_FEATURE_TAR_LZMA( "a" )
|
||||
USE_FEATURE_TAR_FROM( "T:X:")
|
||||
USE_FEATURE_TAR_GZIP( "z" )
|
||||
USE_FEATURE_TAR_COMPRESS("Z" )
|
||||
USE_FEATURE_TAR_CREATE( "ch" )
|
||||
USE_FEATURE_SEAMLESS_BZ2( "j" )
|
||||
USE_FEATURE_SEAMLESS_LZMA("a" )
|
||||
USE_FEATURE_TAR_FROM( "T:X:")
|
||||
USE_FEATURE_SEAMLESS_GZ( "z" )
|
||||
USE_FEATURE_SEAMLESS_Z( "Z" )
|
||||
, &base_dir // -C dir
|
||||
, &tar_filename // -f filename
|
||||
USE_FEATURE_TAR_FROM(, &(tar_handle->accept)) // T
|
||||
@@ -824,6 +850,7 @@ int tar_main(int argc, char **argv)
|
||||
, &verboseFlag // combined count for -t and -v
|
||||
, &verboseFlag // combined count for -t and -v
|
||||
);
|
||||
argv += optind;
|
||||
|
||||
if (verboseFlag) tar_handle->action_header = header_verbose_list;
|
||||
if (verboseFlag == 1) tar_handle->action_header = header_list;
|
||||
@@ -835,13 +862,13 @@ int tar_main(int argc, char **argv)
|
||||
tar_handle->action_data = data_extract_to_stdout;
|
||||
|
||||
if (opt & OPT_KEEP_OLD)
|
||||
tar_handle->flags &= ~ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
tar_handle->ah_flags &= ~ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
|
||||
if (opt & OPT_NOPRESERVE_OWN)
|
||||
tar_handle->flags |= ARCHIVE_NOPRESERVE_OWN;
|
||||
tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_OWN;
|
||||
|
||||
if (opt & OPT_NOPRESERVE_PERM)
|
||||
tar_handle->flags |= ARCHIVE_NOPRESERVE_PERM;
|
||||
tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_PERM;
|
||||
|
||||
if (opt & OPT_GZIP)
|
||||
get_header_ptr = get_header_tar_gz;
|
||||
@@ -869,21 +896,15 @@ int tar_main(int argc, char **argv)
|
||||
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
|
||||
#endif
|
||||
|
||||
/* Check if we are reading from stdin */
|
||||
if (argv[optind] && *argv[optind] == '-') {
|
||||
/* Default is to read from stdin, so just skip to next arg */
|
||||
optind++;
|
||||
}
|
||||
|
||||
/* Setup an array of filenames to work with */
|
||||
/* TODO: This is the same as in ar, separate function ? */
|
||||
while (optind < argc) {
|
||||
while (*argv) {
|
||||
/* kill trailing '/' unless the string is just "/" */
|
||||
char *cp = last_char_is(argv[optind], '/');
|
||||
if (cp > argv[optind])
|
||||
char *cp = last_char_is(*argv, '/');
|
||||
if (cp > *argv)
|
||||
*cp = '\0';
|
||||
llist_add_to_end(&tar_handle->accept, argv[optind]);
|
||||
optind++;
|
||||
llist_add_to_end(&tar_handle->accept, *argv);
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (tar_handle->accept || tar_handle->reject)
|
||||
@@ -901,8 +922,7 @@ int tar_main(int argc, char **argv)
|
||||
|
||||
tar_stream = stdout;
|
||||
/* Mimicking GNU tar 1.15.1: */
|
||||
flags = O_WRONLY|O_CREAT|O_TRUNC;
|
||||
/* was doing unlink; open(O_WRONLY|O_CREAT|O_EXCL); why? */
|
||||
flags = O_WRONLY | O_CREAT | O_TRUNC;
|
||||
} else {
|
||||
tar_stream = stdin;
|
||||
flags = O_RDONLY;
|
||||
@@ -912,7 +932,14 @@ int tar_main(int argc, char **argv)
|
||||
tar_handle->src_fd = fileno(tar_stream);
|
||||
tar_handle->seek = seek_by_read;
|
||||
} else {
|
||||
tar_handle->src_fd = xopen(tar_filename, flags);
|
||||
if (ENABLE_FEATURE_TAR_AUTODETECT && flags == O_RDONLY) {
|
||||
get_header_ptr = get_header_tar;
|
||||
tar_handle->src_fd = open_zipped(tar_filename);
|
||||
if (tar_handle->src_fd < 0)
|
||||
bb_perror_msg_and_die("can't open '%s'", tar_filename);
|
||||
} else {
|
||||
tar_handle->src_fd = xopen(tar_filename, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -926,11 +953,13 @@ int tar_main(int argc, char **argv)
|
||||
|
||||
/* create an archive */
|
||||
if (opt & OPT_CREATE) {
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
int zipMode = 0;
|
||||
if (ENABLE_FEATURE_TAR_GZIP && get_header_ptr == get_header_tar_gz)
|
||||
if (ENABLE_FEATURE_SEAMLESS_GZ && (opt & OPT_GZIP))
|
||||
zipMode = 1;
|
||||
if (ENABLE_FEATURE_TAR_BZIP2 && get_header_ptr == get_header_tar_bz2)
|
||||
if (ENABLE_FEATURE_SEAMLESS_BZ2 && (opt & OPT_BZIP2))
|
||||
zipMode = 2;
|
||||
#endif
|
||||
/* NB: writeTarFile() closes tar_handle->src_fd */
|
||||
return writeTarFile(tar_handle->src_fd, verboseFlag, opt & OPT_DEREFERENCE,
|
||||
tar_handle->accept,
|
||||
@@ -938,7 +967,7 @@ int tar_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
while (get_header_ptr(tar_handle) == EXIT_SUCCESS)
|
||||
/* nothing */;
|
||||
continue;
|
||||
|
||||
/* Check that every file that should have been extracted was */
|
||||
while (tar_handle->accept) {
|
||||
|
||||
+25
-17
@@ -51,13 +51,13 @@ typedef union {
|
||||
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 */
|
||||
uint32_t crc32 PACKED; /* 10-13 */
|
||||
uint32_t cmpsize PACKED; /* 14-17 */
|
||||
uint32_t ucmpsize PACKED; /* 18-21 */
|
||||
uint16_t filename_len; /* 22-23 */
|
||||
uint16_t extra_len; /* 24-25 */
|
||||
} formatted ATTRIBUTE_PACKED;
|
||||
} zip_header_t; /* ATTRIBUTE_PACKED - gcc 4.2.1 doesn't like it (spews warning) */
|
||||
} formatted PACKED;
|
||||
} zip_header_t; /* PACKED - gcc 4.2.1 doesn't like it (spews warning) */
|
||||
|
||||
/* Check the offset of the last element, not the length. This leniency
|
||||
* allows for poor packing, whereby the overall struct may be too long,
|
||||
@@ -258,10 +258,11 @@ int unzip_main(int argc, char **argv)
|
||||
|
||||
/* Check magic number */
|
||||
xread(src_fd, &magic, 4);
|
||||
/* Central directory? It's at the end, so exit */
|
||||
if (magic == ZIP_CDS_MAGIC)
|
||||
break;
|
||||
if (magic != ZIP_FILEHEADER_MAGIC)
|
||||
bb_error_msg_and_die("invalid zip magic %08X", magic);
|
||||
bb_error_msg_and_die("invalid zip magic %08X", (int)magic);
|
||||
|
||||
/* Read the file header */
|
||||
xread(src_fd, zip_header.raw, ZIP_HEADER_LEN);
|
||||
@@ -269,6 +270,12 @@ int unzip_main(int argc, char **argv)
|
||||
if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) {
|
||||
bb_error_msg_and_die("unsupported method %d", zip_header.formatted.method);
|
||||
}
|
||||
if (zip_header.formatted.flags & (0x0008|0x0001)) {
|
||||
/* 0x0001 - encrypted */
|
||||
/* 0x0008 - streaming. [u]cmpsize can be reliably gotten
|
||||
* only from Central Directory. See unzip_doc.txt */
|
||||
bb_error_msg_and_die("zip flags 8 and 1 are not supported");
|
||||
}
|
||||
|
||||
/* Read filename */
|
||||
free(dst_fn);
|
||||
@@ -308,7 +315,7 @@ int unzip_main(int argc, char **argv)
|
||||
} else if (last_char_is(dst_fn, '/')) { /* Extract directory */
|
||||
if (stat(dst_fn, &stat_buf) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
|
||||
bb_perror_msg_and_die("cannot stat '%s'", dst_fn);
|
||||
}
|
||||
if (verbose) {
|
||||
printf(" creating: %s\n", dst_fn);
|
||||
@@ -325,10 +332,10 @@ int unzip_main(int argc, char **argv)
|
||||
i = 'n';
|
||||
|
||||
} else { /* Extract file */
|
||||
_check_file:
|
||||
check_file:
|
||||
if (stat(dst_fn, &stat_buf) == -1) { /* File does not exist */
|
||||
if (errno != ENOENT) {
|
||||
bb_perror_msg_and_die("cannot stat '%s'",dst_fn);
|
||||
bb_perror_msg_and_die("cannot stat '%s'", dst_fn);
|
||||
}
|
||||
i = 'y';
|
||||
} else { /* File already exists */
|
||||
@@ -345,7 +352,7 @@ int unzip_main(int argc, char **argv)
|
||||
i = key_buf[0];
|
||||
}
|
||||
} else { /* File is not regular file */
|
||||
bb_error_msg_and_die("'%s' exists but is not regular file",dst_fn);
|
||||
bb_error_msg_and_die("'%s' exists but is not regular file", dst_fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -384,18 +391,19 @@ int unzip_main(int argc, char **argv)
|
||||
free(dst_fn);
|
||||
dst_fn = xstrdup(key_buf);
|
||||
chomp(dst_fn);
|
||||
goto _check_file;
|
||||
goto check_file;
|
||||
|
||||
default:
|
||||
printf("error: invalid response [%c]\n",(char)i);
|
||||
goto _check_file;
|
||||
goto check_file;
|
||||
}
|
||||
|
||||
/* Data descriptor section */
|
||||
if (zip_header.formatted.flags & 4) {
|
||||
/* skip over duplicate crc, compressed size and uncompressed size */
|
||||
unzip_skip(src_fd, 12);
|
||||
}
|
||||
// Looks like bug (data descriptor cannot be identified this way)
|
||||
// /* Data descriptor section */
|
||||
// if (zip_header.formatted.flags & 4) {
|
||||
// /* skip over duplicate crc, compressed size and uncompressed size */
|
||||
// unzip_skip(src_fd, 12);
|
||||
// }
|
||||
}
|
||||
|
||||
if (listing && verbose) {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
+13
-1
@@ -72,7 +72,7 @@ config RESIZE
|
||||
terminal.
|
||||
|
||||
config FEATURE_RESIZE_PRINT
|
||||
bool "print environment variables"
|
||||
bool "Print environment variables"
|
||||
default n
|
||||
depends on RESIZE
|
||||
help
|
||||
@@ -95,6 +95,12 @@ config FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
help
|
||||
Support long options for the setconsole applet.
|
||||
|
||||
config SETFONT
|
||||
bool "setfont"
|
||||
default n
|
||||
help
|
||||
Allows to load console screen map. Useful for i18n.
|
||||
|
||||
config SETKEYCODES
|
||||
bool "setkeycodes"
|
||||
default n
|
||||
@@ -108,4 +114,10 @@ config SETLOGCONS
|
||||
help
|
||||
This program redirects the output console of kernel messages.
|
||||
|
||||
config SHOWKEY
|
||||
bool "showkey"
|
||||
default n
|
||||
help
|
||||
Shows keys pressed.
|
||||
|
||||
endmenu
|
||||
@@ -16,5 +16,7 @@ lib-$(CONFIG_LOADKMAP) += loadkmap.o
|
||||
lib-$(CONFIG_OPENVT) += openvt.o
|
||||
lib-$(CONFIG_RESET) += reset.o
|
||||
lib-$(CONFIG_RESIZE) += resize.o
|
||||
lib-$(CONFIG_SETFONT) += loadfont.o
|
||||
lib-$(CONFIG_SETKEYCODES) += setkeycodes.o
|
||||
lib-$(CONFIG_SETLOGCONS) += setlogcons.o
|
||||
lib-$(CONFIG_SHOWKEY) += showkey.o
|
||||
+2
-11
@@ -9,25 +9,16 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
enum {
|
||||
VT_ACTIVATE = 0x5606, /* make vt active */
|
||||
VT_WAITACTIVE = 0x5607 /* wait for vt active */
|
||||
};
|
||||
|
||||
int chvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
int num;
|
||||
|
||||
if (argc != 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
fd = get_console_fd();
|
||||
num = xatou_range(argv[1], 1, 63);
|
||||
/* double cast suppresses "cast to ptr from int of different size" */
|
||||
xioctl(fd, VT_ACTIVATE, (void *)(ptrdiff_t)num);
|
||||
xioctl(fd, VT_WAITACTIVE, (void *)(ptrdiff_t)num);
|
||||
console_make_active(get_console_fd_or_die(), num);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "libbb.h"
|
||||
|
||||
int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int clear_main(int argc, char **argv)
|
||||
int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
return printf("\033[H\033[J") != 6;
|
||||
}
|
||||
@@ -16,22 +16,18 @@
|
||||
enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
|
||||
|
||||
int deallocvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int deallocvt_main(int argc, char **argv)
|
||||
int deallocvt_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
/* num = 0 deallocate all unused consoles */
|
||||
int num = 0;
|
||||
|
||||
switch (argc) {
|
||||
case 2:
|
||||
if (argv[1]) {
|
||||
if (argv[2])
|
||||
bb_show_usage();
|
||||
num = xatou_range(argv[1], 1, 63);
|
||||
/* Fallthrough */
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
/* double cast suppresses "cast to ptr from int of different size" */
|
||||
xioctl(get_console_fd(), VT_DISALLOCATE, (void *)(ptrdiff_t)num);
|
||||
xioctl(get_console_fd_or_die(), VT_DISALLOCATE, (void *)(ptrdiff_t)num);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
*/
|
||||
/* no options, no getopt */
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
@@ -23,18 +24,17 @@ struct kbentry {
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int dumpkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int dumpkmap_main(int argc, char **argv)
|
||||
int dumpkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
char flags[MAX_NR_KEYMAPS];
|
||||
RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
|
||||
|
||||
if (argc >= 2 && argv[1][0] == '-')
|
||||
bb_show_usage();
|
||||
/* bb_warn_ignoring_args(argc>=2);*/
|
||||
|
||||
fd = xopen(CURRENT_VC, O_RDWR);
|
||||
fd = get_console_fd_or_die();
|
||||
|
||||
write(1, "bkeymap", 7);
|
||||
write(STDOUT_FILENO, "bkeymap", 7);
|
||||
|
||||
/* Here we want to set everything to 0 except for indexes:
|
||||
* [0-2] [4-6] [8-10] [12] */
|
||||
@@ -43,7 +43,7 @@ int dumpkmap_main(int argc, char **argv)
|
||||
flags[3] = flags[7] = flags[11] = 0;
|
||||
|
||||
/* dump flags */
|
||||
write(1, flags, MAX_NR_KEYMAPS);
|
||||
write(STDOUT_FILENO, flags, MAX_NR_KEYMAPS);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
@@ -56,11 +56,14 @@ int dumpkmap_main(int argc, char **argv)
|
||||
(char *)&ke.kb_table,
|
||||
&ke.kb_value)
|
||||
) {
|
||||
write(1, (void*)&ke.kb_value, 2);
|
||||
write(STDOUT_FILENO, (void*)&ke.kb_value, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(fd);
|
||||
RELEASE_CONFIG_BUFFER(flags);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+29
-46
@@ -1,6 +1,6 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini loadkmap implementation for busybox
|
||||
* Mini kbd_mode implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2007 Loïc Grenié <loic.grenie@gmail.com>
|
||||
* written using Andries Brouwer <aeb@cwi.nl>'s kbd_mode from
|
||||
@@ -10,59 +10,42 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include "libbb.h"
|
||||
#include <linux/kd.h>
|
||||
|
||||
int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int kbd_mode_main(int argc, char **argv)
|
||||
int kbd_mode_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
static const char opts[] = "saku";
|
||||
|
||||
const char *opt = argv[1];
|
||||
const char *p;
|
||||
int fd;
|
||||
unsigned opt;
|
||||
enum {
|
||||
SCANCODE = (1 << 0),
|
||||
ASCII = (1 << 1),
|
||||
MEDIUMRAW = (1 << 2),
|
||||
UNICODE = (1 << 3)
|
||||
};
|
||||
static const char KD_xxx[] ALIGN1 = "saku";
|
||||
opt = getopt32(argv, KD_xxx);
|
||||
fd = get_console_fd_or_die();
|
||||
|
||||
fd = get_console_fd();
|
||||
if (fd < 0) /* get_console_fd() already complained */
|
||||
return EXIT_FAILURE;
|
||||
if (!opt) { /* print current setting */
|
||||
const char *mode = "unknown";
|
||||
int m;
|
||||
|
||||
if (opt == NULL) {
|
||||
/* No arg */
|
||||
const char *msg = "unknown";
|
||||
int mode;
|
||||
|
||||
ioctl(fd, KDGKBMODE, &mode);
|
||||
switch(mode) {
|
||||
case K_RAW:
|
||||
msg = "raw (scancode)";
|
||||
break;
|
||||
case K_XLATE:
|
||||
msg = "default (ASCII)";
|
||||
break;
|
||||
case K_MEDIUMRAW:
|
||||
msg = "mediumraw (keycode)";
|
||||
break;
|
||||
case K_UNICODE:
|
||||
msg = "Unicode (UTF-8)";
|
||||
break;
|
||||
}
|
||||
printf("The keyboard is in %s mode\n", msg);
|
||||
}
|
||||
else if (argc > 2 /* more than 1 arg */
|
||||
|| *opt != '-' /* not an option */
|
||||
|| (p = strchr(opts, opt[1])) == NULL /* not an option we expect */
|
||||
|| opt[2] != '\0' /* more than one option char */
|
||||
) {
|
||||
bb_show_usage();
|
||||
/* return EXIT_FAILURE; - not reached */
|
||||
}
|
||||
else {
|
||||
#if K_RAW != 0 || K_XLATE != 1 || K_MEDIUMRAW != 2 || K_UNICODE != 3
|
||||
#error kbd_mode must be changed
|
||||
#endif
|
||||
/* The options are in the order of the various K_xxx */
|
||||
ioctl(fd, KDSKBMODE, p - opts);
|
||||
ioctl(fd, KDGKBMODE, &m);
|
||||
if (m == K_RAW)
|
||||
mode = "raw (scancode)";
|
||||
else if (m == K_XLATE)
|
||||
mode = "default (ASCII)";
|
||||
else if (m == K_MEDIUMRAW)
|
||||
mode = "mediumraw (keycode)";
|
||||
else if (m == K_UNICODE)
|
||||
mode = "Unicode (UTF-8)";
|
||||
printf("The keyboard is in %s mode\n", mode);
|
||||
} else {
|
||||
opt = opt & UNICODE ? 3 : opt >> 1;
|
||||
/* double cast prevents warnings about widening conversion */
|
||||
xioctl(fd, KDSKBMODE, (void*)(ptrdiff_t)opt);
|
||||
}
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
|
||||
+92
-76
@@ -26,7 +26,7 @@ struct psf_header {
|
||||
unsigned char charsize; /* Character size */
|
||||
};
|
||||
|
||||
#define PSF_MAGIC_OK(x) ((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2)
|
||||
#define PSF_MAGIC_OK(x) ((x)->magic1 == PSF_MAGIC1 && (x)->magic2 == PSF_MAGIC2)
|
||||
|
||||
static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
|
||||
{
|
||||
@@ -37,7 +37,6 @@ static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
|
||||
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);
|
||||
|
||||
@@ -58,8 +57,7 @@ static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
|
||||
free(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
{
|
||||
struct unimapinit advice;
|
||||
struct unimapdesc ud;
|
||||
@@ -68,7 +66,7 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
int glyph;
|
||||
uint16_t unicode;
|
||||
|
||||
maxct = tailsz; /* more than enough */
|
||||
maxct = tailsz; /* more than enough */
|
||||
up = xmalloc(maxct * sizeof(struct unipair));
|
||||
|
||||
for (glyph = 0; glyph < fontsize; glyph++) {
|
||||
@@ -96,86 +94,104 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
xioctl(fd, PIO_UNIMAP, &ud);
|
||||
}
|
||||
|
||||
static void loadnewfont(int fd)
|
||||
static void do_load(int fd, struct psf_header *psfhdr, size_t len)
|
||||
{
|
||||
enum { INBUF_SIZE = 32*1024 + 1 };
|
||||
|
||||
int unit;
|
||||
unsigned inputlth, offset;
|
||||
/* Was on stack, but 32k is a bit too much: */
|
||||
unsigned char *inbuf = xmalloc(INBUF_SIZE);
|
||||
int fontsize;
|
||||
int hastable;
|
||||
unsigned head0, head = head;
|
||||
|
||||
/* test for psf first */
|
||||
if (len >= sizeof(struct psf_header) && PSF_MAGIC_OK(psfhdr)) {
|
||||
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 (fontsize != 256)
|
||||
bb_error_msg_and_die("only fontsize 256 supported");
|
||||
#endif
|
||||
hastable = (psfhdr->mode & PSF_MODEHASTAB);
|
||||
unit = psfhdr->charsize;
|
||||
head0 = sizeof(struct psf_header);
|
||||
|
||||
head = head0 + fontsize * unit;
|
||||
if (head > len || (!hastable && head != len))
|
||||
bb_error_msg_and_die("input file: bad length");
|
||||
} else {
|
||||
/* file with three code pages? */
|
||||
if (len == 9780) {
|
||||
head0 = 40;
|
||||
unit = 16;
|
||||
} else {
|
||||
/* bare font */
|
||||
if (len & 0377)
|
||||
bb_error_msg_and_die("input file: bad length");
|
||||
head0 = 0;
|
||||
unit = len / 256;
|
||||
}
|
||||
fontsize = 256;
|
||||
hastable = 0;
|
||||
}
|
||||
|
||||
do_loadfont(fd, (unsigned char *)psfhdr + head0, unit, fontsize);
|
||||
if (hastable)
|
||||
do_loadtable(fd, (unsigned char *)psfhdr + head, len - head, fontsize);
|
||||
}
|
||||
|
||||
#if ENABLE_LOADFONT
|
||||
int loadfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int loadfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
size_t len;
|
||||
struct psf_header *psfhdr;
|
||||
|
||||
// no arguments allowed!
|
||||
opt_complementary = "=0";
|
||||
getopt32(argv, "");
|
||||
|
||||
/*
|
||||
* 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 = full_read(STDIN_FILENO, inbuf, INBUF_SIZE);
|
||||
if (inputlth < 0)
|
||||
len = 32*1024; // can't be larger
|
||||
psfhdr = (struct psf_header *) xmalloc_read(STDIN_FILENO, &len);
|
||||
// xmalloc_open_zipped_read_close(filename, &len);
|
||||
if (!psfhdr)
|
||||
bb_perror_msg_and_die("error reading input font");
|
||||
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 head0, head;
|
||||
|
||||
if (inputlth < sizeof(struct psf_header))
|
||||
goto no_psf;
|
||||
|
||||
psfhdr = *(struct psf_header *) &inbuf[0];
|
||||
|
||||
if (!PSF_MAGIC_OK(psfhdr))
|
||||
goto no_psf;
|
||||
|
||||
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 (fontsize != 256)
|
||||
bb_error_msg_and_die("only fontsize 256 supported");
|
||||
#endif
|
||||
hastable = (psfhdr.mode & PSF_MODEHASTAB);
|
||||
unit = psfhdr.charsize;
|
||||
head0 = sizeof(struct psf_header);
|
||||
|
||||
head = head0 + fontsize * unit;
|
||||
if (head > inputlth || (!hastable && head != inputlth))
|
||||
bb_error_msg_and_die("input file: bad length");
|
||||
do_loadfont(fd, inbuf + head0, unit, fontsize);
|
||||
if (hastable)
|
||||
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
|
||||
return;
|
||||
}
|
||||
|
||||
no_psf:
|
||||
/* file with three code pages? */
|
||||
if (inputlth == 9780) {
|
||||
offset = 40;
|
||||
unit = 16;
|
||||
} else {
|
||||
/* bare font */
|
||||
if (inputlth & 0377)
|
||||
bb_error_msg_and_die("bad input file size");
|
||||
offset = 0;
|
||||
unit = inputlth / 256;
|
||||
}
|
||||
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);
|
||||
do_load(get_console_fd_or_die(), psfhdr, len);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLE_SETFONT
|
||||
int setfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
size_t len;
|
||||
struct psf_header *psfhdr;
|
||||
char *mapfilename;
|
||||
int fd;
|
||||
|
||||
opt_complementary = "=1";
|
||||
getopt32(argv, "m:", &mapfilename);
|
||||
argv += optind;
|
||||
|
||||
// load font
|
||||
len = 32*1024; // can't be larger
|
||||
psfhdr = (struct psf_header *) xmalloc_open_zipped_read_close(*argv, &len);
|
||||
fd = get_console_fd_or_die();
|
||||
do_load(fd, psfhdr, len);
|
||||
|
||||
// load the screen map, if any
|
||||
if (option_mask32 & 1) { // -m
|
||||
void *map = xmalloc_open_zipped_read_close(mapfilename, &len);
|
||||
if (len == E_TABSZ || len == 2*E_TABSZ) {
|
||||
xioctl(fd, (len == 2*E_TABSZ) ? PIO_UNISCRNMAP : PIO_SCRNMAP, map);
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
+14
-13
@@ -26,28 +26,26 @@ struct kbentry {
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int loadkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int loadkmap_main(int argc, char **argv)
|
||||
int loadkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
uint16_t ibuff[NR_KEYS];
|
||||
char flags[MAX_NR_KEYMAPS];
|
||||
char buff[7];
|
||||
RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
|
||||
|
||||
if (argc != 1)
|
||||
bb_show_usage();
|
||||
/* bb_warn_ignoring_args(argc>=2);*/
|
||||
|
||||
fd = xopen(CURRENT_VC, O_RDWR);
|
||||
fd = get_console_fd_or_die();
|
||||
|
||||
xread(0, buff, 7);
|
||||
if (strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||
bb_error_msg_and_die("this is not a valid binary keymap");
|
||||
xread(STDIN_FILENO, flags, 7);
|
||||
if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7))
|
||||
bb_error_msg_and_die("not a valid binary keymap");
|
||||
|
||||
xread(0, flags, MAX_NR_KEYMAPS);
|
||||
xread(STDIN_FILENO, flags, MAX_NR_KEYMAPS);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
xread(0, ibuff, NR_KEYS * sizeof(uint16_t));
|
||||
xread(STDIN_FILENO, ibuff, NR_KEYS * sizeof(uint16_t));
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
@@ -57,6 +55,9 @@ int loadkmap_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP) close(fd);
|
||||
return 0;
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(fd);
|
||||
RELEASE_CONFIG_BUFFER(flags);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+162
-16
@@ -8,28 +8,174 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <linux/vt.h>
|
||||
#include "libbb.h"
|
||||
|
||||
int openvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int openvt_main(int argc, char **argv)
|
||||
/* "Standard" openvt's man page (we do not support all of this):
|
||||
|
||||
openvt [-c NUM] [-fsulv] [--] [command [args]]
|
||||
|
||||
Find the first available VT, and run command on it. Stdio is directed
|
||||
to that VT. If no command is specified then $SHELL is used.
|
||||
|
||||
-c NUM
|
||||
Use the given VT number, not the first free one.
|
||||
-f
|
||||
Force opening a VT: don't try to check if VT is already in use.
|
||||
-s
|
||||
Switch to the new VT when starting the command.
|
||||
The VT of the new command will be made the new current VT.
|
||||
-u
|
||||
Figure out the owner of the current VT, and run login as that user.
|
||||
Suitable to be called by init. Shouldn't be used with -c or -l.
|
||||
-l
|
||||
Make the command a login shell: a "-" is prepended to the argv[0]
|
||||
when command is executed.
|
||||
-v
|
||||
Verbose.
|
||||
-w
|
||||
Wait for command to complete. If -w and -s are used together,
|
||||
switch back to the controlling terminal when the command completes.
|
||||
|
||||
bbox:
|
||||
-u: not implemented
|
||||
-f: always in effect
|
||||
-l: not implemented, ignored
|
||||
-v: ignored
|
||||
-ws: does NOT switch back
|
||||
*/
|
||||
|
||||
/* Helper: does this fd understand VT_xxx? */
|
||||
static int not_vt_fd(int fd)
|
||||
{
|
||||
char vtname[sizeof(VC_FORMAT) + 2];
|
||||
struct vt_stat vtstat;
|
||||
return ioctl(fd, VT_GETSTATE, &vtstat); /* !0: error, it's not VT fd */
|
||||
}
|
||||
|
||||
if (argc < 3)
|
||||
bb_show_usage();
|
||||
/* Helper: get a fd suitable for VT_xxx */
|
||||
static int get_vt_fd(void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
/* check for illegal vt number: < 1 or > 63 */
|
||||
sprintf(vtname, VC_FORMAT, (int)xatou_range(argv[1], 1, 63));
|
||||
/* Do we, by chance, already have it? */
|
||||
for (fd = 0; fd < 3; fd++)
|
||||
if (!not_vt_fd(fd))
|
||||
return fd;
|
||||
/* _only_ O_NONBLOCK: ask for neither read nor write perms */
|
||||
/*FIXME: use? device_open(DEV_CONSOLE,0); */
|
||||
fd = open(DEV_CONSOLE, O_NONBLOCK);
|
||||
if (fd >= 0 && !not_vt_fd(fd))
|
||||
return fd;
|
||||
bb_error_msg_and_die("can't find open VT");
|
||||
}
|
||||
|
||||
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS, argv);
|
||||
/* grab new one */
|
||||
close(0);
|
||||
static int find_free_vtno(void)
|
||||
{
|
||||
int vtno;
|
||||
int fd = get_vt_fd();
|
||||
|
||||
errno = 0;
|
||||
/*xfunc_error_retval = 3; - do we need compat? */
|
||||
if (ioctl(fd, VT_OPENQRY, &vtno) != 0 || vtno <= 0)
|
||||
bb_perror_msg_and_die("can't find open VT");
|
||||
// Not really needed, grep for DAEMON_ONLY_SANITIZE
|
||||
// if (fd > 2)
|
||||
// close(fd);
|
||||
return vtno;
|
||||
}
|
||||
|
||||
/* vfork scares gcc, it generates bigger code.
|
||||
* Keep it away from main program.
|
||||
* TODO: move to libbb; or adapt existing libbb's spawn().
|
||||
*/
|
||||
static NOINLINE void vfork_child(char **argv)
|
||||
{
|
||||
if (vfork() == 0) {
|
||||
/* CHILD */
|
||||
/* Try to make this VT our controlling tty */
|
||||
setsid(); /* lose old ctty */
|
||||
ioctl(STDIN_FILENO, TIOCSCTTY, 0 /* 0: don't forcibly steal */);
|
||||
//bb_error_msg("our sid %d", getsid(0));
|
||||
//bb_error_msg("our pgrp %d", getpgrp());
|
||||
//bb_error_msg("VT's sid %d", tcgetsid(0));
|
||||
//bb_error_msg("VT's pgrp %d", tcgetpgrp(0));
|
||||
BB_EXECVP(argv[0], argv);
|
||||
bb_perror_msg_and_die("exec %s", argv[0]);
|
||||
}
|
||||
}
|
||||
|
||||
int openvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int openvt_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
char vtname[sizeof(VC_FORMAT) + sizeof(int)*3];
|
||||
struct vt_stat vtstat;
|
||||
char *str_c;
|
||||
int vtno;
|
||||
int flags;
|
||||
enum {
|
||||
OPT_c = (1 << 0),
|
||||
OPT_w = (1 << 1),
|
||||
OPT_s = (1 << 2),
|
||||
OPT_l = (1 << 3),
|
||||
OPT_f = (1 << 4),
|
||||
OPT_v = (1 << 5),
|
||||
};
|
||||
|
||||
/* "+" - stop on first non-option */
|
||||
flags = getopt32(argv, "+c:wslfv", &str_c);
|
||||
argv += optind;
|
||||
|
||||
if (flags & OPT_c) {
|
||||
/* Check for illegal vt number: < 1 or > 63 */
|
||||
vtno = xatou_range(str_c, 1, 63);
|
||||
} else {
|
||||
vtno = find_free_vtno();
|
||||
}
|
||||
|
||||
/* Grab new VT */
|
||||
sprintf(vtname, VC_FORMAT, vtno);
|
||||
/* (Try to) clean up stray open fds above fd 2 */
|
||||
bb_daemonize_or_rexec(DAEMON_CLOSE_EXTRA_FDS | DAEMON_ONLY_SANITIZE, NULL);
|
||||
close(STDIN_FILENO);
|
||||
/*setsid(); - BAD IDEA: after we exit, child is SIGHUPed... */
|
||||
xopen(vtname, O_RDWR);
|
||||
dup2(0, STDOUT_FILENO);
|
||||
dup2(0, STDERR_FILENO);
|
||||
xioctl(STDIN_FILENO, VT_GETSTATE, &vtstat);
|
||||
|
||||
if (flags & OPT_s) {
|
||||
console_make_active(STDIN_FILENO, vtno);
|
||||
}
|
||||
|
||||
if (!argv[0]) {
|
||||
argv--;
|
||||
argv[0] = getenv("SHELL");
|
||||
if (!argv[0])
|
||||
argv[0] = (char *) DEFAULT_SHELL;
|
||||
/*argv[1] = NULL; - already is */
|
||||
}
|
||||
|
||||
xdup2(STDIN_FILENO, STDOUT_FILENO);
|
||||
xdup2(STDIN_FILENO, STDERR_FILENO);
|
||||
|
||||
#ifdef BLOAT
|
||||
{
|
||||
/* Handle -l (login shell) option */
|
||||
const char *prog = argv[0];
|
||||
if (flags & OPT_l)
|
||||
argv[0] = xasprintf("-%s", argv[0]);
|
||||
}
|
||||
#endif
|
||||
|
||||
BB_EXECVP(argv[2], &argv[2]);
|
||||
_exit(1);
|
||||
vfork_child(argv);
|
||||
if (flags & OPT_w) {
|
||||
/* We have only one child, wait for it */
|
||||
safe_waitpid(-1, NULL, 0); /* loops on EINTR */
|
||||
if (flags & OPT_s) {
|
||||
console_make_active(STDIN_FILENO, vtstat.v_active);
|
||||
// Compat: even with -c N (try to) disallocate:
|
||||
// # /usr/app/kbd-1.12/bin/openvt -f -c 9 -ws sleep 5
|
||||
// openvt: could not deallocate console 9
|
||||
xioctl(STDIN_FILENO, VT_DISALLOCATE, (void*)(ptrdiff_t)vtno);
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+22
-5
@@ -8,14 +8,25 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
/* BTW, which "standard" package has this utility? It doesn't seem
|
||||
* to be ncurses, coreutils, console-tools... then what? */
|
||||
|
||||
#if ENABLE_STTY
|
||||
int stty_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
#endif
|
||||
|
||||
int reset_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int reset_main(int argc, char **argv)
|
||||
int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
if (isatty(1)) {
|
||||
static const char *const args[] = {
|
||||
"stty", "sane", NULL
|
||||
};
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
if (isatty(STDIN_FILENO) && isatty(STDOUT_FILENO)) {
|
||||
/* See 'man 4 console_codes' for details:
|
||||
* "ESC c" -- Reset
|
||||
* "ESC ( K" -- Select user mapping
|
||||
@@ -24,7 +35,13 @@ int reset_main(int argc, char **argv)
|
||||
* "ESC [ ? 25 h" -- Make cursor visible.
|
||||
*/
|
||||
printf("\033c\033(K\033[J\033[0m\033[?25h");
|
||||
/* http://bugs.busybox.net/view.php?id=1414:
|
||||
* people want it to reset echo etc: */
|
||||
#if ENABLE_STTY
|
||||
return stty_main(2, (char**)args);
|
||||
#else
|
||||
execvp("stty", (char**)args);
|
||||
#endif
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+10
-8
@@ -14,17 +14,17 @@
|
||||
#define old_termios (*(struct termios*)&bb_common_bufsiz1)
|
||||
|
||||
static void
|
||||
onintr(int sig ATTRIBUTE_UNUSED)
|
||||
onintr(int sig UNUSED_PARAM)
|
||||
{
|
||||
tcsetattr(STDERR_FILENO, TCSANOW, &old_termios);
|
||||
exit(1);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int resize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int resize_main(int argc, char **argv)
|
||||
int resize_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
struct termios new;
|
||||
struct winsize w = { 0,0,0,0 };
|
||||
struct winsize w = { 0, 0, 0, 0 };
|
||||
int ret;
|
||||
|
||||
/* We use _stderr_ in order to make resize usable
|
||||
@@ -37,10 +37,12 @@ int resize_main(int argc, char **argv)
|
||||
new = old_termios;
|
||||
new.c_cflag |= (CLOCAL | CREAD);
|
||||
new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
|
||||
signal(SIGINT, onintr);
|
||||
signal(SIGQUIT, onintr);
|
||||
signal(SIGTERM, onintr);
|
||||
signal(SIGALRM, onintr);
|
||||
bb_signals(0
|
||||
+ (1 << SIGINT)
|
||||
+ (1 << SIGQUIT)
|
||||
+ (1 << SIGTERM)
|
||||
+ (1 << SIGALRM)
|
||||
, onintr);
|
||||
tcsetattr(STDERR_FILENO, TCSANOW, &new);
|
||||
|
||||
/* save_cursor_pos 7
|
||||
|
||||
+13
-20
@@ -3,41 +3,34 @@
|
||||
* setconsole.c - redirect system console output
|
||||
*
|
||||
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
|
||||
* Copyright (C) 2008 Bernhard Fischer
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include "libbb.h"
|
||||
|
||||
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
static const char setconsole_longopts[] ALIGN1 =
|
||||
"reset\0" No_argument "r"
|
||||
;
|
||||
#endif
|
||||
|
||||
#define OPT_SETCONS_RESET 1
|
||||
|
||||
int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setconsole_main(int argc, char **argv)
|
||||
int setconsole_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
unsigned long flags;
|
||||
const char *device = CURRENT_TTY;
|
||||
bool reset;
|
||||
|
||||
#if ENABLE_FEATURE_SETCONSOLE_LONG_OPTIONS
|
||||
static const char setconsole_longopts[] ALIGN1 =
|
||||
"reset\0" No_argument "r"
|
||||
;
|
||||
applet_long_options = setconsole_longopts;
|
||||
#endif
|
||||
flags = getopt32(argv, "r");
|
||||
/* at most one non-option argument */
|
||||
opt_complementary = "?1";
|
||||
reset = getopt32(argv, "r");
|
||||
|
||||
if (argc - optind > 1)
|
||||
bb_show_usage();
|
||||
|
||||
if (argc - optind == 1) {
|
||||
if (flags & OPT_SETCONS_RESET)
|
||||
bb_show_usage();
|
||||
device = argv[optind];
|
||||
argv += 1 + reset;
|
||||
if (*argv) {
|
||||
device = *argv;
|
||||
} else {
|
||||
if (flags & OPT_SETCONS_RESET)
|
||||
if (reset)
|
||||
device = DEV_CONSOLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbkeycode {
|
||||
unsigned int scancode, keycode;
|
||||
unsigned scancode, keycode;
|
||||
};
|
||||
enum {
|
||||
KDSETKEYCODE = 0x4B4D /* write kernel keycode table entry */
|
||||
@@ -26,21 +26,21 @@ int setkeycodes_main(int argc, char **argv)
|
||||
int fd, sc;
|
||||
struct kbkeycode a;
|
||||
|
||||
if (argc % 2 != 1 || argc < 2) {
|
||||
if (!(argc & 1) /* if even */ || argc < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
fd = get_console_fd();
|
||||
fd = get_console_fd_or_die();
|
||||
|
||||
while (argc > 2) {
|
||||
a.keycode = xatoul_range(argv[2], 0, 127);
|
||||
a.keycode = xatou_range(argv[2], 0, 127);
|
||||
a.scancode = sc = xstrtoul_range(argv[1], 16, 0, 255);
|
||||
if (a.scancode > 127) {
|
||||
a.scancode -= 0xe000;
|
||||
a.scancode += 128;
|
||||
}
|
||||
ioctl_or_perror_and_die(fd, KDSETKEYCODE, &a,
|
||||
"failed to set SCANCODE %x to KEYCODE %d",
|
||||
"can't set SCANCODE %x to KEYCODE %d",
|
||||
sc, a.keycode);
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
|
||||
@@ -12,20 +12,19 @@
|
||||
#include "libbb.h"
|
||||
|
||||
int setlogcons_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setlogcons_main(int argc, char **argv)
|
||||
int setlogcons_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
struct {
|
||||
char fn;
|
||||
char subarg;
|
||||
} arg;
|
||||
} arg = { 11, /* redirect kernel messages */
|
||||
0 /* to specified console (current as default) */
|
||||
};
|
||||
|
||||
arg.fn = 11; /* redirect kernel messages */
|
||||
arg.subarg = 0; /* to specified console (current as default) */
|
||||
|
||||
if (argc == 2)
|
||||
arg.subarg = xatoul_range(argv[1], 0, 63);
|
||||
if (argv[1])
|
||||
arg.subarg = xatou_range(argv[1], 0, 63);
|
||||
|
||||
xioctl(xopen(VC_1, O_RDONLY), TIOCLINUX, &arg);
|
||||
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* shows keys pressed. inspired by kbd package
|
||||
*
|
||||
* Copyright (C) 2008 by Vladimir Dronnikov <dronnikov@gmail.com>
|
||||
*
|
||||
* Licensed under GPLv2, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include <linux/kd.h>
|
||||
|
||||
// set raw tty mode
|
||||
// also used by microcom
|
||||
// libbb candidates?
|
||||
static void xget1(int fd, struct termios *t, struct termios *oldt)
|
||||
{
|
||||
tcgetattr(fd, oldt);
|
||||
*t = *oldt;
|
||||
cfmakeraw(t);
|
||||
}
|
||||
|
||||
static int xset1(int fd, struct termios *tio, const char *device)
|
||||
{
|
||||
int ret = tcsetattr(fd, TCSAFLUSH, tio);
|
||||
|
||||
if (ret) {
|
||||
bb_perror_msg("can't tcsetattr for %s", device);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* GLOBALS
|
||||
*/
|
||||
struct globals {
|
||||
int kbmode;
|
||||
struct termios tio, tio0;
|
||||
};
|
||||
#define G (*ptr_to_globals)
|
||||
#define kbmode (G.kbmode)
|
||||
#define tio (G.tio)
|
||||
#define tio0 (G.tio0)
|
||||
#define INIT_G() do { \
|
||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
||||
} while (0)
|
||||
|
||||
|
||||
static void signal_handler(int signo)
|
||||
{
|
||||
// restore keyboard and console settings
|
||||
xset1(STDIN_FILENO, &tio0, "stdin");
|
||||
xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)kbmode);
|
||||
// alarmed? -> exit 0
|
||||
exit(SIGALRM == signo);
|
||||
}
|
||||
|
||||
int showkey_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int showkey_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
enum {
|
||||
OPT_a = (1<<0), // display the decimal/octal/hex values of the keys
|
||||
OPT_k = (1<<1), // display only the interpreted keycodes (default)
|
||||
OPT_s = (1<<2), // display only the raw scan-codes
|
||||
};
|
||||
|
||||
// FIXME: aks are all mutually exclusive
|
||||
getopt32(argv, "aks");
|
||||
|
||||
INIT_G();
|
||||
|
||||
// get keyboard settings
|
||||
xioctl(STDIN_FILENO, KDGKBMODE, &kbmode);
|
||||
printf("kb mode was %s\n\nPress any keys. Program terminates %s\n\n",
|
||||
kbmode == K_RAW ? "RAW" :
|
||||
(kbmode == K_XLATE ? "XLATE" :
|
||||
(kbmode == K_MEDIUMRAW ? "MEDIUMRAW" :
|
||||
(kbmode == K_UNICODE ? "UNICODE" : "?UNKNOWN?")))
|
||||
, (option_mask32 & OPT_a) ? "when CTRL+D pressed" : "10s after last keypress"
|
||||
);
|
||||
// prepare for raw mode
|
||||
xget1(STDIN_FILENO, &tio, &tio0);
|
||||
// put stdin in raw mode
|
||||
xset1(STDIN_FILENO, &tio, "stdin");
|
||||
|
||||
if (option_mask32 & OPT_a) {
|
||||
char c;
|
||||
// just read stdin char by char
|
||||
while (1 == safe_read(STDIN_FILENO, &c, 1)) {
|
||||
printf("%3d 0%03o 0x%02x\r\n", c, c, c);
|
||||
if (04 /*CTRL-D*/ == c)
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// we should exit on any signal
|
||||
bb_signals(BB_FATAL_SIGS, signal_handler);
|
||||
// set raw keyboard mode
|
||||
xioctl(STDIN_FILENO, KDSKBMODE, (void *)(ptrdiff_t)((option_mask32 & OPT_k) ? K_MEDIUMRAW : K_RAW));
|
||||
|
||||
// read and show scancodes
|
||||
while (1) {
|
||||
char buf[18];
|
||||
int i, n;
|
||||
// setup 10s watchdog
|
||||
alarm(10);
|
||||
// read scancodes
|
||||
n = read(STDIN_FILENO, buf, sizeof(buf));
|
||||
i = 0;
|
||||
while (i < n) {
|
||||
char c = buf[i];
|
||||
// show raw scancodes ordered? ->
|
||||
if (option_mask32 & OPT_s) {
|
||||
printf("0x%02x ", buf[i++]);
|
||||
// show interpreted scancodes (default) ? ->
|
||||
} else {
|
||||
int kc;
|
||||
if (i+2 < n && (c & 0x7f) == 0
|
||||
&& (buf[i+1] & 0x80) != 0
|
||||
&& (buf[i+2] & 0x80) != 0) {
|
||||
kc = ((buf[i+1] & 0x7f) << 7) | (buf[i+2] & 0x7f);
|
||||
i += 3;
|
||||
} else {
|
||||
kc = (c & 0x7f);
|
||||
i++;
|
||||
}
|
||||
printf("keycode %3d %s", kc, (c & 0x80) ? "release" : "press");
|
||||
}
|
||||
}
|
||||
puts("\r");
|
||||
}
|
||||
}
|
||||
|
||||
// cleanup
|
||||
signal_handler(SIGALRM);
|
||||
|
||||
// should never be here!
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+46
-16
@@ -10,7 +10,7 @@ config BASENAME
|
||||
default n
|
||||
help
|
||||
basename is used to strip the directory and suffix from filenames,
|
||||
leaving just the filename itself. Enable this option if you wish
|
||||
leaving just the filename itself. Enable this option if you wish
|
||||
to enable the 'basename' utility.
|
||||
|
||||
config CAL
|
||||
@@ -24,7 +24,7 @@ config CAT
|
||||
default n
|
||||
help
|
||||
cat is used to concatenate files and print them to the standard
|
||||
output. Enable this option if you wish to enable the 'cat' utility.
|
||||
output. Enable this option if you wish to enable the 'cat' utility.
|
||||
|
||||
config CATV
|
||||
bool "catv"
|
||||
@@ -117,7 +117,8 @@ config FEATURE_DD_SIGNAL_HANDLING
|
||||
print to standard error the number of records read and written
|
||||
so far, then to resume copying.
|
||||
|
||||
$ dd if=/dev/zero of=/dev/null& pid=$! $ kill -USR1 $pid; sleep 1; kill $pid
|
||||
$ dd if=/dev/zero of=/dev/null&
|
||||
$ pid=$! kill -USR1 $pid; sleep 1; kill $pid
|
||||
10899206+0 records in 10899206+0 records out
|
||||
|
||||
config FEATURE_DD_IBS_OBS
|
||||
@@ -232,7 +233,7 @@ config EXPR_MATH_SUPPORT_64
|
||||
default n
|
||||
depends on EXPR
|
||||
help
|
||||
Enable 64-bit math support in the expr applet. This will make
|
||||
Enable 64-bit math support in the expr applet. This will make
|
||||
the applet slightly larger, but will allow computation with very
|
||||
large numbers.
|
||||
|
||||
@@ -488,6 +489,14 @@ config RMDIR
|
||||
help
|
||||
rmdir is used to remove empty directories.
|
||||
|
||||
config FEATURE_RMDIR_LONG_OPTIONS
|
||||
bool "Enable long options"
|
||||
default n
|
||||
depends on RMDIR && GETOPT_LONG
|
||||
help
|
||||
Support long options for the rmdir applet, including
|
||||
--ignore-fail-on-non-empty for compatibility with GNU rmdir.
|
||||
|
||||
config SEQ
|
||||
bool "seq"
|
||||
default n
|
||||
@@ -501,18 +510,33 @@ config SHA1SUM
|
||||
Compute and check SHA1 message digest
|
||||
|
||||
config SLEEP
|
||||
bool "sleep (single integer arg with no suffix)"
|
||||
bool "sleep"
|
||||
default n
|
||||
help
|
||||
sleep is used to pause for a specified number of seconds,
|
||||
sleep is used to pause for a specified number of seconds.
|
||||
It comes in 3 versions:
|
||||
- small: takes one integer parameter
|
||||
- fancy: takes multiple integer arguments with suffixes:
|
||||
sleep 1d 2h 3m 15s
|
||||
- fancy with fractional numbers:
|
||||
sleep 2.3s 4.5h sleeps for 16202.3 seconds
|
||||
Last one is "the most compatible" with coreutils sleep,
|
||||
but it adds around 1k of code.
|
||||
|
||||
config FEATURE_FANCY_SLEEP
|
||||
bool "Enable multiple integer args and optional time suffixes"
|
||||
bool "Enable multiple arguments and s/m/h/d suffixes"
|
||||
default n
|
||||
depends on SLEEP
|
||||
help
|
||||
Allow sleep to pause for specified minutes, hours, and days.
|
||||
|
||||
config FEATURE_FLOAT_SLEEP
|
||||
bool "Enable fractional arguments"
|
||||
default n
|
||||
depends on FEATURE_FANCY_SLEEP
|
||||
help
|
||||
Allow for fractional numeric parameters.
|
||||
|
||||
config SORT
|
||||
bool "sort"
|
||||
default n
|
||||
@@ -520,13 +544,13 @@ config SORT
|
||||
sort is used to sort lines of text in specified files.
|
||||
|
||||
config FEATURE_SORT_BIG
|
||||
bool "full SuSv3 compliant sort (Support -ktcsbdfiozgM)"
|
||||
bool "Full SuSv3 compliant sort (support -ktcsbdfiozgM)"
|
||||
default y
|
||||
depends on SORT
|
||||
help
|
||||
Without this, sort only supports -r, -u, and an integer version
|
||||
of -n. Selecting this adds sort keys, floating point support, and
|
||||
more. This adds a little over 3k to a nonstatic build on x86.
|
||||
Without this, sort only supports -r, -u, and an integer version
|
||||
of -n. Selecting this adds sort keys, floating point support, and
|
||||
more. This adds a little over 3k to a nonstatic build on x86.
|
||||
|
||||
The SuSv3 sort standard is available at:
|
||||
http://www.opengroup.org/onlinepubs/007904975/utilities/sort.html
|
||||
@@ -538,7 +562,7 @@ config SPLIT
|
||||
split a file into pieces.
|
||||
|
||||
config FEATURE_SPLIT_FANCY
|
||||
bool "fancy extensions"
|
||||
bool "Fancy extensions"
|
||||
default n
|
||||
depends on SPLIT
|
||||
help
|
||||
@@ -558,7 +582,7 @@ config FEATURE_STAT_FORMAT
|
||||
depends on STAT
|
||||
help
|
||||
Without this, stat will not support the '-c format' option where
|
||||
users can pass a custom format string for output. This adds about
|
||||
users can pass a custom format string for output. This adds about
|
||||
7k to a nonstatic build on amd64.
|
||||
|
||||
config STTY
|
||||
@@ -579,6 +603,12 @@ config SYNC
|
||||
help
|
||||
sync is used to flush filesystem buffers.
|
||||
|
||||
config TAC
|
||||
bool "tac"
|
||||
default n
|
||||
help
|
||||
tac is used to concatenate and print files in reverse.
|
||||
|
||||
config TAIL
|
||||
bool "tail"
|
||||
default n
|
||||
@@ -602,7 +632,7 @@ config TEE
|
||||
to standard output and files.
|
||||
|
||||
config FEATURE_TEE_USE_BLOCK_IO
|
||||
bool "Enable block i/o (larger/faster) instead of byte i/o."
|
||||
bool "Enable block I/O (larger/faster) instead of byte I/O"
|
||||
default n
|
||||
depends on TEE
|
||||
help
|
||||
@@ -613,7 +643,7 @@ config TEST
|
||||
default n
|
||||
help
|
||||
test is used to check file types and compare values,
|
||||
returning an appropriate exit code. The bash shell
|
||||
returning an appropriate exit code. The bash shell
|
||||
has test built in, ash can build it in optionally.
|
||||
|
||||
config FEATURE_TEST_64
|
||||
@@ -724,7 +754,7 @@ config FEATURE_WC_LARGE
|
||||
default n
|
||||
depends on WC
|
||||
help
|
||||
Use "unsigned long long" in wc for count variables
|
||||
Use "unsigned long long" in wc for count variables.
|
||||
|
||||
config WHO
|
||||
bool "who"
|
||||
|
||||
+8
-2
@@ -12,6 +12,7 @@ lib-$(CONFIG_CAL) += cal.o
|
||||
lib-$(CONFIG_CAT) += cat.o
|
||||
lib-$(CONFIG_MORE) += cat.o # more uses it if stdout isn't a tty
|
||||
lib-$(CONFIG_LESS) += cat.o # less too
|
||||
lib-$(CONFIG_CRONTAB) += cat.o # crontab -l
|
||||
lib-$(CONFIG_CATV) += catv.o
|
||||
lib-$(CONFIG_CHGRP) += chgrp.o chown.o
|
||||
lib-$(CONFIG_CHMOD) += chmod.o
|
||||
@@ -29,6 +30,7 @@ lib-$(CONFIG_DOS2UNIX) += dos2unix.o
|
||||
lib-$(CONFIG_DU) += du.o
|
||||
lib-$(CONFIG_ECHO) += echo.o
|
||||
lib-$(CONFIG_ASH) += echo.o # used by ash
|
||||
lib-$(CONFIG_HUSH) += echo.o # used by hush
|
||||
lib-$(CONFIG_ENV) += env.o
|
||||
lib-$(CONFIG_EXPR) += expr.o
|
||||
lib-$(CONFIG_EXPAND) += expand.o
|
||||
@@ -52,6 +54,7 @@ lib-$(CONFIG_NOHUP) += nohup.o
|
||||
lib-$(CONFIG_OD) += od.o
|
||||
lib-$(CONFIG_PRINTENV) += printenv.o
|
||||
lib-$(CONFIG_PRINTF) += printf.o
|
||||
lib-$(CONFIG_ASH_BUILTIN_PRINTF) += printf.o
|
||||
lib-$(CONFIG_PWD) += pwd.o
|
||||
lib-$(CONFIG_READLINK) += readlink.o
|
||||
lib-$(CONFIG_REALPATH) += realpath.o
|
||||
@@ -66,10 +69,13 @@ lib-$(CONFIG_STAT) += stat.o
|
||||
lib-$(CONFIG_STTY) += stty.o
|
||||
lib-$(CONFIG_SUM) += sum.o
|
||||
lib-$(CONFIG_SYNC) += sync.o
|
||||
lib-$(CONFIG_TAC) += tac.o
|
||||
lib-$(CONFIG_TAIL) += tail.o
|
||||
lib-$(CONFIG_TEE) += tee.o
|
||||
lib-$(CONFIG_TEST) += test.o
|
||||
lib-$(CONFIG_ASH) += test.o # used by ash
|
||||
lib-$(CONFIG_TEST) += test.o test_ptr_hack.o
|
||||
lib-$(CONFIG_ASH) += test.o test_ptr_hack.o # used by ash
|
||||
lib-$(CONFIG_HUSH) += test.o test_ptr_hack.o # used by hush
|
||||
lib-$(CONFIG_MSH) += test.o test_ptr_hack.o # used by msh
|
||||
lib-$(CONFIG_TOUCH) += touch.o
|
||||
lib-$(CONFIG_TR) += tr.o
|
||||
lib-$(CONFIG_TRUE) += true.o
|
||||
|
||||
@@ -37,15 +37,16 @@ int basename_main(int argc, char **argv)
|
||||
/* It should strip slash: /abc/def/ -> def */
|
||||
s = bb_get_last_path_component_strip(*++argv);
|
||||
|
||||
m = strlen(s);
|
||||
if (*++argv) {
|
||||
n = strlen(*argv);
|
||||
m = strlen(s);
|
||||
if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) {
|
||||
s[m-n] = '\0';
|
||||
m -= n;
|
||||
/*s[m] = '\0'; - redundant */
|
||||
}
|
||||
}
|
||||
|
||||
puts(s);
|
||||
|
||||
return fflush(stdout);
|
||||
/* puts(s) will do, but we can do without stdio this way: */
|
||||
s[m++] = '\n';
|
||||
return full_write(STDOUT_FILENO, s, m) != (ssize_t)m;
|
||||
}
|
||||
+6
-4
@@ -40,7 +40,8 @@ static const unsigned char sep1752[] ALIGN1 = {
|
||||
24, 25, 26, 27, 28, 29, 30
|
||||
};
|
||||
|
||||
static unsigned julian;
|
||||
/* Set to 0 or 1 in main */
|
||||
#define julian ((unsigned)option_mask32)
|
||||
|
||||
/* leap year -- account for Gregorian reformation in 1752 */
|
||||
static int leap_year(unsigned yr)
|
||||
@@ -87,7 +88,8 @@ int cal_main(int argc, char **argv)
|
||||
char buf[40];
|
||||
|
||||
flags = getopt32(argv, "jy");
|
||||
julian = flags & 1;
|
||||
/* This sets julian = flags & 1: */
|
||||
option_mask32 &= 1;
|
||||
month = 0;
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
@@ -100,7 +102,7 @@ int cal_main(int argc, char **argv)
|
||||
time(&now);
|
||||
local_time = localtime(&now);
|
||||
year = local_time->tm_year + 1900;
|
||||
if (!(flags & 2)) {
|
||||
if (!(flags & 2)) { /* no -y */
|
||||
month = local_time->tm_mon + 1;
|
||||
}
|
||||
} else {
|
||||
@@ -179,7 +181,7 @@ int cal_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
fflush_stdout_and_exit(0);
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+4
-8
@@ -17,20 +17,16 @@
|
||||
|
||||
int bb_cat(char **argv)
|
||||
{
|
||||
static const char *const argv_dash[] = { "-", NULL };
|
||||
|
||||
int fd;
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
if (!*argv)
|
||||
argv = (char**) &argv_dash;
|
||||
argv = (char**) &bb_argv_dash;
|
||||
|
||||
do {
|
||||
fd = STDIN_FILENO;
|
||||
if (!LONE_DASH(*argv))
|
||||
fd = open_or_warn(*argv, O_RDONLY);
|
||||
fd = open_or_warn_stdin(*argv);
|
||||
if (fd >= 0) {
|
||||
/* This is not an xfunc - never exits */
|
||||
/* This is not a xfunc - never exits */
|
||||
off_t r = bb_copyfd_eof(fd, STDOUT_FILENO);
|
||||
if (fd != STDIN_FILENO)
|
||||
close(fd);
|
||||
@@ -44,7 +40,7 @@ int bb_cat(char **argv)
|
||||
}
|
||||
|
||||
int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int cat_main(int argc, char **argv)
|
||||
int cat_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "u");
|
||||
argv += optind;
|
||||
|
||||
+4
-8
@@ -13,7 +13,7 @@
|
||||
#include "libbb.h"
|
||||
|
||||
int catv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int catv_main(int argc, char **argv)
|
||||
int catv_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
int fd;
|
||||
@@ -27,18 +27,14 @@ int catv_main(int argc, char **argv)
|
||||
argv += optind;
|
||||
|
||||
/* Read from stdin if there's nothing else to do. */
|
||||
fd = 0;
|
||||
if (!argv[0]) {
|
||||
argv--;
|
||||
goto jump_in;
|
||||
}
|
||||
if (!argv[0])
|
||||
*--argv = (char*)"-";
|
||||
do {
|
||||
fd = open_or_warn(*argv, O_RDONLY);
|
||||
fd = open_or_warn_stdin(*argv);
|
||||
if (fd < 0) {
|
||||
retval = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
jump_in:
|
||||
for (;;) {
|
||||
int i, res;
|
||||
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@
|
||||
* symbolic links encountered during recursive directory traversals.
|
||||
*/
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* param, int depth)
|
||||
static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf, void* param, int depth)
|
||||
{
|
||||
mode_t newmode;
|
||||
|
||||
@@ -68,7 +68,7 @@ static int fileAction(const char *fileName, struct stat *statbuf, void* param, i
|
||||
}
|
||||
|
||||
int chmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int chmod_main(int argc, char **argv)
|
||||
int chmod_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
char *arg, **argp;
|
||||
|
||||
+32
-23
@@ -18,11 +18,11 @@
|
||||
|
||||
#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))
|
||||
#define OPT_RECURSE (opt & 1)
|
||||
#define OPT_NODEREF (opt & 2)
|
||||
#define OPT_VERBOSE (USE_DESKTOP(opt & 0x04) SKIP_DESKTOP(0))
|
||||
#define OPT_CHANGED (USE_DESKTOP(opt & 0x08) SKIP_DESKTOP(0))
|
||||
#define OPT_QUIET (USE_DESKTOP(opt & 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
|
||||
@@ -32,22 +32,27 @@
|
||||
* 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))
|
||||
#define OPT_TRAVERSE (USE_DESKTOP(opt & 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))
|
||||
#define OPT_TRAVERSE_TOP (USE_DESKTOP(opt & BIT_TRAVERSE_TOP) SKIP_DESKTOP(0))
|
||||
|
||||
typedef int (*chown_fptr)(const char *, uid_t, gid_t);
|
||||
|
||||
static struct bb_uidgid_t ugid = { -1, -1 };
|
||||
struct param_t {
|
||||
struct bb_uidgid_t ugid;
|
||||
chown_fptr chown_func;
|
||||
};
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf,
|
||||
void *cf, int depth)
|
||||
static int FAST_FUNC fileAction(const char *fileName, struct stat *statbuf,
|
||||
void *vparam, int depth UNUSED_PARAM)
|
||||
{
|
||||
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;
|
||||
#define param (*(struct param_t*)vparam)
|
||||
#define opt option_mask32
|
||||
uid_t u = (param.ugid.uid == (uid_t)-1) ? statbuf->st_uid : param.ugid.uid;
|
||||
gid_t g = (param.ugid.gid == (gid_t)-1) ? statbuf->st_gid : param.ugid.gid;
|
||||
|
||||
if (!((chown_fptr)cf)(fileName, u, g)) {
|
||||
if (param.chown_func(fileName, u, g) == 0) {
|
||||
if (OPT_VERBOSE
|
||||
|| (OPT_CHANGED && (statbuf->st_uid != u || statbuf->st_gid != g))
|
||||
) {
|
||||
@@ -59,26 +64,30 @@ static int fileAction(const char *fileName, struct stat *statbuf,
|
||||
if (!OPT_QUIET)
|
||||
bb_simple_perror_msg(fileName); /* A filename can have % in it... */
|
||||
return FALSE;
|
||||
#undef opt
|
||||
#undef param
|
||||
}
|
||||
|
||||
int chown_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int chown_main(int argc, char **argv)
|
||||
int chown_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
int flags;
|
||||
chown_fptr chown_func;
|
||||
int opt, flags;
|
||||
struct param_t param;
|
||||
|
||||
param.ugid.uid = -1;
|
||||
param.ugid.gid = -1;
|
||||
param.chown_func = chown;
|
||||
|
||||
opt_complementary = "-2";
|
||||
getopt32(argv, OPT_STR);
|
||||
opt = getopt32(argv, OPT_STR);
|
||||
argv += optind;
|
||||
|
||||
/* 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)
|
||||
USE_DESKTOP( || (opt & (BIT_RECURSE|BIT_TRAVERSE_TOP)) == BIT_RECURSE)
|
||||
) {
|
||||
chown_func = lchown;
|
||||
param.chown_func = lchown;
|
||||
}
|
||||
|
||||
flags = ACTION_DEPTHFIRST; /* match coreutils order */
|
||||
@@ -89,7 +98,7 @@ int chown_main(int argc, char **argv)
|
||||
if (OPT_TRAVERSE)
|
||||
flags |= ACTION_FOLLOWLINKS; /* follow links if -L */
|
||||
|
||||
parse_chown_usergroup_or_die(&ugid, argv[0]);
|
||||
parse_chown_usergroup_or_die(¶m.ugid, argv[0]);
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
argv++;
|
||||
@@ -98,7 +107,7 @@ int chown_main(int argc, char **argv)
|
||||
flags, /* flags */
|
||||
fileAction, /* file action */
|
||||
fileAction, /* dir action */
|
||||
chown_func, /* user data */
|
||||
¶m, /* user data */
|
||||
0) /* depth */
|
||||
) {
|
||||
retval = EXIT_FAILURE;
|
||||
|
||||
+1
-3
@@ -19,9 +19,7 @@ int chroot_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
++argv;
|
||||
if (chroot(*argv)) {
|
||||
bb_perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
xchroot(*argv);
|
||||
xchdir("/");
|
||||
|
||||
++argv;
|
||||
|
||||
+21
-19
@@ -9,46 +9,48 @@
|
||||
#include "libbb.h"
|
||||
|
||||
int cksum_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int cksum_main(int argc, char **argv)
|
||||
int cksum_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
uint32_t *crc32_table = crc32_filltable(NULL, 1);
|
||||
|
||||
FILE *fp;
|
||||
uint32_t crc;
|
||||
long length, filesize;
|
||||
int bytes_read;
|
||||
char *cp;
|
||||
uint8_t *cp;
|
||||
|
||||
int inp_stdin = (argc == optind) ? 1 : 0;
|
||||
#if ENABLE_DESKTOP
|
||||
getopt32(argv, ""); /* coreutils 6.9 compat */
|
||||
argv += optind;
|
||||
#else
|
||||
argv++;
|
||||
#endif
|
||||
|
||||
do {
|
||||
fp = fopen_or_warn_stdin((inp_stdin) ? bb_msg_standard_input : *++argv);
|
||||
int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input);
|
||||
|
||||
if (fd < 0)
|
||||
continue;
|
||||
crc = 0;
|
||||
length = 0;
|
||||
|
||||
#define read_buf bb_common_bufsiz1
|
||||
while ((bytes_read = fread(read_buf, 1, BUFSIZ, fp)) > 0) {
|
||||
cp = read_buf;
|
||||
while ((bytes_read = safe_read(fd, read_buf, sizeof(read_buf))) > 0) {
|
||||
cp = (uint8_t *) read_buf;
|
||||
length += bytes_read;
|
||||
while (bytes_read--)
|
||||
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ (*cp++)) & 0xffL];
|
||||
do {
|
||||
crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *cp++];
|
||||
} while (--bytes_read);
|
||||
}
|
||||
close(fd);
|
||||
|
||||
filesize = length;
|
||||
|
||||
for (; length; length >>= 8)
|
||||
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xffL];
|
||||
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xff];
|
||||
crc ^= 0xffffffffL;
|
||||
|
||||
if (inp_stdin) {
|
||||
printf("%" PRIu32 " %li\n", crc, filesize);
|
||||
break;
|
||||
}
|
||||
|
||||
printf("%" PRIu32 " %li %s\n", crc, filesize, *argv);
|
||||
fclose(fp);
|
||||
} while (*(argv + 1));
|
||||
printf((*argv ? "%" PRIu32 " %li %s\n" : "%" PRIu32 " %li\n"),
|
||||
crc, filesize, *argv);
|
||||
} while (*argv && *++argv);
|
||||
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
+42
-55
@@ -14,8 +14,9 @@
|
||||
#define COMM_OPT_3 (1 << 2)
|
||||
|
||||
/* writeline outputs the input given, appropriately aligned according to class */
|
||||
static void writeline(char *line, int class, int flags)
|
||||
static void writeline(char *line, int class)
|
||||
{
|
||||
int flags = option_mask32;
|
||||
if (class == 0) {
|
||||
if (flags & COMM_OPT_1)
|
||||
return;
|
||||
@@ -32,81 +33,67 @@ static void writeline(char *line, int class, int flags)
|
||||
if (!(flags & COMM_OPT_2))
|
||||
putchar('\t');
|
||||
}
|
||||
fputs(line, stdout);
|
||||
puts(line);
|
||||
}
|
||||
|
||||
int comm_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int comm_main(int argc, char **argv)
|
||||
int comm_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
#define LINE_LEN 100
|
||||
#define BB_EOF_0 0x1
|
||||
#define BB_EOF_1 0x2
|
||||
char thisline[2][LINE_LEN];
|
||||
FILE *streams[2];
|
||||
char *thisline[2];
|
||||
FILE *stream[2];
|
||||
int i;
|
||||
unsigned flags;
|
||||
int order;
|
||||
|
||||
opt_complementary = "=2";
|
||||
flags = getopt32(argv, "123");
|
||||
getopt32(argv, "123");
|
||||
argv += optind;
|
||||
|
||||
for (i = 0; i < 2; ++i) {
|
||||
streams[i] = (argv[i][0] == '-' && !argv[i][1]) ? stdin : xfopen(argv[i], "r");
|
||||
fgets(thisline[i], LINE_LEN, streams[i]);
|
||||
stream[i] = xfopen_stdin(argv[i]);
|
||||
}
|
||||
|
||||
/* This is the real core of the program - lines are compared here */
|
||||
|
||||
while (*thisline[0] || *thisline[1]) {
|
||||
int order = 0;
|
||||
|
||||
i = 0;
|
||||
if (feof(streams[0])) i |= BB_EOF_0;
|
||||
if (feof(streams[1])) i |= BB_EOF_1;
|
||||
|
||||
if (!*thisline[0])
|
||||
order = 1;
|
||||
else if (!*thisline[1])
|
||||
order = -1;
|
||||
else {
|
||||
int tl0_len, tl1_len;
|
||||
tl0_len = strlen(thisline[0]);
|
||||
tl1_len = strlen(thisline[1]);
|
||||
order = memcmp(thisline[0], thisline[1], tl0_len < tl1_len ? tl0_len : tl1_len);
|
||||
if (!order)
|
||||
order = tl0_len < tl1_len ? -1 : tl0_len != tl1_len;
|
||||
order = 0;
|
||||
thisline[1] = thisline[0] = NULL;
|
||||
while (1) {
|
||||
if (order <= 0) {
|
||||
free(thisline[0]);
|
||||
thisline[0] = xmalloc_fgetline(stream[0]);
|
||||
}
|
||||
if (order >= 0) {
|
||||
free(thisline[1]);
|
||||
thisline[1] = xmalloc_fgetline(stream[1]);
|
||||
}
|
||||
|
||||
if (order == 0 && !i)
|
||||
writeline(thisline[1], 2, flags);
|
||||
else if (order > 0 && !(i & BB_EOF_1))
|
||||
writeline(thisline[1], 1, flags);
|
||||
else if (order < 0 && !(i & BB_EOF_0))
|
||||
writeline(thisline[0], 0, flags);
|
||||
|
||||
if (i & BB_EOF_0 & BB_EOF_1) {
|
||||
i = !thisline[0] + (!thisline[1] << 1);
|
||||
if (i)
|
||||
break;
|
||||
order = strcmp(thisline[0], thisline[1]);
|
||||
|
||||
} else if (i) {
|
||||
i = (i & BB_EOF_0 ? 1 : 0);
|
||||
while (!feof(streams[i])) {
|
||||
if ((order < 0 && i) || (order > 0 && !i))
|
||||
writeline(thisline[i], i, flags);
|
||||
fgets(thisline[i], LINE_LEN, streams[i]);
|
||||
}
|
||||
break;
|
||||
if (order >= 0)
|
||||
writeline(thisline[1], order ? 1 : 2);
|
||||
else
|
||||
writeline(thisline[0], 0);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (order >= 0)
|
||||
fgets(thisline[1], LINE_LEN, streams[1]);
|
||||
if (order <= 0)
|
||||
fgets(thisline[0], LINE_LEN, streams[0]);
|
||||
/* EOF at least on one of the streams */
|
||||
i &= 1;
|
||||
if (thisline[i]) {
|
||||
/* stream[i] is not at EOF yet */
|
||||
/* we did not print thisline[i] yet */
|
||||
char *p = thisline[i];
|
||||
writeline(p, i);
|
||||
while (1) {
|
||||
free(p);
|
||||
p = xmalloc_fgetline(stream[i]);
|
||||
if (!p)
|
||||
break;
|
||||
writeline(p, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
fclose(streams[0]);
|
||||
fclose(streams[1]);
|
||||
fclose(stream[0]);
|
||||
fclose(stream[1]);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
+13
-11
@@ -37,25 +37,27 @@ int cp_main(int argc, char **argv)
|
||||
OPT_r = 1 << (sizeof(FILEUTILS_CP_OPTSTR)),
|
||||
OPT_P = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+1),
|
||||
OPT_H = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+2),
|
||||
OPT_L = 1 << (sizeof(FILEUTILS_CP_OPTSTR)+3),
|
||||
};
|
||||
|
||||
// Need at least two arguments
|
||||
// Soft- and hardlinking don't mix
|
||||
// Soft- and hardlinking doesn't mix
|
||||
// -P and -d are the same (-P is POSIX, -d is GNU)
|
||||
// -r and -R are the same
|
||||
// -R (and therefore -r) switches on -d (coreutils does this)
|
||||
// -R (and therefore -r) turns on -d (coreutils does this)
|
||||
// -a = -pdR
|
||||
opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR";
|
||||
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPHL");
|
||||
opt_complementary = "-2:l--s:s--l:Pd:rRd:Rd:apdR:HL";
|
||||
flags = getopt32(argv, FILEUTILS_CP_OPTSTR "arPH");
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
flags ^= FILEUTILS_DEREFERENCE; /* The sense of this flag was reversed. */
|
||||
/* Default behavior of cp is to dereference, so we don't have to do
|
||||
* anything special when we are given -L.
|
||||
* The behavior of -H is *almost* like -L, but not quite, so let's
|
||||
* just ignore it too for fun.
|
||||
if (flags & OPT_L) ...
|
||||
flags ^= FILEUTILS_DEREFERENCE; /* the sense of this flag was reversed */
|
||||
/* coreutils 6.9 compat:
|
||||
* by default, "cp" derefs symlinks (creates regular dest files),
|
||||
* but "cp -R" does not. We switch off deref if -r or -R (see above).
|
||||
* However, "cp -RL" must still deref symlinks: */
|
||||
if (flags & FILEUTILS_DEREF_SOFTLINK) /* -L */
|
||||
flags |= FILEUTILS_DEREFERENCE;
|
||||
/* The behavior of -H is *almost* like -L, but not quite, so let's
|
||||
* just ignore it too for fun. TODO.
|
||||
if (flags & OPT_H) ... // deref command-line params only
|
||||
*/
|
||||
|
||||
|
||||
+44
-43
@@ -33,11 +33,6 @@ enum {
|
||||
NON_RANGE = -1
|
||||
};
|
||||
|
||||
/* growable array holding a series of lists */
|
||||
static struct cut_list *cut_lists;
|
||||
static unsigned int nlists; /* number of elements in above list */
|
||||
|
||||
|
||||
static int cmpfunc(const void *a, const void *b)
|
||||
{
|
||||
return (((struct cut_list *) a)->startpos -
|
||||
@@ -45,18 +40,19 @@ static int cmpfunc(const void *a, const void *b)
|
||||
|
||||
}
|
||||
|
||||
static void cut_file(FILE *file, char delim)
|
||||
static void cut_file(FILE *file, char delim, const struct cut_list *cut_lists, unsigned nlists)
|
||||
{
|
||||
char *line = NULL;
|
||||
unsigned int linenum = 0; /* keep these zero-based to be consistent */
|
||||
char *line;
|
||||
unsigned linenum = 0; /* keep these zero-based to be consistent */
|
||||
|
||||
/* go through every line in the file */
|
||||
while ((line = xmalloc_getline(file)) != NULL) {
|
||||
while ((line = xmalloc_fgetline(file)) != NULL) {
|
||||
|
||||
/* set up a list so we can keep track of what's been printed */
|
||||
char * printed = xzalloc(strlen(line) * sizeof(char));
|
||||
char * orig_line = line;
|
||||
unsigned int cl_pos = 0;
|
||||
int linelen = strlen(line);
|
||||
char *printed = xzalloc(linelen + 1);
|
||||
char *orig_line = line;
|
||||
unsigned cl_pos = 0;
|
||||
int spos;
|
||||
|
||||
/* cut based on chars/bytes XXX: only works when sizeof(char) == byte */
|
||||
@@ -64,15 +60,19 @@ static void cut_file(FILE *file, char delim)
|
||||
/* print the chars specified in each cut list */
|
||||
for (; cl_pos < nlists; cl_pos++) {
|
||||
spos = cut_lists[cl_pos].startpos;
|
||||
while (spos < strlen(line)) {
|
||||
while (spos < linelen) {
|
||||
if (!printed[spos]) {
|
||||
printed[spos] = 'X';
|
||||
putchar(line[spos]);
|
||||
}
|
||||
spos++;
|
||||
if (spos > cut_lists[cl_pos].endpos
|
||||
|| cut_lists[cl_pos].endpos == NON_RANGE)
|
||||
/* NON_RANGE is -1, so if below is true,
|
||||
* the above was true too (spos is >= 0) */
|
||||
/* || cut_lists[cl_pos].endpos == NON_RANGE */
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (delim == '\n') { /* cut by lines */
|
||||
@@ -80,16 +80,17 @@ static void cut_file(FILE *file, char delim)
|
||||
|
||||
/* get out if we have no more lists to process or if the lines
|
||||
* are lower than what we're interested in */
|
||||
if (linenum < spos || cl_pos >= nlists)
|
||||
if (((int)linenum < spos) || (cl_pos >= nlists))
|
||||
goto next_line;
|
||||
|
||||
/* if the line we're looking for is lower than the one we were
|
||||
* passed, it means we displayed it already, so move on */
|
||||
while (spos < linenum) {
|
||||
while (spos < (int)linenum) {
|
||||
spos++;
|
||||
/* go to the next list if we're at the end of this one */
|
||||
if (spos > cut_lists[cl_pos].endpos
|
||||
|| cut_lists[cl_pos].endpos == NON_RANGE) {
|
||||
|| cut_lists[cl_pos].endpos == NON_RANGE
|
||||
) {
|
||||
cl_pos++;
|
||||
/* get out if there's no more lists to process */
|
||||
if (cl_pos >= nlists)
|
||||
@@ -97,7 +98,7 @@ static void cut_file(FILE *file, char delim)
|
||||
spos = cut_lists[cl_pos].startpos;
|
||||
/* get out if the current line is lower than the one
|
||||
* we just became interested in */
|
||||
if (linenum < spos)
|
||||
if ((int)linenum < spos)
|
||||
goto next_line;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +149,7 @@ static void cut_file(FILE *file, char delim)
|
||||
* this is a list, and we're not at the end of that
|
||||
* list */
|
||||
} while (spos <= cut_lists[cl_pos].endpos && line
|
||||
&& cut_lists[cl_pos].endpos != NON_RANGE);
|
||||
&& cut_lists[cl_pos].endpos != NON_RANGE);
|
||||
}
|
||||
}
|
||||
/* if we printed anything at all, we need to finish it with a
|
||||
@@ -162,19 +163,23 @@ static void cut_file(FILE *file, char delim)
|
||||
}
|
||||
|
||||
int cut_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int cut_main(int argc, char **argv)
|
||||
int cut_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
/* growable array holding a series of lists */
|
||||
struct cut_list *cut_lists = NULL;
|
||||
unsigned nlists = 0; /* number of elements in above list */
|
||||
char delim = '\t'; /* delimiter, default is tab */
|
||||
char *sopt, *ltok;
|
||||
unsigned opt;
|
||||
|
||||
opt_complementary = "b--bcf:c--bcf:f--bcf";
|
||||
getopt32(argv, optstring, &sopt, &sopt, &sopt, <ok);
|
||||
opt = getopt32(argv, optstring, &sopt, &sopt, &sopt, <ok);
|
||||
// argc -= optind;
|
||||
argv += optind;
|
||||
if (!(option_mask32 & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
|
||||
if (!(opt & (CUT_OPT_BYTE_FLGS | CUT_OPT_CHAR_FLGS | CUT_OPT_FIELDS_FLGS)))
|
||||
bb_error_msg_and_die("expected a list of bytes, characters, or fields");
|
||||
|
||||
if (option_mask32 & CUT_OPT_DELIM_FLGS) {
|
||||
if (opt & CUT_OPT_DELIM_FLGS) {
|
||||
if (ltok[0] && ltok[1]) { /* more than 1 char? */
|
||||
bb_error_msg_and_die("the delimiter must be a single character");
|
||||
}
|
||||
@@ -182,10 +187,10 @@ int cut_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* non-field (char or byte) cutting has some special handling */
|
||||
if (!(option_mask32 & CUT_OPT_FIELDS_FLGS)) {
|
||||
if (!(opt & CUT_OPT_FIELDS_FLGS)) {
|
||||
static const char _op_on_field[] ALIGN1 = " only when operating on fields";
|
||||
|
||||
if (option_mask32 & CUT_OPT_SUPPRESS_FLGS) {
|
||||
if (opt & CUT_OPT_SUPPRESS_FLGS) {
|
||||
bb_error_msg_and_die
|
||||
("suppressing non-delimited lines makes sense%s",
|
||||
_op_on_field);
|
||||
@@ -205,7 +210,7 @@ int cut_main(int argc, char **argv)
|
||||
char *ntok;
|
||||
int s = 0, e = 0;
|
||||
|
||||
/* take apart the lists, one by one (they are separated with commas */
|
||||
/* take apart the lists, one by one (they are separated with commas) */
|
||||
while ((ltok = strsep(&sopt, ",")) != NULL) {
|
||||
|
||||
/* it's actually legal to pass an empty list */
|
||||
@@ -231,8 +236,8 @@ int cut_main(int argc, char **argv)
|
||||
e = EOL;
|
||||
} else {
|
||||
e = xatoi_u(ltok);
|
||||
/* if the user specified and end position of 0, that means "til the
|
||||
* end of the line */
|
||||
/* if the user specified and end position of 0,
|
||||
* that means "til the end of the line" */
|
||||
if (e == 0)
|
||||
e = EOL;
|
||||
e--; /* again, arrays are zero based, lines are 1 based */
|
||||
@@ -241,9 +246,12 @@ int cut_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
/* add the new list */
|
||||
cut_lists = xrealloc(cut_lists, sizeof(struct cut_list) * (++nlists));
|
||||
cut_lists[nlists-1].startpos = s;
|
||||
cut_lists[nlists-1].endpos = e;
|
||||
cut_lists = xrealloc_vector(cut_lists, 4, nlists);
|
||||
/* NB: startpos is always >= 0,
|
||||
* while endpos may be = NON_RANGE (-1) */
|
||||
cut_lists[nlists].startpos = s;
|
||||
cut_lists[nlists].endpos = e;
|
||||
nlists++;
|
||||
}
|
||||
|
||||
/* make sure we got some cut positions out of all that */
|
||||
@@ -258,25 +266,18 @@ int cut_main(int argc, char **argv)
|
||||
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
FILE *file = stdin;
|
||||
|
||||
if (!*argv) {
|
||||
argv--;
|
||||
goto jump_in;
|
||||
}
|
||||
if (!*argv)
|
||||
*--argv = (char *)"-";
|
||||
|
||||
do {
|
||||
file = stdin;
|
||||
if (NOT_LONE_DASH(*argv))
|
||||
file = fopen_or_warn(*argv, "r");
|
||||
FILE *file = fopen_or_warn_stdin(*argv);
|
||||
if (!file) {
|
||||
retval = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
jump_in:
|
||||
cut_file(file, delim);
|
||||
if (NOT_LONE_DASH(*argv))
|
||||
fclose(file);
|
||||
cut_file(file, delim, cut_lists, nlists);
|
||||
fclose_if_not_stdin(file);
|
||||
} while (*++argv);
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
|
||||
+108
-106
@@ -39,131 +39,135 @@ static void maybe_set_utc(int opt)
|
||||
}
|
||||
|
||||
int date_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int date_main(int argc, char **argv)
|
||||
int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
time_t tm;
|
||||
struct tm tm_time;
|
||||
time_t tm;
|
||||
unsigned opt;
|
||||
int ifmt = -1;
|
||||
char *date_str = NULL;
|
||||
char *date_fmt = NULL;
|
||||
char *filename = NULL;
|
||||
char *isofmt_arg;
|
||||
char *hintfmt_arg;
|
||||
char *date_str;
|
||||
char *fmt_dt2str;
|
||||
char *fmt_str2dt;
|
||||
char *filename;
|
||||
char *isofmt_arg = NULL;
|
||||
|
||||
opt_complementary = "d--s:s--d"
|
||||
USE_FEATURE_DATE_ISOFMT(":R--I:I--R");
|
||||
opt = getopt32(argv, "Rs:ud:r:"
|
||||
USE_FEATURE_DATE_ISOFMT("I::D:"),
|
||||
&date_str, &date_str, &filename
|
||||
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &hintfmt_arg));
|
||||
USE_FEATURE_DATE_ISOFMT(, &isofmt_arg, &fmt_str2dt));
|
||||
argv += optind;
|
||||
maybe_set_utc(opt);
|
||||
|
||||
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_TIMESPEC)) {
|
||||
if (!isofmt_arg) {
|
||||
ifmt = 0; /* default is date */
|
||||
} else {
|
||||
static const char *const isoformats[] = {
|
||||
"date", "hours", "minutes", "seconds"
|
||||
};
|
||||
|
||||
for (ifmt = 0; ifmt < 4; ifmt++)
|
||||
if (!strcmp(isofmt_arg, isoformats[ifmt]))
|
||||
goto found;
|
||||
/* parse error */
|
||||
bb_show_usage();
|
||||
found: ;
|
||||
ifmt = 0; /* default is date */
|
||||
if (isofmt_arg) {
|
||||
static const char isoformats[] ALIGN1 =
|
||||
"date\0""hours\0""minutes\0""seconds\0";
|
||||
ifmt = index_in_strings(isoformats, isofmt_arg);
|
||||
if (ifmt < 0)
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX, date_fmt == NULL from this always */
|
||||
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+')) {
|
||||
date_fmt = &argv[optind][1]; /* Skip over the '+' */
|
||||
} else if (date_str == NULL) {
|
||||
opt |= DATE_OPT_SET;
|
||||
date_str = argv[optind];
|
||||
fmt_dt2str = NULL;
|
||||
if (argv[0] && argv[0][0] == '+') {
|
||||
fmt_dt2str = &argv[0][1]; /* Skip over the '+' */
|
||||
argv++;
|
||||
}
|
||||
if (!(opt & (DATE_OPT_SET | DATE_OPT_DATE))) {
|
||||
opt |= DATE_OPT_SET;
|
||||
date_str = argv[0]; /* can be NULL */
|
||||
if (date_str)
|
||||
argv++;
|
||||
}
|
||||
if (*argv)
|
||||
bb_show_usage();
|
||||
|
||||
/* Now we have parsed all the information except the date format
|
||||
which depends on whether the clock is being set or read */
|
||||
|
||||
if (filename) {
|
||||
if (opt & DATE_OPT_REFERENCE) {
|
||||
struct stat statbuf;
|
||||
xstat(filename, &statbuf);
|
||||
tm = statbuf.st_mtime;
|
||||
} else
|
||||
time(&tm);
|
||||
memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
|
||||
/* Zero out fields - take her back to midnight! */
|
||||
|
||||
/* If date string is given, update tm_time, and maybe set date */
|
||||
if (date_str != NULL) {
|
||||
/* Zero out fields - take her back to midnight! */
|
||||
tm_time.tm_sec = 0;
|
||||
tm_time.tm_min = 0;
|
||||
tm_time.tm_hour = 0;
|
||||
|
||||
/* Process any date input to UNIX time since 1 Jan 1970 */
|
||||
if (ENABLE_FEATURE_DATE_ISOFMT && (opt & DATE_OPT_HINT)) {
|
||||
strptime(date_str, hintfmt_arg, &tm_time);
|
||||
} else if (strchr(date_str, ':') != NULL) {
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
if (strptime(date_str, fmt_str2dt, &tm_time) == NULL)
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
} else {
|
||||
char end = '\0';
|
||||
const char *last_colon = strrchr(date_str, ':');
|
||||
|
||||
if (sscanf(date_str, "%d:%d:%d", &tm_time.tm_hour, &tm_time.tm_min,
|
||||
&tm_time.tm_sec) == 3) {
|
||||
/* no adjustments needed */
|
||||
} else if (sscanf(date_str, "%d:%d", &tm_time.tm_hour,
|
||||
&tm_time.tm_min) == 2) {
|
||||
/* no adjustments needed */
|
||||
} else if (sscanf(date_str, "%d.%d-%d:%d:%d", &tm_time.tm_mon,
|
||||
&tm_time.tm_mday, &tm_time.tm_hour,
|
||||
&tm_time.tm_min, &tm_time.tm_sec) == 5) {
|
||||
/* Adjust dates from 1-12 to 0-11 */
|
||||
tm_time.tm_mon -= 1;
|
||||
} else if (sscanf(date_str, "%d.%d-%d:%d", &tm_time.tm_mon,
|
||||
&tm_time.tm_mday,
|
||||
&tm_time.tm_hour, &tm_time.tm_min) == 4) {
|
||||
/* Adjust dates from 1-12 to 0-11 */
|
||||
tm_time.tm_mon -= 1;
|
||||
} else if (sscanf(date_str, "%d.%d.%d-%d:%d:%d", &tm_time.tm_year,
|
||||
if (last_colon != NULL) {
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
|
||||
if (sscanf(date_str, "%u:%u%c",
|
||||
&tm_time.tm_hour,
|
||||
&tm_time.tm_min,
|
||||
&end) >= 2) {
|
||||
/* no adjustments needed */
|
||||
} else if (sscanf(date_str, "%u.%u-%u:%u%c",
|
||||
&tm_time.tm_mon, &tm_time.tm_mday,
|
||||
&tm_time.tm_hour, &tm_time.tm_min,
|
||||
&tm_time.tm_sec) == 6) {
|
||||
tm_time.tm_year -= 1900; /* Adjust years */
|
||||
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
} else if (sscanf(date_str, "%d.%d.%d-%d:%d", &tm_time.tm_year,
|
||||
&end) >= 4) {
|
||||
/* Adjust dates from 1-12 to 0-11 */
|
||||
tm_time.tm_mon -= 1;
|
||||
} else if (sscanf(date_str, "%u.%u.%u-%u:%u%c", &tm_time.tm_year,
|
||||
&tm_time.tm_mon, &tm_time.tm_mday,
|
||||
&tm_time.tm_hour, &tm_time.tm_min) == 5) {
|
||||
tm_time.tm_year -= 1900; /* Adjust years */
|
||||
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
} else {
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
}
|
||||
} else {
|
||||
int nr;
|
||||
char *cp;
|
||||
|
||||
nr = sscanf(date_str, "%2d%2d%2d%2d%d", &tm_time.tm_mon,
|
||||
&tm_time.tm_mday, &tm_time.tm_hour, &tm_time.tm_min,
|
||||
&tm_time.tm_year);
|
||||
|
||||
if (nr < 4 || nr > 5) {
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
}
|
||||
|
||||
cp = strchr(date_str, '.');
|
||||
if (cp) {
|
||||
nr = sscanf(cp + 1, "%2d", &tm_time.tm_sec);
|
||||
if (nr != 1) {
|
||||
&tm_time.tm_hour, &tm_time.tm_min,
|
||||
&end) >= 5) {
|
||||
tm_time.tm_year -= 1900; /* Adjust years */
|
||||
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
} else if (sscanf(date_str, "%u-%u-%u %u:%u%c", &tm_time.tm_year,
|
||||
&tm_time.tm_mon, &tm_time.tm_mday,
|
||||
&tm_time.tm_hour, &tm_time.tm_min,
|
||||
&end) >= 5) {
|
||||
tm_time.tm_year -= 1900; /* Adjust years */
|
||||
tm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
//TODO: coreutils 6.9 also accepts "YYYY-MM-DD HH" (no minutes)
|
||||
} else {
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
}
|
||||
if (end == ':') {
|
||||
if (sscanf(last_colon + 1, "%u%c", &tm_time.tm_sec, &end) == 1)
|
||||
end = '\0';
|
||||
/* else end != NUL and we error out */
|
||||
}
|
||||
} else {
|
||||
if (sscanf(date_str, "%2u%2u%2u%2u%u%c", &tm_time.tm_mon,
|
||||
&tm_time.tm_mday, &tm_time.tm_hour, &tm_time.tm_min,
|
||||
&tm_time.tm_year, &end) < 4)
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
if (tm_time.tm_year >= 1900) {
|
||||
tm_time.tm_year -= 1900;
|
||||
}
|
||||
/* adjust date */
|
||||
tm_time.tm_mon -= 1;
|
||||
if (end == '.') {
|
||||
if (sscanf(strchr(date_str, '.') + 1, "%u%c",
|
||||
&tm_time.tm_sec, &end) == 1)
|
||||
end = '\0';
|
||||
/* else end != NUL and we error out */
|
||||
}
|
||||
}
|
||||
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
if (tm_time.tm_year >= 1900) {
|
||||
tm_time.tm_year -= 1900;
|
||||
if (end != '\0') {
|
||||
bb_error_msg_and_die(bb_msg_invalid_date, date_str);
|
||||
}
|
||||
/* adjust date */
|
||||
tm_time.tm_mon -= 1;
|
||||
}
|
||||
|
||||
/* Correct any day of week and day of year etc. fields */
|
||||
tm_time.tm_isdst = -1; /* Be sure to recheck dst. */
|
||||
tm = mktime(&tm_time);
|
||||
@@ -181,55 +185,53 @@ int date_main(int argc, char **argv)
|
||||
/* Display output */
|
||||
|
||||
/* Deal with format string */
|
||||
|
||||
if (date_fmt == NULL) {
|
||||
if (fmt_dt2str == NULL) {
|
||||
int i;
|
||||
date_fmt = xzalloc(32);
|
||||
fmt_dt2str = xzalloc(32);
|
||||
if (ENABLE_FEATURE_DATE_ISOFMT && ifmt >= 0) {
|
||||
strcpy(date_fmt, "%Y-%m-%d");
|
||||
strcpy(fmt_dt2str, "%Y-%m-%d");
|
||||
if (ifmt > 0) {
|
||||
i = 8;
|
||||
date_fmt[i++] = 'T';
|
||||
date_fmt[i++] = '%';
|
||||
date_fmt[i++] = 'H';
|
||||
fmt_dt2str[i++] = 'T';
|
||||
fmt_dt2str[i++] = '%';
|
||||
fmt_dt2str[i++] = 'H';
|
||||
if (ifmt > 1) {
|
||||
date_fmt[i++] = ':';
|
||||
date_fmt[i++] = '%';
|
||||
date_fmt[i++] = 'M';
|
||||
}
|
||||
if (ifmt > 2) {
|
||||
date_fmt[i++] = ':';
|
||||
date_fmt[i++] = '%';
|
||||
date_fmt[i++] = 'S';
|
||||
fmt_dt2str[i++] = ':';
|
||||
fmt_dt2str[i++] = '%';
|
||||
fmt_dt2str[i++] = 'M';
|
||||
if (ifmt > 2) {
|
||||
fmt_dt2str[i++] = ':';
|
||||
fmt_dt2str[i++] = '%';
|
||||
fmt_dt2str[i++] = 'S';
|
||||
}
|
||||
}
|
||||
format_utc:
|
||||
date_fmt[i++] = '%';
|
||||
date_fmt[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
|
||||
fmt_dt2str[i++] = '%';
|
||||
fmt_dt2str[i] = (opt & DATE_OPT_UTC) ? 'Z' : 'z';
|
||||
}
|
||||
} else if (opt & DATE_OPT_RFC2822) {
|
||||
/* Undo busybox.c for date -R */
|
||||
if (ENABLE_LOCALE_SUPPORT)
|
||||
setlocale(LC_TIME, "C");
|
||||
strcpy(date_fmt, "%a, %d %b %Y %H:%M:%S ");
|
||||
strcpy(fmt_dt2str, "%a, %d %b %Y %H:%M:%S ");
|
||||
i = 22;
|
||||
goto format_utc;
|
||||
} else /* default case */
|
||||
date_fmt = (char*)"%a %b %e %H:%M:%S %Z %Y";
|
||||
fmt_dt2str = (char*)"%a %b %e %H:%M:%S %Z %Y";
|
||||
}
|
||||
|
||||
#define date_buf bb_common_bufsiz1
|
||||
if (*date_fmt == '\0') {
|
||||
if (*fmt_dt2str == '\0') {
|
||||
/* With no format string, just print a blank line */
|
||||
date_buf[0] = '\0';
|
||||
} else {
|
||||
/* Handle special conversions */
|
||||
|
||||
if (strncmp(date_fmt, "%f", 2) == 0) {
|
||||
date_fmt = (char*)"%Y.%m.%d-%H:%M:%S";
|
||||
if (strncmp(fmt_dt2str, "%f", 2) == 0) {
|
||||
fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S";
|
||||
}
|
||||
|
||||
/* Generate output string */
|
||||
strftime(date_buf, sizeof(date_buf), date_fmt, &tm_time);
|
||||
strftime(date_buf, sizeof(date_buf), fmt_dt2str, &tm_time);
|
||||
}
|
||||
puts(date_buf);
|
||||
|
||||
|
||||
+102
-83
@@ -41,7 +41,7 @@ struct globals {
|
||||
#define INIT_G() memset(&G, 0, sizeof(G))
|
||||
|
||||
|
||||
static void dd_output_status(int ATTRIBUTE_UNUSED cur_signal)
|
||||
static void dd_output_status(int UNUSED_PARAM cur_signal)
|
||||
{
|
||||
/* Deliberately using %u, not %d */
|
||||
fprintf(stderr, "%"OFF_FMT"u+%"OFF_FMT"u records in\n"
|
||||
@@ -65,7 +65,7 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
|
||||
ssize_t n = full_write_or_warn(buf, len, filename);
|
||||
if (n < 0)
|
||||
return 1;
|
||||
if (n == obs)
|
||||
if ((size_t)n == obs)
|
||||
G.out_full++;
|
||||
else if (n) /* > 0 */
|
||||
G.out_part++;
|
||||
@@ -79,23 +79,31 @@ static bool write_and_stats(const void *buf, size_t len, size_t obs,
|
||||
#endif
|
||||
|
||||
int dd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int dd_main(int argc, char **argv)
|
||||
int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
enum {
|
||||
FLAG_SYNC = 1 << 0,
|
||||
FLAG_NOERROR = 1 << 1,
|
||||
FLAG_NOTRUNC = 1 << 2,
|
||||
FLAG_TWOBUFS = 1 << 3,
|
||||
FLAG_COUNT = 1 << 4,
|
||||
/* Must be in the same order as OP_conv_XXX! */
|
||||
/* (see "flags |= (1 << what)" below) */
|
||||
FLAG_NOTRUNC = 1 << 0,
|
||||
FLAG_SYNC = 1 << 1,
|
||||
FLAG_NOERROR = 1 << 2,
|
||||
FLAG_FSYNC = 1 << 3,
|
||||
/* end of conv flags */
|
||||
FLAG_TWOBUFS = 1 << 4,
|
||||
FLAG_COUNT = 1 << 5,
|
||||
};
|
||||
static const char keywords[] ALIGN1 =
|
||||
"bs=\0""count=\0""seek=\0""skip=\0""if=\0""of=\0"
|
||||
"bs\0""count\0""seek\0""skip\0""if\0""of\0"
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
"ibs=\0""obs=\0""conv=\0""notrunc\0""sync\0""noerror\0"
|
||||
"ibs\0""obs\0""conv\0"
|
||||
#endif
|
||||
;
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
static const char conv_words[] ALIGN1 =
|
||||
"notrunc\0""sync\0""noerror\0""fsync\0";
|
||||
#endif
|
||||
enum {
|
||||
OP_bs = 1,
|
||||
OP_bs = 0,
|
||||
OP_count,
|
||||
OP_seek,
|
||||
OP_skip,
|
||||
@@ -105,9 +113,23 @@ int dd_main(int argc, char **argv)
|
||||
OP_ibs,
|
||||
OP_obs,
|
||||
OP_conv,
|
||||
OP_conv_notrunc,
|
||||
/* Must be in the same order as FLAG_XXX! */
|
||||
OP_conv_notrunc = 0,
|
||||
OP_conv_sync,
|
||||
OP_conv_noerror,
|
||||
OP_conv_fsync,
|
||||
/* Unimplemented conv=XXX: */
|
||||
//nocreat do not create the output file
|
||||
//excl fail if the output file already exists
|
||||
//fdatasync physically write output file data before finishing
|
||||
//swab swap every pair of input bytes
|
||||
//lcase change upper case to lower case
|
||||
//ucase change lower case to upper case
|
||||
//block pad newline-terminated records with spaces to cbs-size
|
||||
//unblock replace trailing spaces in cbs-size records with newline
|
||||
//ascii from EBCDIC to ASCII
|
||||
//ebcdic from ASCII to EBCDIC
|
||||
//ibm from ASCII to alternate EBCDIC
|
||||
#endif
|
||||
};
|
||||
int exitcode = EXIT_FAILURE;
|
||||
@@ -121,9 +143,6 @@ int dd_main(int argc, char **argv)
|
||||
off_t count;
|
||||
off_t seek, skip;
|
||||
const char *infile, *outfile;
|
||||
#if ENABLE_FEATURE_DD_SIGNAL_HANDLING
|
||||
struct sigaction sigact;
|
||||
#endif
|
||||
} Z;
|
||||
#define flags (Z.flags )
|
||||
#define oc (Z.oc )
|
||||
@@ -132,98 +151,94 @@ int dd_main(int argc, char **argv)
|
||||
#define skip (Z.skip )
|
||||
#define infile (Z.infile )
|
||||
#define outfile (Z.outfile)
|
||||
#define sigact (Z.sigact )
|
||||
|
||||
memset(&Z, 0, sizeof(Z));
|
||||
INIT_G();
|
||||
//fflush(NULL); - is this needed because of NOEXEC?
|
||||
|
||||
#if ENABLE_FEATURE_DD_SIGNAL_HANDLING
|
||||
sigact.sa_handler = dd_output_status;
|
||||
sigact.sa_flags = SA_RESTART;
|
||||
sigemptyset(&sigact.sa_mask);
|
||||
sigaction(SIGUSR1, &sigact, NULL);
|
||||
signal_SA_RESTART_empty_mask(SIGUSR1, dd_output_status);
|
||||
#endif
|
||||
|
||||
for (n = 1; n < argc; n++) {
|
||||
smalluint key_len;
|
||||
smalluint what;
|
||||
char *key;
|
||||
for (n = 1; argv[n]; n++) {
|
||||
int what;
|
||||
char *val;
|
||||
char *arg = argv[n];
|
||||
|
||||
//XXX:FIXME: we reject plain "dd --" This would cost ~20 bytes, so..
|
||||
//if (*arg == '-' && *++arg == '-' && !*++arg) continue;
|
||||
key = strstr(arg, "=");
|
||||
if (key == NULL)
|
||||
#if ENABLE_DESKTOP
|
||||
/* "dd --". NB: coreutils 6.9 will complain if they see
|
||||
* more than one of them. We wouldn't. */
|
||||
if (arg[0] == '-' && arg[1] == '-' && arg[2] == '\0')
|
||||
continue;
|
||||
#endif
|
||||
val = strchr(arg, '=');
|
||||
if (val == NULL)
|
||||
bb_show_usage();
|
||||
key_len = key - arg + 1;
|
||||
key = xstrndup(arg, key_len);
|
||||
what = index_in_strings(keywords, key) + 1;
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(key);
|
||||
if (what == 0)
|
||||
*val = '\0';
|
||||
what = index_in_strings(keywords, arg);
|
||||
if (what < 0)
|
||||
bb_show_usage();
|
||||
arg += key_len;
|
||||
/* Must fit into positive ssize_t */
|
||||
/* *val = '='; - to preserve ps listing? */
|
||||
val++;
|
||||
#if ENABLE_FEATURE_DD_IBS_OBS
|
||||
if (what == OP_ibs) {
|
||||
ibs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
continue;
|
||||
}
|
||||
if (what == OP_obs) {
|
||||
obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
continue;
|
||||
}
|
||||
if (what == OP_conv) {
|
||||
while (1) {
|
||||
/* find ',', replace them with nil so we can use arg for
|
||||
* index_in_strings() without copying.
|
||||
* We rely on arg being non-null, else strchr would fault.
|
||||
*/
|
||||
key = strchr(arg, ',');
|
||||
if (key)
|
||||
*key = '\0';
|
||||
what = index_in_strings(keywords, arg) + 1;
|
||||
if (what < OP_conv_notrunc)
|
||||
bb_error_msg_and_die(bb_msg_invalid_arg, arg, "conv");
|
||||
if (what == OP_conv_notrunc)
|
||||
flags |= FLAG_NOTRUNC;
|
||||
if (what == OP_conv_sync)
|
||||
flags |= FLAG_SYNC;
|
||||
if (what == OP_conv_noerror)
|
||||
flags |= FLAG_NOERROR;
|
||||
if (!key) /* no ',' left, so this was the last specifier */
|
||||
break;
|
||||
arg = key + 1; /* skip this keyword and ',' */
|
||||
}
|
||||
continue;
|
||||
if (what == OP_ibs) {
|
||||
/* Must fit into positive ssize_t */
|
||||
ibs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_obs) {
|
||||
obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_conv) {
|
||||
while (1) {
|
||||
/* find ',', replace them with NUL so we can use val for
|
||||
* index_in_strings() without copying.
|
||||
* We rely on val being non-null, else strchr would fault.
|
||||
*/
|
||||
arg = strchr(val, ',');
|
||||
if (arg)
|
||||
*arg = '\0';
|
||||
what = index_in_strings(conv_words, val);
|
||||
if (what < 0)
|
||||
bb_error_msg_and_die(bb_msg_invalid_arg, val, "conv");
|
||||
flags |= (1 << what);
|
||||
if (!arg) /* no ',' left, so this was the last specifier */
|
||||
break;
|
||||
/* *arg = ','; - to preserve ps listing? */
|
||||
val = arg + 1; /* skip this keyword and ',' */
|
||||
}
|
||||
continue; /* we trashed 'what', can't fall through */
|
||||
}
|
||||
#endif
|
||||
if (what == OP_bs) {
|
||||
ibs = obs = xatoul_range_sfx(arg, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
continue;
|
||||
ibs = obs = xatoul_range_sfx(val, 1, ((size_t)-1L)/2, dd_suffixes);
|
||||
/*continue;*/
|
||||
}
|
||||
/* These can be large: */
|
||||
if (what == OP_count) {
|
||||
flags |= FLAG_COUNT;
|
||||
count = XATOU_SFX(arg, dd_suffixes);
|
||||
continue;
|
||||
count = XATOU_SFX(val, dd_suffixes);
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_seek) {
|
||||
seek = XATOU_SFX(arg, dd_suffixes);
|
||||
continue;
|
||||
seek = XATOU_SFX(val, dd_suffixes);
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_skip) {
|
||||
skip = XATOU_SFX(arg, dd_suffixes);
|
||||
continue;
|
||||
skip = XATOU_SFX(val, dd_suffixes);
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_if) {
|
||||
infile = arg;
|
||||
continue;
|
||||
infile = val;
|
||||
/*continue;*/
|
||||
}
|
||||
if (what == OP_of)
|
||||
outfile = arg;
|
||||
}
|
||||
if (what == OP_of) {
|
||||
outfile = val;
|
||||
/*continue;*/
|
||||
}
|
||||
} /* end of "for (argv[n])" */
|
||||
|
||||
//XXX:FIXME for huge ibs or obs, malloc'ing them isn't the brightest idea ever
|
||||
ibuf = obuf = xmalloc(ibs);
|
||||
if (ibs != obs) {
|
||||
@@ -297,7 +312,7 @@ int dd_main(int argc, char **argv)
|
||||
while (n) {
|
||||
size_t d = obs - oc;
|
||||
|
||||
if (d > n)
|
||||
if (d > (size_t)n)
|
||||
d = n;
|
||||
memcpy(obuf + oc, tmp, d);
|
||||
n -= d;
|
||||
@@ -311,13 +326,17 @@ int dd_main(int argc, char **argv)
|
||||
}
|
||||
} else if (write_and_stats(ibuf, n, obs, outfile))
|
||||
goto out_status;
|
||||
|
||||
if (flags & FLAG_FSYNC) {
|
||||
if (fsync(ofd) < 0)
|
||||
goto die_outfile;
|
||||
}
|
||||
}
|
||||
|
||||
if (ENABLE_FEATURE_DD_IBS_OBS && oc) {
|
||||
w = full_write_or_warn(obuf, oc, outfile);
|
||||
if (w < 0) goto out_status;
|
||||
if (w > 0)
|
||||
G.out_part++;
|
||||
if (w > 0) G.out_part++;
|
||||
}
|
||||
if (close(ifd) < 0) {
|
||||
die_infile:
|
||||
|
||||
+28
-41
@@ -20,62 +20,52 @@ enum {
|
||||
};
|
||||
|
||||
/* if fn is NULL then input is stdin and output is stdout */
|
||||
static int convert(char *fn, int conv_type)
|
||||
static void convert(char *fn, int conv_type)
|
||||
{
|
||||
FILE *in, *out;
|
||||
int i;
|
||||
#define name_buf bb_common_bufsiz1
|
||||
char *temp_fn = temp_fn; /* for compiler */
|
||||
char *resolved_fn = resolved_fn;
|
||||
|
||||
in = stdin;
|
||||
out = stdout;
|
||||
if (fn != NULL) {
|
||||
in = xfopen(fn, "rw");
|
||||
/*
|
||||
The file is then created with mode read/write and
|
||||
permissions 0666 for glibc 2.0.6 and earlier or
|
||||
0600 for glibc 2.0.7 and later.
|
||||
*/
|
||||
snprintf(name_buf, sizeof(name_buf), "%sXXXXXX", fn);
|
||||
i = mkstemp(&name_buf[0]);
|
||||
if (i == -1 || chmod(name_buf, 0600) == -1) {
|
||||
bb_perror_nomsg_and_die();
|
||||
}
|
||||
out = fdopen(i, "w+");
|
||||
if (!out) {
|
||||
close(i);
|
||||
remove(name_buf);
|
||||
return -2;
|
||||
struct stat st;
|
||||
|
||||
resolved_fn = xmalloc_follow_symlinks(fn);
|
||||
if (resolved_fn == NULL)
|
||||
bb_simple_perror_msg_and_die(fn);
|
||||
in = xfopen_for_read(resolved_fn);
|
||||
fstat(fileno(in), &st);
|
||||
|
||||
temp_fn = xasprintf("%sXXXXXX", resolved_fn);
|
||||
i = mkstemp(temp_fn);
|
||||
if (i == -1
|
||||
|| fchmod(i, st.st_mode) == -1
|
||||
|| !(out = fdopen(i, "w+"))
|
||||
) {
|
||||
bb_simple_perror_msg_and_die(temp_fn);
|
||||
}
|
||||
}
|
||||
|
||||
while ((i = fgetc(in)) != EOF) {
|
||||
if (i == '\r')
|
||||
continue;
|
||||
if (i == '\n') {
|
||||
if (i == '\n')
|
||||
if (conv_type == CT_UNIX2DOS)
|
||||
fputc('\r', out);
|
||||
fputc('\n', out);
|
||||
continue;
|
||||
}
|
||||
fputc(i, out);
|
||||
}
|
||||
|
||||
if (fn != NULL) {
|
||||
if (fclose(in) < 0 || fclose(out) < 0) {
|
||||
bb_perror_nomsg();
|
||||
remove(name_buf);
|
||||
return -2;
|
||||
}
|
||||
/* Assume they are both on the same filesystem (which
|
||||
* should be true since we put them into the same directory
|
||||
* so we _should_ be ok, but you never know... */
|
||||
if (rename(name_buf, fn) < 0) {
|
||||
bb_perror_msg("cannot rename '%s' as '%s'", name_buf, fn);
|
||||
return -1;
|
||||
unlink(temp_fn);
|
||||
bb_perror_nomsg_and_die();
|
||||
}
|
||||
xrename(temp_fn, resolved_fn);
|
||||
free(temp_fn);
|
||||
free(resolved_fn);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dos2unix_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
@@ -84,10 +74,9 @@ int dos2unix_main(int argc, char **argv)
|
||||
int o, conv_type;
|
||||
|
||||
/* See if we are supposed to be doing dos2unix or unix2dos */
|
||||
conv_type = CT_UNIX2DOS;
|
||||
if (applet_name[0] == 'd') {
|
||||
conv_type = CT_DOS2UNIX; /* 2 */
|
||||
} else {
|
||||
conv_type = CT_UNIX2DOS; /* 1 */
|
||||
conv_type = CT_DOS2UNIX;
|
||||
}
|
||||
|
||||
/* -u convert to unix, -d convert to dos */
|
||||
@@ -101,11 +90,9 @@ int dos2unix_main(int argc, char **argv)
|
||||
|
||||
do {
|
||||
/* might be convert(NULL) if there is no filename given */
|
||||
o = convert(argv[optind], conv_type);
|
||||
if (o < 0)
|
||||
break;
|
||||
convert(argv[optind], conv_type);
|
||||
optind++;
|
||||
} while (optind < argc);
|
||||
|
||||
return o;
|
||||
return 0;
|
||||
}
|
||||
+5
-10
@@ -141,12 +141,11 @@ static unsigned long du(const char *filename)
|
||||
}
|
||||
|
||||
int du_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int du_main(int argc, char **argv)
|
||||
int du_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
unsigned long total;
|
||||
int slink_depth_save;
|
||||
bool print_final_total;
|
||||
char *smax_print_depth;
|
||||
unsigned opt;
|
||||
|
||||
#if ENABLE_FEATURE_HUMAN_READABLE
|
||||
@@ -168,8 +167,8 @@ int du_main(int argc, char **argv)
|
||||
* ignore -a. This is consistent with -s being equivalent to -d 0.
|
||||
*/
|
||||
#if ENABLE_FEATURE_HUMAN_READABLE
|
||||
opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s";
|
||||
opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &smax_print_depth);
|
||||
opt_complementary = "h-km:k-hm:m-hk:H-L:L-H:s-d:d-s:d+";
|
||||
opt = getopt32(argv, "aHkLsx" "d:" "lc" "hm", &G.max_print_depth);
|
||||
argv += optind;
|
||||
if (opt & (1 << 9)) {
|
||||
/* -h opt */
|
||||
@@ -184,8 +183,8 @@ int du_main(int argc, char **argv)
|
||||
G.disp_hr = 1024;
|
||||
}
|
||||
#else
|
||||
opt_complementary = "H-L:L-H:s-d:d-s";
|
||||
opt = getopt32(argv, "aHkLsx" "d:" "lc", &smax_print_depth);
|
||||
opt_complementary = "H-L:L-H:s-d:d-s:d+";
|
||||
opt = getopt32(argv, "aHkLsx" "d:" "lc", &G.max_print_depth);
|
||||
argv += optind;
|
||||
#if !ENABLE_FEATURE_DU_DEFAULT_BLOCKSIZE_1K
|
||||
if (opt & (1 << 2)) {
|
||||
@@ -211,10 +210,6 @@ int du_main(int argc, char **argv)
|
||||
G.max_print_depth = 0;
|
||||
}
|
||||
G.one_file_system = opt & (1 << 5); /* -x opt */
|
||||
if (opt & (1 << 6)) {
|
||||
/* -d opt */
|
||||
G.max_print_depth = xatoi_u(smax_print_depth);
|
||||
}
|
||||
if (opt & (1 << 7)) {
|
||||
/* -l opt */
|
||||
G.count_hardlinks = MAXINT(nlink_t);
|
||||
|
||||
+17
-12
@@ -27,11 +27,9 @@
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
/* argc is unused, but removing it precludes compiler from
|
||||
* using call -> jump optimization */
|
||||
/* NB: can be used by shell even if not enabled as applet */
|
||||
|
||||
int echo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int echo_main(int argc, char **argv)
|
||||
int echo_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
const char *arg;
|
||||
#if !ENABLE_FEATURE_FANCY_ECHO
|
||||
@@ -48,8 +46,11 @@ int echo_main(int argc, char **argv)
|
||||
* even if libc receives EBADF on write attempts, it feels determined
|
||||
* to output data no matter what. So it will try later,
|
||||
* and possibly will clobber future output. Not good. */
|
||||
if (dup2(1, 1) != 1)
|
||||
return -1;
|
||||
// TODO: check fcntl() & O_ACCMODE == O_WRONLY or O_RDWR?
|
||||
if (fcntl(1, F_GETFL) == -1)
|
||||
return 1; /* match coreutils 6.10 (sans error msg to stderr) */
|
||||
//if (dup2(1, 1) != 1) - old way
|
||||
// return 1;
|
||||
|
||||
arg = *++argv;
|
||||
if (!arg)
|
||||
@@ -60,8 +61,8 @@ int echo_main(int argc, char **argv)
|
||||
char eflag = 0;
|
||||
|
||||
/* We must check that stdout is not closed. */
|
||||
if (dup2(1, 1) != 1)
|
||||
return -1;
|
||||
if (fcntl(1, F_GETFL) == -1)
|
||||
return 1;
|
||||
|
||||
while (1) {
|
||||
arg = *++argv;
|
||||
@@ -110,15 +111,19 @@ int echo_main(int argc, char **argv)
|
||||
}
|
||||
#if !ENABLE_FEATURE_FANCY_ECHO
|
||||
/* SUSv3 specifies that octal escapes must begin with '0'. */
|
||||
if ( (((unsigned char)*arg) - '1') >= 7)
|
||||
if ( ((int)(unsigned char)(*arg) - '0') >= 8) /* '8' or bigger */
|
||||
#endif
|
||||
{
|
||||
/* Since SUSv3 mandates a first digit of 0, 4-digit octals
|
||||
* of the form \0### are accepted. */
|
||||
if (*arg == '0' && ((unsigned char)(arg[1]) - '0') < 8) {
|
||||
arg++;
|
||||
if (*arg == '0') {
|
||||
/* NB: don't turn "...\0" into "...\" */
|
||||
if (arg[1] && ((unsigned char)(arg[1]) - '0') < 8) {
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
/* bb_process_escape_sequence can handle nul correctly */
|
||||
/* bb_process_escape_sequence handles NUL correctly
|
||||
* ("...\" case). */
|
||||
c = bb_process_escape_sequence(&arg);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-8
@@ -29,8 +29,7 @@
|
||||
* - use xfunc_error_retval
|
||||
*/
|
||||
|
||||
#include <getopt.h> /* struct option */
|
||||
extern char **environ;
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
@@ -42,7 +41,7 @@ static const char env_longopts[] ALIGN1 =
|
||||
#endif
|
||||
|
||||
int env_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int env_main(int argc, char **argv)
|
||||
int env_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
/* cleanenv was static - why? */
|
||||
char *cleanenv[1];
|
||||
@@ -65,8 +64,7 @@ int env_main(int argc, char **argv)
|
||||
environ = cleanenv;
|
||||
} else {
|
||||
while (unset_env) {
|
||||
unsetenv(unset_env->data);
|
||||
unset_env = unset_env->link;
|
||||
unsetenv(llist_pop(&unset_env));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +86,7 @@ int env_main(int argc, char **argv)
|
||||
puts(*ep);
|
||||
}
|
||||
|
||||
fflush_stdout_and_exit(0);
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -123,5 +121,3 @@ int env_main(int argc, char **argv)
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
+10
-19
@@ -41,7 +41,7 @@ static void expand(FILE *file, unsigned tab_size, unsigned opt)
|
||||
char *line;
|
||||
char *ptr;
|
||||
int convert;
|
||||
int pos;
|
||||
unsigned pos;
|
||||
|
||||
/* Increment tab_size by 1 locally.*/
|
||||
tab_size++;
|
||||
@@ -80,7 +80,7 @@ static void unexpand(FILE *file, unsigned int tab_size, unsigned opt)
|
||||
int convert;
|
||||
int pos;
|
||||
int i = 0;
|
||||
int column = 0;
|
||||
unsigned column = 0;
|
||||
|
||||
while ((line = xmalloc_fgets(file)) != NULL) {
|
||||
convert = 1;
|
||||
@@ -126,7 +126,7 @@ static void unexpand(FILE *file, unsigned int tab_size, unsigned opt)
|
||||
#endif
|
||||
|
||||
int expand_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int expand_main(int argc, char **argv)
|
||||
int expand_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
/* Default 8 spaces for 1 tab */
|
||||
const char *opt_t = "8";
|
||||
@@ -154,7 +154,7 @@ int expand_main(int argc, char **argv)
|
||||
if (ENABLE_EXPAND && (!ENABLE_UNEXPAND || applet_name[0] == 'e')) {
|
||||
USE_FEATURE_EXPAND_LONG_OPTIONS(applet_long_options = expand_longopts);
|
||||
opt = getopt32(argv, "it:", &opt_t);
|
||||
} else if (ENABLE_UNEXPAND) {
|
||||
} else {
|
||||
USE_FEATURE_UNEXPAND_LONG_OPTIONS(applet_long_options = unexpand_longopts);
|
||||
/* -t NUM sets also -a */
|
||||
opt_complementary = "ta";
|
||||
@@ -166,32 +166,23 @@ int expand_main(int argc, char **argv)
|
||||
|
||||
argv += optind;
|
||||
|
||||
/* If no args are given, read from stdin */
|
||||
if (!*argv) {
|
||||
*--argv = (char*)bb_msg_standard_input;
|
||||
goto use_stdin;
|
||||
}
|
||||
|
||||
do {
|
||||
if (NOT_LONE_CHAR(*argv, '-')) {
|
||||
file = fopen_or_warn(*argv, "r");
|
||||
if (!file) {
|
||||
exit_status = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
use_stdin:
|
||||
file = stdin;
|
||||
file = fopen_or_warn_stdin(*argv);
|
||||
if (!file) {
|
||||
exit_status = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ENABLE_EXPAND && (!ENABLE_UNEXPAND || applet_name[0] == 'e'))
|
||||
USE_EXPAND(expand(file, tab_size, opt));
|
||||
else if (ENABLE_UNEXPAND)
|
||||
else
|
||||
USE_UNEXPAND(unexpand(file, tab_size, opt));
|
||||
|
||||
/* Check and close the file */
|
||||
/* We do want all of them to execute, thus | instead of || */
|
||||
if (ferror(file) | fclose_if_not_stdin(file)) {
|
||||
if (fclose_if_not_stdin(file)) {
|
||||
bb_simple_perror_msg(*argv);
|
||||
exit_status = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
+84
-87
@@ -28,13 +28,6 @@
|
||||
#include "libbb.h"
|
||||
#include "xregex.h"
|
||||
|
||||
/* The kinds of value we can have. */
|
||||
enum valtype {
|
||||
integer,
|
||||
string
|
||||
};
|
||||
typedef enum valtype TYPE;
|
||||
|
||||
#if ENABLE_EXPR_MATH_SUPPORT_64
|
||||
typedef int64_t arith_t;
|
||||
|
||||
@@ -51,10 +44,16 @@ typedef long arith_t;
|
||||
|
||||
/* TODO: use bb_strtol[l]? It's easier to check for errors... */
|
||||
|
||||
/* The kinds of value we can have. */
|
||||
enum {
|
||||
INTEGER,
|
||||
STRING
|
||||
};
|
||||
|
||||
/* A value is.... */
|
||||
struct valinfo {
|
||||
TYPE type; /* Which kind. */
|
||||
union { /* The value itself. */
|
||||
smallint type; /* Which kind. */
|
||||
union { /* The value itself. */
|
||||
arith_t i;
|
||||
char *s;
|
||||
} u;
|
||||
@@ -77,8 +76,9 @@ static VALUE *int_value(arith_t i)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
v = xmalloc(sizeof(VALUE));
|
||||
v->type = integer;
|
||||
v = xzalloc(sizeof(VALUE));
|
||||
if (INTEGER) /* otherwise xzaaloc did it already */
|
||||
v->type = INTEGER;
|
||||
v->u.i = i;
|
||||
return v;
|
||||
}
|
||||
@@ -89,46 +89,47 @@ static VALUE *str_value(const char *s)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
v = xmalloc(sizeof(VALUE));
|
||||
v->type = string;
|
||||
v = xzalloc(sizeof(VALUE));
|
||||
if (STRING) /* otherwise xzaaloc did it already */
|
||||
v->type = STRING;
|
||||
v->u.s = xstrdup(s);
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Free VALUE V, including structure components. */
|
||||
|
||||
static void freev(VALUE * v)
|
||||
static void freev(VALUE *v)
|
||||
{
|
||||
if (v->type == string)
|
||||
if (v->type == STRING)
|
||||
free(v->u.s);
|
||||
free(v);
|
||||
}
|
||||
|
||||
/* Return nonzero if V is a null-string or zero-number. */
|
||||
|
||||
static int null(VALUE * v)
|
||||
static int null(VALUE *v)
|
||||
{
|
||||
if (v->type == integer)
|
||||
if (v->type == INTEGER)
|
||||
return v->u.i == 0;
|
||||
/* string: */
|
||||
/* STRING: */
|
||||
return v->u.s[0] == '\0' || LONE_CHAR(v->u.s, '0');
|
||||
}
|
||||
|
||||
/* Coerce V to a string value (can't fail). */
|
||||
/* Coerce V to a STRING value (can't fail). */
|
||||
|
||||
static void tostring(VALUE * v)
|
||||
static void tostring(VALUE *v)
|
||||
{
|
||||
if (v->type == integer) {
|
||||
if (v->type == INTEGER) {
|
||||
v->u.s = xasprintf("%" PF_REZ "d", PF_REZ_TYPE v->u.i);
|
||||
v->type = string;
|
||||
v->type = STRING;
|
||||
}
|
||||
}
|
||||
|
||||
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
|
||||
/* Coerce V to an INTEGER value. Return 1 on success, 0 on failure. */
|
||||
|
||||
static bool toarith(VALUE * v)
|
||||
static bool toarith(VALUE *v)
|
||||
{
|
||||
if (v->type == string) {
|
||||
if (v->type == STRING) {
|
||||
arith_t i;
|
||||
char *e;
|
||||
|
||||
@@ -139,50 +140,54 @@ static bool toarith(VALUE * v)
|
||||
return 0;
|
||||
free(v->u.s);
|
||||
v->u.i = i;
|
||||
v->type = integer;
|
||||
v->type = INTEGER;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Return nonzero if the next token matches STR exactly.
|
||||
/* Return str[0]+str[1] if the next token matches STR exactly.
|
||||
STR must not be NULL. */
|
||||
|
||||
static bool nextarg(const char *str)
|
||||
static int nextarg(const char *str)
|
||||
{
|
||||
if (*G.args == NULL)
|
||||
if (*G.args == NULL || strcmp(*G.args, str) != 0)
|
||||
return 0;
|
||||
return strcmp(*G.args, str) == 0;
|
||||
return (unsigned char)str[0] + (unsigned char)str[1];
|
||||
}
|
||||
|
||||
/* The comparison operator handling functions. */
|
||||
|
||||
static int cmp_common(VALUE * l, VALUE * r, int op)
|
||||
static int cmp_common(VALUE *l, VALUE *r, int op)
|
||||
{
|
||||
int cmpval;
|
||||
arith_t ll, rr;
|
||||
|
||||
if (l->type == string || r->type == string) {
|
||||
ll = l->u.i;
|
||||
rr = r->u.i;
|
||||
if (l->type == STRING || r->type == STRING) {
|
||||
tostring(l);
|
||||
tostring(r);
|
||||
cmpval = strcmp(l->u.s, r->u.s);
|
||||
} else
|
||||
cmpval = l->u.i - r->u.i;
|
||||
ll = strcmp(l->u.s, r->u.s);
|
||||
rr = 0;
|
||||
}
|
||||
/* calculating ll - rr and checking the result is prone to overflows.
|
||||
* We'll do it differently: */
|
||||
if (op == '<')
|
||||
return cmpval < 0;
|
||||
if (op == ('L' + 'E'))
|
||||
return cmpval <= 0;
|
||||
if (op == '=')
|
||||
return cmpval == 0;
|
||||
if (op == '!')
|
||||
return cmpval != 0;
|
||||
return ll < rr;
|
||||
if (op == ('<' + '='))
|
||||
return ll <= rr;
|
||||
if (op == '=' || (op == '=' + '='))
|
||||
return ll == rr;
|
||||
if (op == '!' + '=')
|
||||
return ll != rr;
|
||||
if (op == '>')
|
||||
return cmpval > 0;
|
||||
return ll > rr;
|
||||
/* >= */
|
||||
return cmpval >= 0;
|
||||
return ll >= rr;
|
||||
}
|
||||
|
||||
/* The arithmetic operator handling functions. */
|
||||
|
||||
static arith_t arithmetic_common(VALUE * l, VALUE * r, int op)
|
||||
static arith_t arithmetic_common(VALUE *l, VALUE *r, int op)
|
||||
{
|
||||
arith_t li, ri;
|
||||
|
||||
@@ -190,25 +195,24 @@ static arith_t arithmetic_common(VALUE * l, VALUE * r, int op)
|
||||
bb_error_msg_and_die("non-numeric argument");
|
||||
li = l->u.i;
|
||||
ri = r->u.i;
|
||||
if ((op == '/' || op == '%') && ri == 0)
|
||||
bb_error_msg_and_die("division by zero");
|
||||
if (op == '+')
|
||||
return li + ri;
|
||||
else if (op == '-')
|
||||
if (op == '-')
|
||||
return li - ri;
|
||||
else if (op == '*')
|
||||
if (op == '*')
|
||||
return li * ri;
|
||||
else if (op == '/')
|
||||
if (ri == 0)
|
||||
bb_error_msg_and_die("division by zero");
|
||||
if (op == '/')
|
||||
return li / ri;
|
||||
else
|
||||
return li % ri;
|
||||
return li % ri;
|
||||
}
|
||||
|
||||
/* Do the : operator.
|
||||
SV is the VALUE for the lhs (the string),
|
||||
PV is the VALUE for the rhs (the pattern). */
|
||||
|
||||
static VALUE *docolon(VALUE * sv, VALUE * pv)
|
||||
static VALUE *docolon(VALUE *sv, VALUE *pv)
|
||||
{
|
||||
VALUE *v;
|
||||
regex_t re_buffer;
|
||||
@@ -230,14 +234,16 @@ of a basic regular expression is not portable; it is being ignored", pv->u.s);
|
||||
|
||||
/* expr uses an anchored pattern match, so check that there was a
|
||||
* match and that the match starts at offset 0. */
|
||||
if (regexec(&re_buffer, sv->u.s, NMATCH, re_regs, 0) != REG_NOMATCH &&
|
||||
re_regs[0].rm_so == 0) {
|
||||
if (regexec(&re_buffer, sv->u.s, NMATCH, re_regs, 0) != REG_NOMATCH
|
||||
&& re_regs[0].rm_so == 0
|
||||
) {
|
||||
/* Were \(...\) used? */
|
||||
if (re_buffer.re_nsub > 0) {
|
||||
sv->u.s[re_regs[1].rm_eo] = '\0';
|
||||
v = str_value(sv->u.s + re_regs[1].rm_so);
|
||||
} else
|
||||
} else {
|
||||
v = int_value(re_regs[0].rm_eo);
|
||||
}
|
||||
} else {
|
||||
/* Match failed -- return the right kind of null. */
|
||||
if (re_buffer.re_nsub > 0)
|
||||
@@ -327,7 +333,7 @@ static VALUE *eval6(void)
|
||||
v = str_value("");
|
||||
else {
|
||||
v = xmalloc(sizeof(VALUE));
|
||||
v->type = string;
|
||||
v->type = STRING;
|
||||
v->u.s = xstrndup(l->u.s + i1->u.i - 1, i2->u.i);
|
||||
}
|
||||
freev(l);
|
||||
@@ -367,14 +373,11 @@ static VALUE *eval4(void)
|
||||
|
||||
l = eval5();
|
||||
while (1) {
|
||||
if (nextarg("*"))
|
||||
op = '*';
|
||||
else if (nextarg("/"))
|
||||
op = '/';
|
||||
else if (nextarg("%"))
|
||||
op = '%';
|
||||
else
|
||||
return l;
|
||||
op = nextarg("*");
|
||||
if (!op) { op = nextarg("/");
|
||||
if (!op) { op = nextarg("%");
|
||||
if (!op) return l;
|
||||
}}
|
||||
G.args++;
|
||||
r = eval5();
|
||||
val = arithmetic_common(l, r, op);
|
||||
@@ -394,12 +397,11 @@ static VALUE *eval3(void)
|
||||
|
||||
l = eval4();
|
||||
while (1) {
|
||||
if (nextarg("+"))
|
||||
op = '+';
|
||||
else if (nextarg("-"))
|
||||
op = '-';
|
||||
else
|
||||
return l;
|
||||
op = nextarg("+");
|
||||
if (!op) {
|
||||
op = nextarg("-");
|
||||
if (!op) return l;
|
||||
}
|
||||
G.args++;
|
||||
r = eval4();
|
||||
val = arithmetic_common(l, r, op);
|
||||
@@ -419,20 +421,15 @@ static VALUE *eval2(void)
|
||||
|
||||
l = eval3();
|
||||
while (1) {
|
||||
if (nextarg("<"))
|
||||
op = '<';
|
||||
else if (nextarg("<="))
|
||||
op = 'L' + 'E';
|
||||
else if (nextarg("=") || nextarg("=="))
|
||||
op = '=';
|
||||
else if (nextarg("!="))
|
||||
op = '!';
|
||||
else if (nextarg(">="))
|
||||
op = 'G' + 'E';
|
||||
else if (nextarg(">"))
|
||||
op = '>';
|
||||
else
|
||||
return l;
|
||||
op = nextarg("<");
|
||||
if (!op) { op = nextarg("<=");
|
||||
if (!op) { op = nextarg("=");
|
||||
if (!op) { op = nextarg("==");
|
||||
if (!op) { op = nextarg("!=");
|
||||
if (!op) { op = nextarg(">=");
|
||||
if (!op) { op = nextarg(">");
|
||||
if (!op) return l;
|
||||
}}}}}}
|
||||
G.args++;
|
||||
r = eval3();
|
||||
toarith(l);
|
||||
@@ -498,7 +495,7 @@ int expr_main(int argc, char **argv)
|
||||
if (*G.args)
|
||||
bb_error_msg_and_die("syntax error");
|
||||
|
||||
if (v->type == integer)
|
||||
if (v->type == INTEGER)
|
||||
printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i);
|
||||
else
|
||||
puts(v->u.s);
|
||||
|
||||
+2
-2
@@ -8,14 +8,14 @@
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/false.html */
|
||||
/* http://www.opengroup.org/onlinepubs/000095399/utilities/false.html */
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int false_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int false_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv)
|
||||
int false_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
+13
-16
@@ -12,18 +12,17 @@
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
static unsigned long flags;
|
||||
#define FLAG_COUNT_BYTES 1
|
||||
#define FLAG_BREAK_SPACES 2
|
||||
#define FLAG_WIDTH 4
|
||||
/* Must match getopt32 call */
|
||||
#define FLAG_COUNT_BYTES 1
|
||||
#define FLAG_BREAK_SPACES 2
|
||||
#define FLAG_WIDTH 4
|
||||
|
||||
/* Assuming the current column is COLUMN, return the column that
|
||||
printing C will move the cursor to.
|
||||
The first column is 0. */
|
||||
|
||||
static int adjust_column(int column, char c)
|
||||
{
|
||||
if (!(flags & FLAG_COUNT_BYTES)) {
|
||||
if (!(option_mask32 & FLAG_COUNT_BYTES)) {
|
||||
if (c == '\b') {
|
||||
if (column > 0)
|
||||
column--;
|
||||
@@ -54,29 +53,27 @@ int fold_main(int argc, char **argv)
|
||||
char const *a = argv[i];
|
||||
|
||||
if (*a++ == '-') {
|
||||
if (*a == '-' && !a[1])
|
||||
if (*a == '-' && !a[1]) /* "--" */
|
||||
break;
|
||||
if (isdigit(*a)) {
|
||||
if (isdigit(*a))
|
||||
argv[i] = xasprintf("-w%s", a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flags = getopt32(argv, "bsw:", &w_opt);
|
||||
if (flags & FLAG_WIDTH)
|
||||
getopt32(argv, "bsw:", &w_opt);
|
||||
if (option_mask32 & FLAG_WIDTH)
|
||||
width = xatoul_range(w_opt, 1, 10000);
|
||||
|
||||
argv += optind;
|
||||
if (!*argv) {
|
||||
if (!*argv)
|
||||
*--argv = (char*)"-";
|
||||
}
|
||||
|
||||
do {
|
||||
FILE *istream = fopen_or_warn_stdin(*argv);
|
||||
int c;
|
||||
int column = 0; /* Screen column where next char will go. */
|
||||
int offset_out = 0; /* Index in `line_out' for next char. */
|
||||
int offset_out = 0; /* Index in 'line_out' for next char. */
|
||||
|
||||
if (istream == NULL) {
|
||||
errs |= EXIT_FAILURE;
|
||||
@@ -102,7 +99,7 @@ int fold_main(int argc, char **argv)
|
||||
/* This character would make the line too long.
|
||||
Print the line plus a newline, and make this character
|
||||
start the next line. */
|
||||
if (flags & FLAG_BREAK_SPACES) {
|
||||
if (option_mask32 & FLAG_BREAK_SPACES) {
|
||||
/* Look for the last blank. */
|
||||
int logical_end;
|
||||
|
||||
@@ -144,7 +141,7 @@ int fold_main(int argc, char **argv)
|
||||
fwrite(line_out, sizeof(char), (size_t) offset_out, stdout);
|
||||
}
|
||||
|
||||
if (ferror(istream) || fclose_if_not_stdin(istream)) {
|
||||
if (fclose_if_not_stdin(istream)) {
|
||||
bb_simple_perror_msg(*argv); /* Avoid multibyte problems. */
|
||||
errs |= EXIT_FAILURE;
|
||||
}
|
||||
|
||||
+5
-5
@@ -91,19 +91,19 @@ int head_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
if (!*argv) {
|
||||
if (!*argv)
|
||||
*--argv = (char*)"-";
|
||||
}
|
||||
|
||||
fmt = header_fmt_str + 1;
|
||||
#if ENABLE_FEATURE_FANCY_HEAD
|
||||
if (argc - optind <= header_threshhold) {
|
||||
if (argc <= header_threshhold) {
|
||||
header_threshhold = 0;
|
||||
}
|
||||
#else
|
||||
if (argc <= optind + 1) {
|
||||
fmt += 11;
|
||||
if (argc <= 1) {
|
||||
fmt += 11; /* "" */
|
||||
}
|
||||
/* Now define some things here to avoid #ifdefs in the code below.
|
||||
* These should optimize out of the if conditions below. */
|
||||
|
||||
Loaded 100 of 837 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user