Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
40ecf7da88 | ||
|
|
5c3070b29c | ||
|
|
807bda4a24 | ||
|
|
7cd5075908 | ||
|
|
48dfc56b4a | ||
|
|
d9d75555ba | ||
|
|
9137f2a2d1 | ||
|
|
5a071bcbf2 | ||
|
|
934c8ecb88 | ||
|
|
1c03923b0b | ||
|
|
b7e6f13b3c | ||
|
|
0279505e8c | ||
|
|
d28cb03819 | ||
|
|
c308847274 | ||
|
|
00e56ada9c | ||
|
|
3bbcc95ac9 | ||
|
|
d22b78ff05 | ||
|
|
77b68e6f42 | ||
|
|
3102ac4b58 | ||
|
|
5009f90ea2 | ||
|
|
44edeff025 | ||
|
|
8e75f6daa6 | ||
|
|
332394b577 | ||
|
|
d50a61956c | ||
|
|
94f3a570e1 | ||
|
|
8df319b213 | ||
|
|
ed8495990a | ||
|
|
bbac261402 | ||
|
|
7f3cbdd7fd | ||
|
|
623cfa99e5 | ||
|
|
dd8500bce7 | ||
|
|
3073dfbf30 | ||
|
|
22ecf049b6 | ||
|
|
2870d964f8 | ||
|
|
8f6978405d | ||
|
|
10175a43ee | ||
|
|
0159597bd6 | ||
|
|
7e516797f9 | ||
|
|
8fa1bf7cd6 | ||
|
|
8f01839386 | ||
|
|
a77cfbfd0c | ||
|
|
d877d44d12 | ||
|
|
db15cb72e2 | ||
|
|
a2949aa217 | ||
|
|
ff9eee475f | ||
|
|
66ca9480c8 | ||
|
|
029b4a0422 | ||
|
|
ec23c4920f | ||
|
|
df82f611c8 | ||
|
|
cb57d551a2 | ||
|
|
184d73636d | ||
|
|
028b65b060 | ||
|
|
07abfe2092 | ||
|
|
0d8cc1670c | ||
|
|
4b6b5e4314 | ||
|
|
5c66d06104 | ||
|
|
0392b8638e | ||
|
|
a90f20b1c3 | ||
|
|
d98337a7b4 | ||
|
|
91a6318d55 | ||
|
|
5ef5614c31 | ||
|
|
ce98c19dfe | ||
|
|
78b0e379d7 | ||
|
|
addabd6f16 | ||
|
|
f8736d251e | ||
|
|
6c947d289f | ||
|
|
24982c589b | ||
|
|
2d848a476a | ||
|
|
2e6d3cfa82 | ||
|
|
1557626897 | ||
|
|
e0c0757d09 | ||
|
|
d9c8acec37 | ||
|
|
8f5b63edea | ||
|
|
52a97ca00c | ||
|
|
c798b07762 | ||
|
|
a0105713e8 | ||
|
|
764303f980 | ||
|
|
30f1eafaaa | ||
|
|
6b03504441 | ||
|
|
76ce7549ce | ||
|
|
9f832deecf | ||
|
|
7387240ef0 | ||
|
|
837097648e | ||
|
|
fbbd360b3c | ||
|
|
8071c02131 | ||
|
|
ceeff73819 | ||
|
|
091781e20e | ||
|
|
8a646dd293 | ||
|
|
ea4abff595 | ||
|
|
075228a461 | ||
|
|
02c40a72b8 | ||
|
|
fa2661f2e5 | ||
|
|
aff5e2eaef | ||
|
|
06a71cced2 | ||
|
|
8e74bf94f3 | ||
|
|
eb1c94078f | ||
|
|
b4a26e6fc0 | ||
|
|
74c97cdba6 | ||
|
|
32574a41b4 | ||
|
|
bd4b621e91 | ||
|
|
6bad1fa1fd | ||
|
|
f429baca86 | ||
|
|
17822cd60a | ||
|
|
9aff903603 | ||
|
|
dab3d46b9d | ||
|
|
583e3ca456 | ||
|
|
7bd773c9fe | ||
|
|
0915c4b985 | ||
|
|
bf0a010cf7 | ||
|
|
5246225596 | ||
|
|
04407e522b | ||
|
|
4f3e24979b | ||
|
|
817e73cb63 | ||
|
|
12422ffe3e | ||
|
|
c616e53ca2 | ||
|
|
f4dd6e3d1a | ||
|
|
cb2a372c9f | ||
|
|
67a4640333 | ||
|
|
62ebe2e443 | ||
|
|
cda5cf1c2f | ||
|
|
9344f7575e | ||
|
|
8b113f93b9 | ||
|
|
4f6753e586 | ||
|
|
4f990533e3 | ||
|
|
f12cc4ee68 | ||
|
|
86f0167e39 | ||
|
|
6e9e136fcb | ||
|
|
4f6aea807b | ||
|
|
8b7a0d807a | ||
|
|
0a4f578fdc | ||
|
|
fa43e54b6f | ||
|
|
04052f96e1 | ||
|
|
a813afc24f | ||
|
|
5a9d441b2c | ||
|
|
1c1f5d3047 | ||
|
|
a15dc15f12 | ||
|
|
bf7df04ec1 | ||
|
|
77d9268892 | ||
|
|
bdd4eced84 | ||
|
|
774d135b66 | ||
|
|
3200f5ac68 | ||
|
|
57e6a49e5b | ||
|
|
9978576f15 | ||
|
|
aeb44c4da6 | ||
|
|
816867858b | ||
|
|
94ac244dea | ||
|
|
1eb4acfc23 | ||
|
|
edc806507c | ||
|
|
117231c44f | ||
|
|
7f7348b7b2 | ||
|
|
1d9d41150b | ||
|
|
004015e9c4 | ||
|
|
abec344ab7 | ||
|
|
317827d9e5 | ||
|
|
73991ff925 | ||
|
|
ada18ff0f5 | ||
|
|
8ae319a322 | ||
|
|
2f6e1f880b | ||
|
|
13a70ac2ab | ||
|
|
9ffb7dd9a4 | ||
|
|
6197c51834 | ||
|
|
b6967635eb | ||
|
|
1844770fec | ||
|
|
d6ef07406d | ||
|
|
6943815400 | ||
|
|
231f998aba | ||
|
|
7cedac567c | ||
|
|
bc0f783a5f | ||
|
|
233817437d | ||
|
|
bfae2529b8 | ||
|
|
2439a59828 | ||
|
|
8f7a4ad442 | ||
|
|
bf381a0ad8 | ||
|
|
c55b8d41c1 | ||
|
|
59df6f7398 | ||
|
|
bc604a2f41 | ||
|
|
f72f562b2f | ||
|
|
9abfe85e96 | ||
|
|
50ae3102fb | ||
|
|
55f9872616 | ||
|
|
c911a4389b | ||
|
|
15649c11f3 | ||
|
|
20a69a77d2 | ||
|
|
78a7c99f7f | ||
|
|
be9f44a7df | ||
|
|
336480fe6f | ||
|
|
d928accbbd | ||
|
|
2416dfc3c9 | ||
|
|
dd527d3c62 | ||
|
|
9de2659264 | ||
|
|
35e59bed97 | ||
|
|
452cc1f293 | ||
|
|
9496466044 | ||
|
|
14d354312a | ||
|
|
cb378a5267 | ||
|
|
a17b3631fe | ||
|
|
95a349f427 | ||
|
|
ddb00545b7 | ||
|
|
4819c3d477 | ||
|
|
1f3b9f297e | ||
|
|
cfa88ecb72 | ||
|
|
5f265b755a | ||
|
|
9d94deabd3 | ||
|
|
238da24620 | ||
|
|
2b02ab9606 | ||
|
|
eb5f433736 | ||
|
|
c96381be40 | ||
|
|
5b44f48afc | ||
|
|
f3e79ba6e3 | ||
|
|
6e91f69a0d | ||
|
|
854125f6e6 | ||
|
|
d283e1cfe9 | ||
|
|
1a6d39b259 | ||
|
|
0a36de0580 | ||
|
|
45e92ba2ce | ||
|
|
8cd16d8fd3 | ||
|
|
186bf1defc | ||
|
|
de0ca0cd9e | ||
|
|
f3f9f3efa7 | ||
|
|
4ad13e5d95 | ||
|
|
c33ebc9741 | ||
|
|
04b0354d8e | ||
|
|
8f3e51b4ad | ||
|
|
8d35134ad8 | ||
|
|
83a2ae2184 | ||
|
|
7e1273edf7 | ||
|
|
238bc4090d | ||
|
|
da7f095c12 | ||
|
|
28355a36da | ||
|
|
822c3837f9 | ||
|
|
713b398700 | ||
|
|
5bcfc9ba1a | ||
|
|
cc0aa0f2d7 | ||
|
|
1b62619446 | ||
|
|
3aae10014c | ||
|
|
2e6c878763 | ||
|
|
6b8c550d88 | ||
|
|
2dcfba7117 | ||
|
|
044a72d0d5 | ||
|
|
a0ba9f45fb | ||
|
|
d24f878546 | ||
|
|
7526f035f4 | ||
|
|
e5ffb911e8 | ||
|
|
e6bf66eada | ||
|
|
b0aca921be | ||
|
|
87d893c04b | ||
|
|
6689140597 | ||
|
|
80abc45182 | ||
|
|
adcbc12d85 | ||
|
|
3425111bb9 | ||
|
|
0fcd447d59 | ||
|
|
20a3069ec0 | ||
|
|
19ec9ee91e | ||
|
|
9f8caf134f | ||
|
|
bafd94f154 | ||
|
|
1c8a59ab95 | ||
|
|
f162e7d09d | ||
|
|
e67c3ce327 | ||
|
|
e0244b0642 | ||
|
|
b9f5b82339 | ||
|
|
6d553ef200 | ||
|
|
abde065935 | ||
|
|
4ed5e37d4b | ||
|
|
3f99b567b8 | ||
|
|
aac75e5a78 | ||
|
|
0e9aef36fa | ||
|
|
8a633268ef | ||
|
|
6f34394454 | ||
|
|
65504ac12c | ||
|
|
defa4f93c2 | ||
|
|
218aa370b4 | ||
|
|
43ca13714b | ||
|
|
24abecc349 | ||
|
|
af166e7ce0 | ||
|
|
2bf4dad7ec | ||
|
|
07e462fd6d | ||
|
|
72ab975a6b | ||
|
|
088875fec4 | ||
|
|
af44a0e8f4 | ||
|
|
0081466925 | ||
|
|
0f9426edb0 | ||
|
|
25f2703015 | ||
|
|
a1dbc22469 | ||
|
|
924ab5b7d3 | ||
|
|
7f3b86e7bf | ||
|
|
6aabfd5e30 | ||
|
|
ca85cdbe4c | ||
|
|
468f504fd7 | ||
|
|
c1bdffe99b | ||
|
|
3c3277f0bd | ||
|
|
30592a5451 | ||
|
|
e55987896a | ||
|
|
2789906aad | ||
|
|
207587a9b4 | ||
|
|
c29c44c00e | ||
|
|
4f4bcfcd1a | ||
|
|
c57a75d896 | ||
|
|
4b541a8817 | ||
|
|
67d7fe66e7 | ||
|
|
4f3558af17 | ||
|
|
04095e58fb | ||
|
|
3676374915 | ||
|
|
f227815c3a | ||
|
|
8810bdbba3 | ||
|
|
9f0fedb8f6 | ||
|
|
3a4aef5a4c | ||
|
|
01441036e9 | ||
|
|
9ff9325e60 | ||
|
|
af030496fa | ||
|
|
de1b262942 | ||
|
|
91b2855ba8 | ||
|
|
4e9267d76c | ||
|
|
4b66dabc76 | ||
|
|
8a24a65d2f | ||
|
|
ed424dbf1d | ||
|
|
d8862928c2 | ||
|
|
f5c358bc98 | ||
|
|
782ab3ccf8 | ||
|
|
ee0d93ed04 | ||
|
|
89dc02d944 | ||
|
|
56c14a6473 | ||
|
|
497ef46587 | ||
|
|
3e310ac309 | ||
|
|
6ebd633829 | ||
|
|
46cd74b9e3 | ||
|
|
3ce79338e6 | ||
|
|
0a3bda2c53 | ||
|
|
b5ec61e4f5 | ||
|
|
53265546a6 | ||
|
|
96dcd19b8a | ||
|
|
54652230d4 | ||
|
|
b181056e06 | ||
|
|
bcfeb2ac44 | ||
|
|
2771d1a574 | ||
|
|
fccaa3629b | ||
|
|
6e808ca354 | ||
|
|
30ac01cca7 | ||
|
|
3828dbed57 | ||
|
|
31868b85be | ||
|
|
59a86cad67 | ||
|
|
5d81768cf1 | ||
|
|
a3045dfd25 | ||
|
|
1240082e37 | ||
|
|
24ed3bee0c | ||
|
|
3d406da0c9 | ||
|
|
1c0d311ff4 | ||
|
|
ae1c704c44 | ||
|
|
33431ebb9a | ||
|
|
3136904ff6 | ||
|
|
685f5fd6f4 | ||
|
|
a529d885d2 | ||
|
|
5faef74bae | ||
|
|
65708e4cd1 | ||
|
|
4a2e463525 | ||
|
|
0f50bca9aa | ||
|
|
445fb952b8 | ||
|
|
1e04ea388f | ||
|
|
d6cde0bcf4 | ||
|
|
4ef40c02f4 | ||
|
|
8fc364ebd5 | ||
|
|
6ba1a80c26 | ||
|
|
5a65413c04 | ||
|
|
47fd219c95 | ||
|
|
be66ad3212 | ||
|
|
3e2ab88ee2 | ||
|
|
c9cac5be23 | ||
|
|
6785b51280 | ||
|
|
359c106871 | ||
|
|
46079a1d77 | ||
|
|
327175137f | ||
|
|
a6ce670a87 | ||
|
|
2709297f3b | ||
|
|
50b787cac5 | ||
|
|
a283157c38 | ||
|
|
c8d9e0604a | ||
|
|
da160c0da5 | ||
|
|
90d7f696d6 | ||
|
|
65317ea27f | ||
|
|
ed897e5415 | ||
|
|
2975a34f23 | ||
|
|
b3f23d4c6a | ||
|
|
988be100e2 | ||
|
|
4949faf4b2 | ||
|
|
5b20d02ea9 | ||
|
|
9e966ffed4 | ||
|
|
f70f6cef39 | ||
|
|
48081f81bd | ||
|
|
7dc8d227a5 | ||
|
|
528ef50a4a | ||
|
|
a12131966c | ||
|
|
7fd92949d0 | ||
|
|
d22e560ad6 | ||
|
|
9d53c8ab74 | ||
|
|
93ffa950bf | ||
|
|
efcfe874ea | ||
|
|
0958093be6 | ||
|
|
3c3430502a | ||
|
|
b04d744a47 | ||
|
|
e703f7ed42 | ||
|
|
b9af894264 | ||
|
|
6d7fa438a7 | ||
|
|
fd402941a7 | ||
|
|
4e853560f5 | ||
|
|
2f2da90fd4 | ||
|
|
b6b519b416 | ||
|
|
d3f97f1971 | ||
|
|
303dd28bb0 | ||
|
|
4391a16c92 | ||
|
|
e5dfced23a | ||
|
|
a75e286743 | ||
|
|
59aa5703ae | ||
|
|
fc994d1cb4 | ||
|
|
7cf9fed83f | ||
|
|
3f8688b406 | ||
|
|
5d6f3440e6 | ||
|
|
305fdfa755 | ||
|
|
37849f3320 | ||
|
|
13e9c7ad82 | ||
|
|
0e757a2f3f | ||
|
|
f608da4288 | ||
|
|
e5f3957665 | ||
|
|
8a9b2c6448 | ||
|
|
aa21e0f913 | ||
|
|
250a221768 | ||
|
|
83f173b61e | ||
|
|
c270ec1fa2 | ||
|
|
831ed16efc | ||
|
|
79757c9c37 | ||
|
|
ea9065072c | ||
|
|
79359d87e8 | ||
|
|
94e505485e | ||
|
|
5bca0afb31 | ||
|
|
9a1395b9fd | ||
|
|
4e2439ad27 | ||
|
|
911af57ff8 | ||
|
|
64c8b1762c | ||
|
|
acc7757312 | ||
|
|
a2a978ae23 | ||
|
|
fdefbbbe85 | ||
|
|
e76c3b08e1 | ||
|
|
3c0364f391 | ||
|
|
4fd382ea29 | ||
|
|
06070532ba | ||
|
|
d402edfd63 | ||
|
|
14fe392dde | ||
|
|
b2e3e9b0c9 | ||
|
|
2129f97cd9 | ||
|
|
3f98040554 | ||
|
|
91c9388715 | ||
|
|
24073c7665 | ||
|
|
60b2d8d2c8 | ||
|
|
c97ec34370 | ||
|
|
0f0c0b41ce | ||
|
|
c0c502e172 | ||
|
|
c4cef5ab06 | ||
|
|
f77d88641d | ||
|
|
1e117b4752 | ||
|
|
84e229cfbe | ||
|
|
e5c24dfd01 | ||
|
|
3a6da8c183 | ||
|
|
5f2ef46d6d | ||
|
|
ed7a776538 | ||
|
|
ae8ad35590 | ||
|
|
e0a7f917c2 | ||
|
|
c835567914 | ||
|
|
d98e574d41 | ||
|
|
7cd0cfeab6 | ||
|
|
f957c77910 | ||
|
|
02cebebc3b | ||
|
|
9233959940 | ||
|
|
018e9e6799 | ||
|
|
ee79ca1ba6 | ||
|
|
0cbc8cf4c9 | ||
|
|
58e42d5356 | ||
|
|
f58efb57d1 | ||
|
|
a2e68fc233 | ||
|
|
5b8939b147 | ||
|
|
9a2144663a | ||
|
|
cc7b4f39fc | ||
|
|
bff6b18bf9 | ||
|
|
2b549c3be0 | ||
|
|
5cd2a2d53e | ||
|
|
a82a00397f | ||
|
|
1c6581a865 | ||
|
|
af633757d3 | ||
|
|
049dc25fe7 | ||
|
|
36eff9ac55 | ||
|
|
6f3240abf9 | ||
|
|
6b2c23d847 | ||
|
|
21af752b04 | ||
|
|
f6aa13d403 | ||
|
|
82ab8da245 | ||
|
|
8ffaf8d139 | ||
|
|
c54f9530ee | ||
|
|
08ff8a49ba | ||
|
|
0b4d73a53c | ||
|
|
82bb8a2bf8 | ||
|
|
851895ab80 | ||
|
|
1ca20a7747 | ||
|
|
7447642a47 | ||
|
|
6f93277f56 | ||
|
|
ba372620c2 | ||
|
|
7ef1a5beb2 | ||
|
|
4ef37d0c17 | ||
|
|
92d23245c9 | ||
|
|
40eaa9f0bb | ||
|
|
8269396491 | ||
|
|
2ccfef2004 | ||
|
|
23c1a18126 | ||
|
|
7ef54de672 | ||
|
|
b183dfad2d | ||
|
|
cc165b9083 | ||
|
|
00b0496e69 | ||
|
|
16f7015722 | ||
|
|
7c25441792 | ||
|
|
c75586e06d | ||
|
|
61173a5371 | ||
|
|
fa513aab48 | ||
|
|
8b96032139 | ||
|
|
341744781a | ||
|
|
1a6f8cfadf | ||
|
|
8a6dbf6709 | ||
|
|
e2a3cd15a8 | ||
|
|
aad1a88c76 | ||
|
|
dfba13d199 | ||
|
|
704b2c2122 | ||
|
|
53b55ac08d | ||
|
|
c36c2ba598 | ||
|
|
7f1978570f | ||
|
|
4aaefc2a50 | ||
|
|
c5b3242d3d | ||
|
|
056960d8dc | ||
|
|
0d5051def0 | ||
|
|
3a0057e2c5 | ||
|
|
f71378c4ad | ||
|
|
0a6f1d31e7 | ||
|
|
e708cb5f9a | ||
|
|
a4edd0e946 | ||
|
|
f9ff8a7d90 | ||
|
|
af9e533a54 | ||
|
|
48dcc16548 | ||
|
|
730cdb1904 | ||
|
|
0d4e51d390 | ||
|
|
0b57e28373 | ||
|
|
b0c2b7dfe3 | ||
|
|
2825ee8c2c | ||
|
|
a8035a51be | ||
|
|
7384d7dce0 | ||
|
|
0d3a02eba7 | ||
|
|
670bea210e | ||
|
|
d8adaa279e | ||
|
|
3bf60aa723 | ||
|
|
e110ccb672 | ||
|
|
0e0883e0e9 | ||
|
|
038c8eb5a9 | ||
|
|
7ddaf7caae | ||
|
|
bac75ac2d5 | ||
|
|
1ef92685cf | ||
|
|
ce4a586edb | ||
|
|
40e5e7c7ea | ||
|
|
20f61d35de | ||
|
|
44a9914709 | ||
|
|
2892c35bdb | ||
|
|
82d8502409 | ||
|
|
53f5061c7e | ||
|
|
bdc8db9685 | ||
|
|
741f2c9898 | ||
|
|
b9a1e56a80 | ||
|
|
2b1c367a98 | ||
|
|
3c0b425cde | ||
|
|
14e9e9d1ca | ||
|
|
9c09e0eeaa | ||
|
|
c319601db5 | ||
|
|
4e7244e6b2 | ||
|
|
8658816f71 | ||
|
|
f594986b37 | ||
|
|
c75f83d874 | ||
|
|
b3d6e2df95 | ||
|
|
798ab301c7 | ||
|
|
f6ba2da29f | ||
|
|
e0bf91d7c6 | ||
|
|
53737c5421 | ||
|
|
6bff9cc487 | ||
|
|
bd2e42f162 | ||
|
|
94fd480bab | ||
|
|
6317c4baf7 | ||
|
|
4987bbf979 | ||
|
|
5ec5415402 | ||
|
|
1a49fc5e92 | ||
|
|
fe4e13fb97 | ||
|
|
22b889a998 | ||
|
|
68ea1d0325 | ||
|
|
1365bb7861 | ||
|
|
78f57460f2 | ||
|
|
d2117e9c82 | ||
|
|
09f4af5afd | ||
|
|
827e45c518 | ||
|
|
fa45f22e50 | ||
|
|
d92168486b | ||
|
|
4aaf89f49f | ||
|
|
f90c28dd1e | ||
|
|
8d4c397d9d | ||
|
|
3e6ff9017f | ||
|
|
dd91724aa0 | ||
|
|
74e056bfc8 | ||
|
|
3c7361f53a | ||
|
|
ce89871ff7 | ||
|
|
195743f195 | ||
|
|
eba8ed71f0 | ||
|
|
9ba5bce06f | ||
|
|
01658a3eec | ||
|
|
3dbf1e877a | ||
|
|
afffbfe8c4 | ||
|
|
b180dd9e50 | ||
|
|
13d1fa1d01 | ||
|
|
df351d6109 | ||
|
|
39eea898c4 | ||
|
|
7e5291f111 | ||
|
|
32f8c170b0 | ||
|
|
ca6045955d | ||
|
|
e2c44fc966 | ||
|
|
5de909873a | ||
|
|
4cc8f31ffe | ||
|
|
ae5612ca6e | ||
|
|
ae20128e9f | ||
|
|
26d53eb197 | ||
|
|
ec9fad9a49 | ||
|
|
a7db19bb81 | ||
|
|
11ae573320 | ||
|
|
7850f1e2ac | ||
|
|
5986f8d1c6 | ||
|
|
651f8c04ef | ||
|
|
6c563bc1a1 | ||
|
|
8b728a25a3 | ||
|
|
702ec5926f | ||
|
|
8bb7df49c2 | ||
|
|
0f430e34af | ||
|
|
36278b9576 | ||
|
|
54851d3c65 | ||
|
|
07f2f3917a | ||
|
|
1a046d5f9d | ||
|
|
138ece09b5 | ||
|
|
e6c4de03c6 | ||
|
|
f15d4dad66 | ||
|
|
5efa2291aa | ||
|
|
c27b9544b6 | ||
|
|
47cdcdd359 | ||
|
|
21b7459add | ||
|
|
afbff22e6e | ||
|
|
452fd33ffa | ||
|
|
076cdc24fc | ||
|
|
9ead68975c | ||
|
|
323434be42 | ||
|
|
446dd27843 | ||
|
|
42ab250709 | ||
|
|
3b565cdf91 | ||
|
|
85adecb668 | ||
|
|
450736cd3c | ||
|
|
016771834a | ||
|
|
39842defda | ||
|
|
de4406747b | ||
|
|
7b91f02021 | ||
|
|
93ba60f01d | ||
|
|
1b6cff3df4 | ||
|
|
4f76bb6f3e | ||
|
|
4142d4dc66 | ||
|
|
e677dfedd1 | ||
|
|
d11578f916 | ||
|
|
2bf658d5cd | ||
|
|
afeb96547f | ||
|
|
d160a27ec1 | ||
|
|
dc12190ba2 | ||
|
|
37977622c4 | ||
|
|
7d597c4833 | ||
|
|
dbfff6cbde | ||
|
|
e6967b20cb | ||
|
|
3757f98d86 | ||
|
|
8373e70c55 | ||
|
|
7a9cc2dcdd | ||
|
|
15f9b92127 | ||
|
|
df1e9daf30 | ||
|
|
ed0d958c3e | ||
|
|
2498b155fd | ||
|
|
a0cfe94c4e | ||
|
|
b83ffafc15 | ||
|
|
56082dc2ae | ||
|
|
68c1d8400c | ||
|
|
b249fbb1dc | ||
|
|
8c16bc5012 | ||
|
|
4a25d8c9c3 | ||
|
|
0ed9923887 | ||
|
|
3574b70efc | ||
|
|
8079b155c2 | ||
|
|
bbc8e4789f | ||
|
|
2f3105725f | ||
|
|
5723934f7c | ||
|
|
41492d6c23 | ||
|
|
c163e5107f | ||
|
|
544891dd26 | ||
|
|
adea7a6101 | ||
|
|
4b2e69a1cf | ||
|
|
e13bc0bc68 | ||
|
|
ffc40bf3de | ||
|
|
b2007bffc5 | ||
|
|
5d9cad0253 | ||
|
|
7aa1f5c42a | ||
|
|
dbcd8ce464 | ||
|
|
7e9276b50a | ||
|
|
8fc300976f | ||
|
|
be30a6b8b0 | ||
|
|
54006bce25 | ||
|
|
7c3e7ac940 | ||
|
|
8d7bdc9deb | ||
|
|
9e37007edb | ||
|
|
90fe7fea10 | ||
|
|
477aedd77f | ||
|
|
5165fbed63 | ||
|
|
caeeb36784 | ||
|
|
a183f05825 | ||
|
|
f1142c5b11 | ||
|
|
cbe31dace5 | ||
|
|
94456f5984 | ||
|
|
12dceb1147 | ||
|
|
963791a9e9 | ||
|
|
f1bbb22dca | ||
|
|
f57a832063 | ||
|
|
b50da53e0c | ||
|
|
3d20f772c2 | ||
|
|
966b3a6f79 | ||
|
|
1cf8166329 | ||
|
|
47aea4ee71 | ||
|
|
19f86207f5 | ||
|
|
69c8572f29 | ||
|
|
f6a7227fd6 | ||
|
|
28a78ab62c | ||
|
|
6faae7deb4 | ||
|
|
361ee514c6 | ||
|
|
ca0f458ada | ||
|
|
733c4ad6eb | ||
|
|
fa4f146d7d | ||
|
|
5f2c79d8c7 | ||
|
|
af12bc6de4 | ||
|
|
3f5bcbfa3c | ||
|
|
a9c69762ba | ||
|
|
825ae5a166 | ||
|
|
99806ad2bd | ||
|
|
11b7a1deb7 | ||
|
|
d69d2da165 | ||
|
|
b50d707633 | ||
|
|
02b9f42a27 | ||
|
|
81bcc92c32 | ||
|
|
8305006f7c | ||
|
|
c1c43113b4 | ||
|
|
3ec8ffb121 | ||
|
|
67991cf824 | ||
|
|
68be2ab914 | ||
|
|
98e599ca06 | ||
|
|
ec45595300 | ||
|
|
88a5ceb450 | ||
|
|
fc83c4c353 | ||
|
|
6fd8c664c1 | ||
|
|
3af1f88725 | ||
|
|
dadf9c6dcd | ||
|
|
821fbf0f42 | ||
|
|
bc9afadecd | ||
|
|
728875f340 | ||
|
|
631064613f | ||
|
|
0c9d77ccfd | ||
|
|
de556615dc | ||
|
|
510f0ddafa | ||
|
|
649968ceb1 | ||
|
|
af8c65deaa | ||
|
|
c900575dc4 | ||
|
|
c30ab0f4a8 | ||
|
|
e78fd0f721 | ||
|
|
2fd52989f7 | ||
|
|
d238a7bcc8 | ||
|
|
1d70267450 | ||
|
|
df8ccb6350 | ||
|
|
096370d349 | ||
|
|
a164c647ac | ||
|
|
925edb828d | ||
|
|
c3fc3c5e7a | ||
|
|
29cff26f32 | ||
|
|
76c5e60d54 | ||
|
|
af4ac77d9d | ||
|
|
b5c29850e3 | ||
|
|
065c7e779a | ||
|
|
9b300d0b1f | ||
|
|
f2cc2762bb | ||
|
|
05e782ddd3 | ||
|
|
bd018b1bab | ||
|
|
dd19c69904 | ||
|
|
63ec273245 | ||
|
|
82d5e59ea2 | ||
|
|
79e898ac0e | ||
|
|
65225df2dc | ||
|
|
53cfb7e231 | ||
|
|
704d2a6c43 | ||
|
|
39573f7130 | ||
|
|
18d5064c47 | ||
|
|
9ba0daf4ba | ||
|
|
93a8e2e64b | ||
|
|
306f4fe480 | ||
|
|
22332fd26f | ||
|
|
ac21e93a3f | ||
|
|
4bbdd788e0 | ||
|
|
30f64c3aa2 | ||
|
|
8526067336 | ||
|
|
e57d54b456 | ||
|
|
201dc0d5a9 | ||
|
|
ceade5c856 | ||
|
|
8ec10a9483 | ||
|
|
90ca2848fd | ||
|
|
ed3ef50c23 | ||
|
|
ab050f5522 | ||
|
|
3654ca56fa | ||
|
|
4e33875759 | ||
|
|
a68b21a28e | ||
|
|
6e25f92636 | ||
|
|
a528dc7071 | ||
|
|
1e4b957ac3 | ||
|
|
5c9c8b4b26 | ||
|
|
d5cad14b11 | ||
|
|
dff9d54e32 | ||
|
|
5307eca7de | ||
|
|
114ad9c753 | ||
|
|
dbb8f8d123 | ||
|
|
d35c21587a | ||
|
|
ffde8673fe | ||
|
|
8ba1b1120e | ||
|
|
0bc20caea5 | ||
|
|
537d165216 | ||
|
|
c1b8f1224c | ||
|
|
155c89b0c3 | ||
|
|
15f29e7d86 | ||
|
|
cc2bcdc41d | ||
|
|
39b727f498 | ||
|
|
3862423884 | ||
|
|
70c6086474 | ||
|
|
86f3d5bad6 | ||
|
|
54e9457920 | ||
|
|
23a93f52aa | ||
|
|
f5d5e77321 | ||
|
|
26439a2991 | ||
|
|
088d9e0f05 | ||
|
|
7d69701d39 | ||
|
|
8c5cb31e1b | ||
|
|
a18aaf1b6a | ||
|
|
c5cd470fdb | ||
|
|
f6c6d9aacc | ||
|
|
24be980004 | ||
|
|
a5b55ca8a9 | ||
|
|
f1b0c77c22 | ||
|
|
59ab025363 | ||
|
|
2b8d07c590 | ||
|
|
9136e3c84e | ||
|
|
e132119f07 | ||
|
|
6705986f27 | ||
|
|
6d0921cc0b | ||
|
|
3b3f5c364a | ||
|
|
8f8dab94e5 | ||
|
|
0d5a08ed92 | ||
|
|
b098b6d74c | ||
|
|
fe9888ad97 | ||
|
|
965fa326a1 | ||
|
|
e2310b5a91 | ||
|
|
c73a7f9ba0 | ||
|
|
370fb08e79 | ||
|
|
6092680305 | ||
|
|
5f825ee6d6 | ||
|
|
f914a8af2b | ||
|
|
6f65a3a7e8 | ||
|
|
1d269432b1 | ||
|
|
8392acd8fc | ||
|
|
12f417edbd | ||
|
|
c9acf8c766 | ||
|
|
fd4c58d7c5 | ||
|
|
9aa23ba5a8 | ||
|
|
541ffe30a2 | ||
|
|
55787401ea | ||
|
|
744b064a34 | ||
|
|
59d31b68c3 | ||
|
|
8ea28be6d2 | ||
|
|
0bcc813a34 | ||
|
|
b0970d4fed | ||
|
|
eb60d8bcd1 | ||
|
|
55bccf315e | ||
|
|
defcd5e75e | ||
|
|
6c6ea6cba2 | ||
|
|
92386561f1 | ||
|
|
05ebdd03d4 | ||
|
|
0810f723b1 | ||
|
|
09acc06c10 | ||
|
|
849083c886 | ||
|
|
b3dc3b8990 | ||
|
|
70a7855980 | ||
|
|
1171c2fcb4 | ||
|
|
be7499c83c | ||
|
|
a9711a5969 | ||
|
|
59c09d06e3 | ||
|
|
5e23e3d631 | ||
|
|
fa0443216d | ||
|
|
47b005217e | ||
|
|
5e8b3ea19d | ||
|
|
58a408512b | ||
|
|
7541e3a812 | ||
|
|
004827d715 | ||
|
|
1944f547bd | ||
|
|
28b3c53f0d | ||
|
|
01bda5de6b | ||
|
|
27c7bec4d4 | ||
|
|
e6e818309e | ||
|
|
e9e182e255 | ||
|
|
2d5b64273f | ||
|
|
a9819b2908 | ||
|
|
e9f07fb6e8 | ||
|
|
16fdbe8b27 | ||
|
|
a6cd07099d | ||
|
|
e111d69ca2 | ||
|
|
70da6a66d2 | ||
|
|
3680c58084 | ||
|
|
5e8c0ffb75 | ||
|
|
e75f6a972c | ||
|
|
e80a2633bc | ||
|
|
8eb5985f94 | ||
|
|
8a6b619c96 | ||
|
|
eac2636513 | ||
|
|
a1f9775981 | ||
|
|
24ac017961 | ||
|
|
0d2acb0ead | ||
|
|
86349776d0 | ||
|
|
1fa1adea2a | ||
|
|
0dab829977 | ||
|
|
bfa7967c4a | ||
|
|
8677d7b6ec | ||
|
|
e699b9f0fb | ||
|
|
4f1b0124c7 | ||
|
|
8abc78aa84 | ||
|
|
1b622ff5ac | ||
|
|
aefe5629ab | ||
|
|
95fa0ea3d4 | ||
|
|
6f6aa9b428 | ||
|
|
e3a94f7d08 |
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
busybox
|
||||
busybox.links
|
||||
_install
|
||||
loop.h
|
||||
applet_source_list
|
||||
@@ -64,8 +64,8 @@ Gyepi Sam <gyepi@praxis-sw.com>
|
||||
Linus Torvalds <torvalds@transmeta.com>
|
||||
mkswap, fsck.minix, mkfs.minix
|
||||
|
||||
Mark Whitley <markw@lineo.com>
|
||||
sed remix, bug fixes, style-guide, etc.
|
||||
Mark Whitley <markw@lineo.com> <markw@codepoet.org>
|
||||
grep, sed, cut, xargs, style-guide, new-applet-HOWTO, bug fixes, etc.
|
||||
|
||||
Charles P. Wright <cpwright@villagenet.com>
|
||||
gzip, mini-netcat(nc)
|
||||
@@ -73,3 +73,9 @@ Charles P. Wright <cpwright@villagenet.com>
|
||||
Enrique Zanardi <ezanardi@ull.es>
|
||||
tarcat (since removed), loadkmap, various fixes, Debian maintenance
|
||||
|
||||
Vladimir Oleynik <dzo@simtreas.ru>
|
||||
cmdedit, stty-port, locale, various fixes
|
||||
and irreconcilable critic of everything not perfect.
|
||||
|
||||
Tim Riker <Tim@Rikers.org>
|
||||
bug fixes, member of fan club
|
||||
@@ -1,3 +1,266 @@
|
||||
0.52
|
||||
|
||||
Critical Bugfixes:
|
||||
* Glenn McGrath -- Fixed gunzip, zcat when reading from stdin
|
||||
* Marc Karasek and Kanoj (kernel serial.c maintainer) -- fixed init
|
||||
problem on serial consoles with 2.4.3+ kernels.
|
||||
|
||||
New Applets:
|
||||
* Laurence Anderson -- rpm2cpio applet, this obsoletes rpmunpack
|
||||
which has now been removed from BusyBox
|
||||
* Laurence Anderson and Glenn McGrath -- cpio applet, currently
|
||||
only supports unpacking the ascii cpio format.
|
||||
* Vladimir Oleynik and Erik Andersen -- added ash, the most correct
|
||||
busybox shell.
|
||||
* Larry Doolittle -- hush, small shell designed specifically
|
||||
for busybox. Quite usable but still a work in progress.
|
||||
* Erik Andersen -- msh, minix shell. A very small but capable shell
|
||||
that only uses vfork, so it can be used on uClinux systems.
|
||||
|
||||
Other Changes:
|
||||
* Sterling Huxley -- Several bugfixes for the vi applet.
|
||||
* Glenn McGrath -- Restructure unarchiving code to make more code
|
||||
common to the ar, cpio, dpkg, dpkg-deb applets.
|
||||
tar applet has not yet been assimilated...
|
||||
* Matt Kraai -- Rewrote cp, dirname, mkdir, mv, and rm.
|
||||
* Paul J.Y. Lahaie <pjlahaie@linuxcare.com> -- Fixed an endian-ness
|
||||
bug in md5sum (in 0.51, md5sum on big endian machines was broken)
|
||||
* Mark Whitley -- rewrote cut, major updates to grep and sed.
|
||||
* Erik Andersen -- bunches of insmod fixes. It should now always
|
||||
work (no more segfault or missing symbols problems).
|
||||
* Bernhard Kuhn <kuhn@lpr.e-technik.tu-muenchen.de> and Jinux Kim
|
||||
added uClinux/m68k insmod support.
|
||||
* Manuel Novoa III -- rewrote make_human_readable so ls, du, and df
|
||||
should work as expected. Eliminated use of floats.
|
||||
* Aaron Lehmann <aaronl@vitelus.com> -- Scrubbed gzip.c
|
||||
* Alan Modra <amodra@bigpond.net.au> -- fixed an hard to spot
|
||||
bug breaking gunzip checksum checking.
|
||||
* Gennady Feldman -- Fixed 'syslog -C'
|
||||
* Gernot Poerner <gp@it-netservice.de> -- Added mount bind support.
|
||||
* Adam Heath <doogie@debian.org> -- wget arbitrary header support
|
||||
* John Beppu -- updated the automagical doc generator
|
||||
* Zillions of other bugfixes, optimizations, and cleanups.
|
||||
|
||||
|
||||
|
||||
-Erik Andersen, 7 July 2001
|
||||
|
||||
|
||||
0.51
|
||||
Critical Bugfixes:
|
||||
* Erik Andersen -- Fixed a bug that could crash the shell in 0.50
|
||||
when pressing <Enter> on an empty line.
|
||||
* Gennady Feldman -- Fixed a bug that could crash the shell in 0.50
|
||||
when performing an 'export' in the shell.
|
||||
* Gennady Feldman -- fixed a syslogd bug where syslogd could cause
|
||||
the init process to block (which can break systems badly).
|
||||
|
||||
New Applets:
|
||||
* Sterling Huxley -- contributed a new vi applet! This is a very
|
||||
functional vi implementation in Only 22k.
|
||||
* Erik Andersen -- added env applet
|
||||
|
||||
Other changes:
|
||||
* Erik Andersen -- Split utility.c into libbb, which provides a
|
||||
much cleaner was for us to include shared functionality.
|
||||
* Erik Andersen -- Reorganized how and when busybox includes
|
||||
syscalls, aiding portability and (in this case) making the
|
||||
busybox work on ia64 systems.
|
||||
* Erik Andersen -- dpkg.c cleanup to use the updated gunzip interface.
|
||||
* Erik Andersen -- Cleanups for libc5, glibc, and uClibc.
|
||||
* Erik Andersen and Matt Kraai -- Cleanups for the human-readable
|
||||
output from ls, du, and df.
|
||||
* Laurence Anderson <laurence@zxmail.com> -- Fixed wget HTTP 1.1
|
||||
support and added chunked encoding so it is now RFC compliant.
|
||||
* John Beppu -- The busybox.pod documentation is now automagically
|
||||
generated from the source code. This makes it _much_ simpler.
|
||||
Now to update the docs, just update the usage message...
|
||||
* Dirk Behme <dirk.behme@de.bosch.com> -- Adjusted MIPS insmod
|
||||
support a bit for Mips RS3.
|
||||
* Christophe Boyanique -- egrep invoked the "init" applet in 0.50!
|
||||
* Larry Doolittle -- Added -Wshadow and fixed a number of shadowed
|
||||
variables
|
||||
* David Douthitt -- fixed 'find -print'
|
||||
* Gennady Feldman -- fixes for the syslogd circular buffer code
|
||||
* Jeff Garzik -- a number of structural cleanups, fixes for -Wshadow
|
||||
bugs, and similar problems.
|
||||
* Matt Kraai -- Added a new 'shutdown' action to busybox init. Now
|
||||
you can specify arbitrary behavior for 'ctrlaltdel' so now
|
||||
pressing CTL-ALT-DEL can do something else (or nothing).
|
||||
* Andreas Neuhaus <andy@fasta.fh-dortmund.de> -- fix for merging
|
||||
kernel command line environment variables into child environment
|
||||
for init.c
|
||||
* Glenn McGrath -- Fixed problems with dpkg and dpkg-deb applets
|
||||
* Glenn McGrath -- Don't try to automount devfs
|
||||
* Vladimir Oleynik -- optimizations for more.c
|
||||
* Vladimir Oleynik -- Added locale support to the shell, and fixed
|
||||
locale support in several other places
|
||||
* Vladimir Oleynik -- moved struct applet from busybox.c to applets.c
|
||||
* Vladimir Oleynik -- A size optimization for rdate
|
||||
* Vladimir Oleynik -- Fixed printf applets's locale handling
|
||||
* Vladimir Oleynik -- More cmdedit updates
|
||||
* Vladimir Oleynik -- Fixed `du' applet so it continues running
|
||||
after permission errors.
|
||||
* Vladimir Oleynik -- Reduced stack usage in recursive_action()
|
||||
* Pierre Peiffer <pierre.peiffer@sxb.bsf.alcatel.fr> -- made
|
||||
find_pid_by_name() cope with swapped out processes.
|
||||
* Jari Ruusu <jari.ruusu@pp.inet.fi> -- updates so that setting
|
||||
D_FILE_OFFSET_BITS=64 now works as expected.
|
||||
* Anthony Towns <aj@azure.humbug.org.au> -- fixed a bug with
|
||||
sed address range handling
|
||||
* Dmitry Zakharov <dmit@crp.bank.gov.ua> -- a number of updates
|
||||
to wget: support for ftp downloads, basic HTTP basic auth, handling
|
||||
of http redirects, when attempting to continue an aborted download
|
||||
but server doesn't support restarts then reopen output file in
|
||||
write mode, bugfix: when content-length not given, wget didn't
|
||||
download anything, if -c is not specified, it no longer default to
|
||||
restarting an aborted download.
|
||||
|
||||
|
||||
-Erik Andersen, 10 April 2001
|
||||
|
||||
|
||||
0.50
|
||||
* Erik Andersen -- added ifconfig interface status reporting
|
||||
* Erik Andersen -- Debian packaging updates
|
||||
* Erik Andersen -- lash environment variable expansion rewritten,
|
||||
with lots of help/fixes/testing from Larry Doolittle.
|
||||
* Erik Andersen -- Fix use of busybox with dmalloc debugging lib
|
||||
* Erik Andersen -- fixed ls behavior for broken or very narrow terminals
|
||||
* Erik Andersen -- stub umount2 and pivot_root if they are not available
|
||||
* Erik Andersen -- libc5 fixes
|
||||
* Erik Andersen -- make init work with devfsd
|
||||
* Erik Andersen -- fixed df for nfs and dos where blksize = 512
|
||||
* Erik Andersen -- Make sure libpwd.a is linked _last_ so it
|
||||
overrides the system pwd/grp
|
||||
* Christophe Boyanique -- added an optional egrep alias for grep.
|
||||
* Christophe Boyanique -- added optional 'rm -i' support.
|
||||
* Kenneth Chalmers and Erik Andersen -- fixed ln so it
|
||||
behaves when given no arguments (prints usage) and when
|
||||
given just one arg (tries to make a link in the cwd).
|
||||
* Magnus Damm -- added a tftp applet
|
||||
* Magnus Damm -- powerpc support for busybox insmod.
|
||||
* David Douthitt -- fixed a build error in df.c when
|
||||
BB_FEATURE_HUMAN_READABLE was disabled
|
||||
* John Beppu -- wrote autodocifier.pl, which will be used to auto-
|
||||
generate the documentation from the source code, making life
|
||||
much simpler for all.
|
||||
* Magnus Damm <damm@opensource.se> -- Fixed an 'inner scope var
|
||||
masking outer scope var with same name' bug that prevented
|
||||
the loopback device from being unmounted if mount() failed.
|
||||
* Larry Doolittle -- rewrote ifconfig to make it smaller
|
||||
* Larry Doolittle and Erik Andersen -- cleanups to pristine source
|
||||
* Larry Doolittle -- many bugfixes resulting from regression testing
|
||||
* Gennady Feldman -- split syslogd.c into syslogd and klogd
|
||||
* Gennady Feldman -- make syslogd single threaded -- no more forking
|
||||
* Jeff Garzik -- getopt-ified rmmod.
|
||||
* Jeff Garzik -- glibc 2.2 warning cleanups
|
||||
* Jeff Garzik -- namespace pollution cleanup (staticified variables).
|
||||
* Erik Gustavsson <cyrano@algonet.se> -- allow env variables set on the
|
||||
kernel command line to be inherited into init and its children.
|
||||
* Erik Habbinga -- fixed an uninitialized substitution delimiter in sed.
|
||||
* Chris Jaeger -- Makefile cleanup to make option setting less error-prone
|
||||
* Chris Jaeger <cjaeger@ensim.com> -- Carefully check NFS_MOUNT_VERSION
|
||||
depending on what kernel is being used.
|
||||
* Quinn Jensen <jensenq@lineo.com> -- MIPS support for busybox insmod.
|
||||
* Evin Robertson -- new pivot_root applet
|
||||
* Kent Robotti -- usage message cleanups
|
||||
* Kent Robotti -- reworked dos2unix/unix2dos
|
||||
* Evin Robertson and Manuel Novoa III -- reworked how usage messages
|
||||
are stored to save several k of space.
|
||||
* Matt Kraai -- Keep trying if an NFS mount fails
|
||||
* Matt Kraai -- fixed insmod so it won't try to insmod directories.
|
||||
* Matt Kraai -- added nc listening support
|
||||
* Matt Kraai and David Douthitt -- reworked fine to support -type,
|
||||
-perm, -mtime, and other improvements.
|
||||
* Matt Kraai -- added find_applet_by_name and saved some memory thereby
|
||||
* Matt Kraai -- added chomp to reduce redundant code elsewhere
|
||||
* Matt Kraai -- Removed trailing \n chars from error_msg{,_and_die} messages.
|
||||
* John Lombardo -- fixed OOM in insmod.
|
||||
* Glenn McGrath -- bypass /proc in mount, now uses sysfs.
|
||||
* Glenn McGrath -- several updates to dpkg and dpkg-deb.
|
||||
* Manuel Novoa III -- several size optimizations: parse_mode,
|
||||
process_escape_sequence, format, and get_kernel_revision.
|
||||
* Manuel Novoa III -- rewrote ifconfig again to make it smaller still
|
||||
* Manuel Novoa III -- added ifconfig -a, updated interface reporting
|
||||
* Vladimir N. Oleynik -- Fixed a bug where init set PATH incorrectly
|
||||
* Vladimir N. Oleynik -- cleanups to route, cmdedit, mkdir,
|
||||
mkfs_minix, mkswap, chmod_chown_chgrp and utility.c
|
||||
* Vladimir N. Oleynik -- many fixes to cmdedit. so tab completion
|
||||
is now working and general editing is much improved, and to
|
||||
improve complex prompt handling.
|
||||
* Vladimir N. Oleynik -- added route status reporting.
|
||||
* Vladimir N. Oleynik -- fixed wget to use xfopen
|
||||
* Vladimir N. Oleynik -- new stty applet
|
||||
* Vladimir N. Oleynik -- fixed find, it used to stop on perm errors.
|
||||
* Vladimir N. Oleynik -- locale forced to posix for scripts
|
||||
* Vladimir N. Oleynik -- saved 128 bytes by moving error checking
|
||||
for several my_* functions into utility.c
|
||||
* Bjorn Wesen -- new ifconfig and route applet (taken from
|
||||
work done by Axis Communications).
|
||||
* Mark Whitley -- Added a 'How to contribute to Busybox' doc
|
||||
and updated the style guide.
|
||||
* Mark Whitley -- implemented grep -A, -B, and -C
|
||||
* Mark Whitley -- overhauled the test suite.
|
||||
|
||||
|
||||
-Erik Andersen, 15 March 2001
|
||||
|
||||
0.49
|
||||
|
||||
* Matt Kraai -- new sort.c
|
||||
* Matt Kraai -- new tail.c
|
||||
* Glenn McGrath -- new 'dpkg-deb' applet
|
||||
* Glenn McGrath -- new ar code
|
||||
* spoon -- new watchdog applet
|
||||
* Vladimir N. Oleynik <dzo@simtreas.ru> -- fixed cmdedit.c so now
|
||||
scrolling and tab completion in lash work properly. Also several
|
||||
byte saving optimizations.
|
||||
* Erik Andersen -- disabled many less commonly used applets by default
|
||||
* Mark Whitley -- more thrashing about to get clean perror_msg usage
|
||||
* Matt Kraai -- new command line munging
|
||||
* Larry Doolittle -- keep some locales from messing up busybox.sh
|
||||
* Matt Kraai -- cleaned up dd and tail with new parse_number routine
|
||||
* Mark Whitley -- remove debugging messages from deallocvt
|
||||
* Matt Kraai and Mark Whitley -- new document "How to Add a New Applet
|
||||
to BusyBox"
|
||||
* David Douthitt -- fixed "grep -qv" bug
|
||||
* Larry Doolittle -- fixed insmod bug with old kernels
|
||||
* Matt Kraai -- logger remixed to use getopt, selection of stdin made
|
||||
util-linux compatible
|
||||
* Erik Andersen -- many more internal symbols classified static to
|
||||
avoid namespace pollution
|
||||
* Matt Kraai -- nc listening support
|
||||
* Erik Andersen -- made sed understand arbitrary regexp delimiters
|
||||
* Matt Kraai et al. -- more tar improvements and bug fixes, now
|
||||
handles regexp file exclusion
|
||||
* Larry Doolittle -- new script (multibuild.pl) to automate build rule
|
||||
checking
|
||||
* Matt Kraai -- update/cleanup of the docs on how to use init
|
||||
* Erik Andersen -- renamed all sh.c symbols per the style guide,
|
||||
better if-then-else-fi handling
|
||||
* Erik Andersen -- cleaner division of labor between cmdedit.c and sh.c
|
||||
* Larry Doolittle -- shell data structure cleanup, fixed buglets
|
||||
in read, exec, and piped builtins
|
||||
* Erik Andersen -- md5sum was broken in 0.48. Now fixed (and doesn't
|
||||
use getline, shrinking static compiles (since nothing else used it).
|
||||
* ?? -- squashed memory leak in shell prompt handling
|
||||
* Mark Whitley -- Updates to style guide
|
||||
* Mark Whitley -- Big cleanup in utility.c: style guide compliance,
|
||||
de-macro-ifying some variables and functions
|
||||
* Erik Andersen -- ls now honors BB_FEATURE_AUTOWIDTH so it can find
|
||||
the width and height of the console.
|
||||
* Erik Andersen -- insmod now ignores -L and accepts the -o option.
|
||||
* Erik Andersen -- updates so you can now select from the Makefile
|
||||
whether or not to use the system's passwd and group functions.
|
||||
Since most systems use GNU libc, this can save you from having to
|
||||
install the /etc/nsswitch.conf configuration file and the required
|
||||
libnss_* libraries. Adds 1.5k. You can now, also, disable this,
|
||||
causing busybox to use the system's pwd.h and grp.h functions.
|
||||
|
||||
|
||||
-Erik Andersen, 27 January 2001
|
||||
|
||||
0.48
|
||||
|
||||
* Glenn McGrath -- tar now supports uncompressing tar files,
|
||||
|
||||
@@ -2,119 +2,135 @@
|
||||
// This file defines the feature set to be compiled into busybox.
|
||||
// When you turn things off here, they won't be compiled in at all.
|
||||
//
|
||||
//// This file is parsed by sed. You MUST use single line comments.
|
||||
// i.e. //#define BB_BLAH
|
||||
//// This file is parsed by sed. You MUST use single line comments.
|
||||
// i.e., //#define BB_BLAH
|
||||
//
|
||||
//
|
||||
// BusyBox Applications
|
||||
#define BB_AR
|
||||
//#define BB_ADJTIMEX
|
||||
//#define BB_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
#define BB_CHGRP
|
||||
#define BB_CHMOD
|
||||
#define BB_CHOWN
|
||||
#define BB_CHROOT
|
||||
#define BB_CHVT
|
||||
#define BB_CLEAR
|
||||
#define BB_CMP
|
||||
#define BB_CP_MV
|
||||
//#define BB_CMP
|
||||
#define BB_CP
|
||||
//#define BB_CPIO
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
#define BB_DC
|
||||
//#define BB_DC
|
||||
#define BB_DD
|
||||
#define BB_DEALLOCVT
|
||||
//#define BB_DEALLOCVT
|
||||
#define BB_DF
|
||||
#define BB_DIRNAME
|
||||
#define BB_DMESG
|
||||
#define BB_DOS2UNIX
|
||||
#define BB_DUTMP
|
||||
//#define BB_DOS2UNIX
|
||||
//#define BB_DPKG
|
||||
//#define BB_DPKG_DEB
|
||||
//#define BB_DUTMP
|
||||
#define BB_DU
|
||||
#define BB_DUMPKMAP
|
||||
//#define BB_DUMPKMAP
|
||||
#define BB_ECHO
|
||||
#define BB_EXPR
|
||||
#define BB_FBSET
|
||||
#define BB_FDFLUSH
|
||||
#define BB_ENV
|
||||
//#define BB_EXPR
|
||||
//#define BB_FBSET
|
||||
//#define BB_FDFLUSH
|
||||
#define BB_FIND
|
||||
#define BB_FREE
|
||||
#define BB_FREERAMDISK
|
||||
#define BB_FSCK_MINIX
|
||||
#define BB_GETOPT
|
||||
//#define BB_FREERAMDISK
|
||||
//#define BB_FSCK_MINIX
|
||||
//#define BB_GETOPT
|
||||
#define BB_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
#define BB_HOSTID
|
||||
#define BB_HOSTNAME
|
||||
//#define BB_HOSTID
|
||||
//#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
//#define BB_IFCONFIG
|
||||
#define BB_INIT
|
||||
#define BB_INSMOD
|
||||
//#define BB_INSMOD
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_LENGTH
|
||||
#define BB_KLOGD
|
||||
//#define BB_LENGTH
|
||||
#define BB_LN
|
||||
#define BB_LOADACM
|
||||
#define BB_LOADFONT
|
||||
#define BB_LOADKMAP
|
||||
//#define BB_LOADACM
|
||||
//#define BB_LOADFONT
|
||||
//#define BB_LOADKMAP
|
||||
#define BB_LOGGER
|
||||
#define BB_LOGNAME
|
||||
//#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
#define BB_LSMOD
|
||||
#define BB_MAKEDEVS
|
||||
#define BB_MD5SUM
|
||||
//#define BB_MAKEDEVS
|
||||
//#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
#define BB_MKFIFO
|
||||
#define BB_MKFS_MINIX
|
||||
//#define BB_MKFIFO
|
||||
//#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
#define BB_MKSWAP
|
||||
#define BB_MKTEMP
|
||||
#define BB_NC
|
||||
//#define BB_MKTEMP
|
||||
//#define BB_NC
|
||||
#define BB_MORE
|
||||
#define BB_MOUNT
|
||||
#define BB_MT
|
||||
#define BB_NSLOOKUP
|
||||
#define BB_PING
|
||||
//#define BB_MT
|
||||
#define BB_MV
|
||||
//#define BB_NSLOOKUP
|
||||
//#define BB_PING
|
||||
//#define BB_PIVOT_ROOT
|
||||
#define BB_POWEROFF
|
||||
#define BB_PRINTF
|
||||
//#define BB_PRINTF
|
||||
#define BB_PS
|
||||
#define BB_PWD
|
||||
#define BB_RDATE
|
||||
#define BB_READLINK
|
||||
//#define BB_RDATE
|
||||
//#define BB_READLINK
|
||||
#define BB_REBOOT
|
||||
#define BB_RENICE
|
||||
//#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
#define BB_RMMOD
|
||||
#define BB_RPMUNPACK
|
||||
//#define BB_RMMOD
|
||||
//#define BB_ROUTE
|
||||
//#define BB_RPM2CPIO
|
||||
#define BB_SED
|
||||
#define BB_SETKEYCODES
|
||||
//#define BB_SETKEYCODES
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
//#define BB_STTY
|
||||
#define BB_SWAPONOFF
|
||||
#define BB_SYNC
|
||||
#define BB_SYSLOGD
|
||||
#define BB_TAIL
|
||||
#define BB_TAR
|
||||
#define BB_TEE
|
||||
#define BB_TEST
|
||||
#define BB_TELNET
|
||||
//#define BB_TEE
|
||||
//#define BB_TEST
|
||||
//#define BB_TELNET
|
||||
//#define BB_TFTP
|
||||
#define BB_TOUCH
|
||||
#define BB_TR
|
||||
//#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
#define BB_UPTIME
|
||||
#define BB_USLEEP
|
||||
#define BB_WC
|
||||
#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_UUENCODE
|
||||
#define BB_UUDECODE
|
||||
//#define BB_UNIX2DOS
|
||||
//#define BB_UUENCODE
|
||||
//#define BB_UUDECODE
|
||||
#define BB_UMOUNT
|
||||
#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
#define BB_UNIX2DOS
|
||||
#define BB_UPDATE
|
||||
//#define BB_UPDATE
|
||||
#define BB_UPTIME
|
||||
//#define BB_USLEEP
|
||||
//#define BB_VI
|
||||
//#define BB_WATCHDOG
|
||||
#define BB_WC
|
||||
//#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_XARGS
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
@@ -127,36 +143,73 @@
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
// If you enabled BB_SH above, you may select one of the following shells.
|
||||
// You can only select ONE of the following shells. Sorry.
|
||||
//
|
||||
// lash is the very smallest shell (adds just 10k) and it is quite usable as
|
||||
// a command prompt, but it is not suitable for any but the most trivial
|
||||
// scripting (such as an initrd that calls insmod a few times) since it does
|
||||
// not understand Bourne shell grammer. It does handle pipes, redirects, and
|
||||
// job control though. Adding in command editing makes it very nice
|
||||
// lightweight command prompt.
|
||||
//#define BB_FEATURE_LASH
|
||||
//
|
||||
// hush is also quite small (just 18k) and it has very complete Bourne shell
|
||||
// grammer. It handles if/then/else/fi just fine, but doesn't handle loops
|
||||
// like for/do/done or case/esac and such. It also currently has a problem
|
||||
// with job control.
|
||||
//#define BB_FEATURE_HUSH
|
||||
//
|
||||
// msh: The minix shell (adds just 30k) is quite complete and handles things
|
||||
// like for/do/done, case/esac and all the things you expect a Bourne shell to
|
||||
// do. It is not always pedantically correct about Bourne shell grammer (try
|
||||
// running the shell testscript "tests/sh.testcases" on it and compare vs bash)
|
||||
// but for most things it works quite well. It also uses only vfork, so it can
|
||||
// be used on uClinux systems. This was only recently added, so there is still
|
||||
// room to shrink it further...
|
||||
#define BB_FEATURE_MSH
|
||||
//
|
||||
// ash: This adds about 60k in the default configuration and is the most
|
||||
// complete and most pedantically correct shell included with busybox. This
|
||||
// shell was also recently added, and several people (mainly Vladimir and Erik)
|
||||
// have been working on it. There are a number of configurable things at the
|
||||
// top of ash.c as well, so check those out if you want to tweak things. The
|
||||
// Posix math support is currently disabled (that bit of code was horrible) but
|
||||
// will be restored for the next BusyBox release.
|
||||
//#define BB_FEATURE_ASH
|
||||
//
|
||||
// BusyBox will, by default, malloc space for its buffers. This costs code
|
||||
// size for the call to xmalloc. You can use the following feature to have
|
||||
// them put on the stack. For some very small machines with limited stack
|
||||
// space, this can be deadly. For most folks, this works just fine...
|
||||
//#define BB_FEATURE_BUFFERS_GO_ON_STACK
|
||||
// The third alternative for buffer allocation is to use 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 earlier.
|
||||
//#define BB_FEATURE_BUFFERS_GO_IN_BSS
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps, and devmtab kernel drivers,
|
||||
// thereby eliminating the need for the /proc filesystem and thereby saving
|
||||
// lots and lots memory for more important things. You can not use this and
|
||||
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
|
||||
// _must_ have patched the kernel to include the devps patch that is included
|
||||
// in the busybox/kernel-patches directory. You will also need to create some
|
||||
// device special files in /dev on your embedded system:
|
||||
// lots and lots memory for more important things. NOTE: If you enable this
|
||||
// feature, you _must_ have patched the kernel to include the devps patch that
|
||||
// is included in the busybox/kernel-patches directory. You will also need to
|
||||
// create some device special files in /dev on your embedded system:
|
||||
// mknod /dev/mtab c 10 22
|
||||
// mknod /dev/ps c 10 21
|
||||
// I emailed Linus and this patch will not be going into the stock kernel.
|
||||
//#define BB_FEATURE_USE_DEVPS_PATCH
|
||||
//
|
||||
// enable features that use the /proc filesystem (apps that
|
||||
// break without this will tell you on compile)...
|
||||
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
|
||||
// at the same time...
|
||||
#define BB_FEATURE_USE_PROCFS
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
//#define BB_FEATURE_TRIVIAL_HELP
|
||||
// show verbose usage messages
|
||||
//#define BB_FEATURE_VERBOSE_USAGE
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
//#define BB_FEATURE_USE_TERMIOS
|
||||
//
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames (bypasses libc6 NSS) for ls
|
||||
// show username/groupnames for ls
|
||||
#define BB_FEATURE_LS_USERNAME
|
||||
//
|
||||
// show file timestamps in ls
|
||||
@@ -174,8 +227,8 @@
|
||||
// enable ls -L
|
||||
#define BB_FEATURE_LS_FOLLOWLINKS
|
||||
//
|
||||
// Change ping implementation -- simplified, featureless, but really small.
|
||||
//#define BB_FEATURE_SIMPLE_PING
|
||||
// Disable for a smaller (but less functional) ping
|
||||
#define BB_FEATURE_FANCY_PING
|
||||
//
|
||||
// Make init use a simplified /etc/inittab file (recommended).
|
||||
#define BB_FEATURE_USE_INITTAB
|
||||
@@ -186,37 +239,32 @@
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
// Allow init to permenently chroot, and umount the old root fs
|
||||
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
|
||||
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
|
||||
//#define BB_FEATURE_INIT_CHROOT
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
//Should syslogd also provide klogd support?
|
||||
#define BB_FEATURE_KLOGD
|
||||
//#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f' support (only one file at a time.)
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
// enable syslogd -C
|
||||
//#define BB_FEATURE_IPC_SYSLOG
|
||||
//
|
||||
//Disable for a simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f', but this cuts out -c, -q, -s, and -v.
|
||||
#define BB_FEATURE_FANCY_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
#define BB_FEATURE_MOUNT_LOOP
|
||||
//
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
//#define BB_FEATURE_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes.
|
||||
// You may need to mount with "-o nolock" if you are
|
||||
// not running a local portmapper daemon...
|
||||
#define BB_FEATURE_NFSMOUNT
|
||||
//#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support forced filesystem unmounting
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
// (i.e., in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
@@ -228,16 +276,28 @@
|
||||
// Enable support for tar -z option (currently only works for inflating)
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
//
|
||||
//// Enable reverse sort
|
||||
// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable command line editing in the shell
|
||||
#define BB_FEATURE_SH_COMMAND_EDITING
|
||||
// Enable uniqe sort
|
||||
#define BB_FEATURE_SORT_UNIQUE
|
||||
//
|
||||
// Enable command line editing in the shell.
|
||||
// Only relevant if BB_SH is enabled. On by default.
|
||||
#define BB_FEATURE_COMMAND_EDITING
|
||||
//
|
||||
// Enable tab completion in the shell. This is now working quite nicely.
|
||||
// This feature adds a bit over 4k. Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
//
|
||||
// Attempts to match usernames in a ~-prefixed path
|
||||
//#define BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox applets as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell,
|
||||
//among other things.
|
||||
#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//among other things. Off by default.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
//#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
//When this is enabled, busybox shell applets can be called using full path
|
||||
//names. This causes applets (i.e., most busybox commands) to override
|
||||
@@ -245,11 +305,14 @@
|
||||
//will use BusyBox cat even if /bin/cat exists on the filesystem and is _not_
|
||||
//busybox. Some systems want this, others do not. Choose wisely. :-) This
|
||||
//only has meaning when BB_FEATURE_SH_STANDALONE_SHELL is enabled.
|
||||
//BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
// Only relevant if BB_SH is enabled. Off by default.
|
||||
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
//#define BB_FEATURE_SH_TAB_COMPLETION
|
||||
// Uncomment this option for a fancy shell prompt that includes the
|
||||
// current username and hostname. On systems that don't have usernames
|
||||
// or hostnames, this can look hideous.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
//#define BB_FEATURE_SH_FANCY_PROMPT
|
||||
//
|
||||
//Turn on extra fbset options
|
||||
//#define BB_FEATURE_FBSET_FANCY
|
||||
@@ -257,38 +320,91 @@
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support installing modules from pre 2.1 kernels
|
||||
//#define BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
// Support installing modules from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
// Support insmod/lsmod/rmmod for post 2.1 kernels
|
||||
//#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support modules status from pre 2.1 kernels
|
||||
//#define BB_FEATURE_LSMOD_OLD_KERNEL
|
||||
// Support modules status from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_LSMOD_NEW_KERNEL
|
||||
// Support insmod/lsmod/rmmod for pre 2.1 kernels
|
||||
//#define BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
//
|
||||
// Support for uClinux memory usage optimization, which will load the image
|
||||
// directly into the kernel memory. This divides memory requrements by three.
|
||||
// If you are not running uClinux (i.e., your CPU has an MMU) leave this
|
||||
// disabled...
|
||||
//#define BB_FEATURE_INSMOD_LOADINKMEM
|
||||
//
|
||||
// Support for Minix filesystem, version 2
|
||||
//#define BB_FEATURE_MINIX2
|
||||
//
|
||||
// Enable ifconfig status reporting output -- this feature adds 12k.
|
||||
//#define BB_FEATURE_IFCONFIG_STATUS
|
||||
//
|
||||
// Enable ifconfig slip-specific options "keepalive" and "outfill"
|
||||
//#define BB_FEATURE_IFCONFIG_SLIP
|
||||
//
|
||||
// Enable ifconfig options "mem_start", "io_addr", and "irq".
|
||||
//#define BB_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ
|
||||
//
|
||||
// Enable ifconfig option "hw". Currently works for only with "ether".
|
||||
//#define BB_FEATURE_IFCONFIG_HW
|
||||
//
|
||||
// Enable busybox --install [-s]
|
||||
// to create links (or symlinks) for all the commands that are
|
||||
// compiled into the binary. (needs /proc filesystem)
|
||||
// #define BB_FEATURE_INSTALLER
|
||||
//#define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Enable a nifty progress meter in wget (adds just under 2k)
|
||||
//#define BB_FEATURE_STATUSBAR
|
||||
#define BB_FEATURE_WGET_STATUSBAR
|
||||
//
|
||||
// Enable HTTP authentication in wget
|
||||
#define BB_FEATURE_WGET_AUTHENTICATION
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
//#define BB_FEATURE_CLEAN_UP
|
||||
//
|
||||
// Support for human readable output by ls, du, etc.(example 13k, 23M, 235G)
|
||||
#define BB_FEATURE_HUMAN_READABLE
|
||||
//
|
||||
// Support for the find -type option.
|
||||
#define BB_FEATURE_FIND_TYPE
|
||||
//
|
||||
// Support for the find -perm option.
|
||||
#define BB_FEATURE_FIND_PERM
|
||||
//
|
||||
// Support for the find -mtine option.
|
||||
#define BB_FEATURE_FIND_MTIME
|
||||
//
|
||||
// Support for the -A -B and -C context flags in grep
|
||||
//#define BB_FEATURE_GREP_CONTEXT
|
||||
//
|
||||
// Support for the EGREP applet (alias to the grep applet)
|
||||
//#define BB_FEATURE_GREP_EGREP_ALIAS
|
||||
//
|
||||
// Tell tftp what commands that should be supported.
|
||||
#define BB_FEATURE_TFTP_PUT
|
||||
#define BB_FEATURE_TFTP_GET
|
||||
//
|
||||
// features for vi
|
||||
#define BB_FEATURE_VI_COLON // ":" colon commands, no "ex" mode
|
||||
#define BB_FEATURE_VI_YANKMARK // Yank/Put commands and Mark cmds
|
||||
#define BB_FEATURE_VI_SEARCH // search and replace cmds
|
||||
#define BB_FEATURE_VI_USE_SIGNALS // catch signals
|
||||
#define BB_FEATURE_VI_DOT_CMD // remember previous cmd and "." cmd
|
||||
#define BB_FEATURE_VI_READONLY // vi -R and "view" mode
|
||||
#define BB_FEATURE_VI_SETOPTS // set-able options, ai ic showmatch
|
||||
#define BB_FEATURE_VI_SET // :set
|
||||
#define BB_FEATURE_VI_WIN_RESIZE // handle window resize
|
||||
//
|
||||
// Enable a if you system have setuped locale
|
||||
//#define BB_LOCALE_SUPPORT
|
||||
//
|
||||
// Support for TELNET to pass TERM type to remote host. Adds 384 bytes.
|
||||
#define BB_FEATURE_TELNET_TTYPE
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
@@ -300,59 +416,69 @@
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
|
||||
#define BB_CMDEDIT
|
||||
#if defined BB_SH
|
||||
#if defined BB_FEATURE_COMMAND_EDITING
|
||||
#define BB_CMDEDIT
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
#undef BB_FEATURE_SH_FANCY_PROMPT
|
||||
#endif
|
||||
#if ! defined BB_FEATURE_LASH && ! defined BB_FEATURE_HUSH && ! defined BB_FEATURE_MSH && ! defined BB_FEATURE_ASH
|
||||
#define BB_FEATURE_MSH
|
||||
#endif
|
||||
#if defined BB_FEATURE_ASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
|
||||
#undef BB_FEATURE_LASH
|
||||
#undef BB_FEATURE_HUSH
|
||||
#undef BB_FEATURE_MSH
|
||||
#elif defined BB_FEATURE_MSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
|
||||
#undef BB_FEATURE_LASH
|
||||
#undef BB_FEATURE_HUSH
|
||||
#undef BB_FEATURE_ASH
|
||||
#elif defined BB_FEATURE_HUSH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
|
||||
#undef BB_FEATURE_LASH
|
||||
#undef BB_FEATURE_MSH
|
||||
#undef BB_FEATURE_ASH
|
||||
#elif defined BB_FEATURE_LASH && (defined BB_FEATURE_LASH || defined BB_FEATURE_HUSH || defined BB_FEATURE_MSH)
|
||||
#undef BB_FEATURE_HUSH
|
||||
#undef BB_FEATURE_MSH
|
||||
#undef BB_FEATURE_ASH
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
#undef BB_FEATURE_SH_STANDALONE_SHELL
|
||||
#undef BB_FEATURE_SH_FANCY_PROMPT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
#ifndef BB_INIT
|
||||
#define BB_INIT
|
||||
#endif
|
||||
#define BB_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_TAR
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#undef BB_FEATURE_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD
|
||||
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
#if defined BB_INSMOD || defined BB_LSMOD
|
||||
#if ! defined BB_FEATURE_NEW_MODULE_INTERFACE && ! defined BB_FEATURE_OLD_MODULE_INTERFACE
|
||||
#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_SYSLOGD
|
||||
#if defined BB_FEATURE_IPC_SYSLOG
|
||||
#define BB_LOGREAD
|
||||
#endif
|
||||
#endif
|
||||
-323
@@ -1,323 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
|
||||
// NOTE: This file only defines features usefull under the Hurd,
|
||||
// To compile for the Hurd raname this to Config.h prior to make
|
||||
|
||||
// This file defines the feature set to be compiled into busybox.
|
||||
// When you turn things off here, they won't be compiled in at all.
|
||||
//
|
||||
//// This file is parsed by sed. You MUST use single line comments.
|
||||
// i.e. //#define BB_BLAH
|
||||
//
|
||||
//
|
||||
// BusyBox Applications
|
||||
#define BB_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
#define BB_CHROOT
|
||||
//#define BB_CHVT /* not needed */
|
||||
#define BB_CLEAR
|
||||
#define BB_CP_MV
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
#define BB_DC
|
||||
#define BB_DD
|
||||
//#define BB_DEALLOCVT /* inot needed */
|
||||
//#define BB_DF /* different implementation */
|
||||
#define BB_DIRNAME
|
||||
//#define BB_DMESG /* doesnt compile, different implementation */
|
||||
#define BB_DUTMP
|
||||
#define BB_DU
|
||||
//#define BB_DUMPKMAP /* not needed */
|
||||
#define BB_ECHO
|
||||
#define BB_EXPR
|
||||
//#define BB_FBSET /* not needed, doesnt compile */
|
||||
//#define BB_FDFLUSH /* is this needed? */
|
||||
#define BB_FIND
|
||||
//#define BB_FREE /* doesnt compile */
|
||||
#define BB_FREERAMDISK /* does hurd support ramdisks ? */
|
||||
#define BB_FSCK_MINIX
|
||||
#define BB_GETOPT
|
||||
#define BB_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
#define BB_HOSTID
|
||||
#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
//#define BB_INIT /* not needed?, doesnt compile */
|
||||
//#define BB_INSMOD /* not needed, doesnt compile */
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_LENGTH
|
||||
#define BB_LN
|
||||
//#define BB_LOADACM /* not needed, doesnt compile */
|
||||
//#define BB_LOADFONT /* not needed, doesnt compile */
|
||||
//#define BB_LOADKMAP /* not needed */
|
||||
#define BB_LOGGER
|
||||
#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
//#define BB_LSMOD /* not needed, doesnt compile */
|
||||
//#define BB_MAKEDEVS /* different implementation */
|
||||
#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
#define BB_MKFIFO
|
||||
#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
//#define BB_MKSWAP /* different impelementation (i think) */
|
||||
#define BB_MKTEMP
|
||||
#define BB_NC
|
||||
#define BB_MORE
|
||||
//#define BB_MOUNT /* different implementation */
|
||||
#define BB_MT
|
||||
#define BB_NSLOOKUP
|
||||
//#define BB_PING /* doesnt compile, Hurd uses BSD style ip.h */
|
||||
//#define BB_POWEROFF /* different implementation i assume */
|
||||
#define BB_PRINTF
|
||||
//#define BB_PS /* needs /proc */
|
||||
#define BB_PWD
|
||||
#define BB_RDATE
|
||||
//#define BB_REBOOT /* different implementation */
|
||||
#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
//#define BB_RMMOD /* not needed, doesnt compile */
|
||||
#define BB_SED
|
||||
//#define BB_SETKEYCODES /* is this needed ? */
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
//#define BB_SWAPONOFF /* different implementation, doesnt compile */
|
||||
#define BB_SYNC
|
||||
//#define BB_SYSLOGD /* doesnt compile */
|
||||
#define BB_TAIL
|
||||
#define BB_TAR
|
||||
#define BB_TEE
|
||||
#define BB_TEST
|
||||
#define BB_TELNET
|
||||
#define BB_TOUCH
|
||||
#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
//#define BB_UPTIME /* doesnt compile */
|
||||
#define BB_USLEEP
|
||||
#define BB_WC
|
||||
#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_UUENCODE
|
||||
#define BB_UUDECODE
|
||||
//#define BB_UMOUNT /* different implementation */
|
||||
#define BB_UNIQ
|
||||
//#define BB_UNAME /* doesnt compile */
|
||||
//#define BB_UPDATE /* doesnt compile */
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------
|
||||
// This is where feature definitions go. Generally speaking,
|
||||
// turning this stuff off makes things a bit smaller (and less
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps and devmtab kernel drivers,
|
||||
// thereby eliminating the need for the /proc filesystem and thereby saving
|
||||
// lots and lots memory for more important things. You can not use this and
|
||||
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
|
||||
// _must_ have patched the kernel to include the devps patch that is included
|
||||
// in the busybox/kernel-patches directory. You will also need to create some
|
||||
// device special files in /dev on your embedded system:
|
||||
// mknod /dev/mtab c 10 22
|
||||
// mknod /dev/ps c 10 21
|
||||
// I emailed Linus and this patch will not be going into the stock kernel.
|
||||
//#define BB_FEATURE_USE_DEVPS_PATCH
|
||||
//
|
||||
// enable features that use the /proc filesystem (apps that
|
||||
// break without this will tell you on compile)...
|
||||
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
|
||||
// at the same time...
|
||||
#define BB_FEATURE_USE_PROCFS
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
//#define BB_FEATURE_TRIVIAL_HELP
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
//
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames (bypasses libc6 NSS) for ls
|
||||
#define BB_FEATURE_LS_USERNAME
|
||||
//
|
||||
// show file timestamps in ls
|
||||
#define BB_FEATURE_LS_TIMESTAMPS
|
||||
//
|
||||
// enable ls -p and -F
|
||||
#define BB_FEATURE_LS_FILETYPES
|
||||
//
|
||||
// sort the file names (still a bit buggy)
|
||||
#define BB_FEATURE_LS_SORTFILES
|
||||
//
|
||||
// enable ls -R
|
||||
#define BB_FEATURE_LS_RECURSIVE
|
||||
//
|
||||
// Change ping implementation -- simplified, featureless, but really small.
|
||||
#define BB_FEATURE_SIMPLE_PING
|
||||
//
|
||||
// Make init use a simplified /etc/inittab file (recommended).
|
||||
#define BB_FEATURE_USE_INITTAB
|
||||
//
|
||||
//Enable init being called as /linuxrc
|
||||
//#define BB_FEATURE_LINUXRC
|
||||
//
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
// Allow init to permenently chroot, and umount the old root fs
|
||||
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
|
||||
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
|
||||
//#define BB_FEATURE_INIT_CHROOT
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
//Should syslogd also provide klogd support?
|
||||
#define BB_FEATURE_KLOGD
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f' support (only one file at a time.)
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
//#define BB_FEATURE_MOUNT_LOOP
|
||||
//
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes
|
||||
//#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support forced filesystem unmounting
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
// Enable support for "--exclude" for excluding files
|
||||
#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
//// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable command line editing in the shell
|
||||
#define BB_FEATURE_SH_COMMAND_EDITING
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox commands as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell
|
||||
//among other thing.
|
||||
#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
//#define BB_FEATURE_SH_TAB_COMPLETION
|
||||
//
|
||||
//Turn on extra fbset options
|
||||
//#define BB_FEATURE_FBSET_FANCY
|
||||
//
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support installing modules from pre 2.1 kernels
|
||||
//#define BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
// Support installing modules from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
//
|
||||
// Support for Minix filesystem, version 2
|
||||
//#define BB_FEATURE_MINIX2
|
||||
//
|
||||
//
|
||||
// Enable busybox --install [-s]
|
||||
// to create links (or symlinks) for all the commands that are
|
||||
// compiled into the binary. (needs /proc filesystem)
|
||||
// #define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
//#define BB_FEATURE_CLEAN_UP
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING && defined BB_SH
|
||||
#define BB_CMDEDIT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
#ifndef BB_INIT
|
||||
#define BB_INIT
|
||||
#endif
|
||||
#define BB_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_SH_COMMAND_EDITING
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_INSMOD
|
||||
#ifndef BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
1) Check Config.h and adjust if you need a different functionality than
|
||||
defined by default.
|
||||
|
||||
2) Check the Makefile
|
||||
|
||||
3) make
|
||||
|
||||
4) make install
|
||||
@@ -18,7 +18,7 @@ mini-gzip(gzip), mini-netcat(mnc)
|
||||
Copyright 1998 Charles P. Wright <cpwright@villagenet.com>
|
||||
|
||||
Tons of new stuff as noted in header files
|
||||
Copyright (C) 1999 by Lineo, inc. and written by
|
||||
Copyright (C) 1999,2000,2001 by Lineo, inc. and written by
|
||||
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2000 Erik Andersen <andersee@debian.org>
|
||||
# Copyright (C) 2000 Karl M. Hegbloom <karlheg@debian.org>
|
||||
# Copyright (C) 1999,2000,2001 Erik Andersen <andersee@debian.org>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -19,8 +18,8 @@
|
||||
#
|
||||
|
||||
PROG := busybox
|
||||
VERSION := 0.48
|
||||
BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
|
||||
VERSION := 0.52
|
||||
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
|
||||
export VERSION
|
||||
|
||||
# With a modern GNU make(1) (highly recommended, that's what all the
|
||||
@@ -28,15 +27,30 @@ export VERSION
|
||||
# overridden at the command line. For example:
|
||||
# make CROSS=powerpc-linux- BB_SRC_DIR=$HOME/busybox PREFIX=/mnt/app
|
||||
|
||||
# If you want to add some simple compiler switches (like -march=i686),
|
||||
# especially from the command line, use this instead of CFLAGS directly.
|
||||
# For optimization overrides, it's better still to set OPTIMIZATION.
|
||||
CFLAGS_EXTRA =
|
||||
|
||||
# If you want a static binary, turn this on.
|
||||
DOSTATIC = false
|
||||
|
||||
# Set the following to `true' to make a debuggable build.
|
||||
# Leave this set to `false' for production use.
|
||||
# eg: `make DODEBUG=true tests'
|
||||
# Do not enable this for production builds...
|
||||
DODEBUG = false
|
||||
|
||||
# Setting this to `true' will cause busybox to directly use the system's
|
||||
# password and group functions. Assuming you use GNU libc, when this is
|
||||
# `true', you will need to install the /etc/nsswitch.conf configuration file
|
||||
# and the required libnss_* libraries. This generally makes your embedded
|
||||
# system quite a bit larger... If you leave this off, busybox will directly use
|
||||
# the /etc/password, /etc/group files (and your system will be smaller, and I
|
||||
# will get fewer emails asking about how glibc NSS works). Enabling this adds
|
||||
# just 1.4k to the binary size (which is a _lot_ less then glibc NSS costs).
|
||||
# Note that if you want hostname resolution to work with glibc, you still need
|
||||
# the libnss_* libraries. Most people will want to leave this set to false.
|
||||
USE_SYSTEM_PWD_GRP = true
|
||||
|
||||
# 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
|
||||
@@ -45,6 +59,10 @@ DODEBUG = false
|
||||
# Do not enable this for production builds...
|
||||
DODMALLOC = false
|
||||
|
||||
# Electric-fence is another very useful malloc debugging library.
|
||||
# Do not enable this for production builds...
|
||||
DOEFENCE = false
|
||||
|
||||
# If you want large file summit support, turn this on.
|
||||
# This has no effect if you don't have a kernel with lfs
|
||||
# support, and a system with libc-2.1.3 or later.
|
||||
@@ -57,44 +75,73 @@ DOLFS = false
|
||||
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
|
||||
# Experimental and incomplete; tell the mailing list
|
||||
# <busybox@opensource.lineo.com> if you do or don't like it so far.
|
||||
BB_SRC_DIR = .
|
||||
BB_SRC_DIR =
|
||||
|
||||
# If you are running a cross compiler, you may want to set this
|
||||
# to something more interesting, like "powerpc-linux-".
|
||||
CROSS =
|
||||
CC = $(CROSS)gcc
|
||||
AR = $(CROSS)ar
|
||||
STRIPTOOL = $(CROSS)strip
|
||||
|
||||
# To compile vs an alternative libc, you may need to use/adjust
|
||||
# the following lines to meet your needs. This is how I make
|
||||
# busybox compile with uC-Libc (needs BB_GETOPT and BB_FEATURE_NFSMOUNT
|
||||
# disabled at the moment).
|
||||
#LIBCDIR=/home/andersen/CVS/uClibc
|
||||
# To compile vs uClibc, just use the compiler wrapper built by uClibc...
|
||||
# This make things very easy? Everything should compile and work as
|
||||
# expected these days...
|
||||
#CC = ../uClibc/extra/gcc-uClibc/i386-uclibc-gcc
|
||||
|
||||
# To compile vs some other alternative libc, you may need to use/adjust
|
||||
# the following lines to meet your needs...
|
||||
#
|
||||
# If you are using Red Hat 6.x with the compatible RPMs (for developing under
|
||||
# Red Hat 5.x and glibc 2.0) uncomment the following. Be sure to read about
|
||||
# using the compatible RPMs (compat-*) at http://www.redhat.com !
|
||||
#LIBCDIR=/usr/i386-glibc20-linux
|
||||
#
|
||||
# The following is used for libc5 (if you install altgcc and libc5-altdev
|
||||
# on a Debian system).
|
||||
#LIBCDIR=/usr/i486-linuxlibc1
|
||||
#
|
||||
# For other libraries, you are on your own...
|
||||
#LDFLAGS+=-nostdlib
|
||||
#LIBRARIES = $(LIBCDIR)/libc.a -lgcc
|
||||
#LIBRARIES = $(LIBCDIR)/lib/libc.a -lgcc
|
||||
#CROSS_CFLAGS+=-nostdinc -I$(LIBCDIR)/include -I$(GCCINCDIR)
|
||||
#GCCINCDIR = $(shell gcc -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
|
||||
|
||||
#--------------------------------------------------------
|
||||
|
||||
# use '-Os' optimization if available, else use -O2
|
||||
OPTIMIZATION = $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
|
||||
OPTIMIZATION := $(shell if $(CC) -Os -S -o /dev/null -xc /dev/null >/dev/null 2>&1; \
|
||||
then echo "-Os"; else echo "-O2" ; fi)
|
||||
|
||||
WARNINGS = -Wall
|
||||
WARNINGS = -Wall -Wshadow
|
||||
|
||||
ifeq ($(DOLFS),true)
|
||||
ARFLAGS = -r
|
||||
|
||||
#
|
||||
#--------------------------------------------------------
|
||||
# If you're going to do a lot of builds with a non-vanilla configuration,
|
||||
# it makes sense to adjust parameters above, so you can type "make"
|
||||
# by itself, instead of following it by the same half-dozen overrides
|
||||
# every time. The stuff below, on the other hand, is probably less
|
||||
# prone to casual user adjustment.
|
||||
#
|
||||
|
||||
ifeq ($(strip $(DOLFS)),true)
|
||||
# For large file summit support
|
||||
CFLAGS+=-D_FILE_OFFSET_BITS=64
|
||||
endif
|
||||
ifeq ($(DODMALLOC),true)
|
||||
ifeq ($(strip $(DODMALLOC)),true)
|
||||
# For testing mem leaks with dmalloc
|
||||
CFLAGS+=-DDMALLOC
|
||||
LIBRARIES = -ldmalloc
|
||||
# Force debug=true, since this is useless when not debugging...
|
||||
DODEBUG = true
|
||||
else
|
||||
ifeq ($(strip $(DOEFENCE)),true)
|
||||
LIBRARIES = -lefence
|
||||
# Force debug=true, since this is useless when not debugging...
|
||||
DODEBUG = true
|
||||
endif
|
||||
endif
|
||||
ifeq ($(DODEBUG),true)
|
||||
ifeq ($(strip $(DODEBUG)),true)
|
||||
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
|
||||
LDFLAGS += -Wl,-warn-common
|
||||
STRIP =
|
||||
@@ -103,7 +150,7 @@ else
|
||||
LDFLAGS += -s -Wl,-warn-common
|
||||
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
|
||||
endif
|
||||
ifeq ($(DOSTATIC),true)
|
||||
ifeq ($(strip $(DOSTATIC)),true)
|
||||
LDFLAGS += --static
|
||||
#
|
||||
#use '-ffunction-sections -fdata-sections' and '--gc-sections' (if they
|
||||
@@ -123,57 +170,145 @@ ifndef $(PREFIX)
|
||||
endif
|
||||
|
||||
# Additional complications due to support for pristine source dir.
|
||||
# Config.h in the build directory should take precedence over the
|
||||
# copy in BB_SRC_DIR, both during the compilation phase and the
|
||||
# Include files in the build directory should take precedence over
|
||||
# the copy in BB_SRC_DIR, both during the compilation phase and the
|
||||
# shell script that finds the list of object files.
|
||||
#
|
||||
# Work in progress by <ldoolitt@recycle.lbl.gov>.
|
||||
# If it gets in your way, set DISABLE_VPATH=yes
|
||||
ifeq ($(DISABLE_VPATH),yes)
|
||||
CONFIG_H = Config.h
|
||||
else
|
||||
VPATH = .:$(BB_SRC_DIR)
|
||||
CONFIG_LIST = $(addsuffix /Config.h,$(subst :, ,$(VPATH)))
|
||||
CONFIG_H = $(word 1,$(shell ls -f -1 $(CONFIG_LIST) 2>/dev/null))
|
||||
CFLAGS += -I- $(patsubst %,-I%,$(subst :, ,$(VPATH))) $(CROSS_CFLAGS)
|
||||
#
|
||||
ifneq ($(strip $(BB_SRC_DIR)),)
|
||||
VPATH = $(BB_SRC_DIR)
|
||||
endif
|
||||
#ifneq ($(strip $(VPATH)),)
|
||||
# CFLAGS += -I- -I. $(patsubst %,-I%,$(subst :, ,$(VPATH)))
|
||||
#endif
|
||||
|
||||
OBJECTS = $(shell $(BB_SRC_DIR)/busybox.sh $(CONFIG_H) $(BB_SRC_DIR)) busybox.o messages.o usage.o utility.o
|
||||
# We need to set APPLET_SOURCES to something like
|
||||
# $(shell busybox.sh Config.h)
|
||||
# but in a manner that works with VPATH and BB_SRC_DIR.
|
||||
# Possible ways to approach this:
|
||||
#
|
||||
# 1. Explicitly search through .:$(VPATH) for busybox.sh and config.h,
|
||||
# then $(shell $(BUSYBOX_SH) $(CONFIG_H) $(BB_SRC_DIR))
|
||||
#
|
||||
# 2. Explicity search through .:$(VPATH) for slist.mk,
|
||||
# then $(shell $(MAKE) -f $(SLIST_MK) VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR))
|
||||
#
|
||||
# 3. Create slist.mk in this directory, with commands embedded in
|
||||
# a $(shell ...) command, and $(MAKE) it immediately.
|
||||
#
|
||||
# 4. Use a real rule within this makefile to create a file that sets
|
||||
# APPLET_SOURCE_LIST, then include that file. Has complications
|
||||
# with the first trip through the makefile (before processing the
|
||||
# include) trying to do too much, and a spurious warning the first
|
||||
# time make is run.
|
||||
#
|
||||
# This is option 3:
|
||||
#
|
||||
#APPLET_SOURCES = $(shell \
|
||||
# echo -e 'all: busybox.sh Config.h\n\t@ $$(SHELL) $$^ $$(BB_SRC_DIR)' >slist.mk; \
|
||||
# make -f slist.mk VPATH=$(VPATH) BB_SRC_DIR=$(BB_SRC_DIR) \
|
||||
#)
|
||||
# And option 4:
|
||||
-include applet_source_list
|
||||
|
||||
OBJECTS = $(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
|
||||
CFLAGS += $(CROSS_CFLAGS)
|
||||
CFLAGS += -DBB_VER='"$(VERSION)"'
|
||||
CFLAGS += -DBB_BT='"$(BUILDTIME)"'
|
||||
ifdef BB_INIT_SCRIPT
|
||||
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
|
||||
endif
|
||||
|
||||
ifneq ($(strip $(USE_SYSTEM_PWD_GRP)),true)
|
||||
PWD_GRP = pwd_grp
|
||||
PWD_GRP_DIR = $(BB_SRC_DIR:=/)$(PWD_GRP)
|
||||
PWD_LIB = libpwd.a
|
||||
PWD_CSRC=__getpwent.c pwent.c getpwnam.c getpwuid.c putpwent.c getpw.c \
|
||||
fgetpwent.c __getgrent.c grent.c getgrnam.c getgrgid.c fgetgrent.c \
|
||||
initgroups.c setgroups.c
|
||||
PWD_OBJS=$(patsubst %.c,$(PWD_GRP)/%.o, $(PWD_CSRC))
|
||||
PWD_CFLAGS = -I$(PWD_GRP_DIR)
|
||||
else
|
||||
CFLAGS += -DUSE_SYSTEM_PWD_GRP
|
||||
endif
|
||||
|
||||
LIBBB = libbb
|
||||
LIBBB_LIB = libbb.a
|
||||
LIBBB_CSRC= ask_confirmation.c chomp.c concat_path_file.c copy_file.c \
|
||||
copy_file_chunk.c daemon.c device_open.c error_msg.c \
|
||||
error_msg_and_die.c fgets_str.c find_mount_point.c find_pid_by_name.c \
|
||||
find_root_device.c full_read.c full_write.c get_console.c \
|
||||
get_last_path_component.c get_line_from_file.c gz_open.c human_readable.c \
|
||||
isdirectory.c kernel_version.c loop.c mode_string.c module_syscalls.c mtab.c \
|
||||
mtab_file.c my_getgrnam.c my_getgrgid.c my_getpwnam.c my_getpwnamegid.c \
|
||||
my_getpwuid.c parse_mode.c parse_number.c perror_msg.c perror_msg_and_die.c \
|
||||
print_file.c process_escape_sequence.c read_package_field.c recursive_action.c \
|
||||
safe_read.c safe_strncpy.c syscalls.c syslog_msg_with_name.c time_string.c \
|
||||
trim.c unzip.c vdprintf.c verror_msg.c vperror_msg.c wfopen.c xfuncs.c \
|
||||
xgetcwd.c xreadlink.c xregcomp.c interface.c remove_file.c last_char_is.c \
|
||||
copyfd.c vherror_msg.c herror_msg.c herror_msg_and_die.c xgethostbyname.c \
|
||||
dirname.c make_directory.c
|
||||
LIBBB_OBJS=$(patsubst %.c,$(LIBBB)/%.o, $(LIBBB_CSRC))
|
||||
LIBBB_CFLAGS = -I$(LIBBB)
|
||||
ifneq ($(strip $(BB_SRC_DIR)),)
|
||||
LIBBB_CFLAGS += -I$(BB_SRC_DIR)/$(LIBBB)
|
||||
endif
|
||||
|
||||
all: busybox busybox.links doc
|
||||
LIBBB_MSRC=libbb/messages.c
|
||||
LIBBB_MESSAGES= full_version name_too_long omitting_directory not_a_directory \
|
||||
memory_exhausted invalid_date invalid_option io_error dash_dash_help \
|
||||
write_error too_few_args name_longer_than_foo unknown
|
||||
LIBBB_MOBJ=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_MESSAGES))
|
||||
|
||||
LIBBB_ARCSRC=libbb/unarchive.c
|
||||
LIBBB_ARCOBJ= archive_offset seek_sub_file extract_archive unarchive \
|
||||
get_header_ar get_header_cpio get_header_tar deb_extract
|
||||
LIBBB_AROBJS=$(patsubst %,$(LIBBB)/%.o, $(LIBBB_ARCOBJ))
|
||||
|
||||
|
||||
# Put user-supplied flags at the end, where they
|
||||
# have a chance of winning.
|
||||
CFLAGS += $(CFLAGS_EXTRA)
|
||||
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
all: applet_source_list busybox busybox.links doc
|
||||
|
||||
applet_source_list: busybox.sh Config.h
|
||||
(echo -n "APPLET_SOURCES := "; BB_SRC_DIR=$(BB_SRC_DIR) $(SHELL) $^) > $@
|
||||
|
||||
doc: olddoc
|
||||
|
||||
# Old Docs...
|
||||
olddoc: docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
|
||||
olddoc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
|
||||
|
||||
docs/busybox.pod : docs/busybox_header.pod usage.h docs/busybox_footer.pod
|
||||
- ( cat docs/busybox_header.pod; \
|
||||
docs/autodocifier.pl usage.h; \
|
||||
cat docs/busybox_footer.pod ) > docs/busybox.pod
|
||||
|
||||
docs/BusyBox.txt: docs/busybox.pod
|
||||
@echo
|
||||
@echo BusyBox Documentation
|
||||
@echo
|
||||
-mkdir -p docs
|
||||
-pod2text $(BB_SRC_DIR)/docs/busybox.pod > docs/BusyBox.txt
|
||||
-pod2text $< > $@
|
||||
|
||||
docs/BusyBox.1: docs/busybox.pod
|
||||
- mkdir -p docs
|
||||
- pod2man --center=BusyBox --release="version $(VERSION)" \
|
||||
$(BB_SRC_DIR)/docs/busybox.pod > docs/BusyBox.1
|
||||
$< > $@
|
||||
|
||||
docs/BusyBox.html: docs/busybox.lineo.com/BusyBox.html
|
||||
- mkdir -p docs
|
||||
-@ rm -f docs/BusyBox.html
|
||||
-@ ln -s busybox.lineo.com/BusyBox.html docs/BusyBox.html
|
||||
|
||||
docs/busybox.lineo.com/BusyBox.html: docs/busybox.pod
|
||||
-@ mkdir -p docs/busybox.lineo.com
|
||||
- pod2html --noindex $(BB_SRC_DIR)/docs/busybox.pod > \
|
||||
- pod2html --noindex $< > \
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
-@ rm -f pod2html*
|
||||
-@ rm -f pod2htm*
|
||||
|
||||
|
||||
# New docs based on DOCBOOK SGML
|
||||
@@ -203,24 +338,57 @@ docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
|
||||
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
|
||||
|
||||
|
||||
|
||||
busybox: $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) -o $@ $^ $(LIBRARIES)
|
||||
busybox: $(PWD_LIB) $(LIBBB_LIB) $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBBB_LIB) $(PWD_LIB) $(LIBRARIES)
|
||||
$(STRIP)
|
||||
|
||||
busybox.links: Config.h
|
||||
- $(BB_SRC_DIR)/busybox.mkll $(CONFIG_H) $(BB_SRC_DIR)/applets.h >$@
|
||||
# Without VPATH, rule expands to "/bin/sh busybox.mkll Config.h applets.h"
|
||||
# but with VPATH, some or all of those file names are resolved to the
|
||||
# directories in which they live.
|
||||
busybox.links: busybox.mkll Config.h applets.h
|
||||
- $(SHELL) $^ >$@
|
||||
|
||||
nfsmount.o cmdedit.o: %.o: %.h
|
||||
$(OBJECTS): %.o: %.c Config.h busybox.h Makefile
|
||||
sh.o: cmdedit.h
|
||||
$(OBJECTS): %.o: %.c Config.h busybox.h applets.h Makefile
|
||||
$(CC) -I- $(CFLAGS) -I. $(patsubst %,-I%,$(subst :, ,$(BB_SRC_DIR))) -c $< -o $*.o
|
||||
|
||||
utility.o: loop.h
|
||||
$(PWD_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile
|
||||
- mkdir -p $(PWD_GRP)
|
||||
$(CC) $(CFLAGS) $(PWD_CFLAGS) -c $< -o $*.o
|
||||
|
||||
loop.h: mk_loop_h.sh
|
||||
@ sh $<
|
||||
$(LIBBB_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile libbb/libbb.h
|
||||
- mkdir -p $(LIBBB)
|
||||
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -c $< -o $*.o
|
||||
|
||||
$(LIBBB_MOBJ): $(LIBBB_MSRC)
|
||||
- mkdir -p $(LIBBB)
|
||||
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o
|
||||
|
||||
$(LIBBB_AROBJS): $(LIBBB_ARCSRC)
|
||||
- mkdir -p $(LIBBB)
|
||||
$(CC) $(CFLAGS) $(LIBBB_CFLAGS) -DL_$(patsubst libbb/%,%,$*) -c $< -o $*.o
|
||||
|
||||
libpwd.a: $(PWD_OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
libbb.a: $(LIBBB_MOBJ) $(LIBBB_AROBJS) $(LIBBB_OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
usage.o: usage.h
|
||||
|
||||
sh.o: sh.c lash.c hush.c msh.c ash.c
|
||||
|
||||
libbb/loop.o: libbb/loop.h
|
||||
|
||||
libbb/loop.h: mk_loop_h.sh
|
||||
@ $(SHELL) $< > $@
|
||||
|
||||
test tests:
|
||||
cd tests && $(MAKE) all
|
||||
# old way of doing it
|
||||
#cd tests && $(MAKE) all
|
||||
# new way of doing it
|
||||
cd tests && ./tester.sh
|
||||
|
||||
clean:
|
||||
- cd tests && $(MAKE) clean
|
||||
@@ -228,23 +396,23 @@ clean:
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
- rm -f docs/busybox.txt docs/busybox.dvi docs/busybox.ps \
|
||||
docs/busybox.pdf docs/busybox.lineo.com/busybox.html
|
||||
- rm -rf docs/busybox _install
|
||||
- rm -f busybox.links loop.h *~ *.o core
|
||||
- rm -f multibuild.log Config.h.orig
|
||||
- rm -rf docs/busybox _install libpwd.a libbb.a pod2htm*
|
||||
- rm -f busybox.links libbb/loop.h *~ slist.mk core applet_source_list
|
||||
- find -name \*.o -exec rm -f {} \;
|
||||
|
||||
distclean: clean
|
||||
- rm -f busybox
|
||||
- rm -f busybox applet_source_list
|
||||
- cd tests && $(MAKE) distclean
|
||||
|
||||
install: busybox busybox.links
|
||||
$(BB_SRC_DIR)/install.sh $(PREFIX)
|
||||
install: install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX)
|
||||
|
||||
install-hardlinks: busybox busybox.links
|
||||
$(BB_SRC_DIR)/install.sh $(PREFIX) --hardlinks
|
||||
install-hardlinks: install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX) --hardlinks
|
||||
|
||||
debug_pristine:
|
||||
@ echo VPATH=\"$(VPATH)\"
|
||||
@ echo CONFIG_LIST=\"$(CONFIG_LIST)\"
|
||||
@ echo CONFIG_H=\"$(CONFIG_H)\"
|
||||
@ echo OBJECTS=\"$(OBJECTS)\"
|
||||
|
||||
dist release: distclean doc
|
||||
@@ -255,17 +423,12 @@ dist release: distclean doc
|
||||
find busybox-$(VERSION)/ -type d \
|
||||
-name CVS \
|
||||
-print \
|
||||
| xargs rm -rf; \
|
||||
\
|
||||
find busybox-$(VERSION)/ -type f \
|
||||
-name .cvsignore \
|
||||
-print \
|
||||
| xargs rm -f; \
|
||||
-exec rm -rf {} \; ; \
|
||||
\
|
||||
find busybox-$(VERSION)/ -type f \
|
||||
-name .\#* \
|
||||
-print \
|
||||
| xargs rm -f; \
|
||||
-exec rm -f {} \; ; \
|
||||
\
|
||||
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
|
||||
|
||||
|
||||
@@ -11,8 +11,9 @@ the expected functionality and behave very much like their GNU counterparts.
|
||||
BusyBox has been written with size-optimization and limited resources in mind.
|
||||
It is also extremely modular so you can easily include or exclude commands (or
|
||||
features) at compile time. This makes it easy to customize your embedded
|
||||
systems. To create a working system, just add a kernel and an editor (such as
|
||||
e3 (http://www.sax.de/~adlibiti) or elvis-tiny).
|
||||
systems. To create a working system, just add /dev, a shell, and a kernel. For
|
||||
a really minimal system, you can even use the busybox shell (not Bourne
|
||||
compatible, but very small and quite usable) and the busybox vi editor.
|
||||
|
||||
BusyBox was originally written to support the Debian Rescue/Install disks, but
|
||||
it also makes an excellent environment for any small or embedded system.
|
||||
@@ -27,7 +28,25 @@ After the build is complete, a busybox.links file is generated. This is
|
||||
used by 'make install' to create symlinks to the busybox binary for all
|
||||
compiled in functions. By default, 'make install' will place the symlink
|
||||
forest into `pwd`/_install unless you have defined the PREFIX environment
|
||||
variable (i.e., make PREFIX="/tmp/foo" install)
|
||||
variable (i.e., 'make PREFIX=/tmp/foo install')
|
||||
|
||||
----------------
|
||||
|
||||
Supported architectures:
|
||||
|
||||
Busybox in general will build on any architecture supported by gcc. It has
|
||||
a few specialized features added for __sparc__ and __alpha__. insmod
|
||||
functionality is currently limited to x86, ARM, SH3/4, powerpc, and MIPS.
|
||||
|
||||
Supported libcs:
|
||||
|
||||
glibc-2.0.x, glibc-2.1.x, Linux-libc5, uClibc. People are looking at
|
||||
newlib and diet-libc, but consider them unsupported, untested, or worse.
|
||||
|
||||
Supported kernels:
|
||||
|
||||
Full functionality requires Linux 2.0.x, 2.2.x, or 2.4.x. A large fraction
|
||||
of the code should run on just about anything.
|
||||
|
||||
----------------
|
||||
|
||||
@@ -52,7 +71,7 @@ to submit@bugs.lineo.com. Bug reports should look something like this:
|
||||
Subject: /bin/true doesn't work
|
||||
|
||||
Package: busybox
|
||||
Version: 0.48
|
||||
Version: 0.51
|
||||
|
||||
When I invoke '/bin/true' it doesn't work. I expected it to return
|
||||
a "0" but it returned a "1" instead. Here is the transcript:
|
||||
@@ -96,6 +115,7 @@ Please feed suggestions, bug reports, insults, and bribes back to:
|
||||
Erik Andersen
|
||||
<andersen@lineo.com>
|
||||
<andersee@debian.org>
|
||||
<andersee@codepoet.org>
|
||||
|
||||
<blatant plug>
|
||||
Many thanks to go to Lineo for paying me to work on busybox.
|
||||
|
||||
@@ -6,10 +6,10 @@ around to it some time. If you have any good ideas, please let me know.
|
||||
* login/sulogin/passwd/getty/etc are part of tinylogin, and so are not
|
||||
needed or wanted in busybox (or else I'd have to link to libcrypt).
|
||||
|
||||
* Networking apps are going to be split out to a new package called netkit-tiny
|
||||
before the next release of Busybox. This will remove the following items
|
||||
from BusyBox: hostid, hostname, nc, nslookup, telnet, and ping. nfs
|
||||
mounting and syslogd (network logging) will remain in BusyBox.
|
||||
* We _were_ going to split networking apps into a new package called
|
||||
netkit-tiny. Per discussions on the mailing list, this isn't going
|
||||
to happen. False alarm. Sorry about the confusion.
|
||||
|
||||
|
||||
-Erik
|
||||
|
||||
@@ -18,43 +18,28 @@ around to it some time. If you have any good ideas, please let me know.
|
||||
Possible apps to include some time:
|
||||
|
||||
* hwclock
|
||||
* stty
|
||||
* start-stop-daemon
|
||||
* group/commonize strings, remove dups (for i18n, l10n)
|
||||
|
||||
-----------------------
|
||||
-----------
|
||||
|
||||
The Busybox lash shell needs to be taught Bourne shell grammer. This
|
||||
is planned for the next release of Busybox. Look out ash, we are coming
|
||||
for you...
|
||||
With sysvinit, reboot, poweroff and halt all used a named pipe,
|
||||
/dev/initctl, to communicate with the init process. Busybox
|
||||
currently uses signals to communicate with init. This makes
|
||||
busybox incompatible with sysvinit. We should probably use
|
||||
a named pipe as well so we can be compatible.
|
||||
|
||||
-----------------------
|
||||
|
||||
Running the following:
|
||||
Run the following:
|
||||
|
||||
rm -f busybox && make LDFLAGS+=-nostdlib 2>&1 | \
|
||||
sed -ne 's/.*undefined reference to `\(.*\)..*/\1/gp' | sort | uniq
|
||||
|
||||
reveals the list of all external (i.e. libc) things that BusyBox depends on.
|
||||
reveals the list of all external (i.e., libc) things that BusyBox depends on.
|
||||
It would be a very nice thing to reduce this list to an absolute minimum, to
|
||||
reduce the footprint of busybox when staticly linking with libraries such as
|
||||
uClibc.
|
||||
|
||||
-----------------------
|
||||
|
||||
Currently, busybox bypasses libc NSS. Some folks might want that,
|
||||
so perhaps adding in the option to choose whether to go to libc for
|
||||
things like getpwnam() or whether to use the busybox version might
|
||||
be nice.
|
||||
|
||||
-----------------------
|
||||
|
||||
Most wanted list:
|
||||
|
||||
[andersen@slag busybox]$ grep -l getgroups *.[ch]
|
||||
test.c
|
||||
|
||||
Policy violation. getgroups uses libc nss, which is unlikely
|
||||
to be present in an embedded system.
|
||||
reduce the footprint of busybox, especially when staticly linking with
|
||||
libraries such as uClibc.
|
||||
|
||||
-----------------------
|
||||
|
||||
@@ -65,4 +50,8 @@ and then start with the biggest things and make them smaller...
|
||||
|
||||
du.c probably ought to have an -x switch like GNU du does...
|
||||
|
||||
-----------------------
|
||||
|
||||
xargs could use a -l option
|
||||
|
||||
------------------------------------------------------------------
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* adjtimex.c - read, and possibly modify, the Linux kernel `timex' variables.
|
||||
*
|
||||
* Originally written: October 1997
|
||||
* Last hack: March 2001
|
||||
* Copyright 1997, 2000, 2001 Larry Doolittle <LRDoolittle@lbl.gov>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License (Version 2,
|
||||
* June 1991) as published by the Free Software Foundation. At the
|
||||
* time of writing, that license was published by the FSF with the URL
|
||||
* http://www.gnu.org/copyleft/gpl.html, and is incorporated herein by
|
||||
* reference.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This adjtimex(1) is very similar in intent to adjtimex(8) by Steven
|
||||
* Dick <ssd@nevets.oau.org> and Jim Van Zandt <jrv@vanzandt.mv.com>
|
||||
* (see http://metalab.unc.edu/pub/Linux/system/admin/time/adjtimex*).
|
||||
* That version predates this one, and is _much_ bigger and more
|
||||
* featureful. My independently written version was very similar to
|
||||
* Steven's from the start, because they both follow the kernel timex
|
||||
* structure. I further tweaked this version to be equivalent to Steven's
|
||||
* where possible, but I don't like getopt_long, so the actual usage
|
||||
* syntax is incompatible.
|
||||
*
|
||||
* Amazingly enough, my Red Hat 5.2 sys/timex (and sub-includes)
|
||||
* don't actually give a prototype for adjtimex(2), so building
|
||||
* this code (with -Wall) gives a warning. Later versions of
|
||||
* glibc fix this issue.
|
||||
*
|
||||
* This program is too simple for a Makefile, just build with:
|
||||
* gcc -Wall -O adjtimex.c -o adjtimex
|
||||
*
|
||||
* busyboxed 20 March 2001, Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
* It will autosense if it is built in a busybox environment, based
|
||||
* on the BB_VER preprocessor macro.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#if __GNU_LIBRARY__ < 5
|
||||
#include <sys/timex.h>
|
||||
extern int adjtimex(struct timex *buf);
|
||||
#else
|
||||
#include <sys/timex.h>
|
||||
#endif
|
||||
|
||||
#ifdef BB_VER
|
||||
#include "busybox.h"
|
||||
#endif
|
||||
|
||||
static struct {int bit; char *name;} statlist[] = {
|
||||
{ STA_PLL, "PLL" },
|
||||
{ STA_PPSFREQ, "PPSFREQ" },
|
||||
{ STA_PPSTIME, "PPSTIME" },
|
||||
{ STA_FLL, "FFL" },
|
||||
{ STA_INS, "INS" },
|
||||
{ STA_DEL, "DEL" },
|
||||
{ STA_UNSYNC, "UNSYNC" },
|
||||
{ STA_FREQHOLD, "FREQHOLD" },
|
||||
{ STA_PPSSIGNAL, "PPSSIGNAL" },
|
||||
{ STA_PPSJITTER, "PPSJITTER" },
|
||||
{ STA_PPSWANDER, "PPSWANDER" },
|
||||
{ STA_PPSERROR, "PPSERROR" },
|
||||
{ STA_CLOCKERR, "CLOCKERR" },
|
||||
{ 0, NULL } };
|
||||
|
||||
static char *ret_code_descript[] = {
|
||||
"clock synchronized",
|
||||
"insert leap second",
|
||||
"delete leap second",
|
||||
"leap second in progress",
|
||||
"leap second has occurred",
|
||||
"clock not synchronized" };
|
||||
|
||||
#ifdef BB_VER
|
||||
#define main adjtimex_main
|
||||
#else
|
||||
void usage(char *prog)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Usage: %s [ -q ] [ -o offset ] [ -f frequency ] [ -p timeconstant ] [ -t tick ]\n",
|
||||
prog);
|
||||
}
|
||||
#define show_usage() usage(argv[0])
|
||||
#endif
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
struct timex txc;
|
||||
int quiet=0;
|
||||
int c, i, ret, sep;
|
||||
char *descript;
|
||||
txc.modes=0;
|
||||
for (;;) {
|
||||
c = getopt( argc, argv, "qo:f:p:t:");
|
||||
if (c == EOF) break;
|
||||
switch (c) {
|
||||
case 'q':
|
||||
quiet=1;
|
||||
break;
|
||||
case 'o':
|
||||
txc.offset = atoi(optarg);
|
||||
txc.modes |= ADJ_OFFSET_SINGLESHOT;
|
||||
break;
|
||||
case 'f':
|
||||
txc.freq = atoi(optarg);
|
||||
txc.modes |= ADJ_FREQUENCY;
|
||||
break;
|
||||
case 'p':
|
||||
txc.constant = atoi(optarg);
|
||||
txc.modes |= ADJ_TIMECONST;
|
||||
break;
|
||||
case 't':
|
||||
txc.tick = atoi(optarg);
|
||||
txc.modes |= ADJ_TICK;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
if (argc != optind) { /* no valid non-option parameters */
|
||||
show_usage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = adjtimex(&txc);
|
||||
|
||||
if (ret < 0) perror("adjtimex");
|
||||
|
||||
if (!quiet && ret>=0) {
|
||||
printf(
|
||||
" mode: %d\n"
|
||||
"-o offset: %ld\n"
|
||||
"-f frequency: %ld\n"
|
||||
" maxerror: %ld\n"
|
||||
" esterror: %ld\n"
|
||||
" status: %d ( ",
|
||||
txc.modes, txc.offset, txc.freq, txc.maxerror,
|
||||
txc.esterror, txc.status);
|
||||
|
||||
/* representative output of next code fragment:
|
||||
"PLL | PPSTIME" */
|
||||
sep=0;
|
||||
for (i=0; statlist[i].name; i++) {
|
||||
if (txc.status & statlist[i].bit) {
|
||||
if (sep) fputs(" | ",stdout);
|
||||
fputs(statlist[i].name,stdout);
|
||||
sep=1;
|
||||
}
|
||||
}
|
||||
|
||||
descript = "error";
|
||||
if (ret >= 0 && ret <= 5) descript = ret_code_descript[ret];
|
||||
printf(" )\n"
|
||||
"-p timeconstant: %ld\n"
|
||||
" precision: %ld\n"
|
||||
" tolerance: %ld\n"
|
||||
"-t tick: %ld\n"
|
||||
" time.tv_sec: %ld\n"
|
||||
" time.tv_usec: %ld\n"
|
||||
" return value: %d (%s)\n",
|
||||
txc.constant,
|
||||
txc.precision, txc.tolerance, txc.tick,
|
||||
(long)txc.time.tv_sec, (long)txc.time.tv_usec, ret, descript);
|
||||
}
|
||||
return (ret<0);
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Utility routines.
|
||||
*
|
||||
* Copyright (C) tons of folks. Tracking down who wrote what
|
||||
* isn't something I'm going to worry about... If you wrote something
|
||||
* here, please feel free to acknowledge your work.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
struct BB_applet *applet_using;
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
|
||||
const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
extern void show_usage(void)
|
||||
{
|
||||
const char *format_string;
|
||||
const char *usage_string = usage_messages;
|
||||
int i;
|
||||
/* From busybox.c */
|
||||
extern int been_there_done_that;
|
||||
|
||||
if (strcmp(applet_using->name, "busybox")==0) {
|
||||
been_there_done_that=1;
|
||||
busybox_main(0, NULL);
|
||||
}
|
||||
|
||||
for (i = applet_using - applets; i > 0; ) {
|
||||
if (!*usage_string++) {
|
||||
--i;
|
||||
}
|
||||
}
|
||||
format_string = "%s\n\nUsage: %s %s\n\n";
|
||||
if(*usage_string == 0)
|
||||
format_string = "%s\n\nNo help available.\n\n";
|
||||
fprintf(stderr, format_string,
|
||||
full_version, applet_using->name, usage_string);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static int applet_name_compare(const void *x, const void *y)
|
||||
{
|
||||
const char *name = x;
|
||||
const struct BB_applet *applet = y;
|
||||
|
||||
return strcmp(name, applet->name);
|
||||
}
|
||||
|
||||
extern const size_t NUM_APPLETS;
|
||||
|
||||
struct BB_applet *find_applet_by_name(const char *name)
|
||||
{
|
||||
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
|
||||
applet_name_compare);
|
||||
}
|
||||
|
||||
void run_applet_by_name(const char *name, int argc, char **argv)
|
||||
{
|
||||
static int recurse_level = 0;
|
||||
|
||||
recurse_level++;
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
if ((applet_using = find_applet_by_name(name)) != NULL) {
|
||||
applet_name = applet_using->name;
|
||||
if (argv[1] && strcmp(argv[1], "--help") == 0) {
|
||||
show_usage();
|
||||
}
|
||||
exit((*(applet_using->main)) (argc, argv));
|
||||
}
|
||||
/* Just in case they have renamed busybox - Check argv[1] */
|
||||
if (recurse_level == 1) {
|
||||
run_applet_by_name("busybox", argc, argv);
|
||||
}
|
||||
recurse_level = 0;
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -10,382 +10,445 @@
|
||||
* file result in the listing remaining in ascii order. You have been warned.
|
||||
*/
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_ODDNAME
|
||||
#undef APPLET_NOUSAGE
|
||||
|
||||
|
||||
#if defined(PROTOTYPES)
|
||||
#define APPLET(a,b,c,d) \
|
||||
extern int b(int argc, char **argv); \
|
||||
extern const char d[];
|
||||
#define APPLET_NOUSAGE(a,b,c) \
|
||||
extern int b(int argc, char **argv);
|
||||
#define APPLET(a,b,c) extern int b(int argc, char **argv);
|
||||
#define APPLET_NOUSAGE(a,b,c) extern int b(int argc, char **argv);
|
||||
#define APPLET_ODDNAME(a,b,c,d) extern int b(int argc, char **argv);
|
||||
extern const char usage_messages[];
|
||||
#elif defined(MAKE_USAGE)
|
||||
#ifdef BB_FEATURE_VERBOSE_USAGE
|
||||
#define APPLET(a,b,c) a##_trivial_usage "\n\n" a##_full_usage "\0"
|
||||
#define APPLET_NOUSAGE(a,b,c) "\0"
|
||||
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\n\n" d##_full_usage "\0"
|
||||
#else
|
||||
#define APPLET(a,b,c) a##_trivial_usage "\0"
|
||||
#define APPLET_NOUSAGE(a,b,c) "\0"
|
||||
#define APPLET_ODDNAME(a,b,c,d) d##_trivial_usage "\0"
|
||||
#endif
|
||||
#elif defined(MAKE_LINKS)
|
||||
#define APPLET(a,b,c,d) LINK c a
|
||||
#define APPLET_NOUSAGE(a,b,c) LINK c a
|
||||
# define APPLET(a,b,c) LINK c a
|
||||
# define APPLET_NOUSAGE(a,b,c) LINK c a
|
||||
# define APPLET_ODDNAME(a,b,c,d) LINK c a
|
||||
#else
|
||||
const struct BB_applet applets[] = {
|
||||
#define APPLET(a,b,c,d) {a,b,c,d},
|
||||
#define APPLET_NOUSAGE(a,b,c) {a,b,c,NULL},
|
||||
const struct BB_applet applets[] = {
|
||||
#define APPLET(a,b,c) {#a,b,c},
|
||||
#define APPLET_NOUSAGE(a,b,c) {a,b,c},
|
||||
#define APPLET_ODDNAME(a,b,c,d) {a,b,c},
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifdef BB_TEST
|
||||
APPLET("[", test_main, _BB_DIR_USR_BIN, test_usage)
|
||||
APPLET_NOUSAGE("[", test_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_ADJTIMEX
|
||||
APPLET(adjtimex, adjtimex_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_AR
|
||||
APPLET("ar", ar_main, _BB_DIR_USR_BIN, ar_usage)
|
||||
APPLET(ar, ar_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_BASENAME
|
||||
APPLET("basename", basename_main, _BB_DIR_USR_BIN, basename_usage)
|
||||
APPLET(basename, basename_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
APPLET_NOUSAGE("busybox", busybox_main, _BB_DIR_BIN)
|
||||
#ifdef BB_CAT
|
||||
APPLET("cat", cat_main, _BB_DIR_BIN, cat_usage)
|
||||
APPLET(cat, cat_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET("chgrp", chmod_chown_chgrp_main, _BB_DIR_BIN, chgrp_usage)
|
||||
#ifdef BB_CHGRP
|
||||
APPLET(chgrp, chgrp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET("chmod", chmod_chown_chgrp_main, _BB_DIR_BIN, chmod_usage)
|
||||
#ifdef BB_CHMOD
|
||||
APPLET(chmod, chmod_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET("chown", chmod_chown_chgrp_main, _BB_DIR_BIN, chown_usage)
|
||||
#ifdef BB_CHOWN
|
||||
APPLET(chown, chown_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHROOT
|
||||
APPLET("chroot", chroot_main, _BB_DIR_USR_SBIN, chroot_usage)
|
||||
APPLET(chroot, chroot_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_CHVT
|
||||
APPLET("chvt", chvt_main, _BB_DIR_USR_BIN, chvt_usage)
|
||||
APPLET(chvt, chvt_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CLEAR
|
||||
APPLET("clear", clear_main, _BB_DIR_USR_BIN, clear_usage)
|
||||
APPLET(clear, clear_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CMP
|
||||
APPLET("cmp", cmp_main, _BB_DIR_USR_BIN, cmp_usage)
|
||||
APPLET(cmp, cmp_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
APPLET("cp", cp_mv_main, _BB_DIR_BIN, cp_usage)
|
||||
#ifdef BB_CP
|
||||
APPLET(cp, cp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CPIO
|
||||
APPLET(cpio, cpio_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CUT
|
||||
APPLET("cut", cut_main, _BB_DIR_USR_BIN, cut_usage)
|
||||
APPLET(cut, cut_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DATE
|
||||
APPLET("date", date_main, _BB_DIR_BIN, date_usage)
|
||||
APPLET(date, date_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DC
|
||||
APPLET("dc", dc_main, _BB_DIR_USR_BIN, dc_usage)
|
||||
APPLET(dc, dc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DD
|
||||
APPLET("dd", dd_main, _BB_DIR_BIN, dd_usage)
|
||||
APPLET(dd, dd_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT
|
||||
APPLET("deallocvt", deallocvt_main, _BB_DIR_USR_BIN, deallocvt_usage)
|
||||
APPLET(deallocvt, deallocvt_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DF
|
||||
APPLET("df", df_main, _BB_DIR_BIN, df_usage)
|
||||
APPLET(df, df_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DIRNAME
|
||||
APPLET("dirname", dirname_main, _BB_DIR_USR_BIN, dirname_usage)
|
||||
APPLET(dirname, dirname_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DMESG
|
||||
APPLET("dmesg", dmesg_main, _BB_DIR_BIN, dmesg_usage)
|
||||
APPLET(dmesg, dmesg_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DOS2UNIX
|
||||
APPLET("dos2unix", dos2unix_main, _BB_DIR_USR_BIN, dos2unix_usage)
|
||||
APPLET(dos2unix, dos2unix_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DPKG
|
||||
APPLET(dpkg, dpkg_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DPKG_DEB
|
||||
APPLET_ODDNAME("dpkg-deb", dpkg_deb_main, _BB_DIR_USR_BIN, dpkg_deb)
|
||||
#endif
|
||||
#ifdef BB_DU
|
||||
APPLET("du", du_main, _BB_DIR_USR_BIN, du_usage)
|
||||
APPLET(du, du_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DUMPKMAP
|
||||
APPLET("dumpkmap", dumpkmap_main, _BB_DIR_BIN, dumpkmap_usage)
|
||||
APPLET(dumpkmap, dumpkmap_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DUTMP
|
||||
APPLET("dutmp", dutmp_main, _BB_DIR_USR_SBIN, dutmp_usage)
|
||||
APPLET(dutmp, dutmp_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_ECHO
|
||||
APPLET("echo", echo_main, _BB_DIR_BIN, echo_usage)
|
||||
APPLET(echo, echo_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#if defined(BB_FEATURE_GREP_EGREP_ALIAS) && defined(BB_GREP)
|
||||
APPLET_NOUSAGE("egrep", grep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_ENV
|
||||
APPLET(env, env_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_EXPR
|
||||
APPLET("expr", expr_main, _BB_DIR_USR_BIN, expr_usage)
|
||||
APPLET(expr, expr_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET("false", false_main, _BB_DIR_BIN, false_usage)
|
||||
APPLET(false, false_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FBSET
|
||||
APPLET_NOUSAGE("fbset", fbset_main, _BB_DIR_USR_SBIN)
|
||||
APPLET(fbset, fbset_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH
|
||||
APPLET("fdflush", fdflush_main, _BB_DIR_BIN, fdflush_usage)
|
||||
APPLET(fdflush, fdflush_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FIND
|
||||
APPLET("find", find_main, _BB_DIR_USR_BIN, find_usage)
|
||||
APPLET(find, find_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FREE
|
||||
APPLET("free", free_main, _BB_DIR_USR_BIN, free_usage)
|
||||
APPLET(free, free_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FREERAMDISK
|
||||
APPLET("freeramdisk", freeramdisk_main, _BB_DIR_SBIN, freeramdisk_usage)
|
||||
APPLET(freeramdisk, freeramdisk_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX
|
||||
APPLET("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix_usage)
|
||||
APPLET_ODDNAME("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix)
|
||||
#endif
|
||||
#ifdef BB_GETOPT
|
||||
APPLET("getopt", getopt_main, _BB_DIR_BIN, getopt_usage)
|
||||
APPLET(getopt, getopt_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GREP
|
||||
APPLET("grep", grep_main, _BB_DIR_BIN, grep_usage)
|
||||
APPLET(grep, grep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET("gunzip", gunzip_main, _BB_DIR_BIN, gunzip_usage)
|
||||
APPLET(gunzip, gunzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GZIP
|
||||
APPLET("gzip", gzip_main, _BB_DIR_BIN, gzip_usage)
|
||||
APPLET(gzip, gzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HALT
|
||||
APPLET("halt", halt_main, _BB_DIR_SBIN, halt_usage)
|
||||
APPLET(halt, halt_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_HEAD
|
||||
APPLET("head", head_main, _BB_DIR_USR_BIN, head_usage)
|
||||
APPLET(head, head_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HOSTID
|
||||
APPLET("hostid", hostid_main, _BB_DIR_USR_BIN, hostid_usage)
|
||||
APPLET(hostid, hostid_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HOSTNAME
|
||||
APPLET("hostname", hostname_main, _BB_DIR_BIN, hostname_usage)
|
||||
APPLET(hostname, hostname_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_ID
|
||||
APPLET("id", id_main, _BB_DIR_USR_BIN, id_usage)
|
||||
APPLET(id, id_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_IFCONFIG
|
||||
APPLET(ifconfig, ifconfig_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_INIT
|
||||
APPLET_NOUSAGE("init", init_main, _BB_DIR_SBIN)
|
||||
APPLET(init, init_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_INSMOD
|
||||
APPLET("insmod", insmod_main, _BB_DIR_SBIN, insmod_usage)
|
||||
APPLET(insmod, insmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_KILL
|
||||
APPLET("kill", kill_main, _BB_DIR_BIN, kill_usage)
|
||||
APPLET(kill, kill_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_KILLALL
|
||||
APPLET("killall", kill_main, _BB_DIR_USR_BIN, killall_usage)
|
||||
APPLET(killall, kill_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_KLOGD
|
||||
APPLET(klogd, klogd_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LENGTH
|
||||
APPLET("length", length_main, _BB_DIR_USR_BIN, length_usage)
|
||||
APPLET(length, length_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LINUXRC
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT)
|
||||
#endif
|
||||
#ifdef BB_LN
|
||||
APPLET("ln", ln_main, _BB_DIR_BIN, ln_usage)
|
||||
APPLET(ln, ln_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADACM
|
||||
APPLET("loadacm", loadacm_main, _BB_DIR_USR_BIN, loadacm_usage)
|
||||
APPLET(loadacm, loadacm_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADFONT
|
||||
APPLET("loadfont", loadfont_main, _BB_DIR_USR_BIN, loadfont_usage)
|
||||
APPLET(loadfont, loadfont_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP
|
||||
APPLET("loadkmap", loadkmap_main, _BB_DIR_SBIN, loadkmap_usage)
|
||||
APPLET(loadkmap, loadkmap_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LOGGER
|
||||
APPLET("logger", logger_main, _BB_DIR_USR_BIN, logger_usage)
|
||||
APPLET(logger, logger_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOGNAME
|
||||
APPLET("logname", logname_main, _BB_DIR_USR_BIN, logname_usage)
|
||||
APPLET(logname, logname_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOGREAD
|
||||
APPLET(logread, logread_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LS
|
||||
APPLET("ls", ls_main, _BB_DIR_BIN, ls_usage)
|
||||
APPLET(ls, ls_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LSMOD
|
||||
APPLET("lsmod", lsmod_main, _BB_DIR_SBIN, lsmod_usage)
|
||||
APPLET(lsmod, lsmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS
|
||||
APPLET("makedevs", makedevs_main, _BB_DIR_SBIN, makedevs_usage)
|
||||
APPLET(makedevs, makedevs_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MD5SUM
|
||||
APPLET("md5sum", md5sum_main, _BB_DIR_USR_BIN, md5sum_usage)
|
||||
APPLET(md5sum, md5sum_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKDIR
|
||||
APPLET("mkdir", mkdir_main, _BB_DIR_BIN, mkdir_usage)
|
||||
APPLET(mkdir, mkdir_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKFIFO
|
||||
APPLET("mkfifo", mkfifo_main, _BB_DIR_USR_BIN, mkfifo_usage)
|
||||
APPLET(mkfifo, mkfifo_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX
|
||||
APPLET("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix_usage)
|
||||
APPLET_ODDNAME("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix)
|
||||
#endif
|
||||
#ifdef BB_MKNOD
|
||||
APPLET("mknod", mknod_main, _BB_DIR_BIN, mknod_usage)
|
||||
APPLET(mknod, mknod_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKSWAP
|
||||
APPLET("mkswap", mkswap_main, _BB_DIR_SBIN, mkswap_usage)
|
||||
APPLET(mkswap, mkswap_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MKTEMP
|
||||
APPLET("mktemp", mktemp_main, _BB_DIR_BIN, mktemp_usage)
|
||||
APPLET(mktemp, mktemp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MORE
|
||||
APPLET("more", more_main, _BB_DIR_BIN, more_usage)
|
||||
APPLET(more, more_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MOUNT
|
||||
APPLET("mount", mount_main, _BB_DIR_BIN, mount_usage)
|
||||
APPLET(mount, mount_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MT
|
||||
APPLET("mt", mt_main, _BB_DIR_BIN, mt_usage)
|
||||
APPLET(mt, mt_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CP_MV
|
||||
APPLET("mv", cp_mv_main, _BB_DIR_BIN, mv_usage)
|
||||
#ifdef BB_MV
|
||||
APPLET(mv, mv_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_NC
|
||||
APPLET("nc", nc_main, _BB_DIR_USR_BIN, nc_usage)
|
||||
APPLET(nc, nc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_NSLOOKUP
|
||||
APPLET("nslookup", nslookup_main, _BB_DIR_USR_BIN, nslookup_usage)
|
||||
APPLET(nslookup, nslookup_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PING
|
||||
APPLET("ping", ping_main, _BB_DIR_BIN, ping_usage)
|
||||
APPLET(ping, ping_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PIVOT_ROOT
|
||||
APPLET(pivot_root, pivot_root_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_POWEROFF
|
||||
APPLET("poweroff", poweroff_main, _BB_DIR_SBIN, poweroff_usage)
|
||||
APPLET(poweroff, poweroff_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_PRINTF
|
||||
APPLET("printf", printf_main, _BB_DIR_USR_BIN, printf_usage)
|
||||
APPLET(printf, printf_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PS
|
||||
APPLET("ps", ps_main, _BB_DIR_BIN, ps_usage)
|
||||
APPLET(ps, ps_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PWD
|
||||
APPLET("pwd", pwd_main, _BB_DIR_BIN, pwd_usage)
|
||||
APPLET(pwd, pwd_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RDATE
|
||||
APPLET("rdate", rdate_main, _BB_DIR_USR_BIN, rdate_usage)
|
||||
APPLET(rdate, rdate_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_READLINK
|
||||
APPLET("readlink", readlink_main, _BB_DIR_USR_BIN, readlink_usage)
|
||||
APPLET(readlink, readlink_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_REBOOT
|
||||
APPLET("reboot", reboot_main, _BB_DIR_SBIN, reboot_usage)
|
||||
APPLET(reboot, reboot_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_RENICE
|
||||
APPLET("renice", renice_main, _BB_DIR_USR_BIN, renice_usage)
|
||||
APPLET(renice, renice_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RESET
|
||||
APPLET("reset", reset_main, _BB_DIR_USR_BIN, reset_usage)
|
||||
APPLET(reset, reset_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RM
|
||||
APPLET("rm", rm_main, _BB_DIR_BIN, rm_usage)
|
||||
APPLET(rm, rm_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RMDIR
|
||||
APPLET("rmdir", rmdir_main, _BB_DIR_BIN, rmdir_usage)
|
||||
APPLET(rmdir, rmdir_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RMMOD
|
||||
APPLET("rmmod", rmmod_main, _BB_DIR_SBIN, rmmod_usage)
|
||||
APPLET(rmmod, rmmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_ROUTE
|
||||
APPLET(route, route_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RPM2CPIO
|
||||
APPLET(rpm2cpio, rpm2cpio_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RPMUNPACK
|
||||
APPLET("rpmunpack", rpmunpack_main, _BB_DIR_USR_BIN, rpmunpack_usage)
|
||||
APPLET(rpmunpack, rpmunpack_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SED
|
||||
APPLET("sed", sed_main, _BB_DIR_BIN, sed_usage)
|
||||
APPLET(sed, sed_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SETKEYCODES
|
||||
APPLET("setkeycodes", setkeycodes_main, _BB_DIR_USR_BIN, setkeycodes_usage)
|
||||
APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SH
|
||||
APPLET("sh", shell_main, _BB_DIR_BIN, shell_usage)
|
||||
APPLET(sh, shell_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SLEEP
|
||||
APPLET("sleep", sleep_main, _BB_DIR_BIN, sleep_usage)
|
||||
APPLET(sleep, sleep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SORT
|
||||
APPLET("sort", sort_main, _BB_DIR_USR_BIN, sort_usage)
|
||||
APPLET(sort, sort_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_STTY
|
||||
APPLET(stty, stty_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET("swapoff", swap_on_off_main, _BB_DIR_SBIN, swapoff_usage)
|
||||
APPLET(swapoff, swap_on_off_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET("swapon", swap_on_off_main, _BB_DIR_SBIN, swapon_usage)
|
||||
APPLET(swapon, swap_on_off_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_SYNC
|
||||
APPLET("sync", sync_main, _BB_DIR_BIN, sync_usage)
|
||||
APPLET(sync, sync_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SYSLOGD
|
||||
APPLET("syslogd", syslogd_main, _BB_DIR_SBIN, syslogd_usage)
|
||||
APPLET(syslogd, syslogd_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_TAIL
|
||||
APPLET("tail", tail_main, _BB_DIR_USR_BIN, tail_usage)
|
||||
APPLET(tail, tail_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TAR
|
||||
APPLET("tar", tar_main, _BB_DIR_BIN, tar_usage)
|
||||
APPLET(tar, tar_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TEE
|
||||
APPLET("tee", tee_main, _BB_DIR_USR_BIN, tee_usage)
|
||||
APPLET(tee, tee_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TELNET
|
||||
APPLET("telnet", telnet_main, _BB_DIR_USR_BIN, telnet_usage)
|
||||
APPLET(telnet, telnet_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
APPLET("test", test_main, _BB_DIR_USR_BIN, test_usage)
|
||||
APPLET(test, test_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TFTP
|
||||
APPLET(tftp, tftp_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TOUCH
|
||||
APPLET("touch", touch_main, _BB_DIR_BIN, touch_usage)
|
||||
APPLET(touch, touch_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TR
|
||||
APPLET("tr", tr_main, _BB_DIR_USR_BIN, tr_usage)
|
||||
APPLET(tr, tr_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET("true", true_main, _BB_DIR_BIN, true_usage)
|
||||
APPLET(true, true_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TTY
|
||||
APPLET("tty", tty_main, _BB_DIR_USR_BIN, tty_usage)
|
||||
APPLET(tty, tty_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UMOUNT
|
||||
APPLET("umount", umount_main, _BB_DIR_BIN, umount_usage)
|
||||
APPLET(umount, umount_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNAME
|
||||
APPLET("uname", uname_main, _BB_DIR_BIN, uname_usage)
|
||||
APPLET(uname, uname_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNIQ
|
||||
APPLET("uniq", uniq_main, _BB_DIR_USR_BIN, uniq_usage)
|
||||
APPLET(uniq, uniq_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNIX2DOS
|
||||
APPLET("unix2dos", unix2dos_main, _BB_DIR_USR_BIN, unix2dos_usage)
|
||||
APPLET(unix2dos, unix2dos_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UPDATE
|
||||
APPLET("update", update_main, _BB_DIR_SBIN, update_usage)
|
||||
APPLET(update, update_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_UPTIME
|
||||
APPLET("uptime", uptime_main, _BB_DIR_USR_BIN, uptime_usage)
|
||||
APPLET(uptime, uptime_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_USLEEP
|
||||
APPLET("usleep", usleep_main, _BB_DIR_BIN, usleep_usage)
|
||||
APPLET(usleep, usleep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UUDECODE
|
||||
APPLET("uudecode", uudecode_main, _BB_DIR_USR_BIN, uudecode_usage)
|
||||
APPLET(uudecode, uudecode_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UUENCODE
|
||||
APPLET("uuencode", uuencode_main, _BB_DIR_USR_BIN, uuencode_usage)
|
||||
APPLET(uuencode, uuencode_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_VI
|
||||
APPLET(vi, vi_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WATCHDOG
|
||||
APPLET(watchdog, watchdog_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_WC
|
||||
APPLET("wc", wc_main, _BB_DIR_USR_BIN, wc_usage)
|
||||
APPLET(wc, wc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WGET
|
||||
APPLET("wget", wget_main, _BB_DIR_USR_BIN, wget_usage)
|
||||
APPLET(wget, wget_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WHICH
|
||||
APPLET("which", which_main, _BB_DIR_USR_BIN, which_usage)
|
||||
APPLET(which, which_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WHOAMI
|
||||
APPLET("whoami", whoami_main, _BB_DIR_USR_BIN, whoami_usage)
|
||||
APPLET(whoami, whoami_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_XARGS
|
||||
APPLET("xargs", xargs_main, _BB_DIR_USR_BIN, xargs_usage)
|
||||
APPLET(xargs, xargs_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_YES
|
||||
APPLET("yes", yes_main, _BB_DIR_USR_BIN, yes_usage)
|
||||
APPLET(yes, yes_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET("zcat", gunzip_main, _BB_DIR_BIN, gunzip_usage)
|
||||
APPLET(zcat, gunzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
|
||||
#if !defined(PROTOTYPES) && !defined(MAKE_LINKS)
|
||||
{ 0,NULL,0,NULL}
|
||||
#if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
|
||||
{ 0,NULL,0 }
|
||||
};
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,NULL} entry above. */
|
||||
size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,113 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Utility routines.
|
||||
*
|
||||
* Copyright (C) tons of folks. Tracking down who wrote what
|
||||
* isn't something I'm going to worry about... If you wrote something
|
||||
* here, please feel free to acknowledge your work.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Based in part on code from sash, Copyright (c) 1999 by David I. Bell
|
||||
* Permission has been granted to redistribute this code under the GPL.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
struct BB_applet *applet_using;
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
|
||||
const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
extern void show_usage(void)
|
||||
{
|
||||
const char *format_string;
|
||||
const char *usage_string = usage_messages;
|
||||
int i;
|
||||
/* From busybox.c */
|
||||
extern int been_there_done_that;
|
||||
|
||||
if (strcmp(applet_using->name, "busybox")==0) {
|
||||
been_there_done_that=1;
|
||||
busybox_main(0, NULL);
|
||||
}
|
||||
|
||||
for (i = applet_using - applets; i > 0; ) {
|
||||
if (!*usage_string++) {
|
||||
--i;
|
||||
}
|
||||
}
|
||||
format_string = "%s\n\nUsage: %s %s\n\n";
|
||||
if(*usage_string == 0)
|
||||
format_string = "%s\n\nNo help available.\n\n";
|
||||
fprintf(stderr, format_string,
|
||||
full_version, applet_using->name, usage_string);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static int applet_name_compare(const void *x, const void *y)
|
||||
{
|
||||
const char *name = x;
|
||||
const struct BB_applet *applet = y;
|
||||
|
||||
return strcmp(name, applet->name);
|
||||
}
|
||||
|
||||
extern const size_t NUM_APPLETS;
|
||||
|
||||
struct BB_applet *find_applet_by_name(const char *name)
|
||||
{
|
||||
return bsearch(name, applets, NUM_APPLETS, sizeof(struct BB_applet),
|
||||
applet_name_compare);
|
||||
}
|
||||
|
||||
void run_applet_by_name(const char *name, int argc, char **argv)
|
||||
{
|
||||
static int recurse_level = 0;
|
||||
|
||||
recurse_level++;
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
if ((applet_using = find_applet_by_name(name)) != NULL) {
|
||||
applet_name = applet_using->name;
|
||||
if (argv[1] && strcmp(argv[1], "--help") == 0) {
|
||||
show_usage();
|
||||
}
|
||||
exit((*(applet_using->main)) (argc, argv));
|
||||
}
|
||||
/* Just in case they have renamed busybox - Check argv[1] */
|
||||
if (recurse_level == 1) {
|
||||
run_applet_by_name("busybox", argc, argv);
|
||||
}
|
||||
recurse_level = 0;
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
+57
-93
@@ -1,21 +1,15 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#ifdef BB_LOCALE_SUPPORT
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
#define bb_need_full_version
|
||||
#define BB_DECLARE_EXTERN
|
||||
#include "messages.c"
|
||||
|
||||
static int been_there_done_that = 0;
|
||||
|
||||
|
||||
int been_there_done_that = 0; /* Also used in applets.c */
|
||||
const char *applet_name;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
@@ -43,21 +37,7 @@ typedef int (*__link_f)(const char *, const char *);
|
||||
*/
|
||||
static char *busybox_fullpath()
|
||||
{
|
||||
pid_t pid;
|
||||
char path[256];
|
||||
char proc[256];
|
||||
int len;
|
||||
|
||||
pid = getpid();
|
||||
sprintf(proc, "/proc/%d/exe", pid);
|
||||
len = readlink(proc, path, 256);
|
||||
if (len != -1) {
|
||||
path[len] = 0;
|
||||
} else {
|
||||
error_msg("%s: %s\n", proc, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
return strdup(path);
|
||||
return xreadlink("/proc/self/exe");
|
||||
}
|
||||
|
||||
/* create (sym)links for each applet */
|
||||
@@ -65,21 +45,21 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
{
|
||||
__link_f Link = link;
|
||||
|
||||
char command[256];
|
||||
char *fpc;
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links) Link = symlink;
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
sprintf ( command, "%s/%s",
|
||||
install_dir[applets[i].location],
|
||||
applets[i].name);
|
||||
rc = Link(busybox, command);
|
||||
|
||||
if (rc) {
|
||||
error_msg("%s: %s\n", command, strerror(errno));
|
||||
fpc = concat_path_file(
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, fpc);
|
||||
if (rc!=0 && errno!=EEXIST) {
|
||||
perror_msg("%s", fpc);
|
||||
}
|
||||
free(fpc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,9 +67,35 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct BB_applet search_applet, *applet;
|
||||
const char *s;
|
||||
applet_name = "busybox";
|
||||
const char *s;
|
||||
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
/* Add in a special case hack for a leading hyphen */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
applet_name = (*argv+1);
|
||||
}
|
||||
|
||||
#ifdef BB_LOCALE_SUPPORT
|
||||
#ifdef BB_INIT
|
||||
if(getpid()!=1) /* Do not set locale for `init' */
|
||||
#endif
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
}
|
||||
#endif
|
||||
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0, len, i;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
@@ -121,39 +127,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
#ifdef BB_SH
|
||||
/* Add in a special case hack -- whenever **argv == '-'
|
||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
exit(((*(shell_main)) (argc, argv)));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
search_applet.name = applet_name;
|
||||
applet = bsearch(&search_applet, applets, NUM_APPLETS,
|
||||
sizeof(struct BB_applet), applet_name_compare);
|
||||
if (applet != NULL) {
|
||||
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
|
||||
usage(applet->usage);
|
||||
exit((*(applet->main)) (argc, argv));
|
||||
}
|
||||
|
||||
return(busybox_main(argc, argv));
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0;
|
||||
int ps_index;
|
||||
char *index, *index2;
|
||||
|
||||
argc--;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
@@ -179,31 +152,22 @@ int busybox_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(-1);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Flag that we've been here already */
|
||||
been_there_done_that = 1;
|
||||
|
||||
/* We do not want the word "busybox" to show up in ps, so we move
|
||||
* everything in argv around to fake ps into showing what we want it to
|
||||
* show. Since we are only shrinking the string, we don't need to move
|
||||
* __environ or any of that tedious stuff... */
|
||||
ps_index = 0;
|
||||
index=*argv;
|
||||
index2=argv[argc];
|
||||
index2+=strlen(argv[argc]);
|
||||
while(ps_index < argc) {
|
||||
argv[ps_index]=index;
|
||||
memmove(index, argv[ps_index+1], strlen(argv[ps_index+1])+1);
|
||||
index+=(strlen(index));
|
||||
*index='\0';
|
||||
index++;
|
||||
ps_index++;
|
||||
}
|
||||
while(index<=index2)
|
||||
*index++='\0';
|
||||
argv[ps_index]=NULL;
|
||||
/* Move the command line down a notch */
|
||||
len = argv[argc] + strlen(argv[argc]) - argv[1];
|
||||
memmove(argv[0], argv[1], len);
|
||||
memset(argv[0] + len, 0, argv[1] - argv[0]);
|
||||
|
||||
/* Fix up the argv pointers */
|
||||
len = argv[1] - argv[0];
|
||||
memmove(argv, argv + 1, sizeof(char *) * (argc + 1));
|
||||
for (i = 0; i < argc; i++)
|
||||
argv[i] -= len;
|
||||
|
||||
return (main(argc, argv));
|
||||
}
|
||||
|
||||
+10
-2
@@ -1,12 +1,20 @@
|
||||
#!/bin/sh
|
||||
# Make busybox links list file.
|
||||
|
||||
# input $1: full path to Config.h
|
||||
# input $2: full path to applets.h
|
||||
# output (stdout): list of pathnames that should be linked to busybox
|
||||
|
||||
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-Config.h}
|
||||
APPLETS_H=${2:-applets.h}
|
||||
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*LINK/{
|
||||
match($2,"_BB_DIR[A-Z_]*")
|
||||
dir=substr($2,RSTART+7,RLENGTH-7)
|
||||
dir=substr($2,8)
|
||||
gsub("_","/",dir)
|
||||
if(dir=="/ROOT") dir=""
|
||||
file=$3
|
||||
|
||||
+8
-5
@@ -1,13 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
RAW=` \
|
||||
gcc -E -dM ${1:-Config.h} | \
|
||||
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
|
||||
| tr '[:upper:]' '[:lower:]' | sort
|
||||
| tr A-Z a-z | sort
|
||||
`
|
||||
test "${RAW}" != "" || exit
|
||||
cd ${2:-.}
|
||||
# I added in the extra "ls" so only source files that
|
||||
# actually exist will show up in the compile list.
|
||||
ls -1 $RAW 2>/dev/null | sed -e 's/\.c$/\.o/g'
|
||||
if [ -d "$BB_SRC_DIR" ]; then cd $BB_SRC_DIR; fi
|
||||
# By running $RAW through "ls", we avoid listing
|
||||
# source files that don't exist.
|
||||
ls $RAW 2>/dev/null | tr '\n' ' '
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
prefix=$1
|
||||
if [ "$prefix" = "" ]; then
|
||||
echo "No installation directory, aborting."
|
||||
|
||||
+4
-1494
File diff suppressed because it is too large.
Load diff
+1787
File diff suppressed because it is too large.
Load diff
@@ -3,7 +3,7 @@
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
|
||||
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
|
||||
*
|
||||
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
|
||||
*
|
||||
@@ -21,371 +21,69 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Last modified 20 September 2000
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define BLOCK_SIZE 60
|
||||
#define PRESERVE_DATE 1 /* preserve original dates */
|
||||
#define VERBOSE 2 /* be verbose */
|
||||
#define DISPLAY 4 /* display contents */
|
||||
#define EXT_TO_FILE 8 /* extract contents of archive */
|
||||
#define EXT_TO_STDOUT 16 /* extract to stdout */
|
||||
#define RECURSIVE 32
|
||||
|
||||
#define MAX_NAME_LENGTH 100
|
||||
|
||||
//#define BB_DECLARE_EXTERN
|
||||
//#define bb_need_io_error
|
||||
//#include "messages.c"
|
||||
|
||||
//#define BB_AR_EXPERIMENTAL_UNTAR
|
||||
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
typedef struct rawTarHeader {
|
||||
char name[100]; /* 0-99 */
|
||||
char mode[8]; /* 100-107 */
|
||||
char uid[8]; /* 108-115 */
|
||||
char gid[8]; /* 116-123 */
|
||||
char size[12]; /* 124-135 */
|
||||
char mtime[12]; /* 136-147 */
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char linkname[100]; /* 157-256 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char version[2]; /* 263-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char devmajor[8]; /* 329-336 */
|
||||
char devminor[8]; /* 337-344 */
|
||||
char prefix[155]; /* 345-499 */
|
||||
char padding[12]; /* 500-512 */
|
||||
} rawTarHeader_t;
|
||||
#endif
|
||||
|
||||
typedef struct rawArHeader { /* Byte Offset */
|
||||
char name[16]; /* 0-15 */
|
||||
char date[12]; /* 16-27 */
|
||||
char uid[6], gid[6]; /* 28-39 */
|
||||
char mode[8]; /* 40-47 */
|
||||
char size[10]; /* 48-57 */
|
||||
char fmag[2]; /* 58-59 */
|
||||
} rawArHeader_t;
|
||||
|
||||
typedef struct headerL {
|
||||
char name[MAX_NAME_LENGTH];
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct headerL *next;
|
||||
} headerL_t;
|
||||
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
/*
|
||||
* identify Tar header (magic field) and reset srcFd to entry position
|
||||
*/
|
||||
static int checkTarMagic(int srcFd)
|
||||
{
|
||||
off_t headerStart;
|
||||
char magic[6];
|
||||
|
||||
headerStart = lseek(srcFd, 0, SEEK_CUR);
|
||||
lseek(srcFd, (off_t) 257, SEEK_CUR);
|
||||
full_read(srcFd, magic, 6);
|
||||
lseek(srcFd, headerStart, SEEK_SET);
|
||||
if (strncmp(magic, "ustar", 5)!=0)
|
||||
return(FALSE);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
static int readTarHeader(int srcFd, headerL_t *current)
|
||||
{
|
||||
rawTarHeader_t rawTarHeader;
|
||||
unsigned char *temp = (unsigned char *) &rawTarHeader;
|
||||
long sum = 0;
|
||||
int i;
|
||||
off_t initialOffset;
|
||||
|
||||
initialOffset = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
for (i = 0; i < 148 ; i++)
|
||||
sum += temp[i];
|
||||
sum += ' ' * 8;
|
||||
for (i = 156; i < 512 ; i++)
|
||||
sum += temp[i];
|
||||
if (sum!= strtol(rawTarHeader.chksum, NULL, 8))
|
||||
return(FALSE);
|
||||
sscanf(rawTarHeader.name, "%s", current->name);
|
||||
current->size = strtol(rawTarHeader.size, NULL, 8);
|
||||
current->uid = strtol(rawTarHeader.uid, NULL, 8);
|
||||
current->gid = strtol(rawTarHeader.gid, NULL, 8);
|
||||
current->mode = strtol(rawTarHeader.mode, NULL, 8);
|
||||
current->mtime = strtol(rawTarHeader.mtime, NULL, 8);
|
||||
current->offset = lseek(srcFd, 0 , SEEK_CUR);
|
||||
|
||||
current->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
current = current->next;
|
||||
return(TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* identify Ar header (magic) and reset srcFd to entry position
|
||||
*/
|
||||
static int checkArMagic(int srcFd)
|
||||
{
|
||||
off_t headerStart;
|
||||
char arMagic[8];
|
||||
|
||||
headerStart = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (full_read(srcFd, arMagic, 8) != 8) {
|
||||
error_msg("fatal error\n");
|
||||
return (FALSE);
|
||||
}
|
||||
lseek(srcFd, headerStart, SEEK_SET);
|
||||
|
||||
if (strncmp(arMagic,"!<arch>",7) != 0)
|
||||
return(FALSE);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* get, check and correct the converted header
|
||||
*/
|
||||
static int readArEntry(int srcFd, headerL_t *entry)
|
||||
{
|
||||
size_t nameLength;
|
||||
rawArHeader_t rawArHeader;
|
||||
off_t initialOffset;
|
||||
|
||||
initialOffset = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
if ((rawArHeader.fmag[0]!='`') || (rawArHeader.fmag[1]!='\n')) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
strncpy(entry->name, rawArHeader.name, 16);
|
||||
nameLength=strcspn(entry->name, " \\");
|
||||
entry->name[nameLength]='\0';
|
||||
parse_mode(rawArHeader.mode, &entry->mode);
|
||||
entry->mtime = atoi(rawArHeader.date);
|
||||
entry->uid = atoi(rawArHeader.uid);
|
||||
entry->gid = atoi(rawArHeader.gid);
|
||||
entry->size = (size_t) atoi(rawArHeader.size);
|
||||
entry->offset = initialOffset + (off_t) 60;
|
||||
|
||||
nameLength = strcspn(entry->name, "/");
|
||||
|
||||
/* handle GNU style short filenames, strip trailing '/' */
|
||||
if (nameLength > 0)
|
||||
entry->name[nameLength]='\0';
|
||||
|
||||
/* handle GNU style long filenames */
|
||||
if (nameLength == 0) {
|
||||
/* escape from recursive call */
|
||||
if (entry->name[1]=='0')
|
||||
return(TRUE);
|
||||
|
||||
/* the data section contains the real filename */
|
||||
if (entry->name[1]=='/') {
|
||||
char tempName[MAX_NAME_LENGTH];
|
||||
|
||||
if (entry->size > MAX_NAME_LENGTH)
|
||||
entry->size = MAX_NAME_LENGTH;
|
||||
full_read(srcFd, tempName, entry->size);
|
||||
tempName[entry->size-3]='\0';
|
||||
|
||||
/* read the second header for this entry */
|
||||
/* be carefull, this is recursive */
|
||||
if (readArEntry(srcFd, entry)==FALSE)
|
||||
return(FALSE);
|
||||
|
||||
if ((entry->name[0]='/') && (entry->name[1]='0'))
|
||||
strcpy(entry->name, tempName);
|
||||
else {
|
||||
error_msg("Invalid long filename\n");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* return the headerL_t struct for the specified filename
|
||||
*/
|
||||
static headerL_t *getHeaders(int srcFd, headerL_t *head, int funct)
|
||||
{
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
int tar=FALSE;
|
||||
#endif
|
||||
int ar=FALSE;
|
||||
headerL_t *list;
|
||||
off_t initialOffset;
|
||||
|
||||
list = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
initialOffset=lseek(srcFd, 0, SEEK_CUR);
|
||||
if (checkArMagic(srcFd)==TRUE)
|
||||
ar=TRUE;
|
||||
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
if (checkTarMagic(srcFd)==TRUE)
|
||||
tar=TRUE;
|
||||
|
||||
if (tar==TRUE) {
|
||||
while(readTarHeader(srcFd, list)==TRUE) {
|
||||
off_t tarOffset;
|
||||
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
*list->next = *head;
|
||||
*head = *list;
|
||||
|
||||
/* recursive check for sub-archives */
|
||||
if ((funct & RECURSIVE) == RECURSIVE)
|
||||
head = getHeaders(srcFd, head, funct);
|
||||
tarOffset = (off_t) head->size/512;
|
||||
if ( head->size % 512 > 0)
|
||||
tarOffset++;
|
||||
tarOffset=tarOffset*512;
|
||||
lseek(srcFd, head->offset + tarOffset, SEEK_SET);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ar==TRUE) {
|
||||
lseek(srcFd, 8, SEEK_CUR);
|
||||
while(1) {
|
||||
if (readArEntry(srcFd, list) == FALSE) {
|
||||
lseek(srcFd, ++initialOffset, SEEK_CUR);
|
||||
if (readArEntry(srcFd, list) == FALSE)
|
||||
return(head);
|
||||
}
|
||||
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
*list->next = *head;
|
||||
*head = *list;
|
||||
/* recursive check for sub-archives */
|
||||
if (funct & RECURSIVE)
|
||||
head = getHeaders(srcFd, head, funct);
|
||||
lseek(srcFd, head->offset + head->size, SEEK_SET);
|
||||
}
|
||||
}
|
||||
return(head);
|
||||
}
|
||||
|
||||
/*
|
||||
* find an entry in the linked list matching the filename
|
||||
*/
|
||||
static headerL_t *findEntry(headerL_t *head, const char *filename)
|
||||
{
|
||||
while(head->next != NULL) {
|
||||
if (strcmp(filename, head->name)==0)
|
||||
return(head);
|
||||
head=head->next;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
int funct = 0, opt=0;
|
||||
int srcFd=0, dstFd=0;
|
||||
headerL_t *header, *entry, *extractList;
|
||||
FILE *src_stream = NULL;
|
||||
char **extract_names = NULL;
|
||||
char ar_magic[8];
|
||||
int extract_function = extract_unconditional;
|
||||
int opt;
|
||||
int num_of_entries = 0;
|
||||
extern off_t archive_offset;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ovtpxR")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
funct |= PRESERVE_DATE;
|
||||
extract_function |= extract_preserve_date;
|
||||
break;
|
||||
case 'v':
|
||||
funct |= VERBOSE;
|
||||
extract_function |= extract_verbose_list;
|
||||
break;
|
||||
case 't':
|
||||
funct |= DISPLAY;
|
||||
break;
|
||||
case 'x':
|
||||
funct |= EXT_TO_FILE;
|
||||
extract_function |= extract_list;
|
||||
break;
|
||||
case 'p':
|
||||
funct |= EXT_TO_STDOUT;
|
||||
extract_function |= extract_to_stdout;
|
||||
break;
|
||||
case 'R':
|
||||
funct |= RECURSIVE;
|
||||
case 'x':
|
||||
extract_function |= extract_all_to_fs;
|
||||
break;
|
||||
default:
|
||||
usage(ar_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc)
|
||||
usage(ar_usage);
|
||||
|
||||
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
|
||||
error_msg_and_die("Cannot read %s\n", argv[optind]);
|
||||
|
||||
optind++;
|
||||
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
header = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
extractList = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
|
||||
header = getHeaders(srcFd, header, funct);
|
||||
/* find files to extract or display */
|
||||
if (optind<argc) {
|
||||
/* only handle specified files */
|
||||
while(optind < argc) {
|
||||
if ( (entry = findEntry(header, argv[optind])) != NULL) {
|
||||
entry->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
*entry->next = *extractList;
|
||||
*extractList = *entry;
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
if (optind == argc) {
|
||||
show_usage();
|
||||
}
|
||||
else
|
||||
extractList = header;
|
||||
|
||||
while(extractList->next != NULL) {
|
||||
if (funct & EXT_TO_FILE) {
|
||||
if (is_directory(extractList->name, TRUE, NULL)==FALSE)
|
||||
create_path(extractList->name, 0666);
|
||||
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
|
||||
lseek(srcFd, extractList->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
|
||||
}
|
||||
if (funct & EXT_TO_STDOUT) {
|
||||
lseek(srcFd, extractList->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, fileno(stdout), (size_t) extractList->size);
|
||||
}
|
||||
if ( (funct & DISPLAY) || (funct & VERBOSE)) {
|
||||
if (funct & VERBOSE)
|
||||
printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
|
||||
extractList->uid, extractList->gid,
|
||||
extractList->size, time_string(extractList->mtime));
|
||||
printf("%s\n", extractList->name);
|
||||
}
|
||||
extractList=extractList->next;
|
||||
|
||||
src_stream = xfopen(argv[optind++], "r");
|
||||
|
||||
/* check ar magic */
|
||||
fread(ar_magic, 1, 8, src_stream);
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0) {
|
||||
error_msg_and_die("invalid magic");
|
||||
}
|
||||
archive_offset = 8;
|
||||
|
||||
extract_names = malloc(sizeof(char *));
|
||||
extract_names[0] = NULL;
|
||||
while (optind < argc) {
|
||||
num_of_entries++;
|
||||
*extract_names = realloc(*extract_names, num_of_entries);
|
||||
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
|
||||
unarchive(src_stream, &get_header_ar, extract_function, "./", extract_names);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+40
-342
@@ -3,7 +3,7 @@
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@netconnect.com.au> 1 June 2000
|
||||
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
|
||||
*
|
||||
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
|
||||
*
|
||||
@@ -21,371 +21,69 @@
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Last modified 20 September 2000
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define BLOCK_SIZE 60
|
||||
#define PRESERVE_DATE 1 /* preserve original dates */
|
||||
#define VERBOSE 2 /* be verbose */
|
||||
#define DISPLAY 4 /* display contents */
|
||||
#define EXT_TO_FILE 8 /* extract contents of archive */
|
||||
#define EXT_TO_STDOUT 16 /* extract to stdout */
|
||||
#define RECURSIVE 32
|
||||
|
||||
#define MAX_NAME_LENGTH 100
|
||||
|
||||
//#define BB_DECLARE_EXTERN
|
||||
//#define bb_need_io_error
|
||||
//#include "messages.c"
|
||||
|
||||
//#define BB_AR_EXPERIMENTAL_UNTAR
|
||||
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
typedef struct rawTarHeader {
|
||||
char name[100]; /* 0-99 */
|
||||
char mode[8]; /* 100-107 */
|
||||
char uid[8]; /* 108-115 */
|
||||
char gid[8]; /* 116-123 */
|
||||
char size[12]; /* 124-135 */
|
||||
char mtime[12]; /* 136-147 */
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char linkname[100]; /* 157-256 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char version[2]; /* 263-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char devmajor[8]; /* 329-336 */
|
||||
char devminor[8]; /* 337-344 */
|
||||
char prefix[155]; /* 345-499 */
|
||||
char padding[12]; /* 500-512 */
|
||||
} rawTarHeader_t;
|
||||
#endif
|
||||
|
||||
typedef struct rawArHeader { /* Byte Offset */
|
||||
char name[16]; /* 0-15 */
|
||||
char date[12]; /* 16-27 */
|
||||
char uid[6], gid[6]; /* 28-39 */
|
||||
char mode[8]; /* 40-47 */
|
||||
char size[10]; /* 48-57 */
|
||||
char fmag[2]; /* 58-59 */
|
||||
} rawArHeader_t;
|
||||
|
||||
typedef struct headerL {
|
||||
char name[MAX_NAME_LENGTH];
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct headerL *next;
|
||||
} headerL_t;
|
||||
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
/*
|
||||
* identify Tar header (magic field) and reset srcFd to entry position
|
||||
*/
|
||||
static int checkTarMagic(int srcFd)
|
||||
{
|
||||
off_t headerStart;
|
||||
char magic[6];
|
||||
|
||||
headerStart = lseek(srcFd, 0, SEEK_CUR);
|
||||
lseek(srcFd, (off_t) 257, SEEK_CUR);
|
||||
full_read(srcFd, magic, 6);
|
||||
lseek(srcFd, headerStart, SEEK_SET);
|
||||
if (strncmp(magic, "ustar", 5)!=0)
|
||||
return(FALSE);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
||||
static int readTarHeader(int srcFd, headerL_t *current)
|
||||
{
|
||||
rawTarHeader_t rawTarHeader;
|
||||
unsigned char *temp = (unsigned char *) &rawTarHeader;
|
||||
long sum = 0;
|
||||
int i;
|
||||
off_t initialOffset;
|
||||
|
||||
initialOffset = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (full_read(srcFd, (char *) &rawTarHeader, 512) != 512) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
for (i = 0; i < 148 ; i++)
|
||||
sum += temp[i];
|
||||
sum += ' ' * 8;
|
||||
for (i = 156; i < 512 ; i++)
|
||||
sum += temp[i];
|
||||
if (sum!= strtol(rawTarHeader.chksum, NULL, 8))
|
||||
return(FALSE);
|
||||
sscanf(rawTarHeader.name, "%s", current->name);
|
||||
current->size = strtol(rawTarHeader.size, NULL, 8);
|
||||
current->uid = strtol(rawTarHeader.uid, NULL, 8);
|
||||
current->gid = strtol(rawTarHeader.gid, NULL, 8);
|
||||
current->mode = strtol(rawTarHeader.mode, NULL, 8);
|
||||
current->mtime = strtol(rawTarHeader.mtime, NULL, 8);
|
||||
current->offset = lseek(srcFd, 0 , SEEK_CUR);
|
||||
|
||||
current->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
current = current->next;
|
||||
return(TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* identify Ar header (magic) and reset srcFd to entry position
|
||||
*/
|
||||
static int checkArMagic(int srcFd)
|
||||
{
|
||||
off_t headerStart;
|
||||
char arMagic[8];
|
||||
|
||||
headerStart = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (full_read(srcFd, arMagic, 8) != 8) {
|
||||
error_msg("fatal error\n");
|
||||
return (FALSE);
|
||||
}
|
||||
lseek(srcFd, headerStart, SEEK_SET);
|
||||
|
||||
if (strncmp(arMagic,"!<arch>",7) != 0)
|
||||
return(FALSE);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* get, check and correct the converted header
|
||||
*/
|
||||
static int readArEntry(int srcFd, headerL_t *entry)
|
||||
{
|
||||
size_t nameLength;
|
||||
rawArHeader_t rawArHeader;
|
||||
off_t initialOffset;
|
||||
|
||||
initialOffset = lseek(srcFd, 0, SEEK_CUR);
|
||||
if (full_read(srcFd, (char *) &rawArHeader, 60) != 60) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
if ((rawArHeader.fmag[0]!='`') || (rawArHeader.fmag[1]!='\n')) {
|
||||
lseek(srcFd, initialOffset, SEEK_SET);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
strncpy(entry->name, rawArHeader.name, 16);
|
||||
nameLength=strcspn(entry->name, " \\");
|
||||
entry->name[nameLength]='\0';
|
||||
parse_mode(rawArHeader.mode, &entry->mode);
|
||||
entry->mtime = atoi(rawArHeader.date);
|
||||
entry->uid = atoi(rawArHeader.uid);
|
||||
entry->gid = atoi(rawArHeader.gid);
|
||||
entry->size = (size_t) atoi(rawArHeader.size);
|
||||
entry->offset = initialOffset + (off_t) 60;
|
||||
|
||||
nameLength = strcspn(entry->name, "/");
|
||||
|
||||
/* handle GNU style short filenames, strip trailing '/' */
|
||||
if (nameLength > 0)
|
||||
entry->name[nameLength]='\0';
|
||||
|
||||
/* handle GNU style long filenames */
|
||||
if (nameLength == 0) {
|
||||
/* escape from recursive call */
|
||||
if (entry->name[1]=='0')
|
||||
return(TRUE);
|
||||
|
||||
/* the data section contains the real filename */
|
||||
if (entry->name[1]=='/') {
|
||||
char tempName[MAX_NAME_LENGTH];
|
||||
|
||||
if (entry->size > MAX_NAME_LENGTH)
|
||||
entry->size = MAX_NAME_LENGTH;
|
||||
full_read(srcFd, tempName, entry->size);
|
||||
tempName[entry->size-3]='\0';
|
||||
|
||||
/* read the second header for this entry */
|
||||
/* be carefull, this is recursive */
|
||||
if (readArEntry(srcFd, entry)==FALSE)
|
||||
return(FALSE);
|
||||
|
||||
if ((entry->name[0]='/') && (entry->name[1]='0'))
|
||||
strcpy(entry->name, tempName);
|
||||
else {
|
||||
error_msg("Invalid long filename\n");
|
||||
return(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* return the headerL_t struct for the specified filename
|
||||
*/
|
||||
static headerL_t *getHeaders(int srcFd, headerL_t *head, int funct)
|
||||
{
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
int tar=FALSE;
|
||||
#endif
|
||||
int ar=FALSE;
|
||||
headerL_t *list;
|
||||
off_t initialOffset;
|
||||
|
||||
list = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
initialOffset=lseek(srcFd, 0, SEEK_CUR);
|
||||
if (checkArMagic(srcFd)==TRUE)
|
||||
ar=TRUE;
|
||||
|
||||
#if defined BB_AR_EXPERIMENTAL_UNTAR
|
||||
if (checkTarMagic(srcFd)==TRUE)
|
||||
tar=TRUE;
|
||||
|
||||
if (tar==TRUE) {
|
||||
while(readTarHeader(srcFd, list)==TRUE) {
|
||||
off_t tarOffset;
|
||||
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
*list->next = *head;
|
||||
*head = *list;
|
||||
|
||||
/* recursive check for sub-archives */
|
||||
if ((funct & RECURSIVE) == RECURSIVE)
|
||||
head = getHeaders(srcFd, head, funct);
|
||||
tarOffset = (off_t) head->size/512;
|
||||
if ( head->size % 512 > 0)
|
||||
tarOffset++;
|
||||
tarOffset=tarOffset*512;
|
||||
lseek(srcFd, head->offset + tarOffset, SEEK_SET);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ar==TRUE) {
|
||||
lseek(srcFd, 8, SEEK_CUR);
|
||||
while(1) {
|
||||
if (readArEntry(srcFd, list) == FALSE) {
|
||||
lseek(srcFd, ++initialOffset, SEEK_CUR);
|
||||
if (readArEntry(srcFd, list) == FALSE)
|
||||
return(head);
|
||||
}
|
||||
list->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
*list->next = *head;
|
||||
*head = *list;
|
||||
/* recursive check for sub-archives */
|
||||
if (funct & RECURSIVE)
|
||||
head = getHeaders(srcFd, head, funct);
|
||||
lseek(srcFd, head->offset + head->size, SEEK_SET);
|
||||
}
|
||||
}
|
||||
return(head);
|
||||
}
|
||||
|
||||
/*
|
||||
* find an entry in the linked list matching the filename
|
||||
*/
|
||||
static headerL_t *findEntry(headerL_t *head, const char *filename)
|
||||
{
|
||||
while(head->next != NULL) {
|
||||
if (strcmp(filename, head->name)==0)
|
||||
return(head);
|
||||
head=head->next;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
int funct = 0, opt=0;
|
||||
int srcFd=0, dstFd=0;
|
||||
headerL_t *header, *entry, *extractList;
|
||||
FILE *src_stream = NULL;
|
||||
char **extract_names = NULL;
|
||||
char ar_magic[8];
|
||||
int extract_function = extract_unconditional;
|
||||
int opt;
|
||||
int num_of_entries = 0;
|
||||
extern off_t archive_offset;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ovtpxR")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
funct |= PRESERVE_DATE;
|
||||
extract_function |= extract_preserve_date;
|
||||
break;
|
||||
case 'v':
|
||||
funct |= VERBOSE;
|
||||
extract_function |= extract_verbose_list;
|
||||
break;
|
||||
case 't':
|
||||
funct |= DISPLAY;
|
||||
break;
|
||||
case 'x':
|
||||
funct |= EXT_TO_FILE;
|
||||
extract_function |= extract_list;
|
||||
break;
|
||||
case 'p':
|
||||
funct |= EXT_TO_STDOUT;
|
||||
extract_function |= extract_to_stdout;
|
||||
break;
|
||||
case 'R':
|
||||
funct |= RECURSIVE;
|
||||
case 'x':
|
||||
extract_function |= extract_all_to_fs;
|
||||
break;
|
||||
default:
|
||||
usage(ar_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc)
|
||||
usage(ar_usage);
|
||||
|
||||
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
|
||||
error_msg_and_die("Cannot read %s\n", argv[optind]);
|
||||
|
||||
optind++;
|
||||
entry = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
header = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
extractList = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
|
||||
header = getHeaders(srcFd, header, funct);
|
||||
/* find files to extract or display */
|
||||
if (optind<argc) {
|
||||
/* only handle specified files */
|
||||
while(optind < argc) {
|
||||
if ( (entry = findEntry(header, argv[optind])) != NULL) {
|
||||
entry->next = (headerL_t *) xmalloc(sizeof(headerL_t));
|
||||
*entry->next = *extractList;
|
||||
*extractList = *entry;
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
if (optind == argc) {
|
||||
show_usage();
|
||||
}
|
||||
else
|
||||
extractList = header;
|
||||
|
||||
while(extractList->next != NULL) {
|
||||
if (funct & EXT_TO_FILE) {
|
||||
if (is_directory(extractList->name, TRUE, NULL)==FALSE)
|
||||
create_path(extractList->name, 0666);
|
||||
dstFd = open(extractList->name, O_WRONLY | O_CREAT, extractList->mode);
|
||||
lseek(srcFd, extractList->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, dstFd, (size_t) extractList->size);
|
||||
}
|
||||
if (funct & EXT_TO_STDOUT) {
|
||||
lseek(srcFd, extractList->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, fileno(stdout), (size_t) extractList->size);
|
||||
}
|
||||
if ( (funct & DISPLAY) || (funct & VERBOSE)) {
|
||||
if (funct & VERBOSE)
|
||||
printf("%s %d/%d %8d %s ", mode_string(extractList->mode),
|
||||
extractList->uid, extractList->gid,
|
||||
extractList->size, time_string(extractList->mtime));
|
||||
printf("%s\n", extractList->name);
|
||||
}
|
||||
extractList=extractList->next;
|
||||
|
||||
src_stream = xfopen(argv[optind++], "r");
|
||||
|
||||
/* check ar magic */
|
||||
fread(ar_magic, 1, 8, src_stream);
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0) {
|
||||
error_msg_and_die("invalid magic");
|
||||
}
|
||||
archive_offset = 8;
|
||||
|
||||
extract_names = malloc(sizeof(char *));
|
||||
extract_names[0] = NULL;
|
||||
while (optind < argc) {
|
||||
num_of_entries++;
|
||||
*extract_names = realloc(*extract_names, num_of_entries);
|
||||
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
|
||||
unarchive(src_stream, &get_header_ar, extract_function, "./", extract_names);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini cpio implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2001 by Glenn McGrath
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Limitations:
|
||||
* Doesn't check CRC's
|
||||
* Only supports new ASCII and CRC formats
|
||||
*
|
||||
*/
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int cpio_main(int argc, char **argv)
|
||||
{
|
||||
FILE *src_stream = stdin;
|
||||
char **extract_names = NULL;
|
||||
int extract_function = 0;
|
||||
int num_of_entries = 0;
|
||||
int opt = 0;
|
||||
mode_t oldmask = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "idmuvtF:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i': // extract
|
||||
extract_function |= extract_all_to_fs;
|
||||
break;
|
||||
case 'd': // create _leading_ directories
|
||||
extract_function |= extract_create_leading_dirs;
|
||||
oldmask = umask(077); /* Make make_directory act like GNU cpio */
|
||||
break;
|
||||
case 'm': // preserve modification time
|
||||
extract_function |= extract_preserve_date;
|
||||
break;
|
||||
case 'v': // verbosly list files
|
||||
extract_function |= extract_verbose_list;
|
||||
break;
|
||||
case 'u': // unconditional
|
||||
extract_function |= extract_unconditional;
|
||||
break;
|
||||
case 't': // list files
|
||||
extract_function |= extract_list;
|
||||
break;
|
||||
case 'F':
|
||||
src_stream = xfopen(optarg, "r");
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (extract_function & extract_all_to_fs && extract_function & extract_list) {
|
||||
extract_function ^= extract_all_to_fs; /* If specify t, don't extract*/
|
||||
}
|
||||
|
||||
if (extract_function & extract_all_to_fs && extract_function & extract_verbose_list) { /* The meaning of v changes on extract */
|
||||
extract_function ^= extract_verbose_list;
|
||||
extract_function |= extract_list;
|
||||
}
|
||||
|
||||
extract_names = malloc(4);
|
||||
while (optind < argc) {
|
||||
num_of_entries++;
|
||||
*extract_names = realloc(*extract_names, num_of_entries);
|
||||
extract_names[num_of_entries - 1] = xstrdup(argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
|
||||
unarchive(src_stream, &get_header_cpio, extract_function, "./", extract_names);
|
||||
if (oldmask) umask(oldmask); /* Restore umask if we changed it */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+854
@@ -0,0 +1,854 @@
|
||||
#include <ctype.h>
|
||||
#include <dirent.h>
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <search.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#define DEPENDSMAX 64 /* maximum number of depends we can handle */
|
||||
|
||||
/* Should we do full dependency checking? */
|
||||
//#define DODEPENDS 0
|
||||
|
||||
/* Should we do debugging? */
|
||||
//#define DODEBUG 0
|
||||
|
||||
#ifdef DODEBUG
|
||||
#define SYSTEM(x) do_system(x)
|
||||
#define DPRINTF(fmt,args...) fprintf(stderr, fmt, ##args)
|
||||
#else
|
||||
#define SYSTEM(x) system(x)
|
||||
#define DPRINTF(fmt,args...) /* nothing */
|
||||
#endif
|
||||
|
||||
/* from dpkg-deb.c */
|
||||
|
||||
static const char statusfile[] = "/var/lib/dpkg/status.udeb";
|
||||
static const char new_statusfile[] = "/var/lib/dpkg/status.udeb.new";
|
||||
static const char bak_statusfile[] = "/var/lib/dpkg/status.udeb.bak";
|
||||
|
||||
static const char infodir[] = "/var/lib/dpkg/info/";
|
||||
static const char udpkg_quiet[] = "UDPKG_QUIET";
|
||||
|
||||
//static const int status_want_unknown = 1;
|
||||
static const int state_want_install = 2;
|
||||
//static const int state_want_hold = 3;
|
||||
//static const int state_want_deinstall = 4;
|
||||
//static const int state_want_purge = 5;
|
||||
|
||||
static const int state_flag_ok = 1;
|
||||
//static const int state_flag_reinstreq = 2;
|
||||
//static const int state_flag_hold = 3;
|
||||
//static const int state_flag_holdreinstreq = 4;
|
||||
|
||||
//static const int state_statusnoninstalled = 1;
|
||||
static const int state_status_unpacked = 2;
|
||||
static const int state_status_halfconfigured = 3;
|
||||
static const int state_status_installed = 4;
|
||||
static const int state_status_halfinstalled = 5;
|
||||
//static const int state_statusconfigfiles = 6;
|
||||
//static const int state_statuspostinstfailed = 7;
|
||||
//static const int state_statusremovalfailed = 8;
|
||||
|
||||
static const char *state_words_want[] = { "unknown", "install", "hold", "deinstall", "purge", 0 };
|
||||
static const char *state_words_flag[] = { "ok", "reinstreq", "hold", "hold-reinstreq", 0 };
|
||||
static const char *state_words_status[] = { "not-installed", "unpacked", "half-configured", "installed",
|
||||
"half-installed", "config-files", "post-inst-failed", "removal-failed", 0 };
|
||||
|
||||
static const int color_white = 0;
|
||||
static const int color_grey = 1;
|
||||
static const int color_black = 2;
|
||||
|
||||
/* data structures */
|
||||
typedef struct package_s {
|
||||
char *filename;
|
||||
char *package;
|
||||
unsigned char state_want;
|
||||
unsigned char state_flag;
|
||||
unsigned char state_status;
|
||||
char *depends;
|
||||
char *provides;
|
||||
char *description;
|
||||
char *priority;
|
||||
char *section;
|
||||
char *installed_size;
|
||||
char *maintainer;
|
||||
char *source;
|
||||
char *version;
|
||||
char *pre_depends;
|
||||
char *replaces;
|
||||
char *recommends;
|
||||
char *suggests;
|
||||
char *conflicts;
|
||||
char *conffiles;
|
||||
char *long_description;
|
||||
char *architecture;
|
||||
char *md5sum;
|
||||
int installer_menu_item;
|
||||
char color; /* for topo-sort */
|
||||
struct package_s *requiredfor[DEPENDSMAX];
|
||||
unsigned short requiredcount;
|
||||
struct package_s *next;
|
||||
} package_t;
|
||||
|
||||
#ifdef DODEBUG
|
||||
static int do_system(const char *cmd)
|
||||
{
|
||||
DPRINTF("cmd is %s\n", cmd);
|
||||
return system(cmd);
|
||||
}
|
||||
#else
|
||||
#define do_system(cmd) system(cmd)
|
||||
#endif
|
||||
|
||||
static int package_compare(const void *p1, const void *p2)
|
||||
{
|
||||
return strcmp(((package_t *)p1)->package,
|
||||
((package_t *)p2)->package);
|
||||
}
|
||||
|
||||
#ifdef DODEPENDS
|
||||
|
||||
static char **depends_split(const char *dependsstr)
|
||||
{
|
||||
static char *dependsvec[DEPENDSMAX];
|
||||
char *p;
|
||||
int i = 0;
|
||||
|
||||
dependsvec[0] = 0;
|
||||
if (dependsstr == 0) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
p = xstrdup(dependsstr);
|
||||
while (*p != 0 && *p != '\n') {
|
||||
if (*p != ' ') {
|
||||
if (*p == ',') {
|
||||
*p = 0;
|
||||
dependsvec[++i] = 0;
|
||||
} else {
|
||||
if (dependsvec[i] == 0) {
|
||||
dependsvec[i] = p;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*p = 0; /* eat the space... */
|
||||
}
|
||||
p++;
|
||||
}
|
||||
*p = 0;
|
||||
|
||||
end:
|
||||
dependsvec[i+1] = 0;
|
||||
return dependsvec;
|
||||
}
|
||||
|
||||
/* Topological sort algorithm:
|
||||
* ordered is the output list, pkgs is the dependency graph, pkg is
|
||||
* the current node
|
||||
*
|
||||
* recursively add all the adjacent nodes to the ordered list, marking
|
||||
* each one as visited along the way
|
||||
*
|
||||
* yes, this algorithm looks a bit odd when all the params have the
|
||||
* same type :-)
|
||||
*/
|
||||
static void depends_sort_visit(package_t **ordered, package_t *pkgs,
|
||||
package_t *pkg)
|
||||
{
|
||||
unsigned short i;
|
||||
|
||||
/* mark node as processing */
|
||||
pkg->color = color_grey;
|
||||
|
||||
/* visit each not-yet-visited node */
|
||||
for (i = 0; i < pkg->requiredcount; i++)
|
||||
if (pkg->requiredfor[i]->color == color_white)
|
||||
depends_sort_visit(ordered, pkgs, pkg->requiredfor[i]);
|
||||
|
||||
#if 0
|
||||
/* add it to the list */
|
||||
newnode = (struct package_t *)xmalloc(sizeof(struct package_t));
|
||||
/* make a shallow copy */
|
||||
*newnode = *pkg;
|
||||
newnode->next = *ordered;
|
||||
*ordered = newnode;
|
||||
#endif
|
||||
|
||||
pkg->next = *ordered;
|
||||
*ordered = pkg;
|
||||
|
||||
/* mark node as done */
|
||||
pkg->color = color_black;
|
||||
}
|
||||
|
||||
static package_t *depends_sort(package_t *pkgs)
|
||||
{
|
||||
/* TODO: it needs to break cycles in the to-be-installed package
|
||||
* graph... */
|
||||
package_t *ordered = NULL;
|
||||
package_t *pkg;
|
||||
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
pkg->color = color_white;
|
||||
}
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
if (pkg->color == color_white) {
|
||||
depends_sort_visit(&ordered, pkgs, pkg);
|
||||
}
|
||||
}
|
||||
|
||||
/* Leaks the old list... return the new one... */
|
||||
return ordered;
|
||||
}
|
||||
|
||||
|
||||
/* resolve package dependencies --
|
||||
* for each package in the list of packages to be installed, we parse its
|
||||
* dependency info to determine if the dependent packages are either
|
||||
* already installed, or are scheduled to be installed. If both tests fail
|
||||
* than bail.
|
||||
*
|
||||
* The algorithm here is O(n^2*m) where n = number of packages to be
|
||||
* installed and m is the # of dependencies per package. Not a terribly
|
||||
* efficient algorithm, but given that at any one time you are unlikely
|
||||
* to install a very large number of packages it doesn't really matter
|
||||
*/
|
||||
static package_t *depends_resolve(package_t *pkgs, void *status)
|
||||
{
|
||||
package_t *pkg, *chk;
|
||||
package_t dependpkg;
|
||||
char **dependsvec;
|
||||
int i;
|
||||
void *found;
|
||||
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
dependsvec = depends_split(pkg->depends);
|
||||
i = 0;
|
||||
while (dependsvec[i] != 0) {
|
||||
/* Check for dependencies; first look for installed packages */
|
||||
dependpkg.package = dependsvec[i];
|
||||
if (((found = tfind(&dependpkg, &status, package_compare)) == 0) ||
|
||||
((chk = *(package_t **)found) && (chk->state_flag & state_flag_ok) &&
|
||||
(chk->state_status & state_status_installed))) {
|
||||
|
||||
/* if it fails, we look through the list of packages we are going to
|
||||
* install */
|
||||
for (chk = pkgs; chk != 0; chk = chk->next) {
|
||||
if (strcmp(chk->package, dependsvec[i]) == 0 || (chk->provides &&
|
||||
strncmp(chk->provides, dependsvec[i], strlen(dependsvec[i])) == 0)) {
|
||||
if (chk->requiredcount >= DEPENDSMAX) {
|
||||
error_msg("Too many dependencies for %s", chk->package);
|
||||
return 0;
|
||||
}
|
||||
if (chk != pkg) {
|
||||
chk->requiredfor[chk->requiredcount++] = pkg;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (chk == 0) {
|
||||
error_msg("%s depends on %s, but it is not going to be installed", pkg->package, dependsvec[i]);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return depends_sort(pkgs);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Status file handling routines
|
||||
*
|
||||
* This is a fairly minimalistic implementation. there are two main functions
|
||||
* that are supported:
|
||||
*
|
||||
* 1) reading the entire status file:
|
||||
* the status file is read into memory as a binary-tree, with just the
|
||||
* package and status info preserved
|
||||
*
|
||||
* 2) merging the status file
|
||||
* control info from (new) packages is merged into the status file,
|
||||
* replacing any pre-existing entries. when a merge happens, status info
|
||||
* read using the status_read function is written back to the status file
|
||||
*/
|
||||
static unsigned char status_parse(const char *line, const char **status_words)
|
||||
{
|
||||
unsigned char status_num;
|
||||
int i = 0;
|
||||
|
||||
while (status_words[i] != 0) {
|
||||
if (strncmp(line, status_words[i], strlen(status_words[i])) == 0) {
|
||||
status_num = (char)i;
|
||||
return(status_num);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
/* parse error */
|
||||
error_msg("Invalid status word");
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read the buffered control file and parse it,
|
||||
* filling parsed fields into the package structure
|
||||
*/
|
||||
static int fill_package_struct(package_t *package, const char *package_buffer)
|
||||
{
|
||||
char *field = NULL;
|
||||
int field_start = 0;
|
||||
int field_length = 0;
|
||||
|
||||
while ((field = read_package_field(&package_buffer[field_start])) != NULL) {
|
||||
field_length = strlen(field);
|
||||
field_start += (field_length + 1);
|
||||
|
||||
if (strlen(field) == 0) {
|
||||
printf("empty line: *this shouldnt happen i dont think*\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* these are common to both installed and uninstalled packages */
|
||||
if (strstr(field, "Package: ") == field) {
|
||||
package->package = strdup(field + 9);
|
||||
}
|
||||
else if (strstr(field, "Depends: ") == field) {
|
||||
package->depends = strdup(field + 9);
|
||||
}
|
||||
else if (strstr(field, "Provides: ") == field) {
|
||||
package->provides = strdup(field + 10);
|
||||
}
|
||||
/* This is specific to the Debian Installer. Ifdef? */
|
||||
else if (strstr(field, "installer-menu-item: ") == field) {
|
||||
package->installer_menu_item = atoi(field + 21);
|
||||
}
|
||||
else if (strstr(field, "Description: ") == field) {
|
||||
package->description = strdup(field + 13);
|
||||
}
|
||||
else if (strstr(field, "Priority: ") == field) {
|
||||
package->priority = strdup(field + 10);
|
||||
}
|
||||
else if (strstr(field, "Section: ") == field) {
|
||||
package->section = strdup(field + 9);
|
||||
}
|
||||
else if (strstr(field, "Installed-Size: ") == field) {
|
||||
package->installed_size = strdup(field + 16);
|
||||
}
|
||||
else if (strstr(field, "Maintainer: ") == field) {
|
||||
package->maintainer = strdup(field + 12);
|
||||
}
|
||||
else if (strstr(field, "Version: ") == field) {
|
||||
package->version = strdup(field + 9);
|
||||
}
|
||||
else if (strstr(field, "Suggests: ") == field) {
|
||||
package->suggests = strdup(field + 10);
|
||||
}
|
||||
else if (strstr(field, "Recommends: ") == field) {
|
||||
package->recommends = strdup(field + 12);
|
||||
}
|
||||
/* else if (strstr(field, "Conffiles: ") == field) {
|
||||
package->conffiles = read_block(file);
|
||||
package->conffiles = xcalloc(1, 1);
|
||||
while ((field = strtok(NULL, "\n")) != NULL) {
|
||||
package->long_description = xrealloc(package->conffiles,
|
||||
strlen(package->conffiles) + strlen(field) + 1);
|
||||
strcat(package->conffiles, field);
|
||||
}
|
||||
}
|
||||
*/
|
||||
/* These are only in available file */
|
||||
else if (strstr(field, "Architecture: ") == field) {
|
||||
package->architecture = strdup(field + 14);
|
||||
}
|
||||
else if (strstr(field, "Filename: ") == field) {
|
||||
package->filename = strdup(field + 10);
|
||||
}
|
||||
else if (strstr(field, "MD5sum ") == field) {
|
||||
package->md5sum = strdup(field + 7);
|
||||
}
|
||||
|
||||
/* This is only needed for status file */
|
||||
if (strstr(field, "Status: ") == field) {
|
||||
char *word_pointer;
|
||||
|
||||
word_pointer = strchr(field, ' ') + 1;
|
||||
package->state_want = status_parse(word_pointer, state_words_want);
|
||||
word_pointer = strchr(word_pointer, ' ') + 1;
|
||||
package->state_flag = status_parse(word_pointer, state_words_flag);
|
||||
word_pointer = strchr(word_pointer, ' ') + 1;
|
||||
package->state_status = status_parse(word_pointer, state_words_status);
|
||||
} else {
|
||||
package->state_want = status_parse("purge", state_words_want);
|
||||
package->state_flag = status_parse("ok", state_words_flag);
|
||||
package->state_status = status_parse("not-installed", state_words_status);
|
||||
}
|
||||
|
||||
free(field);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
extern void write_package(FILE *out_file, package_t *pkg)
|
||||
{
|
||||
if (pkg->package) {
|
||||
fprintf(out_file, "Package: %s\n", pkg->package);
|
||||
}
|
||||
if ((pkg->state_want != 0) || (pkg->state_flag != 0)|| (pkg->state_status != 0)) {
|
||||
fprintf(out_file, "Status: %s %s %s\n",
|
||||
state_words_want[pkg->state_want - 1],
|
||||
state_words_flag[pkg->state_flag - 1],
|
||||
state_words_status[pkg->state_status - 1]);
|
||||
}
|
||||
if (pkg->depends) {
|
||||
fprintf(out_file, "Depends: %s\n", pkg->depends);
|
||||
}
|
||||
if (pkg->provides) {
|
||||
fprintf(out_file, "Provides: %s\n", pkg->provides);
|
||||
}
|
||||
if (pkg->priority) {
|
||||
fprintf(out_file, "Priority: %s\n", pkg->priority);
|
||||
}
|
||||
if (pkg->section) {
|
||||
fprintf(out_file, "Section: %s\n", pkg->section);
|
||||
}
|
||||
if (pkg->section) {
|
||||
fprintf(out_file, "Installed-Size: %s\n", pkg->installed_size);
|
||||
}
|
||||
if (pkg->maintainer) {
|
||||
fprintf(out_file, "Maintainer: %s\n", pkg->maintainer);
|
||||
}
|
||||
if (pkg->source) {
|
||||
fprintf(out_file, "Source: %s\n", pkg->source);
|
||||
}
|
||||
if (pkg->version) {
|
||||
fprintf(out_file, "Version: %s\n", pkg->version);
|
||||
}
|
||||
if (pkg->pre_depends) {
|
||||
fprintf(out_file, "Pre-depends: %s\n", pkg->pre_depends);
|
||||
}
|
||||
if (pkg->replaces) {
|
||||
fprintf(out_file, "Replaces: %s\n", pkg->replaces);
|
||||
}
|
||||
if (pkg->recommends) {
|
||||
fprintf(out_file, "Recommends: %s\n", pkg->recommends);
|
||||
}
|
||||
if (pkg->suggests) {
|
||||
fprintf(out_file, "Suggests: %s\n", pkg->suggests);
|
||||
}
|
||||
if (pkg->conflicts) {
|
||||
fprintf(out_file, "Conflicts: %s\n", pkg->conflicts);
|
||||
}
|
||||
if (pkg->conffiles) {
|
||||
fprintf(out_file, "Conf-files: %s\n", pkg->conffiles);
|
||||
}
|
||||
if (pkg->architecture) {
|
||||
fprintf(out_file, "Architecture: %s\n", pkg->architecture);
|
||||
}
|
||||
if (pkg->filename) {
|
||||
fprintf(out_file, "Filename: %s\n", pkg->filename);
|
||||
}
|
||||
if (pkg->md5sum) {
|
||||
fprintf(out_file, "MD5sum: %s\n", pkg->md5sum);
|
||||
}
|
||||
if (pkg->installer_menu_item) {
|
||||
fprintf(out_file, "installer-main-menu %d\n", pkg->installer_menu_item);
|
||||
}
|
||||
if (pkg->description) {
|
||||
fprintf(out_file, "Description: %s\n", pkg->description);
|
||||
}
|
||||
fputc('\n', out_file);
|
||||
pkg = pkg->next;
|
||||
}
|
||||
|
||||
static void *status_read(void)
|
||||
{
|
||||
FILE *f;
|
||||
void *status = 0;
|
||||
package_t *m = 0, *p = 0, *t = 0;
|
||||
char *package_control_buffer = NULL;
|
||||
|
||||
if (getenv(udpkg_quiet) == NULL) {
|
||||
printf("(Reading database...)\n");
|
||||
}
|
||||
|
||||
if ((f = wfopen(statusfile, "r")) == NULL) {
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
while ( (package_control_buffer = fgets_str(f, "\n\n")) != NULL) {
|
||||
m = (package_t *)xcalloc(1, sizeof(package_t));
|
||||
fill_package_struct(m, package_control_buffer);
|
||||
if (m->package) {
|
||||
/*
|
||||
* If there is an item in the tree by this name,
|
||||
* it must be a virtual package; insert real
|
||||
* package in preference.
|
||||
*/
|
||||
tdelete(m, &status, package_compare);
|
||||
tsearch(m, &status, package_compare);
|
||||
if (m->provides) {
|
||||
/*
|
||||
* A "Provides" triggers the insertion
|
||||
* of a pseudo package into the status
|
||||
* binary-tree.
|
||||
*/
|
||||
p = (package_t *)xcalloc(1, sizeof(package_t));
|
||||
p->package = xstrdup(m->provides);
|
||||
t = *(package_t **)tsearch(p, &status, package_compare);
|
||||
if (t != p) {
|
||||
free(p->package);
|
||||
free(p);
|
||||
} else {
|
||||
/*
|
||||
* Pseudo package status is the
|
||||
* same as the status of the
|
||||
* package providing it
|
||||
* FIXME: (not quite right, if 2
|
||||
* packages of different statuses
|
||||
* provide it).
|
||||
*/
|
||||
t->state_want = m->state_want;
|
||||
t->state_flag = m->state_flag;
|
||||
t->state_status = m->state_status;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
free(m);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return status;
|
||||
}
|
||||
|
||||
static int status_merge(void *status, package_t *pkgs)
|
||||
{
|
||||
FILE *fin, *fout;
|
||||
char *line = NULL;
|
||||
package_t *pkg = 0, *statpkg = 0;
|
||||
package_t locpkg;
|
||||
|
||||
if ((fout = wfopen(new_statusfile, "w")) == NULL) {
|
||||
return 0;
|
||||
}
|
||||
if (getenv(udpkg_quiet) == NULL) {
|
||||
printf("(Updating database...)\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Dont use wfopen here, handle errors ourself
|
||||
*/
|
||||
if ((fin = fopen(statusfile, "r")) != NULL) {
|
||||
while (((line = get_line_from_file(fin)) != NULL) && !feof(fin)) {
|
||||
chomp(line); /* trim newline */
|
||||
/* If we see a package header, find out if it's a package
|
||||
* that we have processed. if so, we skip that block for
|
||||
* now (write it at the end).
|
||||
*
|
||||
* we also look at packages in the status cache and update
|
||||
* their status fields
|
||||
*/
|
||||
if (strstr(line, "Package: ") == line) {
|
||||
for (pkg = pkgs; pkg != 0 && strcmp(line + 9,
|
||||
pkg->package) != 0; pkg = pkg->next) ;
|
||||
|
||||
locpkg.package = line + 9;
|
||||
statpkg = tfind(&locpkg, &status, package_compare);
|
||||
|
||||
/* note: statpkg should be non-zero, unless the status
|
||||
* file was changed while we are processing (no locking
|
||||
* is currently done...
|
||||
*/
|
||||
if (statpkg != 0) {
|
||||
statpkg = *(package_t **)statpkg;
|
||||
}
|
||||
}
|
||||
if (pkg != 0) {
|
||||
continue;
|
||||
}
|
||||
if (strstr(line, "Status: ") == line && statpkg != 0) {
|
||||
snprintf(line, sizeof(line), "Status: %s %s %s",
|
||||
state_words_want[statpkg->state_want - 1],
|
||||
state_words_flag[statpkg->state_flag - 1],
|
||||
state_words_status[statpkg->state_status - 1]);
|
||||
}
|
||||
fprintf(fout, "%s\n", line);
|
||||
}
|
||||
fclose(fin);
|
||||
}
|
||||
free(line);
|
||||
|
||||
// Print out packages we processed.
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
write_package(fout, pkg);
|
||||
}
|
||||
fclose(fout);
|
||||
|
||||
/*
|
||||
* Its ok if renaming statusfile fails becasue it doesnt exist
|
||||
*/
|
||||
if (rename(statusfile, bak_statusfile) == -1) {
|
||||
struct stat stat_buf;
|
||||
if (stat(statusfile, &stat_buf) == 0) {
|
||||
error_msg("Couldnt create backup status file");
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
error_msg("No status file found, creating new one");
|
||||
}
|
||||
|
||||
if (rename(new_statusfile, statusfile) == -1) {
|
||||
error_msg("Couldnt create status file");
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
static int is_file(const char *fn)
|
||||
{
|
||||
struct stat statbuf;
|
||||
|
||||
if (stat(fn, &statbuf) < 0) {
|
||||
return 0;
|
||||
}
|
||||
return S_ISREG(statbuf.st_mode);
|
||||
}
|
||||
|
||||
static int dpkg_doconfigure(package_t *pkg)
|
||||
{
|
||||
int r;
|
||||
char postinst[1024];
|
||||
char buf[1024];
|
||||
|
||||
DPRINTF("Configuring %s\n", pkg->package);
|
||||
pkg->state_status = 0;
|
||||
snprintf(postinst, sizeof(postinst), "%s%s.postinst", infodir, pkg->package);
|
||||
|
||||
if (is_file(postinst)) {
|
||||
snprintf(buf, sizeof(buf), "%s configure", postinst);
|
||||
if ((r = do_system(buf)) != 0) {
|
||||
error_msg("postinst exited with status %d\n", r);
|
||||
pkg->state_status = state_status_halfconfigured;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
pkg->state_status = state_status_installed;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dpkg_dounpack(package_t *pkg)
|
||||
{
|
||||
FILE *out_stream;
|
||||
char *info_prefix;
|
||||
int status = TRUE;
|
||||
int r = 0;
|
||||
|
||||
DPRINTF("Unpacking %s\n", pkg->package);
|
||||
|
||||
/* extract the data file */
|
||||
deb_extract(pkg->filename, stdout, (extract_data_tar_gz | extract_all_to_fs), "/", NULL);
|
||||
|
||||
/* extract the control files */
|
||||
info_prefix = (char *) malloc(strlen(pkg->package) + strlen(infodir) + 2 + 5 + 1);
|
||||
sprintf(info_prefix, "%s/%s.", infodir, pkg->package);
|
||||
deb_extract(pkg->package, stdout, (extract_control_tar_gz | extract_all_to_fs), info_prefix, NULL);
|
||||
|
||||
/* Create the list file */
|
||||
strcat(info_prefix, "list");
|
||||
out_stream = wfopen(info_prefix, "w");
|
||||
deb_extract(pkg->package, out_stream, (extract_data_tar_gz | extract_list), NULL, NULL);
|
||||
fclose(out_stream);
|
||||
|
||||
pkg->state_want = state_want_install;
|
||||
pkg->state_flag = state_flag_ok;
|
||||
|
||||
if (status == TRUE) {
|
||||
pkg->state_status = state_status_unpacked;
|
||||
} else {
|
||||
pkg->state_status = state_status_halfinstalled;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract and parse the control file from control.tar.gz
|
||||
*/
|
||||
static int dpkg_read_control(package_t *pkg)
|
||||
{
|
||||
FILE *pkg_file;
|
||||
char *control_buffer = NULL;
|
||||
|
||||
if ((pkg_file = wfopen(pkg->filename, "r")) == NULL) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
control_buffer = deb_extract(pkg->filename, stdout, (extract_control_tar_gz | extract_one_to_buffer), NULL, "./control");
|
||||
fill_package_struct(pkg, control_buffer);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static int dpkg_unpack(package_t *pkgs, void *status)
|
||||
{
|
||||
int r = 0;
|
||||
package_t *pkg;
|
||||
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
dpkg_read_control(pkg);
|
||||
if ((r = dpkg_dounpack(pkg)) != 0 ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
status_merge(status, pkgs);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int dpkg_configure(package_t *pkgs, void *status)
|
||||
{
|
||||
int r = 0;
|
||||
void *found;
|
||||
package_t *pkg;
|
||||
|
||||
for (pkg = pkgs; pkg != 0 && r == 0; pkg = pkg->next) {
|
||||
found = tfind(pkg, &status, package_compare);
|
||||
|
||||
if (found == 0) {
|
||||
error_msg("Trying to configure %s, but it is not installed", pkg->package);
|
||||
r = 1;
|
||||
}
|
||||
/* configure the package listed in the status file;
|
||||
* not pkg, as we have info only for the latter
|
||||
*/
|
||||
else {
|
||||
r = dpkg_doconfigure(*(package_t **)found);
|
||||
}
|
||||
}
|
||||
status_merge(status, 0);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static int dpkg_install(package_t *pkgs, void *status)
|
||||
{
|
||||
package_t *p, *ordered = 0;
|
||||
|
||||
/* Stage 1: parse all the control information */
|
||||
for (p = pkgs; p != 0; p = p->next) {
|
||||
dpkg_read_control(p);
|
||||
}
|
||||
|
||||
/* Stage 2: resolve dependencies */
|
||||
#ifdef DODEPENDS
|
||||
ordered = depends_resolve(pkgs, status);
|
||||
#else
|
||||
ordered = pkgs;
|
||||
#endif
|
||||
|
||||
/* Stage 3: install */
|
||||
for (p = ordered; p != 0; p = p->next) {
|
||||
p->state_want = state_want_install;
|
||||
|
||||
/* for now the flag is always set to ok... this is probably
|
||||
* not what we want
|
||||
*/
|
||||
p->state_flag = state_flag_ok;
|
||||
|
||||
DPRINTF("Installing %s\n", p->package);
|
||||
if (dpkg_dounpack(p) != 0) {
|
||||
perror_msg(p->filename);
|
||||
}
|
||||
|
||||
if (dpkg_doconfigure(p) != 0) {
|
||||
perror_msg(p->filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (ordered != 0) {
|
||||
status_merge(status, pkgs);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Not implemented yet
|
||||
*
|
||||
static int dpkg_remove(package_t *pkgs, void *status)
|
||||
{
|
||||
package_t *p;
|
||||
|
||||
for (p = pkgs; p != 0; p = p->next)
|
||||
{
|
||||
}
|
||||
status_merge(status, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
extern int dpkg_main(int argc, char **argv)
|
||||
{
|
||||
const int arg_install = 1;
|
||||
const int arg_unpack = 2;
|
||||
const int arg_configure = 4;
|
||||
|
||||
package_t *p, *packages = NULL;
|
||||
void *status = NULL;
|
||||
int opt = 0;
|
||||
int optflag = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "iruc")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i':
|
||||
optflag |= arg_install;
|
||||
break;
|
||||
case 'u':
|
||||
optflag |= arg_unpack;
|
||||
break;
|
||||
case 'c':
|
||||
optflag |= arg_configure;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
while (optind < argc) {
|
||||
p = (package_t *) xcalloc(1, sizeof(package_t));
|
||||
if (optflag & arg_configure) {
|
||||
p->package = xstrdup(argv[optind]);
|
||||
} else {
|
||||
p->filename = xstrdup(argv[optind]);
|
||||
}
|
||||
p->next = packages;
|
||||
packages = p;
|
||||
|
||||
optind++;
|
||||
}
|
||||
|
||||
make_directory((char *)infodir, S_IRWXU, FILEUTILS_RECUR);
|
||||
|
||||
status = status_read();
|
||||
|
||||
if (optflag & arg_install) {
|
||||
return dpkg_install(packages, status);
|
||||
}
|
||||
else if (optflag & arg_unpack) {
|
||||
return dpkg_unpack(packages, status);
|
||||
}
|
||||
else if (optflag & arg_configure) {
|
||||
return dpkg_configure(packages, status);
|
||||
}
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int dpkg_deb_main(int argc, char **argv)
|
||||
{
|
||||
char *prefix = NULL;
|
||||
char *filename = NULL;
|
||||
char *output_buffer = NULL;
|
||||
int opt = 0;
|
||||
int arg_type = 0;
|
||||
int deb_extract_funct = extract_create_leading_dirs | extract_unconditional;
|
||||
|
||||
const int arg_type_prefix = 1;
|
||||
const int arg_type_field = 2;
|
||||
const int arg_type_filename = 4;
|
||||
// const int arg_type_un_ar_gz = 8;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ceftXxI")) != -1) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
deb_extract_funct |= extract_data_tar_gz;
|
||||
deb_extract_funct |= extract_verbose_list;
|
||||
break;
|
||||
case 'e':
|
||||
arg_type = arg_type_prefix;
|
||||
deb_extract_funct |= extract_control_tar_gz;
|
||||
deb_extract_funct |= extract_all_to_fs;
|
||||
break;
|
||||
case 'f':
|
||||
arg_type = arg_type_field;
|
||||
deb_extract_funct |= extract_control_tar_gz;
|
||||
deb_extract_funct |= extract_one_to_buffer;
|
||||
filename = xstrdup("./control");
|
||||
break;
|
||||
case 't': /* --fsys-tarfile, i just made up this short name */
|
||||
/* Integrate the functionality needed with some code from ar.c */
|
||||
error_msg_and_die("Option disabled");
|
||||
// arg_type = arg_type_un_ar_gz;
|
||||
break;
|
||||
case 'X':
|
||||
arg_type = arg_type_prefix;
|
||||
deb_extract_funct |= extract_data_tar_gz;
|
||||
deb_extract_funct |= extract_all_to_fs;
|
||||
deb_extract_funct |= extract_list;
|
||||
case 'x':
|
||||
arg_type = arg_type_prefix;
|
||||
deb_extract_funct |= extract_data_tar_gz;
|
||||
deb_extract_funct |= extract_all_to_fs;
|
||||
break;
|
||||
case 'I':
|
||||
arg_type = arg_type_filename;
|
||||
deb_extract_funct |= extract_control_tar_gz;
|
||||
deb_extract_funct |= extract_one_to_buffer;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (optind == argc) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
/* Workout where to extract the files */
|
||||
if (arg_type == arg_type_prefix) {
|
||||
/* argument is a dir name */
|
||||
if ((optind + 1) == argc ) {
|
||||
prefix = xstrdup("./DEBIAN/");
|
||||
} else {
|
||||
prefix = (char *) xmalloc(strlen(argv[optind + 1]) + 2);
|
||||
strcpy(prefix, argv[optind + 1]);
|
||||
/* Make sure the directory has a trailing '/' */
|
||||
if (last_char_is(prefix, '/') == NULL) {
|
||||
strcat(prefix, "/");
|
||||
}
|
||||
}
|
||||
mkdir(prefix, 0777);
|
||||
}
|
||||
|
||||
if (arg_type == arg_type_filename) {
|
||||
if ((optind + 1) != argc) {
|
||||
filename = xstrdup(argv[optind + 1]);
|
||||
} else {
|
||||
error_msg_and_die("-I currently requires a filename to be specified");
|
||||
}
|
||||
}
|
||||
|
||||
output_buffer = deb_extract(argv[optind], stdout, deb_extract_funct, prefix, filename);
|
||||
|
||||
if ((arg_type == arg_type_filename) && (output_buffer != NULL)) {
|
||||
puts(output_buffer);
|
||||
}
|
||||
else if (arg_type == arg_type_field) {
|
||||
char *field = NULL;
|
||||
int field_start = 0;
|
||||
|
||||
while ((field = read_package_field(&output_buffer[field_start])) != NULL) {
|
||||
field_start += (strlen(field) + 1);
|
||||
if (strstr(field, argv[optind + 1]) == field) {
|
||||
puts(field + strlen(argv[optind + 1]) + 2);
|
||||
}
|
||||
free(field);
|
||||
}
|
||||
}
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
+91
-1271
File diff suppressed because it is too large.
Load diff
+312
-1160
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,92 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini rpm2cpio implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2001 by Laurence Anderson
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <netinet/in.h> /* For ntohl & htonl function */
|
||||
#include <string.h>
|
||||
|
||||
#define RPM_MAGIC "\355\253\356\333"
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
|
||||
struct rpm_lead {
|
||||
unsigned char magic[4];
|
||||
u8 major, minor;
|
||||
u16 type;
|
||||
u16 archnum;
|
||||
char name[66];
|
||||
u16 osnum;
|
||||
u16 signature_type;
|
||||
char reserved[16];
|
||||
};
|
||||
|
||||
struct rpm_header {
|
||||
char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */
|
||||
u8 version; /* 1 byte version number */
|
||||
u32 reserved; /* 4 bytes reserved */
|
||||
u32 entries; /* Number of entries in header (4 bytes) */
|
||||
u32 size; /* Size of store (4 bytes) */
|
||||
};
|
||||
|
||||
void skip_header(FILE *rpmfile)
|
||||
{
|
||||
struct rpm_header header;
|
||||
|
||||
fread(&header, sizeof(struct rpm_header), 1, rpmfile);
|
||||
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) error_msg_and_die("Invalid RPM header magic"); /* Invalid magic */
|
||||
if (header.version != 1) error_msg_and_die("Unsupported RPM header version"); /* This program only supports v1 headers */
|
||||
header.entries = ntohl(header.entries);
|
||||
header.size = ntohl(header.size);
|
||||
fseek (rpmfile, 16 * header.entries, SEEK_CUR); /* Seek past index entries */
|
||||
fseek (rpmfile, header.size, SEEK_CUR); /* Seek past store */
|
||||
}
|
||||
|
||||
/* No getopt required */
|
||||
extern int rpm2cpio_main(int argc, char **argv)
|
||||
{
|
||||
struct rpm_lead lead;
|
||||
int gunzip_pid;
|
||||
FILE *rpmfile, *cpiofile;
|
||||
|
||||
if (argc == 1) {
|
||||
rpmfile = stdin;
|
||||
} else {
|
||||
rpmfile = fopen(argv[1], "r");
|
||||
if (!rpmfile) perror_msg_and_die("Can't open rpm file");
|
||||
}
|
||||
|
||||
fread (&lead, sizeof(struct rpm_lead), 1, rpmfile);
|
||||
if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */
|
||||
/* Skip the signature header */
|
||||
skip_header(rpmfile);
|
||||
fseek(rpmfile, (8 - (ftell(rpmfile) % 8)) % 8, SEEK_CUR); /* Pad to 8 byte boundary */
|
||||
/* Skip the main header */
|
||||
skip_header(rpmfile);
|
||||
|
||||
cpiofile = gz_open(rpmfile, &gunzip_pid);
|
||||
copyfd(fileno(cpiofile), fileno(stdout));
|
||||
gz_close(gunzip_pid);
|
||||
fclose(rpmfile);
|
||||
return 0;
|
||||
}
|
||||
+250
-319
@@ -4,9 +4,9 @@
|
||||
*
|
||||
* Note, that as of BusyBox-0.43, tar has been completely rewritten from the
|
||||
* ground up. It still has remnents of the old code lying about, but it is
|
||||
* very different now (i.e. cleaner, less global variables, etc)
|
||||
* very different now (i.e., cleaner, less global variables, etc.)
|
||||
*
|
||||
* Copyright (C) 2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* Based in part in the tar implementation in sash
|
||||
@@ -36,11 +36,6 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_io_error
|
||||
#define bb_need_name_longer_than_foo
|
||||
#include "messages.c"
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
@@ -51,11 +46,11 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
extern int unzip(int in, int out);
|
||||
extern int gunzip_init();
|
||||
#endif
|
||||
#include <fnmatch.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Tar file constants */
|
||||
#ifndef MAJOR
|
||||
@@ -63,7 +58,7 @@ extern int gunzip_init();
|
||||
#define MINOR(dev) ((dev)&0xff)
|
||||
#endif
|
||||
|
||||
#define NAME_SIZE 100
|
||||
enum { NAME_SIZE = 100 }; /* because gcc won't let me use 'static const int' */
|
||||
|
||||
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
|
||||
struct TarHeader
|
||||
@@ -93,9 +88,9 @@ typedef struct TarHeader TarHeader;
|
||||
/* A few useful constants */
|
||||
#define TAR_MAGIC "ustar" /* ustar and a null */
|
||||
#define TAR_VERSION " " /* Be compatable with GNU tar format */
|
||||
#define TAR_MAGIC_LEN 6
|
||||
#define TAR_VERSION_LEN 2
|
||||
#define TAR_BLOCK_SIZE 512
|
||||
static const int TAR_MAGIC_LEN = 6;
|
||||
static const int TAR_VERSION_LEN = 2;
|
||||
static const int TAR_BLOCK_SIZE = 512;
|
||||
|
||||
/* A nice enum with all the possible tar file content types */
|
||||
enum TarFileType
|
||||
@@ -126,7 +121,7 @@ struct TarInfo
|
||||
gid_t gid; /* Numeric GID */
|
||||
size_t size; /* Size of file */
|
||||
time_t mtime; /* Last-modified time */
|
||||
enum TarFileType type; /* Regular, directory, link, etc */
|
||||
enum TarFileType type; /* Regular, directory, link, etc. */
|
||||
char * linkname; /* Name for symbolic and hard links */
|
||||
long devmajor; /* Major number for special device */
|
||||
long devminor; /* Minor number for special device */
|
||||
@@ -144,38 +139,11 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
|
||||
char** excludeList);
|
||||
#endif
|
||||
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
/* Signal handler for when child gzip process dies... */
|
||||
void child_died()
|
||||
{
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static int tar_unzip_init(int tarFd)
|
||||
{
|
||||
int child_pid;
|
||||
static int unzip_pipe[2];
|
||||
/* Cope if child dies... Otherwise we block forever in read()... */
|
||||
signal(SIGCHLD, child_died);
|
||||
|
||||
if (pipe(unzip_pipe)!=0)
|
||||
error_msg_and_die("pipe error\n");
|
||||
|
||||
if ( (child_pid = fork()) == -1)
|
||||
error_msg_and_die("fork failure\n");
|
||||
|
||||
if (child_pid==0) {
|
||||
/* child process */
|
||||
gunzip_init();
|
||||
unzip(tarFd, unzip_pipe[1]);
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
else
|
||||
/* return fd of uncompressed data to parent process */
|
||||
return(unzip_pipe[0]);
|
||||
}
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
static struct option longopts[] = {
|
||||
{ "exclude", 1, NULL, 'e' },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
extern int tar_main(int argc, char **argv)
|
||||
@@ -183,13 +151,14 @@ extern int tar_main(int argc, char **argv)
|
||||
char** excludeList=NULL;
|
||||
char** extractList=NULL;
|
||||
const char *tarName="-";
|
||||
const char *cwd=NULL;
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
int excludeListSize=0;
|
||||
char *excludeFileName ="-";
|
||||
FILE *fileList;
|
||||
char file[256];
|
||||
#endif
|
||||
#if defined BB_FEATURE_TAR_GZIP
|
||||
FILE *comp_file = NULL;
|
||||
int unzipFlag = FALSE;
|
||||
#endif
|
||||
int listFlag = FALSE;
|
||||
@@ -198,150 +167,155 @@ extern int tar_main(int argc, char **argv)
|
||||
int verboseFlag = FALSE;
|
||||
int tostdoutFlag = FALSE;
|
||||
int status = FALSE;
|
||||
int firstOpt = TRUE;
|
||||
int stopIt;
|
||||
int opt;
|
||||
pid_t pid;
|
||||
|
||||
if (argc <= 1)
|
||||
usage(tar_usage);
|
||||
show_usage();
|
||||
|
||||
while (*(++argv) && (**argv == '-' || firstOpt == TRUE)) {
|
||||
firstOpt=FALSE;
|
||||
stopIt=FALSE;
|
||||
while (stopIt==FALSE && **argv) {
|
||||
switch (*((*argv)++)) {
|
||||
case 'c':
|
||||
if (extractFlag == TRUE || listFlag == TRUE)
|
||||
goto flagError;
|
||||
createFlag = TRUE;
|
||||
break;
|
||||
case 'x':
|
||||
if (listFlag == TRUE || createFlag == TRUE)
|
||||
goto flagError;
|
||||
extractFlag = TRUE;
|
||||
break;
|
||||
case 't':
|
||||
if (extractFlag == TRUE || createFlag == TRUE)
|
||||
goto flagError;
|
||||
listFlag = TRUE;
|
||||
break;
|
||||
if (argv[1][0] != '-') {
|
||||
char *tmp = xmalloc(strlen(argv[1]) + 2);
|
||||
tmp[0] = '-';
|
||||
strcpy(tmp + 1, argv[1]);
|
||||
argv[1] = tmp;
|
||||
}
|
||||
|
||||
while (
|
||||
#ifndef BB_FEATURE_TAR_EXCLUDE
|
||||
(opt = getopt(argc, argv, "cxtzvOf:pC:"))
|
||||
#else
|
||||
(opt = getopt_long(argc, argv, "cxtzvOf:X:pC:", longopts, NULL))
|
||||
#endif
|
||||
> 0) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
if (extractFlag == TRUE || listFlag == TRUE)
|
||||
goto flagError;
|
||||
createFlag = TRUE;
|
||||
break;
|
||||
case 'x':
|
||||
if (listFlag == TRUE || createFlag == TRUE)
|
||||
goto flagError;
|
||||
extractFlag = TRUE;
|
||||
break;
|
||||
case 't':
|
||||
if (extractFlag == TRUE || createFlag == TRUE)
|
||||
goto flagError;
|
||||
listFlag = TRUE;
|
||||
break;
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
case 'z':
|
||||
unzipFlag = TRUE;
|
||||
break;
|
||||
case 'z':
|
||||
unzipFlag = TRUE;
|
||||
break;
|
||||
#endif
|
||||
case 'v':
|
||||
verboseFlag = TRUE;
|
||||
break;
|
||||
case 'O':
|
||||
tostdoutFlag = TRUE;
|
||||
break;
|
||||
case 'f':
|
||||
if (*tarName != '-')
|
||||
error_msg_and_die( "Only one 'f' option allowed\n");
|
||||
tarName = *(++argv);
|
||||
if (tarName == NULL)
|
||||
error_msg_and_die( "Option requires an argument: No file specified\n");
|
||||
stopIt=TRUE;
|
||||
break;
|
||||
case 'v':
|
||||
verboseFlag = TRUE;
|
||||
break;
|
||||
case 'O':
|
||||
tostdoutFlag = TRUE;
|
||||
break;
|
||||
case 'f':
|
||||
if (*tarName != '-')
|
||||
error_msg_and_die( "Only one 'f' option allowed");
|
||||
tarName = optarg;
|
||||
break;
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
case 'e':
|
||||
if (strcmp(*argv, "xclude")==0) {
|
||||
excludeList=xrealloc( excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
excludeList[excludeListSize] = *(++argv);
|
||||
if (excludeList[excludeListSize] == NULL)
|
||||
error_msg_and_die( "Option requires an argument: No file specified\n");
|
||||
/* Remove leading "/"s */
|
||||
if (*excludeList[excludeListSize] =='/')
|
||||
excludeList[excludeListSize] = (excludeList[excludeListSize])+1;
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
stopIt=TRUE;
|
||||
break;
|
||||
}
|
||||
case 'X':
|
||||
if (*excludeFileName != '-')
|
||||
error_msg_and_die("Only one 'X' option allowed\n");
|
||||
excludeFileName = *(++argv);
|
||||
if (excludeFileName == NULL)
|
||||
error_msg_and_die("Option requires an argument: No file specified\n");
|
||||
fileList = fopen (excludeFileName, "r");
|
||||
if (! fileList)
|
||||
error_msg_and_die("Exclude file: file not found\n");
|
||||
while (fgets(file, sizeof(file), fileList) != NULL) {
|
||||
excludeList = xrealloc(excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
if (file[strlen(file)-1] == '\n')
|
||||
file[strlen(file)-1] = '\0';
|
||||
excludeList[excludeListSize] = xstrdup(file);
|
||||
/* Remove leading "/"s */
|
||||
while (*excludeList[excludeListSize] == '/')
|
||||
excludeList[excludeListSize]++;
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
}
|
||||
fclose(fileList);
|
||||
stopIt=TRUE;
|
||||
break;
|
||||
case 'e':
|
||||
excludeList=xrealloc( excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
excludeList[excludeListSize] = optarg;
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
case 'X':
|
||||
fileList = xfopen(optarg, "r");
|
||||
while (fgets(file, sizeof(file), fileList) != NULL) {
|
||||
excludeList = xrealloc(excludeList,
|
||||
sizeof(char *) * (excludeListSize+2));
|
||||
chomp(file);
|
||||
excludeList[excludeListSize] = xstrdup(file);
|
||||
/* Tack a NULL onto the end of the list */
|
||||
excludeList[++excludeListSize] = NULL;
|
||||
}
|
||||
fclose(fileList);
|
||||
break;
|
||||
#endif
|
||||
case '-':
|
||||
break;
|
||||
default:
|
||||
usage(tar_usage);
|
||||
}
|
||||
case 'p':
|
||||
break;
|
||||
case 'C':
|
||||
cwd = xgetcwd((char *)cwd);
|
||||
if (chdir(optarg)) {
|
||||
printf("cd: %s: %s\n", optarg, strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Do the correct type of action supplying the rest of the
|
||||
* command line arguments as the list of files to process.
|
||||
*/
|
||||
if (createFlag == TRUE) {
|
||||
#ifndef BB_FEATURE_TAR_CREATE
|
||||
error_msg_and_die( "This version of tar was not compiled with tar creation support.\n");
|
||||
error_msg_and_die( "This version of tar was not compiled with tar creation support.");
|
||||
#else
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
if (unzipFlag==TRUE)
|
||||
error_msg_and_die("Creation of compressed not internally support by tar, pipe to busybox gunzip\n");
|
||||
error_msg_and_die("Creation of compressed not internally support by tar, pipe to busybox gunzip");
|
||||
#endif
|
||||
status = writeTarFile(tarName, verboseFlag, argv, excludeList);
|
||||
status = writeTarFile(tarName, verboseFlag, argv + optind, excludeList);
|
||||
#endif
|
||||
}
|
||||
if (listFlag == TRUE || extractFlag == TRUE) {
|
||||
int tarFd;
|
||||
if (*argv)
|
||||
extractList = argv;
|
||||
if (argv[optind])
|
||||
extractList = argv + optind;
|
||||
/* Open the tar file for reading. */
|
||||
if (!strcmp(tarName, "-"))
|
||||
tarFd = fileno(stdin);
|
||||
else
|
||||
tarFd = open(tarName, O_RDONLY);
|
||||
if (tarFd < 0)
|
||||
error_msg_and_die( "Error opening '%s': %s\n", tarName, strerror(errno));
|
||||
perror_msg_and_die("Error opening '%s'", tarName);
|
||||
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
/* unzip tarFd in a seperate process */
|
||||
if (unzipFlag == TRUE)
|
||||
tarFd = tar_unzip_init(tarFd);
|
||||
if (unzipFlag == TRUE) {
|
||||
comp_file = fdopen(tarFd, "r");
|
||||
if ((tarFd = fileno(gz_open(comp_file, &pid))) == EXIT_FAILURE) {
|
||||
error_msg_and_die("Couldnt unzip file");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
status = readTarFile(tarFd, extractFlag, listFlag, tostdoutFlag,
|
||||
verboseFlag, extractList, excludeList);
|
||||
close(tarFd);
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
if (unzipFlag == TRUE) {
|
||||
gz_close(pid);
|
||||
fclose(comp_file);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (cwd)
|
||||
chdir(cwd);
|
||||
if (status == TRUE)
|
||||
return EXIT_SUCCESS;
|
||||
else
|
||||
return EXIT_FAILURE;
|
||||
|
||||
flagError:
|
||||
error_msg_and_die( "Exactly one of 'c', 'x' or 't' must be specified\n");
|
||||
error_msg_and_die( "Exactly one of 'c', 'x' or 't' must be specified");
|
||||
}
|
||||
|
||||
static void
|
||||
fixUpPermissions(TarInfo *header)
|
||||
{
|
||||
struct utimbuf t;
|
||||
/* Now set permissions etc for the new file */
|
||||
/* Now set permissions etc. for the new file */
|
||||
chown(header->name, header->uid, header->gid);
|
||||
chmod(header->name, header->mode);
|
||||
/* Reset the time */
|
||||
@@ -364,7 +338,9 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
if (extractFlag==TRUE && tostdoutFlag==FALSE) {
|
||||
/* Create the path to the file, just in case it isn't there...
|
||||
* This should not screw up path permissions or anything. */
|
||||
create_path(header->name, 0777);
|
||||
char *dir = dirname (header->name);
|
||||
make_directory (dir, -1, FILEUTILS_RECUR);
|
||||
free (dir);
|
||||
if ((outFd=open(header->name, O_CREAT|O_TRUNC|O_WRONLY,
|
||||
header->mode & ~S_IFMT)) < 0) {
|
||||
error_msg(io_error, header->name, strerror(errno));
|
||||
@@ -387,7 +363,7 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
}
|
||||
if ( (readSize = full_read(header->tarFd, buffer, readSize)) <= 0 ) {
|
||||
/* Tarball seems to have a problem */
|
||||
error_msg("Unexpected EOF in archive\n");
|
||||
error_msg("Unexpected EOF in archive");
|
||||
return( FALSE);
|
||||
}
|
||||
if ( readSize < writeSize )
|
||||
@@ -420,21 +396,13 @@ tarExtractRegularFile(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
static int
|
||||
tarExtractDirectory(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
{
|
||||
|
||||
if (extractFlag==FALSE || tostdoutFlag==TRUE)
|
||||
return( TRUE);
|
||||
|
||||
if (create_path(header->name, header->mode) != TRUE) {
|
||||
error_msg("%s: Cannot mkdir: %s\n",
|
||||
header->name, strerror(errno));
|
||||
if (make_directory(header->name, header->mode, FILEUTILS_RECUR) < 0)
|
||||
return( FALSE);
|
||||
}
|
||||
/* make the final component, just in case it was
|
||||
* omitted by create_path() (which will skip the
|
||||
* directory if it doesn't have a terminating '/') */
|
||||
if (mkdir(header->name, header->mode) == 0) {
|
||||
fixUpPermissions(header);
|
||||
}
|
||||
|
||||
fixUpPermissions(header);
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
@@ -445,12 +413,12 @@ tarExtractHardLink(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
return( TRUE);
|
||||
|
||||
if (link(header->linkname, header->name) < 0) {
|
||||
error_msg("%s: Cannot create hard link to '%s': %s\n",
|
||||
header->name, header->linkname, strerror(errno));
|
||||
perror_msg("%s: Cannot create hard link to '%s'", header->name,
|
||||
header->linkname);
|
||||
return( FALSE);
|
||||
}
|
||||
|
||||
/* Now set permissions etc for the new directory */
|
||||
/* Now set permissions etc. for the new directory */
|
||||
fixUpPermissions(header);
|
||||
return( TRUE);
|
||||
}
|
||||
@@ -463,8 +431,8 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
|
||||
#ifdef S_ISLNK
|
||||
if (symlink(header->linkname, header->name) < 0) {
|
||||
error_msg("%s: Cannot create symlink to '%s': %s\n",
|
||||
header->name, header->linkname, strerror(errno));
|
||||
perror_msg("%s: Cannot create symlink to '%s'", header->name,
|
||||
header->linkname);
|
||||
return( FALSE);
|
||||
}
|
||||
/* Try to change ownership of the symlink.
|
||||
@@ -478,7 +446,7 @@ tarExtractSymLink(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
/* Do not change permissions or date on symlink,
|
||||
* since it changes the pointed to file instead. duh. */
|
||||
#else
|
||||
error_msg("%s: Cannot create symlink to '%s': %s\n",
|
||||
error_msg("%s: Cannot create symlink to '%s': %s",
|
||||
header->name, header->linkname,
|
||||
"symlinks not supported");
|
||||
#endif
|
||||
@@ -493,43 +461,21 @@ tarExtractSpecial(TarInfo *header, int extractFlag, int tostdoutFlag)
|
||||
|
||||
if (S_ISCHR(header->mode) || S_ISBLK(header->mode) || S_ISSOCK(header->mode)) {
|
||||
if (mknod(header->name, header->mode, makedev(header->devmajor, header->devminor)) < 0) {
|
||||
error_msg("%s: Cannot mknod: %s\n",
|
||||
header->name, strerror(errno));
|
||||
perror_msg("%s: Cannot mknod", header->name);
|
||||
return( FALSE);
|
||||
}
|
||||
} else if (S_ISFIFO(header->mode)) {
|
||||
if (mkfifo(header->name, header->mode) < 0) {
|
||||
error_msg("%s: Cannot mkfifo: %s\n",
|
||||
header->name, strerror(errno));
|
||||
perror_msg("%s: Cannot mkfifo", header->name);
|
||||
return( FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now set permissions etc for the new directory */
|
||||
/* Now set permissions etc. for the new directory */
|
||||
fixUpPermissions(header);
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
/* Read an octal value in a field of the specified width, with optional
|
||||
* spaces on both sides of the number and with an optional null character
|
||||
* at the end. Returns -1 on an illegal format. */
|
||||
static long getOctal(const char *cp, int size)
|
||||
{
|
||||
long val = 0;
|
||||
|
||||
for(;(size > 0) && (*cp == ' '); cp++, size--);
|
||||
if ((size == 0) || !is_octal(*cp))
|
||||
return -1;
|
||||
for(; (size > 0) && is_octal(*cp); size--) {
|
||||
val = val * 8 + *cp++ - '0';
|
||||
}
|
||||
for (;(size > 0) && (*cp == ' '); cp++, size--);
|
||||
if ((size > 0) && *cp)
|
||||
return -1;
|
||||
return val;
|
||||
}
|
||||
|
||||
|
||||
/* Parse the tar header and fill in the nice struct with the details */
|
||||
static int
|
||||
readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
|
||||
@@ -544,24 +490,24 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
|
||||
static int alreadyWarned=FALSE;
|
||||
|
||||
while (*(header->name) == '/')
|
||||
++*(header->name);
|
||||
header->name++;
|
||||
|
||||
if (alreadyWarned == FALSE) {
|
||||
error_msg("Removing leading '/' from member names\n");
|
||||
error_msg("Removing leading '/' from member names");
|
||||
alreadyWarned = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
header->mode = getOctal(rawHeader->mode, sizeof(rawHeader->mode));
|
||||
header->uid = getOctal(rawHeader->uid, sizeof(rawHeader->uid));
|
||||
header->gid = getOctal(rawHeader->gid, sizeof(rawHeader->gid));
|
||||
header->size = getOctal(rawHeader->size, sizeof(rawHeader->size));
|
||||
header->mtime = getOctal(rawHeader->mtime, sizeof(rawHeader->mtime));
|
||||
chksum = getOctal(rawHeader->chksum, sizeof(rawHeader->chksum));
|
||||
header->mode = strtol(rawHeader->mode, NULL, 8);
|
||||
header->uid = strtol(rawHeader->uid, NULL, 8);
|
||||
header->gid = strtol(rawHeader->gid, NULL, 8);
|
||||
header->size = strtol(rawHeader->size, NULL, 8);
|
||||
header->mtime = strtol(rawHeader->mtime, NULL, 8);
|
||||
chksum = strtol(rawHeader->chksum, NULL, 8);
|
||||
header->type = rawHeader->typeflag;
|
||||
header->linkname = rawHeader->linkname;
|
||||
header->devmajor = getOctal(rawHeader->devmajor, sizeof(rawHeader->devmajor));
|
||||
header->devminor = getOctal(rawHeader->devminor, sizeof(rawHeader->devminor));
|
||||
header->devmajor = strtol(rawHeader->devmajor, NULL, 8);
|
||||
header->devminor = strtol(rawHeader->devminor, NULL, 8);
|
||||
|
||||
/* Check the checksum */
|
||||
for (i = sizeof(*rawHeader); i-- != 0;) {
|
||||
@@ -579,12 +525,53 @@ readTarHeader(struct TarHeader *rawHeader, struct TarInfo *header)
|
||||
return( FALSE);
|
||||
}
|
||||
|
||||
static int exclude_file(char **excluded_files, const char *file)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (excluded_files == NULL)
|
||||
return 0;
|
||||
|
||||
for (i = 0; excluded_files[i] != NULL; i++) {
|
||||
if (excluded_files[i][0] == '/') {
|
||||
if (fnmatch(excluded_files[i], file,
|
||||
FNM_PATHNAME | FNM_LEADING_DIR) == 0)
|
||||
return 1;
|
||||
} else {
|
||||
const char *p;
|
||||
|
||||
for (p = file; p[0] != '\0'; p++) {
|
||||
if ((p == file || p[-1] == '/') && p[0] != '/' &&
|
||||
fnmatch(excluded_files[i], p,
|
||||
FNM_PATHNAME | FNM_LEADING_DIR) == 0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int extract_file(char **extract_files, const char *file)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (extract_files == NULL)
|
||||
return 1;
|
||||
|
||||
for (i = 0; extract_files[i] != NULL; i++) {
|
||||
if (fnmatch(extract_files[i], file, FNM_LEADING_DIR) == 0)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a tar file and extract or list the specified files within it.
|
||||
* If the list is empty than all files are extracted or listed.
|
||||
*/
|
||||
extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
static int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
int tostdoutFlag, int verboseFlag, char** extractList,
|
||||
char** excludeList)
|
||||
{
|
||||
@@ -593,11 +580,6 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
int skipNextHeaderFlag=FALSE;
|
||||
TarHeader rawHeader;
|
||||
TarInfo header;
|
||||
char** tmpList;
|
||||
|
||||
/* Set the umask for this process so it doesn't
|
||||
* screw up permission setting for us later. */
|
||||
umask(0);
|
||||
|
||||
/* Read the tar file, and iterate over it one file at a time */
|
||||
while ( (status = full_read(tarFd, (char*)&rawHeader, TAR_BLOCK_SIZE)) == TAR_BLOCK_SIZE ) {
|
||||
@@ -608,12 +590,12 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
goto endgame;
|
||||
} else {
|
||||
errorFlag=TRUE;
|
||||
error_msg("Bad tar header, skipping\n");
|
||||
error_msg("Bad tar header, skipping");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ( *(header.name) == '\0' )
|
||||
goto endgame;
|
||||
continue;
|
||||
header.tarFd = tarFd;
|
||||
|
||||
/* Skip funky extra GNU headers that precede long files */
|
||||
@@ -632,56 +614,29 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
}
|
||||
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
{
|
||||
int skipFlag=FALSE;
|
||||
/* Check for excluded files.... */
|
||||
for (tmpList=excludeList; tmpList && *tmpList; tmpList++) {
|
||||
/* Do some extra hoop jumping for when directory names
|
||||
* end in '/' but the entry in tmpList doesn't */
|
||||
if (strncmp( *tmpList, header.name, strlen(*tmpList))==0 || (
|
||||
header.name[strlen(header.name)-1]=='/'
|
||||
&& strncmp( *tmpList, header.name,
|
||||
MIN(strlen(header.name)-1, strlen(*tmpList)))==0)) {
|
||||
/* If it is a regular file, pretend to extract it with
|
||||
* the extractFlag set to FALSE, so the junk in the tarball
|
||||
* is properly skipped over */
|
||||
if ( header.type==REGTYPE || header.type==REGTYPE0 ) {
|
||||
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
skipFlag=TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (exclude_file(excludeList, header.name)) {
|
||||
/* There are not the droids you're looking for, move along */
|
||||
if (skipFlag==TRUE)
|
||||
continue;
|
||||
/* If it is a regular file, pretend to extract it with
|
||||
* the extractFlag set to FALSE, so the junk in the tarball
|
||||
* is properly skipped over */
|
||||
if ( header.type==REGTYPE || header.type==REGTYPE0 ) {
|
||||
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (extractList != NULL) {
|
||||
int skipFlag = TRUE;
|
||||
for (tmpList = extractList; *tmpList != NULL; tmpList++) {
|
||||
if (strncmp( *tmpList, header.name, strlen(*tmpList))==0 || (
|
||||
header.name[strlen(header.name)-1]=='/'
|
||||
&& strncmp( *tmpList, header.name,
|
||||
MIN(strlen(header.name)-1, strlen(*tmpList)))==0)) {
|
||||
/* If it is a regular file, pretend to extract it with
|
||||
* the extractFlag set to FALSE, so the junk in the tarball
|
||||
* is properly skipped over */
|
||||
skipFlag = FALSE;
|
||||
memmove(extractList+1, extractList,
|
||||
sizeof(*extractList)*(tmpList-extractList));
|
||||
extractList++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!extract_file(extractList, header.name)) {
|
||||
/* There are not the droids you're looking for, move along */
|
||||
if (skipFlag == TRUE) {
|
||||
if ( header.type==REGTYPE || header.type==REGTYPE0 )
|
||||
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
|
||||
errorFlag = TRUE;
|
||||
continue;
|
||||
/* If it is a regular file, pretend to extract it with
|
||||
* the extractFlag set to FALSE, so the junk in the tarball
|
||||
* is properly skipped over */
|
||||
if ( header.type==REGTYPE || header.type==REGTYPE0 ) {
|
||||
if (tarExtractRegularFile(&header, FALSE, FALSE) == FALSE)
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (listFlag == TRUE) {
|
||||
@@ -751,7 +706,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
case REGTYPE0:
|
||||
/* If the name ends in a '/' then assume it is
|
||||
* supposed to be a directory, and fall through */
|
||||
if (header.name[strlen(header.name)-1] != '/') {
|
||||
if (!last_char_is(header.name,'/')) {
|
||||
if (tarExtractRegularFile(&header, extractFlag, tostdoutFlag)==FALSE)
|
||||
errorFlag=TRUE;
|
||||
break;
|
||||
@@ -782,7 +737,7 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
error_msg("Unknown file type '%c' in tar file\n", header.type);
|
||||
error_msg("Unknown file type '%c' in tar file", header.type);
|
||||
close( tarFd);
|
||||
return( FALSE);
|
||||
}
|
||||
@@ -790,11 +745,11 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
close(tarFd);
|
||||
if (status > 0) {
|
||||
/* Bummer - we read a partial header */
|
||||
error_msg( "Error reading tar file: %s\n", strerror(errno));
|
||||
perror_msg("Error reading tar file");
|
||||
return ( FALSE);
|
||||
}
|
||||
else if (errorFlag==TRUE) {
|
||||
error_msg( "Error exit delayed from previous errors\n");
|
||||
error_msg( "Error exit delayed from previous errors");
|
||||
return( FALSE);
|
||||
} else
|
||||
return( status);
|
||||
@@ -802,15 +757,9 @@ extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
/* Stuff to do when we are done */
|
||||
endgame:
|
||||
close( tarFd);
|
||||
if (extractList != NULL) {
|
||||
for (; *extractList != NULL; extractList++) {
|
||||
error_msg("%s: Not found in archive\n", *extractList);
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
}
|
||||
if ( *(header.name) == '\0' ) {
|
||||
if (errorFlag==TRUE)
|
||||
error_msg( "Error exit delayed from previous errors\n");
|
||||
error_msg( "Error exit delayed from previous errors");
|
||||
else
|
||||
return( TRUE);
|
||||
}
|
||||
@@ -939,47 +888,17 @@ static int putOctal (char *cp, int len, long value)
|
||||
|
||||
/* Write out a tar header for the specified file/directory/whatever */
|
||||
static int
|
||||
writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *statbuf)
|
||||
writeTarHeader(struct TarBallInfo *tbInfo, const char *header_name,
|
||||
const char *real_name, struct stat *statbuf)
|
||||
{
|
||||
long chksum=0;
|
||||
struct TarHeader header;
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
char** tmpList;
|
||||
#endif
|
||||
const unsigned char *cp = (const unsigned char *) &header;
|
||||
ssize_t size = sizeof(struct TarHeader);
|
||||
|
||||
memset( &header, 0, size);
|
||||
|
||||
if (*fileName=='/') {
|
||||
static int alreadyWarned=FALSE;
|
||||
if (alreadyWarned==FALSE) {
|
||||
error_msg("Removing leading '/' from member names\n");
|
||||
alreadyWarned=TRUE;
|
||||
}
|
||||
strncpy(header.name, fileName+1, sizeof(header.name));
|
||||
}
|
||||
else {
|
||||
strncpy(header.name, fileName, sizeof(header.name));
|
||||
}
|
||||
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
/* Check for excluded files.... */
|
||||
for (tmpList=tbInfo->excludeList; tmpList && *tmpList; tmpList++) {
|
||||
/* Do some extra hoop jumping for when directory names
|
||||
* end in '/' but the entry in tmpList doesn't */
|
||||
if (strncmp( *tmpList, header.name, strlen(*tmpList))==0 || (
|
||||
header.name[strlen(header.name)-1]=='/'
|
||||
&& strncmp( *tmpList, header.name,
|
||||
MIN(strlen(header.name)-1, strlen(*tmpList)))==0)) {
|
||||
/* Set the mode to something that is not a regular file, thereby
|
||||
* faking out writeTarFile into thinking that nothing further need
|
||||
* be done for this file. Yes, I know this is ugly, but it works. */
|
||||
statbuf->st_mode = 0;
|
||||
return( TRUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
strncpy(header.name, header_name, sizeof(header.name));
|
||||
|
||||
putOctal(header.mode, sizeof(header.mode), statbuf->st_mode);
|
||||
putOctal(header.uid, sizeof(header.uid), statbuf->st_uid);
|
||||
@@ -1002,16 +921,12 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
||||
header.typeflag = LNKTYPE;
|
||||
strncpy(header.linkname, tbInfo->hlInfo->name, sizeof(header.linkname));
|
||||
} else if (S_ISLNK(statbuf->st_mode)) {
|
||||
int link_size=0;
|
||||
char buffer[BUFSIZ];
|
||||
header.typeflag = SYMTYPE;
|
||||
link_size = readlink(fileName, buffer, sizeof(buffer) - 1);
|
||||
if ( link_size < 0) {
|
||||
error_msg("Error reading symlink '%s': %s\n", header.name, strerror(errno));
|
||||
char *lpath = xreadlink(real_name);
|
||||
if (!lpath) /* Already printed err msg inside xreadlink() */
|
||||
return ( FALSE);
|
||||
}
|
||||
buffer[link_size] = '\0';
|
||||
strncpy(header.linkname, buffer, sizeof(header.linkname));
|
||||
header.typeflag = SYMTYPE;
|
||||
strncpy(header.linkname, lpath, sizeof(header.linkname));
|
||||
free(lpath);
|
||||
} else if (S_ISDIR(statbuf->st_mode)) {
|
||||
header.typeflag = DIRTYPE;
|
||||
strncat(header.name, "/", sizeof(header.name));
|
||||
@@ -1029,11 +944,11 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
||||
header.typeflag = REGTYPE;
|
||||
putOctal(header.size, sizeof(header.size), statbuf->st_size);
|
||||
} else {
|
||||
error_msg("%s: Unknown file type\n", fileName);
|
||||
error_msg("%s: Unknown file type", real_name);
|
||||
return ( FALSE);
|
||||
}
|
||||
|
||||
/* Calculate and store the checksum (i.e. the sum of all of the bytes of
|
||||
/* Calculate and store the checksum (i.e., the sum of all of the bytes of
|
||||
* the header). The checksum field must be filled with blanks for the
|
||||
* calculation. The checksum field is formatted differently from the
|
||||
* other fields: it has [6] digits, a null, then a space -- rather than
|
||||
@@ -1046,7 +961,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
||||
|
||||
/* Now write the header out to disk */
|
||||
if ((size=full_write(tbInfo->tarFd, (char*)&header, sizeof(struct TarHeader))) < 0) {
|
||||
error_msg(io_error, fileName, strerror(errno));
|
||||
error_msg(io_error, real_name, strerror(errno));
|
||||
return ( FALSE);
|
||||
}
|
||||
/* Pad the header up to the tar block size */
|
||||
@@ -1068,6 +983,7 @@ writeTarHeader(struct TarBallInfo *tbInfo, const char *fileName, struct stat *st
|
||||
static int writeFileToTarball(const char *fileName, struct stat *statbuf, void* userData)
|
||||
{
|
||||
struct TarBallInfo *tbInfo = (struct TarBallInfo *)userData;
|
||||
const char *header_name;
|
||||
|
||||
/*
|
||||
** Check to see if we are dealing with a hard link.
|
||||
@@ -1087,7 +1003,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
|
||||
|
||||
/* It is against the rules to archive a socket */
|
||||
if (S_ISSOCK(statbuf->st_mode)) {
|
||||
error_msg("%s: socket ignored\n", fileName);
|
||||
error_msg("%s: socket ignored", fileName);
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
@@ -1096,16 +1012,35 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
|
||||
* the new tarball */
|
||||
if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
|
||||
tbInfo->statBuf.st_ino == statbuf->st_ino) {
|
||||
error_msg("%s: file is the archive; skipping\n", fileName);
|
||||
error_msg("%s: file is the archive; skipping", fileName);
|
||||
return( TRUE);
|
||||
}
|
||||
|
||||
header_name = fileName;
|
||||
while (header_name[0] == '/') {
|
||||
static int alreadyWarned=FALSE;
|
||||
if (alreadyWarned==FALSE) {
|
||||
error_msg("Removing leading '/' from member names");
|
||||
alreadyWarned=TRUE;
|
||||
}
|
||||
header_name++;
|
||||
}
|
||||
|
||||
if (strlen(fileName) >= NAME_SIZE) {
|
||||
error_msg(name_longer_than_foo, NAME_SIZE);
|
||||
return ( TRUE);
|
||||
}
|
||||
|
||||
if (writeTarHeader(tbInfo, fileName, statbuf)==FALSE) {
|
||||
if (header_name[0] == '\0')
|
||||
return TRUE;
|
||||
|
||||
#if defined BB_FEATURE_TAR_EXCLUDE
|
||||
if (exclude_file(tbInfo->excludeList, header_name)) {
|
||||
return SKIP;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (writeTarHeader(tbInfo, header_name, fileName, statbuf)==FALSE) {
|
||||
return( FALSE);
|
||||
}
|
||||
|
||||
@@ -1118,7 +1053,7 @@ static int writeFileToTarball(const char *fileName, struct stat *statbuf, void*
|
||||
|
||||
/* open the file we want to archive, and make sure all is well */
|
||||
if ((inputFileFd = open(fileName, O_RDONLY)) < 0) {
|
||||
error_msg("%s: Cannot open: %s\n", fileName, strerror(errno));
|
||||
error_msg("%s: Cannot open: %s", fileName, strerror(errno));
|
||||
return( FALSE);
|
||||
}
|
||||
|
||||
@@ -1157,7 +1092,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
|
||||
|
||||
/* Make sure there is at least one file to tar up. */
|
||||
if (*argv == NULL)
|
||||
error_msg_and_die("Cowardly refusing to create an empty archive\n");
|
||||
error_msg_and_die("Cowardly refusing to create an empty archive");
|
||||
|
||||
/* Open the tar file for writing. */
|
||||
if (!strcmp(tarName, "-"))
|
||||
@@ -1165,7 +1100,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
|
||||
else
|
||||
tbInfo.tarFd = open (tarName, O_WRONLY | O_CREAT | O_TRUNC, 0644);
|
||||
if (tbInfo.tarFd < 0) {
|
||||
error_msg( "Error opening '%s': %s\n", tarName, strerror(errno));
|
||||
perror_msg( "Error opening '%s'", tarName);
|
||||
freeHardLinkInfo(&tbInfo.hlInfoHead);
|
||||
return ( FALSE);
|
||||
}
|
||||
@@ -1175,10 +1110,6 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
|
||||
if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
|
||||
error_msg_and_die(io_error, tarName, strerror(errno));
|
||||
|
||||
/* Set the umask for this process so it doesn't
|
||||
* screw up permission setting for us later. */
|
||||
umask(0);
|
||||
|
||||
/* Read the directory/files and iterate over them one at a time */
|
||||
while (*argv != NULL) {
|
||||
if (recursive_action(*argv++, TRUE, FALSE, FALSE,
|
||||
@@ -1200,7 +1131,7 @@ static int writeTarFile(const char* tarName, int verboseFlag, char **argv,
|
||||
/* Hang up the tools, close up shop, head home */
|
||||
close(tarFd);
|
||||
if (errorFlag == TRUE) {
|
||||
error_msg("Error exit delayed from previous errors\n");
|
||||
error_msg("Error exit delayed from previous errors");
|
||||
freeHardLinkInfo(&tbInfo.hlInfoHead);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
+7
-4
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini basename implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,8 +21,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
@@ -30,7 +33,7 @@ extern int basename_main(int argc, char **argv)
|
||||
char *s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(basename_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
argv++;
|
||||
@@ -44,6 +47,6 @@ extern int basename_main(int argc, char **argv)
|
||||
if (m>=n && strncmp(s+m-n, *argv, n)==0)
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
printf("%s\n", s);
|
||||
puts(s);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,21 +1,15 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#ifdef BB_LOCALE_SUPPORT
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
#define bb_need_full_version
|
||||
#define BB_DECLARE_EXTERN
|
||||
#include "messages.c"
|
||||
|
||||
static int been_there_done_that = 0;
|
||||
|
||||
|
||||
int been_there_done_that = 0; /* Also used in applets.c */
|
||||
const char *applet_name;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
@@ -43,21 +37,7 @@ typedef int (*__link_f)(const char *, const char *);
|
||||
*/
|
||||
static char *busybox_fullpath()
|
||||
{
|
||||
pid_t pid;
|
||||
char path[256];
|
||||
char proc[256];
|
||||
int len;
|
||||
|
||||
pid = getpid();
|
||||
sprintf(proc, "/proc/%d/exe", pid);
|
||||
len = readlink(proc, path, 256);
|
||||
if (len != -1) {
|
||||
path[len] = 0;
|
||||
} else {
|
||||
error_msg("%s: %s\n", proc, strerror(errno));
|
||||
return NULL;
|
||||
}
|
||||
return strdup(path);
|
||||
return xreadlink("/proc/self/exe");
|
||||
}
|
||||
|
||||
/* create (sym)links for each applet */
|
||||
@@ -65,21 +45,21 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
{
|
||||
__link_f Link = link;
|
||||
|
||||
char command[256];
|
||||
char *fpc;
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links) Link = symlink;
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
sprintf ( command, "%s/%s",
|
||||
install_dir[applets[i].location],
|
||||
applets[i].name);
|
||||
rc = Link(busybox, command);
|
||||
|
||||
if (rc) {
|
||||
error_msg("%s: %s\n", command, strerror(errno));
|
||||
fpc = concat_path_file(
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, fpc);
|
||||
if (rc!=0 && errno!=EEXIST) {
|
||||
perror_msg("%s", fpc);
|
||||
}
|
||||
free(fpc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,9 +67,35 @@ static void install_links(const char *busybox, int use_symbolic_links)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct BB_applet search_applet, *applet;
|
||||
const char *s;
|
||||
applet_name = "busybox";
|
||||
const char *s;
|
||||
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
/* Add in a special case hack for a leading hyphen */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
applet_name = (*argv+1);
|
||||
}
|
||||
|
||||
#ifdef BB_LOCALE_SUPPORT
|
||||
#ifdef BB_INIT
|
||||
if(getpid()!=1) /* Do not set locale for `init' */
|
||||
#endif
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
}
|
||||
#endif
|
||||
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0, len, i;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
@@ -121,39 +127,6 @@ int main(int argc, char **argv)
|
||||
}
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
#ifdef BB_SH
|
||||
/* Add in a special case hack -- whenever **argv == '-'
|
||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
exit(((*(shell_main)) (argc, argv)));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
search_applet.name = applet_name;
|
||||
applet = bsearch(&search_applet, applets, NUM_APPLETS,
|
||||
sizeof(struct BB_applet), applet_name_compare);
|
||||
if (applet != NULL) {
|
||||
if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
|
||||
usage(applet->usage);
|
||||
exit((*(applet->main)) (argc, argv));
|
||||
}
|
||||
|
||||
return(busybox_main(argc, argv));
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0;
|
||||
int ps_index;
|
||||
char *index, *index2;
|
||||
|
||||
argc--;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
@@ -179,31 +152,22 @@ int busybox_main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(-1);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Flag that we've been here already */
|
||||
been_there_done_that = 1;
|
||||
|
||||
/* We do not want the word "busybox" to show up in ps, so we move
|
||||
* everything in argv around to fake ps into showing what we want it to
|
||||
* show. Since we are only shrinking the string, we don't need to move
|
||||
* __environ or any of that tedious stuff... */
|
||||
ps_index = 0;
|
||||
index=*argv;
|
||||
index2=argv[argc];
|
||||
index2+=strlen(argv[argc]);
|
||||
while(ps_index < argc) {
|
||||
argv[ps_index]=index;
|
||||
memmove(index, argv[ps_index+1], strlen(argv[ps_index+1])+1);
|
||||
index+=(strlen(index));
|
||||
*index='\0';
|
||||
index++;
|
||||
ps_index++;
|
||||
}
|
||||
while(index<=index2)
|
||||
*index++='\0';
|
||||
argv[ps_index]=NULL;
|
||||
/* Move the command line down a notch */
|
||||
len = argv[argc] + strlen(argv[argc]) - argv[1];
|
||||
memmove(argv[0], argv[1], len);
|
||||
memset(argv[0] + len, 0, argv[1] - argv[0]);
|
||||
|
||||
/* Fix up the argv pointers */
|
||||
len = argv[1] - argv[0];
|
||||
memmove(argv, argv + 1, sizeof(char *) * (argc + 1));
|
||||
for (i = 0; i < argc; i++)
|
||||
argv[i] -= len;
|
||||
|
||||
return (main(argc, argv));
|
||||
}
|
||||
|
||||
@@ -26,66 +26,18 @@
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define BB_BANNER "BusyBox v" BB_VER " (" BB_BT ")"
|
||||
|
||||
#ifdef DMALLOC
|
||||
#include "dmalloc.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
#include <mntent.h>
|
||||
#include <regex.h>
|
||||
/* for the _syscall() macros */
|
||||
#include <sys/syscall.h>
|
||||
#include <linux/unistd.h>
|
||||
|
||||
|
||||
/* Some useful definitions */
|
||||
#define FALSE ((int) 0)
|
||||
#define TRUE ((int) 1)
|
||||
|
||||
/* for mtab.c */
|
||||
#define MTAB_GETMOUNTPT '1'
|
||||
#define MTAB_GETDEVICE '2'
|
||||
|
||||
#define BUF_SIZE 8192
|
||||
#define EXPAND_ALLOC 1024
|
||||
|
||||
static inline int is_decimal(ch) { return ((ch >= '0') && (ch <= '9')); }
|
||||
static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
|
||||
|
||||
/* Macros for min/max. */
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
|
||||
/* I don't like nested includes, but the string and io functions are used
|
||||
* too often
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#if !defined(NO_STRING_H) || defined(STDC_HEADERS)
|
||||
# include <string.h>
|
||||
# if !defined(STDC_HEADERS) && !defined(NO_MEMORY_H) && !defined(__GNUC__)
|
||||
# include <memory.h>
|
||||
# endif
|
||||
# define memzero(s, n) memset ((void *)(s), 0, (n))
|
||||
#else
|
||||
# include <strings.h>
|
||||
# define strchr index
|
||||
# define strrchr rindex
|
||||
# define memcpy(d, s, n) bcopy((s), (d), (n))
|
||||
# define memcmp(s1, s2, n) bcmp((s1), (s2), (n))
|
||||
# define memzero(s, n) bzero((s), (n))
|
||||
#endif
|
||||
#include <features.h>
|
||||
|
||||
|
||||
enum Location {
|
||||
@@ -100,7 +52,6 @@ struct BB_applet {
|
||||
const char* name;
|
||||
int (*main)(int argc, char** argv);
|
||||
enum Location location;
|
||||
const char* usage;
|
||||
};
|
||||
/* From busybox.c */
|
||||
extern const struct BB_applet applets[];
|
||||
@@ -115,132 +66,20 @@ extern const struct BB_applet applets[];
|
||||
#include "applets.h"
|
||||
#undef PROTOTYPES
|
||||
|
||||
extern const char *applet_name;
|
||||
extern int applet_name_compare(const void *x, const void *y);
|
||||
|
||||
extern void usage(const char *usage) __attribute__ ((noreturn));
|
||||
extern void error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
extern void perror_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
|
||||
|
||||
const char *mode_string(int mode);
|
||||
const char *time_string(time_t timeVal);
|
||||
int is_directory(const char *name, const int followLinks, struct stat *statBuf);
|
||||
int isDevice(const char *name);
|
||||
|
||||
typedef struct ino_dev_hash_bucket_struct {
|
||||
struct ino_dev_hash_bucket_struct *next;
|
||||
ino_t ino;
|
||||
dev_t dev;
|
||||
char name[1];
|
||||
} ino_dev_hashtable_bucket_t;
|
||||
int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
|
||||
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
|
||||
void reset_ino_dev_hashtable(void);
|
||||
|
||||
int copy_file(const char *srcName, const char *destName,
|
||||
int setModes, int followLinks, int forceFlag);
|
||||
int copy_file_chunk(int srcFd, int dstFd, size_t remaining);
|
||||
char *buildName(const char *dirName, const char *fileName);
|
||||
int makeString(int argc, const char **argv, char *buf, int bufLen);
|
||||
char *getChunk(int size);
|
||||
char *chunkstrdup(const char *str);
|
||||
void freeChunks(void);
|
||||
int full_write(int fd, const char *buf, int len);
|
||||
int full_read(int fd, char *buf, int len);
|
||||
int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
|
||||
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
|
||||
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
|
||||
void* userData);
|
||||
|
||||
extern int create_path (const char *name, int mode);
|
||||
extern int parse_mode( const char* s, mode_t* theMode);
|
||||
|
||||
extern int get_kernel_revision(void);
|
||||
|
||||
extern int get_console_fd(char* tty_name);
|
||||
extern struct mntent *find_mount_point(const char *name, const char *table);
|
||||
extern void write_mtab(char* blockDevice, char* directory,
|
||||
char* filesystemType, long flags, char* string_flags);
|
||||
extern void erase_mtab(const char * name);
|
||||
extern void mtab_read(void);
|
||||
extern char *mtab_first(void **iter);
|
||||
extern char *mtab_next(void **iter);
|
||||
extern char *mtab_getinfo(const char *match, const char which);
|
||||
extern int check_wildcard_match(const char* text, const char* pattern);
|
||||
extern long atoi_w_units (const char *cp);
|
||||
extern pid_t* find_pid_by_name( char* pidName);
|
||||
extern int find_real_root_device_name(char* name);
|
||||
extern char *get_line_from_file(FILE *file);
|
||||
extern void print_file(FILE *file);
|
||||
extern int print_file_by_name(char *filename);
|
||||
extern char process_escape_sequence(char **ptr);
|
||||
extern char *get_last_path_component(char *path);
|
||||
extern void xregcomp(regex_t *preg, const char *regex, int cflags);
|
||||
extern FILE *wfopen(const char *path, const char *mode);
|
||||
extern FILE *xfopen(const char *path, const char *mode);
|
||||
|
||||
#ifndef DMALLOC
|
||||
extern void *xmalloc (size_t size);
|
||||
extern void *xrealloc(void *old, size_t size);
|
||||
extern void *xcalloc(size_t nmemb, size_t size);
|
||||
extern char *xstrdup (const char *s);
|
||||
#ifdef BB_FEATURE_BUFFERS_GO_ON_STACK
|
||||
#define RESERVE_BB_BUFFER(buffer,len) char buffer[len]
|
||||
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char buffer[len]
|
||||
#else
|
||||
#ifdef BB_FEATURE_BUFFERS_GO_IN_BSS
|
||||
#define RESERVE_BB_BUFFER(buffer,len) static char buffer[len]
|
||||
#define RESERVE_BB_UBUFFER(buffer,len) static unsigned char buffer[len]
|
||||
#else
|
||||
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
|
||||
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
|
||||
#endif
|
||||
extern char *xstrndup (const char *s, int n);
|
||||
|
||||
|
||||
/* These parse entries in /etc/passwd and /etc/group. This is desirable
|
||||
* for BusyBox since we want to avoid using the glibc NSS stuff, which
|
||||
* increases target size and is often not needed embedded systems. */
|
||||
extern long my_getpwnam(char *name);
|
||||
extern long my_getgrnam(char *name);
|
||||
extern void my_getpwuid(char *name, long uid);
|
||||
extern void my_getgrgid(char *group, long gid);
|
||||
extern long my_getpwnamegid(char *name);
|
||||
|
||||
extern int device_open(char *device, int mode);
|
||||
|
||||
#if defined BB_FEATURE_MOUNT_LOOP
|
||||
extern int del_loop(const char *device);
|
||||
extern int set_loop(const char *device, const char *file, int offset, int *loopro);
|
||||
extern char *find_unused_loop_device (void);
|
||||
#endif
|
||||
|
||||
|
||||
#if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT)
|
||||
extern int vdprintf(int d, const char *format, va_list ap);
|
||||
#endif
|
||||
|
||||
#if defined BB_NFSMOUNT
|
||||
int nfsmount(const char *spec, const char *node, int *flags,
|
||||
char **extra_opts, char **mount_opts, int running_bg);
|
||||
#endif
|
||||
|
||||
#ifndef RB_POWER_OFF
|
||||
/* Stop system and switch power off if possible. */
|
||||
#define RB_POWER_OFF 0x4321fedc
|
||||
#endif
|
||||
|
||||
/* Include our own copy of struct sysinfo to avoid binary compatability
|
||||
* problems with Linux 2.4, which changed things. Grumble, grumble. */
|
||||
struct sysinfo {
|
||||
long uptime; /* Seconds since boot */
|
||||
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
unsigned long totalram; /* Total usable main memory size */
|
||||
unsigned long freeram; /* Available memory size */
|
||||
unsigned long sharedram; /* Amount of shared memory */
|
||||
unsigned long bufferram; /* Memory used by buffers */
|
||||
unsigned long totalswap; /* Total swap space size */
|
||||
unsigned long freeswap; /* swap space still available */
|
||||
unsigned short procs; /* Number of current processes */
|
||||
unsigned long totalhigh; /* Total high memory size */
|
||||
unsigned long freehigh; /* Available high memory size */
|
||||
unsigned int mem_unit; /* Memory unit size in bytes */
|
||||
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
|
||||
};
|
||||
extern int sysinfo (struct sysinfo* info);
|
||||
|
||||
/* Bit map related macros -- libc5 doens't provide these... sigh. */
|
||||
#ifndef setbit
|
||||
#define NBBY CHAR_BIT
|
||||
@@ -250,4 +89,15 @@ extern int sysinfo (struct sysinfo* info);
|
||||
#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
|
||||
#endif
|
||||
|
||||
#ifndef RB_POWER_OFF
|
||||
/* Stop system and switch power off if possible. */
|
||||
#define RB_POWER_OFF 0x4321fedc
|
||||
#endif
|
||||
|
||||
|
||||
/* Pull in the utility routines from libbb */
|
||||
#include "libbb/libbb.h"
|
||||
|
||||
|
||||
|
||||
#endif /* _BB_INTERNAL_H_ */
|
||||
+10
-2
@@ -1,12 +1,20 @@
|
||||
#!/bin/sh
|
||||
# Make busybox links list file.
|
||||
|
||||
# input $1: full path to Config.h
|
||||
# input $2: full path to applets.h
|
||||
# output (stdout): list of pathnames that should be linked to busybox
|
||||
|
||||
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-Config.h}
|
||||
APPLETS_H=${2:-applets.h}
|
||||
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*LINK/{
|
||||
match($2,"_BB_DIR[A-Z_]*")
|
||||
dir=substr($2,RSTART+7,RLENGTH-7)
|
||||
dir=substr($2,8)
|
||||
gsub("_","/",dir)
|
||||
if(dir=="/ROOT") dir=""
|
||||
file=$3
|
||||
|
||||
+8
-5
@@ -1,13 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
RAW=` \
|
||||
gcc -E -dM ${1:-Config.h} | \
|
||||
sed -n -e '/^.*BB_FEATURE.*$/d;s/^#define.*\<BB_\(.*\)\>/\1.c/gp;' \
|
||||
| tr '[:upper:]' '[:lower:]' | sort
|
||||
| tr A-Z a-z | sort
|
||||
`
|
||||
test "${RAW}" != "" || exit
|
||||
cd ${2:-.}
|
||||
# I added in the extra "ls" so only source files that
|
||||
# actually exist will show up in the compile list.
|
||||
ls -1 $RAW 2>/dev/null | sed -e 's/\.c$/\.o/g'
|
||||
if [ -d "$BB_SRC_DIR" ]; then cd $BB_SRC_DIR; fi
|
||||
# By running $RAW through "ls", we avoid listing
|
||||
# source files that don't exist.
|
||||
ls $RAW 2>/dev/null | tr '\n' ' '
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
Name: busybox
|
||||
Version: 0.48
|
||||
Version: 0.52
|
||||
Release: 1
|
||||
Group: System/Utilities
|
||||
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini Cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,8 +21,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Don't use lchown for libc5 or glibc older then 2.1.x */
|
||||
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
|
||||
#define lchown chown
|
||||
#endif
|
||||
|
||||
|
||||
static long gid;
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (lchown(fileName, statbuf->st_uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
perror(fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chgrp_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
int recursiveFlag = FALSE;
|
||||
char *p=NULL;
|
||||
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > optind && argc > 2 && argv[optind]) {
|
||||
/* Find the selected group */
|
||||
gid = strtoul(argv[optind], &p, 10); /* maybe it's already numeric */
|
||||
if (argv[optind] == p)
|
||||
gid = my_getgrnam(argv[optind]);
|
||||
} else {
|
||||
error_msg_and_die(too_few_args);
|
||||
}
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
while (++optind < argc) {
|
||||
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, NULL) == FALSE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,85 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (!parse_mode((char *)junk, &(statbuf->st_mode)))
|
||||
error_msg_and_die("internal error");
|
||||
if (chmod(fileName, statbuf->st_mode) == 0)
|
||||
return (TRUE);
|
||||
perror(fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chmod_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int opt;
|
||||
int recursiveFlag = FALSE;
|
||||
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > optind && argc > 2 && argv[optind]) {
|
||||
/* Parse the specified mode */
|
||||
mode_t mode;
|
||||
if (parse_mode(argv[optind], &mode) == FALSE) {
|
||||
error_msg_and_die( "unknown mode: %s", argv[optind]);
|
||||
}
|
||||
} else {
|
||||
error_msg_and_die(too_few_args);
|
||||
}
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
for (i = optind + 1; i < argc; i++) {
|
||||
if (recursive_action (argv[i], recursiveFlag, FALSE, FALSE, fileAction,
|
||||
fileAction, argv[optind]) == FALSE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,178 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_invalid_option
|
||||
#define bb_need_too_few_args
|
||||
#include "messages.c"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
|
||||
|
||||
static long uid = -1;
|
||||
static long gid = -1;
|
||||
static int whichApp;
|
||||
static char *theMode = NULL;
|
||||
|
||||
|
||||
#define CHGRP_APP 1
|
||||
#define CHOWN_APP 2
|
||||
#define CHMOD_APP 3
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
switch (whichApp) {
|
||||
case CHGRP_APP:
|
||||
case CHOWN_APP:
|
||||
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
|
||||
if (lchown
|
||||
(fileName, (whichApp == CHOWN_APP) ? uid : statbuf->st_uid,
|
||||
(gid == -1) ? statbuf->st_gid : gid) == 0)
|
||||
#else
|
||||
if (chown
|
||||
(fileName, (whichApp == CHOWN_APP) ? uid : statbuf->st_uid,
|
||||
(gid == -1) ? statbuf->st_gid : gid) == 0)
|
||||
#endif
|
||||
{
|
||||
return (TRUE);
|
||||
}
|
||||
break;
|
||||
case CHMOD_APP:
|
||||
/* Parse the specified modes */
|
||||
if (parse_mode(theMode, &(statbuf->st_mode)) == FALSE) {
|
||||
error_msg_and_die( "unknown mode: %s\n", theMode);
|
||||
}
|
||||
if (chmod(fileName, statbuf->st_mode) == 0)
|
||||
return (TRUE);
|
||||
break;
|
||||
}
|
||||
perror(fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chmod_chown_chgrp_main(int argc, char **argv)
|
||||
{
|
||||
int stopIt = FALSE;
|
||||
int recursiveFlag = FALSE;
|
||||
char *groupName=NULL;
|
||||
char *p=NULL;
|
||||
const char *appUsage;
|
||||
|
||||
whichApp = (strcmp(applet_name, "chown") == 0)?
|
||||
CHOWN_APP : (strcmp(applet_name, "chmod") == 0)?
|
||||
CHMOD_APP : CHGRP_APP;
|
||||
|
||||
appUsage = (whichApp == CHOWN_APP)?
|
||||
chown_usage : (whichApp == CHMOD_APP) ? chmod_usage : chgrp_usage;
|
||||
|
||||
if (argc < 2)
|
||||
usage(appUsage);
|
||||
argv++;
|
||||
|
||||
/* Parse options */
|
||||
while (--argc >= 0 && *argv && (**argv == '-')) {
|
||||
while (stopIt==FALSE && *++(*argv)) {
|
||||
switch (**argv) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
theMode=*argv-1;
|
||||
stopIt = TRUE;
|
||||
}
|
||||
}
|
||||
if (stopIt==TRUE)
|
||||
break;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (argc == 0 || *argv == NULL) {
|
||||
error_msg(too_few_args);
|
||||
}
|
||||
|
||||
if (whichApp == CHMOD_APP) {
|
||||
if (theMode==NULL)
|
||||
theMode = *argv;
|
||||
} else {
|
||||
|
||||
/* Find the selected group */
|
||||
if (whichApp == CHGRP_APP) {
|
||||
groupName = *argv;
|
||||
gid = strtoul(groupName, &p, 10); /* maybe it's already numeric */
|
||||
if (groupName == p)
|
||||
gid = my_getgrnam(groupName);
|
||||
if (gid == -1)
|
||||
goto bad_group;
|
||||
} else {
|
||||
groupName = strchr(*argv, '.');
|
||||
if (groupName == NULL)
|
||||
groupName = strchr(*argv, ':');
|
||||
if (groupName) {
|
||||
*groupName++ = '\0';
|
||||
gid = strtoul(groupName, &p, 10);
|
||||
if (groupName == p)
|
||||
gid = my_getgrnam(groupName);
|
||||
if (gid == -1)
|
||||
goto bad_group;
|
||||
} else
|
||||
gid = -1;
|
||||
}
|
||||
|
||||
|
||||
/* Find the selected user (if appropriate) */
|
||||
if (whichApp == CHOWN_APP) {
|
||||
uid = strtoul(*argv, &p, 10); /* if numeric ... */
|
||||
if (*argv == p)
|
||||
uid = my_getpwnam(*argv);
|
||||
if (uid == -1) {
|
||||
error_msg_and_die( "unknown user name: %s\n", *argv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
if (argc < 1) {
|
||||
error_msg_and_die(too_few_args);
|
||||
}
|
||||
while (argc-- > 1) {
|
||||
if (recursive_action (*(++argv), recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, NULL) == FALSE)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
bad_group:
|
||||
error_msg_and_die( "unknown group name: %s\n", groupName);
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,113 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Don't use lchown for libc5 or glibc older then 2.1.x */
|
||||
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
|
||||
#define lchown chown
|
||||
#endif
|
||||
|
||||
static long uid;
|
||||
static long gid;
|
||||
|
||||
static int (*chown_func)() = chown;
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (chown_func(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
perror(fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chown_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
int recursiveFlag = FALSE,
|
||||
noderefFlag = FALSE;
|
||||
char *groupName=NULL;
|
||||
char *p=NULL;
|
||||
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "Rh")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
case 'h':
|
||||
noderefFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (noderefFlag) chown_func = lchown;
|
||||
|
||||
if (argc > optind && argc > 2 && argv[optind]) {
|
||||
/* First, check if there is a group name here */
|
||||
groupName = strchr(argv[optind], '.');
|
||||
if (groupName == NULL)
|
||||
groupName = strchr(argv[optind], ':');
|
||||
if (groupName) {
|
||||
*groupName++ = '\0';
|
||||
gid = strtoul(groupName, &p, 10);
|
||||
if (groupName == p)
|
||||
gid = my_getgrnam(groupName);
|
||||
} else {
|
||||
gid = -1;
|
||||
}
|
||||
/* Now check for the username */
|
||||
uid = strtoul(argv[optind], &p, 10); /* Is is numeric? */
|
||||
if (argv[optind] == p) {
|
||||
uid = my_getpwnam(argv[optind]);
|
||||
}
|
||||
} else {
|
||||
error_msg_and_die(too_few_args);
|
||||
}
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
while (++optind < argc) {
|
||||
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, NULL) == FALSE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini chroot implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,23 +22,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
char *prog;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(chroot_usage);
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno));
|
||||
perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
@@ -53,11 +54,14 @@ int chroot_main(int argc, char **argv)
|
||||
prog = "/bin/sh";
|
||||
execlp(prog, prog, NULL);
|
||||
#else
|
||||
shell_main(argc, argv);
|
||||
char shell[] = "/bin/sh";
|
||||
char *shell_argv[2] = { shell, NULL };
|
||||
applet_name = shell;
|
||||
shell_main(1, shell_argv);
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno));
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,33 +4,32 @@
|
||||
*
|
||||
* busyboxed by Erik Andersen
|
||||
*/
|
||||
#include "busybox.h"
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
#define VT_ACTIVATE 0x5606 /* make vt active */
|
||||
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
|
||||
static const int VT_ACTIVATE = 0x5606; /* make vt active */
|
||||
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
|
||||
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
usage (chvt_usage);
|
||||
show_usage();
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num)) {
|
||||
perror("VT_ACTIVATE");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ioctl(fd, VT_WAITACTIVE, num)) {
|
||||
perror("VT_WAITACTIVE");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ioctl(fd, VT_ACTIVATE, num))
|
||||
perror_msg_and_die("VT_ACTIVATE");
|
||||
if (ioctl(fd, VT_WAITACTIVE, num))
|
||||
perror_msg_and_die("VT_WAITACTIVE");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini clear implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,8 +22,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
extern int clear_main(int argc, char **argv)
|
||||
|
||||
@@ -1,26 +1,8 @@
|
||||
#ifndef CMDEDIT_H
|
||||
#define CMDEDIT_H
|
||||
|
||||
#ifdef BB_FEATURE_SH_COMMAND_EDITING
|
||||
/* unix systems can #define POSIX to use termios, otherwise
|
||||
* the bsd or sysv interface will be used
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
typedef size_t (*cmdedit_strwidth_proc)(char *);
|
||||
|
||||
void cmdedit_init(void);
|
||||
void cmdedit_terminate(void);
|
||||
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
|
||||
void cmdedit_setwidth(int); /* specify width of screen */
|
||||
void cmdedit_histadd(char *); /* adds entries to hist */
|
||||
void cmdedit_strwidth(cmdedit_strwidth_proc); /* to bind cmdedit_strlen */
|
||||
|
||||
extern int (*cmdedit_in_hook)(char *);
|
||||
extern int (*cmdedit_out_hook)(char *);
|
||||
extern int (*cmdedit_tab_hook)(char *, int, int *);
|
||||
|
||||
#endif /* BB_FEATURE_SH_COMMAND_EDITING */
|
||||
|
||||
#endif /* CMDEDIT_H */
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,31 +22,46 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp1 = NULL, *fp2 = stdin;
|
||||
char *filename1 = argv[1], *filename2 = "-";
|
||||
int c1, c2, char_pos = 1, line_pos = 1;
|
||||
char *filename1, *filename2 = "-";
|
||||
int c, c1, c2, char_pos = 1, line_pos = 1, silent = FALSE;
|
||||
|
||||
/* parse argv[] */
|
||||
if (argc < 2 || 3 < argc)
|
||||
usage(cmp_usage);
|
||||
while ((c = getopt(argc, argv, "s")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
silent = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
fp1 = xfopen(argv[1], "r");
|
||||
if (argv[2] != NULL) {
|
||||
fp2 = xfopen(argv[2], "r");
|
||||
filename2 = argv[2];
|
||||
filename1 = argv[optind];
|
||||
switch (argc - optind) {
|
||||
case 2:
|
||||
fp2 = xfopen(filename2 = argv[optind + 1], "r");
|
||||
case 1:
|
||||
fp1 = xfopen(filename1, "r");
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
|
||||
do {
|
||||
c1 = fgetc(fp1);
|
||||
c2 = fgetc(fp2);
|
||||
if (c1 != c2) {
|
||||
if (silent)
|
||||
return EXIT_FAILURE;
|
||||
if (c1 == EOF)
|
||||
printf("EOF on %s\n", filename1);
|
||||
else if (c2 == EOF)
|
||||
|
||||
+11
-12
@@ -4,33 +4,32 @@
|
||||
*
|
||||
* busyboxed by Erik Andersen
|
||||
*/
|
||||
#include "busybox.h"
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
#define VT_ACTIVATE 0x5606 /* make vt active */
|
||||
#define VT_WAITACTIVE 0x5607 /* wait for vt active */
|
||||
static const int VT_ACTIVATE = 0x5606; /* make vt active */
|
||||
static const int VT_WAITACTIVE = 0x5607; /* wait for vt active */
|
||||
|
||||
int chvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd, num;
|
||||
|
||||
if ((argc != 2) || (**(argv + 1) == '-'))
|
||||
usage (chvt_usage);
|
||||
show_usage();
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
if (ioctl(fd, VT_ACTIVATE, num)) {
|
||||
perror("VT_ACTIVATE");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ioctl(fd, VT_WAITACTIVE, num)) {
|
||||
perror("VT_WAITACTIVE");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (ioctl(fd, VT_ACTIVATE, num))
|
||||
perror_msg_and_die("VT_ACTIVATE");
|
||||
if (ioctl(fd, VT_WAITACTIVE, num))
|
||||
perror_msg_and_die("VT_WAITACTIVE");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini clear implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,8 +22,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
extern int clear_main(int argc, char **argv)
|
||||
|
||||
+12
-17
@@ -3,15 +3,15 @@
|
||||
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
|
||||
* Renamed deallocvt.
|
||||
*/
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
#define VT_DISALLOCATE 0x5608 /* free memory associated to vt */
|
||||
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
|
||||
|
||||
int deallocvt_main(int argc, char *argv[])
|
||||
{
|
||||
@@ -19,30 +19,25 @@ int deallocvt_main(int argc, char *argv[])
|
||||
|
||||
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
|
||||
if (argc > 2)
|
||||
usage(deallocvt_usage);
|
||||
show_usage();
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
|
||||
if (argc == 1) {
|
||||
printf("erik: A\n");
|
||||
/* deallocate all unused consoles */
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
} else
|
||||
printf("erik: B\n");
|
||||
if (ioctl(fd, VT_DISALLOCATE, 0))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
} else {
|
||||
for (i = 1; i < argc; i++) {
|
||||
num = atoi(argv[i]);
|
||||
if (num == 0)
|
||||
error_msg("0: illegal VT number\n");
|
||||
error_msg("0: illegal VT number");
|
||||
else if (num == 1)
|
||||
error_msg("VT 1 cannot be deallocated\n");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num)) {
|
||||
perror("VT_DISALLOCATE");
|
||||
error_msg_and_die("could not deallocate console %d\n", num);
|
||||
}
|
||||
error_msg("VT 1 cannot be deallocated");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
}
|
||||
printf("erik: C\n");
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -20,11 +20,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbentry {
|
||||
@@ -32,11 +35,11 @@ struct kbentry {
|
||||
unsigned char kb_index;
|
||||
unsigned short kb_value;
|
||||
};
|
||||
#define KDGKBENT 0x4B46 /* gets one entry in translation table */
|
||||
static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
|
||||
|
||||
/* From <linux/keyboard.h> */
|
||||
#define NR_KEYS 128
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
static const int NR_KEYS = 128;
|
||||
static const int MAX_NR_KEYMAPS = 256;
|
||||
|
||||
int dumpkmap_main(int argc, char **argv)
|
||||
{
|
||||
@@ -45,12 +48,12 @@ int dumpkmap_main(int argc, char **argv)
|
||||
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
usage(dumpkmap_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
error_msg("Error opening /dev/tty0: %s\n", strerror(errno));
|
||||
perror_msg("Error opening /dev/tty0");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@@ -78,7 +81,7 @@ int dumpkmap_main(int argc, char **argv)
|
||||
ke.kb_table = i;
|
||||
if (ioctl(fd, KDGKBENT, &ke) < 0) {
|
||||
|
||||
error_msg("ioctl returned: %s, %s, %s, %xqq\n",strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
|
||||
error_msg("ioctl returned: %s, %s, %s, %xqq", strerror(errno),(char *)&ke.kb_index,(char *)&ke.kb_table,(int)&ke.kb_value);
|
||||
}
|
||||
else {
|
||||
write(1,(void*)&ke.kb_value,2);
|
||||
|
||||
+34
-80
@@ -7,7 +7,6 @@
|
||||
* Peter Novodvorsky <petya@logic.ru>
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
@@ -17,35 +16,34 @@
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/kd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
typedef unsigned short unicode;
|
||||
|
||||
static long int ctoi(unsigned char *s, int *is_unicode);
|
||||
int old_screen_map_read_ascii(FILE * fp, unsigned char buf[]);
|
||||
int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode);
|
||||
unicode utf8_to_ucs2(char *buf);
|
||||
int screen_map_load(int fd, FILE * fp);
|
||||
static int old_screen_map_read_ascii(FILE * fp, unsigned char buf[]);
|
||||
static int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode);
|
||||
static unicode utf8_to_ucs2(char *buf);
|
||||
static int screen_map_load(int fd, FILE * fp);
|
||||
|
||||
int loadacm_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
usage(loadacm_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = open("/dev/tty", O_RDWR);
|
||||
if (fd < 0) {
|
||||
error_msg("Error opening /dev/tty1: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
perror_msg_and_die("Error opening /dev/tty1");
|
||||
}
|
||||
|
||||
if (screen_map_load(fd, stdin)) {
|
||||
error_msg("Error loading acm: %s\n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
perror_msg_and_die("Error loading acm");
|
||||
}
|
||||
|
||||
write(fd, "\033(K", 3);
|
||||
@@ -53,7 +51,7 @@ int loadacm_main(int argc, char **argv)
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
int screen_map_load(int fd, FILE * fp)
|
||||
static int screen_map_load(int fd, FILE * fp)
|
||||
{
|
||||
struct stat stbuf;
|
||||
unicode wbuf[E_TABSZ];
|
||||
@@ -62,7 +60,7 @@ int screen_map_load(int fd, FILE * fp)
|
||||
int is_unicode;
|
||||
|
||||
if (fstat(fileno(fp), &stbuf))
|
||||
perror("Cannot stat map file"), exit(1);
|
||||
perror_msg_and_die("Cannot stat map file");
|
||||
|
||||
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
|
||||
if (!
|
||||
@@ -72,18 +70,16 @@ int screen_map_load(int fd, FILE * fp)
|
||||
if (parse_failed) {
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
error_msg("16bit screen-map MUST be a regular file.\n"),
|
||||
exit(1);
|
||||
error_msg_and_die("16bit screen-map MUST be a regular file.");
|
||||
else
|
||||
perror("fseek failed reading binary 16bit screen-map"),
|
||||
exit(1);
|
||||
perror_msg_and_die("fseek failed reading binary 16bit screen-map");
|
||||
}
|
||||
|
||||
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
|
||||
perror("Cannot read [new] map from file"), exit(1);
|
||||
perror_msg_and_die("Cannot read [new] map from file");
|
||||
#if 0
|
||||
else
|
||||
error_msg("Input screen-map is binary.\n");
|
||||
error_msg("Input screen-map is binary.");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -91,7 +87,7 @@ int screen_map_load(int fd, FILE * fp)
|
||||
/* same if it was binary, ie. if parse_failed */
|
||||
if (parse_failed || is_unicode) {
|
||||
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
|
||||
perror("PIO_UNISCRNMAP ioctl"), exit(1);
|
||||
perror_msg_and_die("PIO_UNISCRNMAP ioctl");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@@ -100,10 +96,10 @@ int screen_map_load(int fd, FILE * fp)
|
||||
/* rewind... */
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
error_msg("Assuming 8bit screen-map - MUST be a regular file.\n"),
|
||||
error_msg("Assuming 8bit screen-map - MUST be a regular file."),
|
||||
exit(1);
|
||||
else
|
||||
perror("fseek failed assuming 8bit screen-map"), exit(1);
|
||||
perror_msg_and_die("fseek failed assuming 8bit screen-map");
|
||||
}
|
||||
|
||||
/* ... and try an old 8-bit screen-map */
|
||||
@@ -113,26 +109,25 @@ int screen_map_load(int fd, FILE * fp)
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
/* should not - it succedeed above */
|
||||
error_msg("fseek() returned ESPIPE !\n"),
|
||||
exit(1);
|
||||
error_msg_and_die("fseek() returned ESPIPE !");
|
||||
else
|
||||
perror("fseek for binary 8bit screen-map"), exit(1);
|
||||
perror_msg_and_die("fseek for binary 8bit screen-map");
|
||||
}
|
||||
|
||||
if (fread(buf, E_TABSZ, 1, fp) != 1)
|
||||
perror("Cannot read [old] map from file"), exit(1);
|
||||
perror_msg_and_die("Cannot read [old] map from file");
|
||||
#if 0
|
||||
else
|
||||
error_msg("Input screen-map is binary.\n");
|
||||
error_msg("Input screen-map is binary.");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ioctl(fd, PIO_SCRNMAP, buf))
|
||||
perror("PIO_SCRNMAP ioctl"), exit(1);
|
||||
perror_msg_and_die("PIO_SCRNMAP ioctl");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
error_msg("Error parsing symbolic map\n");
|
||||
error_msg("Error parsing symbolic map");
|
||||
return(1);
|
||||
}
|
||||
|
||||
@@ -146,7 +141,7 @@ int screen_map_load(int fd, FILE * fp)
|
||||
*
|
||||
* FIXME: ignores everything after second word
|
||||
*/
|
||||
int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
|
||||
static int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
|
||||
{
|
||||
char buffer[256]; /* line buffer reading file */
|
||||
char *p, *q; /* 1st + 2nd words in line */
|
||||
@@ -154,7 +149,7 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
|
||||
int tmp_is_unicode; /* tmp for is_unicode calculation */
|
||||
int i; /* loop index - result holder */
|
||||
int ret_code = 0; /* return code */
|
||||
sigset_t sigset, old_sigset;
|
||||
sigset_t acmsigset, old_sigset;
|
||||
|
||||
assert(is_unicode);
|
||||
|
||||
@@ -168,18 +163,16 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
|
||||
buf[i] = 0xfffd;
|
||||
|
||||
/* block SIGCHLD */
|
||||
sigemptyset(&sigset);
|
||||
sigaddset(&sigset, SIGCHLD);
|
||||
sigprocmask(SIG_BLOCK, &sigset, &old_sigset);
|
||||
sigemptyset(&acmsigset);
|
||||
sigaddset(&acmsigset, SIGCHLD);
|
||||
sigprocmask(SIG_BLOCK, &acmsigset, &old_sigset);
|
||||
|
||||
do {
|
||||
if (NULL == fgets(buffer, sizeof(buffer), fp)) {
|
||||
if (feof(fp))
|
||||
break;
|
||||
else {
|
||||
perror("uni_screen_map_read_ascii() can't read line");
|
||||
exit(2);
|
||||
}
|
||||
else
|
||||
perror_msg_and_die("uni_screen_map_read_ascii() can't read line");
|
||||
}
|
||||
|
||||
/* get "charset-relative charcode", stripping leading spaces */
|
||||
@@ -220,7 +213,7 @@ int uni_screen_map_read_ascii(FILE * fp, unicode buf[], int *is_unicode)
|
||||
}
|
||||
|
||||
|
||||
int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
|
||||
static int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
|
||||
{
|
||||
char buffer[256];
|
||||
int in, on;
|
||||
@@ -262,7 +255,7 @@ int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
|
||||
*
|
||||
* CAVEAT: will report valid UTF mappings using only 1 byte as 8-bit ones.
|
||||
*/
|
||||
long int ctoi(unsigned char *s, int *is_unicode)
|
||||
static long int ctoi(unsigned char *s, int *is_unicode)
|
||||
{
|
||||
int i;
|
||||
size_t ls;
|
||||
@@ -309,46 +302,7 @@ long int ctoi(unsigned char *s, int *is_unicode)
|
||||
}
|
||||
|
||||
|
||||
void saveoldmap(int fd, char *omfil)
|
||||
{
|
||||
FILE *fp;
|
||||
char buf[E_TABSZ];
|
||||
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
unicode xbuf[E_TABSZ];
|
||||
int is_old_map = 0;
|
||||
|
||||
if (ioctl(fd, GIO_UNISCRNMAP, xbuf)) {
|
||||
perror("GIO_UNISCRNMAP ioctl error");
|
||||
#endif
|
||||
if (ioctl(fd, GIO_SCRNMAP, buf)) {
|
||||
perror("GIO_SCRNMAP ioctl error");
|
||||
exit(1);
|
||||
} else
|
||||
is_old_map = 1;
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
}
|
||||
#endif
|
||||
|
||||
fp = xfopen(omfil, "w");
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
if (is_old_map) {
|
||||
#endif
|
||||
if (fwrite(buf, E_TABSZ, 1, fp) != 1) {
|
||||
perror("Error writing map to file");
|
||||
exit(1);
|
||||
}
|
||||
#ifdef GIO_UNISCRNMAP
|
||||
} else if (fwrite(xbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1) {
|
||||
perror("Error writing map to file");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
unicode utf8_to_ucs2(char *buf)
|
||||
static unicode utf8_to_ucs2(char *buf)
|
||||
{
|
||||
int utf_count = 0;
|
||||
long utf_char = 0;
|
||||
|
||||
+15
-15
@@ -7,7 +7,6 @@
|
||||
* Loads the console font, and possibly the corresponding screen map(s).
|
||||
* (Adapted for busybox by Matej Vela.)
|
||||
*/
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
@@ -20,14 +19,15 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kd.h>
|
||||
#include <endian.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define PSF_MAGIC1 0x36
|
||||
#define PSF_MAGIC2 0x04
|
||||
static const int PSF_MAGIC1 = 0x36;
|
||||
static const int PSF_MAGIC2 = 0x04;
|
||||
|
||||
#define PSF_MODE512 0x01
|
||||
#define PSF_MODEHASTAB 0x02
|
||||
#define PSF_MAXMODE 0x03
|
||||
#define PSF_SEPARATOR 0xFFFF
|
||||
static const int PSF_MODE512 = 0x01;
|
||||
static const int PSF_MODEHASTAB = 0x02;
|
||||
static const int PSF_MAXMODE = 0x03;
|
||||
static const int PSF_SEPARATOR = 0xFFFF;
|
||||
|
||||
struct psf_header {
|
||||
unsigned char magic1, magic2; /* Magic number */
|
||||
@@ -44,7 +44,7 @@ extern int loadfont_main(int argc, char **argv)
|
||||
int fd;
|
||||
|
||||
if (argc != 1)
|
||||
usage(loadfont_usage);
|
||||
show_usage();
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0)
|
||||
@@ -62,7 +62,7 @@ static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (unit < 1 || unit > 32)
|
||||
error_msg_and_die("Bad character size %d\n", unit);
|
||||
error_msg_and_die("Bad character size %d", unit);
|
||||
|
||||
for (i = 0; i < fontsize; i++)
|
||||
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
|
||||
@@ -119,8 +119,8 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
|
||||
#ifdef ENOIOCTLCMD
|
||||
if (errno == ENOIOCTLCMD) {
|
||||
error_msg("It seems this kernel is older than 1.1.92\n");
|
||||
error_msg_and_die("No Unicode mapping table loaded.\n");
|
||||
error_msg("It seems this kernel is older than 1.1.92");
|
||||
error_msg_and_die("No Unicode mapping table loaded.");
|
||||
} else
|
||||
#endif
|
||||
perror_msg_and_die("PIO_UNIMAPCLR");
|
||||
@@ -174,11 +174,11 @@ static void loadnewfont(int fd)
|
||||
goto no_psf;
|
||||
|
||||
if (psfhdr.mode > PSF_MAXMODE)
|
||||
error_msg_and_die("Unsupported psf file mode\n");
|
||||
error_msg_and_die("Unsupported psf file mode");
|
||||
fontsize = ((psfhdr.mode & PSF_MODE512) ? 512 : 256);
|
||||
#if !defined( PIO_FONTX ) || defined( __sparc__ )
|
||||
if (fontsize != 256)
|
||||
error_msg_and_die("Only fontsize 256 supported\n");
|
||||
error_msg_and_die("Only fontsize 256 supported");
|
||||
#endif
|
||||
hastable = (psfhdr.mode & PSF_MODEHASTAB);
|
||||
unit = psfhdr.charsize;
|
||||
@@ -186,7 +186,7 @@ static void loadnewfont(int fd)
|
||||
|
||||
head = head0 + fontsize * unit;
|
||||
if (head > inputlth || (!hastable && head != inputlth))
|
||||
error_msg_and_die("Input file: bad length\n");
|
||||
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);
|
||||
@@ -201,7 +201,7 @@ static void loadnewfont(int fd)
|
||||
} else {
|
||||
/* bare font */
|
||||
if (inputlth & 0377)
|
||||
error_msg_and_die("Bad input file size\n");
|
||||
error_msg_and_die("Bad input file size");
|
||||
offset = 0;
|
||||
unit = inputlth / 256;
|
||||
}
|
||||
|
||||
@@ -20,11 +20,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define BINARY_KEYMAP_MAGIC "bkeymap"
|
||||
|
||||
@@ -34,11 +37,11 @@ struct kbentry {
|
||||
unsigned char kb_index;
|
||||
unsigned short kb_value;
|
||||
};
|
||||
#define KDSKBENT 0x4B47 /* sets one entry in translation table */
|
||||
static const int KDSKBENT = 0x4B47; /* sets one entry in translation table */
|
||||
|
||||
/* From <linux/keyboard.h> */
|
||||
#define NR_KEYS 128
|
||||
#define MAX_NR_KEYMAPS 256
|
||||
static const int NR_KEYS = 128;
|
||||
static const int MAX_NR_KEYMAPS = 256;
|
||||
|
||||
int loadkmap_main(int argc, char **argv)
|
||||
{
|
||||
@@ -48,7 +51,7 @@ int loadkmap_main(int argc, char **argv)
|
||||
char flags[MAX_NR_KEYMAPS], buff[7];
|
||||
|
||||
if (argc != 1)
|
||||
usage(loadkmap_usage);
|
||||
show_usage();
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0)
|
||||
@@ -56,7 +59,7 @@ int loadkmap_main(int argc, char **argv)
|
||||
|
||||
read(0, buff, 7);
|
||||
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||
error_msg_and_die("This is not a valid binary keymap.\n");
|
||||
error_msg_and_die("This is not a valid binary keymap.");
|
||||
|
||||
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
|
||||
perror_msg_and_die("Error reading keymap flags");
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Mini reset implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* and Kent Robotti <robotti@metconnect.com>
|
||||
*
|
||||
@@ -23,8 +23,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int reset_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
@@ -22,18 +22,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbkeycode {
|
||||
unsigned int scancode, keycode;
|
||||
};
|
||||
#define KDSETKEYCODE 0x4B4D /* write kernel keycode table entry */
|
||||
static const int KDSETKEYCODE = 0x4B4D; /* write kernel keycode table entry */
|
||||
|
||||
extern int
|
||||
setkeycodes_main(int argc, char** argv)
|
||||
@@ -43,7 +43,7 @@ setkeycodes_main(int argc, char** argv)
|
||||
struct kbkeycode a;
|
||||
|
||||
if (argc % 2 != 1 || argc < 2) {
|
||||
usage(setkeycodes_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
@@ -52,18 +52,18 @@ setkeycodes_main(int argc, char** argv)
|
||||
a.keycode = atoi(argv[2]);
|
||||
a.scancode = sc = strtol(argv[1], &ep, 16);
|
||||
if (*ep) {
|
||||
error_msg_and_die("error reading SCANCODE: '%s'\n", argv[1]);
|
||||
error_msg_and_die("error reading SCANCODE: '%s'", argv[1]);
|
||||
}
|
||||
if (a.scancode > 127) {
|
||||
a.scancode -= 0xe000;
|
||||
a.scancode += 128;
|
||||
}
|
||||
if (a.scancode > 255 || a.keycode > 127) {
|
||||
error_msg_and_die("SCANCODE or KEYCODE outside bounds\n");
|
||||
error_msg_and_die("SCANCODE or KEYCODE outside bounds");
|
||||
}
|
||||
if (ioctl(fd,KDSETKEYCODE,&a)) {
|
||||
perror("KDSETKEYCODE");
|
||||
error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d\n", sc, a.keycode);
|
||||
error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
|
||||
}
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini basename implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,8 +21,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
@@ -30,7 +33,7 @@ extern int basename_main(int argc, char **argv)
|
||||
char *s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(basename_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
argv++;
|
||||
@@ -44,6 +47,6 @@ extern int basename_main(int argc, char **argv)
|
||||
if (m>=n && strncmp(s+m-n, *argv, n)==0)
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
printf("%s\n", s);
|
||||
puts(s);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+3
-2
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini Cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,8 +21,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Don't use lchown for libc5 or glibc older then 2.1.x */
|
||||
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
|
||||
#define lchown chown
|
||||
#endif
|
||||
|
||||
|
||||
static long gid;
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (lchown(fileName, statbuf->st_uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
perror(fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chgrp_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
int recursiveFlag = FALSE;
|
||||
char *p=NULL;
|
||||
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > optind && argc > 2 && argv[optind]) {
|
||||
/* Find the selected group */
|
||||
gid = strtoul(argv[optind], &p, 10); /* maybe it's already numeric */
|
||||
if (argv[optind] == p)
|
||||
gid = my_getgrnam(argv[optind]);
|
||||
} else {
|
||||
error_msg_and_die(too_few_args);
|
||||
}
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
while (++optind < argc) {
|
||||
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, NULL) == FALSE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,85 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (!parse_mode((char *)junk, &(statbuf->st_mode)))
|
||||
error_msg_and_die("internal error");
|
||||
if (chmod(fileName, statbuf->st_mode) == 0)
|
||||
return (TRUE);
|
||||
perror(fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chmod_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int opt;
|
||||
int recursiveFlag = FALSE;
|
||||
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > optind && argc > 2 && argv[optind]) {
|
||||
/* Parse the specified mode */
|
||||
mode_t mode;
|
||||
if (parse_mode(argv[optind], &mode) == FALSE) {
|
||||
error_msg_and_die( "unknown mode: %s", argv[optind]);
|
||||
}
|
||||
} else {
|
||||
error_msg_and_die(too_few_args);
|
||||
}
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
for (i = optind + 1; i < argc; i++) {
|
||||
if (recursive_action (argv[i], recursiveFlag, FALSE, FALSE, fileAction,
|
||||
fileAction, argv[optind]) == FALSE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,113 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Don't use lchown for libc5 or glibc older then 2.1.x */
|
||||
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
|
||||
#define lchown chown
|
||||
#endif
|
||||
|
||||
static long uid;
|
||||
static long gid;
|
||||
|
||||
static int (*chown_func)() = chown;
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (chown_func(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
perror(fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chown_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
int recursiveFlag = FALSE,
|
||||
noderefFlag = FALSE;
|
||||
char *groupName=NULL;
|
||||
char *p=NULL;
|
||||
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "Rh")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
case 'h':
|
||||
noderefFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (noderefFlag) chown_func = lchown;
|
||||
|
||||
if (argc > optind && argc > 2 && argv[optind]) {
|
||||
/* First, check if there is a group name here */
|
||||
groupName = strchr(argv[optind], '.');
|
||||
if (groupName == NULL)
|
||||
groupName = strchr(argv[optind], ':');
|
||||
if (groupName) {
|
||||
*groupName++ = '\0';
|
||||
gid = strtoul(groupName, &p, 10);
|
||||
if (groupName == p)
|
||||
gid = my_getgrnam(groupName);
|
||||
} else {
|
||||
gid = -1;
|
||||
}
|
||||
/* Now check for the username */
|
||||
uid = strtoul(argv[optind], &p, 10); /* Is is numeric? */
|
||||
if (argv[optind] == p) {
|
||||
uid = my_getpwnam(argv[optind]);
|
||||
}
|
||||
} else {
|
||||
error_msg_and_die(too_few_args);
|
||||
}
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
while (++optind < argc) {
|
||||
if (recursive_action (argv[optind], recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, NULL) == FALSE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
+10
-6
@@ -3,7 +3,7 @@
|
||||
* Mini chroot implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,23 +22,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
char *prog;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(chroot_usage);
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
error_msg_and_die("cannot change root directory to %s: %s\n", *argv, strerror(errno));
|
||||
perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
@@ -53,11 +54,14 @@ int chroot_main(int argc, char **argv)
|
||||
prog = "/bin/sh";
|
||||
execlp(prog, prog, NULL);
|
||||
#else
|
||||
shell_main(argc, argv);
|
||||
char shell[] = "/bin/sh";
|
||||
char *shell_argv[2] = { shell, NULL };
|
||||
applet_name = shell;
|
||||
shell_main(1, shell_argv);
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
error_msg_and_die("cannot execute %s: %s\n", prog, strerror(errno));
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
}
|
||||
|
||||
|
||||
+26
-11
@@ -3,7 +3,7 @@
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,31 +22,46 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int cmp_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp1 = NULL, *fp2 = stdin;
|
||||
char *filename1 = argv[1], *filename2 = "-";
|
||||
int c1, c2, char_pos = 1, line_pos = 1;
|
||||
char *filename1, *filename2 = "-";
|
||||
int c, c1, c2, char_pos = 1, line_pos = 1, silent = FALSE;
|
||||
|
||||
/* parse argv[] */
|
||||
if (argc < 2 || 3 < argc)
|
||||
usage(cmp_usage);
|
||||
while ((c = getopt(argc, argv, "s")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
silent = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
fp1 = xfopen(argv[1], "r");
|
||||
if (argv[2] != NULL) {
|
||||
fp2 = xfopen(argv[2], "r");
|
||||
filename2 = argv[2];
|
||||
filename1 = argv[optind];
|
||||
switch (argc - optind) {
|
||||
case 2:
|
||||
fp2 = xfopen(filename2 = argv[optind + 1], "r");
|
||||
case 1:
|
||||
fp1 = xfopen(filename1, "r");
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
|
||||
do {
|
||||
c1 = fgetc(fp1);
|
||||
c2 = fgetc(fp2);
|
||||
if (c1 != c2) {
|
||||
if (silent)
|
||||
return EXIT_FAILURE;
|
||||
if (c1 == EOF)
|
||||
printf("EOF on %s\n", filename1);
|
||||
else if (c2 == EOF)
|
||||
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini cp implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <utime.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
extern int cp_main(int argc, char **argv)
|
||||
{
|
||||
int status = 0;
|
||||
int opt;
|
||||
int flags = 0;
|
||||
int i;
|
||||
|
||||
while ((opt = getopt(argc, argv, "adfipR")) != -1)
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
flags |= FILEUTILS_PRESERVE_STATUS | FILEUTILS_RECUR;
|
||||
/* fallthrough */
|
||||
case 'd':
|
||||
flags |= FILEUTILS_PRESERVE_SYMLINKS;
|
||||
break;
|
||||
case 'f':
|
||||
flags |= FILEUTILS_FORCE;
|
||||
break;
|
||||
case 'i':
|
||||
flags |= FILEUTILS_INTERACTIVE;
|
||||
break;
|
||||
case 'p':
|
||||
flags |= FILEUTILS_PRESERVE_STATUS;
|
||||
break;
|
||||
case 'R':
|
||||
flags |= FILEUTILS_RECUR;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if (optind + 2 > argc)
|
||||
show_usage();
|
||||
|
||||
/* If there are only two arguments and... */
|
||||
if (optind + 2 == argc) {
|
||||
struct stat source_stat;
|
||||
struct stat dest_stat;
|
||||
int source_exists = 1;
|
||||
int dest_exists = 1;
|
||||
|
||||
if (((flags & FILEUTILS_PRESERVE_SYMLINKS) &&
|
||||
lstat(argv[optind], &source_stat) < 0) ||
|
||||
(!(flags & FILEUTILS_PRESERVE_SYMLINKS) &&
|
||||
stat(argv[optind], &source_stat))) {
|
||||
if (errno != ENOENT)
|
||||
perror_msg_and_die("unable to stat `%s'", argv[optind]);
|
||||
source_exists = 0;
|
||||
}
|
||||
|
||||
if (stat(argv[optind + 1], &dest_stat) < 0) {
|
||||
if (errno != ENOENT)
|
||||
perror_msg_and_die("unable to stat `%s'", argv[optind + 1]);
|
||||
dest_exists = 0;
|
||||
}
|
||||
|
||||
/* ...if neither is a directory or... */
|
||||
if (((!source_exists || !S_ISDIR(source_stat.st_mode)) &&
|
||||
(!dest_exists || !S_ISDIR(dest_stat.st_mode))) ||
|
||||
/* ...recursing, the first is a directory, and the
|
||||
* second doesn't exist, then... */
|
||||
((flags & FILEUTILS_RECUR) && S_ISDIR(source_stat.st_mode) &&
|
||||
!dest_exists)) {
|
||||
/* ...do a simple copy. */
|
||||
if (copy_file(argv[optind], argv[optind + 1], flags) < 0)
|
||||
status = 1;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = optind; i < argc - 1; i++) {
|
||||
char *dest = concat_path_file(argv[argc - 1],
|
||||
get_last_path_component(argv[i]));
|
||||
if (copy_file(argv[i], dest, flags) < 0)
|
||||
status = 1;
|
||||
free(dest);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
+241
-128
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* cut.c - minimalist version of cut
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Written by Mark Whitley <markw@lineo.com>, <markw@enol.com>
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Mark Whitley <markw@lineo.com>, <markw@codepoet.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -24,8 +24,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h> /* getopt */
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
@@ -34,65 +33,228 @@ extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
|
||||
/* globals in this file only */
|
||||
/* option vars */
|
||||
static char part = 0; /* (b)yte, (c)har, (f)ields */
|
||||
static int startpos = 1;
|
||||
static int endpos = -1;
|
||||
static char delim = '\t'; /* delimiter, default is tab */
|
||||
static unsigned int supress_non_delimited_lines = 0;
|
||||
static char delim = '\t'; /* delimiter, default is tab */
|
||||
|
||||
struct cut_list {
|
||||
int startpos;
|
||||
int endpos;
|
||||
};
|
||||
|
||||
static const int BOL = 0;
|
||||
static const int EOL = INT_MAX;
|
||||
static const int NON_RANGE = -1;
|
||||
|
||||
static struct cut_list *cut_lists = NULL; /* growable array holding a series of lists */
|
||||
static unsigned int nlists = 0; /* number of elements in above list */
|
||||
|
||||
|
||||
static int cmpfunc(const void *a, const void *b)
|
||||
{
|
||||
struct cut_list *la = (struct cut_list *)a;
|
||||
struct cut_list *lb = (struct cut_list *)b;
|
||||
|
||||
if (la->startpos > lb->startpos)
|
||||
return 1;
|
||||
if (la->startpos < lb->startpos)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* decompose_list() - parses a list and puts values into startpos and endpos.
|
||||
* parse_lists() - parses a list and puts values into startpos and endpos.
|
||||
* valid list formats: N, N-, N-M, -M
|
||||
* more than one list can be seperated by commas
|
||||
*/
|
||||
static void decompose_list(const char *list)
|
||||
static void parse_lists(char *lists)
|
||||
{
|
||||
unsigned int nminus = 0;
|
||||
char *ptr;
|
||||
char *ltok = NULL;
|
||||
char *ntok = NULL;
|
||||
char *junk;
|
||||
int s = 0, e = 0;
|
||||
|
||||
/* the list must contain only digits and no more than one minus sign */
|
||||
for (ptr = (char *)list; *ptr; ptr++) {
|
||||
if (!isdigit(*ptr) && *ptr != '-') {
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
/* take apart the lists, one by one (they are seperated with commas */
|
||||
while ((ltok = strsep(&lists, ",")) != NULL) {
|
||||
|
||||
/* it's actually legal to pass an empty list */
|
||||
if (strlen(ltok) == 0)
|
||||
continue;
|
||||
|
||||
/* get the start pos */
|
||||
ntok = strsep(<ok, "-");
|
||||
if (ntok == NULL) {
|
||||
fprintf(stderr, "Help ntok is null for starting position! What do I do?\n");
|
||||
} else if (strlen(ntok) == 0) {
|
||||
s = BOL;
|
||||
} else {
|
||||
s = strtoul(ntok, &junk, 10);
|
||||
if(*junk != '\0' || s < 0)
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
|
||||
/* account for the fact that arrays are zero based, while the user
|
||||
* expects the first char on the line to be char # 1 */
|
||||
if (s != 0)
|
||||
s--;
|
||||
}
|
||||
if (*ptr == '-') {
|
||||
nminus++;
|
||||
if (nminus > 1) {
|
||||
error_msg_and_die("invalid byte or field list\n");
|
||||
|
||||
/* get the end pos */
|
||||
ntok = strsep(<ok, "-");
|
||||
if (ntok == NULL) {
|
||||
e = NON_RANGE;
|
||||
} else if (strlen(ntok) == 0) {
|
||||
e = EOL;
|
||||
} else {
|
||||
e = strtoul(ntok, &junk, 10);
|
||||
if(*junk != '\0' || e < 0)
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
/* if the user specified and end position of 0, that means "til the
|
||||
* end of the line */
|
||||
if (e == 0)
|
||||
e = INT_MAX;
|
||||
e--; /* again, arrays are zero based, lines are 1 based */
|
||||
if (e == s)
|
||||
e = NON_RANGE;
|
||||
}
|
||||
|
||||
/* if there's something left to tokenize, the user past an invalid list */
|
||||
if (ltok)
|
||||
error_msg_and_die("invalid byte or field list");
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* make sure we got some cut positions out of all that */
|
||||
if (nlists == 0)
|
||||
error_msg_and_die("missing list of positions");
|
||||
|
||||
/* now that the lists are parsed, we need to sort them to make life easier
|
||||
* on us when it comes time to print the chars / fields / lines */
|
||||
qsort(cut_lists, nlists, sizeof(struct cut_list), cmpfunc);
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void cut_line_by_chars(const char *line)
|
||||
{
|
||||
int c, l;
|
||||
/* set up a list so we can keep track of what's been printed */
|
||||
char *printed = xcalloc(strlen(line), sizeof(char));
|
||||
|
||||
/* print the chars specified in each cut list */
|
||||
for (c = 0; c < nlists; c++) {
|
||||
l = cut_lists[c].startpos;
|
||||
while (l < strlen(line)) {
|
||||
if (!printed[l]) {
|
||||
putchar(line[l]);
|
||||
printed[l] = 'X';
|
||||
}
|
||||
l++;
|
||||
if (cut_lists[c].endpos == NON_RANGE || l > cut_lists[c].endpos)
|
||||
break;
|
||||
}
|
||||
}
|
||||
putchar('\n'); /* cuz we were handed a chomped line */
|
||||
free(printed);
|
||||
}
|
||||
|
||||
|
||||
static void cut_line_by_fields(char *line)
|
||||
{
|
||||
int c, f;
|
||||
int ndelim = -1; /* zero-based / one-based problem */
|
||||
int nfields_printed = 0;
|
||||
char *field = NULL;
|
||||
char d[2] = { delim, 0 };
|
||||
char *printed;
|
||||
|
||||
/* test the easy case first: does this line contain any delimiters? */
|
||||
if (strchr(line, delim) == NULL) {
|
||||
if (!supress_non_delimited_lines)
|
||||
puts(line);
|
||||
return;
|
||||
}
|
||||
|
||||
/* set up a list so we can keep track of what's been printed */
|
||||
printed = xcalloc(strlen(line), sizeof(char));
|
||||
|
||||
/* process each list on this line, for as long as we've got a line to process */
|
||||
for (c = 0; c < nlists && line; c++) {
|
||||
f = cut_lists[c].startpos;
|
||||
do {
|
||||
|
||||
/* find the field we're looking for */
|
||||
while (line && ndelim < f) {
|
||||
field = strsep(&line, d);
|
||||
ndelim++;
|
||||
}
|
||||
|
||||
/* we found it, and it hasn't been printed yet */
|
||||
if (field && ndelim == f && !printed[ndelim]) {
|
||||
/* if this isn't our first time through, we need to print the
|
||||
* delimiter after the last field that was printed */
|
||||
if (nfields_printed > 0)
|
||||
putchar(delim);
|
||||
fputs(field, stdout);
|
||||
printed[ndelim] = 'X';
|
||||
nfields_printed++;
|
||||
}
|
||||
|
||||
f++;
|
||||
|
||||
/* keep going as long as we have a line to work with, this is a
|
||||
* list, and we're not at the end of that list */
|
||||
} while (line && cut_lists[c].endpos != NON_RANGE && f <= cut_lists[c].endpos);
|
||||
}
|
||||
|
||||
/* if we printed anything at all, we need to finish it with a newline cuz
|
||||
* we were handed a chomped line */
|
||||
putchar('\n');
|
||||
|
||||
free(printed);
|
||||
}
|
||||
|
||||
|
||||
static void cut_file_by_lines(const char *line, unsigned int linenum)
|
||||
{
|
||||
static int c = 0;
|
||||
static int l = -1;
|
||||
|
||||
/* I can't initialize this above cuz the "initializer isn't
|
||||
* constant" *sigh* */
|
||||
if (l == -1)
|
||||
l = cut_lists[c].startpos;
|
||||
|
||||
/* get out if we have no more lists to process or if the lines are lower
|
||||
* than what we're interested in */
|
||||
if (c >= nlists || linenum < l)
|
||||
return;
|
||||
|
||||
/* if the line we're looking for is lower than the one we were passed, it
|
||||
* means we displayed it already, so move on */
|
||||
while (l < linenum) {
|
||||
l++;
|
||||
/* move on to the next list if we're at the end of this one */
|
||||
if (cut_lists[c].endpos == NON_RANGE || l > cut_lists[c].endpos) {
|
||||
c++;
|
||||
/* get out if there's no more lists to process */
|
||||
if (c >= nlists)
|
||||
return;
|
||||
l = cut_lists[c].startpos;
|
||||
/* get out if the current line is lower than the one we just became
|
||||
* interested in */
|
||||
if (linenum < l)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* handle single value 'N' case */
|
||||
if (nminus == 0) {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
if (startpos == 0) {
|
||||
error_msg_and_die("missing list of fields\n");
|
||||
}
|
||||
endpos = startpos;
|
||||
}
|
||||
/* handle multi-value cases */
|
||||
else if (nminus == 1) {
|
||||
/* handle 'N-' case */
|
||||
if (list[strlen(list) - 1] == '-') {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
}
|
||||
/* handle '-M' case */
|
||||
else if (list[0] == '-') {
|
||||
endpos = strtol(&list[1], NULL, 10);
|
||||
}
|
||||
/* handle 'N-M' case */
|
||||
else {
|
||||
startpos = strtol(list, &ptr, 10);
|
||||
endpos = strtol(ptr+1, &ptr, 10);
|
||||
}
|
||||
|
||||
/* a sanity check */
|
||||
if (startpos == 0) {
|
||||
startpos = 1;
|
||||
}
|
||||
}
|
||||
/* If we made it here, it means we've found the line we're looking for, so print it */
|
||||
puts(line);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,82 +263,31 @@ static void decompose_list(const char *list)
|
||||
*/
|
||||
static void cut_file(FILE *file)
|
||||
{
|
||||
char *line;
|
||||
unsigned int cr_hits = 0;
|
||||
char *line = NULL;
|
||||
unsigned int linenum = 0; /* keep these zero-based to be consistent */
|
||||
|
||||
/* go through every line in the file */
|
||||
for (line = NULL; (line = get_line_from_file(file)) != NULL; free(line)) {
|
||||
/* cut based on chars/bytes */
|
||||
if (part == 'c' || part == 'b') {
|
||||
int i;
|
||||
/* a valid end position has been specified */
|
||||
if (endpos > 0) {
|
||||
for (i = startpos-1; i < endpos; i++) {
|
||||
fputc(line[i], stdout);
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* otherwise, just go to the end of the line */
|
||||
else {
|
||||
for (i = startpos-1; line[i]; i++) {
|
||||
fputc(line[i], stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
while ((line = get_line_from_file(file)) != NULL) {
|
||||
chomp(line);
|
||||
|
||||
/* cut based on chars/bytes XXX: only works when sizeof(char) == byte */
|
||||
if (part == 'c' || part == 'b')
|
||||
cut_line_by_chars(line);
|
||||
|
||||
/* cut based on fields */
|
||||
else if (part == 'f') {
|
||||
char *ptr;
|
||||
char *start = line;
|
||||
unsigned int delims_hit = 0;
|
||||
|
||||
if (delim == '\n') {
|
||||
cr_hits++;
|
||||
if (cr_hits >= startpos && cr_hits <= endpos) {
|
||||
while (*start && *start != '\n') {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (ptr = line; (ptr = strchr(ptr, delim)) != NULL; ptr++) {
|
||||
delims_hit++;
|
||||
if (delims_hit == (startpos - 1)) {
|
||||
start = ptr+1;
|
||||
}
|
||||
if (delims_hit == endpos) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* we didn't hit any delimeters */
|
||||
if (delims_hit == 0 && !supress_non_delimited_lines) {
|
||||
fputs(line, stdout);
|
||||
}
|
||||
/* we =did= hit some delimiters */
|
||||
else if (delims_hit > 0) {
|
||||
/* we have a fixed end point */
|
||||
if (ptr) {
|
||||
while (start < ptr) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
fputc('\n', stdout);
|
||||
}
|
||||
/* or we're just going til the end of the line */
|
||||
else {
|
||||
while (*start) {
|
||||
fputc(*start, stdout);
|
||||
start++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (delim == '\n')
|
||||
cut_file_by_lines(line, linenum);
|
||||
else
|
||||
cut_line_by_fields(line);
|
||||
}
|
||||
|
||||
linenum++;
|
||||
free(line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extern int cut_main(int argc, char **argv)
|
||||
{
|
||||
int opt;
|
||||
@@ -191,11 +302,11 @@ extern int cut_main(int argc, char **argv)
|
||||
error_msg_and_die("only one type of list may be specified");
|
||||
}
|
||||
part = (char)opt;
|
||||
decompose_list(optarg);
|
||||
parse_lists(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
if (strlen(optarg) > 1) {
|
||||
error_msg_and_die("the delimiter must be a single character\n");
|
||||
error_msg_and_die("the delimiter must be a single character");
|
||||
}
|
||||
delim = optarg[0];
|
||||
break;
|
||||
@@ -209,16 +320,18 @@ extern int cut_main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (part == 0) {
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields\n");
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields");
|
||||
}
|
||||
|
||||
if (supress_non_delimited_lines && part != 'f') {
|
||||
error_msg_and_die("suppressing non-delimited lines makes sense
|
||||
only when operating on fields\n");
|
||||
}
|
||||
|
||||
if (delim != '\t' && part != 'f') {
|
||||
error_msg_and_die("a delimiter may be specified only when operating on fields\n");
|
||||
/* non-field (char or byte) cutting has some special handling */
|
||||
if (part != 'f') {
|
||||
if (supress_non_delimited_lines) {
|
||||
error_msg_and_die("suppressing non-delimited lines makes sense"
|
||||
" only when operating on fields");
|
||||
}
|
||||
if (delim != '\t' && part != 'f') {
|
||||
error_msg_and_die("a delimiter may be specified only when operating on fields");
|
||||
}
|
||||
}
|
||||
|
||||
/* argv[(optind)..(argc-1)] should be names of file to process. If no
|
||||
@@ -233,7 +346,7 @@ extern int cut_main(int argc, char **argv)
|
||||
for (i = optind; i < argc; i++) {
|
||||
file = fopen(argv[i], "r");
|
||||
if (file == NULL) {
|
||||
error_msg("%s: %s\n", argv[i], strerror(errno));
|
||||
perror_msg("%s", argv[i]);
|
||||
} else {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
|
||||
+10
-13
@@ -20,18 +20,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_invalid_date
|
||||
#define bb_need_memory_exhausted
|
||||
#include "messages.c"
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* This 'date' command supports only 2 time setting formats,
|
||||
@@ -45,7 +42,7 @@
|
||||
|
||||
/* Default input handling to save suprising some people */
|
||||
|
||||
struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
int nr;
|
||||
|
||||
@@ -72,7 +69,7 @@ struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
|
||||
/* The new stuff for LRP */
|
||||
|
||||
struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
struct tm t;
|
||||
|
||||
@@ -150,7 +147,7 @@ int date_main(int argc, char **argv)
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
|
||||
usage(date_usage);
|
||||
show_usage();
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
@@ -161,10 +158,10 @@ int date_main(int argc, char **argv)
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
usage(date_usage);
|
||||
show_usage();
|
||||
break;
|
||||
default:
|
||||
usage(date_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +174,7 @@ int date_main(int argc, char **argv)
|
||||
#if 0
|
||||
else {
|
||||
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
|
||||
usage(date_usage);
|
||||
show_usage();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -202,7 +199,7 @@ int date_main(int argc, char **argv)
|
||||
date_conv_time(&tm_time, date_str);
|
||||
}
|
||||
|
||||
/* Correct any day of week and day of year etc fields */
|
||||
/* Correct any day of week and day of year etc. fields */
|
||||
tm = mktime(&tm_time);
|
||||
if (tm < 0)
|
||||
error_msg_and_die(invalid_date, date_str);
|
||||
@@ -244,7 +241,7 @@ int date_main(int argc, char **argv)
|
||||
/* Print OUTPUT (after ALL that!) */
|
||||
t_buff = xmalloc(201);
|
||||
strftime(t_buff, 200, date_fmt, &tm_time);
|
||||
printf("%s\n", t_buff);
|
||||
puts(t_buff);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+115
-138
@@ -2,15 +2,8 @@
|
||||
/*
|
||||
* Mini dd implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999, 2000 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* Based in part on code taken from sash.
|
||||
* Copyright (c) 1999 by David I. Bell
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* Permission to distribute this code under the GPL has been granted.
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -28,154 +21,138 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include "busybox.h"
|
||||
#include <features.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
|
||||
#include <inttypes.h>
|
||||
#else
|
||||
typedef unsigned long long int uintmax_t;
|
||||
#endif
|
||||
#include "busybox.h"
|
||||
|
||||
extern int dd_main(int argc, char **argv)
|
||||
|
||||
static const struct suffix_mult dd_suffixes[] = {
|
||||
{ "c", 1 },
|
||||
{ "w", 2 },
|
||||
{ "b", 512 },
|
||||
{ "kD", 1000 },
|
||||
{ "k", 1024 },
|
||||
{ "MD", 1000000 },
|
||||
{ "M", 1048576 },
|
||||
{ "GD", 1000000000 },
|
||||
{ "G", 1073741824 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
int dd_main(int argc, char **argv)
|
||||
{
|
||||
char *inFile = NULL;
|
||||
char *outFile = NULL;
|
||||
int inFd;
|
||||
int outFd;
|
||||
int inCc = 0;
|
||||
int outCc;
|
||||
int trunc=TRUE;
|
||||
int sync=FALSE;
|
||||
long blockSize = 512,ibs;
|
||||
uintmax_t skipBlocks = 0;
|
||||
uintmax_t seekBlocks = 0;
|
||||
uintmax_t count = (uintmax_t) - 1;
|
||||
uintmax_t inTotal = 0;
|
||||
uintmax_t outTotal = 0;
|
||||
uintmax_t totalSize;
|
||||
int i, ifd, ofd, oflag, sync_flag = FALSE, trunc = TRUE;
|
||||
size_t in_full = 0, in_part = 0, out_full = 0, out_part = 0;
|
||||
size_t bs = 512, count = -1;
|
||||
ssize_t n;
|
||||
off_t seek = 0, skip = 0;
|
||||
FILE *statusfp;
|
||||
char *infile = NULL, *outfile = NULL, *buf;
|
||||
|
||||
unsigned char buf[BUFSIZ];
|
||||
char *keyword = NULL;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strncmp("bs=", argv[i], 3) == 0)
|
||||
bs = parse_number(argv[i]+3, dd_suffixes);
|
||||
else if (strncmp("count=", argv[i], 6) == 0)
|
||||
count = parse_number(argv[i]+6, dd_suffixes);
|
||||
else if (strncmp("seek=", argv[i], 5) == 0)
|
||||
seek = parse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("skip=", argv[i], 5) == 0)
|
||||
skip = parse_number(argv[i]+5, dd_suffixes);
|
||||
else if (strncmp("if=", argv[i], 3) == 0)
|
||||
infile = argv[i]+3;
|
||||
else if (strncmp("of=", argv[i], 3) == 0)
|
||||
outfile = argv[i]+3;
|
||||
else if (strncmp("conv=", argv[i], 5) == 0) {
|
||||
buf = argv[i]+5;
|
||||
while (1) {
|
||||
if (strncmp("notrunc", buf, 7) == 0) {
|
||||
trunc = FALSE;
|
||||
buf += 7;
|
||||
} else if (strncmp("sync", buf, 4) == 0) {
|
||||
sync_flag = TRUE;
|
||||
buf += 4;
|
||||
} else {
|
||||
error_msg_and_die("invalid conversion `%s'", argv[i]+5);
|
||||
}
|
||||
if (buf[0] == '\0')
|
||||
break;
|
||||
if (buf[0] == ',')
|
||||
buf++;
|
||||
}
|
||||
} else
|
||||
show_usage();
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
buf = xmalloc(bs);
|
||||
|
||||
/* Parse any options */
|
||||
while (argc) {
|
||||
if (inFile == NULL && (strncmp(*argv, "if", 2) == 0))
|
||||
inFile = ((strchr(*argv, '=')) + 1);
|
||||
else if (outFile == NULL && (strncmp(*argv, "of", 2) == 0))
|
||||
outFile = ((strchr(*argv, '=')) + 1);
|
||||
else if (strncmp("count", *argv, 5) == 0) {
|
||||
count = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (count < 0) {
|
||||
error_msg("Bad count value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "bs", 2) == 0) {
|
||||
blockSize = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (blockSize <= 0) {
|
||||
error_msg("Bad block size value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "skip", 4) == 0) {
|
||||
skipBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (skipBlocks <= 0) {
|
||||
error_msg("Bad skip value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
if (infile != NULL) {
|
||||
if ((ifd = open(infile, O_RDONLY)) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
} else {
|
||||
ifd = STDIN_FILENO;
|
||||
infile = "standard input";
|
||||
}
|
||||
|
||||
} else if (strncmp(*argv, "seek", 4) == 0) {
|
||||
seekBlocks = atoi_w_units((strchr(*argv, '=')) + 1);
|
||||
if (seekBlocks <= 0) {
|
||||
error_msg("Bad seek value %s\n", *argv);
|
||||
goto usage;
|
||||
}
|
||||
} else if (strncmp(*argv, "conv", 4) == 0) {
|
||||
keyword = (strchr(*argv, '=') + 1);
|
||||
if (strcmp(keyword, "notrunc") == 0)
|
||||
trunc=FALSE;
|
||||
if (strcmp(keyword, "sync") == 0)
|
||||
sync=TRUE;
|
||||
} else {
|
||||
goto usage;
|
||||
if (outfile != NULL) {
|
||||
oflag = O_WRONLY | O_CREAT;
|
||||
|
||||
if (!seek && trunc)
|
||||
oflag |= O_TRUNC;
|
||||
|
||||
if ((ofd = open(outfile, oflag, 0666)) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
|
||||
if (seek && trunc) {
|
||||
if (ftruncate(ofd, seek * bs) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
statusfp = stdout;
|
||||
} else {
|
||||
ofd = STDOUT_FILENO;
|
||||
outfile = "standard output";
|
||||
statusfp = stderr;
|
||||
}
|
||||
|
||||
if (inFile == NULL)
|
||||
inFd = fileno(stdin);
|
||||
else
|
||||
inFd = open(inFile, 0);
|
||||
|
||||
if (inFd < 0) {
|
||||
/* Note that we are not freeing buf or closing
|
||||
* files here to save a few bytes. This exits
|
||||
* here anyways... */
|
||||
|
||||
/* free(buf); */
|
||||
perror_msg_and_die("%s", inFile);
|
||||
if (skip) {
|
||||
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
}
|
||||
|
||||
if (outFile == NULL)
|
||||
outFd = fileno(stdout);
|
||||
else
|
||||
outFd = open(outFile, O_WRONLY | O_CREAT, 0666);
|
||||
|
||||
if (outFd < 0) {
|
||||
/* Note that we are not freeing buf or closing
|
||||
* files here to save a few bytes. This exits
|
||||
* here anyways... */
|
||||
|
||||
/* close(inFd);
|
||||
free(buf); */
|
||||
perror_msg_and_die("%s", outFile);
|
||||
if (seek) {
|
||||
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
|
||||
lseek(inFd, (off_t) (skipBlocks * blockSize), SEEK_SET);
|
||||
lseek(outFd, (off_t) (seekBlocks * blockSize), SEEK_SET);
|
||||
totalSize=count*blockSize;
|
||||
|
||||
ibs=blockSize;
|
||||
if (ibs > BUFSIZ)
|
||||
ibs=BUFSIZ;
|
||||
|
||||
while (totalSize > outTotal) {
|
||||
inCc = full_read(inFd, buf, ibs);
|
||||
inTotal += inCc;
|
||||
if ( (sync==TRUE) && (inCc>0) )
|
||||
while (inCc<ibs)
|
||||
buf[inCc++]='\0';
|
||||
|
||||
if ((outCc = full_write(outFd, buf, inCc)) < 1){
|
||||
if (outCc < 0 ){
|
||||
perror("Error during write");
|
||||
}
|
||||
while (in_full + in_part != count) {
|
||||
n = safe_read(ifd, buf, bs);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
if (n == 0)
|
||||
break;
|
||||
if (n == bs)
|
||||
in_full++;
|
||||
else
|
||||
in_part++;
|
||||
if (sync_flag) {
|
||||
memset(buf + n, '\0', bs - n);
|
||||
n = bs;
|
||||
}
|
||||
outTotal += outCc;
|
||||
}
|
||||
if (trunc == TRUE) {
|
||||
ftruncate(outFd, lseek(outFd, 0, SEEK_CUR));
|
||||
n = full_write(ofd, buf, n);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
if (n == bs)
|
||||
out_full++;
|
||||
else
|
||||
out_part++;
|
||||
}
|
||||
/* Note that we are not freeing memory or closing
|
||||
* files here, to save a few bytes. */
|
||||
#ifdef BB_FEATURE_CLEAN_UP
|
||||
close(inFd);
|
||||
close(outFd);
|
||||
#endif
|
||||
|
||||
printf("%ld+%d records in\n", (long) (inTotal / blockSize),
|
||||
(inTotal % blockSize) != 0);
|
||||
printf("%ld+%d records out\n", (long) (outTotal / blockSize),
|
||||
(outTotal % blockSize) != 0);
|
||||
fprintf(statusfp, "%ld+%ld records in\n", (long)in_full, (long)in_part);
|
||||
fprintf(statusfp, "%ld+%ld records out\n", (long)out_full, (long)out_part);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
usage:
|
||||
|
||||
usage(dd_usage);
|
||||
}
|
||||
+81
-35
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini df implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* based on original code by (I think) Bruce Perens <bruce@pixar.com>.
|
||||
*
|
||||
@@ -22,40 +22,63 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/vfs.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern const char mtab_file[]; /* Defined in utility.c */
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
static unsigned long df_disp_hr = KILOBYTE;
|
||||
#endif
|
||||
|
||||
static int df(char *device, const char *mountPoint)
|
||||
static int do_df(char *device, const char *mount_point)
|
||||
{
|
||||
struct statfs s;
|
||||
long blocks_used;
|
||||
long blocks_percent_used;
|
||||
|
||||
if (statfs(mountPoint, &s) != 0) {
|
||||
perror_msg("%s", mountPoint);
|
||||
if (statfs(mount_point, &s) != 0) {
|
||||
perror_msg("%s", mount_point);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (s.f_blocks > 0) {
|
||||
blocks_used = s.f_blocks - s.f_bfree;
|
||||
blocks_percent_used = (long)
|
||||
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
|
||||
if(blocks_used == 0)
|
||||
blocks_percent_used = 0;
|
||||
else {
|
||||
blocks_percent_used = (long)
|
||||
(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
|
||||
}
|
||||
if (strcmp(device, "/dev/root") == 0) {
|
||||
/* Adjusts device to be the real root device,
|
||||
* or leaves device alone if it can't find it */
|
||||
find_real_root_device_name( device);
|
||||
device = find_real_root_device_name(device);
|
||||
if(device==NULL)
|
||||
return FALSE;
|
||||
}
|
||||
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
||||
device,
|
||||
(long) (s.f_blocks * (s.f_bsize / 1024.0)),
|
||||
(long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)),
|
||||
(long) (s.f_bavail * (s.f_bsize / 1024.0)),
|
||||
blocks_percent_used, mountPoint);
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
printf("%-20s %9s ", device,
|
||||
make_human_readable_str(s.f_blocks, s.f_bsize, df_disp_hr));
|
||||
|
||||
printf("%9s ",
|
||||
make_human_readable_str( (s.f_blocks - s.f_bfree), s.f_bsize, df_disp_hr));
|
||||
|
||||
printf("%9s %3ld%% %s\n",
|
||||
make_human_readable_str(s.f_bavail, s.f_bsize, df_disp_hr),
|
||||
blocks_percent_used, mount_point);
|
||||
#else
|
||||
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
|
||||
device,
|
||||
(long) (s.f_blocks * (s.f_bsize / (double)KILOBYTE)),
|
||||
(long) ((s.f_blocks - s.f_bfree)*(s.f_bsize/(double)KILOBYTE)),
|
||||
(long) (s.f_bavail * (s.f_bsize / (double)KILOBYTE)),
|
||||
blocks_percent_used, mount_point);
|
||||
#endif
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@@ -64,40 +87,63 @@ static int df(char *device, const char *mountPoint)
|
||||
extern int df_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int opt = 0;
|
||||
int i = 0;
|
||||
char disp_units_hdr[80] = "1k-blocks"; /* default display is kilobytes */
|
||||
|
||||
printf("%-20s %-14s %s %s %s %s\n", "Filesystem",
|
||||
"1k-blocks", "Used", "Available", "Use%", "Mounted on");
|
||||
|
||||
if (argc > 1) {
|
||||
struct mntent *mountEntry;
|
||||
|
||||
if (**(argv + 1) == '-') {
|
||||
usage(df_usage);
|
||||
while ((opt = getopt(argc, argv, "k"
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
)) > 0)
|
||||
{
|
||||
switch (opt) {
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
case 'h':
|
||||
df_disp_hr = 0;
|
||||
strcpy(disp_units_hdr, " Size");
|
||||
break;
|
||||
case 'm':
|
||||
df_disp_hr = MEGABYTE;
|
||||
strcpy(disp_units_hdr, "1M-blocks");
|
||||
break;
|
||||
#endif
|
||||
case 'k':
|
||||
/* default display is kilobytes */
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
while (argc > 1) {
|
||||
if ((mountEntry = find_mount_point(argv[1], mtab_file)) == 0) {
|
||||
error_msg("%s: can't find mount point.\n", argv[1]);
|
||||
}
|
||||
|
||||
printf("%-20s %-14s %s %s %s %s\n", "Filesystem", disp_units_hdr,
|
||||
"Used", "Available", "Use%", "Mounted on");
|
||||
|
||||
if(optind < argc) {
|
||||
struct mntent *mount_entry;
|
||||
for(i = optind; i < argc; i++)
|
||||
{
|
||||
if ((mount_entry = find_mount_point(argv[i], mtab_file)) == 0) {
|
||||
error_msg("%s: can't find mount point.", argv[i]);
|
||||
status = EXIT_FAILURE;
|
||||
} else if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
|
||||
} else if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
} else {
|
||||
FILE *mountTable;
|
||||
struct mntent *mountEntry;
|
||||
FILE *mount_table;
|
||||
struct mntent *mount_entry;
|
||||
|
||||
mountTable = setmntent(mtab_file, "r");
|
||||
if (mountTable == 0) {
|
||||
mount_table = setmntent(mtab_file, "r");
|
||||
if (mount_table == 0) {
|
||||
perror_msg("%s", mtab_file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while ((mountEntry = getmntent(mountTable))) {
|
||||
if (!df(mountEntry->mnt_fsname, mountEntry->mnt_dir))
|
||||
while ((mount_entry = getmntent(mount_table))) {
|
||||
if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
endmntent(mountTable);
|
||||
endmntent(mount_table);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
+10
-15
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini dirname implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -20,26 +20,21 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include "busybox.h"
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int dirname_main(int argc, char **argv)
|
||||
{
|
||||
char* s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-'))
|
||||
usage(dirname_usage);
|
||||
show_usage();
|
||||
argv++;
|
||||
|
||||
s=*argv+strlen(*argv)-1;
|
||||
while (s != *argv && *s == '/') {
|
||||
*s-- = '\0';
|
||||
}
|
||||
s = strrchr(*argv, '/');
|
||||
if (s != NULL && s == *argv)
|
||||
s[1] = '\0';
|
||||
else if (s != NULL)
|
||||
*s = '\0';
|
||||
puts(s ? *argv : ".");
|
||||
puts (dirname (argv[0]));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+139
-39
@@ -1,45 +1,145 @@
|
||||
/*
|
||||
Mini dos2unix implementation for busybox
|
||||
|
||||
Copyright 1994,1995 Patrick Volkerding, Moorhead, Minnesota USA
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use of this source code, with or without modification, is
|
||||
permitted provided that the following condition is met:
|
||||
|
||||
1. Redistributions of this source code must retain the above copyright
|
||||
notice, this condition, and the following disclaimer.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
* dos2unix for BusyBox
|
||||
*
|
||||
* dos2unix '\n' convertor 0.5.0
|
||||
* based on Unix2Dos 0.9.0 by Peter Hanecak (made 19.2.1997)
|
||||
* Copyright 1997,.. by Peter Hanecak <hanecak@megaloman.sk>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* dos2unix filters reading input from stdin and writing output to stdout.
|
||||
* Without arguments it reverts the format (e.i. if source is in UNIX format,
|
||||
* output is in DOS format and vice versa).
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* See the COPYING file for license information.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int dos2unix_main( int argc, char **argv ) {
|
||||
int c;
|
||||
if (argc > 1) {
|
||||
c = *argv[1];
|
||||
if (c == '-') {
|
||||
usage(dos2unix_usage);
|
||||
}
|
||||
// if fn is NULL then input is stdin and output is stdout
|
||||
static int convert(char *fn, int ConvType) {
|
||||
int c;
|
||||
char *tempFn = NULL;
|
||||
FILE *in = stdin, *out = stdout;
|
||||
|
||||
if (fn != NULL) {
|
||||
if ((in = wfopen(fn, "r")) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if ((out = tmpfile()) == NULL) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
c = getchar();
|
||||
while (c != EOF) {
|
||||
/* Eat any \r's... they shouldn't be here */
|
||||
while (c == '\r') c = getchar();
|
||||
if (c == EOF) break;
|
||||
putchar(c);
|
||||
c = getchar();
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
while ((c = fgetc(in)) != EOF) {
|
||||
if (c == '\r') {
|
||||
if ((ConvType == CT_UNIX2DOS) && (fn != NULL)) {
|
||||
// file is alredy in DOS format so it is not necessery to touch it
|
||||
if (fclose(in) < 0 || fclose(out) < 0) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (!ConvType)
|
||||
ConvType = CT_DOS2UNIX;
|
||||
break;
|
||||
}
|
||||
if (c == '\n') {
|
||||
if ((ConvType == CT_DOS2UNIX) && (fn != NULL)) {
|
||||
// file is alredy in UNIX format so it is not necessery to touch it
|
||||
if ((fclose(in) < 0) || (fclose(out) < 0)) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if (!ConvType) {
|
||||
ConvType = CT_UNIX2DOS;
|
||||
}
|
||||
if (ConvType == CT_UNIX2DOS) {
|
||||
fputc('\r', out);
|
||||
}
|
||||
fputc('\n', out);
|
||||
break;
|
||||
}
|
||||
fputc(c, out);
|
||||
}
|
||||
if (c != EOF)
|
||||
while ((c = fgetc(in)) != EOF) {
|
||||
if (c == '\r')
|
||||
continue;
|
||||
if (c == '\n') {
|
||||
if (ConvType == CT_UNIX2DOS)
|
||||
fputc('\r', out);
|
||||
fputc('\n', out);
|
||||
continue;
|
||||
}
|
||||
fputc(c, out);
|
||||
}
|
||||
|
||||
if (fn != NULL) {
|
||||
if (fclose(in) < 0 || fclose(out) < 0 ||
|
||||
(in = fopen(tempFn, "r")) == NULL || (out = fopen(fn, "w")) == NULL) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
|
||||
while ((c = fgetc(in)) != EOF) {
|
||||
fputc(c, out);
|
||||
}
|
||||
|
||||
if ((fclose(in) < 0) || (fclose(out) < 0)) {
|
||||
perror_msg(NULL);
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dos2unix_main(int argc, char *argv[]) {
|
||||
int ConvType = CT_AUTO;
|
||||
int o;
|
||||
|
||||
// process parameters
|
||||
while ((o = getopt(argc, argv, "du")) != EOF) {
|
||||
switch (o) {
|
||||
case 'd':
|
||||
ConvType = CT_UNIX2DOS;
|
||||
break;
|
||||
case 'u':
|
||||
ConvType = CT_DOS2UNIX;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
while(optind < argc)
|
||||
if ((o = convert(argv[optind++], ConvType)) < 0)
|
||||
break;
|
||||
}
|
||||
else
|
||||
o = convert(NULL, ConvType);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
+111
-29
@@ -3,7 +3,7 @@
|
||||
* Mini du implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,16 +22,20 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_name_too_long
|
||||
#include "messages.c"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
static unsigned long disp_hr = KILOBYTE;
|
||||
#endif
|
||||
|
||||
typedef void (Display) (long, char *);
|
||||
|
||||
@@ -42,7 +46,11 @@ static Display *print;
|
||||
|
||||
static void print_normal(long size, char *filename)
|
||||
{
|
||||
fprintf(stdout, "%ld\t%s\n", size, filename);
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
printf("%s\t%s\n", make_human_readable_str(size<<10, 1, disp_hr), filename);
|
||||
#else
|
||||
printf("%ld\t%s\n", size, filename);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void print_summary(long size, char *filename)
|
||||
@@ -52,15 +60,87 @@ static void print_summary(long size, char *filename)
|
||||
}
|
||||
}
|
||||
|
||||
#define HASH_SIZE 311 /* Should be prime */
|
||||
#define hash_inode(i) ((i) % HASH_SIZE)
|
||||
|
||||
typedef struct ino_dev_hash_bucket_struct {
|
||||
struct ino_dev_hash_bucket_struct *next;
|
||||
ino_t ino;
|
||||
dev_t dev;
|
||||
char name[1];
|
||||
} ino_dev_hashtable_bucket_t;
|
||||
|
||||
static ino_dev_hashtable_bucket_t *ino_dev_hashtable[HASH_SIZE];
|
||||
|
||||
/*
|
||||
* Return 1 if statbuf->st_ino && statbuf->st_dev are recorded in
|
||||
* `ino_dev_hashtable', else return 0
|
||||
*
|
||||
* If NAME is a non-NULL pointer to a character pointer, and there is
|
||||
* a match, then set *NAME to the value of the name slot in that
|
||||
* bucket.
|
||||
*/
|
||||
static int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name)
|
||||
{
|
||||
ino_dev_hashtable_bucket_t *bucket;
|
||||
|
||||
bucket = ino_dev_hashtable[hash_inode(statbuf->st_ino)];
|
||||
while (bucket != NULL) {
|
||||
if ((bucket->ino == statbuf->st_ino) &&
|
||||
(bucket->dev == statbuf->st_dev))
|
||||
{
|
||||
if (name) *name = bucket->name;
|
||||
return 1;
|
||||
}
|
||||
bucket = bucket->next;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Add statbuf to statbuf hash table */
|
||||
static void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name)
|
||||
{
|
||||
int i;
|
||||
size_t s;
|
||||
ino_dev_hashtable_bucket_t *bucket;
|
||||
|
||||
i = hash_inode(statbuf->st_ino);
|
||||
s = name ? strlen(name) : 0;
|
||||
bucket = xmalloc(sizeof(ino_dev_hashtable_bucket_t) + s);
|
||||
bucket->ino = statbuf->st_ino;
|
||||
bucket->dev = statbuf->st_dev;
|
||||
if (name)
|
||||
strcpy(bucket->name, name);
|
||||
else
|
||||
bucket->name[0] = '\0';
|
||||
bucket->next = ino_dev_hashtable[i];
|
||||
ino_dev_hashtable[i] = bucket;
|
||||
}
|
||||
|
||||
/* Clear statbuf hash table */
|
||||
static void reset_ino_dev_hashtable(void)
|
||||
{
|
||||
int i;
|
||||
ino_dev_hashtable_bucket_t *bucket;
|
||||
|
||||
for (i = 0; i < HASH_SIZE; i++) {
|
||||
while (ino_dev_hashtable[i] != NULL) {
|
||||
bucket = ino_dev_hashtable[i]->next;
|
||||
free(ino_dev_hashtable[i]);
|
||||
ino_dev_hashtable[i] = bucket;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* tiny recursive du */
|
||||
static long du(char *filename)
|
||||
{
|
||||
struct stat statbuf;
|
||||
long sum;
|
||||
int len;
|
||||
|
||||
if ((lstat(filename, &statbuf)) != 0) {
|
||||
perror_msg_and_die("%s", filename);
|
||||
perror_msg("%s", filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
du_depth++;
|
||||
@@ -69,12 +149,13 @@ static long du(char *filename)
|
||||
/* Don't add in stuff pointed to by symbolic links */
|
||||
if (S_ISLNK(statbuf.st_mode)) {
|
||||
sum = 0L;
|
||||
if (du_depth == 1)
|
||||
print(sum, filename);
|
||||
if (du_depth == 1) {
|
||||
}
|
||||
}
|
||||
if (S_ISDIR(statbuf.st_mode)) {
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
char *newfile;
|
||||
|
||||
dir = opendir(filename);
|
||||
if (!dir) {
|
||||
@@ -82,27 +163,20 @@ static long du(char *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = strlen(filename);
|
||||
if (filename[len - 1] == '/')
|
||||
filename[--len] = '\0';
|
||||
newfile = last_char_is(filename, '/');
|
||||
if (newfile)
|
||||
*newfile = '\0';
|
||||
|
||||
while ((entry = readdir(dir))) {
|
||||
char newfile[BUFSIZ + 1];
|
||||
char *name = entry->d_name;
|
||||
|
||||
if ((strcmp(name, "..") == 0)
|
||||
|| (strcmp(name, ".") == 0)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (len + strlen(name) + 1 > BUFSIZ) {
|
||||
error_msg(name_too_long);
|
||||
du_depth--;
|
||||
return 0;
|
||||
}
|
||||
sprintf(newfile, "%s/%s", filename, name);
|
||||
|
||||
newfile = concat_path_file(filename, name);
|
||||
sum += du(newfile);
|
||||
free(newfile);
|
||||
}
|
||||
closedir(dir);
|
||||
print(sum, filename);
|
||||
@@ -132,7 +206,11 @@ int du_main(int argc, char **argv)
|
||||
print = print_normal;
|
||||
|
||||
/* parse argv[] */
|
||||
while ((c = getopt(argc, argv, "sl")) != EOF) {
|
||||
while ((c = getopt(argc, argv, "sl"
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
"k")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
print = print_summary;
|
||||
@@ -140,8 +218,13 @@ int du_main(int argc, char **argv)
|
||||
case 'l':
|
||||
count_hardlinks = 1;
|
||||
break;
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
case 'h': disp_hr = 0; break;
|
||||
case 'm': disp_hr = MEGABYTE; break;
|
||||
#endif
|
||||
case 'k': break;
|
||||
default:
|
||||
usage(du_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,9 +236,8 @@ int du_main(int argc, char **argv)
|
||||
long sum;
|
||||
|
||||
for (i=optind; i < argc; i++) {
|
||||
if ((sum = du(argv[i])) == 0)
|
||||
status = EXIT_FAILURE;
|
||||
if (is_directory(argv[i], FALSE, NULL)==FALSE) {
|
||||
sum = du(argv[i]);
|
||||
if(is_directory(argv[i], FALSE, NULL)==FALSE) {
|
||||
print_normal(sum, argv[i]);
|
||||
}
|
||||
reset_ino_dev_hashtable();
|
||||
@@ -165,7 +247,7 @@ int du_main(int argc, char **argv)
|
||||
return status;
|
||||
}
|
||||
|
||||
/* $Id: du.c,v 1.32 2000/12/12 23:17:26 andersen Exp $ */
|
||||
/* $Id: du.c,v 1.50 2001/06/30 17:54:20 andersen Exp $ */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
|
||||
+7
-5
@@ -22,8 +22,10 @@
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int
|
||||
echo_main(int argc, char** argv)
|
||||
@@ -38,7 +40,7 @@ echo_main(int argc, char** argv)
|
||||
while (argc > 0 && *argv[0] == '-')
|
||||
{
|
||||
register char *temp;
|
||||
register int index;
|
||||
register int ix;
|
||||
|
||||
/*
|
||||
* If it appears that we are handling options, then make sure
|
||||
@@ -47,9 +49,9 @@ echo_main(int argc, char** argv)
|
||||
*/
|
||||
temp = argv[0] + 1;
|
||||
|
||||
for (index = 0; temp[index]; index++)
|
||||
for (ix = 0; temp[ix]; ix++)
|
||||
{
|
||||
if (strrchr("neE", temp[index]) == 0)
|
||||
if (strrchr("neE", temp[ix]) == 0)
|
||||
goto just_echo;
|
||||
}
|
||||
|
||||
@@ -79,7 +81,7 @@ echo_main(int argc, char** argv)
|
||||
|
||||
just_echo:
|
||||
while (argc > 0) {
|
||||
char *arg = argv[0];
|
||||
const char *arg = argv[0];
|
||||
register int c;
|
||||
|
||||
while ((c = *arg++)) {
|
||||
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* env implementation for busybox
|
||||
*
|
||||
* Copyright (c) 1988, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Original copyright notice is retained at the end of this file.
|
||||
*
|
||||
* Modified for BusyBox by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int env_main(int argc, char** argv)
|
||||
{
|
||||
char **ep, *p;
|
||||
char *cleanenv[1];
|
||||
int ignore_environment = 0;
|
||||
int ch;
|
||||
|
||||
while ((ch = getopt(argc, argv, "+iu:")) != -1) {
|
||||
switch(ch) {
|
||||
case 'i':
|
||||
ignore_environment = 1;
|
||||
break;
|
||||
case 'u':
|
||||
unsetenv(optarg);
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
if (optind != argc && !strcmp(argv[optind], "-")) {
|
||||
ignore_environment = 1;
|
||||
argv++;
|
||||
}
|
||||
if (ignore_environment) {
|
||||
environ = cleanenv;
|
||||
cleanenv[0] = NULL;
|
||||
}
|
||||
for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)
|
||||
if (putenv(*argv) < 0)
|
||||
perror_msg_and_die("%s", *argv);
|
||||
if (*argv) {
|
||||
execvp(*argv, argv);
|
||||
perror_msg_and_die("%s", *argv);
|
||||
}
|
||||
for (ep = environ; *ep; ep++)
|
||||
puts(*ep);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change
|
||||
* ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change>
|
||||
*
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
+20
-16
@@ -33,11 +33,15 @@
|
||||
* One function can handle multiple operators all of equal precedence,
|
||||
* provided they all associate ((x op x) op x). */
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
/* no getopt needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <regex.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* The kinds of value we can have. */
|
||||
enum valtype {
|
||||
@@ -74,19 +78,19 @@ int expr_main (int argc, char **argv)
|
||||
VALUE *v;
|
||||
|
||||
if (argc == 1) {
|
||||
error_msg_and_die("too few arguments\n");
|
||||
error_msg_and_die("too few arguments");
|
||||
}
|
||||
|
||||
args = argv + 1;
|
||||
|
||||
v = eval ();
|
||||
if (*args)
|
||||
error_msg_and_die ("syntax error\n");
|
||||
error_msg_and_die ("syntax error");
|
||||
|
||||
if (v->type == integer)
|
||||
printf ("%d\n", v->u.i);
|
||||
else
|
||||
printf ("%s\n", v->u.s);
|
||||
else
|
||||
puts (v->u.s);
|
||||
|
||||
exit (null (v));
|
||||
}
|
||||
@@ -216,17 +220,17 @@ static \
|
||||
int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
error_msg_and_die ("non-numeric argument\n"); \
|
||||
error_msg_and_die ("non-numeric argument"); \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
#define arithdivf(name, op) \
|
||||
int name (l, r) VALUE *l; VALUE *r; \
|
||||
static int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
error_msg_and_die ( "non-numeric argument\n"); \
|
||||
error_msg_and_die ( "non-numeric argument"); \
|
||||
if (r->u.i == 0) \
|
||||
error_msg_and_die ( "division by zero\n"); \
|
||||
error_msg_and_die ( "division by zero"); \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
@@ -270,7 +274,7 @@ of a basic regular expression is not portable; it is being ignored",
|
||||
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
|
||||
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
|
||||
if (errmsg) {
|
||||
error_msg_and_die("%s\n", errmsg);
|
||||
error_msg_and_die("%s", errmsg);
|
||||
}
|
||||
|
||||
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
|
||||
@@ -301,19 +305,19 @@ static VALUE *eval7 (void)
|
||||
VALUE *v;
|
||||
|
||||
if (!*args)
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
error_msg_and_die ( "syntax error");
|
||||
|
||||
if (nextarg ("(")) {
|
||||
args++;
|
||||
v = eval ();
|
||||
if (!nextarg (")"))
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
error_msg_and_die ( "syntax error");
|
||||
args++;
|
||||
return v;
|
||||
}
|
||||
|
||||
if (nextarg (")"))
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
error_msg_and_die ( "syntax error");
|
||||
|
||||
return str_value (*args++);
|
||||
}
|
||||
@@ -327,7 +331,7 @@ static VALUE *eval6 (void)
|
||||
if (nextarg ("quote")) {
|
||||
args++;
|
||||
if (!*args)
|
||||
error_msg_and_die ( "syntax error\n");
|
||||
error_msg_and_die ( "syntax error");
|
||||
return str_value (*args++);
|
||||
}
|
||||
else if (nextarg ("length")) {
|
||||
|
||||
+10
-7
@@ -3,7 +3,7 @@
|
||||
* Mini head implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,11 +22,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int head(int len, FILE *fp)
|
||||
static int head(int len, FILE *fp)
|
||||
{
|
||||
int i;
|
||||
char *input;
|
||||
@@ -55,7 +58,7 @@ int head_main(int argc, char **argv)
|
||||
break;
|
||||
/* fallthrough */
|
||||
default:
|
||||
usage(head_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,16 +79,16 @@ int head_main(int argc, char **argv)
|
||||
}
|
||||
if (fp) {
|
||||
if (need_headers) {
|
||||
fprintf(stdout, "==> %s <==\n", argv[optind]);
|
||||
printf("==> %s <==\n", argv[optind]);
|
||||
}
|
||||
head(len, fp);
|
||||
if (errno) {
|
||||
error_msg("%s: %s\n", argv[optind], strerror(errno));
|
||||
perror_msg("%s", argv[optind]);
|
||||
status = EXIT_FAILURE;
|
||||
errno = 0;
|
||||
}
|
||||
if (optind < argc - 1)
|
||||
fprintf(stdout, "\n");
|
||||
putchar('\n');
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
+3
-1
@@ -20,8 +20,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int hostid_main(int argc, char **argv)
|
||||
{
|
||||
|
||||
+21
-13
@@ -23,14 +23,14 @@
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
extern int id_main(int argc, char **argv)
|
||||
{
|
||||
int no_user = 0, no_group = 0, print_real = 0;
|
||||
int name_not_number = 0;
|
||||
char user[9], group[9];
|
||||
long gid;
|
||||
long pwnam, grnam;
|
||||
@@ -38,7 +38,7 @@ extern int id_main(int argc, char **argv)
|
||||
|
||||
gid = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ugr")) > 0) {
|
||||
while ((opt = getopt(argc, argv, "ugrn")) > 0) {
|
||||
switch (opt) {
|
||||
case 'u':
|
||||
no_group++;
|
||||
@@ -49,12 +49,15 @@ extern int id_main(int argc, char **argv)
|
||||
case 'r':
|
||||
print_real++;
|
||||
break;
|
||||
case 'n':
|
||||
name_not_number++;
|
||||
break;
|
||||
default:
|
||||
usage(id_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (no_user && no_group) usage(id_usage);
|
||||
if (no_user && no_group) show_usage();
|
||||
|
||||
if (argv[optind] == NULL) {
|
||||
if (print_real) {
|
||||
@@ -73,15 +76,20 @@ extern int id_main(int argc, char **argv)
|
||||
|
||||
pwnam=my_getpwnam(user);
|
||||
grnam=my_getgrnam(group);
|
||||
if (gid == -1 || pwnam==-1 || grnam==-1) {
|
||||
error_msg_and_die("%s: No such user\n", user);
|
||||
}
|
||||
if (no_group)
|
||||
printf("%ld\n", pwnam);
|
||||
else if (no_user)
|
||||
printf("%ld\n", grnam);
|
||||
else
|
||||
|
||||
if (no_group) {
|
||||
if(name_not_number && user)
|
||||
puts(user);
|
||||
else
|
||||
printf("%ld\n", pwnam);
|
||||
} else if (no_user) {
|
||||
if(name_not_number && group)
|
||||
puts(group);
|
||||
else
|
||||
printf("%ld\n", grnam);
|
||||
} else {
|
||||
printf("uid=%ld(%s) gid=%ld(%s)\n", pwnam, user, grnam, group);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include "busybox.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int length_main(int argc, char **argv)
|
||||
{
|
||||
if (argc != 2 || **(argv + 1) == '-')
|
||||
usage(length_usage);
|
||||
show_usage();
|
||||
printf("%lu\n", (long)strlen(argv[1]));
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+41
-28
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini ln implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -21,59 +21,64 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_not_a_directory
|
||||
#include "messages.c"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define LN_SYMLINK 1
|
||||
#define LN_FORCE 2
|
||||
#define LN_NODEREFERENCE 4
|
||||
|
||||
static const int LN_SYMLINK = 1;
|
||||
static const int LN_FORCE = 2;
|
||||
static const int LN_NODEREFERENCE = 4;
|
||||
|
||||
/*
|
||||
* linkDestName is where the link points to,
|
||||
* linkSrcName is the name of the link to be created.
|
||||
*/
|
||||
static int fs_link(const char *link_DestName, const char *link_SrcName, const int flag)
|
||||
static int fs_link(const char *link_destname, const char *link_srcname,
|
||||
const int flag)
|
||||
{
|
||||
int status;
|
||||
int srcIsDir;
|
||||
char *srcName;
|
||||
int src_is_dir;
|
||||
char *src_name;
|
||||
|
||||
if (link_DestName==NULL)
|
||||
if (link_destname==NULL)
|
||||
return(FALSE);
|
||||
|
||||
srcName = (char *) malloc(strlen(link_SrcName)+strlen(link_DestName)+1);
|
||||
src_name = (char *) xmalloc(strlen(link_srcname)+strlen(link_destname)+1);
|
||||
|
||||
if (link_SrcName==NULL)
|
||||
strcpy(srcName, link_DestName);
|
||||
if (link_srcname==NULL)
|
||||
strcpy(src_name, link_destname);
|
||||
else
|
||||
strcpy(srcName, link_SrcName);
|
||||
strcpy(src_name, link_srcname);
|
||||
|
||||
if (flag&LN_NODEREFERENCE)
|
||||
srcIsDir = is_directory(srcName, TRUE, NULL);
|
||||
src_is_dir = is_directory(src_name, TRUE, NULL);
|
||||
else
|
||||
srcIsDir = is_directory(srcName, FALSE, NULL);
|
||||
src_is_dir = is_directory(src_name, FALSE, NULL);
|
||||
|
||||
if ((srcIsDir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
|
||||
strcat(srcName, "/");
|
||||
strcat(srcName, link_DestName);
|
||||
if ((src_is_dir==TRUE)&&((flag&LN_NODEREFERENCE)==0)) {
|
||||
char* srcdir_name;
|
||||
|
||||
srcdir_name = xstrdup(link_destname);
|
||||
strcat(src_name, "/");
|
||||
strcat(src_name, get_last_path_component(srcdir_name));
|
||||
free(srcdir_name);
|
||||
}
|
||||
|
||||
if (flag&LN_FORCE)
|
||||
unlink(srcName);
|
||||
unlink(src_name);
|
||||
|
||||
if (flag&LN_SYMLINK)
|
||||
status = symlink(link_DestName, srcName);
|
||||
status = symlink(link_destname, src_name);
|
||||
else
|
||||
status = link(link_DestName, srcName);
|
||||
status = link(link_destname, src_name);
|
||||
|
||||
if (status != 0) {
|
||||
perror(srcName);
|
||||
perror_msg(src_name);
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
@@ -98,15 +103,23 @@ extern int ln_main(int argc, char **argv)
|
||||
flag |= LN_NODEREFERENCE;
|
||||
break;
|
||||
default:
|
||||
usage(ln_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
if (optind > (argc-1)) {
|
||||
show_usage();
|
||||
}
|
||||
if (optind == (argc-1)) {
|
||||
if (fs_link(argv[optind],
|
||||
get_last_path_component(argv[optind]), flag)==FALSE)
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
while(optind<(argc-1)) {
|
||||
if (fs_link(argv[optind], argv[argc-1], flag)==FALSE)
|
||||
status = EXIT_FAILURE;
|
||||
optind++;
|
||||
}
|
||||
return(status);
|
||||
exit(status);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+5
-3
@@ -20,20 +20,22 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int logname_main(int argc, char **argv)
|
||||
{
|
||||
char user[9];
|
||||
|
||||
if (argc > 1)
|
||||
usage(logname_usage);
|
||||
show_usage();
|
||||
|
||||
my_getpwuid(user, geteuid());
|
||||
if (*user) {
|
||||
puts(user);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
error_msg_and_die("no login name\n");
|
||||
error_msg_and_die("no login name");
|
||||
}
|
||||
+159
-104
@@ -21,7 +21,7 @@
|
||||
/*
|
||||
* To achieve a small memory footprint, this version of 'ls' doesn't do any
|
||||
* file sorting, and only has the most essential command line switches
|
||||
* (i.e. the ones I couldn't live without :-) All features which involve
|
||||
* (i.e., the ones I couldn't live without :-) All features which involve
|
||||
* linking in substantial chunks of libc can be disabled.
|
||||
*
|
||||
* Although I don't really want to add new features to this program to
|
||||
@@ -41,13 +41,15 @@
|
||||
* 1. requires lstat (BSD) - how do you do it without?
|
||||
*/
|
||||
|
||||
#define TERMINAL_WIDTH 80 /* use 79 if your terminal has linefold bug */
|
||||
#define COLUMN_WIDTH 14 /* default if AUTOWIDTH not defined */
|
||||
#define COLUMN_GAP 2 /* includes the file type char, if present */
|
||||
enum {
|
||||
TERMINAL_WIDTH = 80, /* use 79 if terminal has linefold bug */
|
||||
COLUMN_WIDTH = 14, /* default if AUTOWIDTH not defined */
|
||||
COLUMN_GAP = 2, /* includes the file type char */
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
@@ -55,21 +57,29 @@
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
#include <time.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
#ifndef NAJOR
|
||||
#ifndef MAJOR
|
||||
#define MAJOR(dev) (((dev)>>8)&0xff)
|
||||
#define MINOR(dev) ((dev)&0xff)
|
||||
#endif
|
||||
|
||||
/* what is the overall style of the listing */
|
||||
#define STYLE_AUTO 0
|
||||
#define STYLE_LONG 1 /* one record per line, extended info */
|
||||
#define STYLE_SINGLE 2 /* one record per line */
|
||||
#define STYLE_COLUMNS 3 /* fill columns */
|
||||
enum {
|
||||
STYLE_AUTO = 0,
|
||||
STYLE_LONG = 1, /* one record per line, extended info */
|
||||
STYLE_SINGLE = 2, /* one record per line */
|
||||
STYLE_COLUMNS = 3 /* fill columns */
|
||||
};
|
||||
|
||||
/* 51306 lrwxrwxrwx 1 root root 2 May 11 01:43 /bin/view -> vi* */
|
||||
/* what file information will be listed */
|
||||
@@ -99,23 +109,23 @@
|
||||
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
/* how will the files be sorted */
|
||||
#define SORT_FORWARD 0 /* sort in reverse order */
|
||||
#define SORT_REVERSE 1 /* sort in reverse order */
|
||||
#define SORT_NAME 2 /* sort by file name */
|
||||
#define SORT_SIZE 3 /* sort by file size */
|
||||
#define SORT_ATIME 4 /* sort by last access time */
|
||||
#define SORT_CTIME 5 /* sort by last change time */
|
||||
#define SORT_MTIME 6 /* sort by last modification time */
|
||||
#define SORT_VERSION 7 /* sort by version */
|
||||
#define SORT_EXT 8 /* sort by file name extension */
|
||||
#define SORT_DIR 9 /* sort by file or directory */
|
||||
static const int SORT_FORWARD = 0; /* sort in reverse order */
|
||||
static const int SORT_REVERSE = 1; /* sort in reverse order */
|
||||
static const int SORT_NAME = 2; /* sort by file name */
|
||||
static const int SORT_SIZE = 3; /* sort by file size */
|
||||
static const int SORT_ATIME = 4; /* sort by last access time */
|
||||
static const int SORT_CTIME = 5; /* sort by last change time */
|
||||
static const int SORT_MTIME = 6; /* sort by last modification time */
|
||||
static const int SORT_VERSION = 7; /* sort by version */
|
||||
static const int SORT_EXT = 8; /* sort by file name extension */
|
||||
static const int SORT_DIR = 9; /* sort by file or directory */
|
||||
#endif
|
||||
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
/* which of the three times will be used */
|
||||
#define TIME_MOD 0
|
||||
#define TIME_CHANGE 1
|
||||
#define TIME_ACCESS 2
|
||||
static const int TIME_MOD = 0;
|
||||
static const int TIME_CHANGE = 1;
|
||||
static const int TIME_ACCESS = 2;
|
||||
#endif
|
||||
|
||||
#define LIST_SHORT (LIST_FILENAME)
|
||||
@@ -125,9 +135,9 @@
|
||||
LIST_SYMLINK)
|
||||
#define LIST_ILONG (LIST_INO | LIST_LONG)
|
||||
|
||||
#define SPLIT_DIR 0
|
||||
#define SPLIT_FILE 1
|
||||
#define SPLIT_SUBDIR 2
|
||||
static const int SPLIT_DIR = 0;
|
||||
static const int SPLIT_FILE = 1;
|
||||
static const int SPLIT_SUBDIR = 2;
|
||||
|
||||
#define TYPEINDEX(mode) (((mode) >> 12) & 0x0f)
|
||||
#define TYPECHAR(mode) ("0pcCd?bB-?l?s???" [TYPEINDEX(mode)])
|
||||
@@ -146,19 +156,19 @@ struct dnode { /* the basic node */
|
||||
};
|
||||
typedef struct dnode dnode_t;
|
||||
|
||||
struct dnode **list_dir(char *);
|
||||
struct dnode **dnalloc(int);
|
||||
int list_single(struct dnode *);
|
||||
static struct dnode **list_dir(char *);
|
||||
static struct dnode **dnalloc(int);
|
||||
static int list_single(struct dnode *);
|
||||
|
||||
static unsigned int disp_opts= DISP_NORMAL;
|
||||
static unsigned int style_fmt= STYLE_AUTO ;
|
||||
static unsigned int list_fmt= LIST_SHORT ;
|
||||
static unsigned int disp_opts;
|
||||
static unsigned int style_fmt;
|
||||
static unsigned int list_fmt;
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
static unsigned int sort_opts= SORT_FORWARD;
|
||||
static unsigned int sort_order= SORT_FORWARD;
|
||||
static unsigned int sort_opts;
|
||||
static unsigned int sort_order;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
static unsigned int time_fmt= TIME_MOD;
|
||||
static unsigned int time_fmt;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
static unsigned int follow_links=FALSE;
|
||||
@@ -168,20 +178,23 @@ static unsigned short column = 0;
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
static unsigned short terminal_width = TERMINAL_WIDTH;
|
||||
static unsigned short column_width = COLUMN_WIDTH;
|
||||
static unsigned short tabstops = 8;
|
||||
static unsigned short tabstops = COLUMN_GAP;
|
||||
#else
|
||||
#define terminal_width TERMINAL_WIDTH
|
||||
#define column_width COLUMN_WIDTH
|
||||
static unsigned short column_width = COLUMN_WIDTH;
|
||||
#endif
|
||||
|
||||
static int status = EXIT_SUCCESS;
|
||||
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
static unsigned long ls_disp_hr = 0;
|
||||
#endif
|
||||
|
||||
static int my_stat(struct dnode *cur)
|
||||
{
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
if (follow_links == TRUE) {
|
||||
if (stat(cur->fullname, &cur->dstat)) {
|
||||
error_msg("%s: %s\n", cur->fullname, strerror(errno));
|
||||
perror_msg("%s", cur->fullname);
|
||||
status = EXIT_FAILURE;
|
||||
free(cur->fullname);
|
||||
free(cur);
|
||||
@@ -190,7 +203,7 @@ static int my_stat(struct dnode *cur)
|
||||
} else
|
||||
#endif
|
||||
if (lstat(cur->fullname, &cur->dstat)) {
|
||||
error_msg("%s: %s\n", cur->fullname, strerror(errno));
|
||||
perror_msg("%s", cur->fullname);
|
||||
status = EXIT_FAILURE;
|
||||
free(cur->fullname);
|
||||
free(cur);
|
||||
@@ -202,7 +215,7 @@ static int my_stat(struct dnode *cur)
|
||||
static void newline(void)
|
||||
{
|
||||
if (column > 0) {
|
||||
fprintf(stdout, "\n");
|
||||
putchar('\n');
|
||||
column = 0;
|
||||
}
|
||||
}
|
||||
@@ -229,11 +242,11 @@ static void nexttabstop( void )
|
||||
n= nexttab - column;
|
||||
if (n < 1) n= 1;
|
||||
while (n--) {
|
||||
fprintf(stdout, " ");
|
||||
putchar(' ');
|
||||
column++;
|
||||
}
|
||||
}
|
||||
nexttab= column + column_width + COLUMN_GAP ;
|
||||
nexttab= column + column_width + COLUMN_GAP;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
@@ -243,7 +256,7 @@ static int is_subdir(struct dnode *dn)
|
||||
strcmp(dn->name, "..") != 0);
|
||||
}
|
||||
|
||||
int countdirs(struct dnode **dn, int nfiles)
|
||||
static int countdirs(struct dnode **dn, int nfiles)
|
||||
{
|
||||
int i, dirs;
|
||||
|
||||
@@ -255,7 +268,7 @@ int countdirs(struct dnode **dn, int nfiles)
|
||||
return(dirs);
|
||||
}
|
||||
|
||||
int countsubdirs(struct dnode **dn, int nfiles)
|
||||
static int countsubdirs(struct dnode **dn, int nfiles)
|
||||
{
|
||||
int i, subdirs;
|
||||
|
||||
@@ -267,7 +280,7 @@ int countsubdirs(struct dnode **dn, int nfiles)
|
||||
return subdirs;
|
||||
}
|
||||
|
||||
int countfiles(struct dnode **dnp)
|
||||
static int countfiles(struct dnode **dnp)
|
||||
{
|
||||
int nfiles;
|
||||
struct dnode *cur;
|
||||
@@ -280,7 +293,7 @@ int countfiles(struct dnode **dnp)
|
||||
}
|
||||
|
||||
/* get memory to hold an array of pointers */
|
||||
struct dnode **dnalloc(int num)
|
||||
static struct dnode **dnalloc(int num)
|
||||
{
|
||||
struct dnode **p;
|
||||
|
||||
@@ -290,7 +303,7 @@ struct dnode **dnalloc(int num)
|
||||
return(p);
|
||||
}
|
||||
|
||||
void dfree(struct dnode **dnp)
|
||||
static void dfree(struct dnode **dnp)
|
||||
{
|
||||
struct dnode *cur, *next;
|
||||
|
||||
@@ -306,7 +319,7 @@ void dfree(struct dnode **dnp)
|
||||
free(dnp); /* free the array holding the dnode pointers */
|
||||
}
|
||||
|
||||
struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
|
||||
static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
|
||||
{
|
||||
int dncnt, i, d;
|
||||
struct dnode **dnp;
|
||||
@@ -346,7 +359,7 @@ struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which)
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
int sortcmp(struct dnode *d1, struct dnode *d2)
|
||||
static int sortcmp(struct dnode *d1, struct dnode *d2)
|
||||
{
|
||||
int cmp, dif;
|
||||
|
||||
@@ -383,7 +396,7 @@ int sortcmp(struct dnode *d1, struct dnode *d2)
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void shellsort(struct dnode **dn, int size)
|
||||
static void shellsort(struct dnode **dn, int size)
|
||||
{
|
||||
struct dnode *temp;
|
||||
int gap, i, j;
|
||||
@@ -407,7 +420,7 @@ void shellsort(struct dnode **dn, int size)
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void showfiles(struct dnode **dn, int nfiles)
|
||||
static void showfiles(struct dnode **dn, int nfiles)
|
||||
{
|
||||
int i, ncols, nrows, row, nc;
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
@@ -424,10 +437,18 @@ void showfiles(struct dnode **dn, int nfiles)
|
||||
((list_fmt & LIST_INO) ? 8 : 0) +
|
||||
((list_fmt & LIST_BLOCKS) ? 5 : 0)
|
||||
;
|
||||
if (column_width < len) column_width= len;
|
||||
if (column_width < len)
|
||||
column_width= len;
|
||||
}
|
||||
if (column_width >= 6)
|
||||
ncols = (int)(terminal_width / (column_width + COLUMN_GAP));
|
||||
else {
|
||||
ncols = 1;
|
||||
column_width = COLUMN_WIDTH;
|
||||
}
|
||||
#else
|
||||
ncols= TERMINAL_WIDTH;
|
||||
#endif
|
||||
ncols= (int)(terminal_width / (column_width + COLUMN_GAP));
|
||||
switch (style_fmt) {
|
||||
case STYLE_LONG: /* one record per line, extended info */
|
||||
case STYLE_SINGLE: /* one record per line */
|
||||
@@ -435,7 +456,12 @@ void showfiles(struct dnode **dn, int nfiles)
|
||||
break;
|
||||
}
|
||||
|
||||
nrows= nfiles / ncols;
|
||||
if (ncols > 1) {
|
||||
nrows = nfiles / ncols;
|
||||
} else {
|
||||
nrows = nfiles;
|
||||
ncols = 1;
|
||||
}
|
||||
if ((nrows * ncols) < nfiles) nrows++; /* round up fractionals */
|
||||
|
||||
if (nrows > nfiles) nrows= nfiles;
|
||||
@@ -455,7 +481,7 @@ void showfiles(struct dnode **dn, int nfiles)
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
void showdirs(struct dnode **dn, int ndirs)
|
||||
static void showdirs(struct dnode **dn, int ndirs)
|
||||
{
|
||||
int i, nfiles;
|
||||
struct dnode **subdnp;
|
||||
@@ -468,7 +494,7 @@ void showdirs(struct dnode **dn, int ndirs)
|
||||
|
||||
for (i=0; i<ndirs; i++) {
|
||||
if (disp_opts & (DISP_DIRNAME | DISP_RECURSIVE)) {
|
||||
fprintf(stdout, "\n%s:\n", dn[i]->fullname);
|
||||
printf("\n%s:\n", dn[i]->fullname);
|
||||
}
|
||||
subdnp= list_dir(dn[i]->fullname);
|
||||
nfiles= countfiles(subdnp);
|
||||
@@ -498,7 +524,7 @@ void showdirs(struct dnode **dn, int ndirs)
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
struct dnode **list_dir(char *path)
|
||||
static struct dnode **list_dir(char *path)
|
||||
{
|
||||
struct dnode *dn, *cur, **dnp;
|
||||
struct dirent *entry;
|
||||
@@ -511,22 +537,22 @@ struct dnode **list_dir(char *path)
|
||||
nfiles= 0;
|
||||
dir = opendir(path);
|
||||
if (dir == NULL) {
|
||||
error_msg("%s: %s\n", path, strerror(errno));
|
||||
perror_msg("%s", path);
|
||||
status = EXIT_FAILURE;
|
||||
return(NULL); /* could not open the dir */
|
||||
}
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
/* are we going to list the file- it may be . or .. or a hidden file */
|
||||
if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT)) continue;
|
||||
if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT)) continue;
|
||||
if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN)) continue;
|
||||
if ((strcmp(entry->d_name, ".")==0) && !(disp_opts & DISP_DOT))
|
||||
continue;
|
||||
if ((strcmp(entry->d_name, "..")==0) && !(disp_opts & DISP_DOT))
|
||||
continue;
|
||||
if ((entry->d_name[0] == '.') && !(disp_opts & DISP_HIDDEN))
|
||||
continue;
|
||||
cur= (struct dnode *)xmalloc(sizeof(struct dnode));
|
||||
cur->fullname = xmalloc(strlen(path)+1+strlen(entry->d_name)+1);
|
||||
strcpy(cur->fullname, path);
|
||||
if (cur->fullname[strlen(cur->fullname)-1] != '/')
|
||||
strcat(cur->fullname, "/");
|
||||
cur->name= cur->fullname + strlen(cur->fullname);
|
||||
strcat(cur->fullname, entry->d_name);
|
||||
cur->fullname = concat_path_file(path, entry->d_name);
|
||||
cur->name = cur->fullname +
|
||||
(strlen(cur->fullname) - strlen(entry->d_name));
|
||||
if (my_stat(cur))
|
||||
continue;
|
||||
cur->next= dn;
|
||||
@@ -549,9 +575,9 @@ struct dnode **list_dir(char *path)
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
int list_single(struct dnode *dn)
|
||||
static int list_single(struct dnode *dn)
|
||||
{
|
||||
int i, len;
|
||||
int i;
|
||||
char scratch[BUFSIZ + 1];
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
char *filetime;
|
||||
@@ -579,54 +605,60 @@ int list_single(struct dnode *dn)
|
||||
for (i=0; i<=31; i++) {
|
||||
switch (list_fmt & (1<<i)) {
|
||||
case LIST_INO:
|
||||
fprintf(stdout, "%7ld ", dn->dstat.st_ino);
|
||||
printf("%7ld ", (long int)dn->dstat.st_ino);
|
||||
column += 8;
|
||||
break;
|
||||
case LIST_BLOCKS:
|
||||
#if _FILE_OFFSET_BITS == 64
|
||||
fprintf(stdout, "%4lld ", dn->dstat.st_blocks>>1);
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
fprintf(stdout, "%6s ", make_human_readable_str(dn->dstat.st_blocks>>1,
|
||||
KILOBYTE, (ls_disp_hr==TRUE)? 0: KILOBYTE));
|
||||
#else
|
||||
fprintf(stdout, "%4ld ", dn->dstat.st_blocks>>1);
|
||||
#if _FILE_OFFSET_BITS == 64
|
||||
printf("%4lld ", dn->dstat.st_blocks>>1);
|
||||
#else
|
||||
printf("%4ld ", dn->dstat.st_blocks>>1);
|
||||
#endif
|
||||
#endif
|
||||
column += 5;
|
||||
break;
|
||||
case LIST_MODEBITS:
|
||||
fprintf(stdout, "%10s", (char *)mode_string(dn->dstat.st_mode));
|
||||
printf("%-10s ", (char *)mode_string(dn->dstat.st_mode));
|
||||
column += 10;
|
||||
break;
|
||||
case LIST_NLINKS:
|
||||
fprintf(stdout, "%4d ", dn->dstat.st_nlink);
|
||||
printf("%4ld ", (long)dn->dstat.st_nlink);
|
||||
column += 10;
|
||||
break;
|
||||
case LIST_ID_NAME:
|
||||
#ifdef BB_FEATURE_LS_USERNAME
|
||||
my_getpwuid(scratch, dn->dstat.st_uid);
|
||||
if (*scratch)
|
||||
fprintf(stdout, "%-8.8s ", scratch);
|
||||
else
|
||||
fprintf(stdout, "%-8d ", dn->dstat.st_uid);
|
||||
printf("%-8.8s ", scratch);
|
||||
my_getgrgid(scratch, dn->dstat.st_gid);
|
||||
if (*scratch)
|
||||
fprintf(stdout, "%-8.8s", scratch);
|
||||
else
|
||||
fprintf(stdout, "%-8d", dn->dstat.st_gid);
|
||||
printf("%-8.8s ", scratch);
|
||||
column += 17;
|
||||
break;
|
||||
#endif
|
||||
case LIST_ID_NUMERIC:
|
||||
fprintf(stdout, "%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
|
||||
printf("%-8d %-8d", dn->dstat.st_uid, dn->dstat.st_gid);
|
||||
column += 17;
|
||||
break;
|
||||
case LIST_SIZE:
|
||||
case LIST_DEV:
|
||||
if (S_ISBLK(dn->dstat.st_mode) || S_ISCHR(dn->dstat.st_mode)) {
|
||||
fprintf(stdout, "%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
|
||||
printf("%4d, %3d ", (int)MAJOR(dn->dstat.st_rdev), (int)MINOR(dn->dstat.st_rdev));
|
||||
} else {
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
if (ls_disp_hr==TRUE) {
|
||||
fprintf(stdout, "%8s ", make_human_readable_str(dn->dstat.st_size, 1, 0));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#if _FILE_OFFSET_BITS == 64
|
||||
fprintf(stdout, "%9lld ", dn->dstat.st_size);
|
||||
printf("%9lld ", (long long)dn->dstat.st_size);
|
||||
#else
|
||||
fprintf(stdout, "%9ld ", dn->dstat.st_size);
|
||||
printf("%9ld ", dn->dstat.st_size);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
column += 10;
|
||||
break;
|
||||
@@ -634,44 +666,44 @@ int list_single(struct dnode *dn)
|
||||
case LIST_FULLTIME:
|
||||
case LIST_DATE_TIME:
|
||||
if (list_fmt & LIST_FULLTIME) {
|
||||
fprintf(stdout, "%24.24s ", filetime);
|
||||
printf("%24.24s ", filetime);
|
||||
column += 25;
|
||||
break;
|
||||
}
|
||||
age = time(NULL) - ttime;
|
||||
fprintf(stdout, "%6.6s ", filetime+4);
|
||||
printf("%6.6s ", filetime+4);
|
||||
if (age < 3600L * 24 * 365 / 2 && age > -15 * 60) {
|
||||
/* hh:mm if less than 6 months old */
|
||||
fprintf(stdout, "%5.5s ", filetime+11);
|
||||
printf("%5.5s ", filetime+11);
|
||||
} else {
|
||||
fprintf(stdout, " %4.4s ", filetime+20);
|
||||
printf(" %4.4s ", filetime+20);
|
||||
}
|
||||
column += 13;
|
||||
break;
|
||||
#endif
|
||||
case LIST_FILENAME:
|
||||
fprintf(stdout, "%s", dn->name);
|
||||
printf("%s", dn->name);
|
||||
column += strlen(dn->name);
|
||||
break;
|
||||
case LIST_SYMLINK:
|
||||
if (S_ISLNK(dn->dstat.st_mode)) {
|
||||
len= readlink(dn->fullname, scratch, (sizeof scratch)-1);
|
||||
if (len > 0) {
|
||||
scratch[len]= '\0';
|
||||
fprintf(stdout, " -> %s", scratch);
|
||||
char *lpath = xreadlink(dn->fullname);
|
||||
if (lpath) {
|
||||
printf(" -> %s", lpath);
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
if (!stat(dn->fullname, &info)) {
|
||||
append = append_char(info.st_mode);
|
||||
}
|
||||
#endif
|
||||
column += len+4;
|
||||
column += strlen(lpath) + 4;
|
||||
free(lpath);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#ifdef BB_FEATURE_LS_FILETYPES
|
||||
case LIST_FILETYPE:
|
||||
if (append != '\0') {
|
||||
fprintf(stdout, "%1c", append);
|
||||
printf("%1c", append);
|
||||
column++;
|
||||
}
|
||||
break;
|
||||
@@ -692,15 +724,26 @@ extern int ls_main(int argc, char **argv)
|
||||
int opt;
|
||||
int oi, ac;
|
||||
char **av;
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
struct winsize win = { 0, 0, 0, 0 };
|
||||
#endif
|
||||
|
||||
disp_opts= DISP_NORMAL;
|
||||
style_fmt= STYLE_AUTO;
|
||||
list_fmt= LIST_SHORT;
|
||||
#ifdef BB_FEATURE_LS_SORTFILES
|
||||
sort_opts= SORT_NAME;
|
||||
sort_order= SORT_FORWARD;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LS_TIMESTAMPS
|
||||
time_fmt= TIME_MOD;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_AUTOWIDTH
|
||||
ioctl(fileno(stdout), TIOCGWINSZ, &win);
|
||||
if (win.ws_row > 4)
|
||||
column_width = win.ws_row - 2;
|
||||
if (win.ws_col > 0)
|
||||
terminal_width = win.ws_col - 1;
|
||||
#endif
|
||||
nfiles=0;
|
||||
|
||||
@@ -724,7 +767,10 @@ extern int ls_main(int argc, char **argv)
|
||||
#ifdef BB_FEATURE_LS_FOLLOWLINKS
|
||||
"L"
|
||||
#endif
|
||||
)) > 0) {
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
"h"
|
||||
#endif
|
||||
"k")) > 0) {
|
||||
switch (opt) {
|
||||
case '1': style_fmt = STYLE_SINGLE; break;
|
||||
case 'A': disp_opts |= DISP_HIDDEN; break;
|
||||
@@ -733,7 +779,13 @@ extern int ls_main(int argc, char **argv)
|
||||
case 'd': disp_opts |= DISP_NOLIST; break;
|
||||
case 'g': /* ignore -- for ftp servers */ break;
|
||||
case 'i': list_fmt |= LIST_INO; break;
|
||||
case 'l': style_fmt = STYLE_LONG; list_fmt |= LIST_LONG; break;
|
||||
case 'l':
|
||||
style_fmt = STYLE_LONG;
|
||||
list_fmt |= LIST_LONG;
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
ls_disp_hr = FALSE;
|
||||
#endif
|
||||
break;
|
||||
case 'n': list_fmt |= LIST_ID_NUMERIC; break;
|
||||
case 's': list_fmt |= LIST_BLOCKS; break;
|
||||
case 'x': disp_opts = DISP_ROWS; break;
|
||||
@@ -777,6 +829,10 @@ extern int ls_main(int argc, char **argv)
|
||||
case 'T': tabstops= atoi(optarg); break;
|
||||
case 'w': terminal_width= atoi(optarg); break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
case 'h': ls_disp_hr = TRUE; break;
|
||||
#endif
|
||||
case 'k': break;
|
||||
default:
|
||||
goto print_usage_message;
|
||||
}
|
||||
@@ -871,9 +927,8 @@ extern int ls_main(int argc, char **argv)
|
||||
showdirs(dnd, dndirs);
|
||||
}
|
||||
}
|
||||
|
||||
return(status);
|
||||
|
||||
print_usage_message:
|
||||
usage(ls_usage);
|
||||
show_usage();
|
||||
}
|
||||
+240
-63
@@ -20,18 +20,42 @@
|
||||
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu> */
|
||||
/* Hacked to work with BusyBox by Alfred M. Szmidt <ams@trillian.itslinux.org> */
|
||||
|
||||
#include "busybox.h"
|
||||
/*
|
||||
* June 29, 2001 Manuel Novoa III
|
||||
*
|
||||
* Added MD5SUM_SIZE_VS_SPEED configuration option.
|
||||
*
|
||||
* Current valid values, with data from my system for comparison, are:
|
||||
* (using uClibc and running on linux-2.4.4.tar.bz2)
|
||||
* user times (sec) text size (386)
|
||||
* 0 (fastest) 1.1 6144
|
||||
* 1 1.4 5392
|
||||
* 2 3.0 5088
|
||||
* 3 (smallest) 5.1 4912
|
||||
*/
|
||||
|
||||
#define MD5SUM_SIZE_VS_SPEED 2
|
||||
|
||||
/**********************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
#include <getopt.h>
|
||||
|
||||
/* It turns out that libc5 doesn't have this in its headers
|
||||
* even though it is actually in the lib. Force it to work */
|
||||
#if ! defined __GLIBC__ && ! defined __UCLIBC__
|
||||
#define getline __getline
|
||||
extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <endian.h>
|
||||
#include <sys/types.h>
|
||||
#if defined HAVE_LIMITS_H
|
||||
# include <limits.h>
|
||||
#endif
|
||||
#include "busybox.h"
|
||||
|
||||
/* For some silly reason, this file uses backwards TRUE and FALSE conventions */
|
||||
#undef TRUE
|
||||
#undef FALSE
|
||||
#define FALSE ((int) 1)
|
||||
#define TRUE ((int) 0)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
//--------md5.c
|
||||
@@ -61,12 +85,6 @@ extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
|
||||
|
||||
/* Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995. */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <endian.h>
|
||||
|
||||
#include "busybox.h"
|
||||
//----------------------------------------------------------------------------
|
||||
//--------md5.h
|
||||
//----------------------------------------------------------------------------
|
||||
@@ -92,13 +110,7 @@ extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
|
||||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef _MD5_H
|
||||
#define _MD5_H 1
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined HAVE_LIMITS_H || defined _LIBC
|
||||
# include <limits.h>
|
||||
#endif
|
||||
static const int _MD5_H = 1;
|
||||
|
||||
/* The following contortions are an attempt to use the C preprocessor
|
||||
to determine an unsigned integral type that is 32 bits wide. An
|
||||
@@ -107,7 +119,6 @@ extern _IO_ssize_t getline __P ((char **, size_t *, FILE *));
|
||||
the resulting executable. Locally running cross-compiled executables
|
||||
is usually not possible. */
|
||||
|
||||
# include <sys/types.h>
|
||||
typedef u_int32_t md5_uint32;
|
||||
|
||||
/* Structure to save state of computation between the single steps. */
|
||||
@@ -182,11 +193,20 @@ extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
|
||||
//--------end of md5.h
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
#define SWAP(n) (n)
|
||||
/* Handle endian-ness */
|
||||
#if __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define SWAP(n) (n)
|
||||
#else
|
||||
#define SWAP(n) ((n << 24) | ((n&65280)<<8) | ((n&16711680)>>8) | (n>>24))
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if MD5SUM_SIZE_VS_SPEED == 0
|
||||
/* This array contains the bytes used to pad the buffer to the next
|
||||
64-byte boundary. (RFC 1321, 3.1: Step 1) */
|
||||
static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
|
||||
#endif
|
||||
|
||||
/* Initialize structure containing state of computation.
|
||||
(RFC 1321, 3.3: Step 3) */
|
||||
@@ -233,12 +253,17 @@ void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
|
||||
++ctx->total[1];
|
||||
|
||||
pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
|
||||
#if MD5SUM_SIZE_VS_SPEED > 0
|
||||
memset(&ctx->buffer[bytes], 0, pad);
|
||||
ctx->buffer[bytes] = 0x80;
|
||||
#else
|
||||
memcpy(&ctx->buffer[bytes], fillbuf, pad);
|
||||
#endif
|
||||
|
||||
/* Put the 64-bit file length in *bits* at the end of the buffer. */
|
||||
*(md5_uint32 *) & ctx->buffer[bytes + pad] = SWAP(ctx->total[0] << 3);
|
||||
*(md5_uint32 *) & ctx->buffer[bytes + pad + 4] =
|
||||
SWAP((ctx->total[1] << 3) | (ctx->total[0] >> 29));
|
||||
SWAP( ((ctx->total[1] << 3) | (ctx->total[0] >> 29)) );
|
||||
|
||||
/* Process last bytes. */
|
||||
md5_process_block(ctx->buffer, bytes + pad + 8, ctx);
|
||||
@@ -252,7 +277,7 @@ void *md5_finish_ctx(struct md5_ctx *ctx, void *resbuf)
|
||||
int md5_stream(FILE *stream, void *resblock)
|
||||
{
|
||||
/* Important: BLOCKSIZE must be a multiple of 64. */
|
||||
#define BLOCKSIZE 4096
|
||||
static const int BLOCKSIZE = 4096;
|
||||
struct md5_ctx ctx;
|
||||
char buffer[BLOCKSIZE + 72];
|
||||
size_t sum;
|
||||
@@ -369,6 +394,49 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
const md5_uint32 *words = buffer;
|
||||
size_t nwords = len / sizeof(md5_uint32);
|
||||
const md5_uint32 *endp = words + nwords;
|
||||
#if MD5SUM_SIZE_VS_SPEED > 0
|
||||
static const md5_uint32 C_array[] = {
|
||||
/* round 1 */
|
||||
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee,
|
||||
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501,
|
||||
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be,
|
||||
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821,
|
||||
/* round 2 */
|
||||
0xf61e2562, 0xc040b340, 0x265e5a51, 0xe9b6c7aa,
|
||||
0xd62f105d, 0x2441453, 0xd8a1e681, 0xe7d3fbc8,
|
||||
0x21e1cde6, 0xc33707d6, 0xf4d50d87, 0x455a14ed,
|
||||
0xa9e3e905, 0xfcefa3f8, 0x676f02d9, 0x8d2a4c8a,
|
||||
/* round 3 */
|
||||
0xfffa3942, 0x8771f681, 0x6d9d6122, 0xfde5380c,
|
||||
0xa4beea44, 0x4bdecfa9, 0xf6bb4b60, 0xbebfbc70,
|
||||
0x289b7ec6, 0xeaa127fa, 0xd4ef3085, 0x4881d05,
|
||||
0xd9d4d039, 0xe6db99e5, 0x1fa27cf8, 0xc4ac5665,
|
||||
/* round 4 */
|
||||
0xf4292244, 0x432aff97, 0xab9423a7, 0xfc93a039,
|
||||
0x655b59c3, 0x8f0ccc92, 0xffeff47d, 0x85845dd1,
|
||||
0x6fa87e4f, 0xfe2ce6e0, 0xa3014314, 0x4e0811a1,
|
||||
0xf7537e82, 0xbd3af235, 0x2ad7d2bb, 0xeb86d391
|
||||
};
|
||||
|
||||
static const char P_array[] = {
|
||||
#if MD5SUM_SIZE_VS_SPEED > 1
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 1 */
|
||||
#endif
|
||||
1, 6, 11, 0, 5, 10, 15, 4, 9, 14, 3, 8, 13, 2, 7, 12, /* 2 */
|
||||
5, 8, 11, 14, 1, 4, 7, 10, 13, 0, 3, 6, 9, 12, 15, 2, /* 3 */
|
||||
0, 7, 14, 5, 12, 3, 10, 1, 8, 15, 6, 13, 4, 11, 2, 9 /* 4 */
|
||||
};
|
||||
|
||||
#if MD5SUM_SIZE_VS_SPEED > 1
|
||||
static const char S_array[] = {
|
||||
7, 12, 17, 22,
|
||||
5, 9, 14, 20,
|
||||
4, 11, 16, 23,
|
||||
6, 10, 15, 21
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
md5_uint32 A = ctx->A;
|
||||
md5_uint32 B = ctx->B;
|
||||
md5_uint32 C = ctx->C;
|
||||
@@ -390,6 +458,79 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
md5_uint32 C_save = C;
|
||||
md5_uint32 D_save = D;
|
||||
|
||||
#if MD5SUM_SIZE_VS_SPEED > 1
|
||||
#define CYCLIC(w, s) (w = (w << s) | (w >> (32 - s)))
|
||||
|
||||
const md5_uint32 *pc;
|
||||
const char *pp;
|
||||
const char *ps;
|
||||
int i;
|
||||
md5_uint32 temp;
|
||||
|
||||
for ( i=0 ; i < 16 ; i++ ) {
|
||||
cwp[i] = SWAP(words[i]);
|
||||
}
|
||||
words += 16;
|
||||
|
||||
#if MD5SUM_SIZE_VS_SPEED > 2
|
||||
pc = C_array; pp = P_array; ps = S_array - 4;
|
||||
|
||||
for ( i = 0 ; i < 64 ; i++ ) {
|
||||
if ((i&0x0f) == 0) ps += 4;
|
||||
temp = A;
|
||||
switch (i>>4) {
|
||||
case 0:
|
||||
temp += FF(B,C,D);
|
||||
break;
|
||||
case 1:
|
||||
temp += FG(B,C,D);
|
||||
break;
|
||||
case 2:
|
||||
temp += FH(B,C,D);
|
||||
break;
|
||||
case 3:
|
||||
temp += FI(B,C,D);
|
||||
break;
|
||||
}
|
||||
temp += cwp[(int)(*pp++)] + *pc++;
|
||||
temp = CYCLIC (temp, ps[i&3]);
|
||||
temp += B;
|
||||
A = D; D = C; C = B; B = temp;
|
||||
}
|
||||
#else
|
||||
pc = C_array; pp = P_array; ps = S_array;
|
||||
|
||||
for ( i = 0 ; i < 16 ; i++ ) {
|
||||
temp = A + FF(B,C,D) + cwp[(int)(*pp++)] + *pc++;
|
||||
temp = CYCLIC (temp, ps[i&3]);
|
||||
temp += B;
|
||||
A = D; D = C; C = B; B = temp;
|
||||
}
|
||||
|
||||
ps += 4;
|
||||
for ( i = 0 ; i < 16 ; i++ ) {
|
||||
temp = A + FG(B,C,D) + cwp[(int)(*pp++)] + *pc++;
|
||||
temp = CYCLIC (temp, ps[i&3]);
|
||||
temp += B;
|
||||
A = D; D = C; C = B; B = temp;
|
||||
}
|
||||
ps += 4;
|
||||
for ( i = 0 ; i < 16 ; i++ ) {
|
||||
temp = A + FH(B,C,D) + cwp[(int)(*pp++)] + *pc++;
|
||||
temp = CYCLIC (temp, ps[i&3]);
|
||||
temp += B;
|
||||
A = D; D = C; C = B; B = temp;
|
||||
}
|
||||
ps += 4;
|
||||
for ( i = 0 ; i < 16 ; i++ ) {
|
||||
temp = A + FI(B,C,D) + cwp[(int)(*pp++)] + *pc++;
|
||||
temp = CYCLIC (temp, ps[i&3]);
|
||||
temp += B;
|
||||
A = D; D = C; C = B; B = temp;
|
||||
}
|
||||
|
||||
#endif
|
||||
#else
|
||||
/* First round: using the given function, the context and a constant
|
||||
the next context is computed. Because the algorithms processing
|
||||
unit is a 32-bit word and it is determined to work on words in
|
||||
@@ -417,7 +558,22 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64
|
||||
*/
|
||||
|
||||
#if MD5SUM_SIZE_VS_SPEED == 1
|
||||
const md5_uint32 *pc;
|
||||
const char *pp;
|
||||
int i;
|
||||
#endif
|
||||
|
||||
/* Round 1. */
|
||||
#if MD5SUM_SIZE_VS_SPEED == 1
|
||||
pc = C_array;
|
||||
for ( i=0 ; i < 4 ; i++ ) {
|
||||
OP(A, B, C, D, 7, *pc++);
|
||||
OP(D, A, B, C, 12, *pc++);
|
||||
OP(C, D, A, B, 17, *pc++);
|
||||
OP(B, C, D, A, 22, *pc++);
|
||||
}
|
||||
#else
|
||||
OP(A, B, C, D, 7, 0xd76aa478);
|
||||
OP(D, A, B, C, 12, 0xe8c7b756);
|
||||
OP(C, D, A, B, 17, 0x242070db);
|
||||
@@ -434,6 +590,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
OP(D, A, B, C, 12, 0xfd987193);
|
||||
OP(C, D, A, B, 17, 0xa679438e);
|
||||
OP(B, C, D, A, 22, 0x49b40821);
|
||||
#endif
|
||||
|
||||
/* For the second to fourth round we have the possibly swapped words
|
||||
in CORRECT_WORDS. Redefine the macro to take an additional first
|
||||
@@ -449,6 +606,15 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
while (0)
|
||||
|
||||
/* Round 2. */
|
||||
#if MD5SUM_SIZE_VS_SPEED == 1
|
||||
pp = P_array;
|
||||
for ( i=0 ; i < 4 ; i++ ) {
|
||||
OP(FG, A, B, C, D, (int)(*pp++), 5, *pc++);
|
||||
OP(FG, D, A, B, C, (int)(*pp++), 9, *pc++);
|
||||
OP(FG, C, D, A, B, (int)(*pp++), 14, *pc++);
|
||||
OP(FG, B, C, D, A, (int)(*pp++), 20, *pc++);
|
||||
}
|
||||
#else
|
||||
OP(FG, A, B, C, D, 1, 5, 0xf61e2562);
|
||||
OP(FG, D, A, B, C, 6, 9, 0xc040b340);
|
||||
OP(FG, C, D, A, B, 11, 14, 0x265e5a51);
|
||||
@@ -465,8 +631,17 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
OP(FG, D, A, B, C, 2, 9, 0xfcefa3f8);
|
||||
OP(FG, C, D, A, B, 7, 14, 0x676f02d9);
|
||||
OP(FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
|
||||
#endif
|
||||
|
||||
/* Round 3. */
|
||||
#if MD5SUM_SIZE_VS_SPEED == 1
|
||||
for ( i=0 ; i < 4 ; i++ ) {
|
||||
OP(FH, A, B, C, D, (int)(*pp++), 4, *pc++);
|
||||
OP(FH, D, A, B, C, (int)(*pp++), 11, *pc++);
|
||||
OP(FH, C, D, A, B, (int)(*pp++), 16, *pc++);
|
||||
OP(FH, B, C, D, A, (int)(*pp++), 23, *pc++);
|
||||
}
|
||||
#else
|
||||
OP(FH, A, B, C, D, 5, 4, 0xfffa3942);
|
||||
OP(FH, D, A, B, C, 8, 11, 0x8771f681);
|
||||
OP(FH, C, D, A, B, 11, 16, 0x6d9d6122);
|
||||
@@ -483,8 +658,17 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
OP(FH, D, A, B, C, 12, 11, 0xe6db99e5);
|
||||
OP(FH, C, D, A, B, 15, 16, 0x1fa27cf8);
|
||||
OP(FH, B, C, D, A, 2, 23, 0xc4ac5665);
|
||||
#endif
|
||||
|
||||
/* Round 4. */
|
||||
#if MD5SUM_SIZE_VS_SPEED == 1
|
||||
for ( i=0 ; i < 4 ; i++ ) {
|
||||
OP(FI, A, B, C, D, (int)(*pp++), 6, *pc++);
|
||||
OP(FI, D, A, B, C, (int)(*pp++), 10, *pc++);
|
||||
OP(FI, C, D, A, B, (int)(*pp++), 15, *pc++);
|
||||
OP(FI, B, C, D, A, (int)(*pp++), 21, *pc++);
|
||||
}
|
||||
#else
|
||||
OP(FI, A, B, C, D, 0, 6, 0xf4292244);
|
||||
OP(FI, D, A, B, C, 7, 10, 0x432aff97);
|
||||
OP(FI, C, D, A, B, 14, 15, 0xab9423a7);
|
||||
@@ -501,6 +685,8 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
OP(FI, D, A, B, C, 11, 10, 0xbd3af235);
|
||||
OP(FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
|
||||
OP(FI, B, C, D, A, 9, 21, 0xeb86d391);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Add the starting values of the context. */
|
||||
A += A_save;
|
||||
@@ -530,7 +716,7 @@ void md5_process_block(const void *buffer, size_t len, struct md5_ctx *ctx)
|
||||
/* The minimum length of a valid digest line in a file produced
|
||||
by `md5sum FILE' and read by `md5sum -c'. This length does
|
||||
not include any newline character at the end of a line. */
|
||||
#define MIN_DIGEST_LINE_LENGTH 35 /* 32 - message digest length
|
||||
static const int MIN_DIGEST_LINE_LENGTH = 35; /* 32 - message digest length
|
||||
2 - blank and binary indicator
|
||||
1 - minimum filename length */
|
||||
|
||||
@@ -651,13 +837,13 @@ static int md5_file(const char *filename,
|
||||
} else {
|
||||
fp = fopen(filename, OPENOPTS(binary));
|
||||
if (fp == NULL) {
|
||||
error_msg("%s: %s\n", filename, strerror(errno));
|
||||
perror_msg("%s", filename);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (md5_stream(fp, md5_result)) {
|
||||
error_msg("%s: %s\n", filename, strerror(errno));
|
||||
perror_msg("%s", filename);
|
||||
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
@@ -665,7 +851,7 @@ static int md5_file(const char *filename,
|
||||
}
|
||||
|
||||
if (fp != stdin && fclose(fp) == EOF) {
|
||||
error_msg("%s: %s\n", filename, strerror(errno));
|
||||
perror_msg("%s", filename);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -680,8 +866,7 @@ static int md5_check(const char *checkfile_name)
|
||||
int n_open_or_read_failures = 0;
|
||||
unsigned char md5buffer[16];
|
||||
size_t line_number;
|
||||
char *line;
|
||||
size_t line_chars_allocated;
|
||||
char line[BUFSIZ];
|
||||
|
||||
if (STREQ(checkfile_name, "-")) {
|
||||
have_read_stdin = 1;
|
||||
@@ -689,14 +874,12 @@ static int md5_check(const char *checkfile_name)
|
||||
} else {
|
||||
checkfile_stream = fopen(checkfile_name, "r");
|
||||
if (checkfile_stream == NULL) {
|
||||
error_msg("%s: %s\n", checkfile_name, strerror(errno));
|
||||
perror_msg("%s", checkfile_name);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
line_number = 0;
|
||||
line = 0;
|
||||
line_chars_allocated = 0;
|
||||
|
||||
do {
|
||||
char *filename;
|
||||
@@ -706,9 +889,10 @@ static int md5_check(const char *checkfile_name)
|
||||
|
||||
++line_number;
|
||||
|
||||
line_length = getline(&line, &line_chars_allocated, checkfile_stream);
|
||||
fgets(line, BUFSIZ-1, checkfile_stream);
|
||||
line_length = strlen(line);
|
||||
|
||||
if (line_length <= 0)
|
||||
if (line_length <= 0 || line==NULL)
|
||||
break;
|
||||
|
||||
/* Ignore comment lines, which begin with a '#' character. */
|
||||
@@ -722,7 +906,7 @@ static int md5_check(const char *checkfile_name)
|
||||
if (split_3(line, line_length, &md5num, &binary, &filename)
|
||||
|| !hex_digits(md5num)) {
|
||||
if (warn) {
|
||||
error_msg("%s: %lu: improperly formatted MD5 checksum line\n",
|
||||
error_msg("%s: %lu: improperly formatted MD5 checksum line",
|
||||
checkfile_name, (unsigned long) line_number);
|
||||
}
|
||||
} else {
|
||||
@@ -766,22 +950,19 @@ static int md5_check(const char *checkfile_name)
|
||||
|
||||
while (!feof(checkfile_stream) && !ferror(checkfile_stream));
|
||||
|
||||
if (line)
|
||||
free(line);
|
||||
|
||||
if (ferror(checkfile_stream)) {
|
||||
error_msg("%s: read error\n", checkfile_name); /* */
|
||||
error_msg("%s: read error", checkfile_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (checkfile_stream != stdin && fclose(checkfile_stream) == EOF) {
|
||||
error_msg("md5sum: %s: %s\n", checkfile_name, strerror(errno));
|
||||
perror_msg("md5sum: %s", checkfile_name);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (n_properly_formated_lines == 0) {
|
||||
/* Warn if no tests are found. */
|
||||
error_msg("%s: no properly formatted MD5 checksum lines found\n",
|
||||
error_msg("%s: no properly formatted MD5 checksum lines found",
|
||||
checkfile_name);
|
||||
return FALSE;
|
||||
} else {
|
||||
@@ -790,13 +971,13 @@ static int md5_check(const char *checkfile_name)
|
||||
- n_open_or_read_failures);
|
||||
|
||||
if (n_open_or_read_failures > 0) {
|
||||
error_msg("WARNING: %d of %d listed files could not be read\n",
|
||||
error_msg("WARNING: %d of %d listed files could not be read",
|
||||
n_open_or_read_failures, n_properly_formated_lines);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (n_mismatched_checksums > 0) {
|
||||
error_msg("WARNING: %d of %d computed checksums did NOT match\n",
|
||||
error_msg("WARNING: %d of %d computed checksums did NOT match",
|
||||
n_mismatched_checksums, n_computed_checkums);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -825,8 +1006,6 @@ int md5sum_main(int argc,
|
||||
if (string == NULL)
|
||||
string = (char **) xmalloc ((argc - 1) * sizeof (char *));
|
||||
|
||||
if (optarg == NULL)
|
||||
optarg = "";
|
||||
string[n_strings++] = optarg;
|
||||
break;
|
||||
}
|
||||
@@ -856,36 +1035,31 @@ int md5sum_main(int argc,
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(md5sum_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (file_type_specified && do_check) {
|
||||
error_msg("the -b and -t options are meaningless when verifying checksums\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("the -b and -t options are meaningless when verifying checksums");
|
||||
}
|
||||
|
||||
if (n_strings > 0 && do_check) {
|
||||
error_msg("the -g and -c options are mutually exclusive\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("the -g and -c options are mutually exclusive");
|
||||
}
|
||||
|
||||
if (status_only && !do_check) {
|
||||
error_msg("the -s option is meaningful only when verifying checksums\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("the -s option is meaningful only when verifying checksums");
|
||||
}
|
||||
|
||||
if (warn && !do_check) {
|
||||
error_msg("the -w option is meaningful only when verifying checksums\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("the -w option is meaningful only when verifying checksums");
|
||||
}
|
||||
|
||||
if (n_strings > 0) {
|
||||
size_t i;
|
||||
|
||||
if (optind < argc) {
|
||||
error_msg("no files may be specified when using -g\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("no files may be specified when using -g");
|
||||
}
|
||||
for (i = 0; i < n_strings; ++i) {
|
||||
size_t cnt;
|
||||
@@ -898,7 +1072,7 @@ int md5sum_main(int argc,
|
||||
}
|
||||
} else if (do_check) {
|
||||
if (optind + 1 < argc) {
|
||||
error_msg("only one argument may be specified when using -c\n");
|
||||
error_msg("only one argument may be specified when using -c");
|
||||
}
|
||||
|
||||
err = md5_check ((optind == argc) ? "-" : argv[optind]);
|
||||
@@ -912,7 +1086,12 @@ int md5sum_main(int argc,
|
||||
|
||||
fail = md5_file (file, binary, md5buffer);
|
||||
err |= fail;
|
||||
if (!fail) {
|
||||
if (!fail && STREQ(file, "-")) {
|
||||
size_t i;
|
||||
for (i = 0; i < 16; ++i)
|
||||
printf ("%02x", md5buffer[i]);
|
||||
putchar ('\n');
|
||||
} else if (!fail) {
|
||||
size_t i;
|
||||
/* Output a leading backslash if the file name contains
|
||||
a newline or backslash. */
|
||||
@@ -951,13 +1130,11 @@ int md5sum_main(int argc,
|
||||
}
|
||||
|
||||
if (fclose (stdout) == EOF) {
|
||||
error_msg("write error\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("write error");
|
||||
}
|
||||
|
||||
if (have_read_stdin && fclose (stdin) == EOF) {
|
||||
error_msg("standard input\n");
|
||||
return EXIT_FAILURE;
|
||||
error_msg_and_die("standard input");
|
||||
}
|
||||
|
||||
if (err == 0)
|
||||
|
||||
+32
-72
@@ -2,8 +2,7 @@
|
||||
/*
|
||||
* Mini mkdir implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,84 +20,45 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#define bb_need_name_too_long
|
||||
#define BB_DECLARE_EXTERN
|
||||
#include "messages.c"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static int parentFlag = FALSE;
|
||||
static mode_t mode = 0777;
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
extern int mkdir_main(int argc, char **argv)
|
||||
extern int mkdir_main (int argc, char **argv)
|
||||
{
|
||||
int i = FALSE;
|
||||
mode_t mode = -1;
|
||||
int flags = 0;
|
||||
int status = 0;
|
||||
int i, opt;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse any options */
|
||||
while (argc > 0 && **argv == '-') {
|
||||
while (i == FALSE && *++(*argv)) {
|
||||
switch (**argv) {
|
||||
case 'm':
|
||||
if (--argc == 0)
|
||||
usage(mkdir_usage);
|
||||
/* Find the specified modes */
|
||||
mode = 0;
|
||||
if (parse_mode(*(++argv), &mode) == FALSE) {
|
||||
error_msg("Unknown mode: %s\n", *argv);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
/* Set the umask for this process so it doesn't
|
||||
* screw up whatever the user just entered. */
|
||||
umask(0);
|
||||
i = TRUE;
|
||||
break;
|
||||
case 'p':
|
||||
parentFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage(mkdir_usage);
|
||||
}
|
||||
while ((opt = getopt (argc, argv, "m:p")) != -1) {
|
||||
switch (opt) {
|
||||
case 'm':
|
||||
mode = 0777;
|
||||
if (!parse_mode (optarg, &mode))
|
||||
error_msg_and_die ("invalid mode `%s'", optarg);
|
||||
break;
|
||||
case 'p':
|
||||
flags |= FILEUTILS_RECUR;
|
||||
break;
|
||||
default:
|
||||
show_usage ();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (argc < 1) {
|
||||
usage(mkdir_usage);
|
||||
}
|
||||
if (optind == argc)
|
||||
show_usage ();
|
||||
|
||||
while (argc > 0) {
|
||||
int status;
|
||||
struct stat statBuf;
|
||||
char buf[BUFSIZ + 1];
|
||||
for (i = optind; i < argc; i++)
|
||||
if (make_directory (argv[i], mode, flags) < 0)
|
||||
status = 1;
|
||||
|
||||
if (strlen(*argv) > BUFSIZ - 1) {
|
||||
error_msg(name_too_long);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
strcpy(buf, *argv);
|
||||
status = stat(buf, &statBuf);
|
||||
if (parentFlag == FALSE && status != -1 && errno != ENOENT) {
|
||||
error_msg("%s: File exists\n", buf);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (parentFlag == TRUE) {
|
||||
strcat(buf, "/");
|
||||
create_path(buf, mode);
|
||||
} else {
|
||||
if (mkdir(buf, mode) != 0 && parentFlag == FALSE) {
|
||||
perror(buf);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
return status;
|
||||
}
|
||||
+7
-8
@@ -20,10 +20,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int mkfifo_main(int argc, char **argv)
|
||||
{
|
||||
@@ -36,7 +37,7 @@ extern int mkfifo_main(int argc, char **argv)
|
||||
/* Parse any options */
|
||||
while (argc > 1) {
|
||||
if (**argv != '-')
|
||||
usage(mkfifo_usage);
|
||||
show_usage();
|
||||
thisarg = *argv;
|
||||
thisarg++;
|
||||
switch (*thisarg) {
|
||||
@@ -46,16 +47,14 @@ extern int mkfifo_main(int argc, char **argv)
|
||||
parse_mode(*argv, &mode);
|
||||
break;
|
||||
default:
|
||||
usage(mkfifo_usage);
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc < 1 || *argv[0] == '-')
|
||||
usage(mkfifo_usage);
|
||||
if (mkfifo(*argv, mode) < 0) {
|
||||
perror("mkfifo");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
show_usage();
|
||||
if (mkfifo(*argv, mode) < 0)
|
||||
perror_msg_and_die("mkfifo");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+9
-7
@@ -20,12 +20,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
int mknod_main(int argc, char **argv)
|
||||
{
|
||||
@@ -51,13 +53,13 @@ int mknod_main(int argc, char **argv)
|
||||
umask(0);
|
||||
break;
|
||||
default:
|
||||
usage(mknod_usage);
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc != 4 && argc != 2) {
|
||||
usage(mknod_usage);
|
||||
show_usage();
|
||||
}
|
||||
switch (argv[1][0]) {
|
||||
case 'c':
|
||||
@@ -70,11 +72,11 @@ int mknod_main(int argc, char **argv)
|
||||
case 'p':
|
||||
mode = S_IFIFO;
|
||||
if (argc!=2) {
|
||||
usage(mknod_usage);
|
||||
show_usage();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage(mknod_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if (mode == S_IFCHR || mode == S_IFBLK) {
|
||||
@@ -84,7 +86,7 @@ int mknod_main(int argc, char **argv)
|
||||
mode |= perm;
|
||||
|
||||
if (mknod(argv[0], mode, dev) != 0)
|
||||
error_msg_and_die("%s: %s\n", argv[0], strerror(errno));
|
||||
perror_msg_and_die("%s", argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+168
@@ -0,0 +1,168 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini mv implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
static int flags;
|
||||
|
||||
static int manual_rename(const char *source, const char *dest)
|
||||
{
|
||||
struct stat source_stat;
|
||||
struct stat dest_stat;
|
||||
int source_exists = 1;
|
||||
int dest_exists = 1;
|
||||
|
||||
if (stat(source, &source_stat) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
perror_msg("unable to stat `%s'", source);
|
||||
return -1;
|
||||
}
|
||||
source_exists = 0;
|
||||
}
|
||||
|
||||
if (stat(dest, &dest_stat) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
perror_msg("unable to stat `%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
dest_exists = 0;
|
||||
}
|
||||
|
||||
if (dest_exists) {
|
||||
if (S_ISDIR(dest_stat.st_mode) &&
|
||||
(!source_exists || !S_ISDIR(source_stat.st_mode))) {
|
||||
error_msg("cannot overwrite directory with non-directory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!S_ISDIR(dest_stat.st_mode) && source_exists &&
|
||||
S_ISDIR(source_stat.st_mode)) {
|
||||
error_msg("cannot overwrite non-directory with directory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (unlink(dest) < 0) {
|
||||
perror_msg("cannot remove `%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (copy_file(source, dest, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS |
|
||||
FILEUTILS_PRESERVE_SYMLINKS) < 0)
|
||||
return -1;
|
||||
|
||||
if (remove_file(source, FILEUTILS_RECUR | FILEUTILS_FORCE) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int move_file(const char *source, const char *dest)
|
||||
{
|
||||
struct stat dest_stat;
|
||||
int dest_exists = 1;
|
||||
|
||||
if (stat(dest, &dest_stat) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
perror_msg("unable to stat `%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
dest_exists = 0;
|
||||
}
|
||||
|
||||
if (dest_exists && !(flags & FILEUTILS_FORCE) &&
|
||||
((access(dest, W_OK) < 0 && isatty(0)) ||
|
||||
(flags & FILEUTILS_INTERACTIVE))) {
|
||||
fprintf(stderr, "mv: overwrite `%s'? ", dest);
|
||||
if (!ask_confirmation())
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (rename(source, dest) < 0) {
|
||||
if (errno == EXDEV)
|
||||
return manual_rename(source, dest);
|
||||
|
||||
perror_msg("unable to rename `%s'", source);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int mv_main(int argc, char **argv)
|
||||
{
|
||||
int status = 0;
|
||||
int opt;
|
||||
int i;
|
||||
|
||||
while ((opt = getopt(argc, argv, "fi")) != -1)
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
flags &= ~FILEUTILS_INTERACTIVE;
|
||||
flags |= FILEUTILS_FORCE;
|
||||
break;
|
||||
case 'i':
|
||||
flags &= ~FILEUTILS_FORCE;
|
||||
flags |= FILEUTILS_INTERACTIVE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if (optind + 2 > argc)
|
||||
show_usage();
|
||||
|
||||
if (optind + 2 == argc) {
|
||||
struct stat dest_stat;
|
||||
int dest_exists = 1;
|
||||
|
||||
if (stat(argv[optind + 1], &dest_stat) < 0) {
|
||||
if (errno != ENOENT)
|
||||
perror_msg_and_die("unable to stat `%s'", argv[optind + 1]);
|
||||
dest_exists = 0;
|
||||
}
|
||||
|
||||
if (!dest_exists || !S_ISDIR(dest_stat.st_mode)) {
|
||||
if (move_file(argv[optind], argv[optind + 1]) < 0)
|
||||
status = 1;
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = optind; i < argc - 1; i++) {
|
||||
char *dest = concat_path_file(argv[argc - 1],
|
||||
get_last_path_component(argv[i]));
|
||||
if (move_file(argv[i], dest) < 0)
|
||||
status = 1;
|
||||
free(dest);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
+4
-23
@@ -47,7 +47,6 @@
|
||||
|
||||
// 19990508 Busy Boxed! Dave Cinege
|
||||
|
||||
#include "busybox.h"
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
@@ -56,10 +55,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
#ifndef S_IFMT
|
||||
# define S_IFMT 0170000
|
||||
static const int S_IFMT = 0170000;
|
||||
#endif
|
||||
#if !defined(S_ISBLK) && defined(S_IFBLK)
|
||||
# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
@@ -92,28 +92,9 @@
|
||||
|
||||
#define IN_CTYPE_DOMAIN(c) 1
|
||||
|
||||
#ifdef isblank
|
||||
# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c))
|
||||
#else
|
||||
# define ISBLANK(c) ((c) == ' ' || (c) == '\t')
|
||||
#endif
|
||||
#ifdef isgraph
|
||||
# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isgraph (c))
|
||||
#else
|
||||
# define ISGRAPH(c) (IN_CTYPE_DOMAIN (c) && isprint (c) && !isspace (c))
|
||||
#endif
|
||||
|
||||
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
|
||||
#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
|
||||
#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
|
||||
#define ISCNTRL(c) (IN_CTYPE_DOMAIN (c) && iscntrl (c))
|
||||
#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
|
||||
#define ISPUNCT(c) (IN_CTYPE_DOMAIN (c) && ispunct (c))
|
||||
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
|
||||
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
|
||||
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
|
||||
#define ISDIGIT_LOCALE(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
|
||||
#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
|
||||
#define ISDIGIT(c) (((unsigned char) (c)) - '0' <= 9)
|
||||
|
||||
#define isodigit(c) ((c) >= '0' && (c) <= '7')
|
||||
#define hextobin(c) ((c)>='a'&&(c)<='f' ? (c)-'a'+10 : (c)>='A'&&(c)<='F' ? (c)-'A'+10 : (c)-'0')
|
||||
@@ -143,7 +124,7 @@ int printf_main(int argc, char **argv)
|
||||
|
||||
exit_status = 0;
|
||||
if (argc <= 1 || **(argv + 1) == '-') {
|
||||
usage(printf_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
format = argv[1];
|
||||
|
||||
+14
-8
@@ -21,18 +21,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int pwd_main(int argc, char **argv)
|
||||
{
|
||||
char buf[BUFSIZ + 1];
|
||||
|
||||
if (getcwd(buf, sizeof(buf)) == NULL)
|
||||
error_msg_and_die("%s\n", strerror(errno));
|
||||
|
||||
printf("%s\n", buf);
|
||||
return EXIT_SUCCESS;
|
||||
static char *buf;
|
||||
|
||||
buf = xgetcwd(buf);
|
||||
|
||||
if (buf != NULL) {
|
||||
puts(buf);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
+41
-75
@@ -3,8 +3,8 @@
|
||||
* Mini rm implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* Copyright (C) 2001 Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,90 +22,56 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int recursiveFlag = FALSE;
|
||||
static int forceFlag = FALSE;
|
||||
static const char *srcName;
|
||||
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (unlink(fileName) < 0) {
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static int dirAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (recursiveFlag == FALSE) {
|
||||
errno = EISDIR;
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
if (rmdir(fileName) < 0) {
|
||||
perror_msg("%s", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int rm_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int stopIt=FALSE;
|
||||
struct stat statbuf;
|
||||
int status = 0;
|
||||
int opt;
|
||||
int flags = 0;
|
||||
int i;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse any options */
|
||||
while (argc > 0 && stopIt == FALSE) {
|
||||
if (**argv == '-') {
|
||||
while (*++(*argv))
|
||||
switch (**argv) {
|
||||
case 'R':
|
||||
case 'r':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
case 'f':
|
||||
forceFlag = TRUE;
|
||||
break;
|
||||
case '-':
|
||||
stopIt = TRUE;
|
||||
break;
|
||||
default:
|
||||
usage(rm_usage);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
else
|
||||
while ((opt = getopt(argc, argv, "fiRr")) != -1) {
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
flags &= ~FILEUTILS_INTERACTIVE;
|
||||
flags |= FILEUTILS_FORCE;
|
||||
break;
|
||||
case 'i':
|
||||
flags &= ~FILEUTILS_FORCE;
|
||||
flags |= FILEUTILS_INTERACTIVE;
|
||||
break;
|
||||
case 'R':
|
||||
case 'r':
|
||||
flags |= FILEUTILS_RECUR;
|
||||
break;
|
||||
}
|
||||
|
||||
if (argc < 1 && forceFlag == FALSE) {
|
||||
usage(rm_usage);
|
||||
}
|
||||
|
||||
while (argc-- > 0) {
|
||||
srcName = *(argv++);
|
||||
if (forceFlag == TRUE && lstat(srcName, &statbuf) != 0
|
||||
&& errno == ENOENT) {
|
||||
/* do not reports errors for non-existent files if -f, just skip them */
|
||||
} else {
|
||||
if (recursive_action(srcName, recursiveFlag, FALSE,
|
||||
TRUE, fileAction, dirAction, NULL) == FALSE) {
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!(flags & FILEUTILS_FORCE) && optind == argc)
|
||||
show_usage();
|
||||
|
||||
for (i = optind; i < argc; i++) {
|
||||
char *base = get_last_path_component(argv[i]);
|
||||
|
||||
if (strcmp(base, ".") == 0 || strcmp(base, "..") == 0) {
|
||||
error_msg("cannot remove `.' or `..'");
|
||||
status = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (remove_file(argv[i], flags) < 0)
|
||||
status = 1;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
+5
-3
@@ -3,7 +3,7 @@
|
||||
* Mini rmdir implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,16 +22,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int rmdir_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc == 1 || **(argv + 1) == '-')
|
||||
usage(rmdir_usage);
|
||||
show_usage();
|
||||
|
||||
while (--argc > 0) {
|
||||
if (rmdir(*(++argv)) == -1) {
|
||||
|
||||
+6
-6
@@ -21,18 +21,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int sleep_main(int argc, char **argv)
|
||||
{
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
usage(sleep_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if (sleep(atoi(*(++argv))) != 0) {
|
||||
perror("sleep");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (sleep(atoi(*(++argv))) != 0)
|
||||
perror_msg_and_die("sleep");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+57
-240
@@ -3,8 +3,7 @@
|
||||
* Mini sort implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Written by John Beppu <beppu@lineo.com>
|
||||
* Copyright (C) 2000 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,268 +21,86 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
#define APPLY_REVERSE(x) (reverse ? -(x) : (x))
|
||||
static int reverse = 0;
|
||||
#else
|
||||
#define APPLY_REVERSE(x) (x)
|
||||
#endif
|
||||
|
||||
/* typedefs _______________________________________________________________ */
|
||||
|
||||
/* line node */
|
||||
typedef struct Line {
|
||||
char *data; /* line data */
|
||||
struct Line *next; /* pointer to next line node */
|
||||
} Line;
|
||||
|
||||
/* singly-linked list of lines */
|
||||
typedef struct {
|
||||
int len; /* number of Lines */
|
||||
Line **sorted; /* array fed to qsort */
|
||||
Line *head; /* head of List */
|
||||
Line *current; /* current Line */
|
||||
} List;
|
||||
|
||||
/* comparison function */
|
||||
typedef int (Compare) (const void *, const void *);
|
||||
|
||||
|
||||
/* methods ________________________________________________________________ */
|
||||
|
||||
static const int max = 1024;
|
||||
|
||||
/* mallocate Line */
|
||||
static Line *line_alloc()
|
||||
static int compare_ascii(const void *x, const void *y)
|
||||
{
|
||||
Line *self;
|
||||
self = xmalloc(1 * sizeof(Line));
|
||||
return self;
|
||||
return strcmp(*(char **)x, *(char **)y);
|
||||
}
|
||||
|
||||
/* Construct Line from FILE* */
|
||||
static Line *line_newFromFile(FILE * src)
|
||||
static int compare_numeric(const void *x, const void *y)
|
||||
{
|
||||
Line *self;
|
||||
char *cstring = NULL;
|
||||
|
||||
if ((cstring = get_line_from_file(src))) {
|
||||
self = line_alloc();
|
||||
self->data = cstring;
|
||||
self->next = NULL;
|
||||
return self;
|
||||
}
|
||||
return NULL;
|
||||
int z = atoi(*(char **)x) - atoi(*(char **)y);
|
||||
return z ? z : strcmp(*(char **)x, *(char **)y);
|
||||
}
|
||||
|
||||
/* Line destructor */
|
||||
static Line *line_release(Line * self)
|
||||
{
|
||||
if (self->data) {
|
||||
free(self->data);
|
||||
free(self);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
/* Comparison */
|
||||
|
||||
/* ascii order */
|
||||
static int compare_ascii(const void *a, const void *b)
|
||||
{
|
||||
Line **val;
|
||||
Line *x, *y;
|
||||
|
||||
val = (Line **) a;
|
||||
x = *val;
|
||||
val = (Line **) b;
|
||||
y = *val;
|
||||
|
||||
// fprintf(stdout, "> %p: %s< %p: %s", x, x->data, y, y->data);
|
||||
return APPLY_REVERSE(strcmp(x->data, y->data));
|
||||
}
|
||||
|
||||
/* numeric order */
|
||||
static int compare_numeric(const void *a, const void *b)
|
||||
{
|
||||
Line **val;
|
||||
Line *x, *y;
|
||||
int xint, yint;
|
||||
|
||||
val = (Line **) a;
|
||||
x = *val;
|
||||
val = (Line **) b;
|
||||
y = *val;
|
||||
|
||||
xint = strtoul(x->data, NULL, 10);
|
||||
yint = strtoul(y->data, NULL, 10);
|
||||
|
||||
return APPLY_REVERSE(xint - yint);
|
||||
}
|
||||
|
||||
|
||||
/* List */
|
||||
|
||||
/* */
|
||||
static List *list_init(List * self)
|
||||
{
|
||||
self->len = 0;
|
||||
self->sorted = NULL;
|
||||
self->head = NULL;
|
||||
self->current = NULL;
|
||||
return self;
|
||||
}
|
||||
|
||||
/* for simplicity, the List gains ownership of the line */
|
||||
static List *list_insert(List * self, Line * line)
|
||||
{
|
||||
if (line == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* first insertion */
|
||||
if (self->head == NULL) {
|
||||
self->head = line;
|
||||
self->current = line;
|
||||
|
||||
/* all subsequent insertions */
|
||||
} else {
|
||||
self->current->next = line;
|
||||
self->current = line;
|
||||
}
|
||||
self->len++;
|
||||
return self;
|
||||
}
|
||||
|
||||
/* order the list according to compare() */
|
||||
static List *list_sort(List * self, Compare * compare)
|
||||
{
|
||||
int i;
|
||||
Line *line;
|
||||
|
||||
/* mallocate array of Line*s */
|
||||
self->sorted = (Line **) xmalloc(self->len * sizeof(Line *));
|
||||
|
||||
/* fill array w/ List's contents */
|
||||
i = 0;
|
||||
line = self->head;
|
||||
while (line) {
|
||||
self->sorted[i++] = line;
|
||||
line = line->next;
|
||||
}
|
||||
|
||||
/* apply qsort */
|
||||
qsort(self->sorted, self->len, sizeof(Line *), compare);
|
||||
return self;
|
||||
}
|
||||
|
||||
/* precondition: list must be sorted */
|
||||
static List *list_writeToFile(List * self, FILE * dst)
|
||||
{
|
||||
int i;
|
||||
Line **line = self->sorted;
|
||||
|
||||
if (self->sorted == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
for (i = 0; i < self->len; i++) {
|
||||
fprintf(dst, "%s", line[i]->data);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/* deallocate */
|
||||
static void list_release(List * self)
|
||||
{
|
||||
Line *i;
|
||||
Line *die;
|
||||
|
||||
i = self->head;
|
||||
while (i) {
|
||||
die = i;
|
||||
i = die->next;
|
||||
line_release(die);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int sort_main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
char opt;
|
||||
List list;
|
||||
Line *l;
|
||||
Compare *compare;
|
||||
FILE *fp;
|
||||
char *line, **lines = NULL;
|
||||
int i, opt, nlines = 0;
|
||||
int (*compare)(const void *, const void *) = compare_ascii;
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
int reverse = FALSE;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_SORT_UNIQUE
|
||||
int unique = FALSE;
|
||||
#endif
|
||||
|
||||
/* init */
|
||||
compare = compare_ascii;
|
||||
list_init(&list);
|
||||
|
||||
/* parse argv[] */
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
opt = argv[i][1];
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
usage(sort_usage);
|
||||
break;
|
||||
while ((opt = getopt(argc, argv, "nru")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
/* numeric comparison */
|
||||
compare = compare_numeric;
|
||||
break;
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
case 'r':
|
||||
/* reverse */
|
||||
reverse = 1;
|
||||
reverse = TRUE;
|
||||
break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_SORT_UNIQUE
|
||||
case 'u':
|
||||
unique = TRUE;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
error_msg("invalid option -- %c\n", opt);
|
||||
usage(sort_usage);
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= argc) {
|
||||
/* read the input */
|
||||
for (i = optind; i == optind || i < argc; i++) {
|
||||
if (argv[i] == NULL)
|
||||
fp = stdin;
|
||||
else
|
||||
fp = xfopen(argv[i], "r");
|
||||
|
||||
/* work w/ stdin */
|
||||
while ((l = line_newFromFile(stdin))) {
|
||||
list_insert(&list, l);
|
||||
while ((line = get_line_from_file(fp)) != NULL) {
|
||||
lines = xrealloc(lines, sizeof(char *) * (nlines + 1));
|
||||
chomp(line);
|
||||
lines[nlines++] = line;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/* work w/ what's left in argv[] */
|
||||
FILE *src;
|
||||
|
||||
for (; i < argc; i++) {
|
||||
src = fopen(argv[i], "r");
|
||||
if (src == NULL) {
|
||||
break;
|
||||
}
|
||||
while ((l = line_newFromFile(src))) {
|
||||
list_insert(&list, l);
|
||||
}
|
||||
fclose(src);
|
||||
}
|
||||
|
||||
}
|
||||
list_sort(&list, compare);
|
||||
list_writeToFile(&list, stdout);
|
||||
list_release(&list);
|
||||
|
||||
return(0);
|
||||
/* sort it */
|
||||
qsort(lines, nlines, sizeof(char *), compare);
|
||||
|
||||
/* print it */
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
if (reverse) {
|
||||
for (i = --nlines; 0 <= i; i--)
|
||||
#ifdef BB_FEATURE_SORT_UNIQUE
|
||||
if((!unique) || (i == nlines) || (strcmp(lines[i + 1], lines[i])))
|
||||
#endif
|
||||
puts(lines[i]);
|
||||
} else
|
||||
#endif
|
||||
for (i = 0; i < nlines; i++)
|
||||
#ifdef BB_FEATURE_SORT_UNIQUE
|
||||
if((!unique) || (!i) || (strcmp(lines[i - 1], lines[i])))
|
||||
#endif
|
||||
puts(lines[i]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* $Id: sort.c,v 1.24 2000/12/07 19:56:48 markw Exp $ */
|
||||
+1376
File diff suppressed because it is too large.
Load diff
+6
-3
@@ -21,12 +21,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int sync_main(int argc, char **argv)
|
||||
{
|
||||
if (argc > 1 && **(argv + 1) == '-')
|
||||
usage(sync_usage);
|
||||
return(sync());
|
||||
show_usage();
|
||||
sync();
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
+220
-288
@@ -1,319 +1,251 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/* tail -- output the last part of file(s)
|
||||
Copyright (C) 89, 90, 91, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
Original version by Paul Rubin <phr@ocf.berkeley.edu>.
|
||||
Extensions by David MacKenzie <djm@gnu.ai.mit.edu>.
|
||||
tail -f for multiple files by Ian Lance Taylor <ian@airs.com>.
|
||||
|
||||
Rewrote the option parser, removed locales support,
|
||||
and generally busyboxed, Erik Andersen <andersen@lineo.com>
|
||||
|
||||
Removed superfluous options and associated code ("-c", "-n", "-q").
|
||||
Removed "tail -f" support for multiple files.
|
||||
Both changes by Friedrich Vedder <fwv@myrtle.lahn.de>.
|
||||
|
||||
Compleate Rewrite to correctly support "-NUM", "+NUM", and "-s" by
|
||||
E.Allen Soard (esp@espsw.net).
|
||||
|
||||
/*
|
||||
* Mini tail implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2001 by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define STDIN "standard input"
|
||||
#define LINES 0
|
||||
#define BYTES 1
|
||||
static const struct suffix_mult tail_suffixes[] = {
|
||||
{ "b", 512 },
|
||||
{ "k", 1024 },
|
||||
{ "m", 1048576 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static int n_files = 0;
|
||||
static char **files = NULL;
|
||||
static char * buffer;
|
||||
static ssize_t bytes_read=0;
|
||||
static ssize_t bs;
|
||||
static ssize_t filelocation=0;
|
||||
static char pip;
|
||||
static const int BYTES = 0;
|
||||
static const int LINES = 1;
|
||||
|
||||
#ifdef BB_FEATURE_SIMPLE_TAIL
|
||||
static const char unit_type=LINES;
|
||||
#else
|
||||
static char unit_type=LINES;
|
||||
static char verbose = 0;
|
||||
#endif
|
||||
static char *tailbuf;
|
||||
static int taillen;
|
||||
static int newline;
|
||||
|
||||
static off_t units=0;
|
||||
|
||||
static int tail_stream(int fd)
|
||||
static void tailbuf_append(char *buf, int len)
|
||||
{
|
||||
ssize_t startpoint;
|
||||
ssize_t endpoint=0;
|
||||
ssize_t count=0;
|
||||
ssize_t filesize=0;
|
||||
int direction=1;
|
||||
|
||||
filelocation=0;
|
||||
startpoint=bs=BUFSIZ;
|
||||
|
||||
filesize=lseek(fd, -1, SEEK_END)+1;
|
||||
pip=(filesize<=0);
|
||||
|
||||
if(units>=0)
|
||||
lseek(fd,0,SEEK_SET);
|
||||
else {
|
||||
direction=-1;
|
||||
count=1;
|
||||
}
|
||||
while(units != 0) {
|
||||
if (pip) {
|
||||
char * line;
|
||||
ssize_t f_size=0;
|
||||
|
||||
bs=BUFSIZ;
|
||||
line=xmalloc(bs);
|
||||
while(1) {
|
||||
bytes_read=read(fd,line,bs);
|
||||
if(bytes_read<=0)
|
||||
break;
|
||||
buffer=xrealloc(buffer,f_size+bytes_read);
|
||||
memcpy(&buffer[f_size],line,bytes_read);
|
||||
filelocation=f_size+=bytes_read;
|
||||
}
|
||||
bs=f_size;
|
||||
if(direction<0)
|
||||
bs--;
|
||||
if (line)
|
||||
free(line);
|
||||
} else {
|
||||
filelocation = lseek(fd, 0, SEEK_CUR);
|
||||
if(direction<0) {
|
||||
if(filelocation<bs)
|
||||
bs=filelocation;
|
||||
filelocation = lseek(fd, -bs, SEEK_CUR);
|
||||
}
|
||||
bytes_read = read(fd, buffer, bs);
|
||||
if (bytes_read <= 0)
|
||||
break;
|
||||
bs=bytes_read;
|
||||
}
|
||||
startpoint=bs;
|
||||
if(direction>0) {
|
||||
endpoint=startpoint;
|
||||
startpoint=0;
|
||||
}
|
||||
for(;startpoint!=endpoint;startpoint+=direction) {
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
if(unit_type==BYTES)
|
||||
count++;
|
||||
else
|
||||
#endif
|
||||
if(buffer[startpoint-1]=='\n')
|
||||
count++;
|
||||
if (!pip)
|
||||
filelocation=lseek(fd,0,SEEK_CUR);
|
||||
if(count==units*direction)
|
||||
break;
|
||||
}
|
||||
if((count==units*direction) | pip)
|
||||
break;
|
||||
if(direction<0){
|
||||
filelocation = lseek(fd, -bytes_read, SEEK_CUR);
|
||||
if(filelocation==0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(pip && (direction<0))
|
||||
bs++;
|
||||
bytes_read=bs-startpoint;
|
||||
memcpy(&buffer[0],&buffer[startpoint],bytes_read);
|
||||
|
||||
return 0;
|
||||
tailbuf = xrealloc(tailbuf, taillen + len);
|
||||
memcpy(tailbuf + taillen, buf, len);
|
||||
taillen += len;
|
||||
}
|
||||
|
||||
void add_file(char *name)
|
||||
static void tailbuf_trunc()
|
||||
{
|
||||
++n_files;
|
||||
files = xrealloc(files, n_files);
|
||||
files[n_files - 1] = (char *) xmalloc(strlen(name) + 1);
|
||||
strcpy(files[n_files - 1], name);
|
||||
char *s;
|
||||
s = memchr(tailbuf, '\n', taillen);
|
||||
memmove(tailbuf, s + 1, taillen - ((s + 1) - tailbuf));
|
||||
taillen -= (s + 1) - tailbuf;
|
||||
newline = 0;
|
||||
}
|
||||
|
||||
int tail_main(int argc, char **argv)
|
||||
{
|
||||
int show_headers = 1;
|
||||
int test;
|
||||
int opt;
|
||||
char follow=0;
|
||||
int sleep_int=1;
|
||||
int *fd;
|
||||
|
||||
opterr = 0;
|
||||
|
||||
while ((opt=getopt(argc,argv,"c:fhn:s:q:v")) >0) {
|
||||
int from_top = 0, units = LINES, count = 10, sleep_period = 1;
|
||||
int show_headers = 0, hide_headers = 0, follow = 0;
|
||||
int *fds, nfiles = 0, status = EXIT_SUCCESS, nread, nwrite, seen = 0;
|
||||
char *s, *start, *end, buf[BUFSIZ];
|
||||
int i, opt;
|
||||
|
||||
while ((opt = getopt(argc, argv, "c:fhn:q:s:v")) > 0) {
|
||||
switch (opt) {
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
case 'c':
|
||||
unit_type = BYTES;
|
||||
test = atoi(optarg);
|
||||
if(test==0)
|
||||
usage(tail_usage);
|
||||
if(optarg[strlen(optarg)-1]>'9') {
|
||||
switch (optarg[strlen(optarg)-1]) {
|
||||
case 'b':
|
||||
test *= 512;
|
||||
break;
|
||||
case 'k':
|
||||
test *= 1024;
|
||||
break;
|
||||
case 'm':
|
||||
test *= (1024 * 1024);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr,"Size must be b,k, or m.");
|
||||
usage(tail_usage);
|
||||
}
|
||||
}
|
||||
if(optarg[0]=='+')
|
||||
units=test+1;
|
||||
else
|
||||
units=-(test+1);
|
||||
break;
|
||||
case 'q':
|
||||
show_headers = 0;
|
||||
break;
|
||||
case 's':
|
||||
sleep_int = atoi(optarg);
|
||||
if(sleep_int<1)
|
||||
sleep_int=1;
|
||||
break;
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case 'f':
|
||||
follow = 1;
|
||||
break;
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
case 'c':
|
||||
units = BYTES;
|
||||
/* FALLS THROUGH */
|
||||
#endif
|
||||
case 'f':
|
||||
follow = 1;
|
||||
break;
|
||||
case 'h':
|
||||
usage(tail_usage);
|
||||
break;
|
||||
case 'n':
|
||||
test = atoi(optarg);
|
||||
if (test) {
|
||||
case 'n':
|
||||
count = parse_number(optarg, tail_suffixes);
|
||||
if (count < 0)
|
||||
count = -count;
|
||||
if (optarg[0] == '+')
|
||||
units = test;
|
||||
else
|
||||
units = -(test+1);
|
||||
} else
|
||||
usage(tail_usage);
|
||||
break;
|
||||
default:
|
||||
error_msg("\nUnknown arg: %c.\n\n",optopt);
|
||||
usage(tail_usage);
|
||||
}
|
||||
}
|
||||
while (optind <= argc) {
|
||||
if(optind==argc) {
|
||||
if (n_files==0)
|
||||
add_file(STDIN);
|
||||
else
|
||||
from_top = 1;
|
||||
break;
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
case 'q':
|
||||
hide_headers = 1;
|
||||
break;
|
||||
case 's':
|
||||
sleep_period = parse_number(optarg, 0);
|
||||
break;
|
||||
case 'v':
|
||||
show_headers = 1;
|
||||
break;
|
||||
}else {
|
||||
if (!strcmp(argv[optind], "-")) {
|
||||
add_file(STDIN);
|
||||
} else {
|
||||
add_file(argv[optind]);
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
}
|
||||
if(units==0)
|
||||
units=-11;
|
||||
if(units>0)
|
||||
units--;
|
||||
fd=xmalloc(sizeof(int)*n_files);
|
||||
if (n_files == 1)
|
||||
#ifndef BB_FEATURE_SIMPLE_TAIL
|
||||
if (!verbose)
|
||||
#endif
|
||||
show_headers = 0;
|
||||
buffer=xmalloc(BUFSIZ);
|
||||
for (test = 0; test < n_files; test++) {
|
||||
if (show_headers)
|
||||
printf("==> %s <==\n", files[test]);
|
||||
if (!strcmp(files[test], STDIN))
|
||||
fd[test] = 0;
|
||||
else
|
||||
fd[test] = open(files[test], O_RDONLY);
|
||||
if (fd[test] == -1)
|
||||
error_msg_and_die("Unable to open file %s.\n", files[test]);
|
||||
tail_stream(fd[test]);
|
||||
|
||||
bs=BUFSIZ;
|
||||
while (1) {
|
||||
if((filelocation>0 || pip)){
|
||||
write(1,buffer,bytes_read);
|
||||
}
|
||||
bytes_read = read(fd[test], buffer, bs);
|
||||
filelocation+=bytes_read;
|
||||
if (bytes_read <= 0) {
|
||||
break;
|
||||
}
|
||||
usleep(sleep_int * 1000);
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
if(n_files>1)
|
||||
printf("\n");
|
||||
}
|
||||
while(1){
|
||||
for (test = 0; test < n_files; test++) {
|
||||
if(!follow){
|
||||
close(fd[test]);
|
||||
continue;
|
||||
|
||||
/* open all the files */
|
||||
fds = (int *)xmalloc(sizeof(int) * (argc - optind + 1));
|
||||
if (argc == optind) {
|
||||
fds[nfiles++] = STDIN_FILENO;
|
||||
argv[optind] = "standard input";
|
||||
} else {
|
||||
for (i = optind; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-") == 0) {
|
||||
fds[nfiles++] = STDIN_FILENO;
|
||||
argv[i] = "standard input";
|
||||
} else if ((fds[nfiles++] = open(argv[i], O_RDONLY)) < 0) {
|
||||
perror_msg("%s", argv[i]);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
/* tail the files */
|
||||
if (!from_top && units == BYTES)
|
||||
tailbuf = xmalloc(count);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < nfiles; i++) {
|
||||
if (fds[i] == -1)
|
||||
continue;
|
||||
if (!count) {
|
||||
lseek(fds[i], 0, SEEK_END);
|
||||
continue;
|
||||
}
|
||||
seen = 0;
|
||||
if (show_headers || (!hide_headers && nfiles > 1))
|
||||
printf("%s==> %s <==\n", i == 0 ? "" : "\n", argv[optind + i]);
|
||||
while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
|
||||
if (from_top) {
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
if (units == BYTES) {
|
||||
if (count - 1 <= seen)
|
||||
nwrite = nread;
|
||||
else if (count - 1 <= seen + nread)
|
||||
nwrite = nread + seen - (count - 1);
|
||||
else
|
||||
nwrite = 0;
|
||||
seen += nread;
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
if (count - 1 <= seen)
|
||||
nwrite = nread;
|
||||
else {
|
||||
nwrite = 0;
|
||||
for (s = memchr(buf, '\n', nread); s != NULL;
|
||||
s = memchr(s+1, '\n', nread - (s + 1 - buf))) {
|
||||
if (count - 1 <= ++seen) {
|
||||
nwrite = nread - (s + 1 - buf);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (full_write(STDOUT_FILENO, buf + nread - nwrite,
|
||||
nwrite) < 0) {
|
||||
perror_msg("write");
|
||||
status = EXIT_FAILURE;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
sleep(sleep_int);
|
||||
bytes_read = read(fd[test], buffer, bs);
|
||||
if(bytes_read>0) {
|
||||
if (show_headers)
|
||||
printf("==> %s <==\n", files[test]);
|
||||
write(1,buffer,bytes_read);
|
||||
if(n_files>1)
|
||||
printf("\n");
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
if (units == BYTES) {
|
||||
if (nread < count) {
|
||||
memmove(tailbuf, tailbuf + nread, count - nread);
|
||||
memcpy(tailbuf + count - nread, buf, nread);
|
||||
} else {
|
||||
memcpy(tailbuf, buf + nread - count, count);
|
||||
}
|
||||
seen += nread;
|
||||
} else {
|
||||
#else
|
||||
{
|
||||
#endif
|
||||
for (start = buf, end = memchr(buf, '\n', nread);
|
||||
end != NULL; start = end+1,
|
||||
end = memchr(start, '\n', nread - (start - buf))) {
|
||||
if (newline && count <= seen)
|
||||
tailbuf_trunc();
|
||||
tailbuf_append(start, end - start + 1);
|
||||
seen++;
|
||||
newline = 1;
|
||||
}
|
||||
if (newline && count <= seen && nread - (start - buf) > 0)
|
||||
tailbuf_trunc();
|
||||
tailbuf_append(start, nread - (start - buf));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!follow)
|
||||
break;
|
||||
}
|
||||
if (fd)
|
||||
free(fd);
|
||||
if (buffer)
|
||||
free(buffer);
|
||||
if(files)
|
||||
free(files);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
if (nread < 0) {
|
||||
perror_msg("read");
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
if (!from_top && units == BYTES) {
|
||||
if (count < seen)
|
||||
seen = count;
|
||||
if (full_write(STDOUT_FILENO, tailbuf + count - seen, seen) < 0) {
|
||||
perror_msg("write");
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!from_top && units == LINES) {
|
||||
if (full_write(STDOUT_FILENO, tailbuf, taillen) < 0) {
|
||||
perror_msg("write");
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
taillen = 0;
|
||||
}
|
||||
|
||||
while (follow) {
|
||||
sleep(sleep_period);
|
||||
|
||||
for (i = 0; i < nfiles; i++) {
|
||||
if (fds[i] == -1)
|
||||
continue;
|
||||
|
||||
if ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0) {
|
||||
if (show_headers || (!hide_headers && nfiles > 1))
|
||||
printf("\n==> %s <==\n", argv[optind + i]);
|
||||
|
||||
do {
|
||||
full_write(STDOUT_FILENO, buf, nread);
|
||||
} while ((nread = safe_read(fds[i], buf, sizeof(buf))) > 0);
|
||||
}
|
||||
|
||||
if (nread < 0) {
|
||||
perror_msg("read");
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
/*
|
||||
* Mini tee implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -38,7 +38,7 @@ tee_main(int argc, char **argv)
|
||||
mode = "a";
|
||||
break;
|
||||
default:
|
||||
usage(tee_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ tee_main(int argc, char **argv)
|
||||
while (optind < argc) {
|
||||
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
|
||||
nfiles--;
|
||||
error_msg("%s: %s\n", argv[optind-1], strerror(errno));
|
||||
perror_msg("%s", argv[optind-1]);
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
+10
-13
@@ -31,16 +31,13 @@
|
||||
* "This program is in the Public Domain."
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define BB_DECLARE_EXTERN
|
||||
#define bb_need_help
|
||||
#include "messages.c"
|
||||
#include "busybox.h"
|
||||
|
||||
/* test(1) accepts the following grammar:
|
||||
oexpr ::= aexpr | aexpr "-o" oexpr ;
|
||||
@@ -110,10 +107,10 @@ enum token_types {
|
||||
PAREN
|
||||
};
|
||||
|
||||
struct t_op {
|
||||
static const struct t_op {
|
||||
const char *op_text;
|
||||
short op_num, op_type;
|
||||
} const ops [] = {
|
||||
} ops [] = {
|
||||
{"-r", FILRD, UNOP},
|
||||
{"-w", FILWR, UNOP},
|
||||
{"-x", FILEX, UNOP},
|
||||
@@ -156,8 +153,8 @@ struct t_op {
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
char **t_wp;
|
||||
struct t_op const *t_wp_op;
|
||||
static char **t_wp;
|
||||
static struct t_op const *t_wp_op;
|
||||
static gid_t *group_array = NULL;
|
||||
static int ngroups;
|
||||
|
||||
@@ -184,7 +181,7 @@ test_main(int argc, char** argv)
|
||||
|
||||
if (strcmp(applet_name, "[") == 0) {
|
||||
if (strcmp(argv[--argc], "]"))
|
||||
error_msg_and_die("missing ]\n");
|
||||
error_msg_and_die("missing ]");
|
||||
argv[argc] = NULL;
|
||||
}
|
||||
/* Implement special cases from POSIX.2, section 4.62.4 */
|
||||
@@ -233,9 +230,9 @@ syntax(op, msg)
|
||||
char *msg;
|
||||
{
|
||||
if (op && *op)
|
||||
error_msg_and_die("%s: %s\n", op, msg);
|
||||
error_msg_and_die("%s: %s", op, msg);
|
||||
else
|
||||
error_msg_and_die("%s\n", msg);
|
||||
error_msg_and_die("%s", msg);
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -470,13 +467,13 @@ getn(s)
|
||||
r = strtol(s, &p, 10);
|
||||
|
||||
if (errno != 0)
|
||||
error_msg_and_die("%s: out of range\n", s);
|
||||
error_msg_and_die("%s: out of range", s);
|
||||
|
||||
while (isspace(*p))
|
||||
p++;
|
||||
|
||||
if (*p)
|
||||
error_msg_and_die("%s: bad number\n", s);
|
||||
error_msg_and_die("%s: bad number", s);
|
||||
|
||||
return (int) r;
|
||||
}
|
||||
|
||||
+8
-6
@@ -3,7 +3,7 @@
|
||||
* Mini touch implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000 by Lineo, inc.
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -22,12 +22,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "busybox.h"
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <utime.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int touch_main(int argc, char **argv)
|
||||
{
|
||||
@@ -42,13 +44,13 @@ extern int touch_main(int argc, char **argv)
|
||||
create = FALSE;
|
||||
break;
|
||||
default:
|
||||
usage(touch_usage);
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argc < 1) {
|
||||
usage(touch_usage);
|
||||
show_usage();
|
||||
}
|
||||
|
||||
while (argc > 0) {
|
||||
@@ -58,12 +60,12 @@ extern int touch_main(int argc, char **argv)
|
||||
if (create == FALSE && errno == ENOENT)
|
||||
return EXIT_SUCCESS;
|
||||
else {
|
||||
error_msg_and_die("%s", strerror(errno));
|
||||
perror_msg_and_die("%s", *argv);
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
if (utime(*argv, NULL)) {
|
||||
error_msg_and_die("%s", strerror(errno));
|
||||
perror_msg_and_die("%s", *argv);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
Loaded 100 of 434 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user