Compare commits
2024
Commits
0_29alpha2
..
0_52
| 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 | ||
|
|
95d1f6d7c7 | ||
|
|
4362200712 | ||
|
|
1e1d232f38 | ||
|
|
235f66dea3 | ||
|
|
d0fa0a12f1 | ||
|
|
02ced93ec2 | ||
|
|
46948366fa | ||
|
|
21125543e1 | ||
|
|
4836fd44f0 | ||
|
|
bd193a42a5 | ||
|
|
77508b29fa | ||
|
|
f361ac29b0 | ||
|
|
483262f633 | ||
|
|
4d4b3b1d88 | ||
|
|
e3a48d865a | ||
|
|
d9d03b83f8 | ||
|
|
b12e506d8d | ||
|
|
69a6b2d4ae | ||
|
|
e48eea63d3 | ||
|
|
a2d61e761e | ||
|
|
5ec241d3b3 | ||
|
|
2d6282bb37 | ||
|
|
d323d32c5b | ||
|
|
5a964f9d0b | ||
|
|
20c2bdd7f2 | ||
|
|
5c365da884 | ||
|
|
4ed17829ac | ||
|
|
b2356f6de9 | ||
|
|
59ec601b8e | ||
|
|
a293a516ad | ||
|
|
394cf22668 | ||
|
|
cf7982e908 | ||
|
|
70d09ed1cf | ||
|
|
9962cd9f78 | ||
|
|
c8eedd56ac | ||
|
|
46f44d24fc | ||
|
|
00732b57c7 | ||
|
|
c52a97d79f | ||
|
|
9df3833370 | ||
|
|
29edd005f9 | ||
|
|
afdde3e356 | ||
|
|
5b5db38a7d | ||
|
|
1bca5ed886 | ||
|
|
8c28fd7849 | ||
|
|
7da312058c | ||
|
|
f21aa84389 | ||
|
|
eb4218d0a4 | ||
|
|
bf2b8ae49a | ||
|
|
76fef0a5d0 | ||
|
|
9cff4fbac9 | ||
|
|
5e09b6e3a8 | ||
|
|
f3b2b52b58 | ||
|
|
f57c944e09 | ||
|
|
7b5c16ebe5 | ||
|
|
87afb526b5 | ||
|
|
1e1d9d1c95 | ||
|
|
da7b82981b | ||
|
|
02553a2a18 | ||
|
|
3d957c87b7 | ||
|
|
6b78fe383f | ||
|
|
1e7cea952b | ||
|
|
bc5941a540 | ||
|
|
bfa54143f6 | ||
|
|
8ffabf5825 | ||
|
|
1d3523b7aa | ||
|
|
21adca750a | ||
|
|
e884970c87 | ||
|
|
92ed8a3519 | ||
|
|
ab147f608d | ||
|
|
26a3adb244 | ||
|
|
deb9d4d765 | ||
|
|
4758368505 | ||
|
|
cf61fe14ae | ||
|
|
d27753afd9 | ||
|
|
0e836ed8db | ||
|
|
2187adc619 | ||
|
|
8cede00b9e | ||
|
|
f484e7e65c | ||
|
|
868c057d25 | ||
|
|
e73fda8311 | ||
|
|
29be79c5f6 | ||
|
|
4c45e0991a | ||
|
|
b8b8d81c24 | ||
|
|
4d449c42f2 | ||
|
|
e2f6e12213 | ||
|
|
09a34e5368 | ||
|
|
02f3b2e0c8 | ||
|
|
87559829ff | ||
|
|
3e856ce428 | ||
|
|
b558e76eb1 | ||
|
|
cabafae7b0 | ||
|
|
c119ab9e29 | ||
|
|
8c725e624a | ||
|
|
8c2d3f46ab | ||
|
|
9bd71e8323 | ||
|
|
8fff78d66e | ||
|
|
ddea368dbe | ||
|
|
618e8ed4c4 | ||
|
|
0730943b49 | ||
|
|
20ea5c3352 | ||
|
|
7b5d59464f | ||
|
|
cf1189f5a7 | ||
|
|
4bfb6b7b67 | ||
|
|
e500d20835 | ||
|
|
d58ff8731c | ||
|
|
9a71af54f5 | ||
|
|
ab8f9e286b | ||
|
|
768a2340b5 | ||
|
|
e93abf9e69 | ||
|
|
5022d0e55f | ||
|
|
0053087587 | ||
|
|
9028e2c96a | ||
|
|
a683ee81d9 | ||
|
|
e5aef92e22 | ||
|
|
cf32e23796 | ||
|
|
50b3113dc2 | ||
|
|
337ec1bb32 | ||
|
|
e790ddb2e1 | ||
|
|
4e573f4729 | ||
|
|
8045c08e1c | ||
|
|
e2e2c29ea1 | ||
|
|
3c5ee9a379 | ||
|
|
46f0beb167 | ||
|
|
2aa1091130 | ||
|
|
6d5b73d183 | ||
|
|
f61caf0411 | ||
|
|
7918e1fd54 | ||
|
|
d8ad76cb31 | ||
|
|
63a862272c | ||
|
|
eb69ead091 | ||
|
|
e7ff2842dd | ||
|
|
2dc192fd99 | ||
|
|
a75466e981 | ||
|
|
ef936da7c5 | ||
|
|
3e07541e5f | ||
|
|
269e07cadc | ||
|
|
a5bd26831f | ||
|
|
b273d66518 | ||
|
|
c559d30776 | ||
|
|
b344c21709 | ||
|
|
d1ee7e39f7 | ||
|
|
84bdc75c7e | ||
|
|
e8c55f42c1 | ||
|
|
2dab174daa | ||
|
|
a0428eee9e | ||
|
|
ef5529b278 | ||
|
|
9133c98a9d | ||
|
|
3180413e76 | ||
|
|
ac1169b20f | ||
|
|
97d2612566 | ||
|
|
324a778f31 | ||
|
|
b60208dd8f | ||
|
|
130005cd89 | ||
|
|
207061ac0d | ||
|
|
2be4797a06 | ||
|
|
6050618096 | ||
|
|
69229a6c92 | ||
|
|
4f94e826cf | ||
|
|
567cdd1d51 | ||
|
|
9a6e67c960 | ||
|
|
33fdae54d1 | ||
|
|
e7e1e2dcad | ||
|
|
0d5835a767 | ||
|
|
872138de50 | ||
|
|
7a86e61a54 | ||
|
|
62f987e95f | ||
|
|
958c78f9a1 | ||
|
|
13241dfbdd | ||
|
|
aa3908d1b7 | ||
|
|
b520e083e0 | ||
|
|
25b669c144 | ||
|
|
ba1ff9b4eb | ||
|
|
c2bf5cad79 | ||
|
|
43f3e6114c | ||
|
|
8d369e98a5 | ||
|
|
c0321f9bc6 | ||
|
|
e7c1af1e0d | ||
|
|
bbaef66b3f | ||
|
|
e0bcce09ba | ||
|
|
8ce85ce4e3 | ||
|
|
bdcc6fbd95 | ||
|
|
f8263516c2 | ||
|
|
db7f2af089 | ||
|
|
f6b7139971 | ||
|
|
d266748c76 | ||
|
|
53323695c5 | ||
|
|
67fdf5e538 | ||
|
|
ff1ed7215c | ||
|
|
d89882da16 | ||
|
|
3570a34de4 | ||
|
|
caffb6eff0 | ||
|
|
c5949f62e5 | ||
|
|
e081eae7a4 | ||
|
|
bf73909f23 | ||
|
|
944be90b21 | ||
|
|
fe4208fe93 | ||
|
|
488aac2e2a | ||
|
|
896fa4ea1d | ||
|
|
57f83fffd8 | ||
|
|
6f283c2f77 | ||
|
|
9ae3838657 | ||
|
|
1b1cfde1f8 | ||
|
|
0102a9fd48 | ||
|
|
2da90d3b58 | ||
|
|
285b446d17 | ||
|
|
32e95f988d | ||
|
|
96bdde97fb | ||
|
|
6d66817b6b | ||
|
|
82e0614101 | ||
|
|
a37d5b772b | ||
|
|
5b17693f0a | ||
|
|
ebc0dd7a8a | ||
|
|
92a61c1206 | ||
|
|
90f580ad5b | ||
|
|
d995493987 | ||
|
|
a2f2a8f8c0 | ||
|
|
810d38f850 | ||
|
|
a1b35c4512 | ||
|
|
8c185f9600 | ||
|
|
75610e18b3 | ||
|
|
2c1faecba7 | ||
|
|
c873d61008 | ||
|
|
ba35b98444 | ||
|
|
d2f5677762 | ||
|
|
d1de4a16ad | ||
|
|
f34aa4c378 | ||
|
|
8a2e56c5df | ||
|
|
350b3f9236 | ||
|
|
ae22612792 | ||
|
|
624cc771da | ||
|
|
8847b9a03a | ||
|
|
7c22b77162 | ||
|
|
cff3fe3ae9 | ||
|
|
0cccdfaf36 | ||
|
|
b938e2ff99 | ||
|
|
46a98dfb13 | ||
|
|
56f3e353da | ||
|
|
06f64b2370 | ||
|
|
0b2da467a8 | ||
|
|
721119e1db | ||
|
|
cd26ff4eac | ||
|
|
252bacc9ea | ||
|
|
fd3741d712 | ||
|
|
38c8551cf2 | ||
|
|
63dde9d4ce | ||
|
|
b2f36af157 | ||
|
|
6fc2a7d04d | ||
|
|
82cfbad216 | ||
|
|
c9db2e8665 | ||
|
|
d2d3aa39ef | ||
|
|
2aee993118 | ||
|
|
f5cf8c6c65 | ||
|
|
33bee33af0 | ||
|
|
5f84fd7066 | ||
|
|
cbe05e45db | ||
|
|
7e3bf6e339 | ||
|
|
ce40fc044b | ||
|
|
5d63884a8f | ||
|
|
31e6829bd8 | ||
|
|
131241f71c | ||
|
|
cbbe4d6bc2 | ||
|
|
56a328810b | ||
|
|
b4c3c59a45 | ||
|
|
f8e04f7113 | ||
|
|
fb6a50820c | ||
|
|
d39d120998 | ||
|
|
5d513f7256 | ||
|
|
dd450a0ded | ||
|
|
322ae93a5e | ||
|
|
b89075298e | ||
|
|
23ad7f7f06 | ||
|
|
ccb0a9ba88 | ||
|
|
fca8050f0f | ||
|
|
ac19b7e032 | ||
|
|
49352adf9c | ||
|
|
605a819a17 | ||
|
|
f0b073f55a | ||
|
|
de34e43755 | ||
|
|
cbb61c78ae | ||
|
|
73de6561ca | ||
|
|
729216cb11 | ||
|
|
18310f1ce3 | ||
|
|
0ae8e5a645 | ||
|
|
bd7c67136a | ||
|
|
1c6917d2c4 | ||
|
|
e2b345a6d8 | ||
|
|
437bf72785 | ||
|
|
6fb88e73f7 | ||
|
|
8324b9f1aa | ||
|
|
11c655295c | ||
|
|
44e3840343 | ||
|
|
17c8851813 | ||
|
|
6085c72b6e | ||
|
|
9dd79791c8 | ||
|
|
ebee301c8b | ||
|
|
d13ebff163 | ||
|
|
1eec89df4c | ||
|
|
3639c5d950 | ||
|
|
1b355ebba6 | ||
|
|
43c8c38bbf | ||
|
|
61a9d8d145 | ||
|
|
9670083818 | ||
|
|
b92223b6f5 | ||
|
|
fd50c3d2f9 | ||
|
|
cb91d69b3f | ||
|
|
73bdf13d35 | ||
|
|
3a957b9d4c | ||
|
|
18a1014c95 | ||
|
|
da542f3a0c | ||
|
|
f446297afd | ||
|
|
e99674a70f | ||
|
|
5eb5912790 | ||
|
|
4e61db2284 | ||
|
|
ad3d90f91e | ||
|
|
a3de24e85d | ||
|
|
1638488d26 | ||
|
|
ab60f6987a | ||
|
|
88cc3057fd | ||
|
|
06aeb6c417 | ||
|
|
4d5ac2f346 | ||
|
|
3a0f4baf2f | ||
|
|
8237add8d0 | ||
|
|
32f2769800 | ||
|
|
089d12d762 | ||
|
|
aaa94fb8a9 | ||
|
|
ce82c8ab77 | ||
|
|
2368a387ed | ||
|
|
e4c4d69c04 | ||
|
|
6ab22027d0 | ||
|
|
fba9c00071 | ||
|
|
acf5551099 | ||
|
|
918507edda | ||
|
|
851ce895bd | ||
|
|
a1f16bba72 | ||
|
|
e2205f093b | ||
|
|
0e4cec0be8 | ||
|
|
dc746169cf | ||
|
|
282c364148 | ||
|
|
fa405d0cb2 | ||
|
|
202995c612 | ||
|
|
c86e5e6145 | ||
|
|
be0dc0d06a | ||
|
|
b2fc5a0647 | ||
|
|
e89267c8b3 | ||
|
|
8cbac440d6 | ||
|
|
6ac18a3d83 | ||
|
|
bb39a31e33 | ||
|
|
79565b6c91 | ||
|
|
f9ca653faa | ||
|
|
88f50b6bf5 | ||
|
|
40406e6bad | ||
|
|
adbf018dc4 | ||
|
|
deb95f69b6 | ||
|
|
46ade97983 | ||
|
|
0c8e2a6580 | ||
|
|
fdd5103348 | ||
|
|
5ae166813f | ||
|
|
807f0fd637 | ||
|
|
d5fa3e3e9a | ||
|
|
080d51bf45 | ||
|
|
0f8f7b8a35 | ||
|
|
98bbd688a8 | ||
|
|
43c17b3d96 | ||
|
|
616d13bcd1 | ||
|
|
259972e565 | ||
|
|
9cf306d55e | ||
|
|
6a4c33c5c0 | ||
|
|
6150df320a | ||
|
|
d5704686b1 | ||
|
|
1428c4f136 | ||
|
|
a5716d3029 | ||
|
|
501c88b245 | ||
|
|
6a99aaf020 | ||
|
|
7ce41ad692 | ||
|
|
e92108ae6d | ||
|
|
0d49dd53cf | ||
|
|
cc10a5b42b | ||
|
|
83e85f6a08 | ||
|
|
52681b48dc | ||
|
|
fad9c1198a | ||
|
|
b040d4f3da | ||
|
|
b9ea02c04b | ||
|
|
d34595d857 | ||
|
|
e5db406690 | ||
|
|
40bfc76385 | ||
|
|
e99f7500e0 | ||
|
|
ea824fb937 | ||
|
|
bf960f58e2 | ||
|
|
7df345e149 | ||
|
|
ec8d60f0f8 | ||
|
|
0010ee45e3 | ||
|
|
c768ab490e | ||
|
|
ced2cefcca | ||
|
|
1f45b268cb | ||
|
|
1ac435c15e | ||
|
|
51154bacbe | ||
|
|
3950596e1e | ||
|
|
99e370f0c6 | ||
|
|
aa4f108338 | ||
|
|
27a804246a | ||
|
|
869057238b | ||
|
|
2f46b664b7 | ||
|
|
91a4400fd5 | ||
|
|
a16c66335e | ||
|
|
ae6eae02dd | ||
|
|
52d6fa3bb3 | ||
|
|
1d255be78d | ||
|
|
2ef880b236 | ||
|
|
a9d69fb568 | ||
|
|
8f122431f5 | ||
|
|
6efc48c1ae | ||
|
|
9c5fcc3408 | ||
|
|
cc8a66b113 | ||
|
|
97562bd9d7 | ||
|
|
21ddb38fcf | ||
|
|
a1d187a8a8 | ||
|
|
bc0aed79a8 | ||
|
|
47d4926244 | ||
|
|
bf181b9338 | ||
|
|
3bd8bd89ee | ||
|
|
464c5de00d | ||
|
|
70705d7c96 | ||
|
|
add09fd558 | ||
|
|
17ad45aace | ||
|
|
df4532bfa3 | ||
|
|
ff5a9033f9 | ||
|
|
f626dcbc84 | ||
|
|
9027bcf2f4 | ||
|
|
93c0d9f090 | ||
|
|
fad04fdd12 | ||
|
|
b870af09ae | ||
|
|
d6912c97de | ||
|
|
58361a44b5 | ||
|
|
e7413a9cde | ||
|
|
d537a95fdb | ||
|
|
4ac6cb534d | ||
|
|
ec10b9d534 | ||
|
|
34623db618 | ||
|
|
02008346c0 | ||
|
|
94074a980c | ||
|
|
496e33feeb | ||
|
|
4f7fe77d07 | ||
|
|
06f3529ada | ||
|
|
156959ea93 | ||
|
|
f4c022649b | ||
|
|
55380700d8 | ||
|
|
00143ba921 | ||
|
|
ac48461da9 | ||
|
|
37653aaf9c | ||
|
|
c41e8c840f | ||
|
|
6f96e674b9 | ||
|
|
be84cd4ef6 | ||
|
|
e58771e73c | ||
|
|
e714bce003 | ||
|
|
3ecbe9f4dc | ||
|
|
97426e082a | ||
|
|
8fbaeece53 | ||
|
|
68fda241d2 | ||
|
|
858c1adf2b | ||
|
|
7719008a85 | ||
|
|
aec27bca98 | ||
|
|
960be79964 | ||
|
|
be909b1cd5 | ||
|
|
d006c9e630 | ||
|
|
9ebccb2891 | ||
|
|
f1f6d58598 | ||
|
|
0c838af50b | ||
|
|
195fa15caf | ||
|
|
61dc057183 | ||
|
|
df5f6ba115 | ||
|
|
da9841efc1 | ||
|
|
da1d1e763d | ||
|
|
cc54d12ef7 | ||
|
|
dd23b8bb43 | ||
|
|
c674d70699 | ||
|
|
6315ce603b | ||
|
|
85c552035e | ||
|
|
9b2297a34e | ||
|
|
a0053735dc | ||
|
|
3849f9bfcc | ||
|
|
9a8243aa1e | ||
|
|
928faac503 | ||
|
|
34e1941c32 | ||
|
|
0b4551faf5 | ||
|
|
a03d86cf54 | ||
|
|
44735f8744 | ||
|
|
999bf72f49 | ||
|
|
e9b527ae48 | ||
|
|
161cf93404 | ||
|
|
f12724c21a | ||
|
|
a57ba4db64 | ||
|
|
2cd439f7f0 | ||
|
|
bd22ed8067 | ||
|
|
877a71bbf0 | ||
|
|
9cf44e79aa | ||
|
|
8f282f1b02 | ||
|
|
acecc47261 | ||
|
|
e6b9dfa967 | ||
|
|
53a955786d | ||
|
|
a2c83d885e | ||
|
|
03f9c81cec | ||
|
|
bb374a6935 | ||
|
|
4c95a28461 | ||
|
|
3312b0b626 | ||
|
|
2158092344 | ||
|
|
b9eb0233a9 | ||
|
|
b0b732bfe4 | ||
|
|
03f4c27bd6 | ||
|
|
67536ffa43 | ||
|
|
8845adc545 | ||
|
|
02bc25be56 | ||
|
|
e5cec4e3ac | ||
|
|
62bb2d02b6 | ||
|
|
a5dbb39dac | ||
|
|
c8c10c5715 | ||
|
|
f86aee74ce | ||
|
|
b1e379f7f3 | ||
|
|
78eab2f6c6 | ||
|
|
3cfa9ec09c | ||
|
|
6f5e281479 | ||
|
|
b2731b11ef | ||
|
|
1e03add675 | ||
|
|
5d893b6beb | ||
|
|
89bc256c94 | ||
|
|
f7cf2f7ef9 | ||
|
|
57ebebfb01 | ||
|
|
2086e3d679 | ||
|
|
028fb625f5 | ||
|
|
5331025f79 | ||
|
|
b02c54ebee | ||
|
|
72965e3454 | ||
|
|
b54833cde0 | ||
|
|
7c31ea4e29 | ||
|
|
5d41d60f1e | ||
|
|
2e1148b239 | ||
|
|
8bd891cbec | ||
|
|
1ca41775bb | ||
|
|
d37218941c | ||
|
|
268b8c4f38 | ||
|
|
0c96eba3de | ||
|
|
a44790f539 | ||
|
|
a2db097d66 | ||
|
|
1c314ad655 | ||
|
|
47cac6779a | ||
|
|
eb0283333b | ||
|
|
7cdc76dfbf | ||
|
|
d0edef3cbe | ||
|
|
495869f59a | ||
|
|
cb1d841f09 | ||
|
|
27b5924b96 | ||
|
|
8f425dbf9a | ||
|
|
83a949cb22 | ||
|
|
1386e70210 | ||
|
|
ef40aa81c5 | ||
|
|
3adffb7fc8 | ||
|
|
10dc9d4d17 | ||
|
|
8a24a6783a | ||
|
|
4a971aef59 | ||
|
|
3c37598dc2 | ||
|
|
a29dec28cb | ||
|
|
ccd32cbb61 | ||
|
|
9d9610b8de | ||
|
|
6f9985e2f2 | ||
|
|
addc9c28ad | ||
|
|
4fa84e6b54 | ||
|
|
c6cdf58747 | ||
|
|
07edff4ba4 | ||
|
|
45087b1010 | ||
|
|
766c012975 | ||
|
|
c5c5e3d144 | ||
|
|
afa0662860 | ||
|
|
1a804e4b3c | ||
|
|
f929641c51 | ||
|
|
feb47c024a | ||
|
|
f7a01951fb | ||
|
|
7ac06a3ff1 | ||
|
|
0021679b0d | ||
|
|
b405dfa54d | ||
|
|
c03525475e | ||
|
|
e63ad9ba06 | ||
|
|
28c88a9430 | ||
|
|
339b892313 | ||
|
|
4eb1b30411 | ||
|
|
bd4a75f6c8 | ||
|
|
bb245ba0c2 | ||
|
|
9ca57d377e | ||
|
|
e1e23eecab | ||
|
|
5e29c6ffce | ||
|
|
a15cd0be34 | ||
|
|
b7362e36a8 | ||
|
|
67e32304b1 | ||
|
|
be5023a84d | ||
|
|
b610615be9 | ||
|
|
dbb3019d0d | ||
|
|
30f0f2d040 | ||
|
|
b108a5b780 | ||
|
|
110fc0cacc | ||
|
|
74c66ad06e | ||
|
|
98cd53e86d | ||
|
|
852ff13fc4 | ||
|
|
b991395405 | ||
|
|
2e965239ee | ||
|
|
3f75503fa0 | ||
|
|
28c70b3a16 | ||
|
|
e97da40079 | ||
|
|
1af7ed5573 | ||
|
|
3c709b45b3 | ||
|
|
d84990eb1f | ||
|
|
854e11581f | ||
|
|
2b6ab3cbf8 | ||
|
|
053b1462b7 | ||
|
|
baf22bff21 | ||
|
|
c7ccfc99fc | ||
|
|
9f16d61408 | ||
|
|
44760d058c | ||
|
|
5db60a7a7a | ||
|
|
0c6a970eb2 | ||
|
|
b3d235f63b | ||
|
|
b3cf9baeb9 | ||
|
|
049b706591 | ||
|
|
da10ec0eaa | ||
|
|
0024abcbbc | ||
|
|
0b66577368 | ||
|
|
a42982e8f5 | ||
|
|
1f6262b8e2 | ||
|
|
fb8ba506bb | ||
|
|
3232203226 | ||
|
|
d05e3ce5c2 | ||
|
|
eec2f63b3f | ||
|
|
700a5aed75 | ||
|
|
517cab761f | ||
|
|
6ca28ba65c | ||
|
|
680d65a646 | ||
|
|
68480dc30f | ||
|
|
815e904470 | ||
|
|
c389d91181 | ||
|
|
82c0ac7e4f | ||
|
|
f2fffefe49 | ||
|
|
36fe1a30b1 | ||
|
|
926e0e3465 | ||
|
|
afeb683459 | ||
|
|
46a38dbb9b | ||
|
|
ef4268efa7 | ||
|
|
832000f7f3 | ||
|
|
f0c30b71be | ||
|
|
5a0a2aa00b | ||
|
|
808d03ec19 | ||
|
|
9c8ffa02f4 | ||
|
|
3199bda52e | ||
|
|
6082917e34 | ||
|
|
380e58a05f | ||
|
|
ec480c49c2 | ||
|
|
86ab8a32bd | ||
|
|
4062268bc7 | ||
|
|
08e9289ab3 | ||
|
|
b6c6d87a99 | ||
|
|
77bd2db325 | ||
|
|
1624813459 | ||
|
|
b83e0ed3a1 | ||
|
|
89960b8af2 | ||
|
|
b5966368d7 | ||
|
|
deb0331eb6 | ||
|
|
108a44345c | ||
|
|
e511e7c116 | ||
|
|
8ea7d8cdaf | ||
|
|
330fd2b576 | ||
|
|
d356c6e9d1 | ||
|
|
5b46d792f1 | ||
|
|
499f65fb98 | ||
|
|
969f9b0486 | ||
|
|
67a0dd8f3c | ||
|
|
c3f5c9c2ee | ||
|
|
bcd6177853 | ||
|
|
73c8c9cf9a | ||
|
|
23dea9b712 | ||
|
|
7ab9c7ee52 | ||
|
|
3d427ac5ef | ||
|
|
59b9e87024 | ||
|
|
ac130e1dca | ||
|
|
0a027e6880 | ||
|
|
691f49d3c1 | ||
|
|
0e713cef9d | ||
|
|
6c5f2c6021 | ||
|
|
9b15e50835 | ||
|
|
a59d7094a6 | ||
|
|
0a704e8ff6 | ||
|
|
a19bc64653 | ||
|
|
e31c06608e | ||
|
|
03ccce6e30 | ||
|
|
5afc864422 | ||
|
|
3c1217cfad | ||
|
|
8f8d6d5f2d | ||
|
|
d16665810d | ||
|
|
12d1b378be | ||
|
|
9b7d964581 | ||
|
|
f378fced43 | ||
|
|
4625240674 | ||
|
|
94f5e0ba7c | ||
|
|
28c49b6c9c | ||
|
|
25c44c623d | ||
|
|
923ef599f3 | ||
|
|
6ed02a0ee0 | ||
|
|
abc199eb0c | ||
|
|
4f3f757d56 | ||
|
|
227a59b05d | ||
|
|
f93a95de69 | ||
|
|
e90f4045af | ||
|
|
1d1d95051a | ||
|
|
cf8d38a3eb | ||
|
|
7d6ba57bba | ||
|
|
e3ed156eeb | ||
|
|
1101d23604 | ||
|
|
eef658068b | ||
|
|
2e397341d9 | ||
|
|
262dd039eb | ||
|
|
3fe7f9f20b | ||
|
|
a3e57ca700 | ||
|
|
f13df3752c | ||
|
|
9a8195cc03 | ||
|
|
b9167cb67f | ||
|
|
632bb57135 | ||
|
|
c366050a23 | ||
|
|
f29f797f54 | ||
|
|
0a64de9b4f | ||
|
|
229dd2b905 | ||
|
|
5d68857b9c | ||
|
|
a6c752201e | ||
|
|
91e581fa04 | ||
|
|
5a50def0f4 | ||
|
|
6e703034f4 | ||
|
|
26702fe191 | ||
|
|
e5b6c7dd9c | ||
|
|
4fd10fc73b | ||
|
|
200be97e36 | ||
|
|
5a728cfdfe | ||
|
|
3becdfc316 | ||
|
|
53642b066c | ||
|
|
9057b6a918 | ||
|
|
ab01ed12bd | ||
|
|
5e1189e187 | ||
|
|
95c1c1e05f | ||
|
|
d5ba77d03e | ||
|
|
50ed0676ad | ||
|
|
cbd6628c8c | ||
|
|
9cf3bfa7c1 | ||
|
|
b4f8606c05 | ||
|
|
08e7f75ba2 | ||
|
|
f17792ca9b | ||
|
|
61677feff7 | ||
|
|
62dc17a3b1 | ||
|
|
f0657d3229 | ||
|
|
a2685735b1 | ||
|
|
f3b3d17060 | ||
|
|
0817d1372c | ||
|
|
84e09e4437 | ||
|
|
ecd512453c | ||
|
|
5dd853ad2a | ||
|
|
6a34b539db | ||
|
|
825aead68b | ||
|
|
93d6513d93 | ||
|
|
7a4b719486 | ||
|
|
6bd3602988 | ||
|
|
c0dac18d6d | ||
|
|
e9fee653dc | ||
|
|
d4bc1fcad8 | ||
|
|
5661fe078e | ||
|
|
cbb0a4b40d | ||
|
|
b99ca13261 | ||
|
|
68a9ea4208 | ||
|
|
183da4ade1 | ||
|
|
983b51b17b | ||
|
|
3364d78b18 | ||
|
|
6acaa40f27 | ||
|
|
deea048bec | ||
|
|
1ad302ac90 | ||
|
|
e454fb68a3 | ||
|
|
298854f029 | ||
|
|
ec5bd90916 | ||
|
|
016ffe9307 | ||
|
|
0d068a2067 | ||
|
|
c053e41fa0 | ||
|
|
42094cdad5 | ||
|
|
1dbe340eba | ||
|
|
c7c634bd88 | ||
|
|
6c41c44898 | ||
|
|
531bcb6826 | ||
|
|
6273f655c8 | ||
|
|
161220c498 | ||
|
|
13456d1fcd | ||
|
|
d75af99529 | ||
|
|
a967e3c8f0 | ||
|
|
ce91732416 | ||
|
|
3522eb1ab3 | ||
|
|
269bba2514 | ||
|
|
47d3bb3b6d | ||
|
|
54969a1f64 | ||
|
|
692a4502b0 | ||
|
|
2ac2fae728 | ||
|
|
cbd0d625c7 | ||
|
|
06249f24f3 | ||
|
|
ea6b67de65 | ||
|
|
246cc6dddd | ||
|
|
e916d24805 | ||
|
|
9c5c29d442 | ||
|
|
65fc1c70f7 | ||
|
|
fb002d0df0 | ||
|
|
66be5e7e29 | ||
|
|
6437170cb3 | ||
|
|
029011b9ee | ||
|
|
7c4b2f3fe5 | ||
|
|
a51ecdd9e4 | ||
|
|
5b911ddd57 | ||
|
|
dc75a739ac | ||
|
|
f7c49ef2d1 | ||
|
|
3b9522f2af | ||
|
|
6e769df47d | ||
|
|
d07ee46919 | ||
|
|
fa4718efcf | ||
|
|
42387e4964 | ||
|
|
27fdd081ef | ||
|
|
e272915e1f | ||
|
|
bf5f009862 | ||
|
|
08c965a0a1 | ||
|
|
5e2b96345c | ||
|
|
9ffdaa647e | ||
|
|
5e1b2ca116 | ||
|
|
fa376f8034 | ||
|
|
c1dc5d9473 | ||
|
|
91f3df3c45 | ||
|
|
4d0543138e | ||
|
|
fb1793f03c | ||
|
|
07f5604046 | ||
|
|
d7ce5e7802 | ||
|
|
e132f4b09e | ||
|
|
e49d5ecbbe | ||
|
|
c0bf817bbc | ||
|
|
d0480c26ab | ||
|
|
31cf8e0056 | ||
|
|
79ac30da83 | ||
|
|
d7cd21aed5 | ||
|
|
fac10d7c59 | ||
|
|
50bc101b7d | ||
|
|
b332e779e6 | ||
|
|
04e97024e7 | ||
|
|
a6d0dbc86f | ||
|
|
8e759aa31f | ||
|
|
d7a44c76fe | ||
|
|
ce5b466bcc | ||
|
|
ccc7488615 | ||
|
|
de7965ca7e | ||
|
|
5cbdd712f5 | ||
|
|
3fe39dce5d | ||
|
|
bf3a838aac | ||
|
|
5509af7073 | ||
|
|
9bc7e89fc1 | ||
|
|
a4a8fd05f4 | ||
|
|
06936df164 | ||
|
|
de552874d2 | ||
|
|
f4acea8cf5 | ||
|
|
b2660c703d | ||
|
|
8ad12e32c8 | ||
|
|
4581b4cdd9 | ||
|
|
08fe43d3f9 | ||
|
|
a2f69e5485 | ||
|
|
46a4e76243 | ||
|
|
3a1b6be7d8 | ||
|
|
05100cd477 | ||
|
|
83865e3e90 | ||
|
|
3163821967 | ||
|
|
b7cc49d992 | ||
|
|
05df239ed9 | ||
|
|
9a9a261569 | ||
|
|
ac6e71f0c4 | ||
|
|
766f9c7a19 | ||
|
|
1dbc17f630 | ||
|
|
5338ce19c8 | ||
|
|
5f2df6ccb4 | ||
|
|
9b5c0b7611 | ||
|
|
812d46667d | ||
|
|
96e2abd084 | ||
|
|
286b0de74d | ||
|
|
d38eaef70b | ||
|
|
0e3782f7c3 | ||
|
|
9324b400ab | ||
|
|
9d83165d9e | ||
|
|
96f1f33e56 | ||
|
|
3695052813 | ||
|
|
9e7372584f | ||
|
|
0b874ed41f | ||
|
|
abb4772b28 | ||
|
|
0881de706e | ||
|
|
f4a99cc02c | ||
|
|
fb62e3225f | ||
|
|
7dc160721e | ||
|
|
9c88cac5cb | ||
|
|
1266a13e1f | ||
|
|
a89910829c | ||
|
|
f664c004db | ||
|
|
2fe08c7afb | ||
|
|
00266d3df6 | ||
|
|
69ba6b2956 | ||
|
|
98f67e35d8 | ||
|
|
00417a38c1 | ||
|
|
ee512a3f86 | ||
|
|
568cb7b45f | ||
|
|
d19385e160 | ||
|
|
f3e59041b5 | ||
|
|
019513a59f | ||
|
|
38efa7902e | ||
|
|
c0ca473af9 | ||
|
|
3fe2ecf0d9 | ||
|
|
d387d01f11 | ||
|
|
f294a0288d | ||
|
|
021043205c | ||
|
|
10c341af35 | ||
|
|
4d1d0113fd | ||
|
|
6da0ae8183 | ||
|
|
c144e330c0 | ||
|
|
2129b146db | ||
|
|
3d7e3414da | ||
|
|
0aa6118167 | ||
|
|
1c5b2589d1 | ||
|
|
6f23cec5d0 | ||
|
|
935fb3886f | ||
|
|
25ab653457 | ||
|
|
e1618e42a8 | ||
|
|
3cd5d2541f | ||
|
|
0f0fcecf7f | ||
|
|
664584b50e | ||
|
|
19db07b3d4 | ||
|
|
59248bad97 | ||
|
|
84b009256f | ||
|
|
b52a218c95 | ||
|
|
59017e80da | ||
|
|
cf53687376 | ||
|
|
2cb55077e2 | ||
|
|
c5ff0165ad | ||
|
|
3157b1fba9 | ||
|
|
a3e0d7928b | ||
|
|
9835541c54 | ||
|
|
21818c8a80 | ||
|
|
70e2f0b111 | ||
|
|
14c82b64c9 | ||
|
|
2ad2afd05c | ||
|
|
059f152a7a | ||
|
|
29fcc90f3e | ||
|
|
6805d5d69e | ||
|
|
f95ca97d1b | ||
|
|
395b216a2e | ||
|
|
7a98606d85 | ||
|
|
0f5e1ab949 | ||
|
|
f0758dd6ba | ||
|
|
1792f8c489 | ||
|
|
c24db7b591 | ||
|
|
8cd6a1f9a2 | ||
|
|
48091fb3d3 | ||
|
|
abc0f4f8f9 | ||
|
|
2285f367e2 | ||
|
|
fcdb57a0fc | ||
|
|
d29edf34d6 | ||
|
|
485b9550fd | ||
|
|
d00c262847 | ||
|
|
0ecb54a0f3 | ||
|
|
14ec6cf3c2 | ||
|
|
de1d61268e | ||
|
|
b186d980d6 | ||
|
|
77619b9dda | ||
|
|
bb58702833 | ||
|
|
03018f7551 | ||
|
|
1667fb4b63 | ||
|
|
c054b21f7d | ||
|
|
4c78147755 | ||
|
|
ec33d45e89 | ||
|
|
befda6e4ed | ||
|
|
3843e96252 | ||
|
|
b99df0fd65 | ||
|
|
394f764e7d | ||
|
|
cb41c2e83b | ||
|
|
5d44d1fda5 | ||
|
|
0f4c0848c7 | ||
|
|
0727458a97 | ||
|
|
fa213cd71e | ||
|
|
e1850ddde4 | ||
|
|
6a76e652aa | ||
|
|
08b1034f4f | ||
|
|
ab746abfc0 | ||
|
|
1c43d0c5af | ||
|
|
b052b47722 | ||
|
|
ded6259f62 | ||
|
|
d80e851dc0 | ||
|
|
a9c95ea655 | ||
|
|
80974fad03 | ||
|
|
b6a44b8d39 | ||
|
|
eded54bd96 | ||
|
|
96bcfd346b | ||
|
|
0dfac6b9ce | ||
|
|
c296b54827 | ||
|
|
d73dc5b073 | ||
|
|
84d8568071 | ||
|
|
5556c1874b | ||
|
|
3e2bb288da | ||
|
|
add0158554 | ||
|
|
3d8dbe1ca0 | ||
|
|
50d6360771 | ||
|
|
fbb39c83b6 | ||
|
|
07e5297ca7 | ||
|
|
dc6301e7ca | ||
|
|
350577c5a0 | ||
|
|
29d2e362de | ||
|
|
bc34190694 | ||
|
|
f14937d177 | ||
|
|
e18c75a563 | ||
|
|
9997685953 | ||
|
|
cf8c9cf7b9 | ||
|
|
d0246fb72b | ||
|
|
3ae0c78962 | ||
|
|
be971d6b69 | ||
|
|
219d6f5e0c | ||
|
|
2f6c04f63c | ||
|
|
ff719d663e | ||
|
|
04579780b7 | ||
|
|
7f1acfdb89 | ||
|
|
24d8e7d787 | ||
|
|
c1525e84dd | ||
|
|
6b6b3f6ef2 | ||
|
|
c7c41d306b | ||
|
|
a745606df3 | ||
|
|
c8fdb56389 | ||
|
|
8a8fbb87f7 | ||
|
|
0460ff2e5d | ||
|
|
d143e8f2bd | ||
|
|
a709317cea | ||
|
|
a07f0b0408 | ||
|
|
9922c833ca | ||
|
|
fa0540fb09 | ||
|
|
8eefd021ca | ||
|
|
51f8c89040 | ||
|
|
63a0e530bd | ||
|
|
aa0765e11b | ||
|
|
c49960189a | ||
|
|
887991c78a | ||
|
|
d23f9ba0f6 | ||
|
|
ef8b6c757d | ||
|
|
ce8f3b9933 | ||
|
|
b9b421c186 | ||
|
|
b7a1a75261 | ||
|
|
f8d650c4e5 | ||
|
|
f5a3838e2f | ||
|
|
e674eb78e4 | ||
|
|
e494fdd2c7 | ||
|
|
e77ae3a2c0 | ||
|
|
a3f09076ef | ||
|
|
3e0fbae15e | ||
|
|
abc7d597cb | ||
|
|
b0e9a709ba | ||
|
|
703c62da63 | ||
|
|
8759006b55 | ||
|
|
7f04b5e320 | ||
|
|
bed30e9700 | ||
|
|
9b58718889 | ||
|
|
cb6e25655f | ||
|
|
3c163822d8 | ||
|
|
2c1030177e | ||
|
|
f6be944a6a | ||
|
|
305a73f5ea | ||
|
|
1b61f41f57 | ||
|
|
21943ce641 | ||
|
|
c6cb79dedf | ||
|
|
5de3065f58 | ||
|
|
3cf52d1958 | ||
|
|
2ce1edcf54 | ||
|
|
f811e07b07 | ||
|
|
8341a15653 | ||
|
|
596e5469d0 | ||
|
|
5c3199e0a5 | ||
|
|
17d49efd8c | ||
|
|
9d3aba7b37 | ||
|
|
b09c6b5d4a | ||
|
|
4bea32abb5 | ||
|
|
2b69c40e80 |
No files matched your search
@@ -1 +1,4 @@
|
||||
busybox
|
||||
busybox.links
|
||||
_install
|
||||
applet_source_list
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
--blank-lines-after-declarations
|
||||
--blank-lines-after-procedures
|
||||
--break-before-boolean-operator
|
||||
--no-blank-lines-after-commas
|
||||
--braces-on-if-line
|
||||
--braces-on-struct-decl-line
|
||||
--comment-indentation25
|
||||
--declaration-comment-column25
|
||||
--no-comment-delimiters-on-blank-lines
|
||||
--cuddle-else
|
||||
--continuation-indentation4
|
||||
--case-indentation0
|
||||
--else-endif-column33
|
||||
--space-after-cast
|
||||
--line-comments-indentation0
|
||||
--declaration-indentation1
|
||||
--dont-format-first-column-comments
|
||||
--dont-format-comments
|
||||
--honour-newlines
|
||||
--indent-level4
|
||||
/* changed from 0 to 4 */
|
||||
--parameter-indentation4
|
||||
--line-length78 /* changed from 75 */
|
||||
--continue-at-parentheses
|
||||
--no-space-after-function-call-names
|
||||
--dont-break-procedure-type
|
||||
--dont-star-comments
|
||||
--leave-optional-blank-lines
|
||||
--dont-space-special-semicolon
|
||||
--tab-size4
|
||||
/* additions by Mark */
|
||||
--case-brace-indentation0
|
||||
--leave-preprocessor-space
|
||||
@@ -0,0 +1,81 @@
|
||||
List of the authors of code contained in BusyBox.
|
||||
|
||||
If you have code in BusyBox, you should be listed here. If you should be
|
||||
listed, or the description of what you have done needs more detail, or is
|
||||
incorect, _please_ let me know.
|
||||
|
||||
-Erik
|
||||
|
||||
-----------
|
||||
|
||||
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
Tons of new stuff, major rewrite of most of the
|
||||
core apps, tons of new apps as noted in header files.
|
||||
|
||||
Edward Betts <edward@debian.org>
|
||||
expr, hostid, logname, tty, wc, whoami, yes
|
||||
|
||||
John Beppu <beppu@lineo.com>
|
||||
du, head, nslookup, sort, tee, uniq
|
||||
|
||||
Brian Candler <B.Candler@pobox.com>
|
||||
tiny-ls(ls)
|
||||
|
||||
Randolph Chung <tausq@debian.org>
|
||||
fbset, ping, hostname, and mkfifo
|
||||
|
||||
Dave Cinege <dcinege@psychosis.com>
|
||||
more(v2), makedevs, dutmp, modularization, auto links file,
|
||||
various fixes, Linux Router Project maintenance
|
||||
|
||||
Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
pristine source directory compilation, lots of patches and fixes.
|
||||
|
||||
Karl M. Hegbloom <karlheg@debian.org>
|
||||
cp_mv.c, the test suite, various fixes to utility.c, &c.
|
||||
|
||||
Daniel Jacobowitz <dan@debian.org>
|
||||
mktemp.c
|
||||
|
||||
Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
documentation, bugfixes
|
||||
|
||||
John Lombardo <john@deltanet.com>
|
||||
dirname, tr
|
||||
|
||||
Glenn McGrath <bug1@netconnect.com.au>
|
||||
ar.c
|
||||
|
||||
Bruce Perens <bruce@pixar.com>
|
||||
Original author of BusyBox. His code is still in many apps.
|
||||
|
||||
Kent Robotti <robotti@metconnect.com>
|
||||
reset, tons and tons of bug reports and patchs.
|
||||
|
||||
Chip Rosenthal <chip@unicom.com>, <crosenth@covad.com>
|
||||
wget - Contributed by permission of Covad Communications
|
||||
|
||||
Pavel Roskin <proski@gnu.org>
|
||||
Lots of bugs fixes and patches.
|
||||
|
||||
Gyepi Sam <gyepi@praxis-sw.com>
|
||||
Remote logging feature for syslogd
|
||||
|
||||
Linus Torvalds <torvalds@transmeta.com>
|
||||
mkswap, fsck.minix, mkfs.minix
|
||||
|
||||
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)
|
||||
|
||||
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
|
||||
@@ -0,0 +1,484 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
// 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_ADJTIMEX
|
||||
//#define BB_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHGRP
|
||||
#define BB_CHMOD
|
||||
#define BB_CHOWN
|
||||
#define BB_CHROOT
|
||||
#define BB_CHVT
|
||||
#define BB_CLEAR
|
||||
//#define BB_CMP
|
||||
#define BB_CP
|
||||
//#define BB_CPIO
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
//#define BB_DC
|
||||
#define BB_DD
|
||||
//#define BB_DEALLOCVT
|
||||
#define BB_DF
|
||||
#define BB_DIRNAME
|
||||
#define BB_DMESG
|
||||
//#define BB_DOS2UNIX
|
||||
//#define BB_DPKG
|
||||
//#define BB_DPKG_DEB
|
||||
//#define BB_DUTMP
|
||||
#define BB_DU
|
||||
//#define BB_DUMPKMAP
|
||||
#define BB_ECHO
|
||||
#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_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
//#define BB_HOSTID
|
||||
//#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
//#define BB_IFCONFIG
|
||||
#define BB_INIT
|
||||
//#define BB_INSMOD
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_KLOGD
|
||||
//#define BB_LENGTH
|
||||
#define BB_LN
|
||||
//#define BB_LOADACM
|
||||
//#define BB_LOADFONT
|
||||
//#define BB_LOADKMAP
|
||||
#define BB_LOGGER
|
||||
//#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
#define BB_LSMOD
|
||||
//#define BB_MAKEDEVS
|
||||
//#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
//#define BB_MKFIFO
|
||||
//#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
#define BB_MKSWAP
|
||||
//#define BB_MKTEMP
|
||||
//#define BB_NC
|
||||
#define BB_MORE
|
||||
#define BB_MOUNT
|
||||
//#define BB_MT
|
||||
#define BB_MV
|
||||
//#define BB_NSLOOKUP
|
||||
//#define BB_PING
|
||||
//#define BB_PIVOT_ROOT
|
||||
#define BB_POWEROFF
|
||||
//#define BB_PRINTF
|
||||
#define BB_PS
|
||||
#define BB_PWD
|
||||
//#define BB_RDATE
|
||||
//#define BB_READLINK
|
||||
#define BB_REBOOT
|
||||
//#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
//#define BB_RMMOD
|
||||
//#define BB_ROUTE
|
||||
//#define BB_RPM2CPIO
|
||||
#define BB_SED
|
||||
//#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_TFTP
|
||||
#define BB_TOUCH
|
||||
//#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
//#define BB_UNIX2DOS
|
||||
//#define BB_UUENCODE
|
||||
//#define BB_UUDECODE
|
||||
#define BB_UMOUNT
|
||||
#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
//#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
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------
|
||||
// This is where feature definitions go. Generally speaking,
|
||||
// turning this stuff off makes things a bit smaller (and less
|
||||
// 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. 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
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames 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
|
||||
#define BB_FEATURE_LS_SORTFILES
|
||||
//
|
||||
// enable ls -R
|
||||
#define BB_FEATURE_LS_RECURSIVE
|
||||
//
|
||||
// enable ls -L
|
||||
#define BB_FEATURE_LS_FOLLOWLINKS
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//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
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
//#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
// 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_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
|
||||
//
|
||||
// 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" and "-X" for excluding files
|
||||
#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
// Enable support for tar -z option (currently only works for inflating)
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
//
|
||||
// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// 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. 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
|
||||
//real commands on the filesystem. For example, if you run run /bin/cat, it
|
||||
//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.
|
||||
// Only relevant if BB_SH is enabled. Off by default.
|
||||
//#define BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// Support insmod/lsmod/rmmod for post 2.1 kernels
|
||||
//#define BB_FEATURE_NEW_MODULE_INTERFACE
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// Enable a nifty progress meter in wget (adds just under 2k)
|
||||
#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
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#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
|
||||
#endif
|
||||
//
|
||||
#ifndef BB_INIT
|
||||
#undef BB_FEATURE_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_FEATURE_AUTOWIDTH
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#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
|
||||
@@ -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
|
||||
@@ -17,8 +17,362 @@ Copyright 1998 Dave Cinege <dcinege@psychosis.com>
|
||||
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,2000,2001 by Lineo, inc. and written by
|
||||
Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
|
||||
Please see the top of the source files for more precise indivigual
|
||||
copyright and license info.
|
||||
|
||||
This program suite may be distributed under the GNU General Public License.
|
||||
|
||||
Please feed suggestions, bug reports, insults, and bribes back to:
|
||||
Erik Andersen
|
||||
<andersen@lineo.com>
|
||||
<andersee@debian.org>
|
||||
|
||||
|
||||
|
||||
Busybox may be used and distributed under the GNU General Public License.
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
||||
@@ -1,38 +1,437 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# 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
|
||||
# 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
|
||||
#
|
||||
|
||||
VERSION=0.29alpha1
|
||||
BUILDTIME=$(shell date "+%Y%m%d-%H%M")
|
||||
PROG := busybox
|
||||
VERSION := 0.52
|
||||
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
|
||||
export VERSION
|
||||
|
||||
#This will choke on a non-debian system
|
||||
ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
|
||||
# With a modern GNU make(1) (highly recommended, that's what all the
|
||||
# developers use), all of the following configuration values can be
|
||||
# overridden at the command line. For example:
|
||||
# make CROSS=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.
|
||||
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
|
||||
# want to first set up your environment.
|
||||
# eg: `export DMALLOC_OPTIONS=debug=0x14f47d83,inter=100,log=logfile`
|
||||
# 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.
|
||||
# Some of the programs that can benefit from lfs support
|
||||
# are dd, gzip, mount, tar, and mkfs_minix.
|
||||
# LFS allows you to use the above programs for files
|
||||
# larger than 2GB!
|
||||
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 =
|
||||
|
||||
# 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 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)/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; \
|
||||
then echo "-Os"; else echo "-O2" ; fi)
|
||||
|
||||
WARNINGS = -Wall -Wshadow
|
||||
|
||||
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 ($(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 ($(strip $(DODEBUG)),true)
|
||||
CFLAGS += $(WARNINGS) -g -D_GNU_SOURCE
|
||||
LDFLAGS += -Wl,-warn-common
|
||||
STRIP =
|
||||
else
|
||||
CFLAGS += $(WARNINGS) $(OPTIMIZATION) -fomit-frame-pointer -D_GNU_SOURCE
|
||||
LDFLAGS += -s -Wl,-warn-common
|
||||
STRIP = $(STRIPTOOL) --remove-section=.note --remove-section=.comment $(PROG)
|
||||
endif
|
||||
ifeq ($(strip $(DOSTATIC)),true)
|
||||
LDFLAGS += --static
|
||||
#
|
||||
#use '-ffunction-sections -fdata-sections' and '--gc-sections' (if they
|
||||
# work) to try and strip out any unused junk. Doesn't do much for me,
|
||||
# but you may want to give it a shot...
|
||||
#
|
||||
#ifeq ($(shell $(CC) -ffunction-sections -fdata-sections -S \
|
||||
# -o /dev/null -xc /dev/null 2>/dev/null && $(LD) \
|
||||
# --gc-sections -v >/dev/null && echo 1),1)
|
||||
# CFLAGS += -ffunction-sections -fdata-sections
|
||||
# LDFLAGS += --gc-sections
|
||||
#endif
|
||||
endif
|
||||
|
||||
ifndef $(PREFIX)
|
||||
PREFIX = `pwd`/_install
|
||||
endif
|
||||
|
||||
# Additional complications due to support for pristine source dir.
|
||||
# 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>.
|
||||
#
|
||||
ifneq ($(strip $(BB_SRC_DIR)),)
|
||||
VPATH = $(BB_SRC_DIR)
|
||||
endif
|
||||
#ifneq ($(strip $(VPATH)),)
|
||||
# CFLAGS += -I- -I. $(patsubst %,-I%,$(subst :, ,$(VPATH)))
|
||||
#endif
|
||||
|
||||
# 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
|
||||
|
||||
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))
|
||||
|
||||
|
||||
STRIP= strip --remove-section=.note --remove-section=.comment busybox
|
||||
LDFLAGS= -s
|
||||
# Put user-supplied flags at the end, where they
|
||||
# have a chance of winning.
|
||||
CFLAGS += $(CFLAGS_EXTRA)
|
||||
|
||||
# -D_GNU_SOURCE is needed because environ is used in init.c
|
||||
CFLAGS=-Wall -O2 -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
|
||||
# For debugging only
|
||||
#CFLAGS=-Wall -g -D_GNU_SOURCE
|
||||
LIBRARIES=-lc
|
||||
OBJECTS=$(shell ./busybox.obj) utility.o
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
CFLAGS+= -DBB_VER='"$(VERSION)"'
|
||||
CFLAGS+= -DBB_BT='"$(BUILDTIME)"'
|
||||
all: applet_source_list busybox busybox.links doc
|
||||
|
||||
#all: busybox links
|
||||
all: busybox
|
||||
applet_source_list: busybox.sh Config.h
|
||||
(echo -n "APPLET_SOURCES := "; BB_SRC_DIR=$(BB_SRC_DIR) $(SHELL) $^) > $@
|
||||
|
||||
busybox: $(OBJECTS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o busybox $(OBJECTS) $(LIBRARIES)
|
||||
#$(STRIP)
|
||||
doc: olddoc
|
||||
|
||||
# Old Docs...
|
||||
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 $< > $@
|
||||
|
||||
docs/BusyBox.1: docs/busybox.pod
|
||||
- mkdir -p docs
|
||||
- pod2man --center=BusyBox --release="version $(VERSION)" \
|
||||
$< > $@
|
||||
|
||||
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 $< > \
|
||||
docs/busybox.lineo.com/BusyBox.html
|
||||
-@ rm -f pod2htm*
|
||||
|
||||
|
||||
# New docs based on DOCBOOK SGML
|
||||
newdoc: docs/busybox.txt docs/busybox.pdf docs/busybox/busyboxdocumentation.html
|
||||
|
||||
docs/busybox.txt: docs/busybox.sgml
|
||||
@echo
|
||||
@echo BusyBox Documentation
|
||||
@echo
|
||||
- mkdir -p docs
|
||||
(cd docs; sgmltools -b txt busybox.sgml)
|
||||
|
||||
docs/busybox.dvi: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs; sgmltools -b dvi busybox.sgml)
|
||||
|
||||
docs/busybox.ps: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs; sgmltools -b ps busybox.sgml)
|
||||
|
||||
docs/busybox.pdf: docs/busybox.ps
|
||||
- mkdir -p docs
|
||||
(cd docs; ps2pdf busybox.ps)
|
||||
|
||||
docs/busybox/busyboxdocumentation.html: docs/busybox.sgml
|
||||
- mkdir -p docs
|
||||
(cd docs/busybox.lineo.com; sgmltools -b html ../busybox.sgml)
|
||||
|
||||
|
||||
busybox: $(PWD_LIB) $(LIBBB_LIB) $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBBB_LIB) $(PWD_LIB) $(LIBRARIES)
|
||||
$(STRIP)
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
$(PWD_OBJS): %.o: %.c Config.h busybox.h applets.h Makefile
|
||||
- mkdir -p $(PWD_GRP)
|
||||
$(CC) $(CFLAGS) $(PWD_CFLAGS) -c $< -o $*.o
|
||||
|
||||
$(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:
|
||||
# old way of doing it
|
||||
#cd tests && $(MAKE) all
|
||||
# new way of doing it
|
||||
cd tests && ./tester.sh
|
||||
|
||||
links:
|
||||
- ./busybox.mkll | sort >busybox.links
|
||||
|
||||
clean:
|
||||
- rm -f busybox busybox.links *~ *.o
|
||||
- cd tests && $(MAKE) clean
|
||||
- rm -f docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
|
||||
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 -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
|
||||
|
||||
force:
|
||||
install: install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX)
|
||||
|
||||
install-hardlinks: install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX) --hardlinks
|
||||
|
||||
debug_pristine:
|
||||
@ echo VPATH=\"$(VPATH)\"
|
||||
@ echo OBJECTS=\"$(OBJECTS)\"
|
||||
|
||||
dist release: distclean doc
|
||||
cd ..; \
|
||||
rm -rf busybox-$(VERSION); \
|
||||
cp -a busybox busybox-$(VERSION); \
|
||||
\
|
||||
find busybox-$(VERSION)/ -type d \
|
||||
-name CVS \
|
||||
-print \
|
||||
-exec rm -rf {} \; ; \
|
||||
\
|
||||
find busybox-$(VERSION)/ -type f \
|
||||
-name .\#* \
|
||||
-print \
|
||||
-exec rm -f {} \; ; \
|
||||
\
|
||||
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
|
||||
|
||||
.PHONY: tags
|
||||
tags:
|
||||
ctags -R .
|
||||
@@ -1,27 +1,123 @@
|
||||
Please see the LICENSE file for copyright information.
|
||||
|
||||
BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
small executable. It provides minimalist replacements for most of the utilities
|
||||
you usually find in fileutils, shellutils, findutils, textutils, grep, gzip,
|
||||
tar, etc. BusyBox provides a fairly complete POSIX environment for any small or
|
||||
embedded system. The utilities in BusyBox generally have fewer options than
|
||||
their full featured GNU cousins; however, the options that are included provide
|
||||
the expected functionality and behave very much like their GNU counterparts.
|
||||
|
||||
Busybox is a multicall binary used to provide a minimal subset of
|
||||
POSIX style commands and specialized functions.
|
||||
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 /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.
|
||||
|
||||
It is geared toward 'mini-systems' like boot floppies. Specifically
|
||||
it is used in the Debian Rescue/Install system (which caused the
|
||||
original busybox to be made), the Linux Router Project, and others.
|
||||
BusyBox was originally written to support the Debian Rescue/Install disks, but
|
||||
it also makes an excellent environment for any small or embedded system.
|
||||
|
||||
As of version 0.20 there is a version number. : )
|
||||
Also as of version 0.20, BB is modularized to allow an easy build of
|
||||
only the BB parts you need, to reduce binary size.
|
||||
As of version 0.20 there is now a version number. : ) Also as of version 0.20,
|
||||
BusyBox is now modularized to easily allow you to build only the components you
|
||||
need, thereby reducing binary size. To turn off unwanted BusyBox components,
|
||||
simply edit the file "Config.h" and comment out the components you do not need
|
||||
using C++ style (//) comments.
|
||||
|
||||
Edit the file busybox.def.h and comment out the parts you do not need
|
||||
using C++ comments (//)
|
||||
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')
|
||||
|
||||
After the build is complete a busybox.links file is generated to allow
|
||||
you to easily make the sym/hard links to the busybox binary.
|
||||
----------------
|
||||
|
||||
Supported architectures:
|
||||
|
||||
Note the modular system is Makefile based, and purposly very
|
||||
simplistic. It does no dependency checking. That is left for you
|
||||
to figure out by trial and error.
|
||||
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.
|
||||
|
||||
----------------
|
||||
|
||||
Getting help:
|
||||
|
||||
When you find you need help, you can check out the BusyBox mailing list
|
||||
archives at http://opensource.lineo.com/lists/busybox/ or even join
|
||||
the mailing list if you are interested.
|
||||
|
||||
----------------
|
||||
|
||||
Bugs:
|
||||
|
||||
If you find bugs, please submit a bug report. Full instructions on how to
|
||||
report a bug are found at http://bugs.lineo.com/Reporting.html.
|
||||
|
||||
For the impatient: To submit a bug, simply send an email describing the problem
|
||||
to submit@bugs.lineo.com. Bug reports should look something like this:
|
||||
|
||||
To: submit@bugs.lineo.com
|
||||
From: diligent@testing.linux.org
|
||||
Subject: /bin/true doesn't work
|
||||
|
||||
Package: busybox
|
||||
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:
|
||||
$ /bin/true ; echo $?
|
||||
1
|
||||
With GNU /bin/true, I get the following output:
|
||||
$ /bin/true ; echo $?
|
||||
0
|
||||
I am using Debian 2.2r2, kernel version 2.2.18, and the latest
|
||||
uClibc from CVS. Thanks for the wonderful program!
|
||||
-Diligent
|
||||
|
||||
Note the careful description and use of examples showing not only what BusyBox
|
||||
does, but also a counter example showing what an equivalent GNU app does. Bug
|
||||
reports lacking such detail may take a _long_ time to be fixed... Thanks for
|
||||
understanding.
|
||||
|
||||
----------------
|
||||
|
||||
FTP:
|
||||
|
||||
Source for the latest released version can always be downloaded from
|
||||
ftp://ftp.lineo.com/pub/busybox.
|
||||
|
||||
----------------
|
||||
|
||||
CVS:
|
||||
|
||||
BusyBox now has its own publicly browsable CVS tree at:
|
||||
http://opensource.lineo.com/cgi-bin/cvsweb/busybox/
|
||||
|
||||
Anonymous CVS access is available. For instructions, check out:
|
||||
http://opensource.lineo.com/cvs_anon.html
|
||||
|
||||
For those that are actively contributing there is even CVS write access:
|
||||
http://opensource.lineo.com/cvs_write.html
|
||||
|
||||
----------------
|
||||
|
||||
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.
|
||||
</blatant plug>
|
||||
|
||||
Please feed patches back to:
|
||||
Dave Cinege <dcinege@psychosis.com>
|
||||
and:
|
||||
Enrique Zanardi <ezanardi@ull.es>
|
||||
@@ -0,0 +1,57 @@
|
||||
TODO list for busybox in no particular order. Just because something
|
||||
is listed here doesn't mean that it is going to be added to busybox,
|
||||
or that doing so is even a good idea. It just means that I _might_ get
|
||||
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).
|
||||
|
||||
* 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
|
||||
|
||||
-----------
|
||||
|
||||
Possible apps to include some time:
|
||||
|
||||
* hwclock
|
||||
* start-stop-daemon
|
||||
* group/commonize strings, remove dups (for i18n, l10n)
|
||||
|
||||
-----------
|
||||
|
||||
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.
|
||||
|
||||
-----------------------
|
||||
|
||||
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.
|
||||
It would be a very nice thing to reduce this list to an absolute minimum, to
|
||||
reduce the footprint of busybox, especially when staticly linking with
|
||||
libraries such as uClibc.
|
||||
|
||||
-----------------------
|
||||
|
||||
Compile with debugging on, run 'nm --size-sort ./busybox'
|
||||
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:
|
||||
*/
|
||||
@@ -0,0 +1,454 @@
|
||||
/*
|
||||
* applets.h - a listing of all busybox applets.
|
||||
*
|
||||
* If you write a new applet, you need to add an entry to this list to make
|
||||
* busybox aware of it.
|
||||
*
|
||||
* It is CRUCIAL that this listing be kept in ascii order, otherwise the binary
|
||||
* search lookup contributed by Gaute B Strokkenes stops working. If you value
|
||||
* your kneecaps, you'll be sure to *make sure* that any changes made to this
|
||||
* 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) 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) 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) {#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_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)
|
||||
#endif
|
||||
#ifdef BB_BASENAME
|
||||
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)
|
||||
#endif
|
||||
#ifdef BB_CHGRP
|
||||
APPLET(chgrp, chgrp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD
|
||||
APPLET(chmod, chmod_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHOWN
|
||||
APPLET(chown, chown_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHROOT
|
||||
APPLET(chroot, chroot_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_CHVT
|
||||
APPLET(chvt, chvt_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CLEAR
|
||||
APPLET(clear, clear_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CMP
|
||||
APPLET(cmp, cmp_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#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)
|
||||
#endif
|
||||
#ifdef BB_DATE
|
||||
APPLET(date, date_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DC
|
||||
APPLET(dc, dc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DD
|
||||
APPLET(dd, dd_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DEALLOCVT
|
||||
APPLET(deallocvt, deallocvt_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DF
|
||||
APPLET(df, df_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DIRNAME
|
||||
APPLET(dirname, dirname_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DMESG
|
||||
APPLET(dmesg, dmesg_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DOS2UNIX
|
||||
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)
|
||||
#endif
|
||||
#ifdef BB_DUMPKMAP
|
||||
APPLET(dumpkmap, dumpkmap_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_DUTMP
|
||||
APPLET(dutmp, dutmp_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_ECHO
|
||||
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)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET(false, false_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FBSET
|
||||
APPLET(fbset, fbset_main, _BB_DIR_USR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH
|
||||
APPLET(fdflush, fdflush_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FIND
|
||||
APPLET(find, find_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FREE
|
||||
APPLET(free, free_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_FREERAMDISK
|
||||
APPLET(freeramdisk, freeramdisk_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_FSCK_MINIX
|
||||
APPLET_ODDNAME("fsck.minix", fsck_minix_main, _BB_DIR_SBIN, fsck_minix)
|
||||
#endif
|
||||
#ifdef BB_GETOPT
|
||||
APPLET(getopt, getopt_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GREP
|
||||
APPLET(grep, grep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET(gunzip, gunzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GZIP
|
||||
APPLET(gzip, gzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HALT
|
||||
APPLET(halt, halt_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_HEAD
|
||||
APPLET(head, head_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HOSTID
|
||||
APPLET(hostid, hostid_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_HOSTNAME
|
||||
APPLET(hostname, hostname_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_ID
|
||||
APPLET(id, id_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_IFCONFIG
|
||||
APPLET(ifconfig, ifconfig_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_INIT
|
||||
APPLET(init, init_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_INSMOD
|
||||
APPLET(insmod, insmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_KILL
|
||||
APPLET(kill, kill_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_KILLALL
|
||||
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)
|
||||
#endif
|
||||
#ifdef BB_FEATURE_LINUXRC
|
||||
APPLET_NOUSAGE("linuxrc", init_main, _BB_DIR_ROOT)
|
||||
#endif
|
||||
#ifdef BB_LN
|
||||
APPLET(ln, ln_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADACM
|
||||
APPLET(loadacm, loadacm_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADFONT
|
||||
APPLET(loadfont, loadfont_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP
|
||||
APPLET(loadkmap, loadkmap_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_LOGGER
|
||||
APPLET(logger, logger_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_LOGNAME
|
||||
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)
|
||||
#endif
|
||||
#ifdef BB_LSMOD
|
||||
APPLET(lsmod, lsmod_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS
|
||||
APPLET(makedevs, makedevs_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MD5SUM
|
||||
APPLET(md5sum, md5sum_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKDIR
|
||||
APPLET(mkdir, mkdir_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKFIFO
|
||||
APPLET(mkfifo, mkfifo_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKFS_MINIX
|
||||
APPLET_ODDNAME("mkfs.minix", mkfs_minix_main, _BB_DIR_SBIN, mkfs_minix)
|
||||
#endif
|
||||
#ifdef BB_MKNOD
|
||||
APPLET(mknod, mknod_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MKSWAP
|
||||
APPLET(mkswap, mkswap_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_MKTEMP
|
||||
APPLET(mktemp, mktemp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MORE
|
||||
APPLET(more, more_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MOUNT
|
||||
APPLET(mount, mount_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MT
|
||||
APPLET(mt, mt_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_MV
|
||||
APPLET(mv, mv_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_NC
|
||||
APPLET(nc, nc_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_NSLOOKUP
|
||||
APPLET(nslookup, nslookup_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PING
|
||||
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)
|
||||
#endif
|
||||
#ifdef BB_PRINTF
|
||||
APPLET(printf, printf_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PS
|
||||
APPLET(ps, ps_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_PWD
|
||||
APPLET(pwd, pwd_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RDATE
|
||||
APPLET(rdate, rdate_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_READLINK
|
||||
APPLET(readlink, readlink_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_REBOOT
|
||||
APPLET(reboot, reboot_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_RENICE
|
||||
APPLET(renice, renice_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RESET
|
||||
APPLET(reset, reset_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RM
|
||||
APPLET(rm, rm_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RMDIR
|
||||
APPLET(rmdir, rmdir_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_RMMOD
|
||||
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)
|
||||
#endif
|
||||
#ifdef BB_SED
|
||||
APPLET(sed, sed_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SETKEYCODES
|
||||
APPLET(setkeycodes, setkeycodes_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SH
|
||||
APPLET(sh, shell_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SLEEP
|
||||
APPLET(sleep, sleep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SORT
|
||||
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)
|
||||
#endif
|
||||
#ifdef BB_SWAPONOFF
|
||||
APPLET(swapon, swap_on_off_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_SYNC
|
||||
APPLET(sync, sync_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_SYSLOGD
|
||||
APPLET(syslogd, syslogd_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_TAIL
|
||||
APPLET(tail, tail_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TAR
|
||||
APPLET(tar, tar_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TEE
|
||||
APPLET(tee, tee_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TELNET
|
||||
APPLET(telnet, telnet_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TEST
|
||||
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)
|
||||
#endif
|
||||
#ifdef BB_TR
|
||||
APPLET(tr, tr_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TRUE_FALSE
|
||||
APPLET(true, true_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_TTY
|
||||
APPLET(tty, tty_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UMOUNT
|
||||
APPLET(umount, umount_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNAME
|
||||
APPLET(uname, uname_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNIQ
|
||||
APPLET(uniq, uniq_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UNIX2DOS
|
||||
APPLET(unix2dos, unix2dos_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UPDATE
|
||||
APPLET(update, update_main, _BB_DIR_SBIN)
|
||||
#endif
|
||||
#ifdef BB_UPTIME
|
||||
APPLET(uptime, uptime_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_USLEEP
|
||||
APPLET(usleep, usleep_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UUDECODE
|
||||
APPLET(uudecode, uudecode_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_UUENCODE
|
||||
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)
|
||||
#endif
|
||||
#ifdef BB_WGET
|
||||
APPLET(wget, wget_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WHICH
|
||||
APPLET(which, which_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_WHOAMI
|
||||
APPLET(whoami, whoami_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_XARGS
|
||||
APPLET(xargs, xargs_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_YES
|
||||
APPLET(yes, yes_main, _BB_DIR_USR_BIN)
|
||||
#endif
|
||||
#ifdef BB_GUNZIP
|
||||
APPLET(zcat, gunzip_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
|
||||
#if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
|
||||
{ 0,NULL,0 }
|
||||
};
|
||||
|
||||
#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:
|
||||
*/
|
||||
+158
-207
@@ -1,230 +1,181 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#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
|
||||
|
||||
static int been_there_done_that = 0;
|
||||
int been_there_done_that = 0; /* Also used in applets.c */
|
||||
const char *applet_name;
|
||||
|
||||
static const struct Applet applets[] = {
|
||||
|
||||
#ifdef BB_BUSYBOX //bin
|
||||
{"busybox", busybox_main},
|
||||
#endif
|
||||
#ifdef BB_BLOCK_DEVICE //sbin
|
||||
{"block_device", block_device_main},
|
||||
#endif
|
||||
#ifdef BB_CAT //bin
|
||||
{"cat", cat_more_main},
|
||||
#endif
|
||||
#ifdef BB_CHGRP //bin
|
||||
{"chgrp", chgrp_main},
|
||||
#endif
|
||||
#ifdef BB_CHMOD //bin
|
||||
{"chmod", chmod_main},
|
||||
#endif
|
||||
#ifdef BB_CHOWN //bin
|
||||
{"chown", chown_main},
|
||||
#endif
|
||||
#ifdef BB_CHROOT //sbin
|
||||
{"chroot", chroot_main},
|
||||
#endif
|
||||
#ifdef BB_CLEAR //usr/bin
|
||||
{"clear", clear_main},
|
||||
#endif
|
||||
#ifdef BB_CP //bin
|
||||
{"cp", dyadic_main},
|
||||
#endif
|
||||
#ifdef BB_DATE //bin
|
||||
{"date", date_main},
|
||||
#endif
|
||||
#ifdef BB_DD //bin
|
||||
{"dd", dd_main},
|
||||
#endif
|
||||
#ifdef BB_DF //bin
|
||||
{"df", df_main},
|
||||
#endif
|
||||
#ifdef BB_DMESG //bin
|
||||
{"dmesg", dmesg_main},
|
||||
#endif
|
||||
#ifdef BB_DUTMP //usr/sbin
|
||||
{"dutmp", cat_more_main},
|
||||
#endif
|
||||
#ifdef BB_FALSE //bin
|
||||
{"false", false_main},
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH //bin
|
||||
{"fdflush", monadic_main},
|
||||
#endif
|
||||
#ifdef BB_FIND //usr/bin
|
||||
{"find", find_main},
|
||||
#endif
|
||||
#ifdef BB_GREP //bin
|
||||
{"grep", grep_main},
|
||||
#endif
|
||||
#ifdef BB_HALT //sbin
|
||||
{"halt", halt_main},
|
||||
#endif
|
||||
#ifdef BB_INIT //sbin
|
||||
{"init", init_main},
|
||||
#endif
|
||||
#ifdef BB_KILL //bin
|
||||
{"kill", kill_main},
|
||||
#endif
|
||||
#ifdef BB_LENGTH //usr/bin
|
||||
{"length", length_main},
|
||||
#endif
|
||||
#ifdef BB_LN //bin
|
||||
{"ln", dyadic_main},
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP //sbin
|
||||
{"loadkmap", loadkmap_main},
|
||||
#endif
|
||||
#ifdef BB_LOSETUP //sbin
|
||||
{"losetup", losetup_main},
|
||||
#endif
|
||||
#ifdef BB_LS //bin
|
||||
{"ls", ls_main},
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS //sbin
|
||||
{"makedevs", makedevs_main},
|
||||
#endif
|
||||
#ifdef BB_MATH //usr/bin
|
||||
{"math", math_main},
|
||||
#endif
|
||||
#ifdef BB_MKDIR //bin
|
||||
{"mkdir", monadic_main},
|
||||
#endif
|
||||
#ifdef BB_MKNOD //bin
|
||||
{"mknod", mknod_main},
|
||||
#endif
|
||||
#ifdef BB_MKSWAP //sbin
|
||||
{"mkswap", mkswap_main},
|
||||
#endif
|
||||
#ifdef BB_MNC //usr/bin
|
||||
{"mnc", mnc_main},
|
||||
#endif
|
||||
#ifdef BB_MORE //bin
|
||||
{"more", cat_more_main},
|
||||
#endif
|
||||
#ifdef BB_MOUNT //bin
|
||||
{"mount", mount_main},
|
||||
#endif
|
||||
#ifdef BB_MT //bin
|
||||
{"mt", mt_main},
|
||||
#endif
|
||||
#ifdef BB_MV //bin
|
||||
{"mv", dyadic_main},
|
||||
#endif
|
||||
#ifdef BB_PRINTF //usr/bin
|
||||
{"printf", printf_main},
|
||||
#endif
|
||||
#ifdef BB_PWD //bin
|
||||
{"pwd", pwd_main},
|
||||
#endif
|
||||
#ifdef BB_REBOOT //sbin
|
||||
{"reboot", reboot_main},
|
||||
#endif
|
||||
#ifdef BB_RM //bin
|
||||
{"rm", rm_main},
|
||||
#endif
|
||||
#ifdef BB_RMDIR //bin
|
||||
{"rmdir", monadic_main},
|
||||
#endif
|
||||
#ifdef BB_SLEEP //bin
|
||||
{"sleep", sleep_main},
|
||||
#endif
|
||||
#ifdef BB_TAR //bin
|
||||
{"tar", tar_main},
|
||||
#endif
|
||||
#ifdef BB_SWAPOFF //sbin
|
||||
{"swapoff", monadic_main},
|
||||
#endif
|
||||
#ifdef BB_SWAPON //sbin
|
||||
{"swapon", monadic_main},
|
||||
#endif
|
||||
#ifdef BB_SYNC //bin
|
||||
{"sync", sync_main},
|
||||
#endif
|
||||
#ifdef BB_TOUCH //usr/bin
|
||||
{"touch", monadic_main},
|
||||
#endif
|
||||
#ifdef BB_TRUE //bin
|
||||
{"true", true_main},
|
||||
#endif
|
||||
#ifdef BB_UMOUNT //bin
|
||||
{"umount", umount_main},
|
||||
#endif
|
||||
#ifdef BB_UPDATE //sbin
|
||||
{"update", update_main},
|
||||
#endif
|
||||
#ifdef BB_ZCAT //bin
|
||||
{"zcat", zcat_main},
|
||||
{"gunzip", zcat_main},
|
||||
#endif
|
||||
#ifdef BB_GZIP //bin
|
||||
{"gzip", gzip_main},
|
||||
#endif
|
||||
{0}
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* directory table
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
* or else...
|
||||
*/
|
||||
static char* install_dir[] = {
|
||||
"/",
|
||||
"/bin",
|
||||
"/sbin",
|
||||
"/usr/bin",
|
||||
"/usr/sbin",
|
||||
};
|
||||
|
||||
/* abstract link() */
|
||||
typedef int (*__link_f)(const char *, const char *);
|
||||
|
||||
/*
|
||||
* Where in the filesystem is this busybox?
|
||||
* [return]
|
||||
* malloc'd string w/ full pathname of busybox's location
|
||||
* NULL on failure
|
||||
*/
|
||||
static char *busybox_fullpath()
|
||||
{
|
||||
return xreadlink("/proc/self/exe");
|
||||
}
|
||||
|
||||
/* create (sym)links for each applet */
|
||||
static void install_links(const char *busybox, int use_symbolic_links)
|
||||
{
|
||||
__link_f Link = link;
|
||||
|
||||
char *fpc;
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
fpc = concat_path_file(
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, fpc);
|
||||
if (rc!=0 && errno!=EEXIST) {
|
||||
perror_msg("%s", fpc);
|
||||
}
|
||||
free(fpc);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *s = argv[0];
|
||||
char *name = argv[0];
|
||||
const struct Applet *a = applets;
|
||||
const char *s;
|
||||
|
||||
while (*s != '\0') {
|
||||
if (*s++ == '/')
|
||||
name = s;
|
||||
}
|
||||
|
||||
while (a->name != 0) {
|
||||
if (strcmp(name, a->name) == 0) {
|
||||
int status;
|
||||
|
||||
status = ((*(a->main)) (argc, argv));
|
||||
if (status < 0) {
|
||||
fprintf(stderr, "%s: %s\n", a->name, strerror(errno));
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
exit(status);
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
a++;
|
||||
}
|
||||
return (busybox_main(argc, argv));
|
||||
|
||||
/* 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)
|
||||
{
|
||||
argc--;
|
||||
argv++;
|
||||
int col = 0, len, i;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
if (been_there_done_that == 1)
|
||||
return -1;
|
||||
been_there_done_that = 1;
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* This style of argument parsing doesn't scale well
|
||||
* in the event that busybox starts wanting more --options.
|
||||
* If someone has a cleaner approach, by all means implement it.
|
||||
*/
|
||||
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
|
||||
int use_symbolic_links = 0;
|
||||
int rc = 0;
|
||||
char *busybox;
|
||||
|
||||
if (argc < 1) {
|
||||
const struct Applet *a = applets;
|
||||
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n",
|
||||
BB_VER, BB_BT);
|
||||
fprintf(stderr, "Usage: busybox [function] [arguments]...\n");
|
||||
fprintf(stderr,
|
||||
"\n\tMost people will create a symlink to busybox for each\n"
|
||||
"\tfunction name, and busybox will act like whatever you invoke it as.\n");
|
||||
fprintf(stderr, "\nCurrently defined functions:\n");
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argc > 2) {
|
||||
if ((strcmp(argv[2], "-s") == 0)) {
|
||||
use_symbolic_links = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (a->name != 0) {
|
||||
fprintf(stderr, "%s", a->name);
|
||||
a++;
|
||||
/* link */
|
||||
busybox = busybox_fullpath();
|
||||
if (busybox) {
|
||||
install_links(busybox, use_symbolic_links);
|
||||
free(busybox);
|
||||
} else {
|
||||
rc = 1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
while (a->name != 0) {
|
||||
fprintf(stderr, ", %s", a->name);
|
||||
a++;
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
argc--;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
if (been_there_done_that == 1 || argc < 1) {
|
||||
const struct BB_applet *a = applets;
|
||||
|
||||
fprintf(stderr, "%s\n\n"
|
||||
"Usage: busybox [function] [arguments]...\n"
|
||||
" or: [function] [arguments]...\n\n"
|
||||
"\tBusyBox is a multi-call binary that combines many common Unix\n"
|
||||
"\tutilities into a single executable. Most people will create a\n"
|
||||
"\tlink to busybox for each function they wish to use, and BusyBox\n"
|
||||
"\twill act like whatever it was invoked as.\n"
|
||||
"\nCurrently defined functions:\n", full_version);
|
||||
|
||||
while (a->name != 0) {
|
||||
col +=
|
||||
fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
|
||||
(a++)->name);
|
||||
if (col > 60 && a->name != 0) {
|
||||
fprintf(stderr, ",\n");
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(0);
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(-1);
|
||||
} else
|
||||
|
||||
/* Flag that we've been here already */
|
||||
been_there_done_that = 1;
|
||||
|
||||
/* 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));
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
+20
-13
@@ -1,17 +1,24 @@
|
||||
#!/bin/sh
|
||||
#Make busybox links list file
|
||||
# Make busybox links list file.
|
||||
|
||||
DF="busybox.def.h"
|
||||
MF="main.c"
|
||||
# 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
|
||||
|
||||
LIST="$(sed -n '/^#define/{s/^#define //p;}' $DF)"
|
||||
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
|
||||
for def in ${LIST}; do
|
||||
|
||||
set -- $(sed -n '/^#ifdef '$def'[ +| +].*/,/^#endif/{s/.*\/\///p; /^{ /{ s/^{ "//; s/",.*$//p;}; }' $MF)
|
||||
path=$1; shift
|
||||
|
||||
for n in $@; do
|
||||
echo "$path/$n"
|
||||
done
|
||||
done
|
||||
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/{
|
||||
dir=substr($2,8)
|
||||
gsub("_","/",dir)
|
||||
if(dir=="/ROOT") dir=""
|
||||
file=$3
|
||||
gsub("\"","",file)
|
||||
if (file=="busybox") next
|
||||
print tolower(dir) "/" file
|
||||
}'
|
||||
Executable
+16
@@ -0,0 +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 A-Z a-z | sort
|
||||
`
|
||||
test "${RAW}" != "" || exit
|
||||
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' ' '
|
||||
|
||||
Executable
+52
@@ -0,0 +1,52 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
prefix=$1
|
||||
if [ "$prefix" = "" ]; then
|
||||
echo "No installation directory, aborting."
|
||||
exit 1;
|
||||
fi
|
||||
if [ "$2" = "--hardlinks" ]; then
|
||||
linkopts="-f"
|
||||
else
|
||||
linkopts="-fs"
|
||||
fi
|
||||
h=`sort busybox.links | uniq`
|
||||
|
||||
|
||||
rm -f $prefix/bin/busybox || exit 1
|
||||
mkdir -p $prefix/bin || exit 1
|
||||
install -m 755 busybox $prefix/bin/busybox || exit 1
|
||||
|
||||
for i in $h ; do
|
||||
appdir=`dirname $i`
|
||||
mkdir -p $prefix/$appdir || exit 1
|
||||
if [ "$2" = "--hardlinks" ]; then
|
||||
bb_path="$prefix/bin/busybox"
|
||||
else
|
||||
case "$appdir" in
|
||||
/)
|
||||
bb_path="bin/busybox"
|
||||
;;
|
||||
/bin)
|
||||
bb_path="busybox"
|
||||
;;
|
||||
/sbin)
|
||||
bb_path="../bin/busybox"
|
||||
;;
|
||||
/usr/bin|/usr/sbin)
|
||||
bb_path="../../bin/busybox"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown installation directory: $appdir"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
echo " $prefix$i -> $bb_path"
|
||||
ln $linkopts $bb_path $prefix$i || exit 1
|
||||
done
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "busybox.h"
|
||||
|
||||
const char usage_messages[] =
|
||||
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
|
||||
#include "applets.h"
|
||||
|
||||
;
|
||||
+1787
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,89 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
|
||||
*
|
||||
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
|
||||
*
|
||||
* 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 <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
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, "ovtpx")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
extract_function |= extract_preserve_date;
|
||||
break;
|
||||
case 'v':
|
||||
extract_function |= extract_verbose_list;
|
||||
break;
|
||||
case 't':
|
||||
extract_function |= extract_list;
|
||||
break;
|
||||
case 'p':
|
||||
extract_function |= extract_to_stdout;
|
||||
break;
|
||||
case 'x':
|
||||
extract_function |= extract_all_to_fs;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
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,89 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@optushome.com.au> 1 June 2000
|
||||
*
|
||||
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
|
||||
*
|
||||
* 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 <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
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, "ovtpx")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
extract_function |= extract_preserve_date;
|
||||
break;
|
||||
case 'v':
|
||||
extract_function |= extract_verbose_list;
|
||||
break;
|
||||
case 't':
|
||||
extract_function |= extract_list;
|
||||
break;
|
||||
case 'p':
|
||||
extract_function |= extract_to_stdout;
|
||||
break;
|
||||
case 'x':
|
||||
extract_function |= extract_all_to_fs;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Gzip implementation for busybox
|
||||
*
|
||||
* Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly.
|
||||
*
|
||||
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
|
||||
* based on gzip sources
|
||||
*
|
||||
* Adjusted further by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* to support files as well as stdin/stdout, and to generally behave itself wrt
|
||||
* command line handling.
|
||||
*
|
||||
* General cleanup to better adhere to the style guide and make use of standard
|
||||
* busybox functions by Glenn McGrath <bug1@optushome.com.au>
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*
|
||||
* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
|
||||
* Copyright (C) 1992-1993 Jean-loup Gailly
|
||||
* The unzip code was written and put in the public domain by Mark Adler.
|
||||
* Portions of the lzw code are derived from the public domain 'compress'
|
||||
* written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies,
|
||||
* Ken Turkowski, Dave Mack and Peter Jannesen.
|
||||
*
|
||||
* See the license_msg below and the file COPYING for the software license.
|
||||
* See the file algorithm.doc for the compression algorithms and file formats.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
static char *license_msg[] = {
|
||||
" Copyright (C) 1992-1993 Jean-loup Gailly",
|
||||
" 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., 675 Mass Ave, Cambridge, MA 02139, USA.",
|
||||
0
|
||||
};
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int gunzip_main(int argc, char **argv)
|
||||
{
|
||||
FILE *in_file = stdin;
|
||||
FILE *out_file = NULL;
|
||||
struct stat stat_buf;
|
||||
|
||||
char *if_name = NULL;
|
||||
char *of_name = NULL;
|
||||
char *delete_file_name = NULL;
|
||||
|
||||
const int gunzip_to_stdout = 1;
|
||||
const int gunzip_force = 2;
|
||||
const int gunzip_test = 4;
|
||||
|
||||
int flags = 0;
|
||||
int opt = 0;
|
||||
int delete_old_file = FALSE;
|
||||
|
||||
/* if called as zcat */
|
||||
if (strcmp(applet_name, "zcat") == 0)
|
||||
flags |= gunzip_to_stdout;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ctfhdq")) != -1) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
flags |= gunzip_to_stdout;
|
||||
break;
|
||||
case 'f':
|
||||
flags |= gunzip_force;
|
||||
break;
|
||||
case 't':
|
||||
flags |= gunzip_test;
|
||||
break;
|
||||
case 'd': /* Used to convert gzip to gunzip. */
|
||||
break;
|
||||
case 'q':
|
||||
error_msg("-q option not supported, ignored");
|
||||
break;
|
||||
case 'h':
|
||||
default:
|
||||
show_usage(); /* exit's inside usage */
|
||||
}
|
||||
}
|
||||
|
||||
/* Set input filename and number */
|
||||
if (argv[optind] == NULL || strcmp(argv[optind], "-") == 0) {
|
||||
flags |= gunzip_to_stdout;
|
||||
} else {
|
||||
if_name = strdup(argv[optind]);
|
||||
/* Open input file */
|
||||
in_file = xfopen(if_name, "r");
|
||||
|
||||
/* Get the time stamp on the input file. */
|
||||
if (stat(if_name, &stat_buf) < 0) {
|
||||
error_msg_and_die("Couldn't stat file %s", if_name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that the input is sane. */
|
||||
if (isatty(fileno(in_file)) && (flags & gunzip_force) == 0)
|
||||
error_msg_and_die("compressed data not read from terminal. Use -f to force it.");
|
||||
|
||||
/* Set output filename and number */
|
||||
if (flags & gunzip_test) {
|
||||
out_file = xfopen("/dev/null", "w"); /* why does test use filenum 2 ? */
|
||||
} else if (flags & gunzip_to_stdout) {
|
||||
out_file = stdout;
|
||||
} else {
|
||||
char *extension;
|
||||
int length = strlen(if_name);
|
||||
|
||||
delete_old_file = TRUE;
|
||||
extension = strrchr(if_name, '.');
|
||||
if (extension && strcmp(extension, ".gz") == 0) {
|
||||
length -= 3;
|
||||
} else if (extension && strcmp(extension, ".tgz") == 0) {
|
||||
length -= 4;
|
||||
} else {
|
||||
error_msg_and_die("Invalid extension");
|
||||
}
|
||||
of_name = (char *) xcalloc(sizeof(char), length + 1);
|
||||
strncpy(of_name, if_name, length);
|
||||
|
||||
/* Open output file */
|
||||
out_file = xfopen(of_name, "w");
|
||||
|
||||
/* Set permissions on the file */
|
||||
chmod(of_name, stat_buf.st_mode);
|
||||
}
|
||||
|
||||
/* do the decompression, and cleanup */
|
||||
if (unzip(in_file, out_file) == 0) {
|
||||
/* Success, remove .gz file */
|
||||
delete_file_name = if_name;
|
||||
} else {
|
||||
/* remove failed attempt */
|
||||
delete_file_name = of_name;
|
||||
}
|
||||
|
||||
fclose(out_file);
|
||||
fclose(in_file);
|
||||
|
||||
if (delete_old_file == TRUE) {
|
||||
if (unlink(delete_file_name) < 0) {
|
||||
error_msg_and_die("Couldnt remove %s", delete_file_name);
|
||||
}
|
||||
}
|
||||
|
||||
free(of_name);
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
+1399
-2080
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;
|
||||
}
|
||||
+1029
-1310
File diff suppressed because it is too large.
Load diff
+52
@@ -0,0 +1,52 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini basename 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
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include <string.h>
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
int m, n;
|
||||
char *s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
argv++;
|
||||
|
||||
s = get_last_path_component(*argv);
|
||||
|
||||
if (argc>2) {
|
||||
argv++;
|
||||
n = strlen(*argv);
|
||||
m = strlen(s);
|
||||
if (m>=n && strncmp(s+m-n, *argv, n)==0)
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
puts(s);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
#include "internal.h"
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
const char block_device_usage[] = "block_device mount-point";
|
||||
|
||||
static dev_t *my_device;
|
||||
static char *my_device_name;
|
||||
|
||||
int
|
||||
match_mount(const struct FileInfo * i) {
|
||||
if ( S_ISBLK(i->stat.st_mode)
|
||||
&& (i->stat.st_rdev == *my_device)) {
|
||||
my_device_name=strdup(i->source);
|
||||
return 1;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int
|
||||
block_device_main(struct FileInfo * i, int argc, char * * argv)
|
||||
{
|
||||
char *device_name = block_device(argv[1],i);
|
||||
if ( device_name == NULL )
|
||||
return -1;
|
||||
printf("%s\n", device_name);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
char * block_device(const char *name, struct FileInfo *i)
|
||||
{
|
||||
struct stat s;
|
||||
char *buf;
|
||||
int dinam=0;
|
||||
|
||||
if ( stat(name, &s) ) return (char *) NULL;
|
||||
if (!i) {
|
||||
i=(struct FileInfo*)malloc(sizeof(struct FileInfo));
|
||||
dinam = 1;
|
||||
}
|
||||
memset((void *)i, 0, sizeof(struct FileInfo));
|
||||
my_device=(dev_t *)malloc(sizeof(dev_t));
|
||||
*my_device = s.st_dev;
|
||||
my_device_name = NULL;
|
||||
i->source = "/dev";
|
||||
i->stat = s;
|
||||
i->processDirectoriesAfterTheirContents=1;
|
||||
descend(i, match_mount);
|
||||
if (dinam) free(i);
|
||||
if ( my_device_name ) {
|
||||
buf = strdup(my_device_name);
|
||||
free(my_device);
|
||||
free(my_device_name);
|
||||
return buf;
|
||||
} else {
|
||||
fprintf( stderr
|
||||
,"Can't find special file for block device %d, %d.\n"
|
||||
,(int) *my_device >> 8 & 0xff
|
||||
,(int) *my_device & 0xff);
|
||||
free(my_device);
|
||||
return (char *) NULL;
|
||||
}
|
||||
}
|
||||
@@ -1,230 +1,181 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#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
|
||||
|
||||
static int been_there_done_that = 0;
|
||||
int been_there_done_that = 0; /* Also used in applets.c */
|
||||
const char *applet_name;
|
||||
|
||||
static const struct Applet applets[] = {
|
||||
|
||||
#ifdef BB_BUSYBOX //bin
|
||||
{"busybox", busybox_main},
|
||||
#endif
|
||||
#ifdef BB_BLOCK_DEVICE //sbin
|
||||
{"block_device", block_device_main},
|
||||
#endif
|
||||
#ifdef BB_CAT //bin
|
||||
{"cat", cat_more_main},
|
||||
#endif
|
||||
#ifdef BB_CHGRP //bin
|
||||
{"chgrp", chgrp_main},
|
||||
#endif
|
||||
#ifdef BB_CHMOD //bin
|
||||
{"chmod", chmod_main},
|
||||
#endif
|
||||
#ifdef BB_CHOWN //bin
|
||||
{"chown", chown_main},
|
||||
#endif
|
||||
#ifdef BB_CHROOT //sbin
|
||||
{"chroot", chroot_main},
|
||||
#endif
|
||||
#ifdef BB_CLEAR //usr/bin
|
||||
{"clear", clear_main},
|
||||
#endif
|
||||
#ifdef BB_CP //bin
|
||||
{"cp", dyadic_main},
|
||||
#endif
|
||||
#ifdef BB_DATE //bin
|
||||
{"date", date_main},
|
||||
#endif
|
||||
#ifdef BB_DD //bin
|
||||
{"dd", dd_main},
|
||||
#endif
|
||||
#ifdef BB_DF //bin
|
||||
{"df", df_main},
|
||||
#endif
|
||||
#ifdef BB_DMESG //bin
|
||||
{"dmesg", dmesg_main},
|
||||
#endif
|
||||
#ifdef BB_DUTMP //usr/sbin
|
||||
{"dutmp", cat_more_main},
|
||||
#endif
|
||||
#ifdef BB_FALSE //bin
|
||||
{"false", false_main},
|
||||
#endif
|
||||
#ifdef BB_FDFLUSH //bin
|
||||
{"fdflush", monadic_main},
|
||||
#endif
|
||||
#ifdef BB_FIND //usr/bin
|
||||
{"find", find_main},
|
||||
#endif
|
||||
#ifdef BB_GREP //bin
|
||||
{"grep", grep_main},
|
||||
#endif
|
||||
#ifdef BB_HALT //sbin
|
||||
{"halt", halt_main},
|
||||
#endif
|
||||
#ifdef BB_INIT //sbin
|
||||
{"init", init_main},
|
||||
#endif
|
||||
#ifdef BB_KILL //bin
|
||||
{"kill", kill_main},
|
||||
#endif
|
||||
#ifdef BB_LENGTH //usr/bin
|
||||
{"length", length_main},
|
||||
#endif
|
||||
#ifdef BB_LN //bin
|
||||
{"ln", dyadic_main},
|
||||
#endif
|
||||
#ifdef BB_LOADKMAP //sbin
|
||||
{"loadkmap", loadkmap_main},
|
||||
#endif
|
||||
#ifdef BB_LOSETUP //sbin
|
||||
{"losetup", losetup_main},
|
||||
#endif
|
||||
#ifdef BB_LS //bin
|
||||
{"ls", ls_main},
|
||||
#endif
|
||||
#ifdef BB_MAKEDEVS //sbin
|
||||
{"makedevs", makedevs_main},
|
||||
#endif
|
||||
#ifdef BB_MATH //usr/bin
|
||||
{"math", math_main},
|
||||
#endif
|
||||
#ifdef BB_MKDIR //bin
|
||||
{"mkdir", monadic_main},
|
||||
#endif
|
||||
#ifdef BB_MKNOD //bin
|
||||
{"mknod", mknod_main},
|
||||
#endif
|
||||
#ifdef BB_MKSWAP //sbin
|
||||
{"mkswap", mkswap_main},
|
||||
#endif
|
||||
#ifdef BB_MNC //usr/bin
|
||||
{"mnc", mnc_main},
|
||||
#endif
|
||||
#ifdef BB_MORE //bin
|
||||
{"more", cat_more_main},
|
||||
#endif
|
||||
#ifdef BB_MOUNT //bin
|
||||
{"mount", mount_main},
|
||||
#endif
|
||||
#ifdef BB_MT //bin
|
||||
{"mt", mt_main},
|
||||
#endif
|
||||
#ifdef BB_MV //bin
|
||||
{"mv", dyadic_main},
|
||||
#endif
|
||||
#ifdef BB_PRINTF //usr/bin
|
||||
{"printf", printf_main},
|
||||
#endif
|
||||
#ifdef BB_PWD //bin
|
||||
{"pwd", pwd_main},
|
||||
#endif
|
||||
#ifdef BB_REBOOT //sbin
|
||||
{"reboot", reboot_main},
|
||||
#endif
|
||||
#ifdef BB_RM //bin
|
||||
{"rm", rm_main},
|
||||
#endif
|
||||
#ifdef BB_RMDIR //bin
|
||||
{"rmdir", monadic_main},
|
||||
#endif
|
||||
#ifdef BB_SLEEP //bin
|
||||
{"sleep", sleep_main},
|
||||
#endif
|
||||
#ifdef BB_TAR //bin
|
||||
{"tar", tar_main},
|
||||
#endif
|
||||
#ifdef BB_SWAPOFF //sbin
|
||||
{"swapoff", monadic_main},
|
||||
#endif
|
||||
#ifdef BB_SWAPON //sbin
|
||||
{"swapon", monadic_main},
|
||||
#endif
|
||||
#ifdef BB_SYNC //bin
|
||||
{"sync", sync_main},
|
||||
#endif
|
||||
#ifdef BB_TOUCH //usr/bin
|
||||
{"touch", monadic_main},
|
||||
#endif
|
||||
#ifdef BB_TRUE //bin
|
||||
{"true", true_main},
|
||||
#endif
|
||||
#ifdef BB_UMOUNT //bin
|
||||
{"umount", umount_main},
|
||||
#endif
|
||||
#ifdef BB_UPDATE //sbin
|
||||
{"update", update_main},
|
||||
#endif
|
||||
#ifdef BB_ZCAT //bin
|
||||
{"zcat", zcat_main},
|
||||
{"gunzip", zcat_main},
|
||||
#endif
|
||||
#ifdef BB_GZIP //bin
|
||||
{"gzip", gzip_main},
|
||||
#endif
|
||||
{0}
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* directory table
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
* or else...
|
||||
*/
|
||||
static char* install_dir[] = {
|
||||
"/",
|
||||
"/bin",
|
||||
"/sbin",
|
||||
"/usr/bin",
|
||||
"/usr/sbin",
|
||||
};
|
||||
|
||||
/* abstract link() */
|
||||
typedef int (*__link_f)(const char *, const char *);
|
||||
|
||||
/*
|
||||
* Where in the filesystem is this busybox?
|
||||
* [return]
|
||||
* malloc'd string w/ full pathname of busybox's location
|
||||
* NULL on failure
|
||||
*/
|
||||
static char *busybox_fullpath()
|
||||
{
|
||||
return xreadlink("/proc/self/exe");
|
||||
}
|
||||
|
||||
/* create (sym)links for each applet */
|
||||
static void install_links(const char *busybox, int use_symbolic_links)
|
||||
{
|
||||
__link_f Link = link;
|
||||
|
||||
char *fpc;
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
fpc = concat_path_file(
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, fpc);
|
||||
if (rc!=0 && errno!=EEXIST) {
|
||||
perror_msg("%s", fpc);
|
||||
}
|
||||
free(fpc);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *s = argv[0];
|
||||
char *name = argv[0];
|
||||
const struct Applet *a = applets;
|
||||
const char *s;
|
||||
|
||||
while (*s != '\0') {
|
||||
if (*s++ == '/')
|
||||
name = s;
|
||||
}
|
||||
|
||||
while (a->name != 0) {
|
||||
if (strcmp(name, a->name) == 0) {
|
||||
int status;
|
||||
|
||||
status = ((*(a->main)) (argc, argv));
|
||||
if (status < 0) {
|
||||
fprintf(stderr, "%s: %s\n", a->name, strerror(errno));
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
exit(status);
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
a++;
|
||||
}
|
||||
return (busybox_main(argc, argv));
|
||||
|
||||
/* 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)
|
||||
{
|
||||
argc--;
|
||||
argv++;
|
||||
int col = 0, len, i;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
if (been_there_done_that == 1)
|
||||
return -1;
|
||||
been_there_done_that = 1;
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* This style of argument parsing doesn't scale well
|
||||
* in the event that busybox starts wanting more --options.
|
||||
* If someone has a cleaner approach, by all means implement it.
|
||||
*/
|
||||
if (argc > 1 && (strcmp(argv[1], "--install") == 0)) {
|
||||
int use_symbolic_links = 0;
|
||||
int rc = 0;
|
||||
char *busybox;
|
||||
|
||||
if (argc < 1) {
|
||||
const struct Applet *a = applets;
|
||||
fprintf(stderr, "BusyBox v%s (%s) multi-call binary -- GPL2\n",
|
||||
BB_VER, BB_BT);
|
||||
fprintf(stderr, "Usage: busybox [function] [arguments]...\n");
|
||||
fprintf(stderr,
|
||||
"\n\tMost people will create a symlink to busybox for each\n"
|
||||
"\tfunction name, and busybox will act like whatever you invoke it as.\n");
|
||||
fprintf(stderr, "\nCurrently defined functions:\n");
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argc > 2) {
|
||||
if ((strcmp(argv[2], "-s") == 0)) {
|
||||
use_symbolic_links = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (a->name != 0) {
|
||||
fprintf(stderr, "%s", a->name);
|
||||
a++;
|
||||
/* link */
|
||||
busybox = busybox_fullpath();
|
||||
if (busybox) {
|
||||
install_links(busybox, use_symbolic_links);
|
||||
free(busybox);
|
||||
} else {
|
||||
rc = 1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
while (a->name != 0) {
|
||||
fprintf(stderr, ", %s", a->name);
|
||||
a++;
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
argc--;
|
||||
|
||||
/* If we've already been here once, exit now */
|
||||
if (been_there_done_that == 1 || argc < 1) {
|
||||
const struct BB_applet *a = applets;
|
||||
|
||||
fprintf(stderr, "%s\n\n"
|
||||
"Usage: busybox [function] [arguments]...\n"
|
||||
" or: [function] [arguments]...\n\n"
|
||||
"\tBusyBox is a multi-call binary that combines many common Unix\n"
|
||||
"\tutilities into a single executable. Most people will create a\n"
|
||||
"\tlink to busybox for each function they wish to use, and BusyBox\n"
|
||||
"\twill act like whatever it was invoked as.\n"
|
||||
"\nCurrently defined functions:\n", full_version);
|
||||
|
||||
while (a->name != 0) {
|
||||
col +=
|
||||
fprintf(stderr, "%s%s", ((col == 0) ? "\t" : ", "),
|
||||
(a++)->name);
|
||||
if (col > 60 && a->name != 0) {
|
||||
fprintf(stderr, ",\n");
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(0);
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
exit(-1);
|
||||
} else
|
||||
|
||||
/* Flag that we've been here already */
|
||||
been_there_done_that = 1;
|
||||
|
||||
/* 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));
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* This file is parsed by sed. You MUST use single line comments.
|
||||
* IE //#define BB_BLAH
|
||||
*/
|
||||
|
||||
//#define BB_BLOCK_DEVICE
|
||||
#define BB_BUSYBOX
|
||||
#define BB_CAT
|
||||
#define BB_CHGRP
|
||||
//#define BB_CHMOD
|
||||
//#define BB_CHOWN
|
||||
//#define BB_CHROOT
|
||||
//#define BB_CLEAR
|
||||
//#define BB_CP
|
||||
//#define BB_DATE
|
||||
//#define BB_DD
|
||||
//#define BB_DESCEND
|
||||
//#define BB_DF
|
||||
//#define BB_DMESG
|
||||
//#define BB_DUTMP
|
||||
//#define BB_DYADIC
|
||||
//#define BB_FALSE
|
||||
//#define BB_FDFLUSH
|
||||
//#define BB_FIND
|
||||
//#define BB_FINDMOUNT
|
||||
//#define BB_GREP
|
||||
////#define BB_HALT
|
||||
//#define BB_INIT
|
||||
//#define BB_KILL
|
||||
////#define BB_LENGTH
|
||||
//#define BB_LN
|
||||
//#define BB_LOADKMAP
|
||||
////#define BB_LOSETUP
|
||||
//#define BB_LS
|
||||
//#define BB_MAIN
|
||||
//#define BB_MAKEDEVS
|
||||
////#define BB_MATH
|
||||
//#define BB_MKDIR
|
||||
//#define BB_MKNOD
|
||||
////#define BB_MKSWAP
|
||||
//#define BB_MNC
|
||||
//#define BB_MONADIC
|
||||
//#define BB_MORE
|
||||
//#define BB_MOUNT
|
||||
////#define BB_MT
|
||||
//#define BB_MV
|
||||
//#define BB_POSTPROCESS
|
||||
//#define BB_PRINTF
|
||||
//#define BB_PWD
|
||||
//#define BB_REBOOT
|
||||
//#define BB_RM
|
||||
//#define BB_RMDIR
|
||||
//#define BB_SLEEP
|
||||
////#define BB_SWAPOFF
|
||||
//#define BB_SWAPON
|
||||
//#define BB_SYNC
|
||||
//#define BB_TAR
|
||||
//#define BB_TOUCH
|
||||
//#define BB_TRUE
|
||||
//#define BB_UMOUNT
|
||||
//#define BB_UPDATE
|
||||
//#define BB_UTILITY
|
||||
//#define BB_ZCAT
|
||||
//#define BB_GZIP
|
||||
@@ -0,0 +1,103 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Busybox main internal header file
|
||||
*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef _BB_INTERNAL_H_
|
||||
#define _BB_INTERNAL_H_ 1
|
||||
|
||||
#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 <features.h>
|
||||
|
||||
|
||||
enum Location {
|
||||
_BB_DIR_ROOT = 0,
|
||||
_BB_DIR_BIN,
|
||||
_BB_DIR_SBIN,
|
||||
_BB_DIR_USR_BIN,
|
||||
_BB_DIR_USR_SBIN
|
||||
};
|
||||
|
||||
struct BB_applet {
|
||||
const char* name;
|
||||
int (*main)(int argc, char** argv);
|
||||
enum Location location;
|
||||
};
|
||||
/* From busybox.c */
|
||||
extern const struct BB_applet applets[];
|
||||
|
||||
/* Automagically pull in all the applet function prototypes and
|
||||
* applet usage strings. These are all of the form:
|
||||
* extern int foo_main(int argc, char **argv);
|
||||
* extern const char foo_usage[];
|
||||
* These are all autogenerated from the set of currently defined applets.
|
||||
*/
|
||||
#define PROTOTYPES
|
||||
#include "applets.h"
|
||||
#undef PROTOTYPES
|
||||
|
||||
#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
|
||||
#endif
|
||||
|
||||
|
||||
/* Bit map related macros -- libc5 doens't provide these... sigh. */
|
||||
#ifndef setbit
|
||||
#define NBBY CHAR_BIT
|
||||
#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
|
||||
#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
|
||||
#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
|
||||
#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_ */
|
||||
+20
-13
@@ -1,17 +1,24 @@
|
||||
#!/bin/sh
|
||||
#Make busybox links list file
|
||||
# Make busybox links list file.
|
||||
|
||||
DF="busybox.def.h"
|
||||
MF="main.c"
|
||||
# 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
|
||||
|
||||
LIST="$(sed -n '/^#define/{s/^#define //p;}' $DF)"
|
||||
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
|
||||
for def in ${LIST}; do
|
||||
|
||||
set -- $(sed -n '/^#ifdef '$def'[ +| +].*/,/^#endif/{s/.*\/\///p; /^{ /{ s/^{ "//; s/",.*$//p;}; }' $MF)
|
||||
path=$1; shift
|
||||
|
||||
for n in $@; do
|
||||
echo "$path/$n"
|
||||
done
|
||||
done
|
||||
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/{
|
||||
dir=substr($2,8)
|
||||
gsub("_","/",dir)
|
||||
if(dir=="/ROOT") dir=""
|
||||
file=$3
|
||||
gsub("\"","",file)
|
||||
if (file=="busybox") next
|
||||
print tolower(dir) "/" file
|
||||
}'
|
||||
Executable
+16
@@ -0,0 +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 A-Z a-z | sort
|
||||
`
|
||||
test "${RAW}" != "" || exit
|
||||
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' ' '
|
||||
|
||||
+11
-18
@@ -1,5 +1,5 @@
|
||||
Name: busybox
|
||||
Version: 0.29alpha
|
||||
Version: 0.52
|
||||
Release: 1
|
||||
Group: System/Utilities
|
||||
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
|
||||
@@ -7,33 +7,26 @@ Copyright: GPL
|
||||
Packager : Erik Andersen <andersen@lineo.com>
|
||||
Conflicts: fileutils grep shellutils
|
||||
Buildroot: /tmp/%{Name}-%{Version}
|
||||
Source: busybox-0.29a1.tar.gz
|
||||
Source: %{Name}-%{Version}.tar.gz
|
||||
|
||||
%Description
|
||||
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
|
||||
provides a pretty complete environment that fits on a floppy or in a
|
||||
ROM. Just add "ash" (Keith Almquists tiny Bourne shell clone) and "ae",
|
||||
and a kernel and you have a full system. This is used on the Debian
|
||||
install disk and in an internet router, and it makes a good environment
|
||||
for a "rescue" disk or any small or embedded system.
|
||||
BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
small executable. It provides minimalist replacements for most of the utilities
|
||||
you usually find in fileutils, shellutils, findutils, textutils, grep, gzip,
|
||||
tar, etc. BusyBox provides a fairly complete POSIX environment for any small
|
||||
or emdedded system. The utilities in BusyBox generally have fewer options then
|
||||
their full featured GNU cousins; however, the options that are provided behave
|
||||
very much like their GNU counterparts.
|
||||
|
||||
%Prep
|
||||
%setup -q -n busybox
|
||||
%setup -q -n %{Name}-%{Version}
|
||||
|
||||
%Build
|
||||
make
|
||||
|
||||
%Install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
mkdir -p $RPM_BUILD_ROOT/bin
|
||||
h=`cat busybox.links`
|
||||
|
||||
for i in $h ; do
|
||||
mkdir -p $RPM_BUILD_ROOT/`echo $i | sed -e 's/\(^.*\/\)\(.*\)/\1/g' `
|
||||
(cd $RPM_BUILD_ROOT/bin ; ln -s ln `echo $i | sed -e 's/\(^.*\/\)\(.*\)/\2/g' ` );
|
||||
done
|
||||
rm -f $RPM_BUILD_ROOT/bin/ln
|
||||
install -m 755 busybox $RPM_BUILD_ROOT/bin/ln
|
||||
make PREFIX=$RPM_BUILD_ROOT install
|
||||
|
||||
%Clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#ifndef __BUSYBOX_FUNCTIONS_H__
|
||||
#define __BUSYBOX_FUNCTIONS_H__
|
||||
|
||||
int
|
||||
mkswap(char *device_name, int pages, int check);
|
||||
/* pages = 0 for autodetection */
|
||||
|
||||
int
|
||||
fdflush(char *filename);
|
||||
|
||||
#endif /* __BUSYBOX_FUNCTIONS_H__ */
|
||||
@@ -1,7 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini Cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1998 by Erik Andersen <andersee@debian.org>
|
||||
* 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
|
||||
@@ -19,36 +21,33 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char cat_usage[] = "[file ...]";
|
||||
|
||||
extern int cat_more_main(int argc, char **argv)
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
FILE *file = stdin;
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s %s", *argv, cat_usage);
|
||||
return 1;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
while (argc-- > 0) {
|
||||
file = fopen(*argv, "r");
|
||||
if (file == NULL) {
|
||||
name_and_error(*argv);
|
||||
return 1;
|
||||
if (argc == 1) {
|
||||
print_file(stdin);
|
||||
return status;
|
||||
}
|
||||
while ((c = getc(file)) != EOF)
|
||||
putc(c, stdout);
|
||||
fclose(file);
|
||||
fflush(stdout);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
return 0;
|
||||
while (--argc > 0) {
|
||||
if(!(strcmp(*++argv, "-"))) {
|
||||
print_file(stdin);
|
||||
} else if (print_file_by_name(*argv) == FALSE) {
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,7 +1,10 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chgrp implementation for busybox
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1998 by Erik Andersen <andersee@debian.org>
|
||||
*
|
||||
* 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
|
||||
@@ -19,71 +22,70 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <grp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char chgrp_usage[] = "chgrp [OPTION]... GROUP FILE...\n"
|
||||
"Change the group membership of each FILE to GROUP.\n"
|
||||
"\n\tOptions:\n" "\t-R\tchange files and directories recursively\n";
|
||||
/* 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)
|
||||
{
|
||||
const char *cp;
|
||||
int gid;
|
||||
struct group *grp;
|
||||
struct stat statBuf;
|
||||
int opt;
|
||||
int recursiveFlag = FALSE;
|
||||
char *p=NULL;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s %s", *argv, chgrp_usage);
|
||||
return 1;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
cp = argv[1];
|
||||
if (isDecimal(*cp)) {
|
||||
gid = 0;
|
||||
while (isDecimal(*cp))
|
||||
gid = gid * 10 + (*cp++ - '0');
|
||||
if (*cp) {
|
||||
fprintf(stderr, "Bad gid value\n");
|
||||
return -1;
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
grp = getgrnam(cp);
|
||||
if (grp == NULL) {
|
||||
fprintf(stderr, "Unknown group name\n");
|
||||
return -1;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
gid = grp->gr_gid;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc-- > 1) {
|
||||
argv++;
|
||||
if ((stat(*argv, &statBuf) < 0) ||
|
||||
(chown(*argv, statBuf.st_uid, gid) < 0)) {
|
||||
perror(*argv);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
int
|
||||
recursive(const char *fileName, BOOL followLinks, const char *pattern,
|
||||
int (*fileAction) (const char *fileName,
|
||||
const struct stat * statbuf),
|
||||
int (*dirAction) (const char *fileName,
|
||||
const struct stat * statbuf))
|
||||
|
||||
#endif
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,163 +1,85 @@
|
||||
#include <stdlib.h>
|
||||
/* 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 <sys/stat.h>
|
||||
#include "internal.h"
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char chmod_usage[] = "chmod [-R] mode file [file ...]\n"
|
||||
"\nmode may be an octal integer representing the bit pattern for the\n"
|
||||
"\tnew mode, or a symbolic value matching the pattern\n"
|
||||
"\t[ugoa]{+|-|=}[rwxst] .\n"
|
||||
"\t\tu:\tUser\n"
|
||||
"\t\tg:\tGroup\n"
|
||||
"\t\to:\tOthers\n"
|
||||
"\t\ta:\tAll\n"
|
||||
"\n"
|
||||
"\n+:\tAdd privilege\n"
|
||||
"\n-:\tRemove privilege\n"
|
||||
"\n=:\tSet privilege\n"
|
||||
"\n"
|
||||
"\t\tr:\tRead\n"
|
||||
"\t\tw:\tWrite\n"
|
||||
"\t\tx:\tExecute\n"
|
||||
"\t\ts:\tSet User ID\n"
|
||||
"\t\tt:\t\"Sticky\" Text\n"
|
||||
"\n"
|
||||
"\tModes may be concatenated, as in \"u=rwx,g=rx,o=rx,-t,-s\n"
|
||||
"\n"
|
||||
"\t-R:\tRecursively change the mode of all files and directories\n"
|
||||
"\t\tunder the argument directory.";
|
||||
|
||||
int
|
||||
parse_mode(
|
||||
const char * s
|
||||
,mode_t * or
|
||||
,mode_t * and
|
||||
,int * group_execute)
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
/* [ugoa]{+|-|=}[rwxstl] */
|
||||
mode_t mode = 0;
|
||||
mode_t groups = S_ISVTX;
|
||||
char type;
|
||||
char c;
|
||||
|
||||
do {
|
||||
for ( ; ; ) {
|
||||
switch ( c = *s++ ) {
|
||||
case '\0':
|
||||
return -1;
|
||||
case 'u':
|
||||
groups |= S_ISUID|S_IRWXU;
|
||||
continue;
|
||||
case 'g':
|
||||
groups |= S_ISGID|S_IRWXG;
|
||||
continue;
|
||||
case 'o':
|
||||
groups |= S_IRWXO;
|
||||
continue;
|
||||
case 'a':
|
||||
groups |= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
|
||||
continue;
|
||||
case '+':
|
||||
case '=':
|
||||
case '-':
|
||||
type = c;
|
||||
if ( groups == S_ISVTX ) /* The default is "all" */
|
||||
groups |= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
|
||||
break;
|
||||
default:
|
||||
if ( c >= '0' && c <= '7' && mode == 0 && groups == S_ISVTX ) {
|
||||
*and = 0;
|
||||
*or = strtol(--s, 0, 010);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
while ( (c = *s++) != '\0' ) {
|
||||
switch ( c ) {
|
||||
case ',':
|
||||
break;
|
||||
case 'r':
|
||||
mode |= S_IRUSR|S_IRGRP|S_IROTH;
|
||||
continue;
|
||||
case 'w':
|
||||
mode |= S_IWUSR|S_IWGRP|S_IWOTH;
|
||||
continue;
|
||||
case 'x':
|
||||
mode |= S_IXUSR|S_IXGRP|S_IXOTH;
|
||||
continue;
|
||||
case 's':
|
||||
if ( group_execute != 0 && (groups & S_IRWXG) ) {
|
||||
if ( *group_execute < 0 )
|
||||
return -1;
|
||||
if ( type != '-' ) {
|
||||
mode |= S_IXGRP;
|
||||
*group_execute = 1;
|
||||
}
|
||||
}
|
||||
mode |= S_ISUID|S_ISGID;
|
||||
continue;
|
||||
case 'l':
|
||||
if ( *group_execute > 0 )
|
||||
return -1;
|
||||
if ( type != '-' ) {
|
||||
*and &= ~S_IXGRP;
|
||||
*group_execute = -1;
|
||||
}
|
||||
mode |= S_ISGID;
|
||||
groups |= S_ISGID;
|
||||
continue;
|
||||
case 't':
|
||||
mode |= S_ISVTX;
|
||||
continue;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch ( type ) {
|
||||
case '=':
|
||||
*and &= ~(groups);
|
||||
/* fall through */
|
||||
case '+':
|
||||
*or |= mode & groups;
|
||||
break;
|
||||
case '-':
|
||||
*and &= ~(mode & groups);
|
||||
*or &= *and;
|
||||
break;
|
||||
}
|
||||
} while ( c == ',' );
|
||||
return 0;
|
||||
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);
|
||||
}
|
||||
|
||||
extern int
|
||||
chmod_main(struct FileInfo * i, int argc, char * * argv)
|
||||
int chmod_main(int argc, char **argv)
|
||||
{
|
||||
i->andWithMode = S_ISVTX|S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
|
||||
i->orWithMode = 0;
|
||||
int i;
|
||||
int opt;
|
||||
int recursiveFlag = FALSE;
|
||||
|
||||
while ( argc >= 3 ) {
|
||||
if ( parse_mode(argv[1], &i->orWithMode, &i->andWithMode, 0)
|
||||
== 0 ) {
|
||||
argc--;
|
||||
argv++;
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
else if ( strcmp(argv[1], "-R") == 0 ) {
|
||||
i->recursive = 1;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
i->changeMode = 1;
|
||||
i->complainInPostProcess = 1;
|
||||
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);
|
||||
}
|
||||
|
||||
return monadic_main(i, argc, argv);
|
||||
/* 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,63 +1,113 @@
|
||||
#include "internal.h"
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <string.h>
|
||||
/* 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"
|
||||
|
||||
const char chown_usage[] = "chown [-R] user-name file [file ...]\n"
|
||||
"\n\tThe group list is kept in the file /etc/groups.\n\n"
|
||||
"\t-R:\tRecursively change the mode of all files and directories\n"
|
||||
"\t\tunder the argument directory.";
|
||||
/* Don't use lchown for libc5 or glibc older then 2.1.x */
|
||||
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
|
||||
#define lchown chown
|
||||
#endif
|
||||
|
||||
int
|
||||
parse_user_name(const char * s, struct FileInfo * i)
|
||||
static long uid;
|
||||
static long gid;
|
||||
|
||||
static int (*chown_func)() = chown;
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
struct passwd * p;
|
||||
char * dot = strchr(s, '.');
|
||||
|
||||
if (! dot )
|
||||
dot = strchr(s, ':');
|
||||
|
||||
if ( dot )
|
||||
*dot = '\0';
|
||||
|
||||
if ( (p = getpwnam(s)) == 0 ) {
|
||||
fprintf(stderr, "%s: no such user.\n", s);
|
||||
return 1;
|
||||
if (chown_func(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
i->userID = p->pw_uid;
|
||||
perror(fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if ( dot ) {
|
||||
struct group * g = getgrnam(++dot);
|
||||
if ( g == 0 ) {
|
||||
fprintf(stderr, "%s: no such group.\n", dot);
|
||||
return 1;
|
||||
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();
|
||||
}
|
||||
i->groupID = g->gr_gid;
|
||||
i->changeGroupID = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int
|
||||
chown_main(struct FileInfo * i, int argc, char * * argv)
|
||||
{
|
||||
int status;
|
||||
|
||||
while ( argc >= 3 && strcmp("-R", argv[1]) == 0 ) {
|
||||
i->recursive = 1;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if ( (status = parse_user_name(argv[1], i)) != 0 )
|
||||
return status;
|
||||
if (noderefFlag) chown_func = lchown;
|
||||
|
||||
argv++;
|
||||
argc--;
|
||||
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);
|
||||
}
|
||||
|
||||
i->changeUserID = 1;
|
||||
i->complainInPostProcess = 1;
|
||||
/* 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;
|
||||
|
||||
return monadic_main(i, argc, argv);
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,32 +1,75 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chroot 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
const char chroot_usage[] = "chroot directory [command]\n"
|
||||
"Run a command with special root directory.\n";
|
||||
|
||||
extern int
|
||||
chroot_main (struct FileInfo *i, int argc, char **argv)
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
char *prog;
|
||||
char *prog;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc >= 1) {
|
||||
prog = *argv;
|
||||
execvp(*argv, argv);
|
||||
} else {
|
||||
#ifndef BB_SH
|
||||
prog = getenv("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp(prog, prog, NULL);
|
||||
#else
|
||||
char shell[] = "/bin/sh";
|
||||
char *shell_argv[2] = { shell, NULL };
|
||||
applet_name = shell;
|
||||
shell_main(1, shell_argv);
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
if (chroot (argv[1]))
|
||||
{
|
||||
name_and_error ("cannot chroot to that directory");
|
||||
return 1;
|
||||
}
|
||||
if (argc > 2)
|
||||
{
|
||||
execvp (argv[2], argv + 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
prog = getenv ("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp (prog, prog, NULL);
|
||||
}
|
||||
name_and_error ("cannot exec");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,43 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* chvt.c - aeb - 940227 - Change virtual terminal
|
||||
*
|
||||
* busyboxed by Erik Andersen
|
||||
*/
|
||||
|
||||
/* 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> */
|
||||
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) == '-'))
|
||||
show_usage();
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,13 +1,34 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini clear 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 "busybox.h"
|
||||
|
||||
const char clear_usage[] = "clear\n"
|
||||
"\n"
|
||||
"\tClears the screen.\n";
|
||||
|
||||
extern int
|
||||
clear_main(struct FileInfo * i, int argc, char * * argv)
|
||||
extern int clear_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033[H\033[J");
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef CMDEDIT_H
|
||||
#define CMDEDIT_H
|
||||
|
||||
void cmdedit_init(void);
|
||||
void cmdedit_terminate(void);
|
||||
void cmdedit_read_input(char* promptStr, char* command); /* read a line of input */
|
||||
|
||||
#endif /* CMDEDIT_H */
|
||||
@@ -0,0 +1,80 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* 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 <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, *filename2 = "-";
|
||||
int c, c1, c2, char_pos = 1, line_pos = 1, silent = FALSE;
|
||||
|
||||
while ((c = getopt(argc, argv, "s")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
silent = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
printf("EOF on %s\n", filename2);
|
||||
else
|
||||
printf("%s %s differ: char %d, line %d\n", filename1, filename2,
|
||||
char_pos, line_pos);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char_pos++;
|
||||
if (c1 == '\n')
|
||||
line_pos++;
|
||||
} while (c1 != EOF);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* chvt.c - aeb - 940227 - Change virtual terminal
|
||||
*
|
||||
* busyboxed by Erik Andersen
|
||||
*/
|
||||
|
||||
/* 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> */
|
||||
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) == '-'))
|
||||
show_usage();
|
||||
fd = get_console_fd("/dev/console");
|
||||
num = atoi(argv[1]);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
+28
-7
@@ -1,13 +1,34 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini clear 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 "busybox.h"
|
||||
|
||||
const char clear_usage[] = "clear\n"
|
||||
"\n"
|
||||
"\tClears the screen.\n";
|
||||
|
||||
extern int
|
||||
clear_main(struct FileInfo * i, int argc, char * * argv)
|
||||
extern int clear_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033[H\033[J");
|
||||
return 0;
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* disalloc.c - aeb - 940501 - Disallocate virtual terminal(s)
|
||||
* Renamed deallocvt.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* From <linux/vt.h> */
|
||||
static const int VT_DISALLOCATE = 0x5608; /* free memory associated to vt */
|
||||
|
||||
int deallocvt_main(int argc, char *argv[])
|
||||
{
|
||||
int fd, num, i;
|
||||
|
||||
//if ((argc > 2) || ((argv == 2) && (**(argv + 1) == '-')))
|
||||
if (argc > 2)
|
||||
show_usage();
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
|
||||
if (argc == 1) {
|
||||
/* deallocate all unused consoles */
|
||||
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");
|
||||
else if (num == 1)
|
||||
error_msg("VT 1 cannot be deallocated");
|
||||
else if (ioctl(fd, VT_DISALLOCATE, num))
|
||||
perror_msg_and_die("VT_DISALLOCATE");
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini dumpkmap implementation for busybox
|
||||
*
|
||||
* Copyright (C) Arne Bernin <arne@matrix.loopback.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 <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 {
|
||||
unsigned char kb_table;
|
||||
unsigned char kb_index;
|
||||
unsigned short kb_value;
|
||||
};
|
||||
static const int KDGKBENT = 0x4B46; /* gets one entry in translation table */
|
||||
|
||||
/* From <linux/keyboard.h> */
|
||||
static const int NR_KEYS = 128;
|
||||
static const int MAX_NR_KEYMAPS = 256;
|
||||
|
||||
int dumpkmap_main(int argc, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
int i, j, fd;
|
||||
char flags[MAX_NR_KEYMAPS], magic[] = "bkeymap";
|
||||
|
||||
if (argc>=2 && *argv[1]=='-') {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror_msg("Error opening /dev/tty0");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
write(1, magic, 7);
|
||||
|
||||
for (i=0; i < MAX_NR_KEYMAPS; i++) flags[i]=0;
|
||||
flags[0]=1;
|
||||
flags[1]=1;
|
||||
flags[2]=1;
|
||||
flags[4]=1;
|
||||
flags[5]=1;
|
||||
flags[6]=1;
|
||||
flags[8]=1;
|
||||
flags[9]=1;
|
||||
flags[10]=1;
|
||||
flags[12]=1;
|
||||
|
||||
/* dump flags */
|
||||
for (i=0; i < MAX_NR_KEYMAPS; i++) write(1,&flags[i],1);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
if (ioctl(fd, KDGKBENT, &ke) < 0) {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,357 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Derived from
|
||||
* mapscrn.c - version 0.92
|
||||
*
|
||||
* Was taken from console-tools and adapted by
|
||||
* Peter Novodvorsky <petya@logic.ru>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <memory.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/kd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
typedef unsigned short unicode;
|
||||
|
||||
static long int ctoi(unsigned char *s, int *is_unicode);
|
||||
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]=='-') {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = open("/dev/tty", O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror_msg_and_die("Error opening /dev/tty1");
|
||||
}
|
||||
|
||||
if (screen_map_load(fd, stdin)) {
|
||||
perror_msg_and_die("Error loading acm");
|
||||
}
|
||||
|
||||
write(fd, "\033(K", 3);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static int screen_map_load(int fd, FILE * fp)
|
||||
{
|
||||
struct stat stbuf;
|
||||
unicode wbuf[E_TABSZ];
|
||||
unsigned char buf[E_TABSZ];
|
||||
int parse_failed = 0;
|
||||
int is_unicode;
|
||||
|
||||
if (fstat(fileno(fp), &stbuf))
|
||||
perror_msg_and_die("Cannot stat map file");
|
||||
|
||||
/* first try a UTF screen-map: either ASCII (no restriction) or binary (regular file) */
|
||||
if (!
|
||||
(parse_failed =
|
||||
(-1 == uni_screen_map_read_ascii(fp, wbuf, &is_unicode)))
|
||||
|| (S_ISREG(stbuf.st_mode) && (stbuf.st_size == (sizeof(unicode) * E_TABSZ)))) { /* test for binary UTF map by size */
|
||||
if (parse_failed) {
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
error_msg_and_die("16bit screen-map MUST be a regular file.");
|
||||
else
|
||||
perror_msg_and_die("fseek failed reading binary 16bit screen-map");
|
||||
}
|
||||
|
||||
if (fread(wbuf, sizeof(unicode) * E_TABSZ, 1, fp) != 1)
|
||||
perror_msg_and_die("Cannot read [new] map from file");
|
||||
#if 0
|
||||
else
|
||||
error_msg("Input screen-map is binary.");
|
||||
#endif
|
||||
}
|
||||
|
||||
/* if it was effectively a 16-bit ASCII, OK, else try to read as 8-bit map */
|
||||
/* same if it was binary, ie. if parse_failed */
|
||||
if (parse_failed || is_unicode) {
|
||||
if (ioctl(fd, PIO_UNISCRNMAP, wbuf))
|
||||
perror_msg_and_die("PIO_UNISCRNMAP ioctl");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* rewind... */
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
error_msg("Assuming 8bit screen-map - MUST be a regular file."),
|
||||
exit(1);
|
||||
else
|
||||
perror_msg_and_die("fseek failed assuming 8bit screen-map");
|
||||
}
|
||||
|
||||
/* ... and try an old 8-bit screen-map */
|
||||
if (!(parse_failed = (-1 == old_screen_map_read_ascii(fp, buf))) ||
|
||||
(S_ISREG(stbuf.st_mode) && (stbuf.st_size == E_TABSZ))) { /* test for binary old 8-bit map by size */
|
||||
if (parse_failed) {
|
||||
if (-1 == fseek(fp, 0, SEEK_SET)) {
|
||||
if (errno == ESPIPE)
|
||||
/* should not - it succedeed above */
|
||||
error_msg_and_die("fseek() returned ESPIPE !");
|
||||
else
|
||||
perror_msg_and_die("fseek for binary 8bit screen-map");
|
||||
}
|
||||
|
||||
if (fread(buf, E_TABSZ, 1, fp) != 1)
|
||||
perror_msg_and_die("Cannot read [old] map from file");
|
||||
#if 0
|
||||
else
|
||||
error_msg("Input screen-map is binary.");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ioctl(fd, PIO_SCRNMAP, buf))
|
||||
perror_msg_and_die("PIO_SCRNMAP ioctl");
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
error_msg("Error parsing symbolic map");
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* - reads `fp' as a 16-bit ASCII SFM file.
|
||||
* - returns -1 on error.
|
||||
* - returns it in `unicode' in an E_TABSZ-elements array.
|
||||
* - sets `*is_unicode' flagiff there were any non-8-bit
|
||||
* (ie. real 16-bit) mapping.
|
||||
*
|
||||
* FIXME: ignores everything after second word
|
||||
*/
|
||||
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 */
|
||||
int in, on; /* the same, as numbers */
|
||||
int tmp_is_unicode; /* tmp for is_unicode calculation */
|
||||
int i; /* loop index - result holder */
|
||||
int ret_code = 0; /* return code */
|
||||
sigset_t acmsigset, old_sigset;
|
||||
|
||||
assert(is_unicode);
|
||||
|
||||
*is_unicode = 0;
|
||||
|
||||
/* first 128 codes defaults to ASCII */
|
||||
for (i = 0; i < 128; i++)
|
||||
buf[i] = i;
|
||||
/* remaining defaults to replacement char (usually E_TABSZ = 256) */
|
||||
for (; i < E_TABSZ; i++)
|
||||
buf[i] = 0xfffd;
|
||||
|
||||
/* block SIGCHLD */
|
||||
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_msg_and_die("uni_screen_map_read_ascii() can't read line");
|
||||
}
|
||||
|
||||
/* get "charset-relative charcode", stripping leading spaces */
|
||||
p = strtok(buffer, " \t\n");
|
||||
|
||||
/* skip empty lines and comments */
|
||||
if (!p || *p == '#')
|
||||
continue;
|
||||
|
||||
/* get unicode mapping */
|
||||
q = strtok(NULL, " \t\n");
|
||||
if (q) {
|
||||
in = ctoi(p, NULL);
|
||||
if (in < 0 || in > 255) {
|
||||
ret_code = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
on = ctoi(q, &tmp_is_unicode);
|
||||
if (in < 0 && on > 65535) {
|
||||
ret_code = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
*is_unicode |= tmp_is_unicode;
|
||||
buf[in] = on;
|
||||
} else {
|
||||
ret_code = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (1); /* terminated by break on feof() */
|
||||
|
||||
/* restore sig mask */
|
||||
sigprocmask(SIG_SETMASK, &old_sigset, NULL);
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
|
||||
static int old_screen_map_read_ascii(FILE * fp, unsigned char buf[])
|
||||
{
|
||||
char buffer[256];
|
||||
int in, on;
|
||||
char *p, *q;
|
||||
|
||||
for (in = 0; in < 256; in++)
|
||||
buf[in] = in;
|
||||
|
||||
while (fgets(buffer, sizeof(buffer) - 1, fp)) {
|
||||
p = strtok(buffer, " \t\n");
|
||||
|
||||
if (!p || *p == '#')
|
||||
continue;
|
||||
|
||||
q = strtok(NULL, " \t\n#");
|
||||
if (q) {
|
||||
in = ctoi(p, NULL);
|
||||
if (in < 0 || in > 255)
|
||||
return -1;
|
||||
|
||||
on = ctoi(q, NULL);
|
||||
if (in < 0 && on > 255)
|
||||
return -1;
|
||||
|
||||
buf[in] = on;
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* - converts a string into an int.
|
||||
* - supports dec and hex bytes, hex UCS2, single-quoted byte and UTF8 chars.
|
||||
* - returns the converted value
|
||||
* - if `is_unicode != NULL', use it to tell whether it was unicode
|
||||
*
|
||||
* CAVEAT: will report valid UTF mappings using only 1 byte as 8-bit ones.
|
||||
*/
|
||||
static long int ctoi(unsigned char *s, int *is_unicode)
|
||||
{
|
||||
int i;
|
||||
size_t ls;
|
||||
|
||||
ls = strlen(s);
|
||||
if (is_unicode)
|
||||
*is_unicode = 0;
|
||||
|
||||
/* hex-specified UCS2 */
|
||||
if ((strncmp(s, "U+", 2) == 0) &&
|
||||
(strspn(s + 2, "0123456789abcdefABCDEF") == ls - 2)) {
|
||||
sscanf(s + 2, "%x", &i);
|
||||
if (is_unicode)
|
||||
*is_unicode = 1;
|
||||
}
|
||||
|
||||
/* hex-specified byte */
|
||||
else if ((ls <= 4) && (strncmp(s, "0x", 2) == 0) &&
|
||||
(strspn(s + 2, "0123456789abcdefABCDEF") == ls - 2))
|
||||
sscanf(s + 2, "%x", &i);
|
||||
|
||||
/* oct-specified number (byte) */
|
||||
else if ((*s == '0') && (strspn(s, "01234567") == ls))
|
||||
sscanf(s, "%o", &i);
|
||||
|
||||
/* dec-specified number (byte) */
|
||||
else if (strspn(s, "0123456789") == ls)
|
||||
sscanf(s, "%d", &i);
|
||||
|
||||
/* single-byte quoted char */
|
||||
else if ((strlen(s) == 3) && (s[0] == '\'') && (s[2] == '\''))
|
||||
i = s[1];
|
||||
|
||||
/* multi-byte UTF8 quoted char */
|
||||
else if ((s[0] == '\'') && (s[ls - 1] == '\'')) {
|
||||
s[ls - 1] = 0; /* ensure we'll not "parse UTF too far" */
|
||||
i = utf8_to_ucs2(s + 1);
|
||||
if (is_unicode)
|
||||
*is_unicode = 1;
|
||||
} else
|
||||
return (-1);
|
||||
|
||||
return (i);
|
||||
}
|
||||
|
||||
|
||||
static unicode utf8_to_ucs2(char *buf)
|
||||
{
|
||||
int utf_count = 0;
|
||||
long utf_char = 0;
|
||||
unicode tc = 0;
|
||||
unsigned char c;
|
||||
|
||||
do {
|
||||
c = *buf;
|
||||
buf++;
|
||||
|
||||
/* if byte should be part of multi-byte sequence */
|
||||
if (c & 0x80) {
|
||||
/* if we have already started to parse a UTF8 sequence */
|
||||
if (utf_count > 0 && (c & 0xc0) == 0x80) {
|
||||
utf_char = (utf_char << 6) | (c & 0x3f);
|
||||
utf_count--;
|
||||
if (utf_count == 0)
|
||||
tc = utf_char;
|
||||
else
|
||||
continue;
|
||||
} else { /* Possibly 1st char of a UTF8 sequence */
|
||||
|
||||
if ((c & 0xe0) == 0xc0) {
|
||||
utf_count = 1;
|
||||
utf_char = (c & 0x1f);
|
||||
} else if ((c & 0xf0) == 0xe0) {
|
||||
utf_count = 2;
|
||||
utf_char = (c & 0x0f);
|
||||
} else if ((c & 0xf8) == 0xf0) {
|
||||
utf_count = 3;
|
||||
utf_char = (c & 0x07);
|
||||
} else if ((c & 0xfc) == 0xf8) {
|
||||
utf_count = 4;
|
||||
utf_char = (c & 0x03);
|
||||
} else if ((c & 0xfe) == 0xfc) {
|
||||
utf_count = 5;
|
||||
utf_char = (c & 0x01);
|
||||
} else
|
||||
utf_count = 0;
|
||||
continue;
|
||||
}
|
||||
} else { /* not part of multi-byte sequence - treat as ASCII
|
||||
* this makes incomplete sequences to be ignored
|
||||
*/
|
||||
tc = c;
|
||||
utf_count = 0;
|
||||
}
|
||||
}
|
||||
while (utf_count);
|
||||
|
||||
return tc;
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* loadfont.c - Eugene Crosser & Andries Brouwer
|
||||
*
|
||||
* Version 0.96bb
|
||||
*
|
||||
* Loads the console font, and possibly the corresponding screen map(s).
|
||||
* (Adapted for busybox by Matej Vela.)
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <memory.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/kd.h>
|
||||
#include <endian.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static const int PSF_MAGIC1 = 0x36;
|
||||
static const int PSF_MAGIC2 = 0x04;
|
||||
|
||||
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 */
|
||||
unsigned char mode; /* PSF font mode */
|
||||
unsigned char charsize; /* Character size */
|
||||
};
|
||||
|
||||
#define PSF_MAGIC_OK(x) ((x).magic1 == PSF_MAGIC1 && (x).magic2 == PSF_MAGIC2)
|
||||
|
||||
static void loadnewfont(int fd);
|
||||
|
||||
extern int loadfont_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
|
||||
if (argc != 1)
|
||||
show_usage();
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0)
|
||||
perror_msg_and_die("Error opening /dev/tty0");
|
||||
loadnewfont(fd);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void do_loadfont(int fd, char *inbuf, int unit, int fontsize)
|
||||
{
|
||||
char buf[16384];
|
||||
int i;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
if (unit < 1 || unit > 32)
|
||||
error_msg_and_die("Bad character size %d", unit);
|
||||
|
||||
for (i = 0; i < fontsize; i++)
|
||||
memcpy(buf + (32 * i), inbuf + (unit * i), unit);
|
||||
|
||||
#if defined( PIO_FONTX ) && !defined( __sparc__ )
|
||||
{
|
||||
struct consolefontdesc cfd;
|
||||
|
||||
cfd.charcount = fontsize;
|
||||
cfd.charheight = unit;
|
||||
cfd.chardata = buf;
|
||||
|
||||
if (ioctl(fd, PIO_FONTX, &cfd) == 0)
|
||||
return; /* success */
|
||||
perror_msg("PIO_FONTX ioctl error (trying PIO_FONT)");
|
||||
}
|
||||
#endif
|
||||
if (ioctl(fd, PIO_FONT, buf))
|
||||
perror_msg_and_die("PIO_FONT ioctl error");
|
||||
}
|
||||
|
||||
static void
|
||||
do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
|
||||
{
|
||||
struct unimapinit advice;
|
||||
struct unimapdesc ud;
|
||||
struct unipair *up;
|
||||
int ct = 0, maxct;
|
||||
int glyph;
|
||||
u_short unicode;
|
||||
|
||||
maxct = tailsz; /* more than enough */
|
||||
up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
|
||||
|
||||
for (glyph = 0; glyph < fontsize; glyph++) {
|
||||
while (tailsz >= 2) {
|
||||
unicode = (((u_short) inbuf[1]) << 8) + inbuf[0];
|
||||
tailsz -= 2;
|
||||
inbuf += 2;
|
||||
if (unicode == PSF_SEPARATOR)
|
||||
break;
|
||||
up[ct].unicode = unicode;
|
||||
up[ct].fontpos = glyph;
|
||||
ct++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Note: after PIO_UNIMAPCLR and before PIO_UNIMAP
|
||||
this printf did not work on many kernels */
|
||||
|
||||
advice.advised_hashsize = 0;
|
||||
advice.advised_hashstep = 0;
|
||||
advice.advised_hashlevel = 0;
|
||||
if (ioctl(fd, PIO_UNIMAPCLR, &advice)) {
|
||||
#ifdef ENOIOCTLCMD
|
||||
if (errno == ENOIOCTLCMD) {
|
||||
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");
|
||||
}
|
||||
ud.entry_ct = ct;
|
||||
ud.entries = up;
|
||||
if (ioctl(fd, PIO_UNIMAP, &ud)) {
|
||||
#if 0
|
||||
if (errno == ENOMEM) {
|
||||
/* change advice parameters */
|
||||
}
|
||||
#endif
|
||||
perror_msg_and_die("PIO_UNIMAP");
|
||||
}
|
||||
}
|
||||
|
||||
static void loadnewfont(int fd)
|
||||
{
|
||||
int unit;
|
||||
char inbuf[32768]; /* primitive */
|
||||
unsigned int inputlth, offset;
|
||||
|
||||
/*
|
||||
* We used to look at the length of the input file
|
||||
* with stat(); now that we accept compressed files,
|
||||
* just read the entire file.
|
||||
*/
|
||||
inputlth = fread(inbuf, 1, sizeof(inbuf), stdin);
|
||||
if (ferror(stdin))
|
||||
perror_msg_and_die("Error reading input font");
|
||||
/* use malloc/realloc in case of giant files;
|
||||
maybe these do not occur: 16kB for the font,
|
||||
and 16kB for the map leaves 32 unicode values
|
||||
for each font position */
|
||||
if (!feof(stdin))
|
||||
perror_msg_and_die("Font too large");
|
||||
|
||||
/* test for psf first */
|
||||
{
|
||||
struct psf_header psfhdr;
|
||||
int fontsize;
|
||||
int hastable;
|
||||
unsigned int head0, head;
|
||||
|
||||
if (inputlth < sizeof(struct psf_header))
|
||||
goto no_psf;
|
||||
|
||||
psfhdr = *(struct psf_header *) &inbuf[0];
|
||||
|
||||
if (!PSF_MAGIC_OK(psfhdr))
|
||||
goto no_psf;
|
||||
|
||||
if (psfhdr.mode > PSF_MAXMODE)
|
||||
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");
|
||||
#endif
|
||||
hastable = (psfhdr.mode & PSF_MODEHASTAB);
|
||||
unit = psfhdr.charsize;
|
||||
head0 = sizeof(struct psf_header);
|
||||
|
||||
head = head0 + fontsize * unit;
|
||||
if (head > inputlth || (!hastable && head != inputlth))
|
||||
error_msg_and_die("Input file: bad length");
|
||||
do_loadfont(fd, inbuf + head0, unit, fontsize);
|
||||
if (hastable)
|
||||
do_loadtable(fd, inbuf + head, inputlth - head, fontsize);
|
||||
return;
|
||||
}
|
||||
no_psf:
|
||||
|
||||
/* file with three code pages? */
|
||||
if (inputlth == 9780) {
|
||||
offset = 40;
|
||||
unit = 16;
|
||||
} else {
|
||||
/* bare font */
|
||||
if (inputlth & 0377)
|
||||
error_msg_and_die("Bad input file size");
|
||||
offset = 0;
|
||||
unit = inputlth / 256;
|
||||
}
|
||||
do_loadfont(fd, inbuf + offset, unit, 256);
|
||||
}
|
||||
+75
-54
@@ -1,68 +1,89 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini loadkmap implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1998 Enrique Zanardi <ezanardi@ull.es>
|
||||
*
|
||||
* 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 <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/kd.h>
|
||||
#include <linux/keyboard.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#define BINARY_KEYMAP_MAGIC "bkeymap"
|
||||
|
||||
const char loadkmap_usage[] = "loadkmap\n"
|
||||
"\n"
|
||||
"\tLoad a binary keyboard translation table from standard input.\n"
|
||||
"\n";
|
||||
/* From <linux/kd.h> */
|
||||
struct kbentry {
|
||||
unsigned char kb_table;
|
||||
unsigned char kb_index;
|
||||
unsigned short kb_value;
|
||||
};
|
||||
static const int KDSKBENT = 0x4B47; /* sets one entry in translation table */
|
||||
|
||||
/* From <linux/keyboard.h> */
|
||||
static const int NR_KEYS = 128;
|
||||
static const int MAX_NR_KEYMAPS = 256;
|
||||
|
||||
int
|
||||
loadkmap_main(struct FileInfo * info, int argc, char * * argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
u_short *ibuff;
|
||||
int i,j,fd,readsz,pos,ibuffsz=NR_KEYS * sizeof(u_short);
|
||||
char flags[MAX_NR_KEYMAPS],magic[]="bkeymap",buff[7];
|
||||
int loadkmap_main(int argc, char **argv)
|
||||
{
|
||||
struct kbentry ke;
|
||||
u_short *ibuff;
|
||||
int i, j, fd, readsz, pos, ibuffsz = NR_KEYS * sizeof(u_short);
|
||||
char flags[MAX_NR_KEYMAPS], buff[7];
|
||||
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "Error opening /dev/tty0: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
if (argc != 1)
|
||||
show_usage();
|
||||
|
||||
read(0,buff,7);
|
||||
if (0 != strncmp(buff,magic,7)) {
|
||||
fprintf(stderr, "This is not a valid binary keymap.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( MAX_NR_KEYMAPS != read(0,flags,MAX_NR_KEYMAPS) ) {
|
||||
fprintf(stderr, "Error reading keymap flags: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
fd = open("/dev/tty0", O_RDWR);
|
||||
if (fd < 0)
|
||||
perror_msg_and_die("Error opening /dev/tty0");
|
||||
|
||||
ibuff=(u_short *) malloc(ibuffsz);
|
||||
if (!ibuff) {
|
||||
fprintf(stderr, "Out of memory.\n");
|
||||
return 1;
|
||||
}
|
||||
read(0, buff, 7);
|
||||
if (0 != strncmp(buff, BINARY_KEYMAP_MAGIC, 7))
|
||||
error_msg_and_die("This is not a valid binary keymap.");
|
||||
|
||||
for(i=0; i<MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i]==1){
|
||||
pos=0;
|
||||
while (pos < ibuffsz) {
|
||||
if ( (readsz = read(0,ibuff+pos,ibuffsz-pos)) < 0 ) {
|
||||
fprintf(stderr, "Error reading keymap: %s\n",
|
||||
strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
pos += readsz;
|
||||
}
|
||||
for(j=0; j<NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
ke.kb_value = ibuff[j];
|
||||
ioctl(fd, KDSKBENT, &ke);
|
||||
}
|
||||
if (MAX_NR_KEYMAPS != read(0, flags, MAX_NR_KEYMAPS))
|
||||
perror_msg_and_die("Error reading keymap flags");
|
||||
|
||||
ibuff = (u_short *) xmalloc(ibuffsz);
|
||||
|
||||
for (i = 0; i < MAX_NR_KEYMAPS; i++) {
|
||||
if (flags[i] == 1) {
|
||||
pos = 0;
|
||||
while (pos < ibuffsz) {
|
||||
if ((readsz = read(0, (char *) ibuff + pos, ibuffsz - pos)) < 0)
|
||||
perror_msg_and_die("Error reading keymap");
|
||||
pos += readsz;
|
||||
}
|
||||
for (j = 0; j < NR_KEYS; j++) {
|
||||
ke.kb_index = j;
|
||||
ke.kb_table = i;
|
||||
ke.kb_value = ibuff[j];
|
||||
ioctl(fd, KDSKBENT, &ke);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
close (fd);
|
||||
return 0;
|
||||
/* Don't bother to close files. Exit does that
|
||||
* automagically, so we can save a few bytes */
|
||||
/* close(fd); */
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini reset implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1999,2000,2001 by Lineo, inc.
|
||||
* Written by Erik Andersen <andersen@lineo.com>, <andersee@debian.org>
|
||||
* and Kent Robotti <robotti@metconnect.com>
|
||||
*
|
||||
* 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 "busybox.h"
|
||||
|
||||
extern int reset_main(int argc, char **argv)
|
||||
{
|
||||
printf("\033c");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* setkeycodes
|
||||
*
|
||||
* Copyright (C) 1994-1998 Andries E. Brouwer <aeb@cwi.nl>
|
||||
*
|
||||
* Adjusted for BusyBox by 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
|
||||
* 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 <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* From <linux/kd.h> */
|
||||
struct kbkeycode {
|
||||
unsigned int scancode, keycode;
|
||||
};
|
||||
static const int KDSETKEYCODE = 0x4B4D; /* write kernel keycode table entry */
|
||||
|
||||
extern int
|
||||
setkeycodes_main(int argc, char** argv)
|
||||
{
|
||||
char *ep;
|
||||
int fd, sc;
|
||||
struct kbkeycode a;
|
||||
|
||||
if (argc % 2 != 1 || argc < 2) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
fd = get_console_fd("/dev/console");
|
||||
|
||||
while (argc > 2) {
|
||||
a.keycode = atoi(argv[2]);
|
||||
a.scancode = sc = strtol(argv[1], &ep, 16);
|
||||
if (*ep) {
|
||||
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");
|
||||
}
|
||||
if (ioctl(fd,KDSETKEYCODE,&a)) {
|
||||
perror("KDSETKEYCODE");
|
||||
error_msg_and_die("failed to set SCANCODE %x to KEYCODE %d", sc, a.keycode);
|
||||
}
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini basename 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
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
#include <string.h>
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
int m, n;
|
||||
char *s;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
argv++;
|
||||
|
||||
s = get_last_path_component(*argv);
|
||||
|
||||
if (argc>2) {
|
||||
argv++;
|
||||
n = strlen(*argv);
|
||||
m = strlen(s);
|
||||
if (m>=n && strncmp(s+m-n, *argv, n)==0)
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
puts(s);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+27
-28
@@ -1,7 +1,9 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini Cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1998 by Erik Andersen <andersee@debian.org>
|
||||
* 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
|
||||
@@ -19,36 +21,33 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char cat_usage[] = "[file ...]";
|
||||
|
||||
extern int cat_more_main(int argc, char **argv)
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
FILE *file = stdin;
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s %s", *argv, cat_usage);
|
||||
return 1;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
while (argc-- > 0) {
|
||||
file = fopen(*argv, "r");
|
||||
if (file == NULL) {
|
||||
name_and_error(*argv);
|
||||
return 1;
|
||||
if (argc == 1) {
|
||||
print_file(stdin);
|
||||
return status;
|
||||
}
|
||||
while ((c = getc(file)) != EOF)
|
||||
putc(c, stdout);
|
||||
fclose(file);
|
||||
fflush(stdout);
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
return 0;
|
||||
while (--argc > 0) {
|
||||
if(!(strcmp(*++argv, "-"))) {
|
||||
print_file(stdin);
|
||||
} else if (print_file_by_name(*argv) == FALSE) {
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
+61
-59
@@ -1,7 +1,10 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chgrp implementation for busybox
|
||||
* Mini chown/chmod/chgrp implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1998 by Erik Andersen <andersee@debian.org>
|
||||
*
|
||||
* 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
|
||||
@@ -19,71 +22,70 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "internal.h"
|
||||
#include <grp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char chgrp_usage[] = "chgrp [OPTION]... GROUP FILE...\n"
|
||||
"Change the group membership of each FILE to GROUP.\n"
|
||||
"\n\tOptions:\n" "\t-R\tchange files and directories recursively\n";
|
||||
/* 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)
|
||||
{
|
||||
const char *cp;
|
||||
int gid;
|
||||
struct group *grp;
|
||||
struct stat statBuf;
|
||||
int opt;
|
||||
int recursiveFlag = FALSE;
|
||||
char *p=NULL;
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s %s", *argv, chgrp_usage);
|
||||
return 1;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
cp = argv[1];
|
||||
if (isDecimal(*cp)) {
|
||||
gid = 0;
|
||||
while (isDecimal(*cp))
|
||||
gid = gid * 10 + (*cp++ - '0');
|
||||
if (*cp) {
|
||||
fprintf(stderr, "Bad gid value\n");
|
||||
return -1;
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
grp = getgrnam(cp);
|
||||
if (grp == NULL) {
|
||||
fprintf(stderr, "Unknown group name\n");
|
||||
return -1;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
gid = grp->gr_gid;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
while (argc-- > 1) {
|
||||
argv++;
|
||||
if ((stat(*argv, &statBuf) < 0) ||
|
||||
(chown(*argv, statBuf.st_uid, gid) < 0)) {
|
||||
perror(*argv);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
return EXIT_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
int
|
||||
recursive(const char *fileName, BOOL followLinks, const char *pattern,
|
||||
int (*fileAction) (const char *fileName,
|
||||
const struct stat * statbuf),
|
||||
int (*dirAction) (const char *fileName,
|
||||
const struct stat * statbuf))
|
||||
|
||||
#endif
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
+72
-150
@@ -1,163 +1,85 @@
|
||||
#include <stdlib.h>
|
||||
/* 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 <sys/stat.h>
|
||||
#include "internal.h"
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char chmod_usage[] = "chmod [-R] mode file [file ...]\n"
|
||||
"\nmode may be an octal integer representing the bit pattern for the\n"
|
||||
"\tnew mode, or a symbolic value matching the pattern\n"
|
||||
"\t[ugoa]{+|-|=}[rwxst] .\n"
|
||||
"\t\tu:\tUser\n"
|
||||
"\t\tg:\tGroup\n"
|
||||
"\t\to:\tOthers\n"
|
||||
"\t\ta:\tAll\n"
|
||||
"\n"
|
||||
"\n+:\tAdd privilege\n"
|
||||
"\n-:\tRemove privilege\n"
|
||||
"\n=:\tSet privilege\n"
|
||||
"\n"
|
||||
"\t\tr:\tRead\n"
|
||||
"\t\tw:\tWrite\n"
|
||||
"\t\tx:\tExecute\n"
|
||||
"\t\ts:\tSet User ID\n"
|
||||
"\t\tt:\t\"Sticky\" Text\n"
|
||||
"\n"
|
||||
"\tModes may be concatenated, as in \"u=rwx,g=rx,o=rx,-t,-s\n"
|
||||
"\n"
|
||||
"\t-R:\tRecursively change the mode of all files and directories\n"
|
||||
"\t\tunder the argument directory.";
|
||||
|
||||
int
|
||||
parse_mode(
|
||||
const char * s
|
||||
,mode_t * or
|
||||
,mode_t * and
|
||||
,int * group_execute)
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
/* [ugoa]{+|-|=}[rwxstl] */
|
||||
mode_t mode = 0;
|
||||
mode_t groups = S_ISVTX;
|
||||
char type;
|
||||
char c;
|
||||
|
||||
do {
|
||||
for ( ; ; ) {
|
||||
switch ( c = *s++ ) {
|
||||
case '\0':
|
||||
return -1;
|
||||
case 'u':
|
||||
groups |= S_ISUID|S_IRWXU;
|
||||
continue;
|
||||
case 'g':
|
||||
groups |= S_ISGID|S_IRWXG;
|
||||
continue;
|
||||
case 'o':
|
||||
groups |= S_IRWXO;
|
||||
continue;
|
||||
case 'a':
|
||||
groups |= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
|
||||
continue;
|
||||
case '+':
|
||||
case '=':
|
||||
case '-':
|
||||
type = c;
|
||||
if ( groups == S_ISVTX ) /* The default is "all" */
|
||||
groups |= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
|
||||
break;
|
||||
default:
|
||||
if ( c >= '0' && c <= '7' && mode == 0 && groups == S_ISVTX ) {
|
||||
*and = 0;
|
||||
*or = strtol(--s, 0, 010);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
while ( (c = *s++) != '\0' ) {
|
||||
switch ( c ) {
|
||||
case ',':
|
||||
break;
|
||||
case 'r':
|
||||
mode |= S_IRUSR|S_IRGRP|S_IROTH;
|
||||
continue;
|
||||
case 'w':
|
||||
mode |= S_IWUSR|S_IWGRP|S_IWOTH;
|
||||
continue;
|
||||
case 'x':
|
||||
mode |= S_IXUSR|S_IXGRP|S_IXOTH;
|
||||
continue;
|
||||
case 's':
|
||||
if ( group_execute != 0 && (groups & S_IRWXG) ) {
|
||||
if ( *group_execute < 0 )
|
||||
return -1;
|
||||
if ( type != '-' ) {
|
||||
mode |= S_IXGRP;
|
||||
*group_execute = 1;
|
||||
}
|
||||
}
|
||||
mode |= S_ISUID|S_ISGID;
|
||||
continue;
|
||||
case 'l':
|
||||
if ( *group_execute > 0 )
|
||||
return -1;
|
||||
if ( type != '-' ) {
|
||||
*and &= ~S_IXGRP;
|
||||
*group_execute = -1;
|
||||
}
|
||||
mode |= S_ISGID;
|
||||
groups |= S_ISGID;
|
||||
continue;
|
||||
case 't':
|
||||
mode |= S_ISVTX;
|
||||
continue;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch ( type ) {
|
||||
case '=':
|
||||
*and &= ~(groups);
|
||||
/* fall through */
|
||||
case '+':
|
||||
*or |= mode & groups;
|
||||
break;
|
||||
case '-':
|
||||
*and &= ~(mode & groups);
|
||||
*or &= *and;
|
||||
break;
|
||||
}
|
||||
} while ( c == ',' );
|
||||
return 0;
|
||||
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);
|
||||
}
|
||||
|
||||
extern int
|
||||
chmod_main(struct FileInfo * i, int argc, char * * argv)
|
||||
int chmod_main(int argc, char **argv)
|
||||
{
|
||||
i->andWithMode = S_ISVTX|S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO;
|
||||
i->orWithMode = 0;
|
||||
int i;
|
||||
int opt;
|
||||
int recursiveFlag = FALSE;
|
||||
|
||||
while ( argc >= 3 ) {
|
||||
if ( parse_mode(argv[1], &i->orWithMode, &i->andWithMode, 0)
|
||||
== 0 ) {
|
||||
argc--;
|
||||
argv++;
|
||||
/* do normal option parsing */
|
||||
while ((opt = getopt(argc, argv, "R")) > 0) {
|
||||
switch (opt) {
|
||||
case 'R':
|
||||
recursiveFlag = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
else if ( strcmp(argv[1], "-R") == 0 ) {
|
||||
i->recursive = 1;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
i->changeMode = 1;
|
||||
i->complainInPostProcess = 1;
|
||||
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);
|
||||
}
|
||||
|
||||
return monadic_main(i, argc, argv);
|
||||
/* 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:
|
||||
*/
|
||||
+100
-50
@@ -1,63 +1,113 @@
|
||||
#include "internal.h"
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#include <string.h>
|
||||
/* 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"
|
||||
|
||||
const char chown_usage[] = "chown [-R] user-name file [file ...]\n"
|
||||
"\n\tThe group list is kept in the file /etc/groups.\n\n"
|
||||
"\t-R:\tRecursively change the mode of all files and directories\n"
|
||||
"\t\tunder the argument directory.";
|
||||
/* Don't use lchown for libc5 or glibc older then 2.1.x */
|
||||
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
|
||||
#define lchown chown
|
||||
#endif
|
||||
|
||||
int
|
||||
parse_user_name(const char * s, struct FileInfo * i)
|
||||
static long uid;
|
||||
static long gid;
|
||||
|
||||
static int (*chown_func)() = chown;
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
struct passwd * p;
|
||||
char * dot = strchr(s, '.');
|
||||
|
||||
if (! dot )
|
||||
dot = strchr(s, ':');
|
||||
|
||||
if ( dot )
|
||||
*dot = '\0';
|
||||
|
||||
if ( (p = getpwnam(s)) == 0 ) {
|
||||
fprintf(stderr, "%s: no such user.\n", s);
|
||||
return 1;
|
||||
if (chown_func(fileName, uid, (gid == -1) ? statbuf->st_gid : gid) == 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
i->userID = p->pw_uid;
|
||||
perror(fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
if ( dot ) {
|
||||
struct group * g = getgrnam(++dot);
|
||||
if ( g == 0 ) {
|
||||
fprintf(stderr, "%s: no such group.\n", dot);
|
||||
return 1;
|
||||
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();
|
||||
}
|
||||
i->groupID = g->gr_gid;
|
||||
i->changeGroupID = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int
|
||||
chown_main(struct FileInfo * i, int argc, char * * argv)
|
||||
{
|
||||
int status;
|
||||
|
||||
while ( argc >= 3 && strcmp("-R", argv[1]) == 0 ) {
|
||||
i->recursive = 1;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if ( (status = parse_user_name(argv[1], i)) != 0 )
|
||||
return status;
|
||||
if (noderefFlag) chown_func = lchown;
|
||||
|
||||
argv++;
|
||||
argc--;
|
||||
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);
|
||||
}
|
||||
|
||||
i->changeUserID = 1;
|
||||
i->complainInPostProcess = 1;
|
||||
/* 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;
|
||||
|
||||
return monadic_main(i, argc, argv);
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
+69
-26
@@ -1,32 +1,75 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chroot 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 <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
const char chroot_usage[] = "chroot directory [command]\n"
|
||||
"Run a command with special root directory.\n";
|
||||
|
||||
extern int
|
||||
chroot_main (struct FileInfo *i, int argc, char **argv)
|
||||
int chroot_main(int argc, char **argv)
|
||||
{
|
||||
char *prog;
|
||||
char *prog;
|
||||
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
if (chroot(*argv) || (chdir("/"))) {
|
||||
perror_msg_and_die("cannot change root directory to %s", *argv);
|
||||
}
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc >= 1) {
|
||||
prog = *argv;
|
||||
execvp(*argv, argv);
|
||||
} else {
|
||||
#ifndef BB_SH
|
||||
prog = getenv("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp(prog, prog, NULL);
|
||||
#else
|
||||
char shell[] = "/bin/sh";
|
||||
char *shell_argv[2] = { shell, NULL };
|
||||
applet_name = shell;
|
||||
shell_main(1, shell_argv);
|
||||
return EXIT_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
perror_msg_and_die("cannot execute %s", prog);
|
||||
|
||||
if (chroot (argv[1]))
|
||||
{
|
||||
name_and_error ("cannot chroot to that directory");
|
||||
return 1;
|
||||
}
|
||||
if (argc > 2)
|
||||
{
|
||||
execvp (argv[2], argv + 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
prog = getenv ("SHELL");
|
||||
if (!prog)
|
||||
prog = "/bin/sh";
|
||||
execlp (prog, prog, NULL);
|
||||
}
|
||||
name_and_error ("cannot exec");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,80 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini cmp implementation for busybox
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* 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 <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, *filename2 = "-";
|
||||
int c, c1, c2, char_pos = 1, line_pos = 1, silent = FALSE;
|
||||
|
||||
while ((c = getopt(argc, argv, "s")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
silent = TRUE;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
printf("EOF on %s\n", filename2);
|
||||
else
|
||||
printf("%s %s differ: char %d, line %d\n", filename1, filename2,
|
||||
char_pos, line_pos);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char_pos++;
|
||||
if (c1 == '\n')
|
||||
line_pos++;
|
||||
} while (c1 != EOF);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+104
-79
@@ -1,89 +1,114 @@
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
/* 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 <sys/fcntl.h>
|
||||
#include <sys/param.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <utime.h>
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
const char cp_usage[] = "cp [-r] source-file destination-file\n"
|
||||
"\t\tcp [-r] source-file [source-file ...] destination-directory\n"
|
||||
"\n"
|
||||
"\tCopy the source files to the destination.\n"
|
||||
"\n"
|
||||
"\t-r:\tRecursively copy all files and directories\n"
|
||||
"\t\tunder the argument directory.";
|
||||
#include "busybox.h"
|
||||
|
||||
extern int
|
||||
cp_fn(const struct FileInfo * i)
|
||||
extern int cp_main(int argc, char **argv)
|
||||
{
|
||||
int sourceFd;
|
||||
int destinationFd;
|
||||
const char * destination = i->destination;
|
||||
struct stat destination_stat;
|
||||
int status;
|
||||
char buf[8192];
|
||||
char d[PATH_MAX];
|
||||
int status = 0;
|
||||
int opt;
|
||||
int flags = 0;
|
||||
int i;
|
||||
|
||||
if ( (i->stat.st_mode & S_IFMT) == S_IFDIR ) {
|
||||
if ( mkdir(destination, i->stat.st_mode & ~S_IFMT)
|
||||
!= 0 && errno != EEXIST ) {
|
||||
name_and_error(destination);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
if ( (sourceFd = open(i->source, O_RDONLY)) < 0 ) {
|
||||
name_and_error(i->source);
|
||||
return 1;
|
||||
}
|
||||
if ( stat(destination, &destination_stat) == 0 ) {
|
||||
if ( i->stat.st_ino == destination_stat.st_ino
|
||||
&& i->stat.st_dev == destination_stat.st_dev ) {
|
||||
fprintf(stderr
|
||||
,"copy of %s to %s would copy file to itself.\n"
|
||||
,i->source
|
||||
,destination);
|
||||
close(sourceFd);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If the destination is a directory, create a file within it.
|
||||
*/
|
||||
if ( (destination_stat.st_mode & S_IFMT) == S_IFDIR ) {
|
||||
destination = join_paths(
|
||||
d
|
||||
,i->destination
|
||||
,&i->source[i->directoryLength]);
|
||||
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 ( stat(destination, &destination_stat) == 0 ) {
|
||||
if ( i->stat.st_ino == destination_stat.st_ino
|
||||
&& i->stat.st_dev == destination_stat.st_dev ) {
|
||||
fprintf(stderr
|
||||
,"copy of %s to %s would copy file to itself.\n"
|
||||
,i->source
|
||||
,destination);
|
||||
close(sourceFd);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* 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;
|
||||
|
||||
destinationFd = creat(destination, i->stat.st_mode & 07777);
|
||||
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;
|
||||
}
|
||||
|
||||
while ( (status = read(sourceFd, buf, sizeof(buf))) > 0 ) {
|
||||
if ( write(destinationFd, buf, status) != status ) {
|
||||
name_and_error(destination);
|
||||
close(sourceFd);
|
||||
close(destinationFd);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
close(sourceFd);
|
||||
close(destinationFd);
|
||||
if ( status < 0 ) {
|
||||
name_and_error(i->source);
|
||||
return 1;
|
||||
}
|
||||
return 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;
|
||||
}
|
||||
+358
@@ -0,0 +1,358 @@
|
||||
/*
|
||||
* cut.c - minimalist version of cut
|
||||
*
|
||||
* 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
|
||||
* 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 <unistd.h> /* getopt */
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
/* globals from other files */
|
||||
extern int optind;
|
||||
extern char *optarg;
|
||||
|
||||
|
||||
/* option vars */
|
||||
static char part = 0; /* (b)yte, (c)har, (f)ields */
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 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 parse_lists(char *lists)
|
||||
{
|
||||
char *ltok = NULL;
|
||||
char *ntok = NULL;
|
||||
char *junk;
|
||||
int s = 0, e = 0;
|
||||
|
||||
/* 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--;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
/* If we made it here, it means we've found the line we're looking for, so print it */
|
||||
puts(line);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* snippy-snip
|
||||
*/
|
||||
static void cut_file(FILE *file)
|
||||
{
|
||||
char *line = NULL;
|
||||
unsigned int linenum = 0; /* keep these zero-based to be consistent */
|
||||
|
||||
/* go through every line in the file */
|
||||
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') {
|
||||
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;
|
||||
|
||||
while ((opt = getopt(argc, argv, "b:c:d:f:ns")) > 0) {
|
||||
switch (opt) {
|
||||
case 'b':
|
||||
case 'c':
|
||||
case 'f':
|
||||
/* make sure they didn't ask for two types of lists */
|
||||
if (part != 0) {
|
||||
error_msg_and_die("only one type of list may be specified");
|
||||
}
|
||||
part = (char)opt;
|
||||
parse_lists(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
if (strlen(optarg) > 1) {
|
||||
error_msg_and_die("the delimiter must be a single character");
|
||||
}
|
||||
delim = optarg[0];
|
||||
break;
|
||||
case 'n':
|
||||
/* no-op */
|
||||
break;
|
||||
case 's':
|
||||
supress_non_delimited_lines++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (part == 0) {
|
||||
error_msg_and_die("you must specify a list of bytes, characters, or fields");
|
||||
}
|
||||
|
||||
/* 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
|
||||
* files were specified or '-' was specified, take input from stdin.
|
||||
* Otherwise, we process all the files specified. */
|
||||
if (argv[optind] == NULL || (strcmp(argv[optind], "-") == 0)) {
|
||||
cut_file(stdin);
|
||||
}
|
||||
else {
|
||||
int i;
|
||||
FILE *file;
|
||||
for (i = optind; i < argc; i++) {
|
||||
file = fopen(argv[i], "r");
|
||||
if (file == NULL) {
|
||||
perror_msg("%s", argv[i]);
|
||||
} else {
|
||||
cut_file(file);
|
||||
fclose(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+204
-262
@@ -1,11 +1,34 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini date implementation for busybox
|
||||
*
|
||||
* by Matthew Grant <grantma@anathoth.gen.nz>
|
||||
*
|
||||
* 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 <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,
|
||||
@@ -14,292 +37,211 @@
|
||||
an RFC 822 complient date output for shell scripting
|
||||
mail commands */
|
||||
|
||||
const char date_usage[] = "date [-uR] [+FORMAT|+%f] [ [-s|-d] MMDDhhmm[[CC]YY]\n | [[[[CCYY.]MM.DD-]hh:mm[:ss]]]] ]";
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"date", required_argument, NULL, 'd'},
|
||||
/* {"rfc-822", no_argument, NULL, 'R'},
|
||||
{"set", required_argument, NULL, 's'},
|
||||
{"uct", no_argument, NULL, 'u'},
|
||||
{"utc", no_argument, NULL, 'u'},
|
||||
{"universal", no_argument, NULL, 'u'}, */
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Input parsing code is always bulky - used heavy duty libc stuff as
|
||||
much as possible, missed out a lot of bounds checking */
|
||||
|
||||
/* Default input handling to save suprising some people */
|
||||
|
||||
struct tm *
|
||||
date_conv_time(struct tm *tm_time, const char *t_string) {
|
||||
int nr;
|
||||
static struct tm *date_conv_time(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
int nr;
|
||||
|
||||
nr = sscanf(t_string, "%2d%2d%2d%2d%d",
|
||||
&(tm_time->tm_mon),
|
||||
&(tm_time->tm_mday),
|
||||
&(tm_time->tm_hour),
|
||||
&(tm_time->tm_min),
|
||||
&(tm_time->tm_year));
|
||||
nr = sscanf(t_string, "%2d%2d%2d%2d%d",
|
||||
&(tm_time->tm_mon),
|
||||
&(tm_time->tm_mday),
|
||||
&(tm_time->tm_hour),
|
||||
&(tm_time->tm_min), &(tm_time->tm_year));
|
||||
|
||||
if(nr < 4 || nr > 5) {
|
||||
fprintf(stderr, "date: invalid date `%s'\n", t_string);
|
||||
exit(1);
|
||||
}
|
||||
if (nr < 4 || nr > 5) {
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
}
|
||||
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
if(tm_time->tm_year >= 1900)
|
||||
tm_time->tm_year -= 1900;
|
||||
/* adjust date */
|
||||
tm_time->tm_mon -= 1;
|
||||
|
||||
return(tm_time);
|
||||
/* correct for century - minor Y2K problem here? */
|
||||
if (tm_time->tm_year >= 1900)
|
||||
tm_time->tm_year -= 1900;
|
||||
/* adjust date */
|
||||
tm_time->tm_mon -= 1;
|
||||
|
||||
return (tm_time);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* The new stuff for LRP */
|
||||
|
||||
struct tm *
|
||||
date_conv_ftime(struct tm *tm_time, const char *t_string) {
|
||||
struct tm itm_time, jtm_time, ktm_time, \
|
||||
ltm_time, mtm_time, ntm_time;
|
||||
|
||||
itm_time = *tm_time;
|
||||
jtm_time = *tm_time;
|
||||
ktm_time = *tm_time;
|
||||
ltm_time = *tm_time;
|
||||
mtm_time = *tm_time;
|
||||
ntm_time = *tm_time;
|
||||
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
|
||||
if(sscanf(t_string, "%d:%d:%d",
|
||||
&itm_time.tm_hour,
|
||||
&itm_time.tm_min,
|
||||
&itm_time.tm_sec) == 3 ) {
|
||||
|
||||
*tm_time = itm_time;
|
||||
return(tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d:%d",
|
||||
&jtm_time.tm_hour,
|
||||
&jtm_time.tm_min) == 2) {
|
||||
|
||||
*tm_time = jtm_time;
|
||||
return(tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d-%d:%d:%d",
|
||||
&ktm_time.tm_mon,
|
||||
&ktm_time.tm_mday,
|
||||
&ktm_time.tm_hour,
|
||||
&ktm_time.tm_min,
|
||||
&ktm_time.tm_sec) == 5) {
|
||||
|
||||
ktm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ktm_time;
|
||||
return(tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d-%d:%d",
|
||||
<m_time.tm_mon,
|
||||
<m_time.tm_mday,
|
||||
<m_time.tm_hour,
|
||||
<m_time.tm_min) == 4) {
|
||||
|
||||
ltm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ltm_time;
|
||||
return(tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&mtm_time.tm_year,
|
||||
&mtm_time.tm_mon,
|
||||
&mtm_time.tm_mday,
|
||||
&mtm_time.tm_hour,
|
||||
&mtm_time.tm_min,
|
||||
&mtm_time.tm_sec) == 6) {
|
||||
|
||||
mtm_time.tm_year -= 1900; /* Adjust years */
|
||||
mtm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = mtm_time;
|
||||
return(tm_time);
|
||||
|
||||
} else if (sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&ntm_time.tm_year,
|
||||
&ntm_time.tm_mon,
|
||||
&ntm_time.tm_mday,
|
||||
&ntm_time.tm_hour,
|
||||
&ntm_time.tm_min) == 5) {
|
||||
ntm_time.tm_year -= 1900; /* Adjust years */
|
||||
ntm_time.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
*tm_time = ntm_time;
|
||||
return(tm_time);
|
||||
|
||||
}
|
||||
|
||||
fprintf(stderr, "date: invalid date `%s'\n", t_string);
|
||||
|
||||
exit(1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
date_err(void) {
|
||||
fprintf(stderr, "date: only one date argument can be given at a time.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
date_main(struct FileInfo * i, int argc, char * * argv)
|
||||
static struct tm *date_conv_ftime(struct tm *tm_time, const char *t_string)
|
||||
{
|
||||
char *date_str = NULL;
|
||||
char *date_fmt = NULL;
|
||||
char *t_buff;
|
||||
int set_time = 0;
|
||||
int rfc822 = 0;
|
||||
int utc = 0;
|
||||
int use_arg = 0;
|
||||
int n_args;
|
||||
time_t tm;
|
||||
struct tm tm_time;
|
||||
char optc;
|
||||
|
||||
/* Interpret command line args */
|
||||
|
||||
struct tm t;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "d:Rs:u", long_options, NULL))
|
||||
!= EOF) {
|
||||
switch (optc) {
|
||||
case 0:
|
||||
break;
|
||||
/* Parse input and assign appropriately to tm_time */
|
||||
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
if (t=*tm_time,sscanf(t_string, "%d:%d:%d",
|
||||
&t.tm_hour, &t.tm_min, &t.tm_sec) == 3) {
|
||||
/* no adjustments needed */
|
||||
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if(date_str != NULL) date_err();
|
||||
date_str = optarg;
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv ("TZ=UTC0") != 0) {
|
||||
fprintf(stderr,"date: memory exhausted\n");
|
||||
return(1);
|
||||
}
|
||||
#if LOCALTIME_CACHE
|
||||
tzset ();
|
||||
#endif break;
|
||||
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if(date_str != NULL) date_err();
|
||||
date_str = optarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
usage(date_usage);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d:%d",
|
||||
&t.tm_hour, &t.tm_min) == 2) {
|
||||
/* no adjustments needed */
|
||||
|
||||
|
||||
n_args = argc - optind;
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d:%d",
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 5) {
|
||||
|
||||
while (n_args--){
|
||||
switch(argv[optind][0]) {
|
||||
case '+':
|
||||
/* Date format strings */
|
||||
if(date_fmt != NULL) {
|
||||
fprintf(stderr, "date: only one date format can be given.\n");
|
||||
return(1);
|
||||
}
|
||||
date_fmt = &argv[optind][1];
|
||||
break;
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
case '\0':
|
||||
break;
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d-%d:%d",
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 4) {
|
||||
|
||||
default:
|
||||
/* Anything left over must be a date string to set the time */
|
||||
set_time = 1;
|
||||
if(date_str != NULL) date_err();
|
||||
date_str = argv[optind];
|
||||
break;
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour,
|
||||
&t.tm_min, &t.tm_sec) == 6) {
|
||||
|
||||
/* Now we have parsed all the information except the date format
|
||||
which depends on whether the clock is being set or read */
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
time(&tm);
|
||||
memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
|
||||
/* Zero out fields - take her back to midnight!*/
|
||||
if(date_str != NULL) {
|
||||
tm_time.tm_sec = 0;
|
||||
tm_time.tm_min = 0;
|
||||
tm_time.tm_hour = 0;
|
||||
}
|
||||
|
||||
/* Process any date input to UNIX time since 1 Jan 1970 */
|
||||
if(date_str != NULL) {
|
||||
|
||||
if(strchr(date_str, ':') != NULL) {
|
||||
date_conv_ftime(&tm_time, date_str);
|
||||
} else {
|
||||
date_conv_time(&tm_time, date_str);
|
||||
}
|
||||
|
||||
/* Correct any day of week and day of year etc fields */
|
||||
tm = mktime(&tm_time);
|
||||
if (tm < 0 ) {
|
||||
fprintf(stderr, "date: invalid date `%s'\n", date_str);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* if setting time, set it */
|
||||
if(set_time) {
|
||||
if( stime(&tm) < 0) {
|
||||
fprintf(stderr, "date: can't set date.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display output */
|
||||
|
||||
/* Deal with format string */
|
||||
if(date_fmt == NULL) {
|
||||
date_fmt = (rfc822
|
||||
? (utc
|
||||
? "%a, %_d %b %Y %H:%M:%S GMT"
|
||||
: "%a, %_d %b %Y %H:%M:%S %z")
|
||||
: "%a %b %e %H:%M:%S %Z %Y");
|
||||
|
||||
} else if ( *date_fmt == '\0' ) {
|
||||
/* Imitate what GNU 'date' does with NO format string! */
|
||||
printf ("\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Handle special conversions */
|
||||
|
||||
if( strncmp( date_fmt, "%f", 2) == 0 ) {
|
||||
date_fmt = "%Y.%m.%d-%H:%M:%S";
|
||||
}
|
||||
|
||||
/* Print OUTPUT (after ALL that!) */
|
||||
t_buff = malloc(201);
|
||||
strftime(t_buff, 200, date_fmt, &tm_time);
|
||||
printf("%s\n", t_buff);
|
||||
|
||||
return(0);
|
||||
} else if (t=*tm_time,sscanf(t_string, "%d.%d.%d-%d:%d",
|
||||
&t.tm_year,
|
||||
&t.tm_mon,
|
||||
&t.tm_mday,
|
||||
&t.tm_hour, &t.tm_min) == 5) {
|
||||
t.tm_year -= 1900; /* Adjust years */
|
||||
t.tm_mon -= 1; /* Adjust dates from 1-12 to 0-11 */
|
||||
|
||||
} else {
|
||||
error_msg_and_die(invalid_date, t_string);
|
||||
}
|
||||
*tm_time = t;
|
||||
return (tm_time);
|
||||
}
|
||||
|
||||
|
||||
int date_main(int argc, char **argv)
|
||||
{
|
||||
char *date_str = NULL;
|
||||
char *date_fmt = NULL;
|
||||
char *t_buff;
|
||||
int c;
|
||||
int set_time = 0;
|
||||
int rfc822 = 0;
|
||||
int utc = 0;
|
||||
int use_arg = 0;
|
||||
time_t tm;
|
||||
struct tm tm_time;
|
||||
|
||||
/* Interpret command line args */
|
||||
while ((c = getopt(argc, argv, "Rs:ud:")) != EOF) {
|
||||
switch (c) {
|
||||
case 'R':
|
||||
rfc822 = 1;
|
||||
break;
|
||||
case 's':
|
||||
set_time = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL)) {
|
||||
show_usage();
|
||||
}
|
||||
break;
|
||||
case 'u':
|
||||
utc = 1;
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
break;
|
||||
case 'd':
|
||||
use_arg = 1;
|
||||
if ((date_str != NULL) || ((date_str = optarg) == NULL))
|
||||
show_usage();
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if ((date_fmt == NULL) && (optind < argc) && (argv[optind][0] == '+'))
|
||||
date_fmt = &argv[optind][1]; /* Skip over the '+' */
|
||||
else if (date_str == NULL) {
|
||||
set_time = 1;
|
||||
date_str = argv[optind];
|
||||
}
|
||||
#if 0
|
||||
else {
|
||||
error_msg("date_str='%s' date_fmt='%s'\n", date_str, date_fmt);
|
||||
show_usage();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now we have parsed all the information except the date format
|
||||
which depends on whether the clock is being set or read */
|
||||
|
||||
time(&tm);
|
||||
memcpy(&tm_time, localtime(&tm), sizeof(tm_time));
|
||||
/* Zero out fields - take her back to midnight! */
|
||||
if (date_str != NULL) {
|
||||
tm_time.tm_sec = 0;
|
||||
tm_time.tm_min = 0;
|
||||
tm_time.tm_hour = 0;
|
||||
}
|
||||
|
||||
/* Process any date input to UNIX time since 1 Jan 1970 */
|
||||
if (date_str != NULL) {
|
||||
|
||||
if (strchr(date_str, ':') != NULL) {
|
||||
date_conv_ftime(&tm_time, date_str);
|
||||
} else {
|
||||
date_conv_time(&tm_time, date_str);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
if ( utc ) {
|
||||
if (putenv("TZ=UTC0") != 0)
|
||||
error_msg_and_die(memory_exhausted);
|
||||
}
|
||||
|
||||
/* if setting time, set it */
|
||||
if (set_time) {
|
||||
if (stime(&tm) < 0) {
|
||||
perror_msg("cannot set date");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Display output */
|
||||
|
||||
/* Deal with format string */
|
||||
if (date_fmt == NULL) {
|
||||
date_fmt = (rfc822
|
||||
? (utc
|
||||
? "%a, %_d %b %Y %H:%M:%S GMT"
|
||||
: "%a, %_d %b %Y %H:%M:%S %z")
|
||||
: "%a %b %e %H:%M:%S %Z %Y");
|
||||
|
||||
} else if (*date_fmt == '\0') {
|
||||
/* Imitate what GNU 'date' does with NO format string! */
|
||||
printf("\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/* Handle special conversions */
|
||||
|
||||
if (strncmp(date_fmt, "%f", 2) == 0) {
|
||||
date_fmt = "%Y.%m.%d-%H:%M:%S";
|
||||
}
|
||||
|
||||
/* Print OUTPUT (after ALL that!) */
|
||||
t_buff = xmalloc(201);
|
||||
strftime(t_buff, 200, date_fmt, &tm_time);
|
||||
puts(t_buff);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+135
-284
@@ -1,307 +1,158 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Copyright (c) 1999 by David I. Bell
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
* Mini dd implementation for busybox
|
||||
*
|
||||
* The "dd" command, originally taken from sash.
|
||||
*
|
||||
* Permission to distribute this code under the GPL has been granted.
|
||||
* Majorly modified, and bugs fixed for busybox by Erik Andersen <andersee@debian.org> <andersen@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
|
||||
* 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 "internal.h"
|
||||
#ifdef BB_DD
|
||||
|
||||
const char dd_usage[] =
|
||||
"Copy a file, converting and formatting according to options\n\
|
||||
\n\
|
||||
usage: [if=name] [of=name] [bs=n] [count=n]\n\
|
||||
\tif=FILE\tread from FILE instead of stdin\n\
|
||||
\tof=FILE\twrite to FILE instead of stout\n\
|
||||
\tbs=n\tread and write N bytes at a time\n\
|
||||
\tcount=n\tcopy only n input blocks\n\
|
||||
\n\
|
||||
BYTES may be suffixed: by k for x1024, b for x512, and w for x2.\n";
|
||||
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include "busybox.h"
|
||||
|
||||
|
||||
#define PAR_NONE 0
|
||||
#define PAR_IF 1
|
||||
#define PAR_OF 2
|
||||
#define PAR_BS 3
|
||||
#define PAR_COUNT 4
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char * name;
|
||||
int value;
|
||||
} PARAM;
|
||||
|
||||
|
||||
static const PARAM params[] =
|
||||
{
|
||||
{"if", PAR_IF},
|
||||
{"of", PAR_OF},
|
||||
{"bs", PAR_BS},
|
||||
{"count", PAR_COUNT},
|
||||
{NULL, PAR_NONE}
|
||||
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 }
|
||||
};
|
||||
|
||||
|
||||
static long getNum(const char * cp);
|
||||
|
||||
extern int
|
||||
dd_main (struct FileInfo *unused, int argc, char **argv)
|
||||
int dd_main(int argc, char **argv)
|
||||
{
|
||||
const char * str;
|
||||
const PARAM * par;
|
||||
const char * inFile;
|
||||
const char * outFile;
|
||||
char * cp;
|
||||
int inFd;
|
||||
int outFd;
|
||||
int inCc=0;
|
||||
int outCc;
|
||||
int blockSize;
|
||||
long count;
|
||||
long intotal;
|
||||
long outTotal;
|
||||
unsigned char* buf;
|
||||
unsigned char localBuf[BUF_SIZE];
|
||||
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;
|
||||
|
||||
inFile = NULL;
|
||||
outFile = NULL;
|
||||
blockSize = 512;
|
||||
count = 1;
|
||||
|
||||
|
||||
while (--argc > 0)
|
||||
{
|
||||
str = *++argv;
|
||||
cp = strchr(str, '=');
|
||||
|
||||
if (cp == NULL)
|
||||
{
|
||||
fprintf(stderr, "Bad dd argument\n");
|
||||
goto usage;
|
||||
}
|
||||
|
||||
*cp++ = '\0';
|
||||
|
||||
for (par = params; par->name; par++)
|
||||
{
|
||||
if (strcmp(str, par->name) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
switch (par->value)
|
||||
{
|
||||
case PAR_IF:
|
||||
if (inFile)
|
||||
{
|
||||
fprintf(stderr, "Multiple input files illegal\n");
|
||||
goto usage;
|
||||
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);
|
||||
}
|
||||
|
||||
//fprintf(stderr, "if=%s\n", cp);
|
||||
inFile = cp;
|
||||
break;
|
||||
|
||||
case PAR_OF:
|
||||
if (outFile)
|
||||
{
|
||||
fprintf(stderr, "Multiple output files illegal\n");
|
||||
goto usage;
|
||||
}
|
||||
|
||||
//fprintf(stderr, "of=%s\n", cp);
|
||||
outFile = cp;
|
||||
break;
|
||||
|
||||
case PAR_BS:
|
||||
blockSize = getNum(cp);
|
||||
//fprintf(stderr, "bs=%d\n", blockSize);
|
||||
|
||||
if (blockSize <= 0)
|
||||
{
|
||||
fprintf(stderr, "Bad block size value\n");
|
||||
goto usage;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PAR_COUNT:
|
||||
count = getNum(cp);
|
||||
//fprintf(stderr, "count=%ld\n", count);
|
||||
|
||||
if (count < 0)
|
||||
{
|
||||
fprintf(stderr, "Bad count value\n");
|
||||
goto usage;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
goto usage;
|
||||
}
|
||||
}
|
||||
|
||||
buf = localBuf;
|
||||
|
||||
if (blockSize > sizeof(localBuf))
|
||||
{
|
||||
buf = malloc(blockSize);
|
||||
|
||||
if (buf == NULL)
|
||||
{
|
||||
fprintf(stderr, "Cannot allocate buffer\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
intotal = 0;
|
||||
outTotal = 0;
|
||||
|
||||
if (inFile == NULL)
|
||||
inFd = STDIN;
|
||||
else
|
||||
inFd = open(inFile, 0);
|
||||
|
||||
if (inFd < 0)
|
||||
{
|
||||
perror(inFile);
|
||||
|
||||
if (buf != localBuf)
|
||||
free(buf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (outFile == NULL)
|
||||
outFd = STDOUT;
|
||||
else
|
||||
outFd = creat(outFile, 0666);
|
||||
|
||||
if (outFd < 0)
|
||||
{
|
||||
perror(outFile);
|
||||
close(inFd);
|
||||
|
||||
if (buf != localBuf)
|
||||
free(buf);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ( outTotal < count*blockSize )
|
||||
{
|
||||
inCc = read(inFd, buf, blockSize);
|
||||
if (inCc < 0) {
|
||||
perror(inFile);
|
||||
goto cleanup;
|
||||
}
|
||||
//fprintf(stderr, "read in =%d\n", inCc);
|
||||
intotal += inCc;
|
||||
cp = buf;
|
||||
|
||||
|
||||
while ( intotal > outTotal )
|
||||
{
|
||||
if (outTotal+inCc > count*blockSize)
|
||||
inCc=count*blockSize-outTotal;
|
||||
outCc = write(outFd, cp, inCc);
|
||||
if (outCc < 0)
|
||||
{
|
||||
perror(outFile);
|
||||
goto cleanup;
|
||||
if (buf[0] == '\0')
|
||||
break;
|
||||
if (buf[0] == ',')
|
||||
buf++;
|
||||
}
|
||||
//fprintf(stderr, "wrote out =%d\n", outCc);
|
||||
} else
|
||||
show_usage();
|
||||
}
|
||||
|
||||
inCc -= outCc;
|
||||
cp += outCc;
|
||||
outTotal += outCc;
|
||||
//fprintf(stderr, "outTotal=%ld\n", outTotal);
|
||||
buf = xmalloc(bs);
|
||||
|
||||
if (infile != NULL) {
|
||||
if ((ifd = open(infile, O_RDONLY)) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
} else {
|
||||
ifd = STDIN_FILENO;
|
||||
infile = "standard input";
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
statusfp = stdout;
|
||||
} else {
|
||||
ofd = STDOUT_FILENO;
|
||||
outfile = "standard output";
|
||||
statusfp = stderr;
|
||||
}
|
||||
|
||||
if (inCc < 0)
|
||||
perror(inFile);
|
||||
|
||||
cleanup:
|
||||
close(inFd);
|
||||
|
||||
if (close(outFd) < 0)
|
||||
perror(outFile);
|
||||
|
||||
if (buf != localBuf)
|
||||
free(buf);
|
||||
|
||||
printf("%ld+%d records in\n", intotal / blockSize,
|
||||
(intotal % blockSize) != 0);
|
||||
|
||||
printf("%ld+%d records out\n", outTotal / blockSize,
|
||||
(outTotal % blockSize) != 0);
|
||||
return 0;
|
||||
usage:
|
||||
|
||||
fprintf(stderr, "%s", dd_usage);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Read a number with a possible multiplier.
|
||||
* Returns -1 if the number format is illegal.
|
||||
*/
|
||||
static long
|
||||
getNum(const char * cp)
|
||||
{
|
||||
long value;
|
||||
|
||||
if (!isDecimal(*cp))
|
||||
return -1;
|
||||
|
||||
value = 0;
|
||||
|
||||
while (isDecimal(*cp))
|
||||
value = value * 10 + *cp++ - '0';
|
||||
|
||||
switch (*cp++)
|
||||
{
|
||||
case 'k':
|
||||
value *= 1024;
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
value *= 512;
|
||||
break;
|
||||
|
||||
case 'w':
|
||||
value *= 2;
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
return value;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
if (skip) {
|
||||
if (lseek(ifd, skip * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", infile);
|
||||
}
|
||||
|
||||
if (*cp)
|
||||
return -1;
|
||||
if (seek) {
|
||||
if (lseek(ofd, seek * bs, SEEK_CUR) < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
}
|
||||
|
||||
return value;
|
||||
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;
|
||||
}
|
||||
n = full_write(ofd, buf, n);
|
||||
if (n < 0)
|
||||
perror_msg_and_die("%s", outfile);
|
||||
if (n == bs)
|
||||
out_full++;
|
||||
else
|
||||
out_part++;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
#endif
|
||||
/* END CODE */
|
||||
|
||||
+146
-91
@@ -1,103 +1,158 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini df implementation for busybox
|
||||
*
|
||||
* 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>.
|
||||
*
|
||||
* 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 <mntent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/vfs.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char df_usage[] = "df [filesystem ...]\n"
|
||||
"\n"
|
||||
"\tPrint the filesystem space used and space available.\n";
|
||||
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(const 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;
|
||||
struct statfs s;
|
||||
long blocks_used;
|
||||
long blocks_percent_used;
|
||||
|
||||
if ( statfs(mountPoint, &s) != 0 ) {
|
||||
name_and_error(mountPoint);
|
||||
return 1;
|
||||
if (statfs(mount_point, &s) != 0) {
|
||||
perror_msg("%s", mount_point);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( s.f_blocks > 0 ) {
|
||||
|
||||
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 */
|
||||
device = find_real_root_device_name(device);
|
||||
if(device==NULL)
|
||||
return FALSE;
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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 (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
} else {
|
||||
FILE *mount_table;
|
||||
struct mntent *mount_entry;
|
||||
|
||||
mount_table = setmntent(mtab_file, "r");
|
||||
if (mount_table == 0) {
|
||||
perror_msg("%s", mtab_file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
while ((mount_entry = getmntent(mount_table))) {
|
||||
if (!do_df(mount_entry->mnt_fsname, mount_entry->mnt_dir))
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
endmntent(mount_table);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
printf(
|
||||
"%-20s %7ld %7ld %7ld %5ld%% %s\n"
|
||||
,device
|
||||
,s.f_blocks
|
||||
,s.f_blocks - s.f_bfree
|
||||
,s.f_bavail
|
||||
,blocks_percent_used
|
||||
,mountPoint);
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
|
||||
printf(
|
||||
"%-20s %7.0f %7.0f %7.0f %5ld%% %s\n"
|
||||
,device
|
||||
,s.f_blocks * (s.f_bsize / 1024.0)
|
||||
,(s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)
|
||||
,s.f_bavail * (s.f_bsize / 1024.0)
|
||||
,blocks_percent_used
|
||||
,mountPoint);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int
|
||||
df_main(struct FileInfo * i, int argc, char * * argv)
|
||||
{
|
||||
static const char header[] =
|
||||
"Filesystem 1024-blocks Used Available Capacity Mounted on\n";
|
||||
printf(header);
|
||||
|
||||
if ( argc > 1 ) {
|
||||
struct mntent * mountEntry;
|
||||
int status;
|
||||
|
||||
while ( argc > 1 ) {
|
||||
if ( (mountEntry = findMountPoint(argv[1], "/etc/mtab")) == 0
|
||||
&& (mountEntry = findMountPoint(argv[1], "/proc/mounts")) == 0 )
|
||||
{
|
||||
fprintf(stderr, "%s: can't find mount point.\n"
|
||||
,argv[1]);
|
||||
return 1;
|
||||
}
|
||||
status = df(mountEntry->mnt_fsname, mountEntry->mnt_dir);
|
||||
if ( status != 0 )
|
||||
return status;
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else {
|
||||
FILE * mountTable;
|
||||
struct mntent * mountEntry;
|
||||
|
||||
if ( (mountTable = setmntent("/etc/mtab", "r")) == 0
|
||||
&& (mountTable = setmntent("/proc/mounts", "r")) == 0
|
||||
) {
|
||||
name_and_error("/etc/mtab");
|
||||
return 1;
|
||||
}
|
||||
|
||||
while ( (mountEntry = getmntent(mountTable)) != 0 ) {
|
||||
int status = df(
|
||||
mountEntry->mnt_fsname
|
||||
,mountEntry->mnt_dir);
|
||||
if ( status != 0 )
|
||||
return status;
|
||||
}
|
||||
endmntent(mountTable);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini dirname 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
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int dirname_main(int argc, char **argv)
|
||||
{
|
||||
if ((argc < 2) || (**(argv + 1) == '-'))
|
||||
show_usage();
|
||||
argv++;
|
||||
|
||||
puts (dirname (argv[0]));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* 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"
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini du implementation for busybox
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* 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 <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 *);
|
||||
|
||||
static int du_depth = 0;
|
||||
static int count_hardlinks = 0;
|
||||
|
||||
static Display *print;
|
||||
|
||||
static void print_normal(long size, char *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)
|
||||
{
|
||||
if (du_depth == 1) {
|
||||
print_normal(size, 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;
|
||||
|
||||
if ((lstat(filename, &statbuf)) != 0) {
|
||||
perror_msg("%s", filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
du_depth++;
|
||||
sum = (statbuf.st_blocks >> 1);
|
||||
|
||||
/* Don't add in stuff pointed to by symbolic links */
|
||||
if (S_ISLNK(statbuf.st_mode)) {
|
||||
sum = 0L;
|
||||
if (du_depth == 1) {
|
||||
}
|
||||
}
|
||||
if (S_ISDIR(statbuf.st_mode)) {
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
char *newfile;
|
||||
|
||||
dir = opendir(filename);
|
||||
if (!dir) {
|
||||
du_depth--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
newfile = last_char_is(filename, '/');
|
||||
if (newfile)
|
||||
*newfile = '\0';
|
||||
|
||||
while ((entry = readdir(dir))) {
|
||||
char *name = entry->d_name;
|
||||
|
||||
if ((strcmp(name, "..") == 0)
|
||||
|| (strcmp(name, ".") == 0)) {
|
||||
continue;
|
||||
}
|
||||
newfile = concat_path_file(filename, name);
|
||||
sum += du(newfile);
|
||||
free(newfile);
|
||||
}
|
||||
closedir(dir);
|
||||
print(sum, filename);
|
||||
}
|
||||
else if (statbuf.st_nlink > 1 && !count_hardlinks) {
|
||||
/* Add files with hard links only once */
|
||||
if (is_in_ino_dev_hashtable(&statbuf, NULL)) {
|
||||
sum = 0L;
|
||||
if (du_depth == 1)
|
||||
print(sum, filename);
|
||||
}
|
||||
else {
|
||||
add_to_ino_dev_hashtable(&statbuf, NULL);
|
||||
}
|
||||
}
|
||||
du_depth--;
|
||||
return sum;
|
||||
}
|
||||
|
||||
int du_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int i;
|
||||
int c;
|
||||
|
||||
/* default behaviour */
|
||||
print = print_normal;
|
||||
|
||||
/* parse argv[] */
|
||||
while ((c = getopt(argc, argv, "sl"
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
"hm"
|
||||
#endif
|
||||
"k")) != EOF) {
|
||||
switch (c) {
|
||||
case 's':
|
||||
print = print_summary;
|
||||
break;
|
||||
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:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* go through remaining args (if any) */
|
||||
if (optind >= argc) {
|
||||
if (du(".") == 0)
|
||||
status = EXIT_FAILURE;
|
||||
} else {
|
||||
long sum;
|
||||
|
||||
for (i=optind; i < argc; i++) {
|
||||
sum = du(argv[i]);
|
||||
if(is_directory(argv[i], FALSE, NULL)==FALSE) {
|
||||
print_normal(sum, argv[i]);
|
||||
}
|
||||
reset_ino_dev_hashtable();
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* $Id: du.c,v 1.50 2001/06/30 17:54:20 andersen Exp $ */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,152 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* echo implementation for busybox
|
||||
*
|
||||
* Copyright (c) 1991, 1993
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int
|
||||
echo_main(int argc, char** argv)
|
||||
{
|
||||
int nflag = 0;
|
||||
int eflag = 0;
|
||||
|
||||
/* Skip argv[0]. */
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
while (argc > 0 && *argv[0] == '-')
|
||||
{
|
||||
register char *temp;
|
||||
register int ix;
|
||||
|
||||
/*
|
||||
* If it appears that we are handling options, then make sure
|
||||
* that all of the options specified are actually valid.
|
||||
* Otherwise, the string should just be echoed.
|
||||
*/
|
||||
temp = argv[0] + 1;
|
||||
|
||||
for (ix = 0; temp[ix]; ix++)
|
||||
{
|
||||
if (strrchr("neE", temp[ix]) == 0)
|
||||
goto just_echo;
|
||||
}
|
||||
|
||||
if (!*temp)
|
||||
goto just_echo;
|
||||
|
||||
/*
|
||||
* All of the options in temp are valid options to echo.
|
||||
* Handle them.
|
||||
*/
|
||||
while (*temp)
|
||||
{
|
||||
if (*temp == 'n')
|
||||
nflag = 1;
|
||||
else if (*temp == 'e')
|
||||
eflag = 1;
|
||||
else if (*temp == 'E')
|
||||
eflag = 0;
|
||||
else
|
||||
goto just_echo;
|
||||
|
||||
temp++;
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
just_echo:
|
||||
while (argc > 0) {
|
||||
const char *arg = argv[0];
|
||||
register int c;
|
||||
|
||||
while ((c = *arg++)) {
|
||||
|
||||
/* Check for escape sequence. */
|
||||
if (c == '\\' && eflag && *arg) {
|
||||
if (*arg == 'c') {
|
||||
/* '\c' means cancel newline. */
|
||||
nflag = 1;
|
||||
arg++;
|
||||
continue;
|
||||
} else {
|
||||
c = process_escape_sequence(&arg);
|
||||
}
|
||||
}
|
||||
|
||||
putchar(c);
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
if (argc > 0)
|
||||
putchar(' ');
|
||||
}
|
||||
if (!nflag)
|
||||
putchar('\n');
|
||||
fflush(stdout);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Kenneth Almquist.
|
||||
*
|
||||
* 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>
|
||||
*
|
||||
* California, Berkeley and its contributors.
|
||||
* 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.
|
||||
*
|
||||
* @(#)echo.c 8.1 (Berkeley) 5/31/93
|
||||
*/
|
||||
+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.
|
||||
*/
|
||||
|
||||
|
||||
@@ -0,0 +1,535 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini expr implementation for busybox
|
||||
*
|
||||
* based on GNU expr Mike Parker.
|
||||
* Copyright (C) 86, 1991-1997, 1999 Free Software Foundation, Inc.
|
||||
*
|
||||
* Busybox modifications
|
||||
* Copyright (c) 2000 Edward Betts <edward@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
|
||||
*
|
||||
*/
|
||||
|
||||
/* This program evaluates expressions. Each token (operator, operand,
|
||||
* parenthesis) of the expression must be a seperate argument. The
|
||||
* parser used is a reasonably general one, though any incarnation of
|
||||
* it is language-specific. It is especially nice for expressions.
|
||||
*
|
||||
* No parse tree is needed; a new node is evaluated immediately.
|
||||
* One function can handle multiple operators all of equal precedence,
|
||||
* provided they all associate ((x op x) op x). */
|
||||
|
||||
/* 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 {
|
||||
integer,
|
||||
string
|
||||
};
|
||||
typedef enum valtype TYPE;
|
||||
|
||||
/* A value is.... */
|
||||
struct valinfo {
|
||||
TYPE type; /* Which kind. */
|
||||
union { /* The value itself. */
|
||||
int i;
|
||||
char *s;
|
||||
} u;
|
||||
};
|
||||
typedef struct valinfo VALUE;
|
||||
|
||||
/* The arguments given to the program, minus the program name. */
|
||||
static char **args;
|
||||
|
||||
static VALUE *docolon (VALUE *sv, VALUE *pv);
|
||||
static VALUE *eval (void);
|
||||
static VALUE *int_value (int i);
|
||||
static VALUE *str_value (char *s);
|
||||
static int nextarg (char *str);
|
||||
static int null (VALUE *v);
|
||||
static int toarith (VALUE *v);
|
||||
static void freev (VALUE *v);
|
||||
static void tostring (VALUE *v);
|
||||
|
||||
int expr_main (int argc, char **argv)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
if (argc == 1) {
|
||||
error_msg_and_die("too few arguments");
|
||||
}
|
||||
|
||||
args = argv + 1;
|
||||
|
||||
v = eval ();
|
||||
if (*args)
|
||||
error_msg_and_die ("syntax error");
|
||||
|
||||
if (v->type == integer)
|
||||
printf ("%d\n", v->u.i);
|
||||
else
|
||||
puts (v->u.s);
|
||||
|
||||
exit (null (v));
|
||||
}
|
||||
|
||||
/* Return a VALUE for I. */
|
||||
|
||||
static VALUE *int_value (int i)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
v = xmalloc (sizeof(VALUE));
|
||||
v->type = integer;
|
||||
v->u.i = i;
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Return a VALUE for S. */
|
||||
|
||||
static VALUE *str_value (char *s)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
v = xmalloc (sizeof(VALUE));
|
||||
v->type = string;
|
||||
v->u.s = strdup (s);
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Free VALUE V, including structure components. */
|
||||
|
||||
static void freev (VALUE *v)
|
||||
{
|
||||
if (v->type == string)
|
||||
free (v->u.s);
|
||||
free (v);
|
||||
}
|
||||
|
||||
/* Return nonzero if V is a null-string or zero-number. */
|
||||
|
||||
static int null (VALUE *v)
|
||||
{
|
||||
switch (v->type) {
|
||||
case integer:
|
||||
return v->u.i == 0;
|
||||
case string:
|
||||
return v->u.s[0] == '\0' || strcmp (v->u.s, "0") == 0;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Coerce V to a string value (can't fail). */
|
||||
|
||||
static void tostring (VALUE *v)
|
||||
{
|
||||
char *temp;
|
||||
|
||||
if (v->type == integer) {
|
||||
temp = xmalloc (4 * (sizeof (int) / sizeof (char)));
|
||||
sprintf (temp, "%d", v->u.i);
|
||||
v->u.s = temp;
|
||||
v->type = string;
|
||||
}
|
||||
}
|
||||
|
||||
/* Coerce V to an integer value. Return 1 on success, 0 on failure. */
|
||||
|
||||
static int toarith (VALUE *v)
|
||||
{
|
||||
int i;
|
||||
|
||||
switch (v->type) {
|
||||
case integer:
|
||||
return 1;
|
||||
case string:
|
||||
i = 0;
|
||||
/* Don't interpret the empty string as an integer. */
|
||||
if (v->u.s == 0)
|
||||
return 0;
|
||||
i = atoi(v->u.s);
|
||||
free (v->u.s);
|
||||
v->u.i = i;
|
||||
v->type = integer;
|
||||
return 1;
|
||||
default:
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Return nonzero if the next token matches STR exactly.
|
||||
STR must not be NULL. */
|
||||
|
||||
static int
|
||||
nextarg (char *str)
|
||||
{
|
||||
if (*args == NULL)
|
||||
return 0;
|
||||
return strcmp (*args, str) == 0;
|
||||
}
|
||||
|
||||
/* The comparison operator handling functions. */
|
||||
|
||||
#define cmpf(name, rel) \
|
||||
static int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (l->type == string || r->type == string) { \
|
||||
tostring (l); \
|
||||
tostring (r); \
|
||||
return strcmp (l->u.s, r->u.s) rel 0; \
|
||||
} \
|
||||
else \
|
||||
return l->u.i rel r->u.i; \
|
||||
}
|
||||
cmpf (less_than, <)
|
||||
cmpf (less_equal, <=)
|
||||
cmpf (equal, ==)
|
||||
cmpf (not_equal, !=)
|
||||
cmpf (greater_equal, >=)
|
||||
cmpf (greater_than, >)
|
||||
|
||||
#undef cmpf
|
||||
|
||||
/* The arithmetic operator handling functions. */
|
||||
|
||||
#define arithf(name, op) \
|
||||
static \
|
||||
int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
error_msg_and_die ("non-numeric argument"); \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
#define arithdivf(name, op) \
|
||||
static int name (l, r) VALUE *l; VALUE *r; \
|
||||
{ \
|
||||
if (!toarith (l) || !toarith (r)) \
|
||||
error_msg_and_die ( "non-numeric argument"); \
|
||||
if (r->u.i == 0) \
|
||||
error_msg_and_die ( "division by zero"); \
|
||||
return l->u.i op r->u.i; \
|
||||
}
|
||||
|
||||
arithf (plus, +)
|
||||
arithf (minus, -)
|
||||
arithf (multiply, *)
|
||||
arithdivf (divide, /)
|
||||
arithdivf (mod, %)
|
||||
|
||||
#undef arithf
|
||||
#undef arithdivf
|
||||
|
||||
/* Do the : operator.
|
||||
SV is the VALUE for the lhs (the string),
|
||||
PV is the VALUE for the rhs (the pattern). */
|
||||
|
||||
static VALUE *docolon (VALUE *sv, VALUE *pv)
|
||||
{
|
||||
VALUE *v;
|
||||
const char *errmsg;
|
||||
struct re_pattern_buffer re_buffer;
|
||||
struct re_registers re_regs;
|
||||
int len;
|
||||
|
||||
tostring (sv);
|
||||
tostring (pv);
|
||||
|
||||
if (pv->u.s[0] == '^') {
|
||||
fprintf (stderr, "\
|
||||
warning: unportable BRE: `%s': using `^' as the first character\n\
|
||||
of a basic regular expression is not portable; it is being ignored",
|
||||
pv->u.s);
|
||||
}
|
||||
|
||||
len = strlen (pv->u.s);
|
||||
memset (&re_buffer, 0, sizeof (re_buffer));
|
||||
memset (&re_regs, 0, sizeof (re_regs));
|
||||
re_buffer.allocated = 2 * len;
|
||||
re_buffer.buffer = (unsigned char *) xmalloc (re_buffer.allocated);
|
||||
re_buffer.translate = 0;
|
||||
re_syntax_options = RE_SYNTAX_POSIX_BASIC;
|
||||
errmsg = re_compile_pattern (pv->u.s, len, &re_buffer);
|
||||
if (errmsg) {
|
||||
error_msg_and_die("%s", errmsg);
|
||||
}
|
||||
|
||||
len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs);
|
||||
if (len >= 0) {
|
||||
/* Were \(...\) used? */
|
||||
if (re_buffer.re_nsub > 0) { /* was (re_regs.start[1] >= 0) */
|
||||
sv->u.s[re_regs.end[1]] = '\0';
|
||||
v = str_value (sv->u.s + re_regs.start[1]);
|
||||
}
|
||||
else
|
||||
v = int_value (len);
|
||||
}
|
||||
else {
|
||||
/* Match failed -- return the right kind of null. */
|
||||
if (re_buffer.re_nsub > 0)
|
||||
v = str_value ("");
|
||||
else
|
||||
v = int_value (0);
|
||||
}
|
||||
free (re_buffer.buffer);
|
||||
return v;
|
||||
}
|
||||
|
||||
/* Handle bare operands and ( expr ) syntax. */
|
||||
|
||||
static VALUE *eval7 (void)
|
||||
{
|
||||
VALUE *v;
|
||||
|
||||
if (!*args)
|
||||
error_msg_and_die ( "syntax error");
|
||||
|
||||
if (nextarg ("(")) {
|
||||
args++;
|
||||
v = eval ();
|
||||
if (!nextarg (")"))
|
||||
error_msg_and_die ( "syntax error");
|
||||
args++;
|
||||
return v;
|
||||
}
|
||||
|
||||
if (nextarg (")"))
|
||||
error_msg_and_die ( "syntax error");
|
||||
|
||||
return str_value (*args++);
|
||||
}
|
||||
|
||||
/* Handle match, substr, index, length, and quote keywords. */
|
||||
|
||||
static VALUE *eval6 (void)
|
||||
{
|
||||
VALUE *l, *r, *v, *i1, *i2;
|
||||
|
||||
if (nextarg ("quote")) {
|
||||
args++;
|
||||
if (!*args)
|
||||
error_msg_and_die ( "syntax error");
|
||||
return str_value (*args++);
|
||||
}
|
||||
else if (nextarg ("length")) {
|
||||
args++;
|
||||
r = eval6 ();
|
||||
tostring (r);
|
||||
v = int_value (strlen (r->u.s));
|
||||
freev (r);
|
||||
return v;
|
||||
}
|
||||
else if (nextarg ("match")) {
|
||||
args++;
|
||||
l = eval6 ();
|
||||
r = eval6 ();
|
||||
v = docolon (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
return v;
|
||||
}
|
||||
else if (nextarg ("index")) {
|
||||
args++;
|
||||
l = eval6 ();
|
||||
r = eval6 ();
|
||||
tostring (l);
|
||||
tostring (r);
|
||||
v = int_value (strcspn (l->u.s, r->u.s) + 1);
|
||||
if (v->u.i == (int) strlen (l->u.s) + 1)
|
||||
v->u.i = 0;
|
||||
freev (l);
|
||||
freev (r);
|
||||
return v;
|
||||
}
|
||||
else if (nextarg ("substr")) {
|
||||
args++;
|
||||
l = eval6 ();
|
||||
i1 = eval6 ();
|
||||
i2 = eval6 ();
|
||||
tostring (l);
|
||||
if (!toarith (i1) || !toarith (i2)
|
||||
|| i1->u.i > (int) strlen (l->u.s)
|
||||
|| i1->u.i <= 0 || i2->u.i <= 0)
|
||||
v = str_value ("");
|
||||
else {
|
||||
v = xmalloc (sizeof(VALUE));
|
||||
v->type = string;
|
||||
v->u.s = strncpy ((char *) xmalloc (i2->u.i + 1),
|
||||
l->u.s + i1->u.i - 1, i2->u.i);
|
||||
v->u.s[i2->u.i] = 0;
|
||||
}
|
||||
freev (l);
|
||||
freev (i1);
|
||||
freev (i2);
|
||||
return v;
|
||||
}
|
||||
else
|
||||
return eval7 ();
|
||||
}
|
||||
|
||||
/* Handle : operator (pattern matching).
|
||||
Calls docolon to do the real work. */
|
||||
|
||||
static VALUE *eval5 (void)
|
||||
{
|
||||
VALUE *l, *r, *v;
|
||||
|
||||
l = eval6 ();
|
||||
while (nextarg (":")) {
|
||||
args++;
|
||||
r = eval6 ();
|
||||
v = docolon (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = v;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/* Handle *, /, % operators. */
|
||||
|
||||
static VALUE *eval4 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
int (*fxn) (), val;
|
||||
|
||||
l = eval5 ();
|
||||
while (1) {
|
||||
if (nextarg ("*"))
|
||||
fxn = multiply;
|
||||
else if (nextarg ("/"))
|
||||
fxn = divide;
|
||||
else if (nextarg ("%"))
|
||||
fxn = mod;
|
||||
else
|
||||
return l;
|
||||
args++;
|
||||
r = eval5 ();
|
||||
val = (*fxn) (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (val);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle +, - operators. */
|
||||
|
||||
static VALUE *eval3 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
int (*fxn) (), val;
|
||||
|
||||
l = eval4 ();
|
||||
while (1) {
|
||||
if (nextarg ("+"))
|
||||
fxn = plus;
|
||||
else if (nextarg ("-"))
|
||||
fxn = minus;
|
||||
else
|
||||
return l;
|
||||
args++;
|
||||
r = eval4 ();
|
||||
val = (*fxn) (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (val);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle comparisons. */
|
||||
|
||||
static VALUE *eval2 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
int (*fxn) (), val;
|
||||
|
||||
l = eval3 ();
|
||||
while (1) {
|
||||
if (nextarg ("<"))
|
||||
fxn = less_than;
|
||||
else if (nextarg ("<="))
|
||||
fxn = less_equal;
|
||||
else if (nextarg ("=") || nextarg ("=="))
|
||||
fxn = equal;
|
||||
else if (nextarg ("!="))
|
||||
fxn = not_equal;
|
||||
else if (nextarg (">="))
|
||||
fxn = greater_equal;
|
||||
else if (nextarg (">"))
|
||||
fxn = greater_than;
|
||||
else
|
||||
return l;
|
||||
args++;
|
||||
r = eval3 ();
|
||||
toarith (l);
|
||||
toarith (r);
|
||||
val = (*fxn) (l, r);
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (val);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle &. */
|
||||
|
||||
static VALUE *eval1 (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
|
||||
l = eval2 ();
|
||||
while (nextarg ("&")) {
|
||||
args++;
|
||||
r = eval2 ();
|
||||
if (null (l) || null (r)) {
|
||||
freev (l);
|
||||
freev (r);
|
||||
l = int_value (0);
|
||||
}
|
||||
else
|
||||
freev (r);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/* Handle |. */
|
||||
|
||||
static VALUE *eval (void)
|
||||
{
|
||||
VALUE *l, *r;
|
||||
|
||||
l = eval1 ();
|
||||
while (nextarg ("|")) {
|
||||
args++;
|
||||
r = eval1 ();
|
||||
if (null (l)) {
|
||||
freev (l);
|
||||
l = r;
|
||||
}
|
||||
else
|
||||
freev (r);
|
||||
}
|
||||
return l;
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini head implementation for busybox
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* 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 <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int head(int len, FILE *fp)
|
||||
{
|
||||
int i;
|
||||
char *input;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if ((input = get_line_from_file(fp)) == NULL)
|
||||
break;
|
||||
fputs(input, stdout);
|
||||
free(input);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* BusyBoxed head(1) */
|
||||
int head_main(int argc, char **argv)
|
||||
{
|
||||
FILE *fp;
|
||||
int need_headers, opt, len = 10, status = EXIT_SUCCESS;
|
||||
|
||||
/* parse argv[] */
|
||||
while ((opt = getopt(argc, argv, "n:")) > 0) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
len = atoi(optarg);
|
||||
if (len >= 1)
|
||||
break;
|
||||
/* fallthrough */
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* get rest of argv[] or stdin if nothing's left */
|
||||
if (argv[optind] == NULL) {
|
||||
head(len, stdin);
|
||||
return status;
|
||||
}
|
||||
|
||||
need_headers = optind != (argc - 1);
|
||||
while (argv[optind]) {
|
||||
if (strcmp(argv[optind], "-") == 0) {
|
||||
fp = stdin;
|
||||
argv[optind] = "standard input";
|
||||
} else {
|
||||
if ((fp = wfopen(argv[optind], "r")) == NULL)
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
if (fp) {
|
||||
if (need_headers) {
|
||||
printf("==> %s <==\n", argv[optind]);
|
||||
}
|
||||
head(len, fp);
|
||||
if (errno) {
|
||||
perror_msg("%s", argv[optind]);
|
||||
status = EXIT_FAILURE;
|
||||
errno = 0;
|
||||
}
|
||||
if (optind < argc - 1)
|
||||
putchar('\n');
|
||||
if (fp != stdin)
|
||||
fclose(fp);
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini hostid implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 Edward Betts <edward@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 <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int hostid_main(int argc, char **argv)
|
||||
{
|
||||
printf("%lx\n", gethostid());
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini id implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Randolph Chung <tausq@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"
|
||||
#include <stdio.h>
|
||||
#include <unistd.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;
|
||||
int opt;
|
||||
|
||||
gid = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "ugrn")) > 0) {
|
||||
switch (opt) {
|
||||
case 'u':
|
||||
no_group++;
|
||||
break;
|
||||
case 'g':
|
||||
no_user++;
|
||||
break;
|
||||
case 'r':
|
||||
print_real++;
|
||||
break;
|
||||
case 'n':
|
||||
name_not_number++;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (no_user && no_group) show_usage();
|
||||
|
||||
if (argv[optind] == NULL) {
|
||||
if (print_real) {
|
||||
my_getpwuid(user, getuid());
|
||||
my_getgrgid(group, getgid());
|
||||
} else {
|
||||
my_getpwuid(user, geteuid());
|
||||
my_getgrgid(group, getegid());
|
||||
}
|
||||
} else {
|
||||
strncpy(user, argv[optind], 8);
|
||||
user[8] = '\0';
|
||||
gid = my_getpwnamegid(user);
|
||||
my_getgrgid(group, gid);
|
||||
}
|
||||
|
||||
pwnam=my_getpwnam(user);
|
||||
grnam=my_getgrnam(group);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/* END CODE */
|
||||
+7
-7
@@ -1,13 +1,13 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char length_usage[] = "length string";
|
||||
|
||||
int
|
||||
length_main(struct FileInfo * i, int argc, char * * argv)
|
||||
extern int length_main(int argc, char **argv)
|
||||
{
|
||||
printf("%d\n", strlen(argv[1]));
|
||||
return 0;
|
||||
if (argc != 2 || **(argv + 1) == '-')
|
||||
show_usage();
|
||||
printf("%lu\n", (long)strlen(argv[1]));
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+121
-42
@@ -1,52 +1,131 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini ln 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 <sys/stat.h>
|
||||
#include <sys/param.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char ln_usage[] = "ln [-s] [-f] original-name additional-name\n"
|
||||
"\n"
|
||||
"\tAdd a new name that refers to the same file as \"original-name\"\n"
|
||||
"\n"
|
||||
"\t-s:\tUse a \"symbolic\" link, instead of a \"hard\" link.\n"
|
||||
"\t-f:\tRemove existing destination files.\n";
|
||||
|
||||
int
|
||||
ln_fn(const struct FileInfo * i)
|
||||
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)
|
||||
{
|
||||
int status = 0;
|
||||
char d[PATH_MAX];
|
||||
const char * destination = i->destination;
|
||||
int status;
|
||||
int src_is_dir;
|
||||
char *src_name;
|
||||
|
||||
if ( !i->makeSymbolicLink && (i->stat.st_mode & S_IFMT) == S_IFDIR ) {
|
||||
fprintf(stderr, "Please use \"ln -s\" to link directories.\n");
|
||||
return 1;
|
||||
}
|
||||
if (link_destname==NULL)
|
||||
return(FALSE);
|
||||
|
||||
/*
|
||||
* If the destination is a directory, create a file within it.
|
||||
*/
|
||||
if ( is_a_directory(i->destination) ) {
|
||||
destination = join_paths(
|
||||
d
|
||||
,i->destination
|
||||
,&i->source[i->directoryLength]);
|
||||
}
|
||||
src_name = (char *) xmalloc(strlen(link_srcname)+strlen(link_destname)+1);
|
||||
|
||||
if ( i->force )
|
||||
status = ( unlink(destination) && errno != ENOENT );
|
||||
|
||||
if ( status == 0 ) {
|
||||
if ( i->makeSymbolicLink )
|
||||
status = symlink(i->source, destination);
|
||||
else
|
||||
status = link(i->source, destination);
|
||||
}
|
||||
|
||||
if ( status != 0 ) {
|
||||
name_and_error(destination);
|
||||
return 1;
|
||||
}
|
||||
if (link_srcname==NULL)
|
||||
strcpy(src_name, link_destname);
|
||||
else
|
||||
return 0;
|
||||
strcpy(src_name, link_srcname);
|
||||
|
||||
if (flag&LN_NODEREFERENCE)
|
||||
src_is_dir = is_directory(src_name, TRUE, NULL);
|
||||
else
|
||||
src_is_dir = is_directory(src_name, FALSE, NULL);
|
||||
|
||||
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(src_name);
|
||||
|
||||
if (flag&LN_SYMLINK)
|
||||
status = symlink(link_destname, src_name);
|
||||
else
|
||||
status = link(link_destname, src_name);
|
||||
|
||||
if (status != 0) {
|
||||
perror_msg(src_name);
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
extern int ln_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
int flag = 0;
|
||||
int opt;
|
||||
|
||||
/* Parse any options */
|
||||
while ((opt=getopt(argc, argv, "sfn")) != -1) {
|
||||
switch(opt) {
|
||||
case 's':
|
||||
flag |= LN_SYMLINK;
|
||||
break;
|
||||
case 'f':
|
||||
flag |= LN_FORCE;
|
||||
break;
|
||||
case 'n':
|
||||
flag |= LN_NODEREFERENCE;
|
||||
break;
|
||||
default:
|
||||
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++;
|
||||
}
|
||||
exit(status);
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -0,0 +1,41 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini logname implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 Edward Betts <edward@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 <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int logname_main(int argc, char **argv)
|
||||
{
|
||||
char user[9];
|
||||
|
||||
if (argc > 1)
|
||||
show_usage();
|
||||
|
||||
my_getpwuid(user, geteuid());
|
||||
if (*user) {
|
||||
puts(user);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
error_msg_and_die("no login name");
|
||||
}
|
||||
+823
-431
File diff suppressed because it is too large.
Load diff
+1144
File diff suppressed because it is too large.
Load diff
+56
-50
@@ -1,58 +1,64 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini mkdir implementation for busybox
|
||||
*
|
||||
* 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
|
||||
* 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 <errno.h>
|
||||
#include <sys/param.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
const char mkdir_usage[] = "mkdir [-m mode] directory [directory ...]\n"
|
||||
"\tCreate directories.\n"
|
||||
"\n"
|
||||
"\t-m mode:\tSpecifiy the mode for the new directory\n"
|
||||
"\t\tunder the argument directory.";
|
||||
#include "busybox.h"
|
||||
|
||||
/*make directories skipping the last part of the path. Used here and by untar*/
|
||||
int mkdir_until(const char *fpath, const struct FileInfo * fi)
|
||||
extern int mkdir_main (int argc, char **argv)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
char * s = path;
|
||||
|
||||
strcpy(path, fpath);
|
||||
if ( s[0] == '\0' && s[1] == '\0' ) {
|
||||
usage(mkdir_usage);
|
||||
return 1;
|
||||
}
|
||||
s++;
|
||||
while ( *s != '\0' ) {
|
||||
if ( *s == '/' ) {
|
||||
int status;
|
||||
|
||||
*s = '\0';
|
||||
status = mkdir(path, (fi?fi->orWithMode:0700) );
|
||||
*s = '/';
|
||||
|
||||
if ( status != 0 ) {
|
||||
if ( errno != EEXIST ) {
|
||||
name_and_error(fpath);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
mode_t mode = -1;
|
||||
int flags = 0;
|
||||
int status = 0;
|
||||
int i, opt;
|
||||
|
||||
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 ();
|
||||
}
|
||||
s++;
|
||||
}
|
||||
return 0;
|
||||
|
||||
if (optind == argc)
|
||||
show_usage ();
|
||||
|
||||
for (i = optind; i < argc; i++)
|
||||
if (make_directory (argv[i], mode, flags) < 0)
|
||||
status = 1;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int
|
||||
mkdir_fn(const struct FileInfo * i)
|
||||
{
|
||||
if ( i->makeParentDirectories ) {
|
||||
if(mkdir_until(i->source, i)) return 1;
|
||||
}
|
||||
|
||||
if ( mkdir(i->source, i->orWithMode) != 0 && errno != EEXIST ) {
|
||||
name_and_error(i->source);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini mkfifo implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999 by Randolph Chung <tausq@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 <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int mkfifo_main(int argc, char **argv)
|
||||
{
|
||||
char *thisarg;
|
||||
mode_t mode = 0666;
|
||||
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse any options */
|
||||
while (argc > 1) {
|
||||
if (**argv != '-')
|
||||
show_usage();
|
||||
thisarg = *argv;
|
||||
thisarg++;
|
||||
switch (*thisarg) {
|
||||
case 'm':
|
||||
argc--;
|
||||
argv++;
|
||||
parse_mode(*argv, &mode);
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc < 1 || *argv[0] == '-')
|
||||
show_usage();
|
||||
if (mkfifo(*argv, mode) < 0)
|
||||
perror_msg_and_die("mkfifo");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+69
-29
@@ -1,24 +1,67 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini mknod implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
|
||||
*
|
||||
* 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 <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char mknod_usage[] = "mknod file b|c|u|p major minor\n"
|
||||
"\tMake special files.\n"
|
||||
"\n"
|
||||
"\tb:\tMake a block (buffered) device.\n"
|
||||
"\tc or u:\tMake a character (un-buffered) device.\n"
|
||||
"\tp:\tMake a named pipe. Major and minor are ignored for named pipes.\n";
|
||||
|
||||
int
|
||||
mknod_main(struct FileInfo * i, int argc, char * * argv)
|
||||
int mknod_main(int argc, char **argv)
|
||||
{
|
||||
mode_t mode = 0;
|
||||
dev_t dev = 0;
|
||||
char *thisarg;
|
||||
mode_t mode = 0;
|
||||
mode_t perm = 0666;
|
||||
dev_t dev = 0;
|
||||
|
||||
switch(argv[2][0]) {
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
/* Parse any options */
|
||||
while (argc > 1) {
|
||||
if (**argv != '-')
|
||||
break;
|
||||
thisarg = *argv;
|
||||
thisarg++;
|
||||
switch (*thisarg) {
|
||||
case 'm':
|
||||
argc--;
|
||||
argv++;
|
||||
parse_mode(*argv, &perm);
|
||||
umask(0);
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
if (argc != 4 && argc != 2) {
|
||||
show_usage();
|
||||
}
|
||||
switch (argv[1][0]) {
|
||||
case 'c':
|
||||
case 'u':
|
||||
mode = S_IFCHR;
|
||||
@@ -28,25 +71,22 @@ mknod_main(struct FileInfo * i, int argc, char * * argv)
|
||||
break;
|
||||
case 'p':
|
||||
mode = S_IFIFO;
|
||||
if (argc!=2) {
|
||||
show_usage();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
usage(mknod_usage);
|
||||
return 1;
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if ( mode == S_IFCHR || mode == S_IFBLK ) {
|
||||
dev = (atoi(argv[3]) << 8) | atoi(argv[4]);
|
||||
if ( argc != 5 ) {
|
||||
usage(mknod_usage);
|
||||
return 1;
|
||||
}
|
||||
if (mode == S_IFCHR || mode == S_IFBLK) {
|
||||
dev = (atoi(argv[2]) << 8) | atoi(argv[3]);
|
||||
}
|
||||
|
||||
mode |= 0666;
|
||||
mode |= perm;
|
||||
|
||||
if ( mknod(argv[1], mode, dev) != 0 ) {
|
||||
name_and_error(argv[1]);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
if (mknod(argv[0], mode, dev) != 0)
|
||||
perror_msg_and_die("%s", argv[0]);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
+159
-29
@@ -1,38 +1,168 @@
|
||||
#include "internal.h"
|
||||
#include <stdio.h>
|
||||
/* 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>
|
||||
|
||||
const char mv_usage[] = "mv source-file destination-file\n"
|
||||
"\t\tmv source-file [source-file ...] destination-directory\n"
|
||||
"\n"
|
||||
"\tMove the source files to the destination.\n"
|
||||
"\n";
|
||||
#include "busybox.h"
|
||||
|
||||
extern int
|
||||
mv_fn(const struct FileInfo * i)
|
||||
static int flags;
|
||||
|
||||
static int manual_rename(const char *source, const char *dest)
|
||||
{
|
||||
struct stat destination_stat;
|
||||
char d[1024];
|
||||
struct FileInfo n;
|
||||
struct stat source_stat;
|
||||
struct stat dest_stat;
|
||||
int source_exists = 1;
|
||||
int dest_exists = 1;
|
||||
|
||||
if ( stat(i->destination, &destination_stat) == 0 ) {
|
||||
if ( i->stat.st_ino == destination_stat.st_ino
|
||||
&& i->stat.st_dev == destination_stat.st_dev )
|
||||
return 0; /* Move file to itself. */
|
||||
if (stat(source, &source_stat) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
perror_msg("unable to stat `%s'", source);
|
||||
return -1;
|
||||
}
|
||||
source_exists = 0;
|
||||
}
|
||||
if ( (destination_stat.st_mode & S_IFMT) == S_IFDIR ) {
|
||||
n = *i;
|
||||
n.destination = join_paths(d, i->destination, basename(i->source));
|
||||
i = &n;
|
||||
|
||||
if (stat(dest, &dest_stat) < 0) {
|
||||
if (errno != ENOENT) {
|
||||
perror_msg("unable to stat `%s'", dest);
|
||||
return -1;
|
||||
}
|
||||
dest_exists = 0;
|
||||
}
|
||||
if ( rename(i->source, i->destination) == 0 )
|
||||
return 0;
|
||||
else if ( errno == EXDEV && is_a_directory(i->source) ) {
|
||||
fprintf(stderr
|
||||
,"%s: Can't move directory across filesystems.\n"
|
||||
,i->source);
|
||||
return 1;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
return cp_fn(i);
|
||||
|
||||
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;
|
||||
}
|
||||
+281
-357
@@ -1,8 +1,4 @@
|
||||
// I may still need some more cleaning...fix my error checking
|
||||
|
||||
#include "internal.h"
|
||||
#ifdef BB_PRINTF
|
||||
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/* printf - format and print data
|
||||
Copyright (C) 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
|
||||
|
||||
@@ -47,25 +43,23 @@
|
||||
to convert all of the given arguments.
|
||||
|
||||
David MacKenzie <djm@gnu.ai.mit.edu> */
|
||||
|
||||
|
||||
|
||||
// 19990508 Busy Boxed! Dave Cinege
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
#include <libintl.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)
|
||||
@@ -88,444 +82,374 @@
|
||||
#if !defined(S_ISSOCK) && defined(S_IFSOCK)
|
||||
# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
|
||||
#endif
|
||||
#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
|
||||
#if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */
|
||||
# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
|
||||
# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
|
||||
#endif
|
||||
#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
|
||||
#if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */
|
||||
# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
|
||||
#endif
|
||||
|
||||
#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')
|
||||
#define octtobin(c) ((c) - '0')
|
||||
|
||||
char *xmalloc ();
|
||||
static double xstrtod __P((char *s));
|
||||
static int print_esc __P((char *escstart));
|
||||
static int print_formatted __P((char *format, int argc, char **argv));
|
||||
static long xstrtol __P((char *s));
|
||||
static unsigned long xstrtoul __P((char *s));
|
||||
static void print_direc
|
||||
__P(
|
||||
|
||||
static double xstrtod __P ((char *s));
|
||||
static int print_esc __P ((char *escstart));
|
||||
static int print_formatted __P ((char *format, int argc, char **argv));
|
||||
static long xstrtol __P ((char *s));
|
||||
static unsigned long xstrtoul __P ((char *s));
|
||||
static void print_direc __P ((char *start, size_t length, int field_width, int precision, char *argument));
|
||||
static void print_esc_char __P ((int c));
|
||||
static void print_esc_string __P ((char *str));
|
||||
static void verify __P ((char *s, char *end));
|
||||
(char *start, size_t length, int field_width, int precision,
|
||||
char *argument));
|
||||
static void print_esc_char __P((int c));
|
||||
static void print_esc_string __P((char *str));
|
||||
static void verify __P((char *s, char *end));
|
||||
|
||||
/* The value to return to the calling program. */
|
||||
static int exit_status;
|
||||
|
||||
const char printf_usage[] = "Usage: printf format [argument...]\n";
|
||||
|
||||
int
|
||||
printf_main(struct FileInfo * i, int argc, char * * argv)
|
||||
int printf_main(int argc, char **argv)
|
||||
{
|
||||
char *format;
|
||||
int args_used;
|
||||
char *format;
|
||||
int args_used;
|
||||
|
||||
exit_status = 0;
|
||||
exit_status = 0;
|
||||
if (argc <= 1 || **(argv + 1) == '-') {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
format = argv[1];
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
format = argv[1];
|
||||
argc -= 2;
|
||||
argv += 2;
|
||||
|
||||
do
|
||||
{
|
||||
args_used = print_formatted (format, argc, argv);
|
||||
argc -= args_used;
|
||||
argv += args_used;
|
||||
}
|
||||
while (args_used > 0 && argc > 0);
|
||||
do {
|
||||
args_used = print_formatted(format, argc, argv);
|
||||
argc -= args_used;
|
||||
argv += args_used;
|
||||
}
|
||||
while (args_used > 0 && argc > 0);
|
||||
|
||||
/*
|
||||
if (argc > 0)
|
||||
fprintf(stderr, "excess args ignored");
|
||||
*/
|
||||
|
||||
exit (exit_status);
|
||||
return(exit_status);
|
||||
}
|
||||
|
||||
/* Print the text in FORMAT, using ARGV (with ARGC elements) for
|
||||
arguments to any `%' directives.
|
||||
Return the number of elements of ARGV used. */
|
||||
|
||||
static int
|
||||
print_formatted (char *format, int argc, char **argv)
|
||||
static int print_formatted(char *format, int argc, char **argv)
|
||||
{
|
||||
int save_argc = argc; /* Preserve original value. */
|
||||
char *f; /* Pointer into `format'. */
|
||||
char *direc_start; /* Start of % directive. */
|
||||
size_t direc_length; /* Length of % directive. */
|
||||
int field_width; /* Arg to first '*', or -1 if none. */
|
||||
int precision; /* Arg to second '*', or -1 if none. */
|
||||
int save_argc = argc; /* Preserve original value. */
|
||||
char *f; /* Pointer into `format'. */
|
||||
char *direc_start; /* Start of % directive. */
|
||||
size_t direc_length; /* Length of % directive. */
|
||||
int field_width; /* Arg to first '*', or -1 if none. */
|
||||
int precision; /* Arg to second '*', or -1 if none. */
|
||||
|
||||
for (f = format; *f; ++f)
|
||||
{
|
||||
switch (*f)
|
||||
{
|
||||
case '%':
|
||||
direc_start = f++;
|
||||
direc_length = 1;
|
||||
field_width = precision = -1;
|
||||
if (*f == '%')
|
||||
{
|
||||
putchar ('%');
|
||||
break;
|
||||
}
|
||||
if (*f == 'b')
|
||||
{
|
||||
if (argc > 0)
|
||||
{
|
||||
print_esc_string (*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (strchr ("-+ #", *f))
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
if (*f == '*')
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
if (argc > 0)
|
||||
{
|
||||
field_width = xstrtoul (*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
field_width = 0;
|
||||
}
|
||||
else
|
||||
while (ISDIGIT (*f))
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
if (*f == '.')
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
if (*f == '*')
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
if (argc > 0)
|
||||
{
|
||||
precision = xstrtoul (*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
precision = 0;
|
||||
}
|
||||
else
|
||||
while (ISDIGIT (*f))
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
}
|
||||
if (*f == 'l' || *f == 'L' || *f == 'h')
|
||||
{
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
/*
|
||||
if (!strchr ("diouxXfeEgGcs", *f))
|
||||
fprintf(stderr, "%%%c: invalid directive", *f);
|
||||
*/
|
||||
++direc_length;
|
||||
if (argc > 0)
|
||||
{
|
||||
print_direc (direc_start, direc_length, field_width,
|
||||
precision, *argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
else
|
||||
print_direc (direc_start, direc_length, field_width,
|
||||
precision, "");
|
||||
break;
|
||||
for (f = format; *f; ++f) {
|
||||
switch (*f) {
|
||||
case '%':
|
||||
direc_start = f++;
|
||||
direc_length = 1;
|
||||
field_width = precision = -1;
|
||||
if (*f == '%') {
|
||||
putchar('%');
|
||||
break;
|
||||
}
|
||||
if (*f == 'b') {
|
||||
if (argc > 0) {
|
||||
print_esc_string(*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (strchr("-+ #", *f)) {
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
if (*f == '*') {
|
||||
++f;
|
||||
++direc_length;
|
||||
if (argc > 0) {
|
||||
field_width = xstrtoul(*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
} else
|
||||
field_width = 0;
|
||||
} else
|
||||
while (ISDIGIT(*f)) {
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
if (*f == '.') {
|
||||
++f;
|
||||
++direc_length;
|
||||
if (*f == '*') {
|
||||
++f;
|
||||
++direc_length;
|
||||
if (argc > 0) {
|
||||
precision = xstrtoul(*argv);
|
||||
++argv;
|
||||
--argc;
|
||||
} else
|
||||
precision = 0;
|
||||
} else
|
||||
while (ISDIGIT(*f)) {
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
}
|
||||
if (*f == 'l' || *f == 'L' || *f == 'h') {
|
||||
++f;
|
||||
++direc_length;
|
||||
}
|
||||
/*
|
||||
if (!strchr ("diouxXfeEgGcs", *f))
|
||||
fprintf(stderr, "%%%c: invalid directive", *f);
|
||||
*/
|
||||
++direc_length;
|
||||
if (argc > 0) {
|
||||
print_direc(direc_start, direc_length, field_width,
|
||||
precision, *argv);
|
||||
++argv;
|
||||
--argc;
|
||||
} else
|
||||
print_direc(direc_start, direc_length, field_width,
|
||||
precision, "");
|
||||
break;
|
||||
|
||||
case '\\':
|
||||
f += print_esc (f);
|
||||
break;
|
||||
case '\\':
|
||||
f += print_esc(f);
|
||||
break;
|
||||
|
||||
default:
|
||||
putchar (*f);
|
||||
default:
|
||||
putchar(*f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return save_argc - argc;
|
||||
return save_argc - argc;
|
||||
}
|
||||
|
||||
/* Print a \ escape sequence starting at ESCSTART.
|
||||
Return the number of characters in the escape sequence
|
||||
besides the backslash. */
|
||||
|
||||
static int
|
||||
print_esc (char *escstart)
|
||||
static int print_esc(char *escstart)
|
||||
{
|
||||
register char *p = escstart + 1;
|
||||
int esc_value = 0; /* Value of \nnn escape. */
|
||||
int esc_length; /* Length of \nnn escape. */
|
||||
register char *p = escstart + 1;
|
||||
int esc_value = 0; /* Value of \nnn escape. */
|
||||
int esc_length; /* Length of \nnn escape. */
|
||||
|
||||
/* \0ooo and \xhhh escapes have maximum length of 3 chars. */
|
||||
if (*p == 'x')
|
||||
{
|
||||
for (esc_length = 0, ++p;
|
||||
esc_length < 3 && ISXDIGIT (*p);
|
||||
++esc_length, ++p)
|
||||
esc_value = esc_value * 16 + hextobin (*p);
|
||||
/* \0ooo and \xhhh escapes have maximum length of 3 chars. */
|
||||
if (*p == 'x') {
|
||||
for (esc_length = 0, ++p;
|
||||
esc_length < 3 && ISXDIGIT(*p); ++esc_length, ++p)
|
||||
esc_value = esc_value * 16 + hextobin(*p);
|
||||
/* if (esc_length == 0)
|
||||
fprintf(stderr, "missing hex in esc");
|
||||
*/
|
||||
putchar (esc_value);
|
||||
}
|
||||
else if (*p == '0')
|
||||
{
|
||||
for (esc_length = 0, ++p;
|
||||
esc_length < 3 && isodigit (*p);
|
||||
++esc_length, ++p)
|
||||
esc_value = esc_value * 8 + octtobin (*p);
|
||||
putchar (esc_value);
|
||||
}
|
||||
else if (strchr ("\"\\abcfnrtv", *p))
|
||||
print_esc_char (*p++);
|
||||
putchar(esc_value);
|
||||
} else if (*p == '0') {
|
||||
for (esc_length = 0, ++p;
|
||||
esc_length < 3 && isodigit(*p); ++esc_length, ++p)
|
||||
esc_value = esc_value * 8 + octtobin(*p);
|
||||
putchar(esc_value);
|
||||
} else if (strchr("\"\\abcfnrtv", *p))
|
||||
print_esc_char(*p++);
|
||||
/* else
|
||||
fprintf(stderr, "\\%c: invalid esc", *p);
|
||||
*/
|
||||
return p - escstart - 1;
|
||||
return p - escstart - 1;
|
||||
}
|
||||
|
||||
/* Output a single-character \ escape. */
|
||||
|
||||
static void
|
||||
print_esc_char (int c)
|
||||
static void print_esc_char(int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 'a': /* Alert. */
|
||||
putchar (7);
|
||||
break;
|
||||
case 'b': /* Backspace. */
|
||||
putchar (8);
|
||||
break;
|
||||
case 'c': /* Cancel the rest of the output. */
|
||||
exit (0);
|
||||
break;
|
||||
case 'f': /* Form feed. */
|
||||
putchar (12);
|
||||
break;
|
||||
case 'n': /* New line. */
|
||||
putchar (10);
|
||||
break;
|
||||
case 'r': /* Carriage return. */
|
||||
putchar (13);
|
||||
break;
|
||||
case 't': /* Horizontal tab. */
|
||||
putchar (9);
|
||||
break;
|
||||
case 'v': /* Vertical tab. */
|
||||
putchar (11);
|
||||
break;
|
||||
default:
|
||||
putchar (c);
|
||||
break;
|
||||
}
|
||||
switch (c) {
|
||||
case 'a': /* Alert. */
|
||||
putchar(7);
|
||||
break;
|
||||
case 'b': /* Backspace. */
|
||||
putchar(8);
|
||||
break;
|
||||
case 'c': /* Cancel the rest of the output. */
|
||||
exit(0);
|
||||
break;
|
||||
case 'f': /* Form feed. */
|
||||
putchar(12);
|
||||
break;
|
||||
case 'n': /* New line. */
|
||||
putchar(10);
|
||||
break;
|
||||
case 'r': /* Carriage return. */
|
||||
putchar(13);
|
||||
break;
|
||||
case 't': /* Horizontal tab. */
|
||||
putchar(9);
|
||||
break;
|
||||
case 'v': /* Vertical tab. */
|
||||
putchar(11);
|
||||
break;
|
||||
default:
|
||||
putchar(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Print string STR, evaluating \ escapes. */
|
||||
|
||||
static void
|
||||
print_esc_string (char *str)
|
||||
static void print_esc_string(char *str)
|
||||
{
|
||||
for (; *str; str++)
|
||||
if (*str == '\\')
|
||||
str += print_esc (str);
|
||||
else
|
||||
putchar (*str);
|
||||
for (; *str; str++)
|
||||
if (*str == '\\')
|
||||
str += print_esc(str);
|
||||
else
|
||||
putchar(*str);
|
||||
}
|
||||
|
||||
static void
|
||||
print_direc (char *start, size_t length, int field_width, int precision, char *argument)
|
||||
print_direc(char *start, size_t length, int field_width, int precision,
|
||||
char *argument)
|
||||
{
|
||||
char *p; /* Null-terminated copy of % directive. */
|
||||
char *p; /* Null-terminated copy of % directive. */
|
||||
|
||||
p = xmalloc ((unsigned) (length + 1));
|
||||
strncpy (p, start, length);
|
||||
p[length] = 0;
|
||||
p = xmalloc((unsigned) (length + 1));
|
||||
strncpy(p, start, length);
|
||||
p[length] = 0;
|
||||
|
||||
switch (p[length - 1])
|
||||
{
|
||||
case 'd':
|
||||
case 'i':
|
||||
if (field_width < 0)
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, xstrtol (argument));
|
||||
else
|
||||
printf (p, precision, xstrtol (argument));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, field_width, xstrtol (argument));
|
||||
else
|
||||
printf (p, field_width, precision, xstrtol (argument));
|
||||
}
|
||||
break;
|
||||
switch (p[length - 1]) {
|
||||
case 'd':
|
||||
case 'i':
|
||||
if (field_width < 0) {
|
||||
if (precision < 0)
|
||||
printf(p, xstrtol(argument));
|
||||
else
|
||||
printf(p, precision, xstrtol(argument));
|
||||
} else {
|
||||
if (precision < 0)
|
||||
printf(p, field_width, xstrtol(argument));
|
||||
else
|
||||
printf(p, field_width, precision, xstrtol(argument));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
case 'u':
|
||||
case 'x':
|
||||
case 'X':
|
||||
if (field_width < 0)
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, xstrtoul (argument));
|
||||
else
|
||||
printf (p, precision, xstrtoul (argument));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, field_width, xstrtoul (argument));
|
||||
else
|
||||
printf (p, field_width, precision, xstrtoul (argument));
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
case 'u':
|
||||
case 'x':
|
||||
case 'X':
|
||||
if (field_width < 0) {
|
||||
if (precision < 0)
|
||||
printf(p, xstrtoul(argument));
|
||||
else
|
||||
printf(p, precision, xstrtoul(argument));
|
||||
} else {
|
||||
if (precision < 0)
|
||||
printf(p, field_width, xstrtoul(argument));
|
||||
else
|
||||
printf(p, field_width, precision, xstrtoul(argument));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'g':
|
||||
case 'G':
|
||||
if (field_width < 0)
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, xstrtod (argument));
|
||||
else
|
||||
printf (p, precision, xstrtod (argument));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, field_width, xstrtod (argument));
|
||||
else
|
||||
printf (p, field_width, precision, xstrtod (argument));
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
case 'e':
|
||||
case 'E':
|
||||
case 'g':
|
||||
case 'G':
|
||||
if (field_width < 0) {
|
||||
if (precision < 0)
|
||||
printf(p, xstrtod(argument));
|
||||
else
|
||||
printf(p, precision, xstrtod(argument));
|
||||
} else {
|
||||
if (precision < 0)
|
||||
printf(p, field_width, xstrtod(argument));
|
||||
else
|
||||
printf(p, field_width, precision, xstrtod(argument));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
printf (p, *argument);
|
||||
break;
|
||||
case 'c':
|
||||
printf(p, *argument);
|
||||
break;
|
||||
|
||||
case 's':
|
||||
if (field_width < 0)
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, argument);
|
||||
else
|
||||
printf (p, precision, argument);
|
||||
case 's':
|
||||
if (field_width < 0) {
|
||||
if (precision < 0)
|
||||
printf(p, argument);
|
||||
else
|
||||
printf(p, precision, argument);
|
||||
} else {
|
||||
if (precision < 0)
|
||||
printf(p, field_width, argument);
|
||||
else
|
||||
printf(p, field_width, precision, argument);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (precision < 0)
|
||||
printf (p, field_width, argument);
|
||||
else
|
||||
printf (p, field_width, precision, argument);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
free (p);
|
||||
free(p);
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
xstrtoul (char *s)
|
||||
static unsigned long xstrtoul(char *s)
|
||||
{
|
||||
char *end;
|
||||
unsigned long val;
|
||||
char *end;
|
||||
unsigned long val;
|
||||
|
||||
errno = 0;
|
||||
val = strtoul (s, &end, 0);
|
||||
verify (s, end);
|
||||
return val;
|
||||
errno = 0;
|
||||
val = strtoul(s, &end, 0);
|
||||
verify(s, end);
|
||||
return val;
|
||||
}
|
||||
|
||||
static long
|
||||
xstrtol (char *s)
|
||||
static long xstrtol(char *s)
|
||||
{
|
||||
char *end;
|
||||
long val;
|
||||
char *end;
|
||||
long val;
|
||||
|
||||
errno = 0;
|
||||
val = strtol (s, &end, 0);
|
||||
verify (s, end);
|
||||
return val;
|
||||
errno = 0;
|
||||
val = strtol(s, &end, 0);
|
||||
verify(s, end);
|
||||
return val;
|
||||
}
|
||||
|
||||
static double
|
||||
xstrtod (char *s)
|
||||
static double xstrtod(char *s)
|
||||
{
|
||||
char *end;
|
||||
double val;
|
||||
char *end;
|
||||
double val;
|
||||
|
||||
errno = 0;
|
||||
val = strtod (s, &end);
|
||||
verify (s, end);
|
||||
return val;
|
||||
errno = 0;
|
||||
val = strtod(s, &end);
|
||||
verify(s, end);
|
||||
return val;
|
||||
}
|
||||
|
||||
static void
|
||||
verify (char *s, char *end)
|
||||
static void verify(char *s, char *end)
|
||||
{
|
||||
if (errno)
|
||||
{
|
||||
fprintf(stderr, "%s", s);
|
||||
exit_status = 1;
|
||||
}
|
||||
else if (*end)
|
||||
{
|
||||
/*
|
||||
if (s == end)
|
||||
fprintf(stderr, "%s: expected numeric", s);
|
||||
else
|
||||
fprintf(stderr, "%s: not completely converted", s);
|
||||
*/
|
||||
exit_status = 1;
|
||||
}
|
||||
if (errno) {
|
||||
fprintf(stderr, "%s", s);
|
||||
exit_status = 1;
|
||||
} else if (*end) {
|
||||
/*
|
||||
if (s == end)
|
||||
fprintf(stderr, "%s: expected numeric", s);
|
||||
else
|
||||
fprintf(stderr, "%s: not completely converted", s);
|
||||
*/
|
||||
exit_status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+39
-13
@@ -1,18 +1,44 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini pwd implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
/* getopt not needed */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char pwd_usage[] = "Print the current directory.\n";
|
||||
|
||||
extern int
|
||||
pwd_main(struct FileInfo * i, int argc, char * * argv)
|
||||
extern int pwd_main(int argc, char **argv)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
if ( getcwd(buf, sizeof(buf)) == NULL ) {
|
||||
name_and_error("get working directory");
|
||||
return 1;
|
||||
static char *buf;
|
||||
|
||||
buf = xgetcwd(buf);
|
||||
|
||||
if (buf != NULL) {
|
||||
puts(buf);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
printf("%s\n", buf);
|
||||
return 0;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
+71
-24
@@ -1,30 +1,77 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini rm implementation for busybox
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* 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 <time.h>
|
||||
#include <utime.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char rm_usage[] = "rm [-r] file [file ...]\n"
|
||||
"\n"
|
||||
"\tDelete files.\n"
|
||||
"\n"
|
||||
"\t-r:\tRecursively remove files and directories.\n";
|
||||
|
||||
extern int
|
||||
rm_main(struct FileInfo * i, int argc, char * * argv)
|
||||
extern int rm_main(int argc, char **argv)
|
||||
{
|
||||
i->processDirectoriesAfterTheirContents = 1;
|
||||
return monadic_main(i, argc, argv);
|
||||
}
|
||||
int status = 0;
|
||||
int opt;
|
||||
int flags = 0;
|
||||
int i;
|
||||
|
||||
extern int
|
||||
rm_fn(const struct FileInfo * i)
|
||||
{
|
||||
if ( i->recursive
|
||||
&& !i->isSymbolicLink
|
||||
&& (i->stat.st_mode & S_IFMT) == S_IFDIR )
|
||||
return rmdir_fn(i);
|
||||
else if ( unlink(i->source) != 0 && errno != ENOENT && !i->force ) {
|
||||
name_and_error(i->source);
|
||||
return 1;
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
|
||||
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;
|
||||
}
|
||||
+40
-12
@@ -1,17 +1,45 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini rmdir 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 <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char rmdir_usage[] = "rmdir directory [directory ...]\n"
|
||||
"\n"
|
||||
"\tDelete directories.\n";
|
||||
|
||||
extern int
|
||||
rmdir_fn(const struct FileInfo * i)
|
||||
extern int rmdir_main(int argc, char **argv)
|
||||
{
|
||||
if ( rmdir(i->source) != 0 && errno != ENOENT && !i->force ) {
|
||||
name_and_error(i->source);
|
||||
return 1;
|
||||
int status = EXIT_SUCCESS;
|
||||
|
||||
if (argc == 1 || **(argv + 1) == '-')
|
||||
show_usage();
|
||||
|
||||
while (--argc > 0) {
|
||||
if (rmdir(*(++argv)) == -1) {
|
||||
perror_msg("%s", *argv);
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
return status;
|
||||
}
|
||||
+34
-11
@@ -1,15 +1,38 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini sleep implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
|
||||
*
|
||||
* 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 <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char sleep_usage[] = "sleep seconds\n"
|
||||
"\n"
|
||||
"\tPause program execution for the given number of seconds.\n";
|
||||
|
||||
extern int
|
||||
sleep_main(struct FileInfo * i, int argc, char * * argv)
|
||||
extern int sleep_main(int argc, char **argv)
|
||||
{
|
||||
if ( sleep(atoi(argv[1])) != 0 )
|
||||
return -1;
|
||||
else
|
||||
return 0;
|
||||
if ((argc < 2) || (**(argv + 1) == '-')) {
|
||||
show_usage();
|
||||
}
|
||||
|
||||
if (sleep(atoi(*(++argv))) != 0)
|
||||
perror_msg_and_die("sleep");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini sort 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 <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int compare_ascii(const void *x, const void *y)
|
||||
{
|
||||
return strcmp(*(char **)x, *(char **)y);
|
||||
}
|
||||
|
||||
static int compare_numeric(const void *x, const void *y)
|
||||
{
|
||||
int z = atoi(*(char **)x) - atoi(*(char **)y);
|
||||
return z ? z : strcmp(*(char **)x, *(char **)y);
|
||||
}
|
||||
|
||||
int sort_main(int argc, char **argv)
|
||||
{
|
||||
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
|
||||
|
||||
while ((opt = getopt(argc, argv, "nru")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
compare = compare_numeric;
|
||||
break;
|
||||
#ifdef BB_FEATURE_SORT_REVERSE
|
||||
case 'r':
|
||||
reverse = TRUE;
|
||||
break;
|
||||
#endif
|
||||
#ifdef BB_FEATURE_SORT_UNIQUE
|
||||
case 'u':
|
||||
unique = TRUE;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* read the input */
|
||||
for (i = optind; i == optind || i < argc; i++) {
|
||||
if (argv[i] == NULL)
|
||||
fp = stdin;
|
||||
else
|
||||
fp = xfopen(argv[i], "r");
|
||||
|
||||
while ((line = get_line_from_file(fp)) != NULL) {
|
||||
lines = xrealloc(lines, sizeof(char *) * (nlines + 1));
|
||||
chomp(line);
|
||||
lines[nlines++] = line;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
+1376
File diff suppressed because it is too large.
Load diff
+31
-7
@@ -1,11 +1,35 @@
|
||||
#include "internal.h"
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini sync implementation for busybox
|
||||
*
|
||||
*
|
||||
* Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
const char sync_usage[] = "sync\n"
|
||||
"\n"
|
||||
"\tWrite all buffered filesystem blocks to disk.\n";
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int
|
||||
sync_main(struct FileInfo * i, int argc, char * * argv)
|
||||
extern int sync_main(int argc, char **argv)
|
||||
{
|
||||
return sync();
|
||||
if (argc > 1 && **(argv + 1) == '-')
|
||||
show_usage();
|
||||
sync();
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* 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 <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static const struct suffix_mult tail_suffixes[] = {
|
||||
{ "b", 512 },
|
||||
{ "k", 1024 },
|
||||
{ "m", 1048576 },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static const int BYTES = 0;
|
||||
static const int LINES = 1;
|
||||
|
||||
static char *tailbuf;
|
||||
static int taillen;
|
||||
static int newline;
|
||||
|
||||
static void tailbuf_append(char *buf, int len)
|
||||
{
|
||||
tailbuf = xrealloc(tailbuf, taillen + len);
|
||||
memcpy(tailbuf + taillen, buf, len);
|
||||
taillen += len;
|
||||
}
|
||||
|
||||
static void tailbuf_trunc()
|
||||
{
|
||||
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 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) {
|
||||
case 'f':
|
||||
follow = 1;
|
||||
break;
|
||||
#ifdef BB_FEATURE_FANCY_TAIL
|
||||
case 'c':
|
||||
units = BYTES;
|
||||
/* FALLS THROUGH */
|
||||
#endif
|
||||
case 'n':
|
||||
count = parse_number(optarg, tail_suffixes);
|
||||
if (count < 0)
|
||||
count = -count;
|
||||
if (optarg[0] == '+')
|
||||
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;
|
||||
#endif
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 {
|
||||
#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 (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;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini tee implementation for busybox
|
||||
*
|
||||
* 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
|
||||
* 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 <getopt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
tee_main(int argc, char **argv)
|
||||
{
|
||||
char *mode = "w";
|
||||
int c, i, status = 0, nfiles = 0;
|
||||
FILE **files;
|
||||
|
||||
while ((c = getopt(argc, argv, "a")) != EOF) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
mode = "a";
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
files = (FILE **)xmalloc(sizeof(FILE *) * (argc - optind + 1));
|
||||
files[nfiles++] = stdout;
|
||||
while (optind < argc) {
|
||||
if ((files[nfiles++] = fopen(argv[optind++], mode)) == NULL) {
|
||||
nfiles--;
|
||||
perror_msg("%s", argv[optind-1]);
|
||||
status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
while ((c = getchar()) != EOF)
|
||||
for (i = 0; i < nfiles; i++)
|
||||
putc(c, files[i]);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
Loaded 100 of 456 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user