Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15c0b72584 | ||
|
|
ccdc13d306 | ||
|
|
ab310e1b1c | ||
|
|
1cd1012a90 | ||
|
|
095f5b1c1c | ||
|
|
62e0dc2b51 | ||
|
|
44f96d39e1 | ||
|
|
6d0443557c | ||
|
|
3fa36e2350 | ||
|
|
73cc54388d | ||
|
|
4febd91326 | ||
|
|
dc70069a46 | ||
|
|
2a8329e0e9 | ||
|
|
30e1ab691c | ||
|
|
2ec94a7ee8 | ||
|
|
b0150d299f | ||
|
|
4f7d90f1c7 | ||
|
|
694b514148 | ||
|
|
239d06bd47 | ||
|
|
b9d572a273 | ||
|
|
f10bc3964f | ||
|
|
f068b3e9f4 | ||
|
|
3854c5ddf4 | ||
|
|
70e8f49f71 | ||
|
|
fc66892abd | ||
|
|
35a064b67f | ||
|
|
202ac504e1 | ||
|
|
905ed8730f | ||
|
|
4cb576ea98 | ||
|
|
a643816fe3 | ||
|
|
6559100021 | ||
|
|
391ffa19d1 | ||
|
|
c51457ca5b | ||
|
|
3c385cd706 | ||
|
|
9b0f6e1142 | ||
|
|
1a9e9bdd93 | ||
|
|
5a89763fb7 | ||
|
|
44d5dcebc6 | ||
|
|
64974793b9 | ||
|
|
028eab61bc | ||
|
|
bb26db49b1 | ||
|
|
b9b344aa44 | ||
|
|
f34cfff2f0 | ||
|
|
91f8f82bfb | ||
|
|
6b38e18247 | ||
|
|
470dc1d7e2 | ||
|
|
e29186687b | ||
|
|
31d58e58d2 | ||
|
|
1fe7887659 | ||
|
|
b15a6f2489 | ||
|
|
cf696850f3 | ||
|
|
6a2c2cf6f3 | ||
|
|
e7368f16fa | ||
|
|
58f3c2e01e | ||
|
|
9657596dd6 | ||
|
|
40fdcbb270 | ||
|
|
9504e444b8 | ||
|
|
c3a9dc8ac5 | ||
|
|
34e68c8b42 | ||
|
|
d498850e02 | ||
|
|
6214941a3a | ||
|
|
be54d6bc60 | ||
|
|
7ff85c53f1 | ||
|
|
de5f645dff | ||
|
|
59f502b36f | ||
|
|
c503dde01a | ||
|
|
6b9d6c7544 | ||
|
|
043246560f | ||
|
|
e1ef89abad | ||
|
|
c94fa5651a | ||
|
|
f3dcd3c30a | ||
|
|
7462b21dbe | ||
|
|
7b32e8f0bf | ||
|
|
bdd2d8f178 | ||
|
|
5f6aaf39cf | ||
|
|
39b0135c59 | ||
|
|
0112ff5203 | ||
|
|
73d702ee07 | ||
|
|
ebad0294c9 | ||
|
|
53c80f0972 | ||
|
|
aa2a1c000c | ||
|
|
e8efe81abf | ||
|
|
2d5bd807c0 | ||
|
|
d908395eae | ||
|
|
8f39b72aba | ||
|
|
2dfd295726 | ||
|
|
01ea971610 | ||
|
|
5cb54b5adc | ||
|
|
37890e2f37 | ||
|
|
8fbd8ac8dd | ||
|
|
7effd7ae99 | ||
|
|
4c9e9c4314 | ||
|
|
078323010b | ||
|
|
b730474bda | ||
|
|
d1660cb9ad | ||
|
|
802a7be54f | ||
|
|
582dff0514 | ||
|
|
bff06fe02a | ||
|
|
4bdeaaf556 | ||
|
|
e3742f4217 | ||
|
|
3ab3d8a5cf | ||
|
|
f9dde919d6 | ||
|
|
1dfeeeb651 | ||
|
|
cf4dd07b28 | ||
|
|
d83676ec47 | ||
|
|
aa9eb1fc67 | ||
|
|
8ef801b40c | ||
|
|
7960ea8918 | ||
|
|
8854b352f4 | ||
|
|
a9c3f7a19e | ||
|
|
9299305756 | ||
|
|
e915a1a410 | ||
|
|
81944c9e92 | ||
|
|
cfdb711a18 | ||
|
|
58cc52aa76 | ||
|
|
d44c1535ae | ||
|
|
ddc8ae3003 | ||
|
|
371de4acf7 | ||
|
|
ded6ad34ed | ||
|
|
267e16c74a | ||
|
|
25497c1d92 | ||
|
|
5373fbcd11 | ||
|
|
5e38cd910a | ||
|
|
988dd5549b | ||
|
|
f886fd2bc7 | ||
|
|
d29084dd7d | ||
|
|
22d10a0292 | ||
|
|
1e19afd38a | ||
|
|
d5e305944a | ||
|
|
cdd1f732bc | ||
|
|
afd7a8d744 | ||
|
|
07e05c100f | ||
|
|
c373527e4f | ||
|
|
9af22c7626 | ||
|
|
578de8644c | ||
|
|
2239f81941 | ||
|
|
834dee785d | ||
|
|
176d49d4f7 | ||
|
|
559691a3bf | ||
|
|
93d0776a96 | ||
|
|
c2d5a27b62 | ||
|
|
f60719cd49 | ||
|
|
df6b3ad6ba | ||
|
|
58680706d7 | ||
|
|
22eb410d66 | ||
|
|
27e1501cb2 | ||
|
|
651d49a2ce | ||
|
|
2b2d977057 | ||
|
|
6826441a02 | ||
|
|
bb04506dc8 | ||
|
|
d6855d1b50 | ||
|
|
bed22a01fb | ||
|
|
682ad3045c | ||
|
|
75897ea6d5 | ||
|
|
739e30fbc3 | ||
|
|
7d9399e8dc | ||
|
|
c321b51dc6 | ||
|
|
1a89133caf | ||
|
|
48a6773b3a | ||
|
|
fd3552dff9 | ||
|
|
bfc93a3caf | ||
|
|
ee5dce3365 | ||
|
|
f1980f67d3 | ||
|
|
cdb0b652dd | ||
|
|
b46d5f9a93 | ||
|
|
97516fc3a6 | ||
|
|
6c4dadefb6 | ||
|
|
a46d2b1d2d | ||
|
|
c8842213f5 | ||
|
|
42cc6bab16 | ||
|
|
35840ab204 | ||
|
|
864329d674 | ||
|
|
17e7f04c8d | ||
|
|
e0bcba18eb | ||
|
|
ea7c9b3366 | ||
|
|
cac0f5b7e5 | ||
|
|
f6cad924b1 | ||
|
|
923a79a769 | ||
|
|
30cfdf90ce | ||
|
|
006e8628fc | ||
|
|
eef6077d7e | ||
|
|
b8d1a4cd5f | ||
|
|
b61dc1c1ce | ||
|
|
3728bc5a3d | ||
|
|
248b4a77e7 | ||
|
|
9ac706b7a6 | ||
|
|
c110b7d61f | ||
|
|
72fa70af4c | ||
|
|
2228426512 | ||
|
|
28f5619e84 | ||
|
|
53f219ebbe | ||
|
|
a1e16c9298 | ||
|
|
e357d2ae68 | ||
|
|
7c9c1bb616 | ||
|
|
0d602e9386 | ||
|
|
2bc5c033dc | ||
|
|
ba1315d0fb | ||
|
|
4f3209b9d4 | ||
|
|
0ee1cb0084 | ||
|
|
70de57f60a | ||
|
|
08ea11ab07 | ||
|
|
9725daa03a | ||
|
|
8d89bed840 | ||
|
|
ee9deb863e | ||
|
|
ee34ebe966 | ||
|
|
9f9c1935fa | ||
|
|
1c781cc8ff | ||
|
|
4acb1b0793 | ||
|
|
665eaff3b1 | ||
|
|
fd6b5ad137 | ||
|
|
0901c51518 | ||
|
|
161931efa5 | ||
|
|
d4b719878f | ||
|
|
a2e1eea189 | ||
|
|
b424930e4e | ||
|
|
2bdc99f600 | ||
|
|
d93179fd5b | ||
|
|
d129d7c3cd | ||
|
|
04e458d435 | ||
|
|
1045d00462 | ||
|
|
66496d75a7 | ||
|
|
7cbcd1cbf4 | ||
|
|
996a61475a | ||
|
|
d66aa3c701 | ||
|
|
3b80cac953 | ||
|
|
1ebdaccd6d | ||
|
|
18c93029fd | ||
|
|
8f0e342803 | ||
|
|
f3d1e213fe | ||
|
|
b522d6931d | ||
|
|
279ca69727 | ||
|
|
c4e4b6b936 | ||
|
|
b66d16a2e6 | ||
|
|
5770715588 | ||
|
|
15f2fdb2b9 | ||
|
|
7fe21c69cd | ||
|
|
6cd36bc2da | ||
|
|
9ff245f6a0 | ||
|
|
7d0d3e265b | ||
|
|
657341762a | ||
|
|
a28a05b96a | ||
|
|
99ecc46d93 | ||
|
|
6375853cd8 | ||
|
|
e82da4dfee | ||
|
|
c397792ab3 | ||
|
|
bc8bc59e69 | ||
|
|
3b0161d045 | ||
|
|
f2d4a65be8 | ||
|
|
eae3846e87 | ||
|
|
e0fe65b68f | ||
|
|
8eeaa747c8 | ||
|
|
6887e77c32 | ||
|
|
20a55b7bff | ||
|
|
f0d0811c05 | ||
|
|
b5d701d737 | ||
|
|
beea4b8021 | ||
|
|
0fa539457b | ||
|
|
b91168a74c | ||
|
|
f9dba6e226 | ||
|
|
557f9c4b31 | ||
|
|
5f52150536 | ||
|
|
beb6ea47c3 | ||
|
|
78c41b2dc5 | ||
|
|
14a79381d0 | ||
|
|
68cef20f5d | ||
|
|
b22fbfefc8 | ||
|
|
a0420aba1c | ||
|
|
158f1d4ea6 | ||
|
|
8c8601cfbc | ||
|
|
040feada1e | ||
|
|
c1b39edee1 | ||
|
|
2a7031bb12 | ||
|
|
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 |
No files matched your search
@@ -166,7 +166,7 @@ Paul Fox <pgf@foxharp.boston.ma.us>
|
||||
Roberto A. Foglietta <me@roberto.foglietta.name>
|
||||
port: dnsd
|
||||
|
||||
Bernhard Fischer <rep.nop@aon.at>
|
||||
Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
|
||||
misc
|
||||
|
||||
Mike Frysinger <vapier@gentoo.org>
|
||||
|
||||
@@ -21,6 +21,15 @@ 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
|
||||
@@ -40,7 +49,7 @@ choice
|
||||
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
|
||||
@@ -72,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
|
||||
@@ -86,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.
|
||||
|
||||
@@ -118,7 +127,7 @@ 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.
|
||||
|
||||
@@ -127,7 +136,7 @@ config FEATURE_CLEAN_UP
|
||||
default n
|
||||
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.
|
||||
|
||||
@@ -146,15 +155,17 @@ config FEATURE_SUID
|
||||
default n
|
||||
help
|
||||
With this option you can install the busybox binary belonging
|
||||
to root with the suid bit set, and it'll and it'll automatically drop
|
||||
to root with the suid bit set, and it will automatically drop
|
||||
priviledges for applets that don't need root access.
|
||||
|
||||
If you're really paranoid and don't want to do this, build two
|
||||
If you are 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
|
||||
are login, passwd, su, ping, traceroute, crontab, dnsd, ipcrm, ipcs,
|
||||
and vlock.
|
||||
one that needs it. The applets currently marked to need the suid bit
|
||||
are:
|
||||
|
||||
crontab, dnsd, findfs, ipcrm, ipcs, login, passwd, ping, su,
|
||||
traceroute, vlock.
|
||||
|
||||
config FEATURE_SUID_CONFIG
|
||||
bool "Runtime SUID/SGID configuration via /etc/busybox.conf"
|
||||
@@ -162,7 +173,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>)
|
||||
@@ -170,11 +181,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
|
||||
|
||||
@@ -193,14 +205,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
|
||||
@@ -235,26 +248,26 @@ 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
|
||||
|
||||
config FEATURE_SYSLOG
|
||||
bool "Support for logging to syslog"
|
||||
bool #No description makes it a hidden option
|
||||
default n
|
||||
help
|
||||
This option is auto-selected when you select any applet which may
|
||||
send its output to syslog. You do not need to select it manually.
|
||||
#help
|
||||
# This option is auto-selected when you select any applet which may
|
||||
# send its output to syslog. You do not need to select it manually.
|
||||
|
||||
config FEATURE_HAVE_RPC
|
||||
bool "RPC support"
|
||||
bool #No description makes it a hidden option
|
||||
default n
|
||||
help
|
||||
This is automatically selected if any of enabled applets need it.
|
||||
You do not need to select it manually.
|
||||
#help
|
||||
# This is automatically selected if any of enabled applets need it.
|
||||
# You do not need to select it manually.
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -298,13 +311,13 @@ config NOMMU
|
||||
config BUILD_LIBBUSYBOX
|
||||
bool "Build shared libbusybox"
|
||||
default n
|
||||
depends on !FEATURE_PREFER_APPLETS && !PIE
|
||||
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.
|
||||
|
||||
@@ -321,7 +334,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.
|
||||
###
|
||||
@@ -330,7 +343,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
|
||||
@@ -348,7 +361,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.
|
||||
|
||||
@@ -379,11 +392,11 @@ 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"
|
||||
@@ -391,9 +404,12 @@ config CROSS_COMPILER_PREFIX
|
||||
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.
|
||||
"i386-uclibc-".
|
||||
|
||||
Note that CROSS_COMPILE environment variable or
|
||||
"make CROSS_COMPILE=xxx ..." will override this selection.
|
||||
|
||||
Native builds leave this empty.
|
||||
|
||||
endmenu
|
||||
|
||||
@@ -404,20 +420,20 @@ 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."
|
||||
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
|
||||
stepping through it with a debugger. This switches it off, resulting
|
||||
in a much bigger executable that more closely matches the source
|
||||
code.
|
||||
|
||||
@@ -434,27 +450,28 @@ choice
|
||||
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.
|
||||
|
||||
@@ -476,9 +493,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'
|
||||
@@ -506,8 +526,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"
|
||||
@@ -543,7 +563,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
|
||||
|
||||
@@ -574,9 +595,10 @@ source modutils/Config.in
|
||||
source util-linux/Config.in
|
||||
source miscutils/Config.in
|
||||
source networking/Config.in
|
||||
source printutils/Config.in
|
||||
source mailutils/Config.in
|
||||
source procps/Config.in
|
||||
source shell/Config.in
|
||||
source sysklogd/Config.in
|
||||
source runit/Config.in
|
||||
source selinux/Config.in
|
||||
source printutils/Config.in
|
||||
source shell/Config.in
|
||||
source sysklogd/Config.in
|
||||
@@ -1,6 +1,6 @@
|
||||
VERSION = 1
|
||||
PATCHLEVEL = 11
|
||||
SUBLEVEL = 0
|
||||
PATCHLEVEL = 13
|
||||
SUBLEVEL = 2
|
||||
EXTRAVERSION =
|
||||
NAME = Unnamed
|
||||
|
||||
@@ -456,6 +456,7 @@ libs-y := \
|
||||
libbb/ \
|
||||
libpwdgrp/ \
|
||||
loginutils/ \
|
||||
mailutils/ \
|
||||
miscutils/ \
|
||||
modutils/ \
|
||||
networking/ \
|
||||
@@ -505,7 +506,7 @@ endif
|
||||
# command line.
|
||||
# This allow a user to issue only 'make' to build a kernel including modules
|
||||
# Defaults busybox but it is usually overridden in the arch makefile
|
||||
all: busybox
|
||||
all: busybox doc
|
||||
|
||||
-include $(srctree)/arch/$(ARCH)/Makefile
|
||||
|
||||
@@ -932,8 +933,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 busybox_unstripped* 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'
|
||||
@@ -944,7 +946,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
|
||||
#
|
||||
@@ -960,10 +963,16 @@ 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
|
||||
|
||||
PHONY += doc-clean
|
||||
doc-clean: rm-files := docs/busybox.pod \
|
||||
docs/BusyBox.html docs/BusyBox.1 docs/BusyBox.txt
|
||||
doc-clean:
|
||||
$(call cmd,rmfiles)
|
||||
|
||||
# mrproper - Delete all generated files, including .config
|
||||
#
|
||||
mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
|
||||
@@ -984,9 +993,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
|
||||
|
||||
@@ -1090,7 +1099,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
|
||||
|
||||
|
||||
@@ -105,6 +105,10 @@ bigdata: busybox_unstripped
|
||||
.PHONY: doc
|
||||
doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
|
||||
|
||||
# FIXME: Doesn't belong here
|
||||
disp_doc = \
|
||||
@$(if $(quiet),echo " DOC $(@F)")
|
||||
|
||||
docs/busybox.pod: $(srctree)/docs/busybox_header.pod \
|
||||
$(srctree)/include/usage.h \
|
||||
$(srctree)/docs/busybox_footer.pod \
|
||||
|
||||
+2
-1
@@ -44,12 +44,13 @@ 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,)
|
||||
|
||||
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
|
||||
|
||||
@@ -6,6 +6,7 @@ help:
|
||||
@echo 'Cleaning:'
|
||||
@echo ' clean - delete temporary files created by build'
|
||||
@echo ' distclean - delete all non-source files (including .config)'
|
||||
@echo ' doc-clean - delete all generated documentation'
|
||||
@echo
|
||||
@echo 'Build:'
|
||||
@echo ' all - Executable and documentation'
|
||||
|
||||
@@ -122,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
|
||||
|
||||
@@ -173,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:
|
||||
|
||||
@@ -197,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>
|
||||
@@ -99,7 +99,7 @@ Rob Landley suggested these:
|
||||
This one's open to everybody, but I'll wind up doing it...
|
||||
|
||||
|
||||
Bernhard Fischer <busybox@busybox.net> suggests to look at these:
|
||||
Bernhard Reutner-Fischer <busybox@busybox.net> suggests to look at these:
|
||||
New debug options:
|
||||
-Wlarger-than-127
|
||||
Cleanup any big users
|
||||
|
||||
+119
-89
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# Automatically generated make config: don't edit
|
||||
# Busybox version: 1.11.0.svn
|
||||
# Mon Apr 21 23:20:35 2008
|
||||
# Busybox version: 1.13.0.svn
|
||||
# Sun Nov 9 17:09:13 2008
|
||||
#
|
||||
CONFIG_HAVE_DOT_CONFIG=y
|
||||
|
||||
@@ -13,6 +13,8 @@ CONFIG_HAVE_DOT_CONFIG=y
|
||||
# General Configuration
|
||||
#
|
||||
CONFIG_DESKTOP=y
|
||||
CONFIG_EXTRA_COMPAT=y
|
||||
# CONFIG_FEATURE_ASSUME_UNICODE is not set
|
||||
CONFIG_FEATURE_BUFFERS_USE_MALLOC=y
|
||||
# CONFIG_FEATURE_BUFFERS_GO_ON_STACK is not set
|
||||
# CONFIG_FEATURE_BUFFERS_GO_IN_BSS is not set
|
||||
@@ -38,16 +40,19 @@ 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_DEBUG_PESSIMIZE is not set
|
||||
# CONFIG_WERROR is not set
|
||||
CONFIG_NO_DEBUG_LIB=y
|
||||
# CONFIG_DMALLOC is not set
|
||||
@@ -86,6 +91,7 @@ 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,6 +100,10 @@ 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
|
||||
@@ -104,17 +114,11 @@ CONFIG_DPKG=y
|
||||
CONFIG_DPKG_DEB=y
|
||||
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_GZIP=y
|
||||
CONFIG_FEATURE_TAR_BZIP2=y
|
||||
CONFIG_FEATURE_TAR_LZMA=y
|
||||
CONFIG_FEATURE_TAR_COMPRESS=y
|
||||
CONFIG_FEATURE_TAR_AUTODETECT=y
|
||||
CONFIG_FEATURE_TAR_FROM=y
|
||||
CONFIG_FEATURE_TAR_OLDGNU_COMPATIBILITY=y
|
||||
@@ -127,17 +131,6 @@ CONFIG_UNLZMA=y
|
||||
CONFIG_FEATURE_LZMA_FAST=y
|
||||
CONFIG_UNZIP=y
|
||||
|
||||
#
|
||||
# Common options for cpio and tar
|
||||
#
|
||||
|
||||
#
|
||||
# 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
|
||||
#
|
||||
@@ -159,7 +152,7 @@ CONFIG_DD=y
|
||||
CONFIG_FEATURE_DD_SIGNAL_HANDLING=y
|
||||
CONFIG_FEATURE_DD_IBS_OBS=y
|
||||
CONFIG_DF=y
|
||||
CONFIG_FEATURE_DF_INODE=y
|
||||
CONFIG_FEATURE_DF_FANCY=y
|
||||
CONFIG_DIRNAME=y
|
||||
CONFIG_DOS2UNIX=y
|
||||
CONFIG_UNIX2DOS=y
|
||||
@@ -216,6 +209,7 @@ 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
|
||||
@@ -287,8 +281,12 @@ CONFIG_RESIZE=y
|
||||
CONFIG_FEATURE_RESIZE_PRINT=y
|
||||
CONFIG_SETCONSOLE=y
|
||||
CONFIG_FEATURE_SETCONSOLE_LONG_OPTIONS=y
|
||||
CONFIG_SETFONT=y
|
||||
CONFIG_FEATURE_SETFONT_TEXTUAL_MAP=y
|
||||
CONFIG_DEFAULT_SETFONT_DIR=""
|
||||
CONFIG_SETKEYCODES=y
|
||||
CONFIG_SETLOGCONS=y
|
||||
CONFIG_SHOWKEY=y
|
||||
|
||||
#
|
||||
# Debian Utilities
|
||||
@@ -307,7 +305,7 @@ CONFIG_WHICH=y
|
||||
# Editors
|
||||
#
|
||||
CONFIG_AWK=y
|
||||
CONFIG_FEATURE_AWK_MATH=y
|
||||
CONFIG_FEATURE_AWK_LIBM=y
|
||||
CONFIG_CMP=y
|
||||
CONFIG_DIFF=y
|
||||
CONFIG_FEATURE_DIFF_BINARY=y
|
||||
@@ -370,7 +368,6 @@ CONFIG_FEATURE_XARGS_SUPPORT_ZERO_TERM=y
|
||||
# Init Utilities
|
||||
#
|
||||
CONFIG_INIT=y
|
||||
# CONFIG_DEBUG_INIT is not set
|
||||
CONFIG_FEATURE_USE_INITTAB=y
|
||||
CONFIG_FEATURE_KILL_REMOVED=y
|
||||
CONFIG_FEATURE_KILL_DELAY=1
|
||||
@@ -386,8 +383,9 @@ 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
|
||||
@@ -424,30 +422,36 @@ 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
|
||||
CONFIG_DEFAULT_MODULES_DIR="/lib/modules"
|
||||
CONFIG_DEFAULT_DEPMOD_FILE="modules.dep"
|
||||
CONFIG_MODPROBE_SMALL=y
|
||||
CONFIG_FEATURE_MODPROBE_SMALL_OPTIONS_ON_CMDLINE=y
|
||||
CONFIG_FEATURE_MODPROBE_SMALL_CHECK_ALREADY_LOADED=y
|
||||
# CONFIG_INSMOD is not set
|
||||
# CONFIG_RMMOD is not set
|
||||
# CONFIG_LSMOD is not set
|
||||
# CONFIG_FEATURE_LSMOD_PRETTY_2_6_OUTPUT is not set
|
||||
# CONFIG_MODPROBE is not set
|
||||
# CONFIG_FEATURE_MODPROBE_BLACKLIST is not set
|
||||
# CONFIG_DEPMOD is not set
|
||||
|
||||
#
|
||||
# Options common to multiple modutils
|
||||
#
|
||||
CONFIG_FEATURE_CHECK_TAINTED_MODULE=y
|
||||
CONFIG_FEATURE_2_4_MODULES=y
|
||||
CONFIG_FEATURE_2_6_MODULES=y
|
||||
# CONFIG_FEATURE_QUERY_MODULE_INTERFACE is not set
|
||||
# CONFIG_FEATURE_2_4_MODULES is not set
|
||||
# CONFIG_FEATURE_INSMOD_VERSION_CHECKING is not set
|
||||
# CONFIG_FEATURE_INSMOD_KSYMOOPS_SYMBOLS is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOADINKMEM is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP is not set
|
||||
# CONFIG_FEATURE_INSMOD_LOAD_MAP_FULL is not set
|
||||
# CONFIG_FEATURE_CHECK_TAINTED_MODULE is not set
|
||||
# CONFIG_FEATURE_MODUTILS_ALIAS is not set
|
||||
# CONFIG_FEATURE_MODUTILS_SYMBOLS is not set
|
||||
|
||||
#
|
||||
# Linux System Utilities
|
||||
#
|
||||
CONFIG_BLKID=y
|
||||
CONFIG_DMESG=y
|
||||
CONFIG_FEATURE_DMESG_PRETTY=y
|
||||
CONFIG_FBSET=y
|
||||
@@ -520,11 +524,13 @@ 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
|
||||
@@ -550,26 +556,33 @@ CONFIG_FEATURE_CHAT_VAR_ABORT_LEN=y
|
||||
CONFIG_FEATURE_CHAT_CLR_ABORT=y
|
||||
CONFIG_CHRT=y
|
||||
CONFIG_CROND=y
|
||||
CONFIG_DEBUG_CROND_OPTION=y
|
||||
CONFIG_FEATURE_CROND_D=y
|
||||
CONFIG_FEATURE_CROND_CALL_SENDMAIL=y
|
||||
CONFIG_CRONTAB=y
|
||||
CONFIG_DC=y
|
||||
CONFIG_FEATURE_DC_LIBM=y
|
||||
# CONFIG_DEVFSD is not set
|
||||
# CONFIG_DEVFSD_MODLOAD is not set
|
||||
# CONFIG_DEVFSD_FG_NP is not set
|
||||
# CONFIG_DEVFSD_VERBOSE is not set
|
||||
# CONFIG_FEATURE_DEVFS is not set
|
||||
CONFIG_DEVMEM=y
|
||||
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
|
||||
CONFIG_FEATURE_LESS_FLAGS=y
|
||||
CONFIG_FEATURE_LESS_FLAGCS=y
|
||||
CONFIG_FEATURE_LESS_DASHCMD=y
|
||||
CONFIG_FEATURE_LESS_MARKS=y
|
||||
CONFIG_FEATURE_LESS_REGEXP=y
|
||||
CONFIG_FEATURE_LESS_LINENUMS=y
|
||||
CONFIG_FEATURE_LESS_WINCH=y
|
||||
CONFIG_HDPARM=y
|
||||
CONFIG_FEATURE_HDPARM_GET_IDENTITY=y
|
||||
CONFIG_FEATURE_HDPARM_HDIO_SCAN_HWIF=y
|
||||
@@ -590,7 +603,6 @@ CONFIG_RUNLEVEL=y
|
||||
CONFIG_RX=y
|
||||
CONFIG_SETSID=y
|
||||
CONFIG_STRINGS=y
|
||||
CONFIG_SYMLINKS=y
|
||||
CONFIG_TASKSET=y
|
||||
CONFIG_FEATURE_TASKSET_FANCY=y
|
||||
CONFIG_TIME=y
|
||||
@@ -675,14 +687,13 @@ 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_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
|
||||
@@ -694,7 +705,7 @@ CONFIG_TFTPD=y
|
||||
CONFIG_FEATURE_TFTP_GET=y
|
||||
CONFIG_FEATURE_TFTP_PUT=y
|
||||
CONFIG_FEATURE_TFTP_BLOCKSIZE=y
|
||||
CONFIG_DEBUG_TFTP=y
|
||||
CONFIG_TFTP_DEBUG=y
|
||||
CONFIG_TRACEROUTE=y
|
||||
CONFIG_FEATURE_TRACEROUTE_VERBOSE=y
|
||||
CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE=y
|
||||
@@ -707,9 +718,9 @@ 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_UDHCP_DEBUG=y
|
||||
CONFIG_FEATURE_UDHCP_RFC3397=y
|
||||
CONFIG_UDHCPC_DEFAULT_SCRIPT="/usr/share/udhcpc/default.script"
|
||||
CONFIG_UDHCPC_SLACK_FOR_BUGGY_SERVERS=80
|
||||
CONFIG_VCONFIG=y
|
||||
CONFIG_WGET=y
|
||||
@@ -720,6 +731,26 @@ CONFIG_ZCIP=y
|
||||
CONFIG_TCPSVD=y
|
||||
CONFIG_UDPSVD=y
|
||||
|
||||
#
|
||||
# Print Utilities
|
||||
#
|
||||
CONFIG_LPD=y
|
||||
CONFIG_LPR=y
|
||||
CONFIG_LPQ=y
|
||||
|
||||
#
|
||||
# Mail Utilities
|
||||
#
|
||||
CONFIG_MAKEMIME=y
|
||||
CONFIG_FEATURE_MIME_CHARSET="us-ascii"
|
||||
CONFIG_POPMAILDIR=y
|
||||
CONFIG_FEATURE_POPMAILDIR_DELIVERY=y
|
||||
CONFIG_REFORMIME=y
|
||||
CONFIG_FEATURE_REFORMIME_COMPAT=y
|
||||
CONFIG_SENDMAIL=y
|
||||
CONFIG_FEATURE_SENDMAIL_MAILX=y
|
||||
CONFIG_FEATURE_SENDMAIL_MAILXX=y
|
||||
|
||||
#
|
||||
# Process Utilities
|
||||
#
|
||||
@@ -743,18 +774,54 @@ CONFIG_BB_SYSCTL=y
|
||||
CONFIG_TOP=y
|
||||
CONFIG_FEATURE_TOP_CPU_USAGE_PERCENTAGE=y
|
||||
CONFIG_FEATURE_TOP_CPU_GLOBAL_PERCENTS=y
|
||||
CONFIG_FEATURE_TOP_SMP_CPU=y
|
||||
CONFIG_FEATURE_TOP_DECIMALS=y
|
||||
CONFIG_FEATURE_TOP_SMP_PROCESS=y
|
||||
CONFIG_FEATURE_TOPMEM=y
|
||||
CONFIG_UPTIME=y
|
||||
CONFIG_WATCH=y
|
||||
|
||||
#
|
||||
# Runit Utilities
|
||||
#
|
||||
CONFIG_RUNSV=y
|
||||
CONFIG_RUNSVDIR=y
|
||||
CONFIG_FEATURE_RUNSVDIR_LOG=y
|
||||
CONFIG_SV=y
|
||||
CONFIG_SV_DEFAULT_SERVICE_DIR="/var/service"
|
||||
CONFIG_SVLOGD=y
|
||||
CONFIG_CHPST=y
|
||||
CONFIG_SETUIDGID=y
|
||||
CONFIG_ENVUIDGID=y
|
||||
CONFIG_ENVDIR=y
|
||||
CONFIG_SOFTLIMIT=y
|
||||
|
||||
#
|
||||
# SELinux Utilities
|
||||
#
|
||||
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
|
||||
|
||||
#
|
||||
# Shells
|
||||
#
|
||||
# CONFIG_FEATURE_SH_IS_ASH is not set
|
||||
# CONFIG_FEATURE_SH_IS_HUSH is not set
|
||||
CONFIG_FEATURE_SH_IS_HUSH=y
|
||||
# CONFIG_FEATURE_SH_IS_MSH is not set
|
||||
CONFIG_FEATURE_SH_IS_NONE=y
|
||||
# CONFIG_FEATURE_SH_IS_NONE is not set
|
||||
# CONFIG_ASH is not set
|
||||
# CONFIG_ASH_BASH_COMPAT is not set
|
||||
# CONFIG_ASH_JOB_CONTROL is not set
|
||||
@@ -765,6 +832,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
|
||||
@@ -778,6 +846,7 @@ 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
|
||||
|
||||
@@ -802,42 +871,3 @@ CONFIG_LOGREAD=y
|
||||
CONFIG_FEATURE_LOGREAD_REDUCED_LOCKING=y
|
||||
CONFIG_KLOGD=y
|
||||
CONFIG_LOGGER=y
|
||||
|
||||
#
|
||||
# Runit Utilities
|
||||
#
|
||||
CONFIG_RUNSV=y
|
||||
CONFIG_RUNSVDIR=y
|
||||
CONFIG_SV=y
|
||||
CONFIG_SVLOGD=y
|
||||
CONFIG_CHPST=y
|
||||
CONFIG_SETUIDGID=y
|
||||
CONFIG_ENVUIDGID=y
|
||||
CONFIG_ENVDIR=y
|
||||
CONFIG_SOFTLIMIT=y
|
||||
|
||||
#
|
||||
# Selinux Utilities
|
||||
#
|
||||
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
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
#include "busybox.h"
|
||||
|
||||
#if ENABLE_BUILD_LIBBUSYBOX
|
||||
int main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
return lbb_main(argv);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
|
||||
fputs(APPLET_full_usage "\n", stdout);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@@ -14,14 +14,21 @@ exec >"$target"
|
||||
|
||||
echo 'static const char packed_usage[] ALIGN1 = {'
|
||||
|
||||
# Extra effort to avoid using "od -t x1": -t is not available
|
||||
# in non-CONFIG_DESKTOPed busybox od
|
||||
## 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 -x \
|
||||
"$loc/usage" | bzip2 -1 | od -v -t x1 \
|
||||
| $SED -e 's/^[^ ]*//' \
|
||||
| $SED -e 's/ //g' \
|
||||
| grep -v '^$' \
|
||||
| $SED -e 's/\(..\)\(..\)/0x\2,0x\1,/g'
|
||||
| $SED -e 's/\(..\)/0x\1,/g'
|
||||
|
||||
echo '};'
|
||||
echo '#define SIZEOF_usage_messages' `expr 0 + $sz`
|
||||
+57
-109
@@ -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,
|
||||
@@ -33,8 +57,8 @@ config FEATURE_AR_LONG_FILENAMES
|
||||
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,15 +92,15 @@ 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"
|
||||
@@ -89,31 +113,35 @@ config FEATURE_CPIO_O
|
||||
config DPKG
|
||||
bool "dpkg"
|
||||
default n
|
||||
select FEATURE_SEAMLESS_GZ
|
||||
help
|
||||
dpkg is a medium-level tool to install, build, remove and manage Debian packages.
|
||||
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
|
||||
select FEATURE_SEAMLESS_GZ
|
||||
help
|
||||
dpkg-deb packs, unpacks and provides information about Debian archives.
|
||||
dpkg-deb unpacks and provides information about Debian archives.
|
||||
|
||||
This implementation of dpkg-deb cannot pack archives.
|
||||
|
||||
Unless you have a specific application which requires dpkg-deb, 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)"
|
||||
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"
|
||||
@@ -123,15 +151,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
|
||||
@@ -151,13 +170,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
|
||||
@@ -166,6 +178,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
|
||||
@@ -174,45 +188,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_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_BZIP2
|
||||
bool "Enable -j option to handle .tar.bz2 files"
|
||||
default n
|
||||
depends on TAR
|
||||
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.
|
||||
|
||||
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_AUTODETECT
|
||||
bool "Let tar autodetect gz/bz2 compresses tarballs"
|
||||
bool "Autodetect gz/bz2 compressed tarballs"
|
||||
default n
|
||||
depends on FEATURE_TAR_GZIP || FEATURE_TAR_BZIP2
|
||||
depends on FEATURE_SEAMLESS_Z || FEATURE_SEAMLESS_GZ || FEATURE_SEAMLESS_BZ2 || FEATURE_SEAMLESS_LZMA
|
||||
help
|
||||
With this option tar can automatically detect gzip/bzip2 compressed
|
||||
tarballs. Currently it works only on seekable streams.
|
||||
tarballs. Currently it works only on files (not pipes etc).
|
||||
|
||||
config FEATURE_TAR_FROM
|
||||
bool "Enable -X (exclude from) and -T (include from) options)"
|
||||
@@ -237,8 +219,9 @@ 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 "Support for GNU tar extensions (long filenames)"
|
||||
@@ -264,6 +247,8 @@ config FEATURE_TAR_UNAME_GNAME
|
||||
listings (-t) and preserving permissions when unpacking (-p).
|
||||
+200 bytes.
|
||||
|
||||
endif #tar
|
||||
|
||||
config UNCOMPRESS
|
||||
bool "uncompress"
|
||||
default n
|
||||
@@ -276,7 +261,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.
|
||||
|
||||
@@ -304,41 +289,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
|
||||
|
||||
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;
|
||||
}
|
||||
+41
-19
@@ -28,15 +28,16 @@ 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)
|
||||
USE_DESKTOP(long long) int (*unpacker)(unpack_info_t *info)
|
||||
)
|
||||
{
|
||||
struct stat stat_buf;
|
||||
USE_DESKTOP(long long) int status;
|
||||
char *filename, *new_name;
|
||||
smallint exitcode = 0;
|
||||
unpack_info_t info;
|
||||
|
||||
do {
|
||||
/* NB: new_name is *maybe* malloc'ed! */
|
||||
@@ -73,6 +74,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,
|
||||
@@ -86,14 +93,29 @@ int bbunpack(char **argv,
|
||||
"use -f to force it");
|
||||
}
|
||||
|
||||
status = unpacker();
|
||||
/* memset(&info, 0, sizeof(info)); */
|
||||
info.mtime = 0; /* so far it has one member only */
|
||||
status = unpacker(&info);
|
||||
if (status < 0)
|
||||
exitcode = 1;
|
||||
|
||||
if (filename) {
|
||||
char *del = new_name;
|
||||
if (status >= 0) {
|
||||
/* TODO: restore user/group/times here? */
|
||||
/* TODO: restore other things? */
|
||||
if (info.mtime) {
|
||||
struct utimbuf times;
|
||||
|
||||
times.actime = info.mtime;
|
||||
times.modtime = info.mtime;
|
||||
/* Close first.
|
||||
* On some systems calling utime
|
||||
* then closing resets the mtime. */
|
||||
close(STDOUT_FILENO);
|
||||
/* Ignoring errors */
|
||||
utime(new_name, ×);
|
||||
}
|
||||
|
||||
/* Delete _compressed_ file */
|
||||
del = filename;
|
||||
/* restore extension (unless tgz -> tar case) */
|
||||
@@ -153,13 +175,13 @@ char* make_new_name_bunzip2(char *filename)
|
||||
}
|
||||
|
||||
static
|
||||
USE_DESKTOP(long long) int unpack_bunzip2(void)
|
||||
USE_DESKTOP(long long) int unpack_bunzip2(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
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 ATTRIBUTE_UNUSED, char **argv)
|
||||
int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cfvdt");
|
||||
argv += optind;
|
||||
@@ -212,8 +234,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';
|
||||
@@ -229,7 +251,7 @@ char* make_new_name_gunzip(char *filename)
|
||||
}
|
||||
|
||||
static
|
||||
USE_DESKTOP(long long) int unpack_gunzip(void)
|
||||
USE_DESKTOP(long long) int unpack_gunzip(unpack_info_t *info)
|
||||
{
|
||||
USE_DESKTOP(long long) int status = -1;
|
||||
|
||||
@@ -238,10 +260,10 @@ 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);
|
||||
status = unpack_gz_stream_with_info(STDIN_FILENO, STDOUT_FILENO, info);
|
||||
} else {
|
||||
goto bad_magic;
|
||||
}
|
||||
@@ -271,7 +293,7 @@ USE_DESKTOP(long long) int unpack_gunzip(void)
|
||||
*/
|
||||
|
||||
int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int gunzip_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cfvdtn");
|
||||
argv += optind;
|
||||
@@ -303,13 +325,13 @@ char* make_new_name_unlzma(char *filename)
|
||||
}
|
||||
|
||||
static
|
||||
USE_DESKTOP(long long) int unpack_unlzma(void)
|
||||
USE_DESKTOP(long long) int unpack_unlzma(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
return unpack_lzma_stream(STDIN_FILENO, STDOUT_FILENO);
|
||||
}
|
||||
|
||||
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int unlzma_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int unlzma_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "cf");
|
||||
argv += optind;
|
||||
@@ -338,20 +360,20 @@ char* make_new_name_uncompress(char *filename)
|
||||
}
|
||||
|
||||
static
|
||||
USE_DESKTOP(long long) int unpack_uncompress(void)
|
||||
USE_DESKTOP(long long) int unpack_uncompress(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
USE_DESKTOP(long long) int status = -1;
|
||||
|
||||
if ((xread_char(STDIN_FILENO) != 0x1f) || (xread_char(STDIN_FILENO) != 0x9d)) {
|
||||
bb_error_msg("invalid magic");
|
||||
} else {
|
||||
status = uncompress(STDIN_FILENO, STDOUT_FILENO);
|
||||
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 ATTRIBUTE_UNUSED, 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 */
|
||||
|
||||
+6
-5
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define CONFIG_BZIP2_FEATURE_SPEED 1
|
||||
|
||||
@@ -101,7 +102,7 @@ USE_DESKTOP(long long) int bz_write(bz_stream *strm, void* rbuf, ssize_t rlen, v
|
||||
}
|
||||
|
||||
static
|
||||
USE_DESKTOP(long long) int compressStream(void)
|
||||
USE_DESKTOP(long long) int compressStream(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
USE_DESKTOP(long long) int total;
|
||||
ssize_t count;
|
||||
@@ -141,7 +142,7 @@ char* make_new_name_bzip2(char *filename)
|
||||
}
|
||||
|
||||
int bzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int bzip2_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int bzip2_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
unsigned opt;
|
||||
|
||||
@@ -162,11 +163,11 @@ int bzip2_main(int argc ATTRIBUTE_UNUSED, 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
|
||||
|
||||
+105
-23
@@ -14,18 +14,6 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
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),
|
||||
};
|
||||
|
||||
#if ENABLE_FEATURE_CPIO_O
|
||||
static off_t cpio_pad4(off_t size)
|
||||
{
|
||||
@@ -42,6 +30,7 @@ static off_t cpio_pad4(off_t size)
|
||||
* It's ok to exit instead of return. */
|
||||
static int cpio_o(void)
|
||||
{
|
||||
static const char trailer[] ALIGN1 = "TRAILER!!!";
|
||||
struct name_s {
|
||||
struct name_s *next;
|
||||
char name[1];
|
||||
@@ -131,7 +120,7 @@ static int cpio_o(void)
|
||||
} else {
|
||||
/* If no (more) hardlinks to output,
|
||||
* output "trailer" entry */
|
||||
name = "TRAILER!!!";
|
||||
name = trailer;
|
||||
/* st.st_size == 0 is a must, but for uniformity
|
||||
* in the output, we zero out everything */
|
||||
memset(&st, 0, sizeof(st));
|
||||
@@ -179,7 +168,7 @@ static int cpio_o(void)
|
||||
}
|
||||
|
||||
if (!line) {
|
||||
if (links)
|
||||
if (name != trailer)
|
||||
goto next_link;
|
||||
/* TODO: GNU cpio pads trailer to 512 bytes, do we want that? */
|
||||
return EXIT_SUCCESS;
|
||||
@@ -190,21 +179,106 @@ static int cpio_o(void)
|
||||
}
|
||||
#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 ATTRIBUTE_UNUSED, char **argv)
|
||||
int cpio_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
char *cpio_filename;
|
||||
#if ENABLE_FEATURE_CPIO_O
|
||||
const char *cpio_fmt = "";
|
||||
#endif
|
||||
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),
|
||||
};
|
||||
|
||||
#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);
|
||||
@@ -214,7 +288,7 @@ int cpio_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
bb_show_usage();
|
||||
if (opt & CPIO_OPT_FILE) {
|
||||
fclose(stdout);
|
||||
stdout = fopen(cpio_filename, "w");
|
||||
stdout = fopen_for_write(cpio_filename);
|
||||
/* Paranoia: I don't trust libc that much */
|
||||
xdup2(fileno(stdout), STDOUT_FILENO);
|
||||
}
|
||||
@@ -241,8 +315,8 @@ int cpio_main(int argc ATTRIBUTE_UNUSED, 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) {
|
||||
@@ -256,7 +330,10 @@ int cpio_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
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 (*argv) {
|
||||
@@ -265,8 +342,13 @@ int cpio_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
argv++;
|
||||
}
|
||||
|
||||
/* see get_header_cpio */
|
||||
archive_handle->ah_priv[2] = (void*) ~(ptrdiff_t)0;
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS)
|
||||
continue;
|
||||
|
||||
if (archive_handle->ah_priv[2] != (void*) ~(ptrdiff_t)0)
|
||||
printf("%lu blocks\n", (unsigned long)(ptrdiff_t)(archive_handle->ah_priv[2]));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+26
-23
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include <fnmatch.h>
|
||||
#include "unarchive.h"
|
||||
|
||||
/* note: if you vary hash_prime sizes be aware,
|
||||
@@ -382,9 +383,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;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -749,7 +749,7 @@ static void index_status_file(const char *filename)
|
||||
status_node_t *status_node = NULL;
|
||||
unsigned status_num;
|
||||
|
||||
status_file = xfopen(filename, "r");
|
||||
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) {
|
||||
@@ -791,8 +791,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;
|
||||
@@ -972,7 +972,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 */
|
||||
@@ -989,7 +989,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++;
|
||||
}
|
||||
@@ -1162,7 +1162,7 @@ static char **create_list(const char *filename)
|
||||
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;
|
||||
}
|
||||
@@ -1170,9 +1170,9 @@ static char **create_list(const char *filename)
|
||||
file_list = NULL;
|
||||
count = 0;
|
||||
while ((line = xmalloc_fgetline(list_stream)) != NULL) {
|
||||
file_list = xrealloc(file_list, sizeof(char *) * (count + 2));
|
||||
file_list = xrealloc_vector(file_list, 2, count);
|
||||
file_list[count++] = line;
|
||||
file_list[count] = NULL;
|
||||
/*file_list[count] = NULL; - xrealloc_vector did it */
|
||||
}
|
||||
fclose(list_stream);
|
||||
|
||||
@@ -1294,7 +1294,7 @@ static void free_array(char **array)
|
||||
* the status_hashtable to retrieve the info. This results in smaller code than
|
||||
* scanning the status file. The resulting list, however, is unsorted.
|
||||
*/
|
||||
static void list_packages(void)
|
||||
static void list_packages(const char *pattern)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -1315,6 +1315,9 @@ static void list_packages(void)
|
||||
name_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->name];
|
||||
vers_str = name_hashtable[package_hashtable[status_hashtable[i]->package]->version];
|
||||
|
||||
if (pattern && fnmatch(pattern, name_str, 0))
|
||||
continue;
|
||||
|
||||
/* get abbreviation for status field 1 */
|
||||
s1 = stat_str[0] == 'i' ? 'i' : 'r';
|
||||
|
||||
@@ -1439,10 +1442,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
|
||||
|
||||
@@ -1459,10 +1462,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
|
||||
|
||||
@@ -1482,7 +1485,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;
|
||||
|
||||
@@ -1532,7 +1535,7 @@ 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 */
|
||||
@@ -1543,12 +1546,12 @@ static void unpack_package(deb_file_t *deb_file)
|
||||
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.%s", package_name, "list");
|
||||
out_stream = xfopen(list_filename, "w");
|
||||
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);
|
||||
@@ -1583,7 +1586,7 @@ static void configure_package(deb_file_t *deb_file)
|
||||
}
|
||||
|
||||
int dpkg_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int dpkg_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int dpkg_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
deb_file_t **deb_file = NULL;
|
||||
status_node_t *status_node;
|
||||
@@ -1627,14 +1630,14 @@ int dpkg_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
|
||||
/* if the list action was given print the installed packages and exit */
|
||||
if (opt & OPT_list_installed) {
|
||||
list_packages();
|
||||
list_packages(argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
|
||||
+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;
|
||||
}
|
||||
+6
-4
@@ -40,6 +40,7 @@ aa: 85.1% -- replaced with aa.gz
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
|
||||
/* ===========================================================================
|
||||
@@ -2014,7 +2015,7 @@ char* make_new_name_gzip(char *filename)
|
||||
}
|
||||
|
||||
static
|
||||
USE_DESKTOP(long long) int pack_gzip(void)
|
||||
USE_DESKTOP(long long) int pack_gzip(unpack_info_t *info UNUSED_PARAM)
|
||||
{
|
||||
struct stat s;
|
||||
|
||||
@@ -2043,15 +2044,15 @@ 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 ATTRIBUTE_UNUSED, char **argv)
|
||||
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") "q123456789n" );
|
||||
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 */
|
||||
@@ -2062,6 +2063,7 @@ int gzip_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
|
||||
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 != (ssize_t)count) {
|
||||
bb_error_msg_and_die("short read: %u of %u",
|
||||
(unsigned)size, (unsigned)count);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void data_align(archive_handle_t *archive_handle, unsigned boundary)
|
||||
void FAST_FUNC data_align(archive_handle_t *archive_handle, unsigned boundary)
|
||||
{
|
||||
unsigned skip_amount = (boundary - (archive_handle->offset % boundary)) % boundary;
|
||||
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
#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) {
|
||||
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)
|
||||
@@ -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,
|
||||
@@ -77,8 +77,10 @@ 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)
|
||||
if ((res == -1)
|
||||
&& (errno != EISDIR) /* btw, Linux doesn't return this */
|
||||
&& (errno != EEXIST)
|
||||
&& !(archive_handle->ah_flags & ARCHIVE_EXTRACT_QUIET)
|
||||
) {
|
||||
bb_perror_msg("cannot make dir %s", file_header->name);
|
||||
}
|
||||
@@ -87,7 +89,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 +103,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,7 +113,7 @@ 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;
|
||||
@@ -133,11 +135,11 @@ void data_extract_all(archive_handle_t *archive_handle)
|
||||
/* 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 ((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,7 +160,6 @@ 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 ((int)origPtr > dbufSize) return RETVAL_DATA_ERROR;
|
||||
@@ -179,7 +169,6 @@ static int get_next_block(bunzip_data *bd)
|
||||
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,7 +342,6 @@ 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 ((int)(bd->inbufBitCount) < hufGroup->maxLen) {
|
||||
if (bd->inbufPos == bd->inbufCount) {
|
||||
j = get_bits(bd, hufGroup->maxLen);
|
||||
@@ -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 ((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]);
|
||||
fprintf(stderr, "%s\n", bunzip_errors[-i]);
|
||||
else if (read(STDIN_FILENO, &c, 1))
|
||||
fprintf(stderr,"Trailing garbage ignored\n");
|
||||
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;)
|
||||
@@ -489,12 +488,16 @@ unpack_lzma_stream(int src_fd, int dst_fd)
|
||||
}
|
||||
}
|
||||
|
||||
if (full_write(dst_fd, buffer, buffer_pos) != (ssize_t)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;
|
||||
}
|
||||
@@ -244,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);
|
||||
@@ -1033,7 +1033,7 @@ inflate_unzip_internal(STATE_PARAM int in, int out)
|
||||
|
||||
/* For unzip */
|
||||
|
||||
USE_DESKTOP(long long) int
|
||||
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;
|
||||
@@ -1108,18 +1108,21 @@ static uint32_t buffer_read_le_u32(STATE_PARAM_ONLY)
|
||||
return res;
|
||||
}
|
||||
|
||||
static int check_header_gzip(STATE_PARAM_ONLY)
|
||||
static int check_header_gzip(STATE_PARAM unpack_info_t *info)
|
||||
{
|
||||
union {
|
||||
unsigned char raw[8];
|
||||
struct {
|
||||
uint8_t gz_method;
|
||||
uint8_t flags;
|
||||
//uint32_t mtime; - unused fields
|
||||
//uint8_t xtra_flags;
|
||||
//uint8_t os_flags;
|
||||
} formatted; /* packed */
|
||||
uint32_t mtime;
|
||||
uint8_t xtra_flags_UNUSED;
|
||||
uint8_t os_flags_UNUSED;
|
||||
} __attribute__((packed)) formatted;
|
||||
} header;
|
||||
struct BUG_header {
|
||||
char BUG_header[sizeof(header) == 8 ? 1 : -1];
|
||||
};
|
||||
|
||||
/*
|
||||
* Rewind bytebuffer. We use the beginning because the header has 8
|
||||
@@ -1167,6 +1170,9 @@ static int check_header_gzip(STATE_PARAM_ONLY)
|
||||
}
|
||||
}
|
||||
|
||||
if (info)
|
||||
info->mtime = SWAP_LE32(header.formatted.mtime);
|
||||
|
||||
/* Read the header checksum */
|
||||
if (header.formatted.flags & 0x02) {
|
||||
if (!top_up(PASS_STATE 2))
|
||||
@@ -1176,8 +1182,8 @@ static int check_header_gzip(STATE_PARAM_ONLY)
|
||||
return 1;
|
||||
}
|
||||
|
||||
USE_DESKTOP(long long) int
|
||||
unpack_gz_stream(int in, int out)
|
||||
USE_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_gz_stream_with_info(int in, int out, unpack_info_t *info)
|
||||
{
|
||||
uint32_t v32;
|
||||
USE_DESKTOP(long long) int n;
|
||||
@@ -1192,7 +1198,7 @@ unpack_gz_stream(int in, int out)
|
||||
gunzip_src_fd = in;
|
||||
|
||||
again:
|
||||
if (!check_header_gzip(PASS_STATE_ONLY)) {
|
||||
if (!check_header_gzip(PASS_STATE info)) {
|
||||
bb_error_msg("corrupted data");
|
||||
n = -1;
|
||||
goto ret;
|
||||
@@ -1239,3 +1245,9 @@ unpack_gz_stream(int in, int out)
|
||||
DEALLOC_STATE;
|
||||
return n;
|
||||
}
|
||||
|
||||
USE_DESKTOP(long long) int FAST_FUNC
|
||||
unpack_gz_stream(int in, int out)
|
||||
{
|
||||
return unpack_gz_stream_with_info(in, out, NULL);
|
||||
}
|
||||
@@ -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,7 +11,7 @@
|
||||
/*
|
||||
* 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;
|
||||
const llist_t *reject_entry;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,8 +7,8 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
typedef struct hardlinks_s {
|
||||
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 */
|
||||
@@ -17,24 +17,33 @@ typedef struct hardlinks_s {
|
||||
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 hardlinks_t *saved_hardlinks_created = NULL;
|
||||
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
char cpio_header[110];
|
||||
char dummy[16];
|
||||
int namesize;
|
||||
int major, minor, nlink, mode, inode;
|
||||
unsigned size, uid, gid, mtime;
|
||||
|
||||
#define hardlinks_to_create (*(hardlinks_t **)(&archive_handle->ah_priv[0]))
|
||||
#define created_hardlinks (*(hardlinks_t **)(&archive_handle->ah_priv[1]))
|
||||
#define block_count (archive_handle->ah_priv[2])
|
||||
// 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) {
|
||||
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;
|
||||
|
||||
if (strncmp(&cpio_header[0], "07070", 5) != 0
|
||||
@@ -43,19 +52,21 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
bb_error_msg_and_die("unsupported cpio format, use newc or crc");
|
||||
}
|
||||
|
||||
sscanf(cpio_header + 6,
|
||||
if (sscanf(cpio_header + 6,
|
||||
"%8x" "%8x" "%8x" "%8x"
|
||||
"%8x" "%8x" "%8x" /*maj,min:*/ "%16c"
|
||||
/*rmaj,rmin:*/"%8x" "%8x" "%8x" /*chksum:*/ "%8c",
|
||||
"%8x" "%8x" "%8x" /*maj,min:*/ "%*16c"
|
||||
/*rmaj,rmin:*/"%8x" "%8x" "%8x" /*chksum: "%*8c"*/,
|
||||
&inode, &mode, &uid, &gid,
|
||||
&nlink, &mtime, &size, dummy,
|
||||
&major, &minor, &namesize, dummy);
|
||||
&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;
|
||||
|
||||
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);
|
||||
@@ -66,21 +77,21 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
|
||||
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
|
||||
/* Always round up. ">> 9" divides by 512 */
|
||||
printf("%"OFF_FMT"u blocks\n", (archive_handle->offset + 511) >> 9);
|
||||
block_count = (void*)(ptrdiff_t) ((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;
|
||||
}
|
||||
|
||||
// TODO: data_extract_all can't deal with hardlinks to non-files...
|
||||
// (should be !S_ISDIR instead of S_ISREG here)
|
||||
// when fixed, change S_ISREG to !S_ISDIR here
|
||||
|
||||
if (nlink > 1 && S_ISREG(file_header->mode)) {
|
||||
hardlinks_t *new = xmalloc(sizeof(*new) + namesize);
|
||||
@@ -92,13 +103,13 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
strcpy(new->name, file_header->name);
|
||||
/* Put file on a linked list for later */
|
||||
if (size == 0) {
|
||||
new->next = saved_hardlinks;
|
||||
saved_hardlinks = new;
|
||||
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) */
|
||||
}
|
||||
new->next = saved_hardlinks_created;
|
||||
saved_hardlinks_created = new;
|
||||
new->next = created_hardlinks;
|
||||
created_hardlinks = new;
|
||||
}
|
||||
file_header->device = makedev(major, minor);
|
||||
|
||||
@@ -122,18 +133,23 @@ char get_header_cpio(archive_handle_t *archive_handle)
|
||||
free(file_header->link_target);
|
||||
free(file_header->name);
|
||||
|
||||
while (saved_hardlinks) {
|
||||
while (hardlinks_to_create) {
|
||||
hardlinks_t *cur;
|
||||
hardlinks_t *make_me = saved_hardlinks;
|
||||
saved_hardlinks = make_me->next;
|
||||
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 = saved_hardlinks_created;
|
||||
cur = created_hardlinks;
|
||||
while (cur) {
|
||||
/* TODO: must match maj/min too! */
|
||||
if (cur->inode == make_me->inode) {
|
||||
@@ -144,23 +160,21 @@ char get_header_cpio(archive_handle_t *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)) */
|
||||
file_header->mtime = make_me->mtime;
|
||||
file_header->uid = make_me->uid ;
|
||||
file_header->gid = make_me->gid ;
|
||||
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 = saved_hardlinks_created;
|
||||
saved_hardlinks_created = make_me;
|
||||
make_me->next = created_hardlinks;
|
||||
created_hardlinks = make_me;
|
||||
next_link: ;
|
||||
}
|
||||
|
||||
while (saved_hardlinks_created) {
|
||||
hardlinks_t *p = saved_hardlinks_created;
|
||||
saved_hardlinks_created = p->next;
|
||||
while (created_hardlinks) {
|
||||
hardlinks_t *p = created_hardlinks;
|
||||
created_hardlinks = p->next;
|
||||
free(p);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,13 +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;
|
||||
#if ENABLE_FEATURE_TAR_AUTODETECT
|
||||
static smallint not_first;
|
||||
#endif
|
||||
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
struct {
|
||||
/* ustar header, Posix 1003.1 */
|
||||
@@ -65,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 */
|
||||
@@ -82,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();
|
||||
|
||||
@@ -94,37 +92,46 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
again_after_align:
|
||||
|
||||
#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:
|
||||
/* 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 tar will exit with error code 0.
|
||||
* 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)
|
||||
if (i == 0) {
|
||||
xfunc_error_retval = 0;
|
||||
if (i != 512)
|
||||
short_read:
|
||||
bb_error_msg_and_die("short read");
|
||||
}
|
||||
if (i != 512) {
|
||||
USE_FEATURE_TAR_AUTODETECT(goto autodetect;)
|
||||
goto short_read;
|
||||
}
|
||||
|
||||
#else
|
||||
xread(archive_handle->src_fd, &tar, 512);
|
||||
i = 512;
|
||||
xread(archive_handle->src_fd, &tar, i);
|
||||
#endif
|
||||
archive_handle->offset += 512;
|
||||
archive_handle->offset += i;
|
||||
|
||||
/* If there is no filename its an empty header */
|
||||
if (tar.name[0] == 0 && tar.prefix[0] == 0) {
|
||||
if (end) {
|
||||
/* This is the second consecutive empty header! End of archive!
|
||||
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)
|
||||
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,
|
||||
* five NULs are for the old tar format */
|
||||
@@ -133,21 +140,20 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
|| memcmp(tar.magic, "\0\0\0\0", 5) != 0)
|
||||
) {
|
||||
#if ENABLE_FEATURE_TAR_AUTODETECT
|
||||
char (*get_header_ptr)(archive_handle_t *);
|
||||
char FAST_FUNC (*get_header_ptr)(archive_handle_t *);
|
||||
|
||||
USE_DESKTOP(autodetect:)
|
||||
/* tar gz/bz autodetect: check for gz/bz2 magic.
|
||||
* If it is the very first block, and we see the 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 (not_first)
|
||||
goto err;
|
||||
#if ENABLE_FEATURE_TAR_GZIP
|
||||
#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
|
||||
#if ENABLE_FEATURE_TAR_BZIP2
|
||||
#if ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
if (tar.name[0] == 'B' && tar.name[1] == 'Z'
|
||||
&& tar.name[2] == 'h' && isdigit(tar.name[3])
|
||||
) { /* bzip2 */
|
||||
@@ -155,7 +161,10 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
} else
|
||||
#endif
|
||||
goto err;
|
||||
if (lseek(archive_handle->src_fd, -512, SEEK_CUR) != 0)
|
||||
/* 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;
|
||||
@@ -165,10 +174,6 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
bb_error_msg_and_die("invalid tar magic");
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_TAR_AUTODETECT
|
||||
not_first = 1;
|
||||
#endif
|
||||
|
||||
/* Do checksum on headers.
|
||||
* POSIX says that checksum is done on unsigned bytes, but
|
||||
* Sun and HP-UX gets it wrong... more details in
|
||||
@@ -219,7 +224,7 @@ char get_header_tar(archive_handle_t *archive_handle)
|
||||
tar.prefix[0] = t;
|
||||
}
|
||||
file_header->link_target = NULL;
|
||||
if (!linkname && parse_names && tar.linkname[0]) {
|
||||
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? */
|
||||
@@ -236,7 +241,7 @@ 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'; - gcc 4.3.0 would complain
|
||||
tar.mode[0] = '\0';
|
||||
@@ -261,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;
|
||||
@@ -324,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'",
|
||||
@@ -345,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 {
|
||||
@@ -359,7 +369,7 @@ 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);
|
||||
|
||||
@@ -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,7 +6,7 @@
|
||||
#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));
|
||||
|
||||
|
||||
@@ -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,8 +11,8 @@
|
||||
* 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)
|
||||
{
|
||||
struct fd_pair fd_pipe;
|
||||
@@ -23,28 +23,29 @@ int open_transformer(int src_fd,
|
||||
#if BB_MMU
|
||||
pid = fork();
|
||||
if (pid == -1)
|
||||
bb_perror_msg_and_die("can't fork");
|
||||
bb_perror_msg_and_die("vfork" + 1);
|
||||
#else
|
||||
pid = vfork();
|
||||
if (pid == -1)
|
||||
bb_perror_msg_and_die("can't vfork");
|
||||
bb_perror_msg_and_die("vfork");
|
||||
#endif
|
||||
|
||||
if (pid == 0) {
|
||||
/* child process */
|
||||
close(fd_pipe.rd); /* We don't want 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.wr);
|
||||
transformer(fd, fd_pipe.wr);
|
||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||
close(fd_pipe.wr); /* Send EOF */
|
||||
close(src_fd);
|
||||
close(fd_pipe.wr); /* send EOF */
|
||||
close(fd);
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
/* must be _exit! bug was actually seen here */
|
||||
_exit(EXIT_SUCCESS);
|
||||
#else
|
||||
{
|
||||
char *argv[4];
|
||||
xmove_fd(src_fd, 0);
|
||||
xmove_fd(fd, 0);
|
||||
xmove_fd(fd_pipe.wr, 1);
|
||||
argv[0] = (char*)transform_prog;
|
||||
argv[1] = (char*)"-cf";
|
||||
@@ -58,7 +59,6 @@ int open_transformer(int src_fd,
|
||||
}
|
||||
|
||||
/* parent process */
|
||||
close(fd_pipe.wr); /* Don't want to write to the child */
|
||||
|
||||
return fd_pipe.rd;
|
||||
close(fd_pipe.wr); /* don't want to write to the child */
|
||||
xmove_fd(fd_pipe.rd, fd);
|
||||
}
|
||||
@@ -6,9 +6,11 @@
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
void seek_by_jump(const archive_handle_t *archive_handle, unsigned 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 (amount
|
||||
&& lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1
|
||||
) {
|
||||
if (errno == ESPIPE)
|
||||
seek_by_read(archive_handle, amount);
|
||||
else
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/* 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, unsigned 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;
|
||||
}
|
||||
+38
-29
@@ -115,8 +115,8 @@ int rpm_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
argv += optind;
|
||||
argc -= optind;
|
||||
if (!argc) bb_show_usage();
|
||||
//argc -= optind;
|
||||
if (!argv[0]) bb_show_usage();
|
||||
|
||||
while (*argv) {
|
||||
rpm_fd = xopen(*argv++, O_RDONLY);
|
||||
@@ -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,16 @@ 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
|
||||
/* compat: overwrite existing files.
|
||||
* try "rpm -i foo.src.rpm" few times in a row -
|
||||
* standard rpm will not complain.
|
||||
* (TODO? real rpm creates "file;1234" and then renames it) */
|
||||
| ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
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 +219,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 +241,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;
|
||||
@@ -247,7 +251,7 @@ static void extract_cpio_gz(int fd)
|
||||
static rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
{
|
||||
/* We should never need mode than 200, and realloc later */
|
||||
rpm_index **tags = xzalloc(200 * sizeof(struct rpmtag *));
|
||||
rpm_index **tags = xzalloc(200 * sizeof(tags[0]));
|
||||
int pass, tagindex = 0;
|
||||
|
||||
xlseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */
|
||||
@@ -261,6 +265,9 @@ static rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
uint32_t entries; /* Number of entries in header (4 bytes) */
|
||||
uint32_t size; /* Size of store (4 bytes) */
|
||||
} header;
|
||||
struct BUG_header {
|
||||
char BUG_header[sizeof(header) == 16 ? 1 : -1];
|
||||
};
|
||||
rpm_index *tmpindex;
|
||||
int storepos;
|
||||
|
||||
@@ -274,21 +281,21 @@ static rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
storepos = xlseek(fd,0,SEEK_CUR) + header.entries * 16;
|
||||
|
||||
while (header.entries--) {
|
||||
tmpindex = tags[tagindex++] = xmalloc(sizeof(rpm_index));
|
||||
xread(fd, tmpindex, sizeof(rpm_index));
|
||||
tmpindex = tags[tagindex++] = xmalloc(sizeof(*tmpindex));
|
||||
xread(fd, tmpindex, sizeof(*tmpindex));
|
||||
tmpindex->tag = ntohl(tmpindex->tag);
|
||||
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 */
|
||||
tags = xrealloc(tags, tagindex * sizeof(tags[0])); /* realloc tags to save space */
|
||||
*num_tags = tagindex;
|
||||
return tags; /* All done, leave the file at the start of the gzipped cpio archive */
|
||||
}
|
||||
@@ -379,9 +386,11 @@ static void fileaction_dobackup(char *filename, int fileref)
|
||||
|
||||
static void fileaction_setowngrp(char *filename, int fileref)
|
||||
{
|
||||
int uid, gid;
|
||||
uid = xuname2uid(rpm_getstr(TAG_FILEUSERNAME, fileref));
|
||||
gid = xgroup2gid(rpm_getstr(TAG_FILEGROUPNAME, fileref));
|
||||
/* real rpm warns: "user foo does not exist - using <you>" */
|
||||
struct passwd *pw = getpwnam(rpm_getstr(TAG_FILEUSERNAME, fileref));
|
||||
int uid = pw ? pw->pw_uid : getuid(); /* or euid? */
|
||||
struct group *gr = getgrnam(rpm_getstr(TAG_FILEGROUPNAME, fileref));
|
||||
int gid = gr ? gr->gr_gid : getgid();
|
||||
chown(filename, uid, gid);
|
||||
}
|
||||
|
||||
|
||||
+66
-56
@@ -36,7 +36,7 @@
|
||||
#define block_buf bb_common_bufsiz1
|
||||
|
||||
|
||||
#if !ENABLE_FEATURE_TAR_GZIP && !ENABLE_FEATURE_TAR_BZIP2
|
||||
#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)
|
||||
@@ -396,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;
|
||||
@@ -503,19 +503,19 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
|
||||
#if !(ENABLE_FEATURE_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2)
|
||||
#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_TAR_GZIP && ENABLE_FEATURE_TAR_BZIP2
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ && ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
const char *zip_exec = (gzip == 1) ? "gzip" : "bzip2";
|
||||
#elif ENABLE_FEATURE_TAR_GZIP
|
||||
#elif ENABLE_FEATURE_SEAMLESS_GZ
|
||||
const char *zip_exec = "gzip";
|
||||
#else /* only ENABLE_FEATURE_TAR_BZIP2 */
|
||||
#else /* only ENABLE_FEATURE_SEAMLESS_BZ2 */
|
||||
const char *zip_exec = "bzip2";
|
||||
#endif
|
||||
// On Linux, vfork never unpauses parent early, although standard
|
||||
@@ -538,7 +538,7 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip)
|
||||
|
||||
gzipPid = vfork();
|
||||
if (gzipPid < 0)
|
||||
bb_perror_msg_and_die("can't vfork");
|
||||
bb_perror_msg_and_die("vfork");
|
||||
|
||||
if (gzipPid == 0) {
|
||||
/* child */
|
||||
@@ -579,7 +579,7 @@ static void NOINLINE vfork_compressor(int tar_fd, int gzip)
|
||||
bb_perror_msg_and_die("cannot exec %s", zip_exec);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2 */
|
||||
#endif /* ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2 */
|
||||
|
||||
|
||||
/* gcc 4.2.1 inlines it, making code bigger */
|
||||
@@ -601,7 +601,7 @@ static NOINLINE int writeTarFile(int tar_fd, 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
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
if (gzip)
|
||||
vfork_compressor(tbInfo.tarFd, gzip);
|
||||
#endif
|
||||
@@ -637,7 +637,7 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
|
||||
if (errorFlag)
|
||||
bb_error_msg("error exit delayed from previous errors");
|
||||
|
||||
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
if (gzip) {
|
||||
int status;
|
||||
if (safe_waitpid(-1, &status, 0) == -1)
|
||||
@@ -663,7 +663,7 @@ static llist_t *append_file_list_to_list(llist_t *list)
|
||||
llist_t *newlist = NULL;
|
||||
|
||||
while (list) {
|
||||
src_stream = xfopen(llist_pop(&list), "r");
|
||||
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, '/');
|
||||
@@ -679,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;
|
||||
@@ -692,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;
|
||||
@@ -729,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
|
||||
@@ -747,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
|
||||
};
|
||||
@@ -772,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"
|
||||
@@ -800,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 ATTRIBUTE_UNUSED, 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 = "-";
|
||||
@@ -814,9 +814,13 @@ int tar_main(int argc ATTRIBUTE_UNUSED, 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;
|
||||
|
||||
/* Apparently only root's tar preserves perms (see bug 3844) */
|
||||
if (getuid() != 0)
|
||||
tar_handle->ah_flags |= ARCHIVE_NOPRESERVE_PERM;
|
||||
|
||||
/* Prepend '-' to the first argument if required */
|
||||
opt_complementary = "--:" // first arg is options
|
||||
@@ -834,12 +838,12 @@ int tar_main(int argc ATTRIBUTE_UNUSED, 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
|
||||
@@ -862,13 +866,13 @@ int tar_main(int argc ATTRIBUTE_UNUSED, 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;
|
||||
@@ -922,8 +926,7 @@ int tar_main(int argc ATTRIBUTE_UNUSED, 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;
|
||||
@@ -933,7 +936,14 @@ int tar_main(int argc ATTRIBUTE_UNUSED, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -947,11 +957,11 @@ int tar_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
|
||||
/* create an archive */
|
||||
if (opt & OPT_CREATE) {
|
||||
#if ENABLE_FEATURE_TAR_GZIP || ENABLE_FEATURE_TAR_BZIP2
|
||||
#if ENABLE_FEATURE_SEAMLESS_GZ || ENABLE_FEATURE_SEAMLESS_BZ2
|
||||
int zipMode = 0;
|
||||
if (ENABLE_FEATURE_TAR_GZIP && (opt & OPT_GZIP))
|
||||
if (ENABLE_FEATURE_SEAMLESS_GZ && (opt & OPT_GZIP))
|
||||
zipMode = 1;
|
||||
if (ENABLE_FEATURE_TAR_BZIP2 && (opt & OPT_BZIP2))
|
||||
if (ENABLE_FEATURE_SEAMLESS_BZ2 && (opt & OPT_BZIP2))
|
||||
zipMode = 2;
|
||||
#endif
|
||||
/* NB: writeTarFile() closes tar_handle->src_fd */
|
||||
|
||||
+208
-51
@@ -16,12 +16,7 @@
|
||||
*/
|
||||
|
||||
/* TODO
|
||||
* Endian issues
|
||||
* Zip64 + other methods
|
||||
* Improve handling of zip format, ie.
|
||||
* - deferred CRC, comp. & uncomp. lengths (zip header flags bit 3)
|
||||
* - unix file permissions, etc.
|
||||
* - central directory
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
@@ -31,12 +26,12 @@ enum {
|
||||
#if BB_BIG_ENDIAN
|
||||
ZIP_FILEHEADER_MAGIC = 0x504b0304,
|
||||
ZIP_CDS_MAGIC = 0x504b0102,
|
||||
ZIP_CDS_END_MAGIC = 0x504b0506,
|
||||
ZIP_CDE_MAGIC = 0x504b0506,
|
||||
ZIP_DD_MAGIC = 0x504b0708,
|
||||
#else
|
||||
ZIP_FILEHEADER_MAGIC = 0x04034b50,
|
||||
ZIP_CDS_MAGIC = 0x02014b50,
|
||||
ZIP_CDS_END_MAGIC = 0x06054b50,
|
||||
ZIP_CDE_MAGIC = 0x06054b50,
|
||||
ZIP_DD_MAGIC = 0x08074b50,
|
||||
#endif
|
||||
};
|
||||
@@ -46,18 +41,18 @@ enum {
|
||||
typedef union {
|
||||
uint8_t raw[ZIP_HEADER_LEN];
|
||||
struct {
|
||||
uint16_t version; /* 0-1 */
|
||||
uint16_t flags; /* 2-3 */
|
||||
uint16_t method; /* 4-5 */
|
||||
uint16_t modtime; /* 6-7 */
|
||||
uint16_t moddate; /* 8-9 */
|
||||
uint32_t crc32 ATTRIBUTE_PACKED; /* 10-13 */
|
||||
uint32_t cmpsize ATTRIBUTE_PACKED; /* 14-17 */
|
||||
uint32_t ucmpsize ATTRIBUTE_PACKED; /* 18-21 */
|
||||
uint16_t filename_len; /* 22-23 */
|
||||
uint16_t extra_len; /* 24-25 */
|
||||
} formatted ATTRIBUTE_PACKED;
|
||||
} zip_header_t; /* ATTRIBUTE_PACKED - gcc 4.2.1 doesn't like it (spews warning) */
|
||||
uint16_t version; /* 0-1 */
|
||||
uint16_t flags; /* 2-3 */
|
||||
uint16_t method; /* 4-5 */
|
||||
uint16_t modtime; /* 6-7 */
|
||||
uint16_t moddate; /* 8-9 */
|
||||
uint32_t crc32 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 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,
|
||||
@@ -65,11 +60,11 @@ typedef union {
|
||||
*/
|
||||
struct BUG_zip_header_must_be_26_bytes {
|
||||
char BUG_zip_header_must_be_26_bytes[
|
||||
offsetof(zip_header_t, formatted.extra_len) + 2 ==
|
||||
ZIP_HEADER_LEN ? 1 : -1];
|
||||
offsetof(zip_header_t, formatted.extra_len) + 2
|
||||
== ZIP_HEADER_LEN ? 1 : -1];
|
||||
};
|
||||
|
||||
#define FIX_ENDIANNESS(zip_header) do { \
|
||||
#define FIX_ENDIANNESS_ZIP(zip_header) do { \
|
||||
(zip_header).formatted.version = SWAP_LE16((zip_header).formatted.version ); \
|
||||
(zip_header).formatted.flags = SWAP_LE16((zip_header).formatted.flags ); \
|
||||
(zip_header).formatted.method = SWAP_LE16((zip_header).formatted.method ); \
|
||||
@@ -82,9 +77,138 @@ struct BUG_zip_header_must_be_26_bytes {
|
||||
(zip_header).formatted.extra_len = SWAP_LE16((zip_header).formatted.extra_len ); \
|
||||
} while (0)
|
||||
|
||||
static void unzip_skip(int fd, off_t skip)
|
||||
#define CDS_HEADER_LEN 42
|
||||
|
||||
typedef union {
|
||||
uint8_t raw[CDS_HEADER_LEN];
|
||||
struct {
|
||||
/* uint32_t signature; 50 4b 01 02 */
|
||||
uint16_t version_made_by; /* 0-1 */
|
||||
uint16_t version_needed; /* 2-3 */
|
||||
uint16_t cds_flags; /* 4-5 */
|
||||
uint16_t method; /* 6-7 */
|
||||
uint16_t mtime; /* 8-9 */
|
||||
uint16_t mdate; /* 10-11 */
|
||||
uint32_t crc32; /* 12-15 */
|
||||
uint32_t cmpsize; /* 16-19 */
|
||||
uint32_t ucmpsize; /* 20-23 */
|
||||
uint16_t file_name_length; /* 24-25 */
|
||||
uint16_t extra_field_length; /* 26-27 */
|
||||
uint16_t file_comment_length; /* 28-29 */
|
||||
uint16_t disk_number_start; /* 30-31 */
|
||||
uint16_t internal_file_attributes; /* 32-33 */
|
||||
uint32_t external_file_attributes PACKED; /* 34-37 */
|
||||
uint32_t relative_offset_of_local_header PACKED; /* 38-41 */
|
||||
} formatted PACKED;
|
||||
} cds_header_t;
|
||||
|
||||
struct BUG_cds_header_must_be_42_bytes {
|
||||
char BUG_cds_header_must_be_42_bytes[
|
||||
offsetof(cds_header_t, formatted.relative_offset_of_local_header) + 4
|
||||
== CDS_HEADER_LEN ? 1 : -1];
|
||||
};
|
||||
|
||||
#define FIX_ENDIANNESS_CDS(cds_header) do { \
|
||||
(cds_header).formatted.crc32 = SWAP_LE32((cds_header).formatted.crc32 ); \
|
||||
(cds_header).formatted.cmpsize = SWAP_LE32((cds_header).formatted.cmpsize ); \
|
||||
(cds_header).formatted.ucmpsize = SWAP_LE32((cds_header).formatted.ucmpsize ); \
|
||||
(cds_header).formatted.file_name_length = SWAP_LE16((cds_header).formatted.file_name_length); \
|
||||
(cds_header).formatted.extra_field_length = SWAP_LE16((cds_header).formatted.extra_field_length); \
|
||||
(cds_header).formatted.file_comment_length = SWAP_LE16((cds_header).formatted.file_comment_length); \
|
||||
} while (0)
|
||||
|
||||
#define CDE_HEADER_LEN 16
|
||||
|
||||
typedef union {
|
||||
uint8_t raw[CDE_HEADER_LEN];
|
||||
struct {
|
||||
/* uint32_t signature; 50 4b 05 06 */
|
||||
uint16_t this_disk_no;
|
||||
uint16_t disk_with_cds_no;
|
||||
uint16_t cds_entries_on_this_disk;
|
||||
uint16_t cds_entries_total;
|
||||
uint32_t cds_size;
|
||||
uint32_t cds_offset;
|
||||
/* uint16_t file_comment_length; */
|
||||
/* .ZIP file comment (variable size) */
|
||||
} formatted PACKED;
|
||||
} cde_header_t;
|
||||
|
||||
struct BUG_cde_header_must_be_16_bytes {
|
||||
char BUG_cde_header_must_be_16_bytes[
|
||||
sizeof(cde_header_t) == CDE_HEADER_LEN ? 1 : -1];
|
||||
};
|
||||
|
||||
#define FIX_ENDIANNESS_CDE(cde_header) do { \
|
||||
(cde_header).formatted.cds_offset = SWAP_LE16((cde_header).formatted.cds_offset); \
|
||||
} while (0)
|
||||
|
||||
enum { zip_fd = 3 };
|
||||
|
||||
|
||||
#if ENABLE_DESKTOP
|
||||
/* NB: does not preserve file position! */
|
||||
static uint32_t find_cds_offset(void)
|
||||
{
|
||||
bb_copyfd_exact_size(fd, -1, skip);
|
||||
unsigned char buf[1024];
|
||||
cde_header_t cde_header;
|
||||
unsigned char *p;
|
||||
off_t end;
|
||||
|
||||
end = xlseek(zip_fd, 0, SEEK_END);
|
||||
if (end < 1024)
|
||||
end = 1024;
|
||||
end -= 1024;
|
||||
xlseek(zip_fd, end, SEEK_SET);
|
||||
full_read(zip_fd, buf, 1024);
|
||||
|
||||
p = buf;
|
||||
while (p <= buf + 1024 - CDE_HEADER_LEN - 4) {
|
||||
if (*p != 'P') {
|
||||
p++;
|
||||
continue;
|
||||
}
|
||||
if (*++p != 'K')
|
||||
continue;
|
||||
if (*++p != 5)
|
||||
continue;
|
||||
if (*++p != 6)
|
||||
continue;
|
||||
/* we found CDE! */
|
||||
memcpy(cde_header.raw, p + 1, CDE_HEADER_LEN);
|
||||
FIX_ENDIANNESS_CDE(cde_header);
|
||||
return cde_header.formatted.cds_offset;
|
||||
}
|
||||
bb_error_msg_and_die("can't find file table");
|
||||
};
|
||||
|
||||
static uint32_t read_next_cds(int count_m1, uint32_t cds_offset, cds_header_t *cds_ptr)
|
||||
{
|
||||
off_t org;
|
||||
|
||||
org = xlseek(zip_fd, 0, SEEK_CUR);
|
||||
|
||||
if (!cds_offset)
|
||||
cds_offset = find_cds_offset();
|
||||
|
||||
while (count_m1-- >= 0) {
|
||||
xlseek(zip_fd, cds_offset + 4, SEEK_SET);
|
||||
xread(zip_fd, cds_ptr->raw, CDS_HEADER_LEN);
|
||||
FIX_ENDIANNESS_CDS(*cds_ptr);
|
||||
cds_offset += 4 + CDS_HEADER_LEN
|
||||
+ cds_ptr->formatted.file_name_length
|
||||
+ cds_ptr->formatted.extra_field_length
|
||||
+ cds_ptr->formatted.file_comment_length;
|
||||
}
|
||||
|
||||
xlseek(zip_fd, org, SEEK_SET);
|
||||
return cds_offset;
|
||||
};
|
||||
#endif
|
||||
|
||||
static void unzip_skip(off_t skip)
|
||||
{
|
||||
bb_copyfd_exact_size(zip_fd, -1, skip);
|
||||
}
|
||||
|
||||
static void unzip_create_leading_dirs(const char *fn)
|
||||
@@ -97,17 +221,17 @@ static void unzip_create_leading_dirs(const char *fn)
|
||||
free(name);
|
||||
}
|
||||
|
||||
static void unzip_extract(zip_header_t *zip_header, int src_fd, int dst_fd)
|
||||
static void unzip_extract(zip_header_t *zip_header, int dst_fd)
|
||||
{
|
||||
if (zip_header->formatted.method == 0) {
|
||||
/* Method 0 - stored (not compressed) */
|
||||
off_t size = zip_header->formatted.ucmpsize;
|
||||
if (size)
|
||||
bb_copyfd_exact_size(src_fd, dst_fd, size);
|
||||
bb_copyfd_exact_size(zip_fd, dst_fd, size);
|
||||
} else {
|
||||
/* Method 8 - inflate */
|
||||
inflate_unzip_result res;
|
||||
if (inflate_unzip(&res, zip_header->formatted.cmpsize, src_fd, dst_fd) < 0)
|
||||
if (inflate_unzip(&res, zip_header->formatted.cmpsize, zip_fd, dst_fd) < 0)
|
||||
bb_error_msg_and_die("inflate error");
|
||||
/* Validate decompression - crc */
|
||||
if (zip_header->formatted.crc32 != (res.crc ^ 0xffffffffL)) {
|
||||
@@ -131,9 +255,12 @@ int unzip_main(int argc, char **argv)
|
||||
smallint verbose = 1;
|
||||
smallint listing = 0;
|
||||
smallint overwrite = O_PROMPT;
|
||||
#if ENABLE_DESKTOP
|
||||
uint32_t cds_offset;
|
||||
unsigned cds_entries;
|
||||
#endif
|
||||
unsigned total_size;
|
||||
unsigned total_entries;
|
||||
int src_fd = -1;
|
||||
int dst_fd = -1;
|
||||
char *src_fn = NULL;
|
||||
char *dst_fn = NULL;
|
||||
@@ -221,13 +348,14 @@ int unzip_main(int argc, char **argv)
|
||||
|
||||
/* Open input file */
|
||||
if (LONE_DASH(src_fn)) {
|
||||
src_fd = STDIN_FILENO;
|
||||
xdup2(STDIN_FILENO, zip_fd);
|
||||
/* Cannot use prompt mode since zip data is arriving on STDIN */
|
||||
if (overwrite == O_PROMPT)
|
||||
overwrite = O_NEVER;
|
||||
} else {
|
||||
static const char extn[][5] = {"", ".zip", ".ZIP"};
|
||||
int orig_src_fn_len = strlen(src_fn);
|
||||
int src_fd = -1;
|
||||
|
||||
for (i = 0; (i < 3) && (src_fd == -1); i++) {
|
||||
strcpy(src_fn + orig_src_fn_len, extn[i]);
|
||||
@@ -237,6 +365,7 @@ int unzip_main(int argc, char **argv)
|
||||
src_fn[orig_src_fn_len] = '\0';
|
||||
bb_error_msg_and_die("can't open %s, %s.zip, %s.ZIP", src_fn, src_fn, src_fn);
|
||||
}
|
||||
xmove_fd(src_fd, zip_fd);
|
||||
}
|
||||
|
||||
/* Change dir if necessary */
|
||||
@@ -253,30 +382,63 @@ int unzip_main(int argc, char **argv)
|
||||
|
||||
total_size = 0;
|
||||
total_entries = 0;
|
||||
#if ENABLE_DESKTOP
|
||||
cds_entries = 0;
|
||||
cds_offset = 0;
|
||||
#endif
|
||||
while (1) {
|
||||
uint32_t magic;
|
||||
|
||||
/* Check magic number */
|
||||
xread(src_fd, &magic, 4);
|
||||
xread(zip_fd, &magic, 4);
|
||||
/* Central directory? It's at the end, so exit */
|
||||
if (magic == ZIP_CDS_MAGIC)
|
||||
break;
|
||||
#if ENABLE_DESKTOP
|
||||
/* Data descriptor? It was a streaming file, go on */
|
||||
if (magic == ZIP_DD_MAGIC) {
|
||||
/* skip over duplicate crc32, cmpsize and ucmpsize */
|
||||
unzip_skip(3 * 4);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
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);
|
||||
FIX_ENDIANNESS(zip_header);
|
||||
xread(zip_fd, zip_header.raw, ZIP_HEADER_LEN);
|
||||
FIX_ENDIANNESS_ZIP(zip_header);
|
||||
if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) {
|
||||
bb_error_msg_and_die("unsupported method %d", zip_header.formatted.method);
|
||||
}
|
||||
#if !ENABLE_DESKTOP
|
||||
if (zip_header.formatted.flags & 0x0009) {
|
||||
bb_error_msg_and_die("zip flags 1 and 8 are not supported");
|
||||
}
|
||||
#else
|
||||
if (zip_header.formatted.flags & 0x0001) {
|
||||
/* 0x0001 - encrypted */
|
||||
bb_error_msg_and_die("zip flag 1 (encryption) is not supported");
|
||||
}
|
||||
if (zip_header.formatted.flags & 0x0008) {
|
||||
cds_header_t cds_header;
|
||||
/* 0x0008 - streaming. [u]cmpsize can be reliably gotten
|
||||
* only from Central Directory. See unzip_doc.txt */
|
||||
cds_offset = read_next_cds(total_entries - cds_entries, cds_offset, &cds_header);
|
||||
cds_entries = total_entries + 1;
|
||||
zip_header.formatted.crc32 = cds_header.formatted.crc32;
|
||||
zip_header.formatted.cmpsize = cds_header.formatted.cmpsize;
|
||||
zip_header.formatted.ucmpsize = cds_header.formatted.ucmpsize;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Read filename */
|
||||
free(dst_fn);
|
||||
dst_fn = xzalloc(zip_header.formatted.filename_len + 1);
|
||||
xread(src_fd, dst_fn, zip_header.formatted.filename_len);
|
||||
xread(zip_fd, dst_fn, zip_header.formatted.filename_len);
|
||||
|
||||
/* Skip extra header bytes */
|
||||
unzip_skip(src_fd, zip_header.formatted.extra_len);
|
||||
unzip_skip(zip_header.formatted.extra_len);
|
||||
|
||||
/* Filter zip entries */
|
||||
if (find_list_entry(zreject, dst_fn)
|
||||
@@ -297,7 +459,6 @@ int unzip_main(int argc, char **argv)
|
||||
(dostime & 0x000007e0) >> 5,
|
||||
dst_fn);
|
||||
total_size += zip_header.formatted.ucmpsize;
|
||||
total_entries++;
|
||||
} else {
|
||||
/* short listing -- filenames only */
|
||||
puts(dst_fn);
|
||||
@@ -308,7 +469,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("can't stat '%s'", dst_fn);
|
||||
}
|
||||
if (verbose) {
|
||||
printf(" creating: %s\n", dst_fn);
|
||||
@@ -325,10 +486,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("can't stat '%s'", dst_fn);
|
||||
}
|
||||
i = 'y';
|
||||
} else { /* File already exists */
|
||||
@@ -340,12 +501,12 @@ int unzip_main(int argc, char **argv)
|
||||
} else {
|
||||
printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn);
|
||||
if (!fgets(key_buf, sizeof(key_buf), stdin)) {
|
||||
bb_perror_msg_and_die("cannot read input");
|
||||
bb_perror_msg_and_die("can't read input");
|
||||
}
|
||||
i = key_buf[0];
|
||||
}
|
||||
} else { /* File is not regular file */
|
||||
bb_error_msg_and_die("'%s' exists but is not regular file",dst_fn);
|
||||
bb_error_msg_and_die("'%s' exists but is not regular file", dst_fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -361,7 +522,7 @@ int unzip_main(int argc, char **argv)
|
||||
if (verbose) {
|
||||
printf(" inflating: %s\n", dst_fn);
|
||||
}
|
||||
unzip_extract(&zip_header, src_fd, dst_fd);
|
||||
unzip_extract(&zip_header, dst_fd);
|
||||
if (dst_fd != STDOUT_FILENO) {
|
||||
/* closing STDOUT is potentially bad for future business */
|
||||
close(dst_fd);
|
||||
@@ -372,30 +533,26 @@ int unzip_main(int argc, char **argv)
|
||||
overwrite = O_NEVER;
|
||||
case 'n':
|
||||
/* Skip entry data */
|
||||
unzip_skip(src_fd, zip_header.formatted.cmpsize);
|
||||
unzip_skip(zip_header.formatted.cmpsize);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
/* Prompt for new name */
|
||||
printf("new name: ");
|
||||
if (!fgets(key_buf, sizeof(key_buf), stdin)) {
|
||||
bb_perror_msg_and_die("cannot read input");
|
||||
bb_perror_msg_and_die("can't read input");
|
||||
}
|
||||
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);
|
||||
}
|
||||
total_entries++;
|
||||
}
|
||||
|
||||
if (listing && verbose) {
|
||||
|
||||
Binary file not shown.
@@ -95,6 +95,27 @@ 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 FEATURE_SETFONT_TEXTUAL_MAP
|
||||
bool "Support reading textual screen maps"
|
||||
default n
|
||||
depends on SETFONT
|
||||
help
|
||||
Support reading textual screen maps.
|
||||
|
||||
config DEFAULT_SETFONT_DIR
|
||||
string "Default directory for console-tools files"
|
||||
default ""
|
||||
depends on SETFONT
|
||||
help
|
||||
Directory to use if setfont's params are simple filenames
|
||||
(not /path/to/file or ./file). Default is "" (no default directory).
|
||||
|
||||
config SETKEYCODES
|
||||
bool "setkeycodes"
|
||||
default n
|
||||
@@ -108,4 +129,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
|
||||
@@ -19,7 +19,6 @@ int chvt_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
num = xatou_range(argv[1], 1, 63);
|
||||
/* double cast suppresses "cast to ptr from int of different size" */
|
||||
console_make_active(get_console_fd(), 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 ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
||||
int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
return printf("\033[H\033[J") != 6;
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
enum { VT_DISALLOCATE = 0x5608 }; /* free memory associated to vt */
|
||||
|
||||
int deallocvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int deallocvt_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int deallocvt_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
/* num = 0 deallocate all unused consoles */
|
||||
int num = 0;
|
||||
@@ -28,6 +28,6 @@ int deallocvt_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ struct kbentry {
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int dumpkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int dumpkmap_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv)
|
||||
int dumpkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
@@ -32,7 +32,7 @@ int dumpkmap_main(int ATTRIBUTE_UNUSED argc, char ATTRIBUTE_UNUSED **argv)
|
||||
|
||||
/* bb_warn_ignoring_args(argc>=2);*/
|
||||
|
||||
fd = xopen(CURRENT_VC, O_RDWR);
|
||||
fd = get_console_fd_or_die();
|
||||
|
||||
write(STDOUT_FILENO, "bkeymap", 7);
|
||||
|
||||
|
||||
+18
-18
@@ -2,39 +2,37 @@
|
||||
/*
|
||||
* Mini kbd_mode implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2007 Loïc Grenié <loic.grenie@gmail.com>
|
||||
* Copyright (C) 2007 Loic Grenie <loic.grenie@gmail.com>
|
||||
* written using Andries Brouwer <aeb@cwi.nl>'s kbd_mode from
|
||||
* console-utils v0.2.3, licensed under GNU GPLv2
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
#include <linux/kd.h>
|
||||
|
||||
int kbd_mode_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int kbd_mode_main(int ATTRIBUTE_UNUSED argc, char **argv)
|
||||
int kbd_mode_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
enum {
|
||||
SCANCODE = (1 << 0),
|
||||
ASCII = (1 << 1),
|
||||
MEDIUMRAW = (1 << 2),
|
||||
UNICODE = (1 << 3),
|
||||
};
|
||||
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();
|
||||
/* if (fd < 0)
|
||||
return EXIT_FAILURE;
|
||||
*/
|
||||
const char *tty_name = CURRENT_TTY;
|
||||
|
||||
opt = getopt32(argv, "sakuC:", &tty_name);
|
||||
fd = xopen(tty_name, O_NONBLOCK);
|
||||
opt &= 0xf; /* clear -C bit, see (*) */
|
||||
|
||||
if (!opt) { /* print current setting */
|
||||
const char *mode = "unknown";
|
||||
int m;
|
||||
|
||||
ioctl(fd, KDGKBMODE, &m);
|
||||
xioctl(fd, KDGKBMODE, &m);
|
||||
if (m == K_RAW)
|
||||
mode = "raw (scancode)";
|
||||
else if (m == K_XLATE)
|
||||
@@ -45,8 +43,10 @@ int kbd_mode_main(int ATTRIBUTE_UNUSED argc, char **argv)
|
||||
mode = "Unicode (UTF-8)";
|
||||
printf("The keyboard is in %s mode\n", mode);
|
||||
} else {
|
||||
/* here we depend on specific bits assigned to options (*) */
|
||||
opt = opt & UNICODE ? 3 : opt >> 1;
|
||||
xioctl(fd, KDSKBMODE, &opt);
|
||||
/* double cast prevents warnings about widening conversion */
|
||||
xioctl(fd, KDSKBMODE, (void*)(ptrdiff_t)opt);
|
||||
}
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
|
||||
+268
-78
@@ -10,6 +10,28 @@
|
||||
#include "libbb.h"
|
||||
#include <sys/kd.h>
|
||||
|
||||
#ifndef KDFONTOP
|
||||
#define KDFONTOP 0x4B72
|
||||
struct console_font_op {
|
||||
unsigned op; /* KD_FONT_OP_* */
|
||||
unsigned flags; /* KD_FONT_FLAG_* */
|
||||
unsigned width, height;
|
||||
unsigned charcount;
|
||||
unsigned char *data; /* font data with height fixed to 32 */
|
||||
};
|
||||
|
||||
#define KD_FONT_OP_SET 0 /* Set font */
|
||||
#define KD_FONT_OP_GET 1 /* Get font */
|
||||
#define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default,
|
||||
data points to name / NULL */
|
||||
#define KD_FONT_OP_COPY 3 /* Copy from another console */
|
||||
|
||||
#define KD_FONT_FLAG_OLD 0x80000000 /* Invoked via old interface */
|
||||
#define KD_FONT_FLAG_DONT_RECALC 1 /* Don't call adjust_height() */
|
||||
/* (Used internally for PIO_FONT support) */
|
||||
#endif /* KDFONTOP */
|
||||
|
||||
|
||||
enum {
|
||||
PSF_MAGIC1 = 0x36,
|
||||
PSF_MAGIC2 = 0x04,
|
||||
@@ -17,7 +39,7 @@ enum {
|
||||
PSF_MODE512 = 0x01,
|
||||
PSF_MODEHASTAB = 0x02,
|
||||
PSF_MAXMODE = 0x03,
|
||||
PSF_SEPARATOR = 0xFFFF
|
||||
PSF_SEPARATOR = 0xffff
|
||||
};
|
||||
|
||||
struct psf_header {
|
||||
@@ -26,7 +48,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,10 +59,31 @@ 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);
|
||||
|
||||
{ /* KDFONTOP */
|
||||
struct console_font_op cfo;
|
||||
|
||||
cfo.op = KD_FONT_OP_SET;
|
||||
cfo.flags = 0;
|
||||
cfo.width = 8;
|
||||
cfo.height = unit;
|
||||
cfo.charcount = fontsize;
|
||||
cfo.data = (void*)buf;
|
||||
#if 0
|
||||
if (!ioctl_or_perror(fd, KDFONTOP, &cfo, "KDFONTOP ioctl failed (will try PIO_FONTX)"))
|
||||
goto ret; /* success */
|
||||
#else
|
||||
xioctl(fd, KDFONTOP, &cfo);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* These ones do not honour -C tty (they set font on current tty regardless)
|
||||
* On x86, this distinction is visible on framebuffer consoles
|
||||
* (regular character consoles may have only one shared font anyway)
|
||||
*/
|
||||
#if defined(PIO_FONTX) && !defined(__sparc__)
|
||||
{
|
||||
struct consolefontdesc cfd;
|
||||
@@ -50,16 +93,16 @@ static void do_loadfont(int fd, unsigned char *inbuf, int unit, int fontsize)
|
||||
cfd.chardata = buf;
|
||||
|
||||
if (!ioctl_or_perror(fd, PIO_FONTX, &cfd, "PIO_FONTX ioctl failed (will try PIO_FONT)"))
|
||||
goto ret; /* success */
|
||||
goto ret; /* success */
|
||||
}
|
||||
#endif
|
||||
xioctl(fd, PIO_FONT, buf);
|
||||
ret:
|
||||
#endif /* 0 */
|
||||
free(buf);
|
||||
}
|
||||
|
||||
static void
|
||||
do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
static void do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
{
|
||||
struct unimapinit advice;
|
||||
struct unimapdesc ud;
|
||||
@@ -68,7 +111,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 +139,233 @@ 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 = 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 ATTRIBUTE_UNUSED)
|
||||
{
|
||||
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
|
||||
|
||||
/*
|
||||
kbd-1.12:
|
||||
|
||||
setfont [-O font+umap.orig] [-o font.orig] [-om cmap.orig]
|
||||
[-ou umap.orig] [-N] [font.new ...] [-m cmap] [-u umap] [-C console]
|
||||
[-hNN] [-v] [-V]
|
||||
|
||||
-h NN Override font height
|
||||
-o file
|
||||
Save previous font in file
|
||||
-O file
|
||||
Save previous font and Unicode map in file
|
||||
-om file
|
||||
Store console map in file
|
||||
-ou file
|
||||
Save previous Unicode map in file
|
||||
-m file
|
||||
Load console map or Unicode console map from file
|
||||
-u file
|
||||
Load Unicode table describing the font from file
|
||||
Example:
|
||||
# cp866
|
||||
0x00-0x7f idem
|
||||
#
|
||||
0x80 U+0410 # CYRILLIC CAPITAL LETTER A
|
||||
0x81 U+0411 # CYRILLIC CAPITAL LETTER BE
|
||||
0x82 U+0412 # CYRILLIC CAPITAL LETTER VE
|
||||
-C console
|
||||
Set the font for the indicated console
|
||||
-v Verbose
|
||||
-V Version
|
||||
*/
|
||||
|
||||
#if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
|
||||
static int ctoi(char *s)
|
||||
{
|
||||
if (s[0] == '\'' && s[1] != '\0' && s[2] == '\'' && s[3] == '\0')
|
||||
return s[1];
|
||||
// U+ means 0x
|
||||
if (s[0] == 'U' && s[1] == '+') {
|
||||
s[0] = '0';
|
||||
s[1] = 'x';
|
||||
}
|
||||
if (!isdigit(s[0]))
|
||||
return -1;
|
||||
return xstrtoul(s, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
int setfont_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setfont_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
size_t len;
|
||||
unsigned opts;
|
||||
int fd;
|
||||
struct psf_header *psfhdr;
|
||||
char *mapfilename;
|
||||
const char *tty_name = CURRENT_TTY;
|
||||
|
||||
opt_complementary = "=1";
|
||||
opts = getopt32(argv, "m:C:", &mapfilename, &tty_name);
|
||||
argv += optind;
|
||||
|
||||
fd = xopen(tty_name, O_NONBLOCK);
|
||||
|
||||
if (sizeof(CONFIG_DEFAULT_SETFONT_DIR) > 1) { // if not ""
|
||||
if (*argv[0] != '/') {
|
||||
// goto default fonts location. don't die if doesn't exist
|
||||
chdir(CONFIG_DEFAULT_SETFONT_DIR "/consolefonts");
|
||||
}
|
||||
}
|
||||
// load font
|
||||
len = 32*1024; // can't be larger
|
||||
psfhdr = xmalloc_open_zipped_read_close(*argv, &len);
|
||||
if (!psfhdr)
|
||||
bb_simple_perror_msg_and_die(*argv);
|
||||
do_load(fd, psfhdr, len);
|
||||
|
||||
// load the screen map, if any
|
||||
if (opts & 1) { // -m
|
||||
unsigned mode = PIO_SCRNMAP;
|
||||
void *map;
|
||||
|
||||
if (sizeof(CONFIG_DEFAULT_SETFONT_DIR) > 1) { // if not ""
|
||||
if (mapfilename[0] != '/') {
|
||||
// goto default keymaps location
|
||||
chdir(CONFIG_DEFAULT_SETFONT_DIR "/consoletrans");
|
||||
}
|
||||
}
|
||||
// fetch keymap
|
||||
map = xmalloc_open_zipped_read_close(mapfilename, &len);
|
||||
if (!map)
|
||||
bb_simple_perror_msg_and_die(mapfilename);
|
||||
// file size is 256 or 512 bytes? -> assume binary map
|
||||
if (len == E_TABSZ || len == 2*E_TABSZ) {
|
||||
if (len == 2*E_TABSZ)
|
||||
mode = PIO_UNISCRNMAP;
|
||||
}
|
||||
#if ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
|
||||
// assume textual Unicode console maps:
|
||||
// 0x00 U+0000 # NULL (NUL)
|
||||
// 0x01 U+0001 # START OF HEADING (SOH)
|
||||
// 0x02 U+0002 # START OF TEXT (STX)
|
||||
// 0x03 U+0003 # END OF TEXT (ETX)
|
||||
else {
|
||||
int i;
|
||||
char *token[2];
|
||||
parser_t *parser;
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(map);
|
||||
map = xmalloc(E_TABSZ * sizeof(unsigned short));
|
||||
|
||||
#define unicodes ((unsigned short *)map)
|
||||
// fill vanilla map
|
||||
for (i = 0; i < E_TABSZ; i++)
|
||||
unicodes[i] = 0xf000 + i;
|
||||
|
||||
parser = config_open(mapfilename);
|
||||
while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL | PARSE_MIN_DIE)) {
|
||||
// parse code/value pair
|
||||
int a = ctoi(token[0]);
|
||||
int b = ctoi(token[1]);
|
||||
if (a < 0 || a >= E_TABSZ
|
||||
|| b < 0 || b > 65535
|
||||
) {
|
||||
bb_error_msg_and_die("map format");
|
||||
}
|
||||
// patch map
|
||||
unicodes[a] = b;
|
||||
// unicode character is met?
|
||||
if (b > 255)
|
||||
mode = PIO_UNISCRNMAP;
|
||||
}
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
config_close(parser);
|
||||
|
||||
if (mode != PIO_UNISCRNMAP) {
|
||||
#define asciis ((unsigned char *)map)
|
||||
for (i = 0; i < E_TABSZ; i++)
|
||||
asciis[i] = unicodes[i];
|
||||
#undef asciis
|
||||
}
|
||||
#undef unicodes
|
||||
}
|
||||
#endif // ENABLE_FEATURE_SETFONT_TEXTUAL_MAP
|
||||
|
||||
// do set screen map
|
||||
xioctl(fd, mode, map);
|
||||
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(map);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
@@ -5,9 +5,7 @@
|
||||
* Copyright (C) 1998 Enrique Zanardi <ezanardi@ull.es>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
#define BINARY_KEYMAP_MAGIC "bkeymap"
|
||||
@@ -26,16 +24,20 @@ struct kbentry {
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
|
||||
int loadkmap_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int loadkmap_main(int ATTRIBUTE_UNUSED argc, char **argv ATTRIBUTE_UNUSED)
|
||||
int loadkmap_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
uint16_t ibuff[NR_KEYS];
|
||||
/* const char *tty_name = CURRENT_TTY; */
|
||||
RESERVE_CONFIG_BUFFER(flags,MAX_NR_KEYMAPS);
|
||||
|
||||
/* bb_warn_ignoring_args(argc>=2);*/
|
||||
|
||||
fd = xopen(CURRENT_VC, O_RDWR);
|
||||
/* bb_warn_ignoring_args(argc >= 2); */
|
||||
fd = get_console_fd_or_die();
|
||||
/* or maybe:
|
||||
opt = getopt32(argv, "C:", &tty_name);
|
||||
fd = xopen(tty_name, O_NONBLOCK);
|
||||
*/
|
||||
|
||||
xread(STDIN_FILENO, flags, 7);
|
||||
if (strncmp(flags, BINARY_KEYMAP_MAGIC, 7))
|
||||
|
||||
@@ -105,7 +105,7 @@ static NOINLINE void vfork_child(char **argv)
|
||||
}
|
||||
|
||||
int openvt_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int openvt_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int openvt_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
char vtname[sizeof(VC_FORMAT) + sizeof(int)*3];
|
||||
struct vt_stat vtstat;
|
||||
|
||||
@@ -18,7 +18,7 @@ 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 ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
||||
int reset_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
static const char *const args[] = {
|
||||
"stty", "sane", NULL
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* resize - set terminal width and height.
|
||||
*
|
||||
* Copyright 2006 Bernhard Fischer
|
||||
* Copyright 2006 Bernhard Reutner-Fischer
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
@@ -14,14 +14,14 @@
|
||||
#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(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int resize_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int resize_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
|
||||
int resize_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
|
||||
{
|
||||
struct termios new;
|
||||
struct winsize w = { 0, 0, 0, 0 };
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* setconsole.c - redirect system console output
|
||||
*
|
||||
* Copyright (C) 2004,2005 Enrik Berkhan <Enrik.Berkhan@inka.de>
|
||||
* Copyright (C) 2008 Bernhard Fischer
|
||||
* Copyright (C) 2008 Bernhard Reutner-Fischer
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "libbb.h"
|
||||
|
||||
int setconsole_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setconsole_main(int ATTRIBUTE_UNUSED argc, char **argv)
|
||||
int setconsole_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
const char *device = CURRENT_TTY;
|
||||
bool reset;
|
||||
|
||||
@@ -26,11 +26,11 @@ 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 = xatou_range(argv[2], 0, 127);
|
||||
@@ -40,7 +40,7 @@ int setkeycodes_main(int argc, char **argv)
|
||||
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,7 +12,7 @@
|
||||
#include "libbb.h"
|
||||
|
||||
int setlogcons_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int setlogcons_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int setlogcons_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
struct {
|
||||
char fn;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
+34
-18
@@ -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
|
||||
@@ -135,12 +136,12 @@ config DF
|
||||
df reports the amount of disk space used and available
|
||||
on filesystems.
|
||||
|
||||
config FEATURE_DF_INODE
|
||||
bool "Enable -i (inode information)"
|
||||
config FEATURE_DF_FANCY
|
||||
bool "Enable -a, -i, -B"
|
||||
default n
|
||||
depends on DF
|
||||
help
|
||||
This option enables support for df -i.
|
||||
This option enables -a, -i and -B.
|
||||
|
||||
config DIRNAME
|
||||
bool "dirname"
|
||||
@@ -188,7 +189,7 @@ config ECHO
|
||||
config FEATURE_FANCY_ECHO
|
||||
bool "Enable echo options (-n and -e)"
|
||||
default y
|
||||
depends on ECHO
|
||||
depends on ECHO || ASH_BUILTIN_ECHO
|
||||
help
|
||||
This adds options (-n and -e) to echo.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -509,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
|
||||
@@ -532,9 +548,9 @@ config FEATURE_SORT_BIG
|
||||
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
|
||||
@@ -566,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
|
||||
@@ -627,13 +643,13 @@ 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
|
||||
bool "Extend test to 64 bit"
|
||||
default n
|
||||
depends on TEST
|
||||
depends on TEST || ASH_BUILTIN_TEST
|
||||
help
|
||||
Enable 64-bit support in test.
|
||||
|
||||
@@ -738,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"
|
||||
|
||||
@@ -48,5 +48,6 @@ int basename_main(int argc, char **argv)
|
||||
|
||||
/* 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;
|
||||
/* NB: != is correct here: */
|
||||
return full_write(STDOUT_FILENO, s, m) != (ssize_t)m;
|
||||
}
|
||||
+5
-3
@@ -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 {
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ int bb_cat(char **argv)
|
||||
}
|
||||
|
||||
int cat_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int cat_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int cat_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
getopt32(argv, "u");
|
||||
argv += optind;
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
#include "libbb.h"
|
||||
|
||||
int catv_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int catv_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int catv_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
int fd;
|
||||
|
||||
+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 ATTRIBUTE_UNUSED, char **argv)
|
||||
int chmod_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
char *arg, **argp;
|
||||
|
||||
+32
-22
@@ -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 ATTRIBUTE_UNUSED)
|
||||
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,25 +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 ATTRIBUTE_UNUSED, 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 */
|
||||
@@ -88,7 +98,7 @@ int chown_main(int argc ATTRIBUTE_UNUSED, 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++;
|
||||
@@ -97,7 +107,7 @@ int chown_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
flags, /* flags */
|
||||
fileAction, /* file action */
|
||||
fileAction, /* dir action */
|
||||
chown_func, /* user data */
|
||||
¶m, /* user data */
|
||||
0) /* depth */
|
||||
) {
|
||||
retval = EXIT_FAILURE;
|
||||
|
||||
+14
-6
@@ -9,11 +9,11 @@
|
||||
#include "libbb.h"
|
||||
|
||||
int cksum_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int cksum_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int cksum_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
uint32_t *crc32_table = crc32_filltable(NULL, 1);
|
||||
uint32_t crc;
|
||||
long length, filesize;
|
||||
off_t length, filesize;
|
||||
int bytes_read;
|
||||
uint8_t *cp;
|
||||
|
||||
@@ -44,11 +44,19 @@ int cksum_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
|
||||
filesize = length;
|
||||
|
||||
for (; length; length >>= 8)
|
||||
crc = (crc << 8) ^ crc32_table[((crc >> 24) ^ length) & 0xff];
|
||||
crc ^= 0xffffffffL;
|
||||
while (length) {
|
||||
crc = (crc << 8) ^ crc32_table[(uint8_t)(crc >> 24) ^ (uint8_t)length];
|
||||
/* must ensure that shift is unsigned! */
|
||||
if (sizeof(length) <= sizeof(unsigned))
|
||||
length = (unsigned)length >> 8;
|
||||
else if (sizeof(length) <= sizeof(unsigned long))
|
||||
length = (unsigned long)length >> 8;
|
||||
else
|
||||
length = (unsigned long long)length >> 8;
|
||||
}
|
||||
crc = ~crc;
|
||||
|
||||
printf((*argv ? "%" PRIu32 " %li %s\n" : "%" PRIu32 " %li\n"),
|
||||
printf((*argv ? "%"PRIu32" %"OFF_FMT"i %s\n" : "%"PRIu32" %"OFF_FMT"i\n"),
|
||||
crc, filesize, *argv);
|
||||
} while (*argv && *++argv);
|
||||
|
||||
|
||||
+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 ATTRIBUTE_UNUSED, 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;
|
||||
|
||||
+36
-28
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Mark Whitley <markw@codepoet.org>
|
||||
* debloated by Bernhard Fischer
|
||||
* debloated by Bernhard Reutner-Fischer
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
@@ -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_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 < (int)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 */
|
||||
@@ -89,7 +89,8 @@ static void cut_file(FILE *file, char delim)
|
||||
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)
|
||||
@@ -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 ATTRIBUTE_UNUSED, 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 ATTRIBUTE_UNUSED, 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);
|
||||
@@ -231,8 +236,8 @@ int cut_main(int argc ATTRIBUTE_UNUSED, 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 ATTRIBUTE_UNUSED, 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 */
|
||||
@@ -268,7 +276,7 @@ int cut_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
retval = EXIT_FAILURE;
|
||||
continue;
|
||||
}
|
||||
cut_file(file, delim);
|
||||
cut_file(file, delim, cut_lists, nlists);
|
||||
fclose_if_not_stdin(file);
|
||||
} while (*++argv);
|
||||
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
* by Matthew Grant <grantma@anathoth.gen.nz>
|
||||
*
|
||||
* iso-format handling added by Robert Griebl <griebl@gmx.de>
|
||||
* bugfixes and cleanup by Bernhard Fischer
|
||||
* bugfixes and cleanup by Bernhard Reutner-Fischer
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
@@ -39,7 +39,7 @@ static void maybe_set_utc(int opt)
|
||||
}
|
||||
|
||||
int date_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int date_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int date_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
struct tm tm_time;
|
||||
time_t tm;
|
||||
|
||||
+2
-2
@@ -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"
|
||||
@@ -79,7 +79,7 @@ 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 ATTRIBUTE_UNUSED, char **argv)
|
||||
int dd_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
enum {
|
||||
/* Must be in the same order as OP_conv_XXX! */
|
||||
|
||||
+59
-36
@@ -8,7 +8,7 @@
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 _NOT_ compliant -- options -P and -t missing. Also blocksize. */
|
||||
/* BB_AUDIT SUSv3 _NOT_ compliant -- option -t missing. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/df.html */
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
@@ -16,6 +16,10 @@
|
||||
* Size reduction. Removed floating point dependency. Added error checking
|
||||
* on output. Output stats on 0-sized filesystems if specifically listed on
|
||||
* the command line. Properly round *-blocks, Used, and Available quantities.
|
||||
*
|
||||
* Aug 28, 2008 Bernhard Reutner-Fischer
|
||||
*
|
||||
* Implement -P and -B; better coreutils compat; cleanup
|
||||
*/
|
||||
|
||||
#include <mntent.h>
|
||||
@@ -34,51 +38,73 @@ int df_main(int argc, char **argv)
|
||||
{
|
||||
unsigned long blocks_used;
|
||||
unsigned blocks_percent_used;
|
||||
#if ENABLE_FEATURE_HUMAN_READABLE
|
||||
unsigned df_disp_hr = 1024;
|
||||
#endif
|
||||
unsigned long df_disp_hr = 1024;
|
||||
int status = EXIT_SUCCESS;
|
||||
unsigned opt;
|
||||
FILE *mount_table;
|
||||
struct mntent *mount_entry;
|
||||
struct statfs s;
|
||||
/* default display is kilobytes */
|
||||
const char *disp_units_hdr = "1k-blocks";
|
||||
static const char ignored_mounts[] ALIGN1 =
|
||||
"rootfs\0";
|
||||
|
||||
enum {
|
||||
OPT_ALL = (1 << 0),
|
||||
OPT_INODE = (ENABLE_FEATURE_HUMAN_READABLE ? (1 << 4) : (1 << 2))
|
||||
* ENABLE_FEATURE_DF_INODE
|
||||
OPT_KILO = (1 << 0),
|
||||
OPT_POSIX = (1 << 1),
|
||||
OPT_ALL = (1 << 2) * ENABLE_FEATURE_DF_FANCY,
|
||||
OPT_INODE = (1 << 3) * ENABLE_FEATURE_DF_FANCY,
|
||||
OPT_BSIZE = (1 << 4) * ENABLE_FEATURE_DF_FANCY,
|
||||
OPT_HUMAN = (1 << 5) * ENABLE_FEATURE_HUMAN_READABLE,
|
||||
OPT_MEGA = (1 << 6) * ENABLE_FEATURE_HUMAN_READABLE,
|
||||
};
|
||||
const char *disp_units_hdr = NULL;
|
||||
char *chp;
|
||||
|
||||
#if ENABLE_FEATURE_HUMAN_READABLE
|
||||
opt_complementary = "h-km:k-hm:m-hk";
|
||||
opt = getopt32(argv, "ahmk" USE_FEATURE_DF_INODE("i"));
|
||||
if (opt & (1 << 1)) { // -h
|
||||
#if ENABLE_FEATURE_HUMAN_READABLE && ENABLE_FEATURE_DF_FANCY
|
||||
opt_complementary = "k-mB:m-Bk:B-km";
|
||||
#elif ENABLE_FEATURE_HUMAN_READABLE
|
||||
opt_complementary = "k-m:m-k";
|
||||
#endif
|
||||
opt = getopt32(argv, "kP"
|
||||
USE_FEATURE_DF_FANCY("aiB:")
|
||||
USE_FEATURE_HUMAN_READABLE("hm")
|
||||
USE_FEATURE_DF_FANCY(, &chp));
|
||||
if (opt & OPT_MEGA)
|
||||
df_disp_hr = 1024*1024;
|
||||
|
||||
if (opt & OPT_BSIZE)
|
||||
df_disp_hr = xatoul_range(chp, 1, ULONG_MAX); /* disallow 0 */
|
||||
|
||||
/* From the manpage of df from coreutils-6.10:
|
||||
Disk space is shown in 1K blocks by default, unless the environment
|
||||
variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.
|
||||
*/
|
||||
if (getenv("POSIXLY_CORRECT")) /* TODO - a new libbb function? */
|
||||
df_disp_hr = 512;
|
||||
|
||||
if (opt & OPT_HUMAN) {
|
||||
df_disp_hr = 0;
|
||||
disp_units_hdr = " Size";
|
||||
}
|
||||
if (opt & (1 << 2)) { // -m
|
||||
df_disp_hr = 1024*1024;
|
||||
disp_units_hdr = "1M-blocks";
|
||||
}
|
||||
if (opt & OPT_INODE) {
|
||||
if (opt & OPT_INODE)
|
||||
disp_units_hdr = " Inodes";
|
||||
}
|
||||
#else
|
||||
opt = getopt32(argv, "ak" USE_FEATURE_DF_INODE("i"));
|
||||
#endif
|
||||
|
||||
printf("Filesystem %-15sUsed Available Use%% Mounted on\n",
|
||||
disp_units_hdr);
|
||||
if (disp_units_hdr == NULL) {
|
||||
#if ENABLE_FEATURE_HUMAN_READABLE
|
||||
disp_units_hdr = xasprintf("%s-blocks",
|
||||
make_human_readable_str(df_disp_hr, 0, !!(opt & OPT_POSIX)));
|
||||
#else
|
||||
disp_units_hdr = xasprintf("%lu-blocks", df_disp_hr);
|
||||
#endif
|
||||
}
|
||||
printf("Filesystem %-15sUsed Available %s Mounted on\n",
|
||||
disp_units_hdr, (opt & OPT_POSIX) ? "Capacity" : "Use%");
|
||||
|
||||
mount_table = NULL;
|
||||
argv += optind;
|
||||
if (optind >= argc) {
|
||||
mount_table = setmntent(bb_path_mtab_file, "r");
|
||||
if (!mount_table) {
|
||||
if (!mount_table)
|
||||
bb_perror_msg_and_die(bb_path_mtab_file);
|
||||
}
|
||||
}
|
||||
|
||||
while (1) {
|
||||
@@ -93,9 +119,8 @@ int df_main(int argc, char **argv)
|
||||
}
|
||||
} else {
|
||||
mount_point = *argv++;
|
||||
if (!mount_point) {
|
||||
if (!mount_point)
|
||||
break;
|
||||
}
|
||||
mount_entry = find_mount_point(mount_point, bb_path_mtab_file);
|
||||
if (!mount_entry) {
|
||||
bb_error_msg("%s: can't find mount point", mount_point);
|
||||
@@ -118,10 +143,9 @@ int df_main(int argc, char **argv)
|
||||
s.f_blocks = s.f_files;
|
||||
s.f_bavail = s.f_bfree = s.f_ffree;
|
||||
s.f_bsize = 1;
|
||||
#if ENABLE_FEATURE_HUMAN_READABLE
|
||||
|
||||
if (df_disp_hr)
|
||||
df_disp_hr = 1;
|
||||
#endif
|
||||
}
|
||||
blocks_used = s.f_blocks - s.f_bfree;
|
||||
blocks_percent_used = 0;
|
||||
@@ -131,11 +155,10 @@ int df_main(int argc, char **argv)
|
||||
) / (blocks_used + s.f_bavail);
|
||||
}
|
||||
|
||||
#ifdef WHY_IT_SHOULD_BE_HIDDEN
|
||||
if (strcmp(device, "rootfs") == 0) {
|
||||
/* GNU coreutils 6.10 skip certain mounts, try to be compatible. */
|
||||
if (index_in_strings(device, ignored_mounts) != -1)
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WHY_WE_DO_IT_FOR_DEV_ROOT_ONLY
|
||||
/* ... and also this is the only user of find_block_device */
|
||||
if (strcmp(device, "/dev/root") == 0) {
|
||||
@@ -164,12 +187,12 @@ int df_main(int argc, char **argv)
|
||||
#else
|
||||
printf(" %9lu %9lu %9lu %3u%% %s\n",
|
||||
kscale(s.f_blocks, s.f_bsize),
|
||||
kscale(s.f_blocks-s.f_bfree, s.f_bsize),
|
||||
kscale(s.f_blocks - s.f_bfree, s.f_bsize),
|
||||
kscale(s.f_bavail, s.f_bsize),
|
||||
blocks_percent_used, mount_point);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
fflush_stdout_and_exit(status);
|
||||
return status;
|
||||
}
|
||||
@@ -35,7 +35,7 @@ static void convert(char *fn, int conv_type)
|
||||
resolved_fn = xmalloc_follow_symlinks(fn);
|
||||
if (resolved_fn == NULL)
|
||||
bb_simple_perror_msg_and_die(fn);
|
||||
in = xfopen(resolved_fn, "r");
|
||||
in = xfopen_for_read(resolved_fn);
|
||||
fstat(fileno(in), &st);
|
||||
|
||||
temp_fn = xasprintf("%sXXXXXX", resolved_fn);
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ static unsigned long du(const char *filename)
|
||||
}
|
||||
|
||||
int du_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int du_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int du_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
unsigned long total;
|
||||
int slink_depth_save;
|
||||
|
||||
+8
-5
@@ -29,7 +29,7 @@
|
||||
|
||||
/* NB: can be used by shell even if not enabled as applet */
|
||||
|
||||
int echo_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int echo_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
const char *arg;
|
||||
#if !ENABLE_FEATURE_FANCY_ECHO
|
||||
@@ -46,8 +46,11 @@ int echo_main(int argc ATTRIBUTE_UNUSED, 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)
|
||||
@@ -58,8 +61,8 @@ int echo_main(int argc ATTRIBUTE_UNUSED, 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;
|
||||
|
||||
+3
-3
@@ -29,6 +29,8 @@
|
||||
* - use xfunc_error_retval
|
||||
*/
|
||||
|
||||
/* This is a NOEXEC applet. Be very careful! */
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
#if ENABLE_FEATURE_ENV_LONG_OPTIONS
|
||||
@@ -39,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 ATTRIBUTE_UNUSED, char **argv)
|
||||
int env_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
/* cleanenv was static - why? */
|
||||
char *cleanenv[1];
|
||||
@@ -119,5 +121,3 @@ int env_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
+1
-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 ATTRIBUTE_UNUSED, char **argv)
|
||||
int expand_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
/* Default 8 spaces for 1 tab */
|
||||
const char *opt_t = "8";
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
/* 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;
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int hostid_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int hostid_main(int argc, char ATTRIBUTE_UNUSED **argv)
|
||||
int hostid_main(int argc, char **argv UNUSED_PARAM)
|
||||
{
|
||||
if (argc > 1) {
|
||||
bb_show_usage();
|
||||
|
||||
+178
-84
@@ -3,124 +3,218 @@
|
||||
* Mini id implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Randolph Chung <tausq@debian.org>
|
||||
* Copyright (C) 2008 by Tito Ragusa <farmatito@tiscali.it>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 _NOT_ compliant -- option -G is not currently supported. */
|
||||
/* Hacked by Tito Ragusa (C) 2004 to handle usernames of whatever length and to
|
||||
* be more similar to GNU id.
|
||||
/* BB_AUDIT SUSv3 compliant. */
|
||||
/* Hacked by Tito Ragusa (C) 2004 to handle usernames of whatever
|
||||
* length and to be more similar to GNU id.
|
||||
* -Z option support: by Yuichi Nakamura <ynakam@hitachisoft.jp>
|
||||
* Added -G option Tito Ragusa (C) 2008 for SUSv3.
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
#define PRINT_REAL 1
|
||||
#define NAME_NOT_NUMBER 2
|
||||
#define JUST_USER 4
|
||||
#define JUST_GROUP 8
|
||||
#if ENABLE_SELINUX
|
||||
#define JUST_CONTEXT 16
|
||||
#if !ENABLE_USE_BB_PWD_GRP
|
||||
#if defined(__UCLIBC_MAJOR__) && (__UCLIBC_MAJOR__ == 0)
|
||||
#if (__UCLIBC_MINOR__ < 9) || (__UCLIBC_MINOR__ == 9 && __UCLIBC_SUBLEVEL__ < 30)
|
||||
#error "Sorry, you need at least uClibc version 0.9.30 for id applet to build"
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static int printf_full(unsigned int id, const char *arg, const char prefix)
|
||||
{
|
||||
const char *fmt = "%cid=%u";
|
||||
int status = EXIT_FAILURE;
|
||||
enum {
|
||||
PRINT_REAL = (1 << 0),
|
||||
NAME_NOT_NUMBER = (1 << 1),
|
||||
JUST_USER = (1 << 2),
|
||||
JUST_GROUP = (1 << 3),
|
||||
JUST_ALL_GROUPS = (1 << 4),
|
||||
#if ENABLE_SELINUX
|
||||
JUST_CONTEXT = (1 << 5),
|
||||
#endif
|
||||
};
|
||||
|
||||
if (arg) {
|
||||
fmt = "%cid=%u(%s)";
|
||||
status = EXIT_SUCCESS;
|
||||
static int print_common(unsigned id,
|
||||
char* FAST_FUNC bb_getXXXid(char *name, int bufsize, long uid),
|
||||
const char *prefix)
|
||||
{
|
||||
const char *name = bb_getXXXid(NULL, 0, id);
|
||||
|
||||
if (prefix) {
|
||||
printf("%s", prefix);
|
||||
}
|
||||
printf(fmt, prefix, id, arg);
|
||||
return status;
|
||||
if (!(option_mask32 & NAME_NOT_NUMBER) || !name) {
|
||||
printf("%u", id);
|
||||
}
|
||||
if (!option_mask32 || (option_mask32 & NAME_NOT_NUMBER)) {
|
||||
if (name) {
|
||||
printf(option_mask32 ? "%s" : "(%s)", name);
|
||||
} else {
|
||||
/* Don't set error status flag in default mode */
|
||||
if (option_mask32) {
|
||||
if (ENABLE_DESKTOP)
|
||||
bb_error_msg("unknown ID %u", id);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static int print_group(gid_t id, const char *prefix)
|
||||
{
|
||||
return print_common(id, bb_getgrgid, prefix);
|
||||
}
|
||||
|
||||
static int print_user(uid_t id, const char *prefix)
|
||||
{
|
||||
return print_common(id, bb_getpwuid, prefix);
|
||||
}
|
||||
|
||||
/* On error set *n < 0 and return >= 0
|
||||
* If *n is too small, update it and return < 0
|
||||
* (ok to trash groups[] in both cases)
|
||||
* Otherwise fill in groups[] and return >= 0
|
||||
*/
|
||||
static int get_groups(const char *username, gid_t rgid, gid_t *groups, int *n)
|
||||
{
|
||||
int m;
|
||||
|
||||
if (username) {
|
||||
/* If the user is a member of more than
|
||||
* *n groups, then -1 is returned. Otherwise >= 0.
|
||||
* (and no defined way of detecting errors?!) */
|
||||
m = getgrouplist(username, rgid, groups, n);
|
||||
/* I guess *n < 0 might indicate error. Anyway,
|
||||
* malloc'ing -1 bytes won't be good, so: */
|
||||
//if (*n < 0)
|
||||
// return 0;
|
||||
//return m;
|
||||
//commented out here, happens below anyway
|
||||
} else {
|
||||
/* On error -1 is returned, which ends up in *n */
|
||||
int nn = getgroups(*n, groups);
|
||||
/* 0: nn <= *n, groups[] was big enough; -1 otherwise */
|
||||
m = - (nn > *n);
|
||||
*n = nn;
|
||||
}
|
||||
if (*n < 0)
|
||||
return 0; /* error, don't return < 0! */
|
||||
return m;
|
||||
}
|
||||
|
||||
int id_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int id_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int id_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
struct passwd *p;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
unsigned long flags;
|
||||
short status;
|
||||
uid_t ruid;
|
||||
gid_t rgid;
|
||||
uid_t euid;
|
||||
gid_t egid;
|
||||
unsigned opt;
|
||||
int i;
|
||||
int status = EXIT_SUCCESS;
|
||||
const char *prefix;
|
||||
const char *username;
|
||||
#if ENABLE_SELINUX
|
||||
security_context_t scontext;
|
||||
security_context_t scontext = NULL;
|
||||
#endif
|
||||
/* Don't allow -n -r -nr -ug -rug -nug -rnug */
|
||||
/* Don't allow -n -r -nr -ug -rug -nug -rnug -uZ -gZ -GZ*/
|
||||
/* Don't allow more than one username */
|
||||
opt_complementary = "?1:u--g:g--u:r?ug:n?ug" USE_SELINUX(":u--Z:Z--u:g--Z:Z--g");
|
||||
flags = getopt32(argv, "rnug" USE_SELINUX("Z"));
|
||||
opt_complementary = "?1:u--g:g--u:G--u:u--G:g--G:G--g:r?ugG:n?ugG"
|
||||
USE_SELINUX(":u--Z:Z--u:g--Z:Z--g:G--Z:Z--G");
|
||||
opt = getopt32(argv, "rnugG" USE_SELINUX("Z"));
|
||||
|
||||
/* This values could be overwritten later */
|
||||
uid = geteuid();
|
||||
gid = getegid();
|
||||
if (flags & PRINT_REAL) {
|
||||
uid = getuid();
|
||||
gid = getgid();
|
||||
username = argv[optind];
|
||||
if (username) {
|
||||
struct passwd *p = getpwnam(username);
|
||||
if (!p)
|
||||
bb_error_msg_and_die("unknown user %s", username);
|
||||
euid = ruid = p->pw_uid;
|
||||
egid = rgid = p->pw_gid;
|
||||
} else {
|
||||
egid = getegid();
|
||||
rgid = getgid();
|
||||
euid = geteuid();
|
||||
ruid = getuid();
|
||||
}
|
||||
/* JUST_ALL_GROUPS ignores -r PRINT_REAL flag even if man page for */
|
||||
/* id says: print the real ID instead of the effective ID, with -ugG */
|
||||
/* in fact in this case egid is always printed if egid != rgid */
|
||||
if (!opt || (opt & JUST_ALL_GROUPS)) {
|
||||
gid_t *groups;
|
||||
int n;
|
||||
|
||||
if (argv[optind]) {
|
||||
p = getpwnam(argv[optind]);
|
||||
/* xuname2uid is needed because it exits on failure */
|
||||
uid = xuname2uid(argv[optind]);
|
||||
gid = p->pw_gid;
|
||||
/* in this case PRINT_REAL is the same */
|
||||
}
|
||||
|
||||
if (flags & (JUST_GROUP | JUST_USER USE_SELINUX(| JUST_CONTEXT))) {
|
||||
/* JUST_GROUP and JUST_USER are mutually exclusive */
|
||||
if (flags & NAME_NOT_NUMBER) {
|
||||
/* bb_getXXXid(-1) exit on failure, puts cannot segfault */
|
||||
puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid));
|
||||
if (!opt) {
|
||||
/* Default Mode */
|
||||
status |= print_user(ruid, "uid=");
|
||||
status |= print_group(rgid, " gid=");
|
||||
if (euid != ruid)
|
||||
status |= print_user(euid, " euid=");
|
||||
if (egid != rgid)
|
||||
status |= print_group(egid, " egid=");
|
||||
} else {
|
||||
if (flags & JUST_USER) {
|
||||
printf("%u\n", uid);
|
||||
}
|
||||
if (flags & JUST_GROUP) {
|
||||
printf("%u\n", gid);
|
||||
}
|
||||
/* JUST_ALL_GROUPS */
|
||||
status |= print_group(rgid, NULL);
|
||||
if (egid != rgid)
|
||||
status |= print_group(egid, " ");
|
||||
}
|
||||
|
||||
/* We are supplying largish buffer, trying
|
||||
* to not run get_groups() twice. That might be slow
|
||||
* ("user database in remote SQL server" case) */
|
||||
groups = xmalloc(64 * sizeof(gid_t));
|
||||
n = 64;
|
||||
if (get_groups(username, rgid, groups, &n) < 0) {
|
||||
/* Need bigger buffer after all */
|
||||
groups = xrealloc(groups, n * sizeof(gid_t));
|
||||
get_groups(username, rgid, groups, &n);
|
||||
}
|
||||
if (n > 0) {
|
||||
/* Print the list */
|
||||
prefix = " groups=";
|
||||
for (i = 0; i < n; i++) {
|
||||
if (opt && (groups[i] == rgid || groups[i] == egid))
|
||||
continue;
|
||||
status |= print_group(groups[i], opt ? " " : prefix);
|
||||
prefix = ",";
|
||||
}
|
||||
} else if (n < 0) { /* error in get_groups() */
|
||||
if (!ENABLE_DESKTOP)
|
||||
bb_error_msg_and_die("cannot get groups");
|
||||
else
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(groups);
|
||||
#if ENABLE_SELINUX
|
||||
if (flags & JUST_CONTEXT) {
|
||||
selinux_or_die();
|
||||
if (argc - optind == 1) {
|
||||
bb_error_msg_and_die("user name can't be passed with -Z");
|
||||
}
|
||||
|
||||
if (getcon(&scontext)) {
|
||||
bb_error_msg_and_die("can't get process context");
|
||||
}
|
||||
puts(scontext);
|
||||
if (is_selinux_enabled()) {
|
||||
if (getcon(&scontext) == 0)
|
||||
printf(" context=%s", scontext);
|
||||
}
|
||||
#endif
|
||||
/* exit */
|
||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
} else if (opt & PRINT_REAL) {
|
||||
euid = ruid;
|
||||
egid = rgid;
|
||||
}
|
||||
|
||||
/* Print full info like GNU id */
|
||||
/* bb_getpwuid(0) doesn't exit on failure (returns NULL) */
|
||||
status = printf_full(uid, bb_getpwuid(NULL, 0, uid), 'u');
|
||||
bb_putchar(' ');
|
||||
status |= printf_full(gid, bb_getgrgid(NULL, 0, gid), 'g');
|
||||
|
||||
if (opt & JUST_USER)
|
||||
status |= print_user(euid, NULL);
|
||||
else if (opt & JUST_GROUP)
|
||||
status |= print_group(egid, NULL);
|
||||
#if ENABLE_SELINUX
|
||||
if (is_selinux_enabled()) {
|
||||
security_context_t mysid;
|
||||
const char *context;
|
||||
|
||||
context = "unknown";
|
||||
getcon(&mysid);
|
||||
if (mysid) {
|
||||
context = alloca(strlen(mysid) + 1);
|
||||
strcpy((char*)context, mysid);
|
||||
freecon(mysid);
|
||||
else if (opt & JUST_CONTEXT) {
|
||||
selinux_or_die();
|
||||
if (username || getcon(&scontext)) {
|
||||
bb_error_msg_and_die("can't get process context%s",
|
||||
username ? " for a different user" : "");
|
||||
}
|
||||
printf(" context=%s", context);
|
||||
fputs(scontext, stdout);
|
||||
}
|
||||
/* freecon(NULL) seems to be harmless */
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
freecon(scontext);
|
||||
#endif
|
||||
|
||||
bb_putchar('\n');
|
||||
fflush_stdout_and_exit(status);
|
||||
}
|
||||
Executable
+244
@@ -0,0 +1,244 @@
|
||||
#!/bin/bash
|
||||
# Test script for busybox id vs. coreutils id.
|
||||
# Needs root privileges for some tests.
|
||||
|
||||
cp /usr/bin/id .
|
||||
BUSYBOX=./busybox
|
||||
ID=./id
|
||||
LIST=`awk -F: '{ printf "%s\n", $1 }' /etc/passwd`
|
||||
FLAG_USER_EXISTS="no"
|
||||
TEST_USER="f583ca884c1d93458fb61ed137ff44f6"
|
||||
|
||||
echo "test 1: id [options] nousername"
|
||||
rm -f foo bar
|
||||
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
|
||||
do
|
||||
#echo "$OPTIONS"
|
||||
$BUSYBOX id $OPTIONS >foo 2>/dev/null
|
||||
RET1=$?
|
||||
$ID $OPTIONS >bar 2>/dev/null
|
||||
RET2=$?
|
||||
if test "$RET1" != "$RET2"; then
|
||||
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
|
||||
fi
|
||||
diff foo bar
|
||||
done
|
||||
|
||||
echo "test 2: id [options] username"
|
||||
rm -f foo bar
|
||||
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
|
||||
do
|
||||
#echo "$OPTIONS"
|
||||
for i in $LIST ; do
|
||||
if test "$i" = "$TEST_USER"; then
|
||||
FLAG_USER_EXISTS="yes"
|
||||
fi
|
||||
$BUSYBOX id $OPTIONS $i >foo 2>/dev/null
|
||||
RET1=$?
|
||||
$ID $OPTIONS $i >bar 2>/dev/null
|
||||
RET2=$?
|
||||
if test "$RET1" != "$RET2"; then
|
||||
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
|
||||
fi
|
||||
diff foo bar
|
||||
done
|
||||
done
|
||||
|
||||
if test $FLAG_USER_EXISTS = "yes"; then
|
||||
echo "test 3,4,5,6,7,8,9,10,11,12 skipped because test user $TEST_USER already exists"
|
||||
rm -f foo bar
|
||||
exit 1
|
||||
fi
|
||||
|
||||
adduser -s /bin/true -g "" -H -D "$TEST_USER" || exit 1
|
||||
|
||||
chown $TEST_USER.$TEST_USER $BUSYBOX
|
||||
chmod u+s $BUSYBOX 2>&1 /dev/null
|
||||
chown $TEST_USER.$TEST_USER $ID
|
||||
chmod u+s $ID 2>&1 /dev/null
|
||||
|
||||
echo "test 3 setuid, existing user: id [options] no username"
|
||||
rm -f foo bar
|
||||
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
|
||||
do
|
||||
#echo "$OPTIONS"
|
||||
$BUSYBOX id $OPTIONS >foo 2>/dev/null
|
||||
RET1=$?
|
||||
$ID $OPTIONS >bar 2>/dev/null
|
||||
RET2=$?
|
||||
if test "$RET1" != "$RET2"; then
|
||||
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
|
||||
fi
|
||||
diff foo bar
|
||||
#done
|
||||
done
|
||||
|
||||
echo "test 4 setuid, existing user: id [options] username"
|
||||
rm -f foo bar
|
||||
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
|
||||
do
|
||||
#echo "$OPTIONS"
|
||||
for i in $LIST ; do
|
||||
$BUSYBOX id $OPTIONS $i >foo 2>/dev/null
|
||||
RET1=$?
|
||||
$ID $OPTIONS $i >bar 2>/dev/null
|
||||
RET2=$?
|
||||
if test "$RET1" != "$RET2"; then
|
||||
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
|
||||
fi
|
||||
diff foo bar
|
||||
done
|
||||
done
|
||||
|
||||
chown $TEST_USER.$TEST_USER $BUSYBOX
|
||||
chmod g+s $BUSYBOX 2>&1 /dev/null
|
||||
chown $TEST_USER.$TEST_USER $ID
|
||||
chmod g+s $ID 2>&1 /dev/null
|
||||
|
||||
echo "test 5 setgid, existing user: id [options] no username"
|
||||
rm -f foo bar
|
||||
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
|
||||
do
|
||||
#echo "$OPTIONS"
|
||||
$BUSYBOX id $OPTIONS >foo 2>/dev/null
|
||||
RET1=$?
|
||||
$ID $OPTIONS >bar 2>/dev/null
|
||||
RET2=$?
|
||||
if test "$RET1" != "$RET2"; then
|
||||
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
|
||||
fi
|
||||
diff foo bar
|
||||
#done
|
||||
done
|
||||
|
||||
echo "test 6 setgid, existing user: id [options] username"
|
||||
rm -f foo bar
|
||||
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
|
||||
do
|
||||
#echo "$OPTIONS"
|
||||
for i in $LIST ; do
|
||||
$BUSYBOX id $OPTIONS $i >foo 2>/dev/null
|
||||
RET1=$?
|
||||
$ID $OPTIONS $i >bar 2>/dev/null
|
||||
RET2=$?
|
||||
if test "$RET1" != "$RET2"; then
|
||||
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
|
||||
fi
|
||||
diff foo bar
|
||||
done
|
||||
done
|
||||
|
||||
chown $TEST_USER.$TEST_USER $BUSYBOX
|
||||
chmod u+s,g+s $BUSYBOX 2>&1 /dev/null
|
||||
chown $TEST_USER.$TEST_USER $ID
|
||||
chmod u+s,g+s $ID 2>&1 /dev/null
|
||||
|
||||
echo "test 7 setuid, setgid, existing user: id [options] no username"
|
||||
rm -f foo bar
|
||||
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
|
||||
do
|
||||
#echo "$OPTIONS"
|
||||
$BUSYBOX id $OPTIONS >foo 2>/dev/null
|
||||
RET1=$?
|
||||
$ID $OPTIONS >bar 2>/dev/null
|
||||
RET2=$?
|
||||
if test "$RET1" != "$RET2"; then
|
||||
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
|
||||
fi
|
||||
diff foo bar
|
||||
#done
|
||||
done
|
||||
|
||||
echo "test 8 setuid, setgid, existing user: id [options] username"
|
||||
rm -f foo bar
|
||||
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
|
||||
do
|
||||
#echo "$OPTIONS"
|
||||
for i in $LIST ; do
|
||||
$BUSYBOX id $OPTIONS $i >foo 2>/dev/null
|
||||
RET1=$?
|
||||
$ID $OPTIONS $i >bar 2>/dev/null
|
||||
RET2=$?
|
||||
if test "$RET1" != "$RET2"; then
|
||||
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
|
||||
fi
|
||||
diff foo bar
|
||||
done
|
||||
done
|
||||
|
||||
deluser $TEST_USER || exit 1
|
||||
|
||||
echo "test 9 setuid, setgid, not existing user: id [options] no username"
|
||||
rm -f foo bar
|
||||
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
|
||||
do
|
||||
#echo "$OPTIONS"
|
||||
$BUSYBOX id $OPTIONS >foo 2>/dev/null
|
||||
RET1=$?
|
||||
$ID $OPTIONS >bar 2>/dev/null
|
||||
RET2=$?
|
||||
if test "$RET1" != "$RET2"; then
|
||||
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
|
||||
fi
|
||||
diff foo bar
|
||||
done
|
||||
|
||||
echo "test 10 setuid, setgid, not existing user: id [options] username"
|
||||
rm -f foo bar
|
||||
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
|
||||
do
|
||||
#echo "$OPTIONS"
|
||||
for i in $LIST ; do
|
||||
$BUSYBOX id $OPTIONS $i >foo 2>/dev/null
|
||||
RET1=$?
|
||||
$ID $OPTIONS $i >bar 2>/dev/null
|
||||
RET2=$?
|
||||
if test "$RET1" != "$RET2"; then
|
||||
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
|
||||
fi
|
||||
diff foo bar
|
||||
done
|
||||
done
|
||||
|
||||
chown .root $BUSYBOX 2>&1 /dev/null
|
||||
chown .root $ID 2>&1 /dev/null
|
||||
chmod g+s $BUSYBOX 2>&1 /dev/null
|
||||
chmod g+s $ID 2>&1 /dev/null
|
||||
|
||||
echo "test 11 setgid, not existing group: id [options] no username"
|
||||
rm -f foo bar
|
||||
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
|
||||
do
|
||||
#echo "$OPTIONS"
|
||||
$BUSYBOX id $OPTIONS >foo 2>/dev/null
|
||||
RET1=$?
|
||||
$ID $OPTIONS >bar 2>/dev/null
|
||||
RET2=$?
|
||||
if test "$RET1" != "$RET2"; then
|
||||
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
|
||||
fi
|
||||
diff foo bar
|
||||
#done
|
||||
done
|
||||
|
||||
echo "test 12 setgid, not existing group: id [options] username"
|
||||
rm -f foo bar
|
||||
for OPTIONS in "" "-u" "-un" "-unr" "-g" "-gn" "-gnr" "-G" "-Gn" "-Gnr"
|
||||
do
|
||||
#echo "$OPTIONS"
|
||||
for i in $LIST ; do
|
||||
$BUSYBOX id $OPTIONS $i >foo 2>/dev/null
|
||||
RET1=$?
|
||||
$ID $OPTIONS $i >bar 2>/dev/null
|
||||
RET2=$?
|
||||
if test "$RET1" != "$RET2"; then
|
||||
echo "Return Values differ ($RET1 != $RET2): options $OPTIONS"
|
||||
fi
|
||||
diff foo bar
|
||||
done
|
||||
done
|
||||
|
||||
chown root.root $BUSYBOX 2>&1 /dev/null
|
||||
chown root.root $ID 2>&1 /dev/null
|
||||
rm -f $ID
|
||||
rm -f foo bar
|
||||
+66
-78
@@ -4,9 +4,6 @@
|
||||
* SELinux support: by Yuichi Nakamura <ynakam@hitachisoft.jp>
|
||||
*
|
||||
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
|
||||
*
|
||||
* TODO: -d option, need a way of recursively making directories and changing
|
||||
* owner/group, will probably modify bb_make_directory(...)
|
||||
*/
|
||||
|
||||
#include "libbb.h"
|
||||
@@ -17,9 +14,9 @@ static const char install_longopts[] ALIGN1 =
|
||||
"directory\0" No_argument "d"
|
||||
"preserve-timestamps\0" No_argument "p"
|
||||
"strip\0" No_argument "s"
|
||||
"group\0" No_argument "g"
|
||||
"mode\0" No_argument "m"
|
||||
"owner\0" No_argument "o"
|
||||
"group\0" Required_argument "g"
|
||||
"mode\0" Required_argument "m"
|
||||
"owner\0" Required_argument "o"
|
||||
/* autofs build insists of using -b --suffix=.orig */
|
||||
/* TODO? (short option for --suffix is -S) */
|
||||
#if ENABLE_SELINUX
|
||||
@@ -53,7 +50,8 @@ static void setdefaultfilecon(const char *path)
|
||||
|
||||
if (lsetfilecon(path, scontext) < 0) {
|
||||
if (errno != ENOTSUP) {
|
||||
bb_perror_msg("warning: failed to change context of %s to %s", path, scontext);
|
||||
bb_perror_msg("warning: failed to change context"
|
||||
" of %s to %s", path, scontext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,9 +73,10 @@ int install_main(int argc, char **argv)
|
||||
const char *uid_str;
|
||||
const char *mode_str;
|
||||
int copy_flags = FILEUTILS_DEREFERENCE | FILEUTILS_FORCE;
|
||||
int flags;
|
||||
int opts;
|
||||
int min_args = 1;
|
||||
int ret = EXIT_SUCCESS;
|
||||
int isdir;
|
||||
int isdir = 0;
|
||||
#if ENABLE_SELINUX
|
||||
security_context_t scontext;
|
||||
bool use_default_selinux_context = 1;
|
||||
@@ -86,15 +85,16 @@ int install_main(int argc, char **argv)
|
||||
OPT_c = 1 << 0,
|
||||
OPT_v = 1 << 1,
|
||||
OPT_b = 1 << 2,
|
||||
OPT_DIRECTORY = 1 << 3,
|
||||
OPT_PRESERVE_TIME = 1 << 4,
|
||||
OPT_STRIP = 1 << 5,
|
||||
OPT_GROUP = 1 << 6,
|
||||
OPT_MODE = 1 << 7,
|
||||
OPT_OWNER = 1 << 8,
|
||||
OPT_MKDIR_LEADING = 1 << 3,
|
||||
OPT_DIRECTORY = 1 << 4,
|
||||
OPT_PRESERVE_TIME = 1 << 5,
|
||||
OPT_STRIP = 1 << 6,
|
||||
OPT_GROUP = 1 << 7,
|
||||
OPT_MODE = 1 << 8,
|
||||
OPT_OWNER = 1 << 9,
|
||||
#if ENABLE_SELINUX
|
||||
OPT_SET_SECURITY_CONTEXT = 1 << 9,
|
||||
OPT_PRESERVE_SECURITY_CONTEXT = 1 << 10,
|
||||
OPT_SET_SECURITY_CONTEXT = 1 << 10,
|
||||
OPT_PRESERVE_SECURITY_CONTEXT = 1 << 11,
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -105,91 +105,79 @@ int install_main(int argc, char **argv)
|
||||
/* -c exists for backwards compatibility, it's needed */
|
||||
/* -v is ignored ("print name of each created directory") */
|
||||
/* -b is ignored ("make a backup of each existing destination file") */
|
||||
flags = getopt32(argv, "cvb" "dpsg:m:o:" USE_SELINUX("Z:"),
|
||||
opts = getopt32(argv, "cvb" "Ddpsg:m:o:" USE_SELINUX("Z:"),
|
||||
&gid_str, &mode_str, &uid_str USE_SELINUX(, &scontext));
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
#if ENABLE_SELINUX
|
||||
if (flags & (OPT_PRESERVE_SECURITY_CONTEXT|OPT_SET_SECURITY_CONTEXT)) {
|
||||
if (opts & (OPT_PRESERVE_SECURITY_CONTEXT|OPT_SET_SECURITY_CONTEXT)) {
|
||||
selinux_or_die();
|
||||
use_default_selinux_context = 0;
|
||||
if (flags & OPT_PRESERVE_SECURITY_CONTEXT) {
|
||||
if (opts & OPT_PRESERVE_SECURITY_CONTEXT) {
|
||||
copy_flags |= FILEUTILS_PRESERVE_SECURITY_CONTEXT;
|
||||
}
|
||||
if (flags & OPT_SET_SECURITY_CONTEXT) {
|
||||
if (opts & OPT_SET_SECURITY_CONTEXT) {
|
||||
setfscreatecon_or_die(scontext);
|
||||
copy_flags |= FILEUTILS_SET_SECURITY_CONTEXT;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* preserve access and modification time, this is GNU behaviour, BSD only preserves modification time */
|
||||
if (flags & OPT_PRESERVE_TIME) {
|
||||
/* preserve access and modification time, this is GNU behaviour,
|
||||
* BSD only preserves modification time */
|
||||
if (opts & OPT_PRESERVE_TIME) {
|
||||
copy_flags |= FILEUTILS_PRESERVE_STATUS;
|
||||
}
|
||||
mode = 0666;
|
||||
if (flags & OPT_MODE)
|
||||
if (opts & OPT_MODE)
|
||||
bb_parse_mode(mode_str, &mode);
|
||||
uid = (flags & OPT_OWNER) ? get_ug_id(uid_str, xuname2uid) : getuid();
|
||||
gid = (flags & OPT_GROUP) ? get_ug_id(gid_str, xgroup2gid) : getgid();
|
||||
if (flags & (OPT_OWNER|OPT_GROUP))
|
||||
umask(0);
|
||||
|
||||
/* Create directories
|
||||
* don't use bb_make_directory() as it can't change uid or gid
|
||||
* perhaps bb_make_directory() should be improved.
|
||||
*/
|
||||
if (flags & OPT_DIRECTORY) {
|
||||
while ((arg = *argv++) != NULL) {
|
||||
char *slash = arg;
|
||||
while (1) {
|
||||
slash = strchr(slash + 1, '/');
|
||||
if (slash)
|
||||
*slash = '\0';
|
||||
if (mkdir(arg, mode | 0111) == -1) {
|
||||
if (errno != EEXIST) {
|
||||
bb_perror_msg("cannot create %s", arg);
|
||||
ret = EXIT_FAILURE;
|
||||
break;
|
||||
}
|
||||
} /* dir was created, chown? */
|
||||
else if ((flags & (OPT_OWNER|OPT_GROUP))
|
||||
&& lchown(arg, uid, gid) == -1
|
||||
) {
|
||||
bb_perror_msg("cannot change ownership of %s", arg);
|
||||
ret = EXIT_FAILURE;
|
||||
break;
|
||||
}
|
||||
if (!slash)
|
||||
break;
|
||||
*slash = '/';
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (argc < 2)
|
||||
bb_show_usage();
|
||||
uid = (opts & OPT_OWNER) ? get_ug_id(uid_str, xuname2uid) : getuid();
|
||||
gid = (opts & OPT_GROUP) ? get_ug_id(gid_str, xgroup2gid) : getgid();
|
||||
|
||||
last = argv[argc - 1];
|
||||
argv[argc - 1] = NULL;
|
||||
/* coreutils install resolves link in this case, don't use lstat */
|
||||
isdir = stat(last, &statbuf) < 0 ? 0 : S_ISDIR(statbuf.st_mode);
|
||||
if (!(opts & OPT_DIRECTORY)) {
|
||||
argv[argc - 1] = NULL;
|
||||
min_args++;
|
||||
|
||||
/* coreutils install resolves link in this case, don't use lstat */
|
||||
isdir = stat(last, &statbuf) < 0 ? 0 : S_ISDIR(statbuf.st_mode);
|
||||
}
|
||||
|
||||
if (argc < min_args)
|
||||
bb_show_usage();
|
||||
|
||||
while ((arg = *argv++) != NULL) {
|
||||
char *dest = last;
|
||||
if (isdir)
|
||||
dest = concat_path_file(last, basename(arg));
|
||||
if (copy_file(arg, dest, copy_flags)) {
|
||||
/* copy is not made */
|
||||
ret = EXIT_FAILURE;
|
||||
goto next;
|
||||
if (opts & OPT_DIRECTORY) {
|
||||
dest = arg;
|
||||
/* GNU coreutils 6.9 does not set uid:gid
|
||||
* on intermediate created directories
|
||||
* (only on last one) */
|
||||
if (bb_make_directory(dest, 0755, FILEUTILS_RECUR)) {
|
||||
ret = EXIT_FAILURE;
|
||||
goto next;
|
||||
}
|
||||
} else {
|
||||
if (opts & OPT_MKDIR_LEADING) {
|
||||
char *ddir = xstrdup(dest);
|
||||
bb_make_directory(dirname(ddir), 0755, FILEUTILS_RECUR);
|
||||
/* errors are not checked. copy_file
|
||||
* will fail if dir is not created. */
|
||||
free(ddir);
|
||||
}
|
||||
if (isdir)
|
||||
dest = concat_path_file(last, basename(arg));
|
||||
if (copy_file(arg, dest, copy_flags)) {
|
||||
/* copy is not made */
|
||||
ret = EXIT_FAILURE;
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the file mode */
|
||||
if ((flags & OPT_MODE) && chmod(dest, mode) == -1) {
|
||||
bb_perror_msg("cannot change permissions of %s", dest);
|
||||
if ((opts & OPT_MODE) && chmod(dest, mode) == -1) {
|
||||
bb_perror_msg("can't change %s of %s", "permissions", dest);
|
||||
ret = EXIT_FAILURE;
|
||||
}
|
||||
#if ENABLE_SELINUX
|
||||
@@ -197,13 +185,13 @@ int install_main(int argc, char **argv)
|
||||
setdefaultfilecon(dest);
|
||||
#endif
|
||||
/* Set the user and group id */
|
||||
if ((flags & (OPT_OWNER|OPT_GROUP))
|
||||
if ((opts & (OPT_OWNER|OPT_GROUP))
|
||||
&& lchown(dest, uid, gid) == -1
|
||||
) {
|
||||
bb_perror_msg("cannot change ownership of %s", dest);
|
||||
bb_perror_msg("can't change %s of %s", "ownership", dest);
|
||||
ret = EXIT_FAILURE;
|
||||
}
|
||||
if (flags & OPT_STRIP) {
|
||||
if (opts & OPT_STRIP) {
|
||||
char *args[3];
|
||||
args[0] = (char*)"strip";
|
||||
args[1] = dest;
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
|
||||
typedef int (*stat_func)(const char *fn, struct stat *ps);
|
||||
|
||||
int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf);
|
||||
int cp_mv_stat(const char *fn, struct stat *fn_stat);
|
||||
int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf) FAST_FUNC;
|
||||
int cp_mv_stat(const char *fn, struct stat *fn_stat) FAST_FUNC;
|
||||
|
||||
mode_t getopt_mk_fifo_nod(char **argv);
|
||||
mode_t getopt_mk_fifo_nod(char **argv) FAST_FUNC;
|
||||
|
||||
#if __GNUC_PREREQ(4,1)
|
||||
# pragma GCC visibility pop
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "libbb.h"
|
||||
#include "coreutils.h"
|
||||
|
||||
int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf)
|
||||
int FAST_FUNC cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf)
|
||||
{
|
||||
if (sf(fn, fn_stat) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
@@ -44,7 +44,7 @@ int cp_mv_stat2(const char *fn, struct stat *fn_stat, stat_func sf)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cp_mv_stat(const char *fn, struct stat *fn_stat)
|
||||
int FAST_FUNC cp_mv_stat(const char *fn, struct stat *fn_stat)
|
||||
{
|
||||
return cp_mv_stat2(fn, fn_stat, stat);
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "libbb.h"
|
||||
#include "coreutils.h"
|
||||
|
||||
mode_t getopt_mk_fifo_nod(char **argv)
|
||||
mode_t FAST_FUNC getopt_mk_fifo_nod(char **argv)
|
||||
{
|
||||
mode_t mode = 0666;
|
||||
char *smode = NULL;
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@
|
||||
/* This is a NOFORK applet. Be very careful! */
|
||||
|
||||
int logname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int logname_main(int argc, char ATTRIBUTE_UNUSED **argv)
|
||||
int logname_main(int argc, char **argv UNUSED_PARAM)
|
||||
{
|
||||
char buf[128];
|
||||
|
||||
|
||||
+7
-6
@@ -825,7 +825,7 @@ static const char ls_color_opt[] ALIGN1 =
|
||||
|
||||
|
||||
int ls_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int ls_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int ls_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
struct dnode **dnd;
|
||||
struct dnode **dnf;
|
||||
@@ -837,7 +837,8 @@ int ls_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
int dnfiles;
|
||||
int dndirs;
|
||||
int i;
|
||||
USE_FEATURE_LS_COLOR(char *color_opt;)
|
||||
/* need to initialize since --color has _an optional_ argument */
|
||||
USE_FEATURE_LS_COLOR(const char *color_opt = "always";)
|
||||
|
||||
INIT_G();
|
||||
|
||||
@@ -888,15 +889,15 @@ int ls_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
||||
if (ENABLE_FEATURE_LS_COLOR_IS_DEFAULT && isatty(STDOUT_FILENO)) {
|
||||
char *p = getenv("LS_COLORS");
|
||||
/* LS_COLORS is unset, or (not empty && not "none") ? */
|
||||
if (!p || (p[0] && strcmp(p, "none")))
|
||||
if (!p || (p[0] && strcmp(p, "none") != 0))
|
||||
show_color = 1;
|
||||
}
|
||||
if (opt & (1 << i)) { /* next flag after short options */
|
||||
if (!color_opt || !strcmp("always", color_opt))
|
||||
if (strcmp("always", color_opt) == 0)
|
||||
show_color = 1;
|
||||
else if (color_opt && !strcmp("never", color_opt))
|
||||
else if (strcmp("never", color_opt) == 0)
|
||||
show_color = 0;
|
||||
else if (color_opt && !strcmp("auto", color_opt) && isatty(STDOUT_FILENO))
|
||||
else if (strcmp("auto", color_opt) == 0 && isatty(STDOUT_FILENO))
|
||||
show_color = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
Loaded 100 of 646 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user