Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
cc8ed39b24 |
No files matched your search
@@ -0,0 +1,5 @@
|
||||
busybox
|
||||
busybox.links
|
||||
_install
|
||||
loop.h
|
||||
applet_source_list
|
||||
File renamed without changes.
@@ -0,0 +1,75 @@
|
||||
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
|
||||
|
||||
@@ -0,0 +1,964 @@
|
||||
0.50
|
||||
* Erik Andersen -- added ifconfig interface status reporting
|
||||
* Erik Andersen -- Debian packaging updates
|
||||
* Erik Andersen -- lash environment variable expansion rewritten,
|
||||
with lots of help/fixes/testing from Larry Doolittle.
|
||||
* Erik Andersen -- Fix use of busybox with dmalloc debugging lib
|
||||
* Erik Andersen -- fixed ls behavior for broken or very narrow terminals.
|
||||
* Erik Andersen -- stub umount2 and pivot_root if they are not available.
|
||||
* Erik Andersen -- libc5 fixes
|
||||
* Erik Andersen -- make init work with devfsd
|
||||
* Erik Andersen -- fixed df for nfs and dos where blksize = 512
|
||||
* Erik Andersen -- Make sure libpwd.a is linked _last_ so it
|
||||
overrides the system pwd/grp
|
||||
* Christophe Boyanique -- added an optional egrep alias for grep.
|
||||
* Christophe Boyanique -- added optional 'rm -i' support.
|
||||
* Kenneth Chalmers and Erik Andersen -- fixed ln so it
|
||||
behaves when given no arguments (prints usage) and when
|
||||
given just one arg (tries to make a link in the cwd).
|
||||
* Magnus Damm -- added a tftp applet
|
||||
* Magnus Damm -- powerpc support for busybox insmod.
|
||||
* David Douthitt -- fixed a build error in df.c when
|
||||
BB_FEATURE_HUMAN_READABLE was disabled
|
||||
* John Beppu -- wrote autodocifier.pl, which will be used to auto-
|
||||
generate the documentation from the source code, making life
|
||||
much simpler for all.
|
||||
* Magnus Damm <damm@opensource.se> -- Fixed an 'inner scope var
|
||||
masking outer scope var with same name' bug that prevented
|
||||
the loopback device from being unmounted if mount() failed.
|
||||
* Larry Doolittle -- rewrote ifconfig to make it smaller
|
||||
* Larry Doolittle and Erik Andersen -- cleanups to pristine source
|
||||
* Larry Doolittle -- many bugfixes resulting from regression testing
|
||||
* Gennady Feldman -- split syslogd.c into syslogd and klogd
|
||||
* Gennady Feldman -- make syslogd single threaded -- no more forking
|
||||
* Jeff Garzik -- getopt-ified rmmod.
|
||||
* Jeff Garzik -- glibc 2.2 warning cleanups
|
||||
* Jeff Garzik -- namespace pollution cleanup (staticified variables).
|
||||
* Erik Gustavsson <cyrano@algonet.se> -- allow env variables set on the
|
||||
kernel command line to be inherited into init and its children.
|
||||
* Erik Habbinga -- fixed an uninitialized substitution delimiter in sed.
|
||||
* Chris Jaeger -- Makefile cleanup to make option setting less error-prone
|
||||
* Chris Jaeger <cjaeger@ensim.com> -- Carefully check NFS_MOUNT_VERSION
|
||||
depending on what kernel is being used.
|
||||
* Quinn Jensen <jensenq@lineo.com> -- MIPS support for busybox insmod.
|
||||
* Evin Robertson -- new pivot_root applet
|
||||
* Kent Robotti -- usage message cleanups
|
||||
* Kent Robotti -- reworked dos2unix/unix2dos
|
||||
* Evin Robertson and Manuel Novoa III -- reworked how usage messages
|
||||
are stored to save several k of space.
|
||||
* Matt Kraai -- Keep trying if an NFS mount fails
|
||||
* Matt Kraai -- fixed insmod so it won't try to insmod directories.
|
||||
* Matt Kraai -- added nc listening support
|
||||
* Matt Kraai and David Douthitt -- reworked fine to support -type,
|
||||
-perm, -mtime, and other improvements.
|
||||
* Matt Kraai -- added find_applet_by_name and saved some memory thereby
|
||||
* Matt Kraai -- added chomp to reduce redundant code elsewhere
|
||||
* Matt Kraai -- Removed trailing \n chars from error_msg{,_and_die} messages.
|
||||
* John Lombardo -- fixed OOM in insmod.
|
||||
* Glenn McGrath -- bypass /proc in mount, now uses sysfs.
|
||||
* Glenn McGrath -- several updates to dpkg and dpkg-deb.
|
||||
* Manuel Novoa III -- several size optimizations: parse_mode,
|
||||
process_escape_sequence, format, and get_kernel_revision.
|
||||
* Manuel Novoa III -- rewrote ifconfig again to make it smaller still
|
||||
* Manuel Novoa III -- added ifconfig -a, updated interface reporting
|
||||
* Vladimir N. Oleynik -- Fixed a bug where init set PATH incorrectly
|
||||
* Vladimir N. Oleynik -- cleanups to route, cmdedit, mkdir,
|
||||
mkfs_minix, mkswap, chmod_chown_chgrp and utility.c
|
||||
* Vladimir N. Oleynik -- many fixes to cmdedit. so tab completion
|
||||
is now working and general editing is much improved, and to
|
||||
improve complex prompt handling.
|
||||
* Vladimir N. Oleynik -- added route status reporting.
|
||||
* Vladimir N. Oleynik -- fixed wget to use xfopen
|
||||
* Vladimir N. Oleynik -- new stty applet
|
||||
* Vladimir N. Oleynik -- fixed find, it used to stop on perm errors.
|
||||
* Vladimir N. Oleynik -- locale forced to posix for scripts
|
||||
* Vladimir N. Oleynik -- saved 128 bytes by moving error checking
|
||||
for several my_* functions into utility.c
|
||||
* Bjorn Wesen -- new ifconfig and route applet (taken from
|
||||
work done by Axis Communications).
|
||||
* Mark Whitley -- Added a 'How to contribute to Busybox' doc
|
||||
and updated the style guide.
|
||||
* Mark Whitley -- implemented grep -A, -B, and -C
|
||||
* Mark Whitley -- overhauled the test suite.
|
||||
|
||||
|
||||
-Erik Andersen, 15 March 2001
|
||||
|
||||
0.49
|
||||
|
||||
* Matt Kraai -- new sort.c
|
||||
* Matt Kraai -- new tail.c
|
||||
* Glenn McGrath -- new 'dpkg-deb' applet
|
||||
* Glenn McGrath -- new ar code
|
||||
* spoon -- new watchdog applet
|
||||
* Vladimir N. Oleynik <dzo@simtreas.ru> -- fixed cmdedit.c so now
|
||||
scrolling and tab completion in lash work properly. Also several
|
||||
byte saving optimizations.
|
||||
* Erik Andersen -- disabled many less commonly used applets by default
|
||||
* Mark Whitley -- more thrashing about to get clean perror_msg usage
|
||||
* Matt Kraai -- new command line munging
|
||||
* Larry Doolittle -- keep some locales from messing up busybox.sh
|
||||
* Matt Kraai -- cleaned up dd and tail with new parse_number routine
|
||||
* Mark Whitley -- remove debugging messages from deallocvt
|
||||
* Matt Kraai and Mark Whitley -- new document "How to Add a New Applet
|
||||
to BusyBox"
|
||||
* David Douthitt -- fixed "grep -qv" bug
|
||||
* Larry Doolittle -- fixed insmod bug with old kernels
|
||||
* Matt Kraai -- logger remixed to use getopt, selection of stdin made
|
||||
util-linux compatible
|
||||
* Erik Andersen -- many more internal symbols classified static to
|
||||
avoid namespace pollution
|
||||
* Matt Kraai -- nc listening support
|
||||
* Erik Andersen -- made sed understand arbitrary regexp delimiters
|
||||
* Matt Kraai et al. -- more tar improvements and bug fixes, now
|
||||
handles regexp file exclusion
|
||||
* Larry Doolittle -- new script (multibuild.pl) to automate build rule
|
||||
checking
|
||||
* Matt Kraai -- update/cleanup of the docs on how to use init
|
||||
* Erik Andersen -- renamed all sh.c symbols per the style guide,
|
||||
better if-then-else-fi handling
|
||||
* Erik Andersen -- cleaner division of labor between cmdedit.c and sh.c
|
||||
* Larry Doolittle -- shell data structure cleanup, fixed buglets
|
||||
in read, exec, and piped builtins
|
||||
* Erik Andersen -- md5sum was broken in 0.48. Now fixed (and doesn't
|
||||
use getline, shrinking static compiles (since nothing else used it).
|
||||
* ?? -- squashed memory leak in shell prompt handling
|
||||
* Mark Whitley -- Updates to style guide
|
||||
* Mark Whitley -- Big cleanup in utility.c: style guide compliance,
|
||||
de-macro-ifying some variables and functions
|
||||
* Erik Andersen -- ls now honors BB_FEATURE_AUTOWIDTH so it can find
|
||||
the width and height of the console.
|
||||
* Erik Andersen -- insmod now ignores -L and accepts the -o option.
|
||||
* Erik Andersen -- updates so you can now select from the Makefile
|
||||
whether or not to use the system's passwd and group functions.
|
||||
Since most systems use GNU libc, this can save you from having to
|
||||
install the /etc/nsswitch.conf configuration file and the required
|
||||
libnss_* libraries. Adds 1.5k. You can now, also, disable this,
|
||||
causing busybox to use the system's pwd.h and grp.h functions.
|
||||
|
||||
|
||||
-Erik Andersen, 27 January 2001
|
||||
|
||||
0.48
|
||||
|
||||
* Glenn McGrath -- tar now supports uncompressing tar files,
|
||||
define BB_FEATURE_TAR_GZIP to use the -z option.
|
||||
* Matt Kraai -- fix all usage of TRUE and FALSE so all apps now
|
||||
return EXIT_SUCCESS or EXIT_FAILURE to the system.
|
||||
Now TRUE and FALSE are set to the C standard where TRUE=1.
|
||||
* me -- Fixed uname problem causing the kernel version to be
|
||||
mis-detected (causing problems with poweroff, init,
|
||||
and other things).
|
||||
* Alcove, Julien Gaulmin <julien.gaulmin@alcove.fr> and
|
||||
Nicolas Ferre <nicolas.ferre@alcove.fr> -- insmod support on ARM
|
||||
and StrongArm, and suport for lsmod on older 2.0.x kernels.
|
||||
* Kent Robotti -- Renamed unrpm to original rpmunpack, so you can use
|
||||
an included shell script called unrpm as a front end to it. There's
|
||||
also a shell script called undeb included for debian packages.
|
||||
* Matt Kraai -- fix an infinite loop with ls -aR
|
||||
* Larry Doolittle -- Shaved off about 100 bytes and 200 bytes heap
|
||||
from date.c. Also document the "-d" option in the usage message.
|
||||
* Gennady Feldman -- fixed dd to use blocksize when reading/writing,
|
||||
(it was reading the whole thing and then writing it out). Also
|
||||
updated usage information (was missing conv=notrunc) and added
|
||||
conv=sync feature.
|
||||
* Larry Doolittle (in collaboration with Matt Kraai) -- allow for a
|
||||
pristine source directory -- where all the .o files and such are
|
||||
not placed into the source tree. Thanks Larry!
|
||||
* Larry Doolittle -- use the applet definitions in applets.h
|
||||
to autogenerate the applet function and usage prototypes.
|
||||
* Sebastien Huet, Arne Bernin, and Kent Robotti -- Add in tar -X and
|
||||
fixed a bug breaking tar --exclude.
|
||||
* Jonas Holmberg -- echo option handling made GNU-echo compatible
|
||||
* Aleksey Demidov <asd@ixcelerator.com> -- date option handling made
|
||||
GNU-date compatible
|
||||
* me -- Progress meter (optional) in wget
|
||||
* Doolittle/me -- programs invoked by full path name take
|
||||
precedence over applets unless BB_FEATURE_SH_BUILTINS_ALWAYS_WIN
|
||||
* Gaute B Strokkenes <gs234@cam.ac.uk> -- applets found using a
|
||||
binary search instead of linear search. Much faster!
|
||||
* new applets: cmp readlink
|
||||
* Mark Whitley -- Removed advertising clause of Berkeley license
|
||||
according to decision by the Regents of the University of
|
||||
California; included reference
|
||||
* tail's confusing special treatment of single digit options removed;
|
||||
people should use -n instead
|
||||
* Larry Doolittle -- \r handled now in echo and tr
|
||||
* Matt Kraai -- rewrite of uniq
|
||||
* Mark Whitley -- remix of xargs
|
||||
* Jim Gleason <jimg@lineo.com> -- fixed tar so it no longer breaks
|
||||
hard links.
|
||||
* Matt Kraai -- logger now logs all arguments, not just the first
|
||||
* Gennady Feldman -- syslogd no longer logs to localhost if compiled
|
||||
for remote logging...
|
||||
* Richard June <rjune@ims1.imagestream-is.com> -- support for 'gzip -d'
|
||||
* various artists -- Other good stuff that I forgot to document.
|
||||
|
||||
|
||||
-Erik Andersen, 13 December 2000
|
||||
|
||||
0.47
|
||||
|
||||
* A bug in syslogd was fixed that allowed it to potentially fork-bomb
|
||||
your system. Anyone using 0.46 syslogd should upgrade.
|
||||
* Renamed busybox.defs.h to the more sensible "Config.h"
|
||||
* Improved portability between different libcs.
|
||||
* Many apps ported to use getopt()
|
||||
* Common handling of '--help'
|
||||
* All usage messages centralized.
|
||||
* Added a bunch of new commands:
|
||||
* 'rdate' contributed by Sterling Huxley <sterling@europa.com>
|
||||
* 'wget' contributed by Chip Rosenthal <chip@unicom.com>,
|
||||
<crosenth@covad.com> and Covad Communications
|
||||
* 'getopt' from "Alfred M. Szmidt" <ams@trillian.itslinux.org>
|
||||
* dos2unix, unix2dos, reset, and unrpm.c (and lots of help
|
||||
debugging) thanks to Kent Robotti <robotti@metconnect.com>.
|
||||
* 'renice' command, thanks to Dave Cinege <dcinege@psychosis.com>
|
||||
* 'xargs' (written by me)
|
||||
* 'expr' contributed by Edward Betts <edward@debian.org>, based
|
||||
on GNY expr
|
||||
* lsmod now uses the query_module syscall, rather then /proc (me)
|
||||
* syslogd can now log messages to remote hosts -- patch thanks
|
||||
to Gyepi Sam <gyepi@praxis-sw.com>
|
||||
* chroot can now call the builtin shell - Pavel Roskin <proski@gnu.org>
|
||||
* 'make install' now creates relative symlinks, and added a new
|
||||
'make install-hardlinks' target to (tada) install hardlinks.
|
||||
* Rewrite of 'tail' to make it simpler, smaller, and more robust.
|
||||
It now weighs only 2.25k (3k when full featured). The code is
|
||||
cleaner too, thanks to Allen Soard <esp-software@mail.hypermart.net>
|
||||
* Add optional ls file sorting, thanks to a patch from
|
||||
Sterling Huxley <sterling@europa.com>
|
||||
* Fixed chmod option parsing so things like 'chmod -r /tmp/file'
|
||||
now work (previously it thought -r was an option). Doh!
|
||||
* Fixed tar handling of stdin and stdout
|
||||
* Renamed "internal.h" to the more sensible "busybox.h"
|
||||
* Preliminary support for GNU HURD.
|
||||
* Updated my devps and devmtab kernel patches for the latest 2.2.x
|
||||
kernel, for those wanting to go proc-less.
|
||||
* Tons of other bugfixes.
|
||||
|
||||
|
||||
-Erik Andersen, 25 September 2000
|
||||
|
||||
|
||||
0.46
|
||||
|
||||
* Better portability. Now should compile cleanly with libc5,
|
||||
GNU libc 2.0 and 2.1, and various Linux kernels including
|
||||
2.0.x, 2.2.x, and to 2.4.0-test*. (patch for 2.4.x kernels
|
||||
to make /proc/mounts behave included in the kernel-patches dir).
|
||||
* Fixed a _horrible_ bug where 'tar -tvf' could unlink
|
||||
local files that matched tarball contents!!! Fix thanks
|
||||
to Marius Groeger <mgroeger@sysgo.de>
|
||||
* Fixed a nasty bug in tar when could mess up saved symlinks.
|
||||
* Fixed tar creation support when reading from stdin ('tar -cf - . ')
|
||||
thanks to Daniel Quinlan <quinlan@transmeta.com>
|
||||
* Updates to handle Linux 2.4.0 kernels (kludged around the
|
||||
"none" entries in /proc/mounts, added a hack to make sysinfo
|
||||
work with both old and new kernels).
|
||||
* Fixed insmod module option parsing for options lacking an '='.
|
||||
Fix thanks to Marc Nijdam <marc_nijdam@hp.com>
|
||||
* Fixed segfault with 'cut -f 1 -d:' and added 'cut -s' suport.
|
||||
Fix thanks to Arne Bernin <arne@matrix.loopback.org>
|
||||
* Several fixes from Marius Groeger <mag@sysgo.de>
|
||||
- Added support for "sh -c command args..."
|
||||
- Fixed globbing, i.e. 'echo * *' and 'echo "******"' now work.
|
||||
- Added shell environment variable substitution
|
||||
- Added the "read" shell builtin.
|
||||
* Fixed cursor editing in cmdedit.c. The following keyboard sequence
|
||||
used to create an infinite loop: ls, cursor up, left, down.
|
||||
* Added support for being a login shell, so things like
|
||||
'-su' or '-sh' (stuff where argv[0][0]=='-') will now always
|
||||
invoke the shell. Now you can use BusyBox as a login shell.
|
||||
* ls.c now ignores '-g', since some ftp clients like that sort
|
||||
of thing. Patch thanks to David Vrabel <dvrabel@arcom.co.uk>
|
||||
* Fix to init.c from Stuart Menefy <Stuart.Menefy@st.com> so that
|
||||
it always sets the controlling terminal before running any programs
|
||||
* Several fixes from Matt Kraai <kraai@alumni.carnegiemellon.edu>
|
||||
- Fixed tr so it recognizes standard escape sequences.
|
||||
Merged common escape seq. code from tr and echo into utility.c.
|
||||
- Major work in updating/cleaning up the docs, and getting the
|
||||
new SGML based docs into shape.
|
||||
- cleanup of ar.c
|
||||
- BusyBox should now poweroff when asked to do so.
|
||||
- Fixed 'ln -n' and 'ln -s' so they both work properly.
|
||||
* Reorganized signal names in kill.c for better architecture support
|
||||
-- patch thanks to simon wood <simon@mungewell.uklinux.net>
|
||||
* In 0.43, backspace and delete worked properly, but with 0.45,
|
||||
it just echoed a ^? for backspace, and ^H for control-h. This
|
||||
was due to a broken macro in init.c, that is now fixed.
|
||||
* Removed sfdisk from BusyBox. It was buggy, fat, and we really
|
||||
couldn't maintain it very well, so including it was not really
|
||||
very appropriate. Those wanting an fdisk are invited to
|
||||
grab a copy from util-linux.
|
||||
* Added 'dumpkmap' to allow people to dump a binary keymap, which can
|
||||
then be loaded in by 'loadkmap' -- submitted by
|
||||
Arne Bernin <arne@matrix.loopback.org>
|
||||
* Fixed NFS so it supports 2.4.x kernels and NFSv3.
|
||||
* Brand, new versions of grep and sed which use libc regex routines,
|
||||
thanks to Mark Whitley <markw@lineo.com>. The hand-tooled
|
||||
"regexp.[ch]" files have been removed. Much help on these from
|
||||
Matt Kraai as well.
|
||||
|
||||
|
||||
-Erik Andersen, 11 July 2000
|
||||
|
||||
|
||||
0.45
|
||||
* Now compiles vs libc5 (which can save lots of space for
|
||||
embedded systems).
|
||||
* Added BB_FEATURE_TRIVIAL_HELP which compiles out most all of the
|
||||
help messages (i.e --help). Saves 17k over a full compile.
|
||||
* Added cut and tr from minix, since due to the license change,
|
||||
we can now use minix code. Minix tr saves 4k.
|
||||
* insmod now works. It costs 29k, but imagine an initrd with a
|
||||
staticly linked busybox containing only insmod and sh, a few /dev
|
||||
entries, and a kernel module or two... It doesn't get smaller
|
||||
then this folks (I pity the fool that writes insmod in asm ;-).
|
||||
Many kudos go to Ron Alder <alder@lineo.com> for finishing this off!
|
||||
* Added a mini ar archive utility, especially written for BusyBox by
|
||||
Glenn McGrath <bug1@netconnect.com.au>
|
||||
* Added mktemp, contributed by Daniel Jacobowitz <dan@debian.org>
|
||||
* Added setkeycodes, for those that have wierd keyboard buttons.
|
||||
* Added md5sum, uuencode and uudecode -- thanks to Alfred M. Szmidt
|
||||
<ams@trillian.itslinux.org> for contributing these.
|
||||
* Added 'grep -v' option (inverted search) and updated
|
||||
docs accordingly. -beppu
|
||||
* Wrote which
|
||||
* Replaced the telnet implementation with one written by
|
||||
Tomi Ollila <too@iki.fi> It works great and costs 3k.
|
||||
* BusyBox sh (lash) now supports being used as a standalone shell. When
|
||||
BB_FEATURE_SH_STANDALONE_SHELL is defined, all the busybox commands may
|
||||
be invoked as shell internals. Best used when compiling staticly
|
||||
(i.e. DOSTATIC=true)
|
||||
* BusyBox sh (lash) internals now behave as expected wrt pipes
|
||||
and redirects.
|
||||
* Fixed ping warnings -- fix from Sascha Ziemann <szi@aibon.ping.de>
|
||||
* Fixed update segfault
|
||||
* Fixed mknod -- minor number was always 0
|
||||
* Fixed tar option parsing, so both "tar xvf foo.tar" and
|
||||
"tar -xvf foo.tar" now work (i.e. no "-" before options)
|
||||
(this was very broken in 0.43).
|
||||
* Several contributions from Randolph Chung <tausq@debian.org>.
|
||||
* cp/mv now accepts the -f flag
|
||||
* tail can now accept -<num> commands (e.g. -10) for better
|
||||
compatibility with the standard tail command
|
||||
* added a simple id implementation; doesn't support sup. groups yet
|
||||
* logname used getlogin(3) which uses utmp. Now it doesn't.
|
||||
* whoami used getpwuid(3) which uses libc NSS. Now it behaves.
|
||||
* Add support for "noatime" and "nodiratime" mount flags to mount.
|
||||
* Changed 'umount -f' to mean force, and actually use umount2.
|
||||
* Changed 'umount -l' to mean "Do not free loop device".
|
||||
* Fixed basename to support stripping of suffixes. Patch thanks
|
||||
to xiong jianxin <jxiong@uiuc.edu>
|
||||
* cp -fa now works as expected for symlinks (it didn't before)
|
||||
* zcat now works (wasn't working since option parsing was broken)
|
||||
* Renamed "mnc" to the more correct "nc" (for netcat).
|
||||
* Makefile intelligence updates
|
||||
* Changed the way init parses /etc/inittab entries to avoid problems
|
||||
with commands that contain colons in them. Fix thanks to
|
||||
Pavel Roskin <proski@gnu.org>
|
||||
* Fixed a warning in utility.c due to char being unsigned on Linux/PPC,
|
||||
Fix thanks to Pavel Roskin <proski@gnu.org>
|
||||
* Made "killall" complain (not error and exit) about processes that it
|
||||
cannot find by name -- Pavel Roskin <proski@gnu.org>
|
||||
* Fixed more and ps to have sensible terminal width defaults, thanks
|
||||
to Pavel Roskin.
|
||||
* Fixed all fatalError() calls lacking a "\n", thanks to Pavel Roskin.
|
||||
* Fixed a segfault in yes when no args were given -- Pavel Roskin.
|
||||
* Simplified freeramdisk and added argument checking -- Pavel Roskin.
|
||||
* Fixed segfault caused by "touch -c"
|
||||
* Fixed segfault caused by "rm -f"
|
||||
* Fixed segfault caused by "ln -s -s" and similar abuses. Further fixes
|
||||
and "--" support from Pavel Roskin.
|
||||
* Fixed segfault caused by "cp -a -a" and similar abuses.
|
||||
* Implemented "rm -- <foo>". Implementation fixed by Pavel Roskin.
|
||||
* "which" rewritten to use stat(). Fixes to improve its compatability
|
||||
with traditional implementations -- Pavel Roskin.
|
||||
* "mount" now reports errors from nfsmount() and assumes NFS mount
|
||||
if ':' is present in the device name - Pavel Roskin
|
||||
* Fixed exit status for killall - Pavel Roskin
|
||||
* Fixed 'swapon -a' and 'swapoff -a', which were broken.
|
||||
* Fixed 'mount -a' so it works as expected.
|
||||
* Implemented 'ls -R' (enabled by enabling BB_FEATURE_LS_RECURSIVE)
|
||||
* Implemented "ping -s", fixed error messages and argument parsing -
|
||||
Pavel Roskin
|
||||
* Syslogd will not go to background if "-n" is given. Better help
|
||||
and argument checking -- Pavel Roskin
|
||||
* Fixed a small bug that could cause tar to emit warning messages
|
||||
and not extract the first file in a directory in some cases
|
||||
of nested directories. Thanks to Kevin Traas <kevin@netmaster.com>
|
||||
for helping track this one down.
|
||||
* More doc updates
|
||||
* Fixed grep "Line too long" problem -- John Beppu
|
||||
* Fixed 'grep -q -i B some_file' so it works
|
||||
* math takes input from stdin if no args are given. -- John Beppu
|
||||
* math was renamed to dc. Although it deviates from dc's behaviour,
|
||||
this will probably be remedied in the future. -- John Beppu
|
||||
|
||||
|
||||
-Erik Andersen, June 21, 2000
|
||||
|
||||
|
||||
0.44
|
||||
Previously, an erronous announcement of BusyBox 0.44 was made, so to
|
||||
avoid possible confusion, we are skipping straight to 0.45, and calling
|
||||
it good.
|
||||
|
||||
-Erik Andersen
|
||||
|
||||
|
||||
0.43
|
||||
* Major update to the provided documentation.
|
||||
* Busybox now includes a shell! It currently costs 7.5 k (plus an
|
||||
additional 2.5 k if you compile in command line editing). Handles
|
||||
job control, has the usual set of builtins, and does everything
|
||||
except for handling programming statements (if, while, etc...)
|
||||
* Busybox can now work perfectly when /proc is disabled, thereby
|
||||
saving a bunch of memory (kernel /proc support is not thin). This
|
||||
is done by making use of some nice kernel patches I wrote up to
|
||||
support the features that busybox requires and that /proc usually
|
||||
provides. To enable this, turn on BB_FEATURE_USE_DEVPS_PATCH and
|
||||
patch your kernel with the devps patch in the kernel-patches/
|
||||
directory.
|
||||
* Wrote basename, dirname, killall, and uptime.
|
||||
* tar has been completely rewritten by me. Both tar creation and
|
||||
extraction are now well behaved. Costs 7.6k with all optional
|
||||
tar features enabled, and 5k for just tar extraction support.
|
||||
* Added freeramdisk, which will free up all memory associated
|
||||
with a ram disk. Contributed by Emanuele Caratti <wiz@iol.it>
|
||||
and then adjusted a bit by me.
|
||||
* Added tr from John Lombardo <john@deltanet.com>
|
||||
* Added echo and test (from me).
|
||||
* Added usleep contributed by Nicolas Pitre <nico@cam.org>
|
||||
* BusyBox's bss size has been majorly reduced (was 384668, is now 28740).
|
||||
* Several fixes from Pavel Roskin <proski@gnu.org>:
|
||||
- When `tail' fails to open a file it now exits.
|
||||
- When `syslogd' is given the `-n' option it should still use
|
||||
fork() for running klogd.
|
||||
* nslookup types are now changed to u_int32_t (instead of uint32_t)
|
||||
changed per a patch from Pascal Bellard <pascal.bellard@ascend.com>
|
||||
* Fixed "du" so it gives the same answers as GNU "du" (busybox du used
|
||||
to count hard-linked files more then once). Many thanks to
|
||||
Friedrich Vedder <fwv@myrtle.lahn.de> for the fix.
|
||||
* Removed /proc dependancies for init and free (while maintaining
|
||||
exactly the same functionality). /proc takes up 90k of kernel
|
||||
space, so it is nice to avoid using it at all costs.
|
||||
* init no longer tries to mount /proc (unless there is less the 1 meg
|
||||
free). Use of /proc (or not) is policy that should be set up in
|
||||
/etc/fstab (or in hardcoded scripts), not in init.
|
||||
* Fixed rebooting when init runs as an initrd.
|
||||
* Fixes and updates from Karl M. Hegbloom <karlheg@debian.org>
|
||||
- update.c rewritten to look more like update-2.11
|
||||
- moveed the inode hash out of du.c and into utility.c to make
|
||||
it a common resource that can be used by other apps.
|
||||
- cp_mv.c now checks inodes to see if a source and dest are
|
||||
the same, and prints an error (instead of endlessly looping).
|
||||
- mv now attempts to do a rename, and will fall back to doing
|
||||
a copy only if the rename fails.
|
||||
- Syslogd now supports multiple concurrent connections
|
||||
* Several fixes from Pavel Roskin <proski@gnu.org>:
|
||||
- Fixes to sort. Removed "-g", fixed and added "-r"
|
||||
- Fixes to the makefile for handling "strip"
|
||||
* An initial telnet implementation was added by
|
||||
Randolph Chung <tausq@debian.org>.
|
||||
* Fixed a bug where "sed 's/foo/bar/g'" (i.e. a script w/o a "-e")
|
||||
* ps now supports BB_FEATURE_AUTOWIDTH, and can adjust its width
|
||||
to match the terminal (defaults to width=79 when this is off).
|
||||
* ps now accepts (and ignores) all options except for "--help" (which
|
||||
as would be expected displays help).
|
||||
* Fixed mount'ing loop devices when the filesystem type was not
|
||||
specified. It used to revert to non-loop after the first try.
|
||||
* all mallocs now use xmalloc (and so are OOM error safe), and
|
||||
the common error handling saves a few bytes. Thanks to
|
||||
Bob Tinsley <bob@earthrise.demon.co.uk> for the patch.
|
||||
* Fix "+" parsing bug in date, from "Merle F. McClelland" <mfm@cts.com>.
|
||||
* Fix symlink following bug in chmod -R and friends.
|
||||
* Now allows SYSV style 'chown foo:bar' in addition to 'chown foo.bar'
|
||||
* Fixed a bug in the busybox globbing routine such that 'find /dir -name [i]'
|
||||
no longer segfaults.
|
||||
|
||||
|
||||
-Erik Andersen
|
||||
|
||||
|
||||
0.42
|
||||
|
||||
* Fairly massive restructuring of umount.c to deal with remounting
|
||||
busy devices read-only. Adds a -r option to control that; it is
|
||||
optionally compiled in with BB_FEATURE_REMOUNT
|
||||
* Added a bunch of functions to mtab.c to interact with the
|
||||
{get,set,end}mntent interface; as it turns out, those functions do
|
||||
not appear to be re-entrant, and that causes a lot of problems with
|
||||
the way umount was originally written.
|
||||
* Makes init send TERM and KILL (instead of HUP and KILL) on reboot
|
||||
to be more consistent with sysvinit
|
||||
* Changes to init.c to use the new -r option to umount. Also increased
|
||||
the sleep time between the time the TERM and KILL signals are sent
|
||||
|
||||
- Randolph Chung
|
||||
|
||||
|
||||
* cp.c, mv.c: removed, replaced by cp_mv.c which has been
|
||||
extensively rewritten from the original cp.c.
|
||||
* Fixed cp and mv so if the source and destination are a the
|
||||
same directory it will print an error and continue.
|
||||
* Also added a warning message to the `mv' usage string saying that
|
||||
this is not GNU mv, and it will break hard links. cp also breaks
|
||||
hard links.
|
||||
* ln.c: implemented `-n' switch, no-deref symlinks.
|
||||
* include<sys/param.h>: and use PATH_MAX everywhere. busybox: File
|
||||
* name buffer overrun guards to prevent future crashes.
|
||||
- Always check exit status.
|
||||
- Purge all use of `creat()', replace with `open()'.
|
||||
* utility.c
|
||||
- recursiveAction was overriding the value of followLinks thus
|
||||
ignoring it.
|
||||
- isDirectory now takes a followLinks boolean, updated all callers
|
||||
- copyFile had the followLinks logic reversed.
|
||||
* messages.c: New file. Put common error message strings all in
|
||||
one place in an attempt to shrink the binary a little.
|
||||
|
||||
-Karl M. Hegbloom
|
||||
|
||||
|
||||
* changed fsck_minix.c to reduce its .bss size significantly
|
||||
-beppu -piptigger
|
||||
* Made tar creation support in busybox tar optional. You no longer
|
||||
* _have_ to put a "-" in front of tar options. Tar could inadvertently
|
||||
* change permissions and ownership on
|
||||
certain directories pointed to by symlinks.
|
||||
* Made grep and grep -h do the right thing wrt printing
|
||||
the file name (it failed to print files names in many cases).
|
||||
* Fix a namespace aliasing problem wereby if du was built in, the
|
||||
symlink for both du and dutmp would be installed, or then rm was
|
||||
built in, the symlinks for both rm and rmmod would be installed.
|
||||
* Added a closelog() to init.c after loging -- fix thanks to
|
||||
Taketoshi Sano <kgh12351@nifty.ne.jp>
|
||||
* Rewrote and simplified logger. Added the "-t" option, and made it
|
||||
behave itself a bit better.
|
||||
* Optional support contributed by Ben Collins <bcollins@debian.org>
|
||||
for the kernel init chroot patch by Werner Almesberger, which
|
||||
allows init to chroot to a new device, and umount the old one.
|
||||
* Fixed bug that wouldn't let one chown a symlink -- it would
|
||||
always dereference before. -beppu
|
||||
* Fixed a bug where init could have reference already freed memory.
|
||||
Found and fixed by Taketoshi Sano <kgh12351@nifty.ne.jp>
|
||||
* Several contributions from Friedrich Vedder <fwv@myrtle.lahn.de>
|
||||
* Added (and documented) "-n" option for head
|
||||
* Cleanup for a number of usage messages -- also
|
||||
contributed Friedrich Vedder <fwv@myrtle.lahn.de>
|
||||
* Cosmetic fix to busybox.c (Don't print a comma at the
|
||||
end of line if there are no more application names).
|
||||
* Fixed a stupid bug in "head" option handling ("head -n"
|
||||
would segfault).
|
||||
* Moved commonly used functions "xmalloc()" and "exit()"
|
||||
to utility.c (with proper #ifdef's).
|
||||
* Created a tiny tail implementation, removing -c, -q, -v, and making
|
||||
tail -f work only with a single file. This reduced tail from 6k to
|
||||
2.4k. The bigger/more featured tail can still be had by disabling
|
||||
BB_FEATURE_SIMPLE_TAIL in busybox.defs.h
|
||||
* Ping now falls back to doing the right thing if /etc/protocols
|
||||
turns up missing.
|
||||
* Fixed mount and umount. Previously they could leak loop device
|
||||
allocations, causing the system to quickly run out. Fix for umount
|
||||
by Ben Collins <bcollins@debian.org>, and mount was fixed by me.
|
||||
* ls formatting on eight charactor user names fixed by
|
||||
Randolph Chung <tausq@debian.org>.
|
||||
* cp could, when copying symlinks, change permissions of the
|
||||
files pointed to by the symlinks.
|
||||
* Several fixes from Pavel Roskin <proski@gnu.org>:
|
||||
- `chown' with 1 argument displayed the error incorrectly
|
||||
- `fdflush', `length' and `printf' crashed if run without arguments
|
||||
- `fdflush' tried to flush itself using *argv
|
||||
- added "skip" and "seek" to dd.
|
||||
- ls no longer messus up output when combining files and
|
||||
directories on the command line
|
||||
* swapoff -a was not working. Now it is.
|
||||
* init did not cleanly unmount filesystems on reboot. Now it does.
|
||||
* "sed -ne s/foo/bar/" worked but "sed -n -e s/foo/bar/" didn't.
|
||||
Now both work.
|
||||
* Some architectures (PowerPc) assume chars are unsigned, so they could
|
||||
not distinguish between EOF and '\0xFF' in sed. Sed now uses ints.
|
||||
* Began converting error handling to use some common routines
|
||||
in utility.c
|
||||
* syslogd now has better message handling and ignores SIGHUP.
|
||||
* install.sh had a bug preventing installation to the specified
|
||||
target directory. Fix from Gilbert Coville <gilbert@mvista.com>
|
||||
* You can now spefify alternative strip commands -- change
|
||||
also from Gilbert Coville.
|
||||
|
||||
|
||||
-Erik Andersen
|
||||
|
||||
0.41
|
||||
* New Apps: wc, hostid, logname, tty, whoami, yes -- all contributed
|
||||
by Edward Betts <edward@debian.org>
|
||||
* Fixed a bug in both cp and mv preventing 'cp foo/README bar'
|
||||
type commands (file in a directory to another directory) from
|
||||
working.
|
||||
* Fixed a logger bug that caused garbage to be written to the syslog
|
||||
(unless you used busybox syslog, which hid the bug). Thanks to
|
||||
Alex Holden <alex@linuxhacker.org> for the fix.
|
||||
* /bin/true and /bin/false were echoing a blank line when run.
|
||||
Now fixed.
|
||||
* mkdir -p would print an error when asked to mkdir an existing dir
|
||||
with no interveining subdirectories.
|
||||
* Fixed "syslogd -O" so that it works. Added -o loop option for mount,
|
||||
* and support in umount for loop
|
||||
devices. Support is toggled by MOUNT_LOOP feature -- Ben Collins
|
||||
<bcollins@debian.org>
|
||||
* Several fixes from Marco Pantaleoni <panta@prosa.it> compile in
|
||||
* fullWrite() not only if BB_TAR is defined, but also
|
||||
if BB_CP or BB_MV are (fullWrite() is referenced by copyFile())
|
||||
* add some compiler optimizations to further reduce executable size
|
||||
(as a side note, on my machines the largest code is generated
|
||||
by gcc 2.95.2 with -Os ! The smallest by plain gcc 2.7.2.3 with
|
||||
-O2 -m386 ...)
|
||||
* Compile now won't fail if busybox.def.h defines
|
||||
BB_FEATURE_LINUXRC but not BB_INIT. (init_main used to be
|
||||
referenced, but not compiled)
|
||||
* Fixed a bug in setting TERM for serial console support. TERM now
|
||||
defaults to "ansi" for serial consoles.
|
||||
* Fixed a bug in handling the CONSOLE env. variable for serial
|
||||
* consoles.
|
||||
|
||||
-Erik Andersen, Jan 15, 2000
|
||||
|
||||
0.40
|
||||
* New Apps: sort, uniq. -beppu New Apps: lsmod, rmmod -erik New Apps:
|
||||
* fbset contributed by Randolph Chung <tausq@debian.org>. New App::
|
||||
* loadacm contributed by Peter Novodvorsky <petya@logic.ru>
|
||||
for loading application character maps for Unicode fonts.
|
||||
* Major init re-work. init now supports inittab (slightly different
|
||||
but similar to sysvinit), allowing me to get all the policy out of
|
||||
init and into the conf file. It works just fine without inittab
|
||||
being present, but if you dont like the default behavior you can
|
||||
now do something about it. Init is much cleaner as a result.
|
||||
* Fixed an bug in syslogd causing it to stop after 20 minutes. -erik
|
||||
* Fixed an embarrasing segfault in head -beppu Fixed the embarrasing
|
||||
* failure of 'logger -p'. -erik Added the -s option to du -beppu
|
||||
* Re-worked the source tree a bit so it will compile under glibc 2.0.7
|
||||
with the 2.0.x Linux kernel.
|
||||
* Added 'grep -q' thanks to a patch from "Konstantin Boldyshev"
|
||||
<konst@voshod.com>.
|
||||
* Grep -i previously failed on UPPER CASE patterns due to a silly
|
||||
regexp implementation bug that is now fixed.
|
||||
* Fixed a bug where tar would set, and then clear SGID and SUID bits.
|
||||
* Fixed a bug where tar would not set the user and group on device
|
||||
special files.
|
||||
* Fixed a bug where tar would not restore the time to files. Fixed a
|
||||
* major security problem with tar -- it changed ownership
|
||||
of any file pointed to by a symlink to 777 (like say libc....)
|
||||
Ouch!!!
|
||||
* cp and mv were very broken when moving directories. I have rewritten
|
||||
them so they should now work as expected.
|
||||
* sed now supports addresses (numeric or regexp, with negation) and
|
||||
has an append command, thanks to Marco Pantaleoni <panta@prosa.it>
|
||||
* Fixed dmesg. It wasn't parsing its options (-n or -s) properly.
|
||||
* Some cosmetic fixes to ls output formatting to make it behave more
|
||||
like GNU ls.
|
||||
* Fixed a stupid segfault in kill. Several fixes from Friedrich Vedder
|
||||
* <fwv@myrtle.lahn.de>:
|
||||
- Added gunzip -t, removed gunzip.c dead code,
|
||||
- fixed several typos
|
||||
- Glibc 2.0.7 and libc5 compile fixes
|
||||
* Fixed a bug where 'mknod --help' would segfault.
|
||||
|
||||
|
||||
-Erik Andersen, Jan 07, 2000
|
||||
|
||||
0.39
|
||||
* New Apps: ping, hostname, and mkfifo contributed by Randolph Chung
|
||||
<tausq@debian.org>. 3 items off the TODO list!
|
||||
* I wrote free (just calls "cat /proc/meminfo"). Added tail, based on
|
||||
* tail from GNU textutils-1.19, but adjusted
|
||||
to suit my evil purposes. Costs 6k. I'll make it smaller
|
||||
sometime.
|
||||
* on reboot, init called 'umount -a -n', which caused errors
|
||||
when BB_MTAB was not enabled. Changed to 'umount -a', which does
|
||||
the right thing.
|
||||
* init will now try to run /sbin/getty if it is present (for easy
|
||||
integration with the about-to-be-released tinylogin.)
|
||||
* kill now behaves itself properly, added 'kill -l' to list signals 'ls
|
||||
* -l' was failing on long directories, since my_getid was leaking
|
||||
one file descriptor per file. Oops.
|
||||
* Fixed rebooting from init. I'd accidently left some debugging code
|
||||
* in
|
||||
which blocked reboots.
|
||||
* Fixed reboot, halt (and added poweroff) such that they handle it when
|
||||
init is not at PID 1 (like when running in an initrd).
|
||||
* Added a prelinary du implementation. Some parameter parsing
|
||||
stuff still needs to be added. -beppu (John Beppu
|
||||
<beppu@lineo.com>)
|
||||
* Implemented tee. -beppu Implemented head. -beppu
|
||||
|
||||
-Erik Andersen, Dec 10, 1999
|
||||
|
||||
0.38
|
||||
* Fixed a segfault in 'umount -a' when a badly formed /etc/fstab
|
||||
file existed.
|
||||
* df will not exit on error, but will stat all mounted filesystems.
|
||||
* Fixed tar so uid/gid/permissions on extracted tarballs will be
|
||||
correct.
|
||||
* Fixed find -name so it properly uses shell wildcard patterns
|
||||
(i.e. `*', `?', and `[]') instead of regular expressions, which
|
||||
was causing some confusing and unexpected behavior.
|
||||
* Added klogd to syslogd, so now the log will contain both system and
|
||||
kernel messages.
|
||||
* syslogd now creates the /dev/log socket to make sure it is there, and
|
||||
is actually a socket with the right permissions.
|
||||
* I've taken a first step to making busybox not need the /proc
|
||||
filesystem. Most apps don't need it. Those that _require_ it,
|
||||
will complain if you enable them when you disable
|
||||
BB_FEATURE_USE_PROCFS.
|
||||
|
||||
-Erik Andersen, Dec 5, 1999
|
||||
|
||||
0.37
|
||||
* Wrote a micro syslogd, and a logger util (to log things to the syslog
|
||||
from the command line or scripts) With both compiled in, costs 4k.
|
||||
* Fixed 'make install' so symlinks are installed in their proper
|
||||
* locations. Changed the build system slightly so that features can
|
||||
* now be enabled
|
||||
or disabled from the busybox.defs.h header file, without trying to
|
||||
compile in a source file named after that featue (unless that file
|
||||
exists).
|
||||
* Several options are now moved into busybox.defs.h Now 'rm -R' and 'rm
|
||||
* -r' both work. dd now properly handles input beyond 1 block from
|
||||
* stdin. Fixed a bug where tar unpacked everything a directories.
|
||||
* Moved some code
|
||||
from createPath into mkdir where it belonged, thereby making tar
|
||||
work properly.
|
||||
* Fixed an off-by-one bug in cat. Given a list of file it wouldn't cat
|
||||
* out the
|
||||
last file in the list.
|
||||
* Fixed 'ls -ln' so numeric group/uid are presented properly, and fixed
|
||||
* 'ls -l'
|
||||
so when uid/gid is not in /etc/{passwd,group} the numeric group/uid
|
||||
are presented properly.
|
||||
* Also added a TODO.
|
||||
|
||||
|
||||
-Erik Andersen, Nov 25, 1999
|
||||
|
||||
0.36
|
||||
* fixed dd so it properly defaults to stdin and stdout when no
|
||||
if= and of= are set (fix thanks to Eric Delaunay).
|
||||
* Don't try to close the file descriptor of a pipein tar. (fix also
|
||||
* from
|
||||
Eric Delaunay).
|
||||
* Made createPath be quiet (again thanks to Eric Delaunay). If
|
||||
* BB_CONSOLE_CMD_IF_RC_SCRIPT_EXITS is defined, then whatever
|
||||
command you define it as will be run if the init script exits.
|
||||
* Updated install.sh to make it more robust (thanks to Adam Di Carlo)
|
||||
* NFS support added to mount by Eric Delaunay. It costs 10k when
|
||||
* compiled
|
||||
in, but that is still a big win for those that use NFS.
|
||||
* Made 'rm -f' be silent for non-existant files (thanks to Eric
|
||||
* Delaunay). changed zcat.c to gunzip.c. It now obeys the principle
|
||||
* of least surprise
|
||||
and acts as god intended gunzip and zcat to act. They answer
|
||||
--help and obey the '-c' flag.
|
||||
* Fixed a bug in mv which caused it to not move files when the
|
||||
* destination
|
||||
was a directory.
|
||||
* Fixed a decimal-instead-of-octal bug causing mkdir to make
|
||||
* directories
|
||||
with very wrong permissions.
|
||||
* chmod would overwrite file permissions instead of modifying them.
|
||||
Now it properly modifies permissions.
|
||||
* Init now sends warnings destined for the console to /dev/console to
|
||||
* ensure
|
||||
they show up on whatever the active console it. Otherwise
|
||||
important messages (for example that the system is rebooting) were
|
||||
not seen when switched to a different VT.
|
||||
|
||||
-Erik Andersen, Nov 17, 1999
|
||||
|
||||
0.35
|
||||
* gzip now obeys the principle of least surprise and acts like god
|
||||
* intended
|
||||
(i.e. it accepts a file name, answers --help, and obeys the '-c'
|
||||
flag and only then outputs to stdout).
|
||||
* Fixed more.c to compile autowidth on sparc and set initial winsize
|
||||
to 0,0 in case the TIOCGWINSZ ioctl fails. Fix thanks to Eric
|
||||
Delaunay.
|
||||
* Fixed tar so it now works as expected (it had TRUE/FALSE backwards)
|
||||
* tar now accepts --help chmod, chown, and chgrp usage now works
|
||||
* General usage (i.e. --help) cleanups for most apps umount now parses
|
||||
* options correctly tar can now unpack tarballs containing device
|
||||
* special files,
|
||||
sockets, and fifos (though it can't pack them up) thanks to Matt
|
||||
Porter. Creating archives containing these is still left to the
|
||||
interested student.
|
||||
* fixed up the license in more.c to properly point to Bruce Perens.
|
||||
|
||||
-Erik Andersen, Nov 11, 1999
|
||||
|
||||
0.34
|
||||
* ls -l now displays link names outside the current directory,
|
||||
Patch thanks to Eric Delaunay
|
||||
* init now properly handles sparc serial consoles and does a
|
||||
better job of finding the real console device rather than using
|
||||
/dev/console which doesn't support job control. Patch also thanks
|
||||
to Eric Delaunay.
|
||||
* more started to read from stdin after the last file was finished, and
|
||||
options were not parsed correctly (fix thanks to Eric Delaunay).
|
||||
* more will now use the terminal size if BB_FEATURE_AUTOWIDTH is on.
|
||||
* rm wouldn't remove a symlink unless the symlink was valid. This was
|
||||
a side effect of the busybox 0.32 recursiveAction() fix. Things
|
||||
should now work correctly.
|
||||
* grep wouldn't grep stdin. Now it does. sed wouldn't sed stdin. Now
|
||||
* it does. sed was appending a \n to the end of lines with
|
||||
* replacements.
|
||||
Now it doesn't do that.
|
||||
* ls -l now bypasses libc6 nss when displaying user/group names.
|
||||
Now uses my_getpwuid and my_getgrgid.
|
||||
|
||||
-Erik Andersen, Nov 8, 1999
|
||||
|
||||
0.33
|
||||
* Fixed a bug where init could hang instead of rebooting.
|
||||
* Removed some debugging noise from init.c
|
||||
* Fixed ln so it works now (it was very broken).
|
||||
* Fixed df so it won't segfault when there is no /etc/fstab,
|
||||
* If BB_MTAB is not defined, df and mount will whine if /etc/fstab
|
||||
is not installed (since they cannot fixup "/dev/root" to
|
||||
state the real root device name)
|
||||
* merged some redundant code from mtab.c/df.c into utility.c
|
||||
|
||||
-Erik Andersen, Nov 5, 1999
|
||||
|
||||
0.32
|
||||
* More changes -- many thanks to Lineo for paying me to work on
|
||||
busybox. If you have any problems please let me know ASAP at
|
||||
andersen@lineo.com or andersee@debian.org
|
||||
* usage() now prints the BusyBox version. This will help folks
|
||||
realize that they are not in Kansas anymore.
|
||||
* Fixed mkdir -m option so that it works. kill segfaulted w/o any
|
||||
* arguments. Now it doesn't do that. kill wasn't properly accepting
|
||||
* signal names. It does now. Added new apps chvt and deallocvt (I
|
||||
* should probably add open) Major rewrite of init.c. Code is now
|
||||
* readable by mere mortals IMHO. Wrote sed -- weighs only 1.8k (5.8k
|
||||
* with full regular expressions!). Fixed a stupid seg-fault in sync
|
||||
* Fixed mount -- mount -a failed to parse and apply mount options Fixed
|
||||
* umount -n (patch thanks to Matthew Grant <grantma@anathoth.gen.nz>)
|
||||
* umount -a no longer umounts /proc Added BB_MTAB, allowing (at the
|
||||
* cost of ~1.5k and the need for a rw /etc)
|
||||
folks to use a real /etc/mtab file instead of a symlink to
|
||||
/proc/mounts. mount, and umount will add/remove entries and df
|
||||
will now use /etc/mtab if BB_MTAB is defined.
|
||||
* Fixed a nice bug in recursiveAction() which caused it to infinitely
|
||||
hunt through /proc/../fd/* creating new file descriptors if it
|
||||
followed the /dev/fd link over to /proc. recursiveAction() now
|
||||
lstat's the file when followLinks==FALSE so it won't follow links
|
||||
as the name suggests. Fix thanks to Matt Porter
|
||||
<porter@debian.org>.
|
||||
|
||||
|
||||
-Erik Andersen, Nov 4, 1999
|
||||
|
||||
0.31
|
||||
* I added a changelog for version 0.30. adjusted find internals to
|
||||
* make it smaller, and removed
|
||||
some redundancy.
|
||||
* Fixed a segfault in ps when /etc/passwd or /etc/group
|
||||
are absent. Now will warn you and carry on.
|
||||
* Added in optional _real_ regular expression support (to be
|
||||
the basis for a future sed utility). When compiled in it adds
|
||||
3.9k, but makes grep much more capable.
|
||||
* Checked out using nftw(3) for recursive stuff, but unfortunatly
|
||||
it wasn't supported before GNU libc 2.1, and some folks use glibc
|
||||
2.0.7 since it is much smaller than that latest and greatest.
|
||||
|
||||
-Erik Andersen, Oct 21, 1999
|
||||
|
||||
0.30
|
||||
Major changes -- lots of stuff rewritten. Many thanks to Lineo for
|
||||
paying me to make these updates. If you have any problems with busybox,
|
||||
or notice any bugs -- please let me know so I can fix it. These
|
||||
changes include:
|
||||
|
||||
Core Changes:
|
||||
* busybox can now invoke apps in two ways: via symlinks to the
|
||||
busybox binary, and as 'busybox [function] [arguments]...'
|
||||
* When invoked as busybox, the list of currently compiled in
|
||||
functions is printed out (no this is not bloat -- the list has
|
||||
to be there anyway to map invocation name to function).
|
||||
* busybox no longer parses command lines for apps or displays their
|
||||
usage info. Each app gets to handle (or not handle) this for
|
||||
itself.
|
||||
* Eliminated monadic, dyadic, descend, block_device, and
|
||||
postprocess. It was cumbersome to have so many programs
|
||||
cobbled together in this way. Without them, the app is much
|
||||
more granular.
|
||||
* All shared code now lives in utility.c, and is properly
|
||||
ifdef'ed to be only included for those apps requiring it.
|
||||
* Eliminated struct FileInfo (the basis of monadic, dyadic, etc)
|
||||
so now each app has the function prototype of (da-dum): extern
|
||||
int foo_main(int argc, char** argv); which speeds integration
|
||||
of new apps.
|
||||
* Adjusted the Makefile to make it easier to
|
||||
{en|dis}able debugging.
|
||||
* Changed default compiler optimization to -Os
|
||||
(optimize for smaller binaries).
|
||||
|
||||
App Changes:
|
||||
* To cope with the new app function prototype and the removal of
|
||||
monadic, dyadic, etc, the following apps were re-written:
|
||||
* cat - Works same as always. chgrp, chmod, chown -
|
||||
* rewrite. Combined into a single
|
||||
source file. Absorbed patches from Enrique Zanardi
|
||||
<ezanard@debian.org> that removes the dependency on
|
||||
libc6 libnss* libraries.
|
||||
* cp - Can now do 'cp -a' can can copy devices,
|
||||
pipes, symlinks, as well as recursive or non-recursive
|
||||
dir copies.
|
||||
* fdflush - adjusted to remove dependancy on struct
|
||||
* FileInfo. find - Now includes some basic regexp matching
|
||||
which will be the basic of a future mini-sed.
|
||||
* ln - Same functionality. mkdir - Added -p flag to
|
||||
* feature set. mv - rewrite. rm - Added -f flag to
|
||||
* feature set. rmdir - Same functionality. swapon,
|
||||
* swapoff - Combined into a single binary. No longer
|
||||
uses /etc/swaps. swap{on|off} -a uses /etc/fstab
|
||||
instead.
|
||||
* touch - Same functionality. date - adjusted with a patch
|
||||
* from Matthew Grant <grantma@anathoth.gen.nz>
|
||||
to accomodate glibc timezone support. I then ripped out GNU
|
||||
getopt.
|
||||
* mkswap -- new version merged from util-linux. Can now make
|
||||
>128Meg swaps.
|
||||
* Replaced the old and star, unstar, and tarcat with the tar
|
||||
implementation from sash. Now tar behaves as god intended it
|
||||
to (i.e. tar -xvf <file> and tar -cf <file> <dir> work).
|
||||
* dd -- rewritten. Can with with files, stdin, stdout. Added the
|
||||
* following new apps: loadfont -- added from debian boot floppies
|
||||
* chroot -- added based on a patch from Paolo Molaro
|
||||
* <lupus@lettere.unipd.it> grep -- I just wrote it. Only matches
|
||||
* simple strings ps -- I just wrote it. Has _no_ options at all,
|
||||
* but works. fsck_minix, mkfs_minix -- added from util-linux, but
|
||||
* I ripped out
|
||||
internationalization and such to make them smaller.
|
||||
* sfdisk -- Added from util-linux (minus
|
||||
* internationalization and such). Probably some other
|
||||
* changes that I forgot to document...
|
||||
|
||||
-Erik Andersen, Oct 20, 1999
|
||||
|
||||
0.29
|
||||
This version was a messy pre-alpha. stay away or it will bite you.
|
||||
-Erik Andersen, Sep 24, 1999
|
||||
|
||||
0.28
|
||||
mini-netcat (mnc) rewritten.
|
||||
|
||||
0.27
|
||||
Mount now supports -a, and -t auto.
|
||||
Mount now updates mtab correctly for 'ro'.
|
||||
More checks screen rows size, outputs bytes percentage.
|
||||
Printf added as module.
|
||||
0.26
|
||||
Touch now creates files. -c option for no create.
|
||||
|
||||
@@ -0,0 +1,448 @@
|
||||
/* 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_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
#define BB_CHROOT
|
||||
#define BB_CHVT
|
||||
#define BB_CLEAR
|
||||
//#define BB_CMP
|
||||
#define BB_CP_MV
|
||||
#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_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_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_RPMUNPACK
|
||||
#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_UUENCODE
|
||||
//#define BB_UUDECODE
|
||||
#define BB_UMOUNT
|
||||
#define BB_UNIQ
|
||||
#define BB_UNAME
|
||||
//#define BB_UPDATE
|
||||
#define BB_UPTIME
|
||||
//#define BB_USLEEP
|
||||
//#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).
|
||||
//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
#define BB_FEATURE_TRIVIAL_HELP
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
//
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames 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
|
||||
//
|
||||
// Change ping implementation -- simplified, featureless, but really small.
|
||||
//#define BB_FEATURE_SIMPLE_PING
|
||||
//
|
||||
// Make init use a simplified /etc/inittab file (recommended).
|
||||
#define BB_FEATURE_USE_INITTAB
|
||||
//
|
||||
//Enable init being called as /linuxrc
|
||||
#define BB_FEATURE_LINUXRC
|
||||
//
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
//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
|
||||
//
|
||||
//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_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
#define BB_FEATURE_MOUNT_LOOP
|
||||
//
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes.
|
||||
// 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
|
||||
//
|
||||
// use -i (interactive) flag for rm
|
||||
//#define BB_FEATURE_RM_INTERACTIVE
|
||||
//
|
||||
// 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 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
|
||||
//
|
||||
// Some deeply embedded systems don't have usernames or even hostnames,
|
||||
// and the default prompt can look rather hideous on them. Uncomment
|
||||
// this option for a simpler, path-only prompt (which was the default until
|
||||
// around BusyBox-0.48). On by default.
|
||||
// Only relevant if BB_SH is enabled.
|
||||
#define BB_FEATURE_SH_SIMPLE_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 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
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
#else
|
||||
#undef BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_SH
|
||||
#if defined BB_FEATURE_COMMAND_EDITING
|
||||
#define BB_CMDEDIT
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
#define BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
#undef BB_FEATURE_SH_STANDALONE_SHELL
|
||||
#undef BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifndef BB_INIT
|
||||
#undef BB_FEATURE_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG
|
||||
#ifndef BB_DPKG_DEB
|
||||
#define BB_DPKG_DEB
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG_DEB
|
||||
#ifndef BB_AR
|
||||
#define BB_AR
|
||||
#endif
|
||||
#ifndef BB_TAR
|
||||
#define BB_TAR
|
||||
#endif
|
||||
#ifndef BB_FEATURE_TAR_GZIP
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_TAR
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_IFCONFIG
|
||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||
#define BB_INTERFACE
|
||||
#endif
|
||||
#else
|
||||
#undef BB_INTERFACE
|
||||
#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
|
||||
//
|
||||
#if defined BB_DOS2UNIX
|
||||
#define BB_UNIX2DOS
|
||||
#endif
|
||||
+378
@@ -0,0 +1,378 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
|
||||
// NOTE: This file only defines features usefull under the Hurd,
|
||||
// To compile for the Hurd raname this to Config.h prior to make
|
||||
|
||||
// This file defines the feature set to be compiled into busybox.
|
||||
// When you turn things off here, they won't be compiled in at all.
|
||||
//
|
||||
//// This file is parsed by sed. You MUST use single line comments.
|
||||
// i.e. //#define BB_BLAH
|
||||
//
|
||||
//
|
||||
// BusyBox Applications
|
||||
#define BB_AR
|
||||
#define BB_BASENAME
|
||||
#define BB_CAT
|
||||
#define BB_CHMOD_CHOWN_CHGRP
|
||||
#define BB_CHROOT
|
||||
//#define BB_CHVT /* not needed */
|
||||
#define BB_CLEAR
|
||||
#define BB_CP_MV
|
||||
#define BB_CUT
|
||||
#define BB_DATE
|
||||
#define BB_DC
|
||||
#define BB_DD
|
||||
//#define BB_DEALLOCVT /* inot needed */
|
||||
//#define BB_DF /* different implementation */
|
||||
#define BB_DIRNAME
|
||||
//#define BB_DMESG /* doesnt compile, different implementation */
|
||||
#define BB_DUTMP
|
||||
#define BB_DU
|
||||
//#define BB_DUMPKMAP /* not needed */
|
||||
#define BB_ECHO
|
||||
#define BB_EXPR
|
||||
//#define BB_FBSET /* not needed, doesnt compile */
|
||||
//#define BB_FDFLUSH /* is this needed? */
|
||||
#define BB_FIND
|
||||
//#define BB_FREE /* doesnt compile */
|
||||
#define BB_FREERAMDISK /* does hurd support ramdisks ? */
|
||||
#define BB_FSCK_MINIX
|
||||
#define BB_GETOPT
|
||||
#define BB_GREP
|
||||
#define BB_GUNZIP
|
||||
#define BB_GZIP
|
||||
#define BB_HALT
|
||||
#define BB_HEAD
|
||||
#define BB_HOSTID
|
||||
#define BB_HOSTNAME
|
||||
#define BB_ID
|
||||
//#define BB_INIT /* not needed?, doesnt compile */
|
||||
//#define BB_INSMOD /* not needed, doesnt compile */
|
||||
#define BB_KILL
|
||||
#define BB_KILLALL
|
||||
#define BB_LENGTH
|
||||
#define BB_LN
|
||||
//#define BB_LOADACM /* not needed, doesnt compile */
|
||||
//#define BB_LOADFONT /* not needed, doesnt compile */
|
||||
//#define BB_LOADKMAP /* not needed */
|
||||
#define BB_LOGGER
|
||||
#define BB_LOGNAME
|
||||
#define BB_LS
|
||||
//#define BB_LSMOD /* not needed, doesnt compile */
|
||||
//#define BB_MAKEDEVS /* different implementation */
|
||||
#define BB_MD5SUM
|
||||
#define BB_MKDIR
|
||||
#define BB_MKFIFO
|
||||
#define BB_MKFS_MINIX
|
||||
#define BB_MKNOD
|
||||
//#define BB_MKSWAP /* different impelementation (i think) */
|
||||
#define BB_MKTEMP
|
||||
#define BB_NC
|
||||
#define BB_MORE
|
||||
//#define BB_MOUNT /* different implementation */
|
||||
#define BB_MT
|
||||
#define BB_NSLOOKUP
|
||||
//#define BB_PING /* doesnt compile, Hurd uses BSD style ip.h */
|
||||
//#define BB_POWEROFF /* different implementation i assume */
|
||||
#define BB_PRINTF
|
||||
//#define BB_PS /* needs /proc */
|
||||
#define BB_PWD
|
||||
#define BB_RDATE
|
||||
//#define BB_REBOOT /* different implementation */
|
||||
#define BB_RENICE
|
||||
#define BB_RESET
|
||||
#define BB_RM
|
||||
#define BB_RMDIR
|
||||
//#define BB_RMMOD /* not needed, doesnt compile */
|
||||
#define BB_SED
|
||||
//#define BB_SETKEYCODES /* is this needed ? */
|
||||
#define BB_SH
|
||||
#define BB_SLEEP
|
||||
#define BB_SORT
|
||||
//#define BB_SWAPONOFF /* different implementation, doesnt compile */
|
||||
#define BB_SYNC
|
||||
//#define BB_SYSLOGD /* doesnt compile */
|
||||
#define BB_TAIL
|
||||
#define BB_TAR
|
||||
#define BB_TEE
|
||||
#define BB_TEST
|
||||
#define BB_TELNET
|
||||
#define BB_TOUCH
|
||||
#define BB_TR
|
||||
#define BB_TRUE_FALSE
|
||||
#define BB_TTY
|
||||
//#define BB_UPTIME /* doesnt compile */
|
||||
#define BB_USLEEP
|
||||
#define BB_WC
|
||||
#define BB_WGET
|
||||
#define BB_WHICH
|
||||
#define BB_WHOAMI
|
||||
#define BB_UUENCODE
|
||||
#define BB_UUDECODE
|
||||
//#define BB_UMOUNT /* different implementation */
|
||||
#define BB_UNIQ
|
||||
//#define BB_UNAME /* doesnt compile */
|
||||
//#define BB_UPDATE /* doesnt compile */
|
||||
#define BB_YES
|
||||
// End of Applications List
|
||||
//
|
||||
//
|
||||
//
|
||||
// ---------------------------------------------------------
|
||||
// This is where feature definitions go. Generally speaking,
|
||||
// turning this stuff off makes things a bit smaller (and less
|
||||
// pretty/useful).
|
||||
//
|
||||
//
|
||||
//
|
||||
// Turn this on to use Erik's very cool devps and devmtab kernel drivers,
|
||||
// thereby eliminating the need for the /proc filesystem and thereby saving
|
||||
// lots and lots memory for more important things. You can not use this and
|
||||
// USE_PROCFS at the same time... NOTE: If you enable this feature, you
|
||||
// _must_ have patched the kernel to include the devps patch that is included
|
||||
// in the busybox/kernel-patches directory. You will also need to create some
|
||||
// device special files in /dev on your embedded system:
|
||||
// mknod /dev/mtab c 10 22
|
||||
// mknod /dev/ps c 10 21
|
||||
// I emailed Linus and this patch will not be going into the stock kernel.
|
||||
//#define BB_FEATURE_USE_DEVPS_PATCH
|
||||
//
|
||||
// enable features that use the /proc filesystem (apps that
|
||||
// break without this will tell you on compile)...
|
||||
// You can't use this and BB_FEATURE_USE_DEVPS_PATCH
|
||||
// at the same time...
|
||||
#define BB_FEATURE_USE_PROCFS
|
||||
//
|
||||
// This compiles out everything but the most
|
||||
// trivial --help usage information (i.e. reduces binary size)
|
||||
//#define BB_FEATURE_TRIVIAL_HELP
|
||||
//
|
||||
// Use termios to manipulate the screen ('more' is prettier with this on)
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
//
|
||||
// calculate terminal & column widths (for more and ls)
|
||||
#define BB_FEATURE_AUTOWIDTH
|
||||
//
|
||||
// show username/groupnames (bypasses libc6 NSS) for ls
|
||||
#define BB_FEATURE_LS_USERNAME
|
||||
//
|
||||
// show file timestamps in ls
|
||||
#define BB_FEATURE_LS_TIMESTAMPS
|
||||
//
|
||||
// enable ls -p and -F
|
||||
#define BB_FEATURE_LS_FILETYPES
|
||||
//
|
||||
// sort the file names (still a bit buggy)
|
||||
#define BB_FEATURE_LS_SORTFILES
|
||||
//
|
||||
// enable ls -R
|
||||
#define BB_FEATURE_LS_RECURSIVE
|
||||
//
|
||||
// Change ping implementation -- simplified, featureless, but really small.
|
||||
#define BB_FEATURE_SIMPLE_PING
|
||||
//
|
||||
// Make init use a simplified /etc/inittab file (recommended).
|
||||
#define BB_FEATURE_USE_INITTAB
|
||||
//
|
||||
//Enable init being called as /linuxrc
|
||||
//#define BB_FEATURE_LINUXRC
|
||||
//
|
||||
//Have init enable core dumping for child processes (for debugging only)
|
||||
//#define BB_FEATURE_INIT_COREDUMPS
|
||||
//
|
||||
// Allow init to permenently chroot, and umount the old root fs
|
||||
// just like an initrd does. Requires a kernel patch by Werner Almesberger.
|
||||
// ftp://icaftp.epfl.ch/pub/people/almesber/misc/umount-root-*.tar.gz
|
||||
//#define BB_FEATURE_INIT_CHROOT
|
||||
//
|
||||
//Make sure nothing is printed to the console on boot
|
||||
#define BB_FEATURE_EXTRA_QUIET
|
||||
//
|
||||
// enable syslogd -R remotehost
|
||||
#define BB_FEATURE_REMOTE_LOG
|
||||
//
|
||||
//Simple tail implementation (2.34k vs 3k for the full one).
|
||||
//Both provide 'tail -f' support (only one file at a time.)
|
||||
#define BB_FEATURE_SIMPLE_TAIL
|
||||
//
|
||||
// Enable support for loop devices in mount
|
||||
//#define BB_FEATURE_MOUNT_LOOP
|
||||
//
|
||||
// Enable support for a real /etc/mtab file instead of /proc/mounts
|
||||
//#define BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
//
|
||||
// Enable support for mounting remote NFS volumes
|
||||
//#define BB_FEATURE_NFSMOUNT
|
||||
//
|
||||
// Enable support forced filesystem unmounting
|
||||
// (i.e. in case of an unreachable NFS system).
|
||||
#define BB_FEATURE_MOUNT_FORCE
|
||||
//
|
||||
// use -i (interactive) flag for rm
|
||||
//#define BB_FEATURE_RM_INTERACTIVE
|
||||
//
|
||||
// Enable support for creation of tar files.
|
||||
#define BB_FEATURE_TAR_CREATE
|
||||
//
|
||||
// Enable support for "--exclude" for excluding files
|
||||
#define BB_FEATURE_TAR_EXCLUDE
|
||||
//
|
||||
//// Enable reverse sort
|
||||
#define BB_FEATURE_SORT_REVERSE
|
||||
//
|
||||
// Enable command line editing in the shell
|
||||
#define BB_FEATURE_SH_COMMAND_EDITING
|
||||
//
|
||||
//Allow the shell to invoke all the compiled in BusyBox commands as if they
|
||||
//were shell builtins. Nice for staticly linking an emergency rescue shell
|
||||
//among other thing.
|
||||
#define BB_FEATURE_SH_STANDALONE_SHELL
|
||||
//
|
||||
// Enable tab completion in the shell (not yet
|
||||
// working very well -- so don't turn this on)
|
||||
//#define BB_FEATURE_SH_TAB_COMPLETION
|
||||
//
|
||||
//Turn on extra fbset options
|
||||
//#define BB_FEATURE_FBSET_FANCY
|
||||
//
|
||||
//Turn on fbset readmode support
|
||||
//#define BB_FEATURE_FBSET_READMODE
|
||||
//
|
||||
// You must enable one or both of these features
|
||||
// Support installing modules from pre 2.1 kernels
|
||||
//#define BB_FEATURE_INSMOD_OLD_KERNEL
|
||||
// Support installing modules from kernel versions after 2.1.18
|
||||
#define BB_FEATURE_INSMOD_NEW_KERNEL
|
||||
//
|
||||
// Support module version checking
|
||||
//#define BB_FEATURE_INSMOD_VERSION_CHECKING
|
||||
//
|
||||
// Support for Minix filesystem, version 2
|
||||
//#define BB_FEATURE_MINIX2
|
||||
//
|
||||
//
|
||||
// Enable busybox --install [-s]
|
||||
// to create links (or symlinks) for all the commands that are
|
||||
// compiled into the binary. (needs /proc filesystem)
|
||||
// #define BB_FEATURE_INSTALLER
|
||||
//
|
||||
// Clean up all memory before exiting -- usually not needed
|
||||
// as the OS can clean up... Don't enable this unless you
|
||||
// have a really good reason for cleaning things up manually.
|
||||
//#define BB_FEATURE_CLEAN_UP
|
||||
//
|
||||
// End of Features List
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------
|
||||
// Nothing beyond this point should ever be touched by
|
||||
// mere mortals so leave this stuff alone.
|
||||
//
|
||||
#if defined BB_MOUNT || defined BB_UMOUNT || defined BB_DF
|
||||
#ifdef BB_FEATURE_MOUNT_MTAB_SUPPORT
|
||||
#define BB_MTAB
|
||||
#endif
|
||||
#else
|
||||
#undef BB_MTAB
|
||||
#endif
|
||||
//
|
||||
#if defined BB_SH
|
||||
#if defined BB_FEATURE_COMMAND_EDITING
|
||||
#define BB_CMDEDIT
|
||||
#ifndef BB_FEATURE_USE_TERMIOS
|
||||
#define BB_FEATURE_USE_TERMIOS
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_COMMAND_TAB_COMPLETION
|
||||
#undef BB_FEATURE_COMMAND_USERNAME_COMPLETION
|
||||
#define BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
#else
|
||||
#undef BB_FEATURE_COMMAND_EDITING
|
||||
#undef BB_FEATURE_SH_APPLETS_ALWAYS_WIN
|
||||
#undef BB_FEATURE_SH_STANDALONE_SHELL
|
||||
#undef BB_FEATURE_SH_SIMPLE_PROMPT
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_KILLALL
|
||||
#ifndef BB_KILL
|
||||
#define BB_KILL
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifndef BB_INIT
|
||||
#undef BB_FEATURE_LINUXRC
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG
|
||||
#ifndef BB_DPKG_DEB
|
||||
#define BB_DPKG_DEB
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_DPKG_DEB
|
||||
#ifndef BB_AR
|
||||
#define BB_AR
|
||||
#endif
|
||||
#ifndef BB_TAR
|
||||
#define BB_TAR
|
||||
#endif
|
||||
#ifndef BB_FEATURE_TAR_GZIP
|
||||
#define BB_FEATURE_TAR_GZIP
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#ifdef BB_TAR
|
||||
#ifdef BB_FEATURE_TAR_GZIP
|
||||
#ifndef BB_GUNZIP
|
||||
#define BB_GUNZIP
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
//
|
||||
#if defined BB_MOUNT && defined BB_FEATURE_NFSMOUNT
|
||||
#define BB_NFSMOUNT
|
||||
#endif
|
||||
//
|
||||
#if defined BB_IFCONFIG
|
||||
#ifdef BB_FEATURE_IFCONFIG_STATUS
|
||||
#define BB_INTERFACE
|
||||
#endif
|
||||
#else
|
||||
#undef BB_INTERFACE
|
||||
#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
|
||||
//
|
||||
#if defined BB_DOS2UNIX
|
||||
#define BB_UNIX2DOS
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,40 @@
|
||||
Original release code (unless otherwise noted)
|
||||
Copyright 1995, 1996 Bruce Perens <bruce@pixar.com>
|
||||
|
||||
mkswap
|
||||
Copyright 1991 Linus Torvalds
|
||||
|
||||
tiny-ls(ls)
|
||||
Copyright 1996 Brian Candler <B.Candler@pobox.com>
|
||||
|
||||
tarcat, loadkmap, various fixes, Debian maintenance
|
||||
Copyright 1998 Enrique Zanardi <ezanardi@ull.es>
|
||||
|
||||
more(v2), makedevs, dutmp, modularization, auto links file,
|
||||
various fixes, Linux Router Project maintenance
|
||||
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 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
|
||||
|
||||
@@ -338,3 +375,4 @@ 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.
|
||||
|
||||
@@ -0,0 +1,375 @@
|
||||
# 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
|
||||
#
|
||||
|
||||
PROG := busybox
|
||||
VERSION := 0.50
|
||||
BUILDTIME := $(shell TZ=UTC date --utc "+%Y.%m.%d-%H:%M%z")
|
||||
export VERSION
|
||||
|
||||
# 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.
|
||||
# eg: `make DODEBUG=true tests'
|
||||
# Do not enable this for production builds...
|
||||
DODEBUG = false
|
||||
|
||||
# Setting this to `true' will cause busybox to directly use the system's
|
||||
# password and group functions. Assuming you use GNU libc, when this is
|
||||
# `true', you will need to install the /etc/nsswitch.conf configuration file
|
||||
# and the required libnss_* libraries. This generally makes your embedded
|
||||
# system quite a bit larger... If you leave this off, busybox will directly
|
||||
# use the /etc/password, /etc/group files (and your system will be smaller, and
|
||||
# I will get fewer emails asking about how glibc NSS works). Enabling this adds
|
||||
# just 1.4k to the binary size (which is a _lot_ less then glibc NSS costs),
|
||||
# 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
|
||||
|
||||
# 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/gcc-uClibc-i386
|
||||
|
||||
# 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
|
||||
|
||||
#
|
||||
#--------------------------------------------------------
|
||||
# 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
|
||||
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 messages.o usage.o utility.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
|
||||
|
||||
# Put user-supplied flags at the end, where they
|
||||
# have a chance of winning.
|
||||
CFLAGS += $(CFLAGS_EXTRA)
|
||||
|
||||
.EXPORT_ALL_VARIABLES:
|
||||
|
||||
all: applet_source_list busybox busybox.links doc
|
||||
|
||||
applet_source_list: busybox.sh Config.h
|
||||
(echo -n "APPLET_SOURCES := "; $(SHELL) $^ $(BB_SRC_DIR)) > $@
|
||||
|
||||
doc: olddoc
|
||||
|
||||
# Old Docs...
|
||||
olddoc: docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
|
||||
|
||||
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 pod2html*
|
||||
|
||||
|
||||
# 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) $(OBJECTS)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBRARIES) $(PWD_LIB)
|
||||
$(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
|
||||
|
||||
libpwd.a: $(PWD_OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
usage.o: usage.h
|
||||
|
||||
utility.o: loop.h
|
||||
|
||||
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
|
||||
|
||||
clean:
|
||||
- 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
|
||||
- rm -f busybox.links loop.h *~ slist.mk core applet_source_list
|
||||
- find -name \*.o -exec rm -f {} \;
|
||||
|
||||
distclean: clean
|
||||
- rm -f busybox
|
||||
- cd tests && $(MAKE) distclean
|
||||
|
||||
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 .cvsignore \
|
||||
-print \
|
||||
-exec rm -f {} \; ; \
|
||||
\
|
||||
find busybox-$(VERSION)/ -type f \
|
||||
-name .\#* \
|
||||
-print \
|
||||
-exec rm -f {} \; ; \
|
||||
\
|
||||
tar -cvzf busybox-$(VERSION).tar.gz busybox-$(VERSION)/;
|
||||
|
||||
.PHONY: tags
|
||||
tags:
|
||||
ctags -R .
|
||||
@@ -0,0 +1,122 @@
|
||||
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 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 kernel, and an editor,
|
||||
such as nano, e3, or elvis-tiny. For a really minimal system, you can even use
|
||||
the busybox shell (not Bourne compatible, but very small and quite usable).
|
||||
|
||||
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 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.
|
||||
|
||||
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')
|
||||
|
||||
----------------
|
||||
|
||||
Supported architectures:
|
||||
|
||||
Busybox in general will build on any architecture supported by gcc. It has
|
||||
a few specialized features added for __sparc__ and __alpha__. insmod
|
||||
functionality is currently limited to x86, ARM, and SH3/4.
|
||||
|
||||
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.48
|
||||
|
||||
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>
|
||||
|
||||
<blatant plug>
|
||||
Many thanks to go to Lineo for paying me to work on busybox.
|
||||
</blatant plug>
|
||||
|
||||
@@ -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.
|
||||
|
||||
* The busybox shell, lash, is really too weak for serious use, although it is
|
||||
possible to run simple systems with it. BusyBox 0.49 was supposed to have
|
||||
a new shell, updated to understand full Bourne grammer. Well, that simply
|
||||
didn't happen in time for the release. A rewrite is in progress that will
|
||||
result in a new shell that understands the full Bourne grammar. This new
|
||||
shell is being championed by Larry Doolittle <ldoolitt@recycle.lbl.gov>, and
|
||||
could use your help. Please see the work in progress at
|
||||
http://doolittle.faludi.com/~larry/parser.html
|
||||
|
||||
-Erik
|
||||
|
||||
-----------
|
||||
|
||||
Possible apps to include some time:
|
||||
|
||||
* hwclock
|
||||
* group/commonize strings, remove dups (for i18n, l10n)
|
||||
|
||||
-----------
|
||||
|
||||
Write a fixup_globals function to do just that right before calling
|
||||
non-forking applets. Or, just always fork...
|
||||
|
||||
-----------------------
|
||||
|
||||
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...
|
||||
|
||||
------------------------------------------------------------------
|
||||
@@ -0,0 +1,442 @@
|
||||
/*
|
||||
* 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_TRIVIAL_HELP
|
||||
#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"
|
||||
#else
|
||||
#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"
|
||||
#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_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_CHMOD_CHOWN_CHGRP
|
||||
APPLET(chgrp, chmod_chown_chgrp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET(chmod, chmod_chown_chgrp_main, _BB_DIR_BIN)
|
||||
#endif
|
||||
#ifdef BB_CHMOD_CHOWN_CHGRP
|
||||
APPLET(chown, chmod_chown_chgrp_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_MV
|
||||
APPLET(cp, cp_mv_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", init_main, _BB_DIR_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_CP_MV
|
||||
APPLET(mv, cp_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_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, dos2unix_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_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 }
|
||||
};
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
|
||||
size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,195 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
#define bb_need_full_version
|
||||
#define BB_DECLARE_EXTERN
|
||||
#include "messages.c"
|
||||
|
||||
static int been_there_done_that = 0;
|
||||
const char *applet_name;
|
||||
|
||||
#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()
|
||||
{
|
||||
pid_t pid;
|
||||
char path[256];
|
||||
char proc[256];
|
||||
int len;
|
||||
|
||||
pid = getpid();
|
||||
sprintf(proc, "/proc/%d/exe", pid);
|
||||
len = readlink(proc, path, 256);
|
||||
if (len != -1) {
|
||||
path[len] = 0;
|
||||
} else {
|
||||
perror_msg("%s", proc);
|
||||
return NULL;
|
||||
}
|
||||
return strdup(path);
|
||||
}
|
||||
|
||||
/* create (sym)links for each applet */
|
||||
static void install_links(const char *busybox, int use_symbolic_links)
|
||||
{
|
||||
__link_f Link = link;
|
||||
|
||||
char command[256];
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
sprintf ( command, "%s/%s",
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, command);
|
||||
|
||||
if (rc) {
|
||||
perror_msg("%s", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
#ifdef BB_SH
|
||||
/* Add in a special case hack -- whenever **argv == '-'
|
||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
exit(((*(shell_main)) (argc, argv)));
|
||||
}
|
||||
#endif
|
||||
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0, len, i;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argc > 2) {
|
||||
if ((strcmp(argv[2], "-s") == 0)) {
|
||||
use_symbolic_links = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* link */
|
||||
busybox = busybox_fullpath();
|
||||
if (busybox) {
|
||||
install_links(busybox, use_symbolic_links);
|
||||
free(busybox);
|
||||
} else {
|
||||
rc = 1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
#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);
|
||||
}
|
||||
|
||||
/* 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:
|
||||
*/
|
||||
@@ -10,8 +10,8 @@
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-include/config.h}
|
||||
APPLETS_H=${2:-include/applets.h}
|
||||
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)
|
||||
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
|
||||
cd ${2:-.}
|
||||
# By running $RAW through "ls", we avoid listing
|
||||
# source files that don't exist.
|
||||
ls $RAW 2>/dev/null | tr '\n' ' '
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,10 @@
|
||||
#include "busybox.h"
|
||||
|
||||
const char usage_messages[] =
|
||||
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
|
||||
#include "applets.h"
|
||||
|
||||
;
|
||||
+1716
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,227 @@
|
||||
/* 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 <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
typedef struct ar_headers_s {
|
||||
char *name;
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct ar_headers_s *next;
|
||||
} ar_headers_t;
|
||||
|
||||
/*
|
||||
* return the headerL_t struct for the filename descriptor
|
||||
*/
|
||||
extern ar_headers_t get_ar_headers(int srcFd)
|
||||
{
|
||||
typedef struct raw_ar_header_s { /* Byte Offset */
|
||||
char name[16]; /* 0-15 */
|
||||
char date[12]; /* 16-27 */
|
||||
char uid[6];
|
||||
char gid[6]; /* 28-39 */
|
||||
char mode[8]; /* 40-47 */
|
||||
char size[10]; /* 48-57 */
|
||||
char fmag[2]; /* 58-59 */
|
||||
} raw_ar_header_t;
|
||||
|
||||
raw_ar_header_t raw_ar_header;
|
||||
|
||||
ar_headers_t *head, *entry;
|
||||
char ar_magic[8];
|
||||
char *long_name=NULL;
|
||||
|
||||
head = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
|
||||
/* check ar magic */
|
||||
if (full_read(srcFd, ar_magic, 8) != 8) {
|
||||
error_msg_and_die("cannot read magic");
|
||||
}
|
||||
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0) {
|
||||
error_msg_and_die("invalid magic");
|
||||
}
|
||||
|
||||
while (full_read(srcFd, (char *) &raw_ar_header, 60)==60) {
|
||||
/* check the end of header markers are valid */
|
||||
if ((raw_ar_header.fmag[0]!='`') || (raw_ar_header.fmag[1]!='\n')) {
|
||||
char newline;
|
||||
if (raw_ar_header.fmag[1]!='`') {
|
||||
break;
|
||||
}
|
||||
/* some version of ar, have an extra '\n' after each entry */
|
||||
read(srcFd, &newline, 1);
|
||||
if (newline!='\n') {
|
||||
break;
|
||||
}
|
||||
/* fix up the header, we started reading 1 byte too early due to a '\n' */
|
||||
memmove((char *) &raw_ar_header, (char *)&raw_ar_header+1, 59);
|
||||
/* dont worry about adding the last '\n', we dont need it now */
|
||||
}
|
||||
|
||||
entry->size = (size_t) atoi(raw_ar_header.size);
|
||||
/* long filenames have '/' as the first character */
|
||||
if (raw_ar_header.name[0] == '/') {
|
||||
if (raw_ar_header.name[1] == '/') {
|
||||
/* multiple long filenames are stored as data in one entry */
|
||||
long_name = (char *) xrealloc(long_name, entry->size);
|
||||
full_read(srcFd, long_name, entry->size);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
/* The number after the '/' indicates the offset in the ar data section
|
||||
(saved in variable long_name) that conatains the real filename */
|
||||
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
|
||||
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
|
||||
strcpy(entry->name, &long_name[long_name_offset]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* short filenames */
|
||||
entry->name = xmalloc(16);
|
||||
strncpy(entry->name, raw_ar_header.name, 16);
|
||||
}
|
||||
entry->name[strcspn(entry->name, " /")]='\0';
|
||||
|
||||
/* convert the rest of the now valid char header to its typed struct */
|
||||
parse_mode(raw_ar_header.mode, &entry->mode);
|
||||
entry->mtime = atoi(raw_ar_header.date);
|
||||
entry->uid = atoi(raw_ar_header.uid);
|
||||
entry->gid = atoi(raw_ar_header.gid);
|
||||
entry->offset = lseek(srcFd, 0, SEEK_CUR);
|
||||
|
||||
/* add this entries header to our combined list */
|
||||
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
*entry->next = *head;
|
||||
*head = *entry;
|
||||
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
|
||||
}
|
||||
return(*head);
|
||||
}
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
const int preserve_date = 1; /* preserve original dates */
|
||||
const int verbose = 2; /* be verbose */
|
||||
const int display = 4; /* display contents */
|
||||
const int extract_to_file = 8; /* extract contents of archive */
|
||||
const int extract_to_stdout = 16; /* extract to stdout */
|
||||
|
||||
int funct = 0, opt=0;
|
||||
int srcFd=0, dstFd=0;
|
||||
|
||||
ar_headers_t head, *extract_list=NULL;
|
||||
|
||||
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
|
||||
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
funct |= preserve_date;
|
||||
break;
|
||||
case 'v':
|
||||
funct |= verbose;
|
||||
break;
|
||||
case 't':
|
||||
funct |= display;
|
||||
break;
|
||||
case 'p':
|
||||
funct |= extract_to_stdout;
|
||||
break;
|
||||
case 'x':
|
||||
funct |= extract_to_file;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc)
|
||||
show_usage();
|
||||
|
||||
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
|
||||
error_msg_and_die("Cannot read %s", argv[optind]);
|
||||
|
||||
optind++;
|
||||
head = get_ar_headers(srcFd);
|
||||
|
||||
/* find files to extract or display */
|
||||
/* search through argv and build extract list */
|
||||
for (;optind<argc; optind++) {
|
||||
ar_headers_t *ar_entry;
|
||||
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
ar_entry = &head;
|
||||
while (ar_entry->next != NULL) {
|
||||
if (strcmp(argv[optind], ar_entry->name) == 0) {
|
||||
ar_headers_t *tmp;
|
||||
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
*tmp = *extract_list;
|
||||
*extract_list = *ar_entry;
|
||||
extract_list->next = tmp;
|
||||
break;
|
||||
}
|
||||
ar_entry=ar_entry->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* if individual files not found extract all files */
|
||||
if (extract_list->next==NULL) {
|
||||
extract_list = &head;
|
||||
}
|
||||
|
||||
/* find files to extract or display */
|
||||
while (extract_list->next != NULL) {
|
||||
if (funct & extract_to_file) {
|
||||
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
|
||||
}
|
||||
else if (funct & extract_to_stdout) {
|
||||
dstFd = fileno(stdout);
|
||||
}
|
||||
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
|
||||
lseek(srcFd, extract_list->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, dstFd, (size_t) extract_list->size);
|
||||
}
|
||||
if (funct & verbose) {
|
||||
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
|
||||
extract_list->uid, extract_list->gid,
|
||||
extract_list->size, time_string(extract_list->mtime));
|
||||
}
|
||||
if ((funct & display) || (funct & verbose)){
|
||||
printf("%s\n", extract_list->name);
|
||||
}
|
||||
extract_list=extract_list->next;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
/* 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 <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
typedef struct ar_headers_s {
|
||||
char *name;
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct ar_headers_s *next;
|
||||
} ar_headers_t;
|
||||
|
||||
/*
|
||||
* return the headerL_t struct for the filename descriptor
|
||||
*/
|
||||
extern ar_headers_t get_ar_headers(int srcFd)
|
||||
{
|
||||
typedef struct raw_ar_header_s { /* Byte Offset */
|
||||
char name[16]; /* 0-15 */
|
||||
char date[12]; /* 16-27 */
|
||||
char uid[6];
|
||||
char gid[6]; /* 28-39 */
|
||||
char mode[8]; /* 40-47 */
|
||||
char size[10]; /* 48-57 */
|
||||
char fmag[2]; /* 58-59 */
|
||||
} raw_ar_header_t;
|
||||
|
||||
raw_ar_header_t raw_ar_header;
|
||||
|
||||
ar_headers_t *head, *entry;
|
||||
char ar_magic[8];
|
||||
char *long_name=NULL;
|
||||
|
||||
head = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
|
||||
/* check ar magic */
|
||||
if (full_read(srcFd, ar_magic, 8) != 8) {
|
||||
error_msg_and_die("cannot read magic");
|
||||
}
|
||||
|
||||
if (strncmp(ar_magic,"!<arch>",7) != 0) {
|
||||
error_msg_and_die("invalid magic");
|
||||
}
|
||||
|
||||
while (full_read(srcFd, (char *) &raw_ar_header, 60)==60) {
|
||||
/* check the end of header markers are valid */
|
||||
if ((raw_ar_header.fmag[0]!='`') || (raw_ar_header.fmag[1]!='\n')) {
|
||||
char newline;
|
||||
if (raw_ar_header.fmag[1]!='`') {
|
||||
break;
|
||||
}
|
||||
/* some version of ar, have an extra '\n' after each entry */
|
||||
read(srcFd, &newline, 1);
|
||||
if (newline!='\n') {
|
||||
break;
|
||||
}
|
||||
/* fix up the header, we started reading 1 byte too early due to a '\n' */
|
||||
memmove((char *) &raw_ar_header, (char *)&raw_ar_header+1, 59);
|
||||
/* dont worry about adding the last '\n', we dont need it now */
|
||||
}
|
||||
|
||||
entry->size = (size_t) atoi(raw_ar_header.size);
|
||||
/* long filenames have '/' as the first character */
|
||||
if (raw_ar_header.name[0] == '/') {
|
||||
if (raw_ar_header.name[1] == '/') {
|
||||
/* multiple long filenames are stored as data in one entry */
|
||||
long_name = (char *) xrealloc(long_name, entry->size);
|
||||
full_read(srcFd, long_name, entry->size);
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
/* The number after the '/' indicates the offset in the ar data section
|
||||
(saved in variable long_name) that conatains the real filename */
|
||||
const int long_name_offset = (int) atoi((char *) &raw_ar_header.name[1]);
|
||||
entry->name = xmalloc(strlen(&long_name[long_name_offset]));
|
||||
strcpy(entry->name, &long_name[long_name_offset]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* short filenames */
|
||||
entry->name = xmalloc(16);
|
||||
strncpy(entry->name, raw_ar_header.name, 16);
|
||||
}
|
||||
entry->name[strcspn(entry->name, " /")]='\0';
|
||||
|
||||
/* convert the rest of the now valid char header to its typed struct */
|
||||
parse_mode(raw_ar_header.mode, &entry->mode);
|
||||
entry->mtime = atoi(raw_ar_header.date);
|
||||
entry->uid = atoi(raw_ar_header.uid);
|
||||
entry->gid = atoi(raw_ar_header.gid);
|
||||
entry->offset = lseek(srcFd, 0, SEEK_CUR);
|
||||
|
||||
/* add this entries header to our combined list */
|
||||
entry->next = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
*entry->next = *head;
|
||||
*head = *entry;
|
||||
lseek(srcFd, (off_t) entry->size, SEEK_CUR);
|
||||
}
|
||||
return(*head);
|
||||
}
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
const int preserve_date = 1; /* preserve original dates */
|
||||
const int verbose = 2; /* be verbose */
|
||||
const int display = 4; /* display contents */
|
||||
const int extract_to_file = 8; /* extract contents of archive */
|
||||
const int extract_to_stdout = 16; /* extract to stdout */
|
||||
|
||||
int funct = 0, opt=0;
|
||||
int srcFd=0, dstFd=0;
|
||||
|
||||
ar_headers_t head, *extract_list=NULL;
|
||||
|
||||
extract_list = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
|
||||
while ((opt = getopt(argc, argv, "ovtpx")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
funct |= preserve_date;
|
||||
break;
|
||||
case 'v':
|
||||
funct |= verbose;
|
||||
break;
|
||||
case 't':
|
||||
funct |= display;
|
||||
break;
|
||||
case 'p':
|
||||
funct |= extract_to_stdout;
|
||||
break;
|
||||
case 'x':
|
||||
funct |= extract_to_file;
|
||||
break;
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
/* check the src filename was specified */
|
||||
if (optind == argc)
|
||||
show_usage();
|
||||
|
||||
if ( (srcFd = open(argv[optind], O_RDONLY)) < 0)
|
||||
error_msg_and_die("Cannot read %s", argv[optind]);
|
||||
|
||||
optind++;
|
||||
head = get_ar_headers(srcFd);
|
||||
|
||||
/* find files to extract or display */
|
||||
/* search through argv and build extract list */
|
||||
for (;optind<argc; optind++) {
|
||||
ar_headers_t *ar_entry;
|
||||
ar_entry = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
ar_entry = &head;
|
||||
while (ar_entry->next != NULL) {
|
||||
if (strcmp(argv[optind], ar_entry->name) == 0) {
|
||||
ar_headers_t *tmp;
|
||||
tmp = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
*tmp = *extract_list;
|
||||
*extract_list = *ar_entry;
|
||||
extract_list->next = tmp;
|
||||
break;
|
||||
}
|
||||
ar_entry=ar_entry->next;
|
||||
}
|
||||
}
|
||||
|
||||
/* if individual files not found extract all files */
|
||||
if (extract_list->next==NULL) {
|
||||
extract_list = &head;
|
||||
}
|
||||
|
||||
/* find files to extract or display */
|
||||
while (extract_list->next != NULL) {
|
||||
if (funct & extract_to_file) {
|
||||
dstFd = open(extract_list->name, O_WRONLY | O_CREAT, extract_list->mode);
|
||||
}
|
||||
else if (funct & extract_to_stdout) {
|
||||
dstFd = fileno(stdout);
|
||||
}
|
||||
if ((funct & extract_to_file) || (funct & extract_to_stdout)) {
|
||||
lseek(srcFd, extract_list->offset, SEEK_SET);
|
||||
copy_file_chunk(srcFd, dstFd, (size_t) extract_list->size);
|
||||
}
|
||||
if (funct & verbose) {
|
||||
printf("%s %d/%d %8d %s ", mode_string(extract_list->mode),
|
||||
extract_list->uid, extract_list->gid,
|
||||
extract_list->size, time_string(extract_list->mtime));
|
||||
}
|
||||
if ((funct & display) || (funct & verbose)){
|
||||
printf("%s\n", extract_list->name);
|
||||
}
|
||||
extract_list=extract_list->next;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
+855
@@ -0,0 +1,855 @@
|
||||
#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"
|
||||
|
||||
|
||||
/* Stupid libc doesn't have a reliable way for use to know
|
||||
* that libc5 is being used. Assume this is good enough */
|
||||
#if !defined __GLIBC__ && !defined __UCLIBC__
|
||||
#error It looks like you are using libc5, which does not support
|
||||
#error tfind(). tfind() is used by busybox dpkg.
|
||||
#error Please disable BB_DPKG. Sorry.
|
||||
#endif
|
||||
|
||||
#define DEPENDSMAX 64 /* maximum number of depends we can handle */
|
||||
|
||||
/* Should we do full dependency checking? */
|
||||
#define DODEPENDS 1
|
||||
|
||||
/* Should we do debugging? */
|
||||
#define DODEBUG 1
|
||||
|
||||
#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 */
|
||||
extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename);
|
||||
static const int dpkg_deb_contents = 1;
|
||||
static const int dpkg_deb_control = 2;
|
||||
// const int dpkg_deb_info = 4;
|
||||
static const int dpkg_deb_extract = 8;
|
||||
static const int dpkg_deb_verbose_extract = 16;
|
||||
static const int dpkg_deb_list = 32;
|
||||
|
||||
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 dpkgcidir[] = "/var/lib/dpkg/tmp.ci/";
|
||||
|
||||
static const char infodir[] = "/var/lib/dpkg/info/";
|
||||
static const char udpkg_quiet[] = "UDPKG_QUIET";
|
||||
|
||||
//static const int status_wantstart = 0;
|
||||
//static const int status_wantunknown = (1 << 0);
|
||||
static const int status_wantinstall = (1 << 1);
|
||||
//static const int status_wanthold = (1 << 2);
|
||||
//static const int status_wantdeinstall = (1 << 3);
|
||||
//static const int status_wantpurge = (1 << 4);
|
||||
static const int status_wantmask = 31;
|
||||
|
||||
//static const int status_flagstart = 5;
|
||||
static const int status_flagok = (1 << 5); /* 32 */
|
||||
//static const int status_flagreinstreq = (1 << 6);
|
||||
//static const int status_flaghold = (1 << 7);
|
||||
//static const int status_flagholdreinstreq = (1 << 8);
|
||||
static const int status_flagmask = 480;
|
||||
|
||||
//static const int status_statusstart = 9;
|
||||
//static const int status_statusnoninstalled = (1 << 9); /* 512 */
|
||||
static const int status_statusunpacked = (1 << 10);
|
||||
static const int status_statushalfconfigured = (1 << 11);
|
||||
static const int status_statusinstalled = (1 << 12);
|
||||
static const int status_statushalfinstalled = (1 << 13);
|
||||
//static const int status_statusconfigfiles = (1 << 14);
|
||||
//static const int status_statuspostinstfailed = (1 << 15);
|
||||
//static const int status_statusremovalfailed = (1 << 16);
|
||||
static const int status_statusmask = 130560; /* i assume status_statusinstalled is supposed to be included */
|
||||
|
||||
static const char *statuswords[][10] = {
|
||||
{ (char *) 0, "unknown", "install", "hold", "deinstall", "purge", 0 },
|
||||
{ (char *) 5, "ok", "reinstreq", "hold", "hold-reinstreq", 0 },
|
||||
{ (char *) 9, "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 *file;
|
||||
char *package;
|
||||
char *version;
|
||||
char *depends;
|
||||
char *provides;
|
||||
char *description;
|
||||
int installer_menu_item;
|
||||
unsigned long status;
|
||||
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);
|
||||
}
|
||||
|
||||
static int remove_dpkgcidir()
|
||||
{
|
||||
char *rm_dpkgcidir = NULL;
|
||||
|
||||
rm_dpkgcidir = (char *) xmalloc(strlen(dpkgcidir) + 8);
|
||||
strcpy(rm_dpkgcidir, "rm -rf ");
|
||||
strcat(rm_dpkgcidir, dpkgcidir);
|
||||
|
||||
if (SYSTEM(rm_dpkgcidir) != 0) {
|
||||
perror("mkdir ");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef DODEPENDS
|
||||
#include <ctype.h>
|
||||
|
||||
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 = strdup(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->status & (status_flagok | status_statusinstalled)) !=
|
||||
(status_flagok | status_statusinstalled))) {
|
||||
|
||||
/* 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) {
|
||||
fprintf(stderr, "Too many dependencies for %s\n", chk->package);
|
||||
return 0;
|
||||
}
|
||||
if (chk != pkg) {
|
||||
chk->requiredfor[chk->requiredcount++] = pkg;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (chk == 0) {
|
||||
fprintf(stderr, "%s depends on %s, but it is not going to be installed\n", 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 long status_parse(const char *line)
|
||||
{
|
||||
char *p;
|
||||
int i, j;
|
||||
unsigned long l = 0;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if ((p = strchr(line, ' ')) != NULL) {
|
||||
*p = 0;
|
||||
}
|
||||
j = 1;
|
||||
while (statuswords[i][j] != 0) {
|
||||
if (strcmp(line, statuswords[i][j]) == 0) {
|
||||
l |= (1 << ((int)statuswords[i][0] + j - 1));
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
/* parse error */
|
||||
if (statuswords[i][j] == 0) {
|
||||
return 0;
|
||||
}
|
||||
line = p+1;
|
||||
}
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
static const char *status_print(unsigned long flags)
|
||||
{
|
||||
/* this function returns a static buffer... */
|
||||
static char buf[256];
|
||||
int i, j;
|
||||
|
||||
buf[0] = 0;
|
||||
for (i = 0; i < 3; i++) {
|
||||
j = 1;
|
||||
while (statuswords[i][j] != 0) {
|
||||
if ((flags & (1 << ((int)statuswords[i][0] + j - 1))) != 0) {
|
||||
strcat(buf, statuswords[i][j]);
|
||||
if (i < 2) strcat(buf, " ");
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (statuswords[i][j] == 0) {
|
||||
fprintf(stderr, "corrupted status flag!!\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a control file (or a stanza of a status file) and parse it,
|
||||
* filling parsed fields into the package structure
|
||||
*/
|
||||
static int control_read(FILE *file, package_t *p)
|
||||
{
|
||||
char *line;
|
||||
|
||||
while ((line = get_line_from_file(file)) != NULL) {
|
||||
line[strlen(line)] = 0;
|
||||
|
||||
if (strlen(line) == 0) {
|
||||
break;
|
||||
} else
|
||||
if (strstr(line, "Package: ") == line) {
|
||||
p->package = strdup(line + 9);
|
||||
} else
|
||||
if (strstr(line, "Status: ") == line) {
|
||||
p->status = status_parse(line + 8);
|
||||
} else
|
||||
if (strstr(line, "Depends: ") == line) {
|
||||
p->depends = strdup(line + 9);
|
||||
} else
|
||||
if (strstr(line, "Provides: ") == line) {
|
||||
p->provides = strdup(line + 10);
|
||||
} else
|
||||
if (strstr(line, "Description: ") == line) {
|
||||
p->description = strdup(line + 13);
|
||||
/* This is specific to the Debian Installer. Ifdef? */
|
||||
} else
|
||||
if (strstr(line, "installer-menu-item: ") == line) {
|
||||
p->installer_menu_item = atoi(line + 21);
|
||||
}
|
||||
/* TODO: localized descriptions */
|
||||
}
|
||||
free(line);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
static void *status_read(void)
|
||||
{
|
||||
FILE *f;
|
||||
void *status = 0;
|
||||
package_t *m = 0, *p = 0, *t = 0;
|
||||
|
||||
if ((f = fopen(statusfile, "r")) == NULL) {
|
||||
perror(statusfile);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (getenv(udpkg_quiet) == NULL) {
|
||||
printf("(Reading database...)\n");
|
||||
}
|
||||
|
||||
while (!feof(f)) {
|
||||
m = (package_t *)xmalloc(sizeof(package_t));
|
||||
memset(m, 0, sizeof(package_t));
|
||||
control_read(f, m);
|
||||
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 *)xmalloc(sizeof(package_t));
|
||||
memset(p, 0, sizeof(package_t));
|
||||
p->package = strdup(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->status = m->status;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
free(m);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
return status;
|
||||
}
|
||||
|
||||
static int status_merge(void *status, package_t *pkgs)
|
||||
{
|
||||
FILE *fin, *fout;
|
||||
char *line;
|
||||
package_t *pkg = 0, *statpkg = 0;
|
||||
package_t locpkg;
|
||||
int r = 0;
|
||||
|
||||
if ((fin = fopen(statusfile, "r")) == NULL) {
|
||||
perror(statusfile);
|
||||
return 0;
|
||||
}
|
||||
if ((fout = fopen(new_statusfile, "w")) == NULL) {
|
||||
perror(new_statusfile);
|
||||
return 0;
|
||||
}
|
||||
if (getenv(udpkg_quiet) == NULL) {
|
||||
printf("(Updating database...)\n");
|
||||
}
|
||||
|
||||
while (((line = get_line_from_file(fin)) != NULL) && !feof(fin)) {
|
||||
line[strlen(line)] = 0; /* 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 && strncmp(line + 9,
|
||||
pkg->package, strlen(line) - 9) != 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",
|
||||
status_print(statpkg->status));
|
||||
}
|
||||
fputs(line, fout);
|
||||
fputc('\n', fout);
|
||||
}
|
||||
free(line);
|
||||
|
||||
// Print out packages we processed.
|
||||
for (pkg = pkgs; pkg != 0; pkg = pkg->next) {
|
||||
fprintf(fout, "Package: %s\nStatus: %s\n",
|
||||
pkg->package, status_print(pkg->status));
|
||||
if (pkg->depends)
|
||||
fprintf(fout, "Depends: %s\n", pkg->depends);
|
||||
if (pkg->provides)
|
||||
fprintf(fout, "Provides: %s\n", pkg->provides);
|
||||
if (pkg->installer_menu_item)
|
||||
fprintf(fout, "installer-menu-item: %i\n", pkg->installer_menu_item);
|
||||
if (pkg->description)
|
||||
fprintf(fout, "Description: %s\n", pkg->description);
|
||||
fputc('\n', fout);
|
||||
}
|
||||
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
|
||||
r = rename(statusfile, bak_statusfile);
|
||||
if (r == 0) {
|
||||
r = rename(new_statusfile, statusfile);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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->status &= status_statusmask;
|
||||
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) {
|
||||
fprintf(stderr, "postinst exited with status %d\n", r);
|
||||
pkg->status |= status_statushalfconfigured;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
pkg->status |= status_statusinstalled;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dpkg_dounpack(package_t *pkg)
|
||||
{
|
||||
int r = 0, i;
|
||||
char *cwd;
|
||||
FILE *outfp;
|
||||
char *src_file = NULL;
|
||||
char *dst_file = NULL;
|
||||
char *lst_file = NULL;
|
||||
char *adminscripts[] = { "/prerm", "/postrm", "/preinst", "/postinst",
|
||||
"/conffiles", "/md5sums", "/shlibs", "/templates" };
|
||||
char buf[1024], buf2[1024];
|
||||
|
||||
DPRINTF("Unpacking %s\n", pkg->package);
|
||||
|
||||
cwd = getcwd(0, 0);
|
||||
chdir("/");
|
||||
deb_extract(dpkg_deb_extract, "/", pkg->file);
|
||||
|
||||
/* Installs the package scripts into the info directory */
|
||||
for (i = 0; i < sizeof(adminscripts) / sizeof(adminscripts[0]); i++) {
|
||||
/* The full path of the current location of the admin file */
|
||||
src_file = xrealloc(src_file, strlen(dpkgcidir) + strlen(pkg->package) + strlen(adminscripts[i]) + 1);
|
||||
strcpy(src_file, dpkgcidir);
|
||||
strcat(src_file, pkg->package);
|
||||
strcat(src_file, adminscripts[i]);
|
||||
|
||||
/* the full path of where we want the file to be copied to */
|
||||
dst_file = xrealloc(dst_file, strlen(infodir) + strlen(pkg->package) + strlen(adminscripts[i]) + 1);
|
||||
strcpy(dst_file, infodir);
|
||||
strcat(dst_file, pkg->package);
|
||||
strcat(dst_file, adminscripts[i]);
|
||||
|
||||
/* copy admin file to permanent home */
|
||||
if (copy_file(src_file, dst_file, TRUE, FALSE, FALSE) < 0) {
|
||||
error_msg_and_die("Cannot copy %s to %s ", buf, buf2);
|
||||
}
|
||||
|
||||
/* create the list file */
|
||||
lst_file = (char *) xmalloc(strlen(infodir) + strlen(pkg->package) + 6);
|
||||
strcpy(lst_file, infodir);
|
||||
strcat(lst_file, pkg->package);
|
||||
strcat(lst_file, ".list");
|
||||
outfp = freopen(lst_file, "w", stdout);
|
||||
deb_extract(dpkg_deb_list, NULL, pkg->file);
|
||||
stdout = freopen(NULL, "w", outfp);
|
||||
|
||||
printf("done\n");
|
||||
getchar();
|
||||
|
||||
fclose(outfp);
|
||||
}
|
||||
|
||||
pkg->status &= status_wantmask;
|
||||
pkg->status |= status_wantinstall;
|
||||
pkg->status &= status_flagmask;
|
||||
pkg->status |= status_flagok;
|
||||
pkg->status &= status_statusmask;
|
||||
|
||||
if (r == 0) {
|
||||
pkg->status |= status_statusunpacked;
|
||||
} else {
|
||||
pkg->status |= status_statushalfinstalled;
|
||||
}
|
||||
chdir(cwd);
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract and parse the control.tar.gz from the specified package
|
||||
*/
|
||||
static int dpkg_unpackcontrol(package_t *pkg)
|
||||
{
|
||||
char *tmp_name;
|
||||
FILE *file;
|
||||
int length;
|
||||
|
||||
/* clean the temp directory (dpkgcidir) be recreating it */
|
||||
remove_dpkgcidir();
|
||||
if (mkdir(dpkgcidir, S_IRWXU) != 0) {
|
||||
perror("mkdir");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the package name from the file name,
|
||||
* first remove the directories
|
||||
*/
|
||||
if ((tmp_name = strrchr(pkg->file, '/')) == NULL) {
|
||||
tmp_name = pkg->file;
|
||||
} else {
|
||||
tmp_name++;
|
||||
}
|
||||
/* now remove trailing version numbers etc */
|
||||
length = strcspn(tmp_name, "_.");
|
||||
pkg->package = (char *) xmalloc(length + 1);
|
||||
/* store the package name */
|
||||
strncpy(pkg->package, tmp_name, length);
|
||||
|
||||
/* work out the full extraction path */
|
||||
tmp_name = (char *) xmalloc(strlen(dpkgcidir) + strlen(pkg->package) + 9);
|
||||
memset(tmp_name, 0, strlen(dpkgcidir) + strlen(pkg->package) + 9);
|
||||
strcpy(tmp_name, dpkgcidir);
|
||||
strcat(tmp_name, pkg->package);
|
||||
|
||||
/* extract control.tar.gz to the full extraction path */
|
||||
deb_extract(dpkg_deb_control, tmp_name, pkg->file);
|
||||
|
||||
/* parse the extracted control file */
|
||||
strcat(tmp_name, "/control");
|
||||
if ((file = fopen(tmp_name, "r")) == NULL) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (control_read(file, pkg) == EXIT_FAILURE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
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) {
|
||||
if (dpkg_unpackcontrol(pkg) == EXIT_FAILURE) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if ((r = dpkg_dounpack(pkg)) != 0 ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
status_merge(status, pkgs);
|
||||
remove_dpkgcidir();
|
||||
|
||||
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) {
|
||||
fprintf(stderr, "Trying to configure %s, but it is not installed\n", 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) {
|
||||
if (dpkg_unpackcontrol(p) == EXIT_FAILURE) {
|
||||
perror(p->file);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
/* 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->status &= status_wantmask;
|
||||
p->status |= status_wantinstall;
|
||||
|
||||
/* for now the flag is always set to ok... this is probably
|
||||
* not what we want
|
||||
*/
|
||||
p->status &= status_flagmask;
|
||||
p->status |= status_flagok;
|
||||
|
||||
DPRINTF("Installing %s\n", p->package);
|
||||
if (dpkg_dounpack(p) != 0) {
|
||||
perror(p->file);
|
||||
}
|
||||
if (dpkg_doconfigure(p) != 0) {
|
||||
perror(p->file);
|
||||
}
|
||||
}
|
||||
|
||||
if (ordered != 0) {
|
||||
status_merge(status, pkgs);
|
||||
}
|
||||
remove_dpkgcidir();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
char opt = 0;
|
||||
char *s;
|
||||
package_t *p, *packages = NULL;
|
||||
char *cwd = getcwd(0, 0);
|
||||
void *status = NULL;
|
||||
|
||||
while (*++argv) {
|
||||
if (**argv == '-') {
|
||||
/* Nasty little hack to "parse" long options. */
|
||||
s = *argv;
|
||||
while (*s == '-') {
|
||||
s++;
|
||||
}
|
||||
opt=s[0];
|
||||
} else {
|
||||
p = (package_t *)xmalloc(sizeof(package_t));
|
||||
memset(p, 0, sizeof(package_t));
|
||||
|
||||
if (**argv == '/') {
|
||||
p->file = *argv;
|
||||
} else
|
||||
if (opt != 'c') {
|
||||
p->file = xmalloc(strlen(cwd) + strlen(*argv) + 2);
|
||||
sprintf(p->file, "%s/%s", cwd, *argv);
|
||||
} else {
|
||||
p->package = strdup(*argv);
|
||||
}
|
||||
|
||||
p->next = packages;
|
||||
packages = p;
|
||||
}
|
||||
}
|
||||
|
||||
status = status_read();
|
||||
|
||||
switch (opt) {
|
||||
case 'i':
|
||||
return dpkg_install(packages, status);
|
||||
case 'r':
|
||||
return dpkg_remove(packages, status);
|
||||
case 'u':
|
||||
return dpkg_unpack(packages, status);
|
||||
case 'c':
|
||||
return dpkg_configure(packages, status);
|
||||
default :
|
||||
show_usage();
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Merge this applet into dpkg when dpkg becomes more stable
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
typedef struct ar_headers_s {
|
||||
char *name;
|
||||
size_t size;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
mode_t mode;
|
||||
time_t mtime;
|
||||
off_t offset;
|
||||
struct ar_headers_s *next;
|
||||
} ar_headers_t;
|
||||
|
||||
extern ar_headers_t get_ar_headers(int srcFd);
|
||||
extern int tar_unzip_init(int tarFd);
|
||||
extern int readTarFile(int tarFd, int extractFlag, int listFlag,
|
||||
int tostdoutFlag, int verboseFlag, char** extractList, char** excludeList);
|
||||
|
||||
static const int dpkg_deb_contents = 1;
|
||||
static const int dpkg_deb_control = 2;
|
||||
// const int dpkg_deb_info = 4;
|
||||
static const int dpkg_deb_extract = 8;
|
||||
static const int dpkg_deb_verbose_extract = 16;
|
||||
static const int dpkg_deb_list = 32;
|
||||
|
||||
extern int deb_extract(int optflags, const char *dir_name, const char *deb_filename)
|
||||
{
|
||||
char **extract_list = NULL;
|
||||
ar_headers_t *ar_headers = NULL;
|
||||
char ar_filename[15];
|
||||
int extract_flag = FALSE;
|
||||
int list_flag = FALSE;
|
||||
int verbose_flag = FALSE;
|
||||
int extract_to_stdout = FALSE;
|
||||
int srcFd = 0;
|
||||
int status;
|
||||
|
||||
if (dpkg_deb_contents == (dpkg_deb_contents & optflags)) {
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
verbose_flag = TRUE;
|
||||
list_flag = TRUE;
|
||||
}
|
||||
if (dpkg_deb_list == (dpkg_deb_list & optflags)) {
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
list_flag = TRUE;
|
||||
}
|
||||
if (dpkg_deb_control == (dpkg_deb_control & optflags)) {
|
||||
strcpy(ar_filename, "control.tar.gz");
|
||||
extract_flag = TRUE;
|
||||
}
|
||||
if (dpkg_deb_extract == (dpkg_deb_extract & optflags)) {
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
extract_flag = TRUE;
|
||||
}
|
||||
if (dpkg_deb_verbose_extract == (dpkg_deb_verbose_extract & optflags)) {
|
||||
strcpy(ar_filename, "data.tar.gz");
|
||||
extract_flag = TRUE;
|
||||
list_flag = TRUE;
|
||||
}
|
||||
|
||||
ar_headers = (ar_headers_t *) xmalloc(sizeof(ar_headers_t));
|
||||
srcFd = open(deb_filename, O_RDONLY);
|
||||
|
||||
*ar_headers = get_ar_headers(srcFd);
|
||||
if (ar_headers->next == NULL) {
|
||||
error_msg_and_die("Couldnt find %s in %s", ar_filename, deb_filename);
|
||||
}
|
||||
|
||||
while (ar_headers->next != NULL) {
|
||||
if (strcmp(ar_headers->name, ar_filename) == 0) {
|
||||
break;
|
||||
}
|
||||
ar_headers = ar_headers->next;
|
||||
}
|
||||
lseek(srcFd, ar_headers->offset, SEEK_SET);
|
||||
srcFd = tar_unzip_init(srcFd);
|
||||
if ( dir_name != NULL) {
|
||||
if (is_directory(dir_name, TRUE, NULL)==FALSE) {
|
||||
mkdir(dir_name, 0755);
|
||||
}
|
||||
if (chdir(dir_name)==-1) {
|
||||
error_msg_and_die("Cannot change to dir %s", dir_name);
|
||||
}
|
||||
}
|
||||
status = readTarFile(srcFd, extract_flag, list_flag, extract_to_stdout, verbose_flag, NULL, extract_list);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
extern int dpkg_deb_main(int argc, char **argv)
|
||||
{
|
||||
char *target_dir = NULL;
|
||||
int opt = 0;
|
||||
int optflag = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "cexXl")) != -1) {
|
||||
switch (opt) {
|
||||
case 'c':
|
||||
optflag |= dpkg_deb_contents;
|
||||
break;
|
||||
case 'e':
|
||||
optflag |= dpkg_deb_control;
|
||||
break;
|
||||
case 'X':
|
||||
optflag |= dpkg_deb_verbose_extract;
|
||||
break;
|
||||
case 'x':
|
||||
optflag |= dpkg_deb_extract;
|
||||
break;
|
||||
case 'l':
|
||||
optflag |= dpkg_deb_list;
|
||||
break;
|
||||
/* case 'I':
|
||||
optflag |= dpkg_deb_info;
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (((optind + 1 ) > argc) || (optflag == 0)) {
|
||||
show_usage();
|
||||
}
|
||||
if ((optflag & dpkg_deb_control) || (optflag & dpkg_deb_extract) || (optflag & dpkg_deb_verbose_extract)) {
|
||||
if ( (optind + 1) == argc ) {
|
||||
target_dir = (char *) xmalloc(7);
|
||||
strcpy(target_dir, "DEBIAN");
|
||||
} else {
|
||||
target_dir = (char *) xmalloc(strlen(argv[optind + 1]));
|
||||
strcpy(target_dir, argv[optind + 1]);
|
||||
}
|
||||
}
|
||||
deb_extract(optflag, target_dir, argv[optind]);
|
||||
/* else if (optflag & dpkg_deb_info) {
|
||||
extract_flag = TRUE;
|
||||
extract_to_stdout = TRUE;
|
||||
strcpy(ar_filename, "control.tar.gz");
|
||||
extract_list = argv+optind+1;
|
||||
printf("list one is [%s]\n",extract_list[0]);
|
||||
}
|
||||
*/
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
+1363
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+1205
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';
|
||||
}
|
||||
printf("%s\n", s);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "busybox.h"
|
||||
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
#define bb_need_full_version
|
||||
#define BB_DECLARE_EXTERN
|
||||
#include "messages.c"
|
||||
|
||||
static int been_there_done_that = 0;
|
||||
const char *applet_name;
|
||||
|
||||
#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()
|
||||
{
|
||||
pid_t pid;
|
||||
char path[256];
|
||||
char proc[256];
|
||||
int len;
|
||||
|
||||
pid = getpid();
|
||||
sprintf(proc, "/proc/%d/exe", pid);
|
||||
len = readlink(proc, path, 256);
|
||||
if (len != -1) {
|
||||
path[len] = 0;
|
||||
} else {
|
||||
perror_msg("%s", proc);
|
||||
return NULL;
|
||||
}
|
||||
return strdup(path);
|
||||
}
|
||||
|
||||
/* create (sym)links for each applet */
|
||||
static void install_links(const char *busybox, int use_symbolic_links)
|
||||
{
|
||||
__link_f Link = link;
|
||||
|
||||
char command[256];
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
if (use_symbolic_links)
|
||||
Link = symlink;
|
||||
|
||||
for (i = 0; applets[i].name != NULL; i++) {
|
||||
sprintf ( command, "%s/%s",
|
||||
install_dir[applets[i].location], applets[i].name);
|
||||
rc = Link(busybox, command);
|
||||
|
||||
if (rc) {
|
||||
perror_msg("%s", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BB_FEATURE_INSTALLER */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
for (s = applet_name = argv[0]; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
applet_name = s;
|
||||
}
|
||||
|
||||
#ifdef BB_SH
|
||||
/* Add in a special case hack -- whenever **argv == '-'
|
||||
* (i.e. '-su' or '-sh') always invoke the shell */
|
||||
if (**argv == '-' && *(*argv+1)!= '-') {
|
||||
exit(((*(shell_main)) (argc, argv)));
|
||||
}
|
||||
#endif
|
||||
|
||||
run_applet_by_name(applet_name, argc, argv);
|
||||
error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0, len, i;
|
||||
|
||||
#ifdef BB_FEATURE_INSTALLER
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argc > 2) {
|
||||
if ((strcmp(argv[2], "-s") == 0)) {
|
||||
use_symbolic_links = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* link */
|
||||
busybox = busybox_fullpath();
|
||||
if (busybox) {
|
||||
install_links(busybox, use_symbolic_links);
|
||||
free(busybox);
|
||||
} else {
|
||||
rc = 1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
#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);
|
||||
}
|
||||
|
||||
/* 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:
|
||||
*/
|
||||
@@ -0,0 +1,271 @@
|
||||
/* 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>
|
||||
|
||||
#ifdef DMALLOC
|
||||
#include "dmalloc.h"
|
||||
#endif
|
||||
|
||||
#include <features.h>
|
||||
/* Stupid libc doesn't have a reliable way for use to know
|
||||
* that libc5 is being used. Assume this is good enough */
|
||||
#if ! defined __GLIBC__ && ! defined __UCLIBC__
|
||||
/* libc5 doesn't define socklen_t */
|
||||
typedef unsigned int socklen_t;
|
||||
#endif
|
||||
|
||||
|
||||
/* Some useful definitions */
|
||||
#define FALSE ((int) 0)
|
||||
#define TRUE ((int) 1)
|
||||
#define SKIP ((int) 2)
|
||||
|
||||
/* for mtab.c */
|
||||
#define MTAB_GETMOUNTPT '1'
|
||||
#define MTAB_GETDEVICE '2'
|
||||
|
||||
#define BUF_SIZE 8192
|
||||
#define EXPAND_ALLOC 1024
|
||||
|
||||
static inline int is_decimal(ch) { return ((ch >= '0') && (ch <= '9')); }
|
||||
static inline int is_octal(ch) { return ((ch >= '0') && (ch <= '7')); }
|
||||
|
||||
/* Macros for min/max. */
|
||||
#ifndef MIN
|
||||
#define MIN(a,b) (((a)<(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
|
||||
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
|
||||
|
||||
extern const char *applet_name;
|
||||
|
||||
extern void show_usage(void) __attribute__ ((noreturn));
|
||||
extern void error_msg(const char *s, ...);
|
||||
extern void error_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
extern void perror_msg(const char *s, ...);
|
||||
extern void perror_msg_and_die(const char *s, ...) __attribute__ ((noreturn));
|
||||
|
||||
const char *mode_string(int mode);
|
||||
const char *time_string(time_t timeVal);
|
||||
int is_directory(const char *name, const int followLinks, struct stat *statBuf);
|
||||
int isDevice(const char *name);
|
||||
|
||||
typedef struct ino_dev_hash_bucket_struct {
|
||||
struct ino_dev_hash_bucket_struct *next;
|
||||
ino_t ino;
|
||||
dev_t dev;
|
||||
char name[1];
|
||||
} ino_dev_hashtable_bucket_t;
|
||||
int is_in_ino_dev_hashtable(const struct stat *statbuf, char **name);
|
||||
void add_to_ino_dev_hashtable(const struct stat *statbuf, const char *name);
|
||||
void reset_ino_dev_hashtable(void);
|
||||
|
||||
int copy_file(const char *srcName, const char *destName,
|
||||
int setModes, int followLinks, int forceFlag);
|
||||
int copy_file_chunk(int srcFd, int dstFd, size_t remaining);
|
||||
char *buildName(const char *dirName, const char *fileName);
|
||||
int makeString(int argc, const char **argv, char *buf, int bufLen);
|
||||
char *getChunk(int size);
|
||||
char *chunkstrdup(const char *str);
|
||||
void freeChunks(void);
|
||||
ssize_t safe_read(int fd, void *buf, size_t count);
|
||||
int full_write(int fd, const char *buf, int len);
|
||||
int full_read(int fd, char *buf, int len);
|
||||
int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
|
||||
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
|
||||
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
|
||||
void* userData);
|
||||
|
||||
extern int create_path (const char *name, int mode);
|
||||
extern int parse_mode( const char* s, mode_t* theMode);
|
||||
|
||||
extern int get_kernel_revision(void);
|
||||
|
||||
extern int get_console_fd(char* tty_name);
|
||||
extern struct mntent *find_mount_point(const char *name, const char *table);
|
||||
extern void write_mtab(char* blockDevice, char* directory,
|
||||
char* filesystemType, long flags, char* string_flags);
|
||||
extern void erase_mtab(const char * name);
|
||||
extern void mtab_read(void);
|
||||
extern char *mtab_first(void **iter);
|
||||
extern char *mtab_next(void **iter);
|
||||
extern char *mtab_getinfo(const char *match, const char which);
|
||||
extern int check_wildcard_match(const char* text, const char* pattern);
|
||||
extern long atoi_w_units (const char *cp);
|
||||
extern pid_t* find_pid_by_name( char* pidName);
|
||||
extern int find_real_root_device_name(char* name);
|
||||
extern char *get_line_from_file(FILE *file);
|
||||
extern void print_file(FILE *file);
|
||||
extern int print_file_by_name(char *filename);
|
||||
extern char process_escape_sequence(char **ptr);
|
||||
extern char *get_last_path_component(char *path);
|
||||
extern FILE *wfopen(const char *path, const char *mode);
|
||||
extern FILE *xfopen(const char *path, const char *mode);
|
||||
extern void chomp(char *s);
|
||||
extern void trim(char *s);
|
||||
extern struct BB_applet *find_applet_by_name(const char *name);
|
||||
void run_applet_by_name(const char *name, int argc, char **argv);
|
||||
|
||||
#ifndef DMALLOC
|
||||
extern void *xmalloc (size_t size);
|
||||
extern void *xrealloc(void *old, size_t size);
|
||||
extern void *xcalloc(size_t nmemb, size_t size);
|
||||
extern char *xstrdup (const char *s);
|
||||
#endif
|
||||
extern char *xstrndup (const char *s, int n);
|
||||
extern char * safe_strncpy(char *dst, const char *src, size_t size);
|
||||
|
||||
struct suffix_mult {
|
||||
char *suffix;
|
||||
int mult;
|
||||
};
|
||||
|
||||
extern unsigned long parse_number(const char *numstr,
|
||||
const struct suffix_mult *suffixes);
|
||||
|
||||
|
||||
/* These parse entries in /etc/passwd and /etc/group. This is desirable
|
||||
* for BusyBox since we want to avoid using the glibc NSS stuff, which
|
||||
* increases target size and is often not needed embedded systems. */
|
||||
extern long my_getpwnam(const char *name);
|
||||
extern long my_getgrnam(const char *name);
|
||||
extern void my_getpwuid(char *name, long uid);
|
||||
extern void my_getgrgid(char *group, long gid);
|
||||
extern long my_getpwnamegid(const char *name);
|
||||
|
||||
extern int device_open(char *device, int mode);
|
||||
|
||||
#if defined BB_FEATURE_MOUNT_LOOP
|
||||
extern int del_loop(const char *device);
|
||||
extern int set_loop(const char *device, const char *file, int offset, int *loopro);
|
||||
extern char *find_unused_loop_device (void);
|
||||
#endif
|
||||
|
||||
|
||||
#if (__GLIBC__ < 2) && (defined BB_SYSLOGD || defined BB_INIT)
|
||||
extern int vdprintf(int d, const char *format, va_list ap);
|
||||
#endif
|
||||
|
||||
#if defined BB_NFSMOUNT
|
||||
int nfsmount(const char *spec, const char *node, int *flags,
|
||||
char **extra_opts, char **mount_opts, int running_bg);
|
||||
#endif
|
||||
|
||||
#ifndef RB_POWER_OFF
|
||||
/* Stop system and switch power off if possible. */
|
||||
#define RB_POWER_OFF 0x4321fedc
|
||||
#endif
|
||||
|
||||
#if defined(BB_KLOGD) || defined(BB_LOGGER)
|
||||
void syslog_msg_with_name(const char *name, int facility, int pri, const char *msg);
|
||||
void syslog_msg(int facility, int pri, const char *msg);
|
||||
#endif
|
||||
|
||||
/* Include our own copy of struct sysinfo to avoid binary compatability
|
||||
* problems with Linux 2.4, which changed things. Grumble, grumble. */
|
||||
struct sysinfo {
|
||||
long uptime; /* Seconds since boot */
|
||||
unsigned long loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
unsigned long totalram; /* Total usable main memory size */
|
||||
unsigned long freeram; /* Available memory size */
|
||||
unsigned long sharedram; /* Amount of shared memory */
|
||||
unsigned long bufferram; /* Memory used by buffers */
|
||||
unsigned long totalswap; /* Total swap space size */
|
||||
unsigned long freeswap; /* swap space still available */
|
||||
unsigned short procs; /* Number of current processes */
|
||||
unsigned long totalhigh; /* Total high memory size */
|
||||
unsigned long freehigh; /* Available high memory size */
|
||||
unsigned int mem_unit; /* Memory unit size in bytes */
|
||||
char _f[20-2*sizeof(long)-sizeof(int)]; /* Padding: libc5 uses this.. */
|
||||
};
|
||||
extern int sysinfo (struct sysinfo* info);
|
||||
|
||||
/* Bit map related macros -- libc5 doens't provide these... sigh. */
|
||||
#ifndef setbit
|
||||
#define NBBY CHAR_BIT
|
||||
#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
|
||||
|
||||
#ifdef BB_FEATURE_HUMAN_READABLE
|
||||
const char *make_human_readable_str(unsigned long val, unsigned long hr);
|
||||
#endif
|
||||
enum {
|
||||
KILOBYTE = 1024,
|
||||
MEGABYTE = (KILOBYTE*1024),
|
||||
GIGABYTE = (MEGABYTE*1024)
|
||||
};
|
||||
|
||||
#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
|
||||
#define RESERVE_BB_BUFFER(buffer,len) char *buffer=xmalloc(len)
|
||||
#define RESERVE_BB_UBUFFER(buffer,len) unsigned char *buffer=xmalloc(len)
|
||||
#endif
|
||||
|
||||
#if defined(BB_FEATURE_RM_INTERACTIVE) && defined(BB_RM)
|
||||
int ask_confirmation(void);
|
||||
#endif
|
||||
|
||||
#endif /* _BB_INTERNAL_H_ */
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/sh
|
||||
# Make busybox links list file.
|
||||
|
||||
# input $1: full path to Config.h
|
||||
# input $2: full path to applets.h
|
||||
# output (stdout): list of pathnames that should be linked to busybox
|
||||
|
||||
# Maintainer: Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
|
||||
export LC_ALL=POSIX
|
||||
export LC_CTYPE=POSIX
|
||||
|
||||
CONFIG_H=${1:-Config.h}
|
||||
APPLETS_H=${2:-applets.h}
|
||||
gcc -E -DMAKE_LINKS -include $CONFIG_H $APPLETS_H |
|
||||
awk '/^[ \t]*LINK/{
|
||||
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
|
||||
cd ${2:-.}
|
||||
# By running $RAW through "ls", we avoid listing
|
||||
# source files that don't exist.
|
||||
ls $RAW 2>/dev/null | tr '\n' ' '
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
%define name busybox
|
||||
%define epoch 0
|
||||
%define version 0.61.pre
|
||||
%define release %(date -I | sed -e 's/-/_/g')
|
||||
%define serial 1
|
||||
|
||||
Name: %{name}
|
||||
#Epoch: %{epoch}
|
||||
Version: %{version}
|
||||
Release: %{release}
|
||||
Serial: %{serial}
|
||||
Copyright: GPL
|
||||
Name: busybox
|
||||
Version: 0.50
|
||||
Release: 1
|
||||
Group: System/Utilities
|
||||
Summary: BusyBox is a tiny suite of Unix utilities in a multi-call binary.
|
||||
URL: http://busybox.net/
|
||||
Source: ftp://busybox.net/busybox/%{name}-%{version}.tar.gz
|
||||
Buildroot: /var/tmp/%{name}-%{version}
|
||||
Packager : Erik Andersen <andersen@codepoet.org>
|
||||
Copyright: GPL
|
||||
Packager : Erik Andersen <andersen@lineo.com>
|
||||
Conflicts: fileutils grep shellutils
|
||||
Buildroot: /tmp/%{Name}-%{Version}
|
||||
Source: %{Name}-%{Version}.tar.gz
|
||||
|
||||
%Description
|
||||
BusyBox combines tiny versions of many common UNIX utilities into a single
|
||||
@@ -27,7 +19,7 @@ their full featured GNU cousins; however, the options that are provided behave
|
||||
very much like their GNU counterparts.
|
||||
|
||||
%Prep
|
||||
%setup -q -n %{name}-%{version}
|
||||
%setup -q -n %{Name}-%{Version}
|
||||
|
||||
%Build
|
||||
make
|
||||
@@ -39,6 +31,6 @@ make PREFIX=$RPM_BUILD_ROOT install
|
||||
%Clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%Files
|
||||
%Files
|
||||
%defattr(-,root,root)
|
||||
/
|
||||
-141
@@ -1,141 +0,0 @@
|
||||
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
|
||||
incorrect, _please_ let me know.
|
||||
|
||||
-Erik
|
||||
|
||||
-----------
|
||||
|
||||
Emanuele Aina <emanuele.aina@tiscali.it>
|
||||
run-parts
|
||||
|
||||
Erik Andersen <andersen@codepoet.org>
|
||||
Tons of new stuff, major rewrite of most of the
|
||||
core apps, tons of new apps as noted in header files.
|
||||
Lots of tedious effort writing these boring docs that
|
||||
nobody is going to actually read.
|
||||
|
||||
Laurence Anderson <l.d.anderson@warwick.ac.uk>
|
||||
rpm2cpio, unzip, get_header_cpio, read_gz interface, rpm
|
||||
|
||||
Jeff Angielski <jeff@theptrgroup.com>
|
||||
ftpput, ftpget
|
||||
|
||||
Jim Bauer <jfbauer@nfr.com>
|
||||
modprobe shell dependency
|
||||
|
||||
Edward Betts <edward@debian.org>
|
||||
expr, hostid, logname, whoami
|
||||
|
||||
John Beppu <beppu@codepoet.org>
|
||||
du, nslookup, sort
|
||||
|
||||
Brian Candler <B.Candler@pobox.com>
|
||||
tiny-ls(ls)
|
||||
|
||||
Randolph Chung <tausq@debian.org>
|
||||
fbset, ping, hostname
|
||||
|
||||
Dave Cinege <dcinege@psychosis.com>
|
||||
more(v2), makedevs, dutmp, modularization, auto links file,
|
||||
various fixes, Linux Router Project maintenance
|
||||
|
||||
Jordan Crouse <jordan@cosmicpenguin.net>
|
||||
ipcalc
|
||||
|
||||
Magnus Damm <damm@opensource.se>
|
||||
tftp client
|
||||
insmod powerpc support
|
||||
|
||||
Larry Doolittle <ldoolitt@recycle.lbl.gov>
|
||||
pristine source directory compilation, lots of patches and fixes.
|
||||
|
||||
Glenn Engel <glenne@engel.org>
|
||||
httpd
|
||||
|
||||
Gennady Feldman <gfeldman@gena01.com>
|
||||
Sysklogd (single threaded syslogd, IPC Circular buffer support,
|
||||
logread), various fixes.
|
||||
|
||||
Robert Griebl <sandman@handhelds.org>
|
||||
modprobe, hwclock, suid/sgid handling, tinylogin integration
|
||||
many bugfixes and enhancements
|
||||
|
||||
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.cmu.edu>
|
||||
documentation, bugfixes, test suite
|
||||
|
||||
Rob Landley <rob@landley.net>
|
||||
sed (major rewrite in 2003, and I now maintain the thing).
|
||||
bunzip2 (complete from-scratch rewrite, then mjn3 optimized the result.)
|
||||
I've patched lots of other applets, but don't maintain 'em.
|
||||
|
||||
Stephan Linz <linz@li-pro.net>
|
||||
ipcalc, Red Hat equivalence
|
||||
|
||||
John Lombardo <john@deltanet.com>
|
||||
tr
|
||||
|
||||
Glenn McGrath <bug1@iinet.net.au>
|
||||
Common unarchiving code and unarchiving applets, ifupdown, ftpgetput,
|
||||
nameif, sed, patch, fold, install, uudecode.
|
||||
Various bugfixes, review and apply numerous patches.
|
||||
|
||||
Manuel Novoa III <mjn3@codepoet.org>
|
||||
cat, head, mkfifo, mknod, rmdir, sleep, tee, tty, uniq, usleep, wc, yes,
|
||||
mesg, vconfig, make_directory, parse_mode, dirname, mode_string,
|
||||
get_last_path_component, simplify_path, and a number trivial libbb routines
|
||||
|
||||
also bug fixes, partial rewrites, and size optimizations in
|
||||
ash, basename, cal, cmp, cp, df, du, echo, env, ln, logname, md5sum, mkdir,
|
||||
mv, realpath, rm, sort, tail, touch, uname, watch, arith, human_readable,
|
||||
interface, dutmp, ifconfig, route
|
||||
|
||||
Vladimir Oleynik <dzo@simtreas.ru>
|
||||
cmdedit; xargs(current), httpd(current);
|
||||
ports: ash, crond, fdisk, inetd, stty, traceroute, top;
|
||||
locale, various fixes
|
||||
and irreconcilable critic of everything not perfect.
|
||||
|
||||
Bruce Perens <bruce@pixar.com>
|
||||
Original author of BusyBox in 1995, 1996. Some of his code can
|
||||
still be found hiding here and there...
|
||||
|
||||
Tim Riker <Tim@Rikers.org>
|
||||
bug fixes, member of fan club
|
||||
|
||||
Kent Robotti <robotti@metconnect.com>
|
||||
reset, tons and tons of bug reports and patches.
|
||||
|
||||
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@codepoet.org>
|
||||
grep, sed, cut, xargs(previous),
|
||||
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
|
||||
|
||||
Tito Ragusa <farmatito@tiscali.it>
|
||||
devfsd and size optimizations in strings, openvt, chvt, deallocvt, hdparm and fdformat.
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
1) Run 'make config' or 'make menuconfig' and select the
|
||||
functionality that you wish to enable.
|
||||
|
||||
2) Run 'make dep'
|
||||
|
||||
3) Check the Makefile for any Makefile setting you wish
|
||||
to adjust for your system (things like like setting
|
||||
your cross compiler, adjusting optimizations, etc)
|
||||
|
||||
4) Run 'make'
|
||||
|
||||
5) Go get a drink of water, drink a soda, visit the bathroom,
|
||||
or whatever while it compiles. It doesn't take very
|
||||
long to compile, so you don't really need to waste too
|
||||
much time waiting...
|
||||
|
||||
6) Run 'make install' or 'make PREFIX=/target install' to
|
||||
install busybox and all the needed links. Some people
|
||||
will prefer to install using hardlinks and will instead
|
||||
want to run 'make install-hardlinks'....
|
||||
@@ -1,314 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
#
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# You shouldn't need to mess with anything beyond this point...
|
||||
#--------------------------------------------------------------
|
||||
noconfig_targets := menuconfig config oldconfig randconfig \
|
||||
defconfig allyesconfig allnoconfig clean distclean \
|
||||
release tags
|
||||
|
||||
ifndef TOPDIR
|
||||
TOPDIR=$(CURDIR)/
|
||||
endif
|
||||
ifndef top_srcdir
|
||||
top_srcdir=$(CURDIR)
|
||||
endif
|
||||
ifndef top_builddir
|
||||
top_builddir=$(CURDIR)
|
||||
endif
|
||||
|
||||
export srctree=$(top_srcdir)
|
||||
vpath %/Config.in $(srctree)
|
||||
|
||||
include $(top_builddir)/Rules.mak
|
||||
|
||||
DIRS:=applets archival archival/libunarchive coreutils console-tools \
|
||||
debianutils editors findutils init miscutils modutils networking \
|
||||
networking/libiproute networking/udhcp procps loginutils shell \
|
||||
sysklogd util-linux libpwdgrp coreutils/libcoreutils libbb
|
||||
|
||||
SRC_DIRS:=$(patsubst %,$(top_srcdir)/%,$(DIRS))
|
||||
|
||||
ifeq ($(strip $(CONFIG_SELINUX)),y)
|
||||
CFLAGS += -I/usr/include/selinux
|
||||
LIBRARIES += -lsecure
|
||||
endif
|
||||
|
||||
CONFIG_CONFIG_IN = $(top_srcdir)/sysdeps/$(TARGET_OS)/Config.in
|
||||
CONFIG_DEFCONFIG = $(top_srcdir)/sysdeps/$(TARGET_OS)/defconfig
|
||||
|
||||
ALL_DIRS:= $(DIRS) scripts/config
|
||||
ALL_MAKEFILES:=$(patsubst %,%/Makefile,$(ALL_DIRS))
|
||||
|
||||
ifeq ($(KBUILD_SRC),)
|
||||
|
||||
ifdef O
|
||||
ifeq ("$(origin O)", "command line")
|
||||
KBUILD_OUTPUT := $(O)
|
||||
endif
|
||||
endif
|
||||
|
||||
# That's our default target when none is given on the command line
|
||||
.PHONY: _all
|
||||
_all:
|
||||
|
||||
ifneq ($(KBUILD_OUTPUT),)
|
||||
# Invoke a second make in the output directory, passing relevant variables
|
||||
# check that the output directory actually exists
|
||||
saved-output := $(KBUILD_OUTPUT)
|
||||
KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
|
||||
$(if $(wildcard $(KBUILD_OUTPUT)),, \
|
||||
$(error output directory "$(saved-output)" does not exist))
|
||||
|
||||
.PHONY: $(MAKECMDGOALS)
|
||||
|
||||
$(filter-out _all,$(MAKECMDGOALS)) _all: $(KBUILD_OUTPUT)/Rules.mak $(KBUILD_OUTPUT)/Makefile
|
||||
$(MAKE) -C $(KBUILD_OUTPUT) \
|
||||
top_srcdir=$(CURDIR) \
|
||||
top_builddir=$(KBUILD_OUTPUT) \
|
||||
TOPDIR=$(KBUILD_OUTPUT) \
|
||||
KBUILD_SRC=$(CURDIR) \
|
||||
-f $(CURDIR)/Makefile $@
|
||||
|
||||
$(KBUILD_OUTPUT)/Rules.mak:
|
||||
@echo > $@
|
||||
@echo top_srcdir=$(CURDIR) >> $@
|
||||
@echo top_builddir=$(KBUILD_OUTPUT) >> $@
|
||||
@echo include $(top_srcdir)/Rules.mak >> $@
|
||||
|
||||
$(KBUILD_OUTPUT)/Makefile:
|
||||
@echo > $@
|
||||
@echo top_srcdir=$(CURDIR) >> $@
|
||||
@echo top_builddir=$(KBUILD_OUTPUT) >> $@
|
||||
@echo KBUILD_SRC='$$(top_srcdir)' >> $@
|
||||
@echo include '$$(KBUILD_SRC)'/Makefile >> $@
|
||||
|
||||
# Leave processing to above invocation of make
|
||||
skip-makefile := 1
|
||||
endif # ifneq ($(KBUILD_OUTPUT),)
|
||||
endif # ifeq ($(KBUILD_SRC),)
|
||||
|
||||
ifeq ($(skip-makefile),)
|
||||
|
||||
_all: all
|
||||
|
||||
ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
|
||||
|
||||
all: busybox busybox.links doc
|
||||
|
||||
all_tree: $(ALL_MAKEFILES)
|
||||
|
||||
$(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile
|
||||
d=`dirname $@`; [ -d "$$d" ] || mkdir -p "$$d"; cp $< $@
|
||||
|
||||
# In this section, we need .config
|
||||
-include $(top_builddir)/.config.cmd
|
||||
include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
busybox: $(ALL_MAKEFILES) .depend include/config.h $(libraries-y)
|
||||
$(CC) $(LDFLAGS) -o $@ -Wl,--start-group $(libraries-y) $(LIBRARIES) -Wl,--end-group
|
||||
$(STRIPCMD) $@
|
||||
|
||||
busybox.links: $(top_srcdir)/applets/busybox.mkll include/config.h $(top_srcdir)/include/applets.h
|
||||
- $(SHELL) $^ >$@
|
||||
|
||||
install: applets/install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX)
|
||||
ifeq ($(strip $(CONFIG_FEATURE_SUID)),y)
|
||||
@echo
|
||||
@echo
|
||||
@echo --------------------------------------------------
|
||||
@echo You will probably need to make your busybox binary
|
||||
@echo setuid root to ensure all configured applets will
|
||||
@echo work properly.
|
||||
@echo --------------------------------------------------
|
||||
@echo
|
||||
endif
|
||||
|
||||
uninstall: busybox.links
|
||||
rm -f $(PREFIX)/bin/busybox
|
||||
for i in `cat busybox.links` ; do rm -f $(PREFIX)$$i; done
|
||||
|
||||
install-hardlinks: $(top_srcdir)/applets/install.sh busybox busybox.links
|
||||
$(SHELL) $< $(PREFIX) --hardlinks
|
||||
|
||||
check: busybox
|
||||
bindir=$(top_builddir) srcdir=$(top_srcdir)/testsuite \
|
||||
$(top_srcdir)/testsuite/runtest
|
||||
|
||||
# Documentation Targets
|
||||
doc: docs/busybox.pod docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html
|
||||
|
||||
docs/busybox.pod : $(top_srcdir)/docs/busybox_header.pod $(top_srcdir)/include/usage.h $(top_srcdir)/docs/busybox_footer.pod
|
||||
-mkdir -p docs
|
||||
- ( cat $(top_srcdir)/docs/busybox_header.pod; \
|
||||
$(top_srcdir)/docs/autodocifier.pl $(top_srcdir)/include/usage.h; \
|
||||
cat $(top_srcdir)/docs/busybox_footer.pod ) > docs/busybox.pod
|
||||
|
||||
docs/BusyBox.txt: docs/busybox.pod
|
||||
$(SECHO)
|
||||
$(SECHO) BusyBox Documentation
|
||||
$(SECHO)
|
||||
-mkdir -p docs
|
||||
-pod2text $< > $@
|
||||
|
||||
docs/BusyBox.1: docs/busybox.pod
|
||||
- mkdir -p docs
|
||||
- pod2man --center=BusyBox --release="version $(VERSION)" \
|
||||
$< > $@
|
||||
|
||||
docs/BusyBox.html: docs/busybox.net/BusyBox.html
|
||||
- mkdir -p docs
|
||||
-@ rm -f docs/BusyBox.html
|
||||
-@ cp docs/busybox.net/BusyBox.html docs/BusyBox.html
|
||||
|
||||
docs/busybox.net/BusyBox.html: docs/busybox.pod
|
||||
-@ mkdir -p docs/busybox.net
|
||||
- pod2html --noindex $< > \
|
||||
docs/busybox.net/BusyBox.html
|
||||
-@ rm -f pod2htm*
|
||||
|
||||
# The nifty new buildsystem stuff
|
||||
scripts/mkdep: $(top_srcdir)/scripts/mkdep.c
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
|
||||
|
||||
scripts/split-include: $(top_srcdir)/scripts/split-include.c
|
||||
$(HOSTCC) $(HOSTCFLAGS) -o $@ $<
|
||||
|
||||
.depend: scripts/mkdep include/config.h
|
||||
rm -f .depend .hdepend;
|
||||
mkdir -p include/config;
|
||||
scripts/mkdep -I include -- \
|
||||
`find $(top_srcdir) -name \*.c -print | sed -e "s,^./,,"` >> .depend;
|
||||
scripts/mkdep -I include -- \
|
||||
`find $(top_srcdir) -name \*.h -print | sed -e "s,^./,,"` >> .hdepend;
|
||||
|
||||
depend dep: .depend
|
||||
|
||||
include/config/MARKER: depend scripts/split-include
|
||||
scripts/split-include include/config.h include/config
|
||||
@ touch include/config/MARKER
|
||||
|
||||
include/config.h: .config
|
||||
@if [ ! -x $(top_builddir)/scripts/config/conf ] ; then \
|
||||
$(MAKE) -C scripts/config conf; \
|
||||
fi;
|
||||
@$(top_builddir)/scripts/config/conf -o $(CONFIG_CONFIG_IN)
|
||||
|
||||
finished2:
|
||||
$(SECHO)
|
||||
$(SECHO) Finished installing...
|
||||
$(SECHO)
|
||||
|
||||
else # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
|
||||
|
||||
all: menuconfig
|
||||
|
||||
# configuration
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
$(ALL_MAKEFILES): %/Makefile: $(top_srcdir)/%/Makefile
|
||||
d=`dirname $@`; [ -d "$$d" ] || mkdir -p "$$d"; cp $< $@
|
||||
|
||||
scripts/config/conf: scripts/config/Makefile Rules.mak
|
||||
$(MAKE) -C scripts/config conf
|
||||
-@if [ ! -f .config ] ; then \
|
||||
cp $(CONFIG_DEFCONFIG) .config; \
|
||||
fi
|
||||
|
||||
scripts/config/mconf: scripts/config/Makefile Rules.mak
|
||||
$(MAKE) -C scripts/config ncurses conf mconf
|
||||
-@if [ ! -f .config ] ; then \
|
||||
cp $(CONFIG_DEFCONFIG) .config; \
|
||||
fi
|
||||
|
||||
menuconfig: scripts/config/mconf
|
||||
@./scripts/config/mconf $(CONFIG_CONFIG_IN)
|
||||
|
||||
config: scripts/config/conf
|
||||
@./scripts/config/conf $(CONFIG_CONFIG_IN)
|
||||
|
||||
oldconfig: scripts/config/conf
|
||||
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
|
||||
|
||||
randconfig: scripts/config/conf
|
||||
@./scripts/config/conf -r $(CONFIG_CONFIG_IN)
|
||||
|
||||
allyesconfig: scripts/config/conf
|
||||
@./scripts/config/conf -y $(CONFIG_CONFIG_IN)
|
||||
sed -i -e "s/^CONFIG_DEBUG.*/# CONFIG_DEBUG is not set/" .config
|
||||
sed -i -e "s/^USING_CROSS_COMPILER.*/# USING_CROSS_COMPILER is not set/" .config
|
||||
sed -i -e "s/^CONFIG_STATIC.*/# CONFIG_STATIC is not set/" .config
|
||||
sed -i -e "s/^CONFIG_SELINUX.*/# CONFIG_SELINUX is not set/" .config
|
||||
@./scripts/config/conf -o $(CONFIG_CONFIG_IN)
|
||||
|
||||
allnoconfig: scripts/config/conf
|
||||
@./scripts/config/conf -n $(CONFIG_CONFIG_IN)
|
||||
|
||||
defconfig: scripts/config/conf
|
||||
@./scripts/config/conf -d $(CONFIG_CONFIG_IN)
|
||||
|
||||
clean:
|
||||
- rm -f docs/busybox.dvi docs/busybox.ps \
|
||||
docs/busybox.pod docs/busybox.net/busybox.html \
|
||||
docs/busybox pod2htm* *.gdb *.elf *~ core .*config.log \
|
||||
docs/BusyBox.txt docs/BusyBox.1 docs/BusyBox.html \
|
||||
docs/busybox.net/BusyBox.html busybox.links libbb/loop.h \
|
||||
.config.old .hdepend busybox
|
||||
- rm -rf _install
|
||||
- find . -name .\*.flags -exec rm -f {} \;
|
||||
- find . -name \*.o -exec rm -f {} \;
|
||||
- find . -name \*.a -exec rm -f {} \;
|
||||
|
||||
distclean: clean
|
||||
- rm -f scripts/split-include scripts/mkdep
|
||||
- rm -rf include/config include/config.h
|
||||
- find . -name .depend -exec rm -f {} \;
|
||||
rm -f .config .config.old .config.cmd
|
||||
- $(MAKE) -C scripts/config clean
|
||||
|
||||
release: distclean #doc
|
||||
cd ..; \
|
||||
rm -rf $(PROG)-$(VERSION); \
|
||||
cp -a busybox $(PROG)-$(VERSION); \
|
||||
\
|
||||
find $(PROG)-$(VERSION)/ -type d \
|
||||
-name .svn \
|
||||
-print \
|
||||
-exec rm -rf {} \; ; \
|
||||
\
|
||||
find $(PROG)-$(VERSION)/ -type f \
|
||||
-name .\#* \
|
||||
-print \
|
||||
-exec rm -f {} \; ; \
|
||||
\
|
||||
tar -cvzf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)/;
|
||||
|
||||
tags:
|
||||
ctags -R .
|
||||
|
||||
|
||||
endif # ifeq ($(strip $(HAVE_DOT_CONFIG)),y)
|
||||
|
||||
endif # ifeq ($(skip-makefile),)
|
||||
|
||||
.PHONY: dummy subdirs release distclean clean config oldconfig \
|
||||
menuconfig tags check test depend buildtree
|
||||
-196
@@ -1,196 +0,0 @@
|
||||
Please see the LICENSE file for details on copying and usage.
|
||||
|
||||
What is busybox:
|
||||
|
||||
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 bzip2, coreutils, file, findutils, gawk, grep,
|
||||
inetutils, modutils, net-tools, procps, sed, shadow, sysklogd, sysvinit, tar,
|
||||
util-linux, and vim. The utilities in BusyBox often have fewer options than
|
||||
their full-featured cousins; however, the options that are included provide
|
||||
the expected functionality and behave very much like their larger
|
||||
counterparts.
|
||||
|
||||
BusyBox has been written with size-optimization and limited resources in
|
||||
mind, both to produce small binaries and to reduce run-time memory usage.
|
||||
Busybox is also extremely modular so you can easily include or exclude
|
||||
commands (or features) at compile time. This makes it easy to customize
|
||||
embedded systems; to create a working system, just add /dev, /etc, and a
|
||||
Linux kernel. Busybox (usually together with uClibc) has also been used as
|
||||
a component of "thin client" desktop systems, live-CD distributions, rescue
|
||||
disks, installers, and so on.
|
||||
|
||||
BusyBox provides a fairly complete POSIX environment for any small system,
|
||||
both embedded environments and more full featured systems concerned about
|
||||
space. Busybox is slowly working towards implementing the full Single Unix
|
||||
Specification V3 (http://www.opengroup.org/onlinepubs/009695399/), but isn't
|
||||
there yet (and for size reasons will probably support at most UTF-8 for
|
||||
internationalization). We are also interested in passing the Linux Test
|
||||
Project (http://ltp.sourceforge.net).
|
||||
|
||||
----------------
|
||||
|
||||
Using busybox:
|
||||
|
||||
BusyBox is extremely configurable. This allows you to include only the
|
||||
components and options you need, thereby reducing binary size. Run 'make
|
||||
config' or 'make menuconfig' to select the functionality that you wish to
|
||||
enable.
|
||||
|
||||
The behavior of busybox is determined by the name it's called under: as
|
||||
"cp" it behaves like cp, as "sed" it behaves like sed, and so on. Called
|
||||
as "busybox" it takes the second argument as the name of the applet to
|
||||
run (I.E. "./busybox ls -l /proc").
|
||||
|
||||
The "standalone shell" mode is an easy way to try out busybox; this is a
|
||||
command shell that calls the builtin applets without needing them to be
|
||||
installed in the path. (Note that this requires /proc to be mounted, if
|
||||
testing from a boot floppy or in a chroot environment.)
|
||||
|
||||
The build automatically generates a file "busybox.links", which is used by
|
||||
'make install' to create symlinks to the BusyBox binary for all compiled in
|
||||
commands. Use the PREFIX environment variable to specify where to install
|
||||
the busybox binary and symlink forest. (i.e., 'make PREFIX=/tmp/foo install',
|
||||
or 'make PREFIX=/tmp/foo install-hardlinks' if you prefer hard links.)
|
||||
|
||||
----------------
|
||||
|
||||
Downloading the current source code:
|
||||
|
||||
Source for the latest released version, as well as daily snapshots, can always
|
||||
be downloaded from
|
||||
|
||||
http://busybox.net/downloads/
|
||||
|
||||
You can browse the up to the minute source code and change history online
|
||||
at:
|
||||
|
||||
http://www.busybox.net/cgi-bin/viewcvs.cgi/branches/busybox_1_00_stable/busybox/
|
||||
|
||||
Anonymous SVN access is available. For instructions, check out:
|
||||
|
||||
http://busybox.net/subversion.html
|
||||
|
||||
For those that are actively contributing and would like to check files in,
|
||||
see:
|
||||
|
||||
http://busybox.net/developer.html
|
||||
|
||||
The developers also have a bug and patch tracking system
|
||||
(http://bugs.busybox.net) although posting a bug/patch to the mailing list
|
||||
is generally a faster way of getting it fixed, and the complete archive of
|
||||
what happened is the subversion changelog.
|
||||
|
||||
----------------
|
||||
|
||||
getting help:
|
||||
|
||||
when you find you need help, you can check out the busybox mailing list
|
||||
archives at http://busybox.net/lists/busybox/ or even join
|
||||
the mailing list if you are interested.
|
||||
|
||||
----------------
|
||||
|
||||
bugs:
|
||||
|
||||
if you find bugs, please submit a detailed bug report to the busybox mailing
|
||||
list at busybox@busybox.net. a well-written bug report should include a
|
||||
transcript of a shell session that demonstrates the bad behavior and enables
|
||||
anyone else to duplicate the bug on their own machine. the following is such
|
||||
an example:
|
||||
|
||||
to: busybox@mail.busybox.net
|
||||
from: diligent@testing.linux.org
|
||||
subject: /bin/date doesn't work
|
||||
|
||||
package: busybox
|
||||
version: 1.00
|
||||
|
||||
when i execute busybox 'date' it produces unexpected results.
|
||||
with gnu date i get the following output:
|
||||
|
||||
$ date
|
||||
fri oct 8 14:19:41 mdt 2004
|
||||
|
||||
but when i use busybox date i get this instead:
|
||||
|
||||
$ date
|
||||
illegal instruction
|
||||
|
||||
i am using debian unstable, kernel version 2.4.25-vrs2 on a netwinder,
|
||||
and the latest uclibc from cvs. thanks for the wonderful program!
|
||||
|
||||
-diligent
|
||||
|
||||
note the careful description and use of examples showing not only what
|
||||
busybox does, but also a counter example showing what an equivalent app
|
||||
does (or pointing to the text of a relevant standard). Bug reports lacking
|
||||
such detail may never be fixed... Thanks for understanding.
|
||||
|
||||
----------------
|
||||
|
||||
Portability:
|
||||
|
||||
Busybox is developed and tested on Linux 2.4 and 2.6 kernels, linked
|
||||
against uClibc (0.9.27 or greater) and glibc (2.2 or greater). In such
|
||||
an environment, the full set of busybox features should work (and if
|
||||
anything doesn't we want to know about it so we can fix it). Note that
|
||||
the 2.6 kernel can be trimmed down considerably with the aid of Matt
|
||||
Mackall's -tiny work (http://www.selenic.com/tiny-about/).
|
||||
|
||||
Since busybox consists of a large number of more or less independent
|
||||
applets, portability is a question of which features work where. Some
|
||||
busybox applets (such as cat and rm) are highly portable and likely to work
|
||||
just about anywhere, while others (such as insmod and losetup) are only
|
||||
likely to work under fairly recent Linux kernels with recent C libraries.
|
||||
|
||||
Earlier versions of Linux and glibc may or may not work, for any given
|
||||
configuration. Linux 2.2 or earlier should mostly work, but this is no
|
||||
longer regularly tested and inherently won't support certain features (such
|
||||
as long files and --bind mounts). The same is true for glibc 2.0 and 2.1,
|
||||
expect a higher testing and debugging burden using such old infrastructure.
|
||||
(The busybox developers are not very interested in supporting these older
|
||||
versions, but can probably be talked into accepting small patches to fix
|
||||
simple problems.)
|
||||
|
||||
Some environments are not recommended. Early versions of uClibc were buggy
|
||||
and missing many features: upgrade. Linking against libc5 or dietlibc is
|
||||
not supported and not interesting to the busybox developers. (The first is
|
||||
obsolete and has no known size or feature advantages over uClibc, the second
|
||||
has known bugs that its developers have actively refused to fix.) Ancient
|
||||
Linux kernels (2.0.x and earlier) are similarly uninteresting.
|
||||
|
||||
In theory it's possible to use Busybox under other operating systems (such as
|
||||
MacOS X, Solaris, Cygwin, or the BSD Fork Du Jour). This generally involves
|
||||
a different kernel and a different C library at the same time. While it
|
||||
should be possible to port the majority of the code to work in one of
|
||||
these environments, don't be suprised if it doesn't work out of the box. If
|
||||
you're into that sort of thing, start small (selecting just a few applets)
|
||||
and work your way up.
|
||||
|
||||
Shaun Jackman has recently (2005) ported busybox to a combination of newlib
|
||||
and libgloss, and some of his patches have been integrated. This platform
|
||||
may join glibc/uclibc and Linux as a supported combination with the 1.1
|
||||
release, but is not supported in 1.0.
|
||||
|
||||
Supported hardware:
|
||||
|
||||
BusyBox in general will build on any architecture supported by gcc. We
|
||||
support both 32 and 64 bit platforms, and both big and little endian
|
||||
systems.
|
||||
|
||||
Under 2.4 Linux kernels, kernel module loading was implemented in a
|
||||
platform-specific manner. Busybox's insmod utility has been reported to
|
||||
work under ARM, CRIS, H8/300, x86, ia64, x86_64, m68k, MIPS, PowerPC, S390,
|
||||
SH3/4/5, Sparc, v850e, and x86_64. Anything else probably won't work.
|
||||
|
||||
The module loading mechanism for the 2.6 kernel is much more generic, and
|
||||
we believe 2.6.x kernel module loading support should work on all
|
||||
architectures supported by the kernel.
|
||||
|
||||
----------------
|
||||
|
||||
Please feed suggestions, bug reports, insults, and bribes back to the busybox
|
||||
maintainer:
|
||||
Erik Andersen
|
||||
<andersen@codepoet.org>
|
||||
@@ -1,200 +0,0 @@
|
||||
# Rules.make for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
#
|
||||
|
||||
#--------------------------------------------------------
|
||||
PROG := busybox
|
||||
VERSION := 1.01
|
||||
BUILDTIME := $(shell TZ=UTC date -u "+%Y.%m.%d-%H:%M%z")
|
||||
|
||||
|
||||
#--------------------------------------------------------
|
||||
# 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 are running a cross compiler, you will want to set 'CROSS'
|
||||
# to something more interesting... Target architecture is determined
|
||||
# by asking the CC compiler what arch it compiles things for, so unless
|
||||
# your compiler is broken, you should not need to specify TARGET_ARCH
|
||||
CROSS =$(subst ",, $(strip $(CROSS_COMPILER_PREFIX)))
|
||||
CC = $(CROSS)gcc
|
||||
AR = $(CROSS)ar
|
||||
AS = $(CROSS)as
|
||||
LD = $(CROSS)ld
|
||||
NM = $(CROSS)nm
|
||||
STRIP = $(CROSS)strip
|
||||
CPP = $(CC) -E
|
||||
# MAKEFILES = $(top_builddir)/.config
|
||||
|
||||
# What OS are you compiling busybox for? This allows you to include
|
||||
# OS specific things, syscall overrides, etc.
|
||||
TARGET_OS=linux
|
||||
|
||||
# Select the compiler needed to build binaries for your development system
|
||||
HOSTCC = gcc
|
||||
HOSTCFLAGS= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer
|
||||
|
||||
# Ensure consistent sort order, 'gcc -print-search-dirs' behavior, etc.
|
||||
LC_ALL:= C
|
||||
|
||||
# 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=$(subst ",, $(strip $(EXTRA_CFLAGS_OPTIONS)))
|
||||
|
||||
# If you have a "pristine" source directory, point BB_SRC_DIR to it.
|
||||
# Experimental and incomplete; tell the mailing list
|
||||
# <busybox@busybox.net> if you do or don't like it so far.
|
||||
BB_SRC_DIR=
|
||||
|
||||
# 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
|
||||
#
|
||||
# For other libraries, you are on your own. But these may (or may not) help...
|
||||
#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")
|
||||
|
||||
WARNINGS=-Wall -Wstrict-prototypes -Wshadow
|
||||
CFLAGS=-I$(top_builddir)/include -I$(top_srcdir)/include -I$(srcdir)
|
||||
ARFLAGS=cru
|
||||
|
||||
#--------------------------------------------------------
|
||||
export VERSION BUILDTIME TOPDIR HOSTCC HOSTCFLAGS CROSS CC AR AS LD NM STRIP CPP
|
||||
ifeq ($(strip $(TARGET_ARCH)),)
|
||||
TARGET_ARCH:=$(shell $(CC) -dumpmachine | sed -e s'/-.*//' \
|
||||
-e 's/i.86/i386/' \
|
||||
-e 's/sparc.*/sparc/' \
|
||||
-e 's/arm.*/arm/g' \
|
||||
-e 's/m68k.*/m68k/' \
|
||||
-e 's/ppc/powerpc/g' \
|
||||
-e 's/v850.*/v850/g' \
|
||||
-e 's/sh[234]/sh/' \
|
||||
-e 's/mips-.*/mips/' \
|
||||
-e 's/mipsel-.*/mipsel/' \
|
||||
-e 's/cris.*/cris/' \
|
||||
)
|
||||
endif
|
||||
|
||||
# Pull in the user's busybox configuration
|
||||
ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
|
||||
-include $(top_builddir)/.config
|
||||
endif
|
||||
|
||||
# A nifty macro to make testing gcc features easier
|
||||
check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
|
||||
then echo "$(1)"; else echo "$(2)"; fi)
|
||||
|
||||
# Setup some shortcuts so that silent mode is silent like it should be
|
||||
ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS))
|
||||
export MAKE_IS_SILENT=n
|
||||
SECHO=@echo
|
||||
else
|
||||
export MAKE_IS_SILENT=y
|
||||
SECHO=-@false
|
||||
endif
|
||||
|
||||
#--------------------------------------------------------
|
||||
# Arch specific compiler optimization stuff should go here.
|
||||
# Unless you want to override the defaults, do not set anything
|
||||
# for OPTIMIZATION...
|
||||
|
||||
# use '-Os' optimization if available, else use -O2
|
||||
OPTIMIZATION:=${call check_gcc,-Os,-O2}
|
||||
|
||||
# Some nice architecture specific optimizations
|
||||
ifeq ($(strip $(TARGET_ARCH)),arm)
|
||||
OPTIMIZATION+=-fstrict-aliasing
|
||||
endif
|
||||
ifeq ($(strip $(TARGET_ARCH)),i386)
|
||||
OPTIMIZATION+=$(call check_gcc,-march=i386,)
|
||||
OPTIMIZATION+=$(call check_gcc,-mpreferred-stack-boundary=2,)
|
||||
OPTIMIZATION+=$(call check_gcc,-falign-functions=0 -falign-jumps=0 -falign-loops=0,\
|
||||
-malign-functions=0 -malign-jumps=0 -malign-loops=0)
|
||||
endif
|
||||
OPTIMIZATIONS=$(OPTIMIZATION) -fomit-frame-pointer
|
||||
|
||||
#
|
||||
#--------------------------------------------------------
|
||||
# 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 $(CONFIG_LFS)),y)
|
||||
# For large file summit support
|
||||
CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
|
||||
endif
|
||||
ifeq ($(strip $(CONFIG_DMALLOC)),y)
|
||||
# For testing mem leaks with dmalloc
|
||||
CFLAGS+=-DDMALLOC
|
||||
LIBRARIES:=-ldmalloc
|
||||
else
|
||||
ifeq ($(strip $(CONFIG_EFENCE)),y)
|
||||
LIBRARIES:=-lefence
|
||||
endif
|
||||
endif
|
||||
ifeq ($(strip $(CONFIG_DEBUG)),y)
|
||||
CFLAGS +=$(WARNINGS) -g -D_GNU_SOURCE
|
||||
LDFLAGS +=-Wl,-warn-common
|
||||
STRIPCMD:=/bin/true -Not_stripping_since_we_are_debugging
|
||||
else
|
||||
CFLAGS+=$(WARNINGS) $(OPTIMIZATIONS) -D_GNU_SOURCE -DNDEBUG
|
||||
LDFLAGS += -Wl,-warn-common
|
||||
STRIPCMD:=$(STRIP) -s --remove-section=.note --remove-section=.comment
|
||||
endif
|
||||
ifeq ($(strip $(CONFIG_STATIC)),y)
|
||||
LDFLAGS += --static
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(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
|
||||
|
||||
OBJECTS:=$(APPLET_SOURCES:.c=.o) busybox.o usage.o applets.o
|
||||
CFLAGS += $(CROSS_CFLAGS)
|
||||
ifdef BB_INIT_SCRIPT
|
||||
CFLAGS += -DINIT_SCRIPT='"$(BB_INIT_SCRIPT)"'
|
||||
endif
|
||||
|
||||
# Put user-supplied flags at the end, where they
|
||||
# have a chance of winning.
|
||||
CFLAGS += $(CFLAGS_EXTRA)
|
||||
|
||||
.PHONY: dummy
|
||||
@@ -1,11 +0,0 @@
|
||||
Busybox TODO
|
||||
|
||||
Stuff that needs to be done
|
||||
|
||||
----
|
||||
tr - missing SuS3 features in busybox 1.0pre10
|
||||
|
||||
tr doesnt support [:blank:], [:digit:] or other predefined classes, [=equiv=]
|
||||
support is also missing.
|
||||
----
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
#
|
||||
|
||||
top_srcdir=..
|
||||
top_builddir=..
|
||||
srcdir=$(top_srcdir)/applets
|
||||
APPLETS_DIR:=./
|
||||
include $(top_builddir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(top_builddir).depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
#
|
||||
|
||||
APPLETS_AR:=applets.a
|
||||
ifndef $(APPLETS_DIR)
|
||||
APPLETS_DIR:=$(top_builddir)/applets/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/applets
|
||||
|
||||
APPLET_SRC:=applets.c busybox.c
|
||||
APPLET_OBJ:= $(patsubst %.c,$(APPLETS_DIR)%.o, $(APPLET_SRC))
|
||||
|
||||
libraries-y+=$(APPLETS_DIR)$(APPLETS_AR)
|
||||
|
||||
$(APPLETS_DIR)$(APPLETS_AR): $(APPLET_OBJ)
|
||||
$(AR) $(ARFLAGS) $@ $(APPLET_OBJ)
|
||||
|
||||
$(APPLET_OBJ): $(top_builddir)/.config
|
||||
$(APPLET_OBJ): $(APPLETS_DIR)%.o: $(srcdir)/%.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
@@ -1,512 +0,0 @@
|
||||
/* 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 <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "busybox.h"
|
||||
|
||||
const char usage_messages[] =
|
||||
|
||||
#define MAKE_USAGE
|
||||
#include "usage.h"
|
||||
|
||||
#include "applets.h"
|
||||
|
||||
;
|
||||
|
||||
#undef MAKE_USAGE
|
||||
#undef APPLET
|
||||
#undef APPLET_NOUSAGE
|
||||
#undef PROTOTYPES
|
||||
#include "applets.h"
|
||||
|
||||
|
||||
static struct BB_applet *applet_using;
|
||||
|
||||
/* The -1 arises because of the {0,NULL,0,-1} entry above. */
|
||||
const size_t NUM_APPLETS = (sizeof (applets) / sizeof (struct BB_applet) - 1);
|
||||
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID
|
||||
|
||||
static void check_suid (struct BB_applet *app);
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
#include "pwd_.h"
|
||||
#include "grp_.h"
|
||||
|
||||
static void parse_config_file (void);
|
||||
|
||||
#define CONFIG_FILE "/etc/busybox.conf"
|
||||
|
||||
/* applets [] is const, so we have to define this "override" structure */
|
||||
struct BB_suid_config
|
||||
{
|
||||
struct BB_applet *m_applet;
|
||||
|
||||
uid_t m_uid;
|
||||
gid_t m_gid;
|
||||
mode_t m_mode;
|
||||
|
||||
struct BB_suid_config *m_next;
|
||||
};
|
||||
|
||||
static struct BB_suid_config *suid_config;
|
||||
static int suid_cfg_readable;
|
||||
|
||||
#endif /* CONFIG_FEATURE_SUID_CONFIG */
|
||||
|
||||
#endif /* CONFIG_FEATURE_SUID */
|
||||
|
||||
|
||||
|
||||
extern void
|
||||
bb_show_usage (void)
|
||||
{
|
||||
const char *format_string;
|
||||
const char *usage_string = usage_messages;
|
||||
int i;
|
||||
|
||||
for (i = applet_using - applets; i > 0;) {
|
||||
if (!*usage_string++) {
|
||||
--i;
|
||||
}
|
||||
}
|
||||
|
||||
format_string = "%s\n\nUsage: %s %s\n\n";
|
||||
if (*usage_string == '\b')
|
||||
format_string = "%s\n\nNo help available.\n\n";
|
||||
fprintf (stderr, format_string, bb_msg_full_version, applet_using->name,
|
||||
usage_string);
|
||||
|
||||
exit (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;
|
||||
extern int been_there_done_that; /* From busybox.c */
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
if (recurse_level == 0)
|
||||
parse_config_file ();
|
||||
#endif
|
||||
|
||||
recurse_level++;
|
||||
/* Do a binary search to find the applet entry given the name. */
|
||||
if ((applet_using = find_applet_by_name (name)) != NULL) {
|
||||
bb_applet_name = applet_using->name;
|
||||
if (argv[1] && strcmp (argv[1], "--help") == 0) {
|
||||
if (strcmp (applet_using->name, "busybox") == 0) {
|
||||
if (argv[2])
|
||||
applet_using = find_applet_by_name (argv[2]);
|
||||
else
|
||||
applet_using = NULL;
|
||||
}
|
||||
if (applet_using)
|
||||
bb_show_usage ();
|
||||
been_there_done_that = 1;
|
||||
busybox_main (0, NULL);
|
||||
}
|
||||
#ifdef CONFIG_FEATURE_SUID
|
||||
check_suid (applet_using);
|
||||
#endif
|
||||
|
||||
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--;
|
||||
}
|
||||
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
|
||||
/* check if u is member of group g */
|
||||
static int
|
||||
ingroup (uid_t u, gid_t g)
|
||||
{
|
||||
struct group *grp = getgrgid (g);
|
||||
|
||||
if (grp) {
|
||||
char **mem;
|
||||
|
||||
for (mem = grp->gr_mem; *mem; mem++) {
|
||||
struct passwd *pwd = getpwnam (*mem);
|
||||
|
||||
if (pwd && (pwd->pw_uid == u))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
check_suid (struct BB_applet *applet)
|
||||
{
|
||||
uid_t ruid = getuid (); /* real [ug]id */
|
||||
uid_t rgid = getgid ();
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
if (suid_cfg_readable) {
|
||||
struct BB_suid_config *sct;
|
||||
|
||||
for (sct = suid_config; sct; sct = sct->m_next) {
|
||||
if (sct->m_applet == applet)
|
||||
break;
|
||||
}
|
||||
if (sct) {
|
||||
mode_t m = sct->m_mode;
|
||||
|
||||
if (sct->m_uid == ruid) /* same uid */
|
||||
m >>= 6;
|
||||
else if ((sct->m_gid == rgid) || ingroup (ruid, sct->m_gid)) /* same group / in group */
|
||||
m >>= 3;
|
||||
|
||||
if (!(m & S_IXOTH)) /* is x bit not set ? */
|
||||
bb_error_msg_and_die ("You have no permission to run this applet!");
|
||||
|
||||
if ((sct->m_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) { /* *both* have to be set for sgid */
|
||||
if (setegid (sct->m_gid))
|
||||
bb_error_msg_and_die
|
||||
("BusyBox binary has insufficient rights to set proper GID for applet!");
|
||||
} else
|
||||
setgid (rgid); /* no sgid -> drop */
|
||||
|
||||
if (sct->m_mode & S_ISUID) {
|
||||
if (seteuid (sct->m_uid))
|
||||
bb_error_msg_and_die
|
||||
("BusyBox binary has insufficient rights to set proper UID for applet!");
|
||||
} else
|
||||
setuid (ruid); /* no suid -> drop */
|
||||
} else {
|
||||
/* default: drop all priviledges */
|
||||
setgid (rgid);
|
||||
setuid (ruid);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
#ifndef CONFIG_FEATURE_SUID_CONFIG_QUIET
|
||||
static int onetime = 0;
|
||||
|
||||
if (!onetime) {
|
||||
onetime = 1;
|
||||
fprintf (stderr, "Using fallback suid method\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (applet->need_suid == _BB_SUID_ALWAYS) {
|
||||
if (geteuid () != 0)
|
||||
bb_error_msg_and_die ("This applet requires root priviledges!");
|
||||
} else if (applet->need_suid == _BB_SUID_NEVER) {
|
||||
setgid (rgid); /* drop all priviledges */
|
||||
setuid (ruid);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FEATURE_SUID_CONFIG
|
||||
|
||||
/* This should probably be a libbb routine. In that case,
|
||||
* I'd probably rename it to something like bb_trimmed_slice.
|
||||
*/
|
||||
static char *get_trimmed_slice(char *s, char *e)
|
||||
{
|
||||
/* First, consider the value at e to be nul and back up until we
|
||||
* reach a non-space char. Set the char after that (possibly at
|
||||
* the original e) to nul. */
|
||||
while (e-- > s) {
|
||||
if (!isspace(*e)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
e[1] = 0;
|
||||
|
||||
/* Next, advance past all leading space and return a ptr to the
|
||||
* first non-space char; possibly the terminating nul. */
|
||||
return (char *) bb_skip_whitespace(s);
|
||||
}
|
||||
|
||||
|
||||
#define parse_error(x) { err=x; goto pe_label; }
|
||||
|
||||
/* Don't depend on the tools to combine strings. */
|
||||
static const char config_file[] = CONFIG_FILE;
|
||||
|
||||
/* There are 4 chars + 1 nul for each of user/group/other. */
|
||||
static const char mode_chars[] = "Ssx-\0Ssx-\0Ttx-";
|
||||
|
||||
/* We don't supply a value for the nul, so an index adjustment is
|
||||
* necessary below. Also, we use unsigned short here to save some
|
||||
* space even though these are really mode_t values. */
|
||||
static const unsigned short mode_mask[] = {
|
||||
/* SST sst xxx --- */
|
||||
S_ISUID, S_ISUID|S_IXUSR, S_IXUSR, 0, /* user */
|
||||
S_ISGID, S_ISGID|S_IXGRP, S_IXGRP, 0, /* group */
|
||||
0, S_IXOTH, S_IXOTH, 0 /* other */
|
||||
};
|
||||
|
||||
static void parse_config_file(void)
|
||||
{
|
||||
struct BB_suid_config *sct_head;
|
||||
struct BB_suid_config *sct;
|
||||
struct BB_applet *applet;
|
||||
FILE *f;
|
||||
char *err;
|
||||
char *s;
|
||||
char *e;
|
||||
int i, lc, section;
|
||||
char buffer[256];
|
||||
struct stat st;
|
||||
|
||||
assert(!suid_config); /* Should be set to NULL by bss init. */
|
||||
|
||||
if ((stat(config_file, &st) != 0) /* No config file? */
|
||||
|| !S_ISREG(st.st_mode) /* Not a regular file? */
|
||||
|| (st.st_uid != 0) /* Not owned by root? */
|
||||
|| (st.st_mode & (S_IWGRP | S_IWOTH)) /* Writable by non-root? */
|
||||
|| !(f = fopen(config_file, "r")) /* Can not open? */
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
suid_cfg_readable = 1;
|
||||
sct_head = NULL;
|
||||
section = lc = 0;
|
||||
|
||||
do {
|
||||
s = buffer;
|
||||
|
||||
if (!fgets(s, sizeof(buffer), f)) { /* Are we done? */
|
||||
if (ferror(f)) { /* Make sure it wasn't a read error. */
|
||||
parse_error("reading");
|
||||
}
|
||||
fclose(f);
|
||||
suid_config = sct_head; /* Success, so set the pointer. */
|
||||
return;
|
||||
}
|
||||
|
||||
lc++; /* Got a (partial) line. */
|
||||
|
||||
/* If a line is too long for our buffer, we consider it an error.
|
||||
* The following test does mistreat one corner case though.
|
||||
* If the final line of the file does not end with a newline and
|
||||
* yet exactly fills the buffer, it will be treated as too long
|
||||
* even though there isn't really a problem. But it isn't really
|
||||
* worth adding code to deal with such an unlikely situation, and
|
||||
* we do err on the side of caution. Besides, the line would be
|
||||
* too long if it did end with a newline. */
|
||||
if (!strchr(s, '\n') && !feof(f)) {
|
||||
parse_error("line too long");
|
||||
}
|
||||
|
||||
/* Trim leading and trailing whitespace, ignoring comments, and
|
||||
* check if the resulting string is empty. */
|
||||
if (!*(s = get_trimmed_slice(s, strchrnul(s, '#')))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Check for a section header. */
|
||||
|
||||
if (*s == '[') {
|
||||
/* Unlike the old code, we ignore leading and trailing
|
||||
* whitespace for the section name. We also require that
|
||||
* there are no stray characters after the closing bracket. */
|
||||
if (!(e = strchr(s, ']')) /* Missing right bracket? */
|
||||
|| e[1] /* Trailing characters? */
|
||||
|| !*(s = get_trimmed_slice(s+1, e)) /* Missing name? */
|
||||
) {
|
||||
parse_error("section header");
|
||||
}
|
||||
/* Right now we only have one section so just check it.
|
||||
* If more sections are added in the future, please don't
|
||||
* resort to cascading ifs with multiple strcasecmp calls.
|
||||
* That kind of bloated code is all too common. A loop
|
||||
* and a string table would be a better choice unless the
|
||||
* number of sections is very small. */
|
||||
if (strcasecmp(s, "SUID") == 0) {
|
||||
section = 1;
|
||||
continue;
|
||||
}
|
||||
section = -1; /* Unknown section so set to skip. */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Process sections. */
|
||||
|
||||
if (section == 1) { /* SUID */
|
||||
/* Since we trimmed leading and trailing space above, we're
|
||||
* now looking for strings of the form
|
||||
* <key>[::space::]*=[::space::]*<value>
|
||||
* where both key and value could contain inner whitespace. */
|
||||
|
||||
/* First get the key (an applet name in our case). */
|
||||
if (!!(e = strchr(s, '='))) {
|
||||
s = get_trimmed_slice(s, e);
|
||||
}
|
||||
if (!e || !*s) { /* Missing '=' or empty key. */
|
||||
parse_error("keyword");
|
||||
}
|
||||
|
||||
/* Ok, we have an applet name. Process the rhs if this
|
||||
* applet is currently built in and ignore it otherwise.
|
||||
* Note: This can hide config file bugs which only pop
|
||||
* up when the busybox configuration is changed. */
|
||||
if ((applet = find_applet_by_name(s))) {
|
||||
/* Note: We currently don't check for duplicates!
|
||||
* The last config line for each applet will be the
|
||||
* one used since we insert at the head of the list.
|
||||
* I suppose this could be considered a feature. */
|
||||
sct = xmalloc(sizeof(struct BB_suid_config));
|
||||
sct->m_applet = applet;
|
||||
sct->m_mode = 0;
|
||||
sct->m_next = sct_head;
|
||||
sct_head = sct;
|
||||
|
||||
/* Get the specified mode. */
|
||||
|
||||
e = (char *) bb_skip_whitespace(e+1);
|
||||
|
||||
for (i=0 ; i < 3 ; i++) {
|
||||
const char *q;
|
||||
if (!*(q = strchrnul(mode_chars + 5*i, *e++))) {
|
||||
parse_error("mode");
|
||||
}
|
||||
/* Adjust by -i to account for nul. */
|
||||
sct->m_mode |= mode_mask[(q - mode_chars) - i];
|
||||
}
|
||||
|
||||
/* Now get the the user/group info. */
|
||||
|
||||
s = (char *) bb_skip_whitespace(e);
|
||||
|
||||
/* Note: We require whitespace between the mode and the
|
||||
* user/group info. */
|
||||
if ((s == e) || !(e = strchr(s, '.'))) {
|
||||
parse_error("<uid>.<gid>");
|
||||
}
|
||||
*e++ = 0;
|
||||
|
||||
/* We can't use get_ug_id here since it would exit()
|
||||
* if a uid or gid was not found. Oh well... */
|
||||
{
|
||||
char *e2;
|
||||
|
||||
sct->m_uid = strtoul(s, &e2, 10);
|
||||
if (*e2 || (s == e2)) {
|
||||
struct passwd *pwd;
|
||||
if (!(pwd = getpwnam(s))) {
|
||||
parse_error("user");
|
||||
}
|
||||
sct->m_uid = pwd->pw_uid;
|
||||
}
|
||||
|
||||
sct->m_gid = strtoul(e, &e2, 10);
|
||||
if (*e2 || (e == e2)) {
|
||||
struct group *grp;
|
||||
if (!(grp = getgrnam(e))) {
|
||||
parse_error("group");
|
||||
}
|
||||
sct->m_gid = grp->gr_gid;
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Unknown sections are ignored. */
|
||||
|
||||
/* Encountering configuration lines prior to seeing a
|
||||
* section header is treated as an error. This is how
|
||||
* the old code worked, but it may not be desirable.
|
||||
* We may want to simply ignore such lines in case they
|
||||
* are used in some future version of busybox. */
|
||||
if (!section) {
|
||||
parse_error("keyword outside section");
|
||||
}
|
||||
|
||||
} while (1);
|
||||
|
||||
pe_label:
|
||||
fprintf(stderr, "Parse error in %s, line %d: %s\n",
|
||||
config_file, lc, err);
|
||||
|
||||
fclose(f);
|
||||
/* Release any allocated memory before returning. */
|
||||
while (sct_head) {
|
||||
sct = sct_head->m_next;
|
||||
free(sct_head);
|
||||
sct_head = sct;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* END CODE */
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,193 +0,0 @@
|
||||
/* 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 CONFIG_LOCALE_SUPPORT
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
int been_there_done_that = 0; /* Also used in applets.c */
|
||||
const char *bb_applet_name;
|
||||
|
||||
#ifdef CONFIG_FEATURE_INSTALLER
|
||||
/*
|
||||
* directory table
|
||||
* this should be consistent w/ the enum, busybox.h::Location,
|
||||
* or else...
|
||||
*/
|
||||
static const char usr_bin [] ="/usr/bin";
|
||||
static const char usr_sbin[] ="/usr/sbin";
|
||||
|
||||
static const char* const install_dir[] = {
|
||||
&usr_bin [8], /* "", equivalent to "/" for concat_path_file() */
|
||||
&usr_bin [4], /* "/bin" */
|
||||
&usr_sbin[4], /* "/sbin" */
|
||||
usr_bin,
|
||||
usr_sbin
|
||||
};
|
||||
|
||||
/* abstract link() */
|
||||
typedef int (*__link_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 inline char *busybox_fullpath(void)
|
||||
{
|
||||
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) {
|
||||
bb_perror_msg("%s", fpc);
|
||||
}
|
||||
free(fpc);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FEATURE_INSTALLER */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
bb_applet_name = argv[0];
|
||||
|
||||
if (bb_applet_name[0] == '-')
|
||||
bb_applet_name++;
|
||||
|
||||
for (s = bb_applet_name; *s != '\0';) {
|
||||
if (*s++ == '/')
|
||||
bb_applet_name = s;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_LOCALE_SUPPORT
|
||||
#ifdef CONFIG_INIT
|
||||
if(getpid()!=1) /* Do not set locale for `init' */
|
||||
#endif
|
||||
{
|
||||
setlocale(LC_ALL, "");
|
||||
}
|
||||
#endif
|
||||
|
||||
run_applet_by_name(bb_applet_name, argc, argv);
|
||||
bb_error_msg_and_die("applet not found");
|
||||
}
|
||||
|
||||
|
||||
int busybox_main(int argc, char **argv)
|
||||
{
|
||||
int col = 0, len, i;
|
||||
|
||||
#ifdef CONFIG_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;
|
||||
|
||||
/* to use symlinks, or not to use symlinks... */
|
||||
if (argc > 2) {
|
||||
if ((strcmp(argv[2], "-s") == 0)) {
|
||||
use_symbolic_links = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* link */
|
||||
busybox = busybox_fullpath();
|
||||
if (busybox) {
|
||||
install_links(busybox, use_symbolic_links);
|
||||
free(busybox);
|
||||
} else {
|
||||
rc = 1;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
#endif /* CONFIG_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;
|
||||
int output_width = 60;
|
||||
|
||||
#ifdef CONFIG_FEATURE_AUTOWIDTH
|
||||
/* Obtain the terminal width. */
|
||||
get_terminal_width_height(0, &output_width, NULL);
|
||||
/* leading tab and room to wrap */
|
||||
output_width -= 20;
|
||||
#endif
|
||||
|
||||
printf("%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", bb_msg_full_version);
|
||||
|
||||
while (a->name != 0) {
|
||||
col +=
|
||||
printf("%s%s", ((col == 0) ? "\t" : ", "),
|
||||
(a++)->name);
|
||||
if (col > output_width && a->name != 0) {
|
||||
printf(",\n");
|
||||
col = 0;
|
||||
}
|
||||
}
|
||||
printf("\n\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Flag that we've been here already */
|
||||
been_there_done_that = 1;
|
||||
|
||||
/* Move the command line down a notch */
|
||||
/* Preserve pointers so setproctitle() works consistently */
|
||||
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,258 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see scripts/kbuild/config-language.txt.
|
||||
#
|
||||
|
||||
menu "Archival Utilities"
|
||||
|
||||
config CONFIG_AR
|
||||
bool "ar"
|
||||
default n
|
||||
help
|
||||
ar is an archival utility program used to create, modify, and
|
||||
extract contents from archives. An archive is a single file holding
|
||||
a collection of other files in a structure that makes it possible to
|
||||
retrieve the original individual files (called archive members).
|
||||
The original files' contents, mode (permissions), timestamp, owner,
|
||||
and group are preserved in the archive, and can be restored on
|
||||
extraction.
|
||||
|
||||
The stored filename is limited to 15 characters. (for more information
|
||||
see long filename support).
|
||||
ar has 60 bytes of overheads for every stored file.
|
||||
|
||||
This implementation of ar can extract archives, it cannot create or
|
||||
modify them.
|
||||
On an x86 system, the ar applet adds about 1K.
|
||||
|
||||
Unless you have a specific application which requires ar, you should
|
||||
probably say N here.
|
||||
|
||||
config CONFIG_FEATURE_AR_LONG_FILENAMES
|
||||
bool " Enable support for long filenames (not need for debs)"
|
||||
default n
|
||||
depends on CONFIG_AR
|
||||
help
|
||||
By default the ar format can only store the first 15 characters of the
|
||||
filename, this option removes that limitation.
|
||||
It supports the GNU ar long filename method which moves multiple long
|
||||
filenames into a the data section of a new ar entry.
|
||||
|
||||
config CONFIG_BUNZIP2
|
||||
bool "bunzip2"
|
||||
default n
|
||||
help
|
||||
bunzip2 is a compression utility using the Burrows-Wheeler block
|
||||
sorting text compression algorithm, and Huffman coding. Compression
|
||||
is generally considerably better than that achieved by more
|
||||
conventional LZ77/LZ78-based compressors, and approaches the
|
||||
performance of the PPM family of statistical compressors.
|
||||
|
||||
The BusyBox bunzip2 applet is limited to de-compression only.
|
||||
On an x86 system, this applet adds about 11K.
|
||||
|
||||
Unless you have a specific application which requires bunzip2, you
|
||||
should probably say N here.
|
||||
|
||||
config CONFIG_CPIO
|
||||
bool "cpio"
|
||||
default n
|
||||
help
|
||||
cpio is an archival utility program used to create, modify, and extract
|
||||
contents from archives.
|
||||
cpio has 110 bytes of overheads for every stored file.
|
||||
|
||||
This implementation of cpio can extract cpio archives created in the
|
||||
"newc" or "crc" format, it cannot create or modify them.
|
||||
|
||||
Unless you have a specific application which requires cpio, you should
|
||||
probably say N here.
|
||||
|
||||
config CONFIG_DPKG
|
||||
bool "dpkg"
|
||||
default n
|
||||
help
|
||||
dpkg is a medium-level tool to install, build, remove and manage Debian packages.
|
||||
|
||||
This implementation of dpkg has a number of limitations, you should use the
|
||||
official dpkg if possible.
|
||||
|
||||
config CONFIG_DPKG_DEB
|
||||
bool "dpkg_deb"
|
||||
default n
|
||||
help
|
||||
dpkg-deb packs, unpacks and provides information about Debian archives.
|
||||
|
||||
This implementation of dpkg-deb cannot pack archives.
|
||||
|
||||
Unless you have a specific application which requires dpkg-deb, you should
|
||||
probably say N here.
|
||||
|
||||
config CONFIG_FEATURE_DPKG_DEB_EXTRACT_ONLY
|
||||
bool " extract only (-x)"
|
||||
default n
|
||||
depends on CONFIG_DPKG_DEB
|
||||
help
|
||||
This reduces dpkg-deb to the equivalent of "ar -p <deb> data.tar.gz | tar -zx".
|
||||
However it saves space as none of the extra dpkg-deb, ar or tar options are
|
||||
needed, they are linked to internally.
|
||||
|
||||
config CONFIG_GUNZIP
|
||||
bool "gunzip"
|
||||
default n
|
||||
help
|
||||
gunzip is used to decompress archives created by gzip.
|
||||
You can use the `-t' option to test the integrity of
|
||||
an archive, without decompressing it.
|
||||
|
||||
config CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
bool " Uncompress support"
|
||||
default n
|
||||
depends on CONFIG_GUNZIP
|
||||
help
|
||||
Enable if you want gunzip to have the ability to decompress
|
||||
archives created by the program compress (not much
|
||||
used anymore).
|
||||
|
||||
config CONFIG_GZIP
|
||||
bool "gzip"
|
||||
default n
|
||||
help
|
||||
gzip is used to compress files.
|
||||
It's probably the most widely used UNIX compression program.
|
||||
|
||||
config CONFIG_RPM2CPIO
|
||||
bool "rpm2cpio"
|
||||
default n
|
||||
help
|
||||
Converts an RPM file into a CPIO archive.
|
||||
|
||||
config CONFIG_RPM
|
||||
bool "rpm"
|
||||
default n
|
||||
help
|
||||
Mini RPM applet - queries and extracts
|
||||
|
||||
config CONFIG_TAR
|
||||
bool "tar"
|
||||
default n
|
||||
help
|
||||
tar is an archiving program. It's commonly used with gzip to
|
||||
create compressed archives. It's probably the most widely used
|
||||
UNIX archive program.
|
||||
|
||||
config CONFIG_FEATURE_TAR_CREATE
|
||||
bool " Enable archive creation"
|
||||
default y
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
If you enable this option you'll be able to create
|
||||
tar archives using the `-c' option.
|
||||
|
||||
config CONFIG_FEATURE_TAR_BZIP2
|
||||
bool " Enable -j option to handle .tar.bz2 files"
|
||||
default n
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
If you enable this option you'll be able to extract
|
||||
archives compressed with bzip2.
|
||||
|
||||
config CONFIG_FEATURE_TAR_FROM
|
||||
bool " Enable -X (exclude from) and -T (include from) options)"
|
||||
default n
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
If you enable this option you'll be able to specify
|
||||
a list of files to include or exclude from an archive.
|
||||
|
||||
config CONFIG_FEATURE_TAR_GZIP
|
||||
bool " Enable -z option"
|
||||
default y
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
If you enable this option tar will be able to call gzip,
|
||||
when creating or extracting tar gziped archives.
|
||||
|
||||
config CONFIG_FEATURE_TAR_COMPRESS
|
||||
bool " Enable -Z option"
|
||||
default n
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
If you enable this option tar will be able to call uncompress,
|
||||
when extracting .tar.Z archives.
|
||||
|
||||
config CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
|
||||
bool " Enable support for old tar header format"
|
||||
default N
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
This option is required to unpack archives created in
|
||||
the old GNU format; help to kill this old format by
|
||||
repacking your ancient archives with the new format.
|
||||
|
||||
config CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
bool " Enable support for some GNU tar extensions"
|
||||
default y
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
With this option busybox supports GNU long filenames and
|
||||
linknames.
|
||||
|
||||
config CONFIG_FEATURE_TAR_LONG_OPTIONS
|
||||
bool " Enable long options"
|
||||
default n
|
||||
depends on CONFIG_TAR
|
||||
help
|
||||
Enable use of long options, increases size by about 400 Bytes
|
||||
|
||||
config CONFIG_UNCOMPRESS
|
||||
bool "uncompress"
|
||||
default n
|
||||
help
|
||||
uncompress is used to decompress archives created by compress.
|
||||
Not much used anymore, replaced by gzip/gunzip.
|
||||
|
||||
config CONFIG_UNZIP
|
||||
bool "unzip"
|
||||
default n
|
||||
help
|
||||
unzip will list or extract files from a ZIP archive,
|
||||
commonly found on DOS/WIN systems. The default behavior
|
||||
(with no options) is to extract the archive into the
|
||||
current directory. Use the `-d' option to extract to a
|
||||
directory of your choice.
|
||||
|
||||
comment "Common options for cpio and tar"
|
||||
depends on CONFIG_CPIO || CONFIG_TAR
|
||||
|
||||
config CONFIG_FEATURE_UNARCHIVE_TAPE
|
||||
bool " Enable tape drive support"
|
||||
default n
|
||||
depends on CONFIG_CPIO || CONFIG_TAR
|
||||
help
|
||||
I don't think this is needed anymore.
|
||||
|
||||
comment "Common options for dpkg and dpkg_deb"
|
||||
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
|
||||
config CONFIG_FEATURE_DEB_TAR_GZ
|
||||
bool " gzip debian packages (normal)"
|
||||
default y if CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
help
|
||||
This is the default compression method inside the debian ar file.
|
||||
|
||||
If you want compatibility with standard .deb's you should say yes here.
|
||||
|
||||
config CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
bool " bzip2 debian packages"
|
||||
default n
|
||||
depends on CONFIG_DPKG || CONFIG_DPKG_DEB
|
||||
help
|
||||
This allows dpkg and dpkg-deb to extract deb's that are compressed internally
|
||||
with bzip2 instead of gzip.
|
||||
|
||||
You only want this if you are creating your own custom debian packages that
|
||||
use an internal control.tar.bz2 or data.tar.bz2.
|
||||
|
||||
endmenu
|
||||
@@ -1,32 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
#
|
||||
|
||||
top_srcdir=..
|
||||
top_builddir=..
|
||||
ARCHIVAL_DIR:=./
|
||||
srcdir=$(top_srcdir)/archival
|
||||
include $(top_builddir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
#
|
||||
|
||||
ARCHIVAL_AR:=archival.a
|
||||
ifndef $(ARCHIVAL_DIR)
|
||||
ARCHIVAL_DIR:=$(top_builddir)/archival/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/archival
|
||||
|
||||
ARCHIVAL-y:=
|
||||
ARCHIVAL-$(CONFIG_APT_GET) +=
|
||||
ARCHIVAL-$(CONFIG_AR) += ar.o
|
||||
ARCHIVAL-$(CONFIG_BUNZIP2) += bunzip2.o
|
||||
ARCHIVAL-$(CONFIG_CPIO) += cpio.o
|
||||
ARCHIVAL-$(CONFIG_DPKG) += dpkg.o
|
||||
ARCHIVAL-$(CONFIG_DPKG_DEB) += dpkg_deb.o
|
||||
ARCHIVAL-$(CONFIG_GUNZIP) += gunzip.o
|
||||
ARCHIVAL-$(CONFIG_GZIP) += gzip.o
|
||||
ARCHIVAL-$(CONFIG_RPM2CPIO) += rpm2cpio.o
|
||||
ARCHIVAL-$(CONFIG_RPM) += rpm.o
|
||||
ARCHIVAL-$(CONFIG_TAR) += tar.o
|
||||
ARCHIVAL-$(CONFIG_UNCOMPRESS) += uncompress.o
|
||||
ARCHIVAL-$(CONFIG_UNZIP) += unzip.o
|
||||
|
||||
libraries-y+=$(ARCHIVAL_DIR)$(ARCHIVAL_AR)
|
||||
|
||||
$(ARCHIVAL_DIR)$(ARCHIVAL_AR): $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
|
||||
$(AR) $(ARFLAGS) $@ $(patsubst %,$(ARCHIVAL_DIR)%, $(ARCHIVAL-y))
|
||||
|
||||
$(ARCHIVAL_DIR)%.o: $(srcdir)/%.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
@@ -1,115 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini ar implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2000 by Glenn McGrath
|
||||
* Written by Glenn McGrath <bug1@iinet.net.au> 1 June 2000
|
||||
*
|
||||
* Based in part on BusyBox tar, Debian dpkg-deb and GNU ar.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* There is no single standard to adhere to so ar may not portable
|
||||
* between different systems
|
||||
* http://www.unix-systems.org/single_unix_specification_v2/xcu/ar.html
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
static void header_verbose_list_ar(const file_header_t *file_header)
|
||||
{
|
||||
const char *mode = bb_mode_string(file_header->mode);
|
||||
char *mtime;
|
||||
|
||||
mtime = ctime(&file_header->mtime);
|
||||
mtime[16] = ' ';
|
||||
memmove(&mtime[17], &mtime[20], 4);
|
||||
mtime[21] = '\0';
|
||||
printf("%s %d/%d%7d %s %s\n", &mode[1], file_header->uid, file_header->gid, (int) file_header->size, &mtime[4], file_header->name);
|
||||
}
|
||||
|
||||
#define AR_CTX_PRINT 0x01
|
||||
#define AR_CTX_LIST 0x02
|
||||
#define AR_CTX_EXTRACT 0x04
|
||||
#define AR_OPT_PRESERVE_DATE 0x08
|
||||
#define AR_OPT_VERBOSE 0x10
|
||||
#define AR_OPT_CREATE 0x20
|
||||
#define AR_OPT_INSERT 0x40
|
||||
|
||||
extern int ar_main(int argc, char **argv)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned long opt;
|
||||
char *msg_unsupported_err = "Archive %s not supported. Install binutils 'ar'.";
|
||||
char magic[8];
|
||||
|
||||
archive_handle = init_handle();
|
||||
|
||||
bb_opt_complementaly = "p~tx:t~px:x~pt";
|
||||
opt = bb_getopt_ulflags(argc, argv, "ptxovcr");
|
||||
|
||||
if ((opt & BB_GETOPT_ERROR) || (opt == 0) || (optind == argc)) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if (opt & AR_CTX_PRINT) {
|
||||
archive_handle->action_data = data_extract_to_stdout;
|
||||
}
|
||||
if (opt & AR_CTX_LIST) {
|
||||
archive_handle->action_header = header_list;
|
||||
}
|
||||
if (opt & AR_CTX_EXTRACT) {
|
||||
archive_handle->action_data = data_extract_all;
|
||||
}
|
||||
if (opt & AR_OPT_PRESERVE_DATE) {
|
||||
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
|
||||
}
|
||||
if (opt & AR_OPT_VERBOSE) {
|
||||
archive_handle->action_header = header_verbose_list_ar;
|
||||
}
|
||||
if (opt & AR_OPT_CREATE) {
|
||||
bb_error_msg_and_die(msg_unsupported_err, "creation");
|
||||
}
|
||||
if (opt & AR_OPT_INSERT) {
|
||||
bb_error_msg_and_die(msg_unsupported_err, "insertion");
|
||||
}
|
||||
|
||||
archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
|
||||
|
||||
while (optind < argc) {
|
||||
archive_handle->filter = filter_accept_list;
|
||||
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind++]);
|
||||
}
|
||||
|
||||
archive_xread_all(archive_handle, magic, 7);
|
||||
if (strncmp(magic, "!<arch>", 7) != 0) {
|
||||
bb_error_msg_and_die("Invalid ar magic");
|
||||
}
|
||||
archive_handle->offset += 7;
|
||||
|
||||
while (get_header_ar(archive_handle) == EXIT_SUCCESS);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Modified for busybox by Glenn McGrath <bug1@iinet.net.au>
|
||||
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
|
||||
*
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define BUNZIP2_OPT_STDOUT 1
|
||||
#define BUNZIP2_OPT_FORCE 2
|
||||
|
||||
int bunzip2_main(int argc, char **argv)
|
||||
{
|
||||
char *compressed_name;
|
||||
/* Note: Ignore the warning about save_name being used uninitialized.
|
||||
* That is not the case, but gcc has trouble working that out... */
|
||||
char *save_name;
|
||||
unsigned long opt;
|
||||
int status;
|
||||
int src_fd;
|
||||
int dst_fd;
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "cf");
|
||||
|
||||
/* if called as bzcat force the stdout flag */
|
||||
if (bb_applet_name[2] == 'c') {
|
||||
opt |= BUNZIP2_OPT_STDOUT;
|
||||
}
|
||||
|
||||
/* Set input filename and number */
|
||||
compressed_name = argv[optind];
|
||||
if ((compressed_name) && (compressed_name[0] != '-') && (compressed_name[1] != '\0')) {
|
||||
/* Open input file */
|
||||
src_fd = bb_xopen(compressed_name, O_RDONLY);
|
||||
} else {
|
||||
src_fd = STDIN_FILENO;
|
||||
opt |= BUNZIP2_OPT_STDOUT;
|
||||
}
|
||||
|
||||
/* Check that the input is sane. */
|
||||
if (isatty(src_fd) && (opt & BUNZIP2_OPT_FORCE) == 0) {
|
||||
bb_error_msg_and_die("compressed data not read from terminal. Use -f to force it.");
|
||||
}
|
||||
|
||||
if (opt & BUNZIP2_OPT_STDOUT) {
|
||||
dst_fd = STDOUT_FILENO;
|
||||
} else {
|
||||
int len = strlen(compressed_name) - 4;
|
||||
if (strcmp(compressed_name + len, ".bz2") != 0) {
|
||||
bb_error_msg_and_die("Invalid extension");
|
||||
}
|
||||
save_name = bb_xstrndup(compressed_name, len);
|
||||
dst_fd = bb_xopen(save_name, O_WRONLY | O_CREAT);
|
||||
}
|
||||
|
||||
status = uncompressStream(src_fd, dst_fd);
|
||||
if(!(opt & BUNZIP2_OPT_STDOUT)) {
|
||||
char *delete_name;
|
||||
if (status) {
|
||||
delete_name = save_name;
|
||||
} else {
|
||||
delete_name = compressed_name;
|
||||
}
|
||||
if (unlink(delete_name) < 0) {
|
||||
bb_error_msg_and_die("Couldn't remove %s", delete_name);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/* 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 "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
#define CPIO_OPT_EXTRACT 0x01
|
||||
#define CPIO_OPT_TEST 0x02
|
||||
#define CPIO_OPT_UNCONDITIONAL 0x04
|
||||
#define CPIO_OPT_VERBOSE 0x08
|
||||
#define CPIO_OPT_FILE 0x10
|
||||
#define CPIO_OPT_CREATE_LEADING_DIR 0x20
|
||||
#define CPIO_OPT_PRESERVE_MTIME 0x40
|
||||
|
||||
extern int cpio_main(int argc, char **argv)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
char *cpio_filename = NULL;
|
||||
unsigned long opt;
|
||||
|
||||
/* Initialise */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->src_fd = STDIN_FILENO;
|
||||
archive_handle->seek = seek_by_char;
|
||||
archive_handle->flags = ARCHIVE_EXTRACT_NEWER | ARCHIVE_PRESERVE_DATE;
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "ituvF:dm", &cpio_filename);
|
||||
|
||||
/* One of either extract or test options must be given */
|
||||
if ((opt & (CPIO_OPT_TEST | CPIO_OPT_EXTRACT)) == 0) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if (opt & CPIO_OPT_TEST) {
|
||||
/* if both extract and test option are given, ignore extract option */
|
||||
if (opt & CPIO_OPT_EXTRACT) {
|
||||
opt &= ~CPIO_OPT_EXTRACT;
|
||||
}
|
||||
archive_handle->action_header = header_list;
|
||||
}
|
||||
if (opt & CPIO_OPT_EXTRACT) {
|
||||
archive_handle->action_data = data_extract_all;
|
||||
}
|
||||
if (opt & CPIO_OPT_UNCONDITIONAL) {
|
||||
archive_handle->flags |= ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
archive_handle->flags &= ~ARCHIVE_EXTRACT_NEWER;
|
||||
}
|
||||
if (opt & CPIO_OPT_VERBOSE) {
|
||||
if (archive_handle->action_header == header_list) {
|
||||
archive_handle->action_header = header_verbose_list;
|
||||
} else {
|
||||
archive_handle->action_header = header_list;
|
||||
}
|
||||
}
|
||||
if (cpio_filename) { /* CPIO_OPT_FILE */
|
||||
archive_handle->src_fd = bb_xopen(cpio_filename, O_RDONLY);
|
||||
archive_handle->seek = seek_by_jump;
|
||||
}
|
||||
if (opt & CPIO_OPT_CREATE_LEADING_DIR) {
|
||||
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
|
||||
}
|
||||
|
||||
while (optind < argc) {
|
||||
archive_handle->filter = filter_accept_list;
|
||||
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* 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 <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
#define DPKG_DEB_OPT_CONTENTS 1
|
||||
#define DPKG_DEB_OPT_CONTROL 2
|
||||
#define DPKG_DEB_OPT_FIELD 4
|
||||
#define DPKG_DEB_OPT_EXTRACT 8
|
||||
#define DPKG_DEB_OPT_EXTRACT_VERBOSE 16
|
||||
|
||||
extern int dpkg_deb_main(int argc, char **argv)
|
||||
{
|
||||
archive_handle_t *ar_archive;
|
||||
archive_handle_t *tar_archive;
|
||||
llist_t *control_tar_llist = NULL;
|
||||
unsigned long opt;
|
||||
char *extract_dir = NULL;
|
||||
short argcount = 1;
|
||||
|
||||
/* Setup the tar archive handle */
|
||||
tar_archive = init_handle();
|
||||
|
||||
/* Setup an ar archive handle that refers to the gzip sub archive */
|
||||
ar_archive = init_handle();
|
||||
ar_archive->sub_archive = tar_archive;
|
||||
ar_archive->filter = filter_accept_list_reassign;
|
||||
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
ar_archive->accept = llist_add_to(NULL, "data.tar.gz");
|
||||
control_tar_llist = llist_add_to(NULL, "control.tar.gz");
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
ar_archive->accept = llist_add_to(ar_archive->accept, "data.tar.bz2");
|
||||
control_tar_llist = llist_add_to(control_tar_llist, "control.tar.bz2");
|
||||
#endif
|
||||
|
||||
bb_opt_complementaly = "c~efXx:e~cfXx:f~ceXx:X~cefx:x~cefX";
|
||||
opt = bb_getopt_ulflags(argc, argv, "cefXx");
|
||||
|
||||
if (opt & DPKG_DEB_OPT_CONTENTS) {
|
||||
tar_archive->action_header = header_verbose_list;
|
||||
}
|
||||
if (opt & DPKG_DEB_OPT_CONTROL) {
|
||||
ar_archive->accept = control_tar_llist;
|
||||
tar_archive->action_data = data_extract_all;
|
||||
if (optind + 1 == argc) {
|
||||
extract_dir = "./DEBIAN";
|
||||
} else {
|
||||
argcount++;
|
||||
}
|
||||
}
|
||||
if (opt & DPKG_DEB_OPT_FIELD) {
|
||||
/* Print the entire control file
|
||||
* it should accept a second argument which specifies a
|
||||
* specific field to print */
|
||||
ar_archive->accept = control_tar_llist;
|
||||
tar_archive->accept = llist_add_to(NULL, "./control");;
|
||||
tar_archive->filter = filter_accept_list;
|
||||
tar_archive->action_data = data_extract_to_stdout;
|
||||
}
|
||||
if (opt & DPKG_DEB_OPT_EXTRACT) {
|
||||
tar_archive->action_header = header_list;
|
||||
}
|
||||
if (opt & (DPKG_DEB_OPT_EXTRACT_VERBOSE | DPKG_DEB_OPT_EXTRACT)) {
|
||||
tar_archive->action_data = data_extract_all;
|
||||
argcount = 2;
|
||||
}
|
||||
|
||||
if ((optind + argcount != argc) || (opt & BB_GETOPT_ERROR)) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
tar_archive->src_fd = ar_archive->src_fd = bb_xopen(argv[optind++], O_RDONLY);
|
||||
|
||||
/* Workout where to extract the files */
|
||||
/* 2nd argument is a dir name */
|
||||
if (argv[optind]) {
|
||||
extract_dir = argv[optind];
|
||||
}
|
||||
if (extract_dir) {
|
||||
mkdir(extract_dir, 0777);
|
||||
chdir(extract_dir);
|
||||
}
|
||||
unpack_ar_archive(ar_archive);
|
||||
|
||||
/* Cleanup */
|
||||
close (ar_archive->src_fd);
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1,198 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Gzip implementation for busybox
|
||||
*
|
||||
* Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly.
|
||||
*
|
||||
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
|
||||
* based on gzip sources
|
||||
*
|
||||
* Adjusted further by Erik Andersen <andersen@codepoet.org> to support files as
|
||||
* well as stdin/stdout, and to generally behave itself wrt command line
|
||||
* handling.
|
||||
*
|
||||
* General cleanup to better adhere to the style guide and make use of standard
|
||||
* busybox functions by Glenn McGrath <bug1@iinet.net.au>
|
||||
*
|
||||
* 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 <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define GUNZIP_OPT_STDOUT 1
|
||||
#define GUNZIP_OPT_FORCE 2
|
||||
#define GUNZIP_OPT_TEST 4
|
||||
#define GUNZIP_OPT_DECOMPRESS 8
|
||||
|
||||
extern int gunzip_main(int argc, char **argv)
|
||||
{
|
||||
char status = EXIT_SUCCESS;
|
||||
unsigned long opt;
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, "cftd");
|
||||
/* if called as zcat */
|
||||
if (strcmp(bb_applet_name, "zcat") == 0) {
|
||||
opt |= GUNZIP_OPT_STDOUT;
|
||||
}
|
||||
|
||||
do {
|
||||
struct stat stat_buf;
|
||||
const char *old_path = argv[optind];
|
||||
const char *delete_path = NULL;
|
||||
char *new_path = NULL;
|
||||
int src_fd;
|
||||
int dst_fd;
|
||||
|
||||
optind++;
|
||||
|
||||
if (old_path == NULL || strcmp(old_path, "-") == 0) {
|
||||
src_fd = STDIN_FILENO;
|
||||
opt |= GUNZIP_OPT_STDOUT;
|
||||
} else {
|
||||
src_fd = bb_xopen(old_path, O_RDONLY);
|
||||
|
||||
/* Get the time stamp on the input file. */
|
||||
if (stat(old_path, &stat_buf) < 0) {
|
||||
bb_error_msg_and_die("Couldn't stat file %s", old_path);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that the input is sane. */
|
||||
if (isatty(src_fd) && ((opt & GUNZIP_OPT_FORCE) == 0)) {
|
||||
bb_error_msg_and_die
|
||||
("compressed data not read from terminal. Use -f to force it.");
|
||||
}
|
||||
|
||||
/* Set output filename and number */
|
||||
if (opt & GUNZIP_OPT_TEST) {
|
||||
dst_fd = bb_xopen("/dev/null", O_WRONLY); /* why does test use filenum 2 ? */
|
||||
} else if (opt & GUNZIP_OPT_STDOUT) {
|
||||
dst_fd = STDOUT_FILENO;
|
||||
} else {
|
||||
char *extension;
|
||||
|
||||
new_path = bb_xstrdup(old_path);
|
||||
|
||||
extension = strrchr(new_path, '.');
|
||||
#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
if (extension && (strcmp(extension, ".Z") == 0)) {
|
||||
*extension = '\0';
|
||||
} else
|
||||
#endif
|
||||
if (extension && (strcmp(extension, ".gz") == 0)) {
|
||||
*extension = '\0';
|
||||
} else if (extension && (strcmp(extension, ".tgz") == 0)) {
|
||||
extension[2] = 'a';
|
||||
extension[3] = 'r';
|
||||
} else {
|
||||
bb_error_msg_and_die("Invalid extension");
|
||||
}
|
||||
|
||||
/* Open output file */
|
||||
dst_fd = bb_xopen(new_path, O_WRONLY | O_CREAT);
|
||||
|
||||
/* Set permissions on the file */
|
||||
chmod(new_path, stat_buf.st_mode);
|
||||
|
||||
/* If unzip succeeds remove the old file */
|
||||
delete_path = old_path;
|
||||
}
|
||||
|
||||
/* do the decompression, and cleanup */
|
||||
if (bb_xread_char(src_fd) == 0x1f) {
|
||||
unsigned char magic2;
|
||||
|
||||
magic2 = bb_xread_char(src_fd);
|
||||
#ifdef CONFIG_FEATURE_GUNZIP_UNCOMPRESS
|
||||
if (magic2 == 0x9d) {
|
||||
status = uncompress(src_fd, dst_fd);
|
||||
} else
|
||||
#endif
|
||||
if (magic2 == 0x8b) {
|
||||
check_header_gzip(src_fd);
|
||||
status = inflate_gunzip(src_fd, dst_fd);
|
||||
if (status != 0) {
|
||||
bb_error_msg_and_die("Error inflating");
|
||||
}
|
||||
} else {
|
||||
bb_error_msg_and_die("Invalid magic");
|
||||
}
|
||||
} else {
|
||||
bb_error_msg_and_die("Invalid magic");
|
||||
}
|
||||
|
||||
if ((status != EXIT_SUCCESS) && (new_path)) {
|
||||
/* Unzip failed, remove new path instead of old path */
|
||||
delete_path = new_path;
|
||||
}
|
||||
|
||||
if (dst_fd != STDOUT_FILENO) {
|
||||
close(dst_fd);
|
||||
}
|
||||
if (src_fd != STDIN_FILENO) {
|
||||
close(src_fd);
|
||||
}
|
||||
|
||||
/* delete_path will be NULL if in test mode or from stdin */
|
||||
if (delete_path && (unlink(delete_path) == -1)) {
|
||||
bb_error_msg_and_die("Couldn't remove %s", delete_path);
|
||||
}
|
||||
|
||||
free(new_path);
|
||||
|
||||
} while (optind < argc);
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
#
|
||||
|
||||
top_srcdir=../..
|
||||
top_builddir=../..
|
||||
srcdir=$(top_srcdir)/archival/libunarchive
|
||||
LIBUNARCHIVE_DIR:=./
|
||||
include $(top_builddir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
#
|
||||
|
||||
LIBUNARCHIVE_AR:=libunarchive.a
|
||||
ifndef $(LIBUNARCHIVE_DIR)
|
||||
LIBUNARCHIVE_DIR:=$(top_builddir)/archival/libunarchive/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/archvial/libunarchive
|
||||
|
||||
LIBUNARCHIVE-y:= \
|
||||
\
|
||||
data_skip.o \
|
||||
data_extract_all.o \
|
||||
data_extract_to_stdout.o \
|
||||
data_extract_to_buffer.o \
|
||||
\
|
||||
filter_accept_all.o \
|
||||
filter_accept_list.o \
|
||||
filter_accept_reject_list.o \
|
||||
\
|
||||
header_skip.o \
|
||||
header_list.o \
|
||||
header_verbose_list.o \
|
||||
\
|
||||
archive_xread_all.o \
|
||||
archive_xread_all_eof.o \
|
||||
\
|
||||
seek_by_char.o \
|
||||
seek_by_jump.o \
|
||||
\
|
||||
data_align.o \
|
||||
find_list_entry.o \
|
||||
open_transformer.o \
|
||||
init_handle.o
|
||||
|
||||
GUNZIP_FILES:= check_header_gzip.o decompress_unzip.o
|
||||
DPKG_FILES:= \
|
||||
get_header_ar.o \
|
||||
unpack_ar_archive.o \
|
||||
get_header_tar.o \
|
||||
filter_accept_list_reassign.o
|
||||
|
||||
LIBUNARCHIVE-$(CONFIG_AR) += get_header_ar.o unpack_ar_archive.o
|
||||
LIBUNARCHIVE-$(CONFIG_BUNZIP2) += decompress_bunzip2.o
|
||||
LIBUNARCHIVE-$(CONFIG_CPIO) += get_header_cpio.o
|
||||
LIBUNARCHIVE-$(CONFIG_DPKG) += $(DPKG_FILES)
|
||||
LIBUNARCHIVE-$(CONFIG_DPKG_DEB) += $(DPKG_FILES)
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_GZ) += $(GUNZIP_FILES) get_header_tar_gz.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_DEB_TAR_BZ2) += decompress_bunzip2.o get_header_tar_bz2.o
|
||||
LIBUNARCHIVE-$(CONFIG_GUNZIP) += $(GUNZIP_FILES)
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_GUNZIP_UNCOMPRESS) += decompress_uncompress.o
|
||||
LIBUNARCHIVE-$(CONFIG_RPM2CPIO) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
LIBUNARCHIVE-$(CONFIG_RPM) += $(GUNZIP_FILES) get_header_cpio.o
|
||||
LIBUNARCHIVE-$(CONFIG_TAR) += get_header_tar.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_BZIP2) += decompress_bunzip2.o get_header_tar_bz2.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_GZIP) += $(GUNZIP_FILES) get_header_tar_gz.o
|
||||
LIBUNARCHIVE-$(CONFIG_FEATURE_TAR_COMPRESS) += decompress_uncompress.o
|
||||
LIBUNARCHIVE-$(CONFIG_UNCOMPRESS) += decompress_uncompress.o
|
||||
LIBUNARCHIVE-$(CONFIG_UNZIP) += $(GUNZIP_FILES)
|
||||
|
||||
libraries-y+=$(LIBUNARCHIVE_DIR)$(LIBUNARCHIVE_AR)
|
||||
|
||||
$(LIBUNARCHIVE_DIR)$(LIBUNARCHIVE_AR): $(patsubst %,$(LIBUNARCHIVE_DIR)%, $(LIBUNARCHIVE-y))
|
||||
$(AR) $(ARFLAGS) $@ $(patsubst %,$(LIBUNARCHIVE_DIR)%, $(LIBUNARCHIVE-y))
|
||||
|
||||
$(LIBUNARCHIVA_DIR)%.o: $(srcdir)/%.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
extern void archive_xread_all(const archive_handle_t *archive_handle, void *buf, const size_t count)
|
||||
{
|
||||
ssize_t size;
|
||||
|
||||
size = bb_full_read(archive_handle->src_fd, buf, count);
|
||||
if (size != count) {
|
||||
bb_error_msg_and_die("Short read");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
extern ssize_t archive_xread_all_eof(archive_handle_t *archive_handle, unsigned char *buf, size_t count)
|
||||
{
|
||||
ssize_t size;
|
||||
|
||||
size = bb_full_read(archive_handle->src_fd, buf, count);
|
||||
if ((size != 0) && (size != count)) {
|
||||
bb_perror_msg_and_die("Short read, read %ld of %ld", (long)size, (long)count);
|
||||
}
|
||||
return(size);
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "libbb.h"
|
||||
|
||||
extern void check_header_gzip(int src_fd)
|
||||
{
|
||||
union {
|
||||
unsigned char raw[8];
|
||||
struct {
|
||||
unsigned char method;
|
||||
unsigned char flags;
|
||||
unsigned int mtime;
|
||||
unsigned char xtra_flags;
|
||||
unsigned char os_flags;
|
||||
} formated;
|
||||
} header;
|
||||
|
||||
bb_xread_all(src_fd, header.raw, 8);
|
||||
|
||||
/* Check the compression method */
|
||||
if (header.formated.method != 8) {
|
||||
bb_error_msg_and_die("Unknown compression method %d",
|
||||
header.formated.method);
|
||||
}
|
||||
|
||||
if (header.formated.flags & 0x04) {
|
||||
/* bit 2 set: extra field present */
|
||||
unsigned char extra_short;
|
||||
|
||||
extra_short = bb_xread_char(src_fd) + (bb_xread_char(src_fd) << 8);
|
||||
while (extra_short > 0) {
|
||||
/* Ignore extra field */
|
||||
bb_xread_char(src_fd);
|
||||
extra_short--;
|
||||
}
|
||||
}
|
||||
|
||||
/* Discard original name if any */
|
||||
if (header.formated.flags & 0x08) {
|
||||
/* bit 3 set: original file name present */
|
||||
while(bb_xread_char(src_fd) != 0);
|
||||
}
|
||||
|
||||
/* Discard file comment if any */
|
||||
if (header.formated.flags & 0x10) {
|
||||
/* bit 4 set: file comment present */
|
||||
while(bb_xread_char(src_fd) != 0);
|
||||
}
|
||||
|
||||
/* Read the header checksum */
|
||||
if (header.formated.flags & 0x02) {
|
||||
bb_xread_char(src_fd);
|
||||
bb_xread_char(src_fd);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* 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 <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void data_align(archive_handle_t *archive_handle, const unsigned short boundary)
|
||||
{
|
||||
const unsigned short skip_amount = (boundary - (archive_handle->offset % boundary)) % boundary;
|
||||
|
||||
archive_handle->seek(archive_handle, skip_amount);
|
||||
archive_handle->offset += skip_amount;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
* 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 <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <utime.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void data_extract_all(archive_handle_t *archive_handle)
|
||||
{
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
int dst_fd;
|
||||
int res;
|
||||
|
||||
if (archive_handle->flags & ARCHIVE_CREATE_LEADING_DIRS) {
|
||||
char *name = bb_xstrdup(file_header->name);
|
||||
bb_make_directory (dirname(name), -1, FILEUTILS_RECUR);
|
||||
free(name);
|
||||
}
|
||||
|
||||
/* Check if the file already exists */
|
||||
if (archive_handle->flags & ARCHIVE_EXTRACT_UNCONDITIONAL) {
|
||||
/* Remove the existing entry if it exists */
|
||||
if (((file_header->mode & S_IFMT) != S_IFDIR) && (unlink(file_header->name) == -1) && (errno != ENOENT)) {
|
||||
bb_perror_msg_and_die("Couldnt remove old file");
|
||||
}
|
||||
}
|
||||
else if (archive_handle->flags & ARCHIVE_EXTRACT_NEWER) {
|
||||
/* Remove the existing entry if its older than the extracted entry */
|
||||
struct stat statbuf;
|
||||
if (lstat(file_header->name, &statbuf) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
bb_perror_msg_and_die("Couldnt stat old file");
|
||||
}
|
||||
}
|
||||
else if (statbuf.st_mtime <= file_header->mtime) {
|
||||
if (!(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_error_msg("%s not created: newer or same age file exists", file_header->name);
|
||||
}
|
||||
data_skip(archive_handle);
|
||||
return;
|
||||
}
|
||||
else if ((unlink(file_header->name) == -1) && (errno != EISDIR)) {
|
||||
bb_perror_msg_and_die("Couldnt remove old file %s", file_header->name);
|
||||
}
|
||||
}
|
||||
|
||||
/* Handle hard links separately
|
||||
* We identified hard links as regular files of size 0 with a symlink */
|
||||
if (S_ISREG(file_header->mode) && (file_header->link_name) && (file_header->size == 0)) {
|
||||
/* hard link */
|
||||
res = link(file_header->link_name, file_header->name);
|
||||
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("Couldnt create hard link");
|
||||
}
|
||||
} else {
|
||||
/* Create the filesystem entry */
|
||||
switch(file_header->mode & S_IFMT) {
|
||||
case S_IFREG: {
|
||||
/* Regular file */
|
||||
dst_fd = bb_xopen(file_header->name, O_WRONLY | O_CREAT | O_EXCL);
|
||||
bb_copyfd_size(archive_handle->src_fd, dst_fd, file_header->size);
|
||||
close(dst_fd);
|
||||
break;
|
||||
}
|
||||
case S_IFDIR:
|
||||
res = mkdir(file_header->name, file_header->mode);
|
||||
if ((errno != EISDIR) && (res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("extract_archive: %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
case S_IFLNK:
|
||||
/* Symlink */
|
||||
res = symlink(file_header->link_name, file_header->name);
|
||||
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("Cannot create symlink from %s to '%s'", file_header->name, file_header->link_name);
|
||||
}
|
||||
break;
|
||||
case S_IFSOCK:
|
||||
case S_IFBLK:
|
||||
case S_IFCHR:
|
||||
case S_IFIFO:
|
||||
res = mknod(file_header->name, file_header->mode, file_header->device);
|
||||
if ((res == -1) && !(archive_handle->flags & ARCHIVE_EXTRACT_QUIET)) {
|
||||
bb_perror_msg("Cannot create node %s", file_header->name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
bb_error_msg_and_die("Unrecognised file type");
|
||||
}
|
||||
}
|
||||
|
||||
lchown(file_header->name, file_header->uid, file_header->gid);
|
||||
if ((file_header->mode & S_IFMT) != S_IFLNK) {
|
||||
chmod(file_header->name, file_header->mode);
|
||||
}
|
||||
|
||||
if (archive_handle->flags & ARCHIVE_PRESERVE_DATE) {
|
||||
struct utimbuf t;
|
||||
t.actime = t.modtime = file_header->mtime;
|
||||
utime(file_header->name, &t);
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* 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 "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void data_extract_to_buffer(archive_handle_t *archive_handle)
|
||||
{
|
||||
const unsigned int size = archive_handle->file_header->size;
|
||||
|
||||
archive_handle->buffer = xmalloc(size + 1);
|
||||
|
||||
archive_xread_all(archive_handle, archive_handle->buffer, size);
|
||||
archive_handle->buffer[size] = '\0';
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
/*
|
||||
* 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 "unarchive.h"
|
||||
#include <unistd.h>
|
||||
|
||||
extern void data_extract_to_stdout(archive_handle_t *archive_handle)
|
||||
{
|
||||
bb_copyfd_size(archive_handle->src_fd, STDOUT_FILENO, archive_handle->file_header->size);
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* 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 <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
extern void data_skip(archive_handle_t *archive_handle)
|
||||
{
|
||||
archive_handle->seek(archive_handle, archive_handle->file_header->size);
|
||||
}
|
||||
@@ -1,612 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/* Small bzip2 deflate implementation, by Rob Landley (rob@landley.net).
|
||||
|
||||
Based on bzip2 decompression code by Julian R Seward (jseward@acm.org),
|
||||
which also acknowledges contributions by Mike Burrows, David Wheeler,
|
||||
Peter Fenwick, Alistair Moffat, Radford Neal, Ian H. Witten,
|
||||
Robert Sedgewick, and Jon L. Bentley.
|
||||
|
||||
This code is licensed under the LGPLv2:
|
||||
LGPL (http://www.gnu.org/copyleft/lgpl.html
|
||||
*/
|
||||
|
||||
/*
|
||||
Size and speed optimizations by Manuel Novoa III (mjn3@codepoet.org).
|
||||
|
||||
More efficient reading of Huffman codes, a streamlined read_bunzip()
|
||||
function, and various other tweaks. In (limited) tests, approximately
|
||||
20% faster than bzcat on x86 and about 10% faster on arm.
|
||||
|
||||
Note that about 2/3 of the time is spent in read_unzip() reversing
|
||||
the Burrows-Wheeler transformation. Much of that time is delay
|
||||
resulting from cache misses.
|
||||
|
||||
I would ask that anyone benefiting from this work, especially those
|
||||
using it in commercial products, consider making a donation to my local
|
||||
non-profit hospice organization in the name of the woman I loved, who
|
||||
passed away Feb. 12, 2003.
|
||||
|
||||
In memory of Toni W. Hagan
|
||||
|
||||
Hospice of Acadiana, Inc.
|
||||
2600 Johnston St., Suite 200
|
||||
Lafayette, LA 70503-3240
|
||||
|
||||
Phone (337) 232-1234 or 1-800-738-2226
|
||||
Fax (337) 232-1297
|
||||
|
||||
http://www.hospiceacadiana.com/
|
||||
|
||||
Manuel
|
||||
*/
|
||||
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
/* Constants for Huffman coding */
|
||||
#define MAX_GROUPS 6
|
||||
#define GROUP_SIZE 50 /* 64 would have been more efficient */
|
||||
#define MAX_HUFCODE_BITS 20 /* Longest Huffman code allowed */
|
||||
#define MAX_SYMBOLS 258 /* 256 literals + RUNA + RUNB */
|
||||
#define SYMBOL_RUNA 0
|
||||
#define SYMBOL_RUNB 1
|
||||
|
||||
/* Status return values */
|
||||
#define RETVAL_OK 0
|
||||
#define RETVAL_LAST_BLOCK (-1)
|
||||
#define RETVAL_NOT_BZIP_DATA (-2)
|
||||
#define RETVAL_UNEXPECTED_INPUT_EOF (-3)
|
||||
#define RETVAL_UNEXPECTED_OUTPUT_EOF (-4)
|
||||
#define RETVAL_DATA_ERROR (-5)
|
||||
#define RETVAL_OUT_OF_MEMORY (-6)
|
||||
#define RETVAL_OBSOLETE_INPUT (-7)
|
||||
|
||||
/* Other housekeeping constants */
|
||||
#define IOBUF_SIZE 4096
|
||||
|
||||
/* This is what we know about each Huffman coding group */
|
||||
struct group_data {
|
||||
/* We have an extra slot at the end of limit[] for a sentinal value. */
|
||||
int limit[MAX_HUFCODE_BITS+1],base[MAX_HUFCODE_BITS],permute[MAX_SYMBOLS];
|
||||
int minLen, maxLen;
|
||||
};
|
||||
|
||||
/* Structure holding all the housekeeping data, including IO buffers and
|
||||
memory that persists between calls to bunzip */
|
||||
typedef struct {
|
||||
/* State for interrupting output loop */
|
||||
int writeCopies,writePos,writeRunCountdown,writeCount,writeCurrent;
|
||||
/* I/O tracking data (file handles, buffers, positions, etc.) */
|
||||
int in_fd,out_fd,inbufCount,inbufPos /*,outbufPos*/;
|
||||
unsigned char *inbuf /*,*outbuf*/;
|
||||
unsigned int inbufBitCount, inbufBits;
|
||||
/* The CRC values stored in the block header and calculated from the data */
|
||||
unsigned int crc32Table[256],headerCRC, totalCRC, writeCRC;
|
||||
/* Intermediate buffer and its size (in bytes) */
|
||||
unsigned int *dbuf, dbufSize;
|
||||
/* These things are a bit too big to go on the stack */
|
||||
unsigned char selectors[32768]; /* nSelectors=15 bits */
|
||||
struct group_data groups[MAX_GROUPS]; /* Huffman coding tables */
|
||||
/* For I/O error handling */
|
||||
jmp_buf jmpbuf;
|
||||
} bunzip_data;
|
||||
|
||||
/* Return the next nnn bits of input. All reads from the compressed input
|
||||
are done through this function. All reads are big endian */
|
||||
static unsigned int get_bits(bunzip_data *bd, char bits_wanted)
|
||||
{
|
||||
unsigned int bits=0;
|
||||
|
||||
/* If we need to get more data from the byte buffer, do so. (Loop getting
|
||||
one byte at a time to enforce endianness and avoid unaligned access.) */
|
||||
while (bd->inbufBitCount<bits_wanted) {
|
||||
/* If we need to read more data from file into byte buffer, do so */
|
||||
if(bd->inbufPos==bd->inbufCount) {
|
||||
if((bd->inbufCount = read(bd->in_fd, bd->inbuf, IOBUF_SIZE)) <= 0)
|
||||
longjmp(bd->jmpbuf,RETVAL_UNEXPECTED_INPUT_EOF);
|
||||
bd->inbufPos=0;
|
||||
}
|
||||
/* Avoid 32-bit overflow (dump bit buffer to top of output) */
|
||||
if(bd->inbufBitCount>=24) {
|
||||
bits=bd->inbufBits&((1<<bd->inbufBitCount)-1);
|
||||
bits_wanted-=bd->inbufBitCount;
|
||||
bits<<=bits_wanted;
|
||||
bd->inbufBitCount=0;
|
||||
}
|
||||
/* Grab next 8 bits of input from buffer. */
|
||||
bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++];
|
||||
bd->inbufBitCount+=8;
|
||||
}
|
||||
/* Calculate result */
|
||||
bd->inbufBitCount-=bits_wanted;
|
||||
bits|=(bd->inbufBits>>bd->inbufBitCount)&((1<<bits_wanted)-1);
|
||||
|
||||
return bits;
|
||||
}
|
||||
|
||||
/* Unpacks the next block and sets up for the inverse burrows-wheeler step. */
|
||||
|
||||
static int get_next_block(bunzip_data *bd)
|
||||
{
|
||||
struct group_data *hufGroup;
|
||||
int dbufCount,nextSym,dbufSize,groupCount,*base,*limit,selector,
|
||||
i,j,k,t,runPos,symCount,symTotal,nSelectors,byteCount[256];
|
||||
unsigned char uc, symToByte[256], mtfSymbol[256], *selectors;
|
||||
unsigned int *dbuf,origPtr;
|
||||
|
||||
dbuf=bd->dbuf;
|
||||
dbufSize=bd->dbufSize;
|
||||
selectors=bd->selectors;
|
||||
/* Reset longjmp I/O error handling */
|
||||
i=setjmp(bd->jmpbuf);
|
||||
if(i) return i;
|
||||
/* Read in header signature and CRC, then validate signature.
|
||||
(last block signature means CRC is for whole file, return now) */
|
||||
i = get_bits(bd,24);
|
||||
j = get_bits(bd,24);
|
||||
bd->headerCRC=get_bits(bd,32);
|
||||
if ((i == 0x177245) && (j == 0x385090)) return RETVAL_LAST_BLOCK;
|
||||
if ((i != 0x314159) || (j != 0x265359)) return RETVAL_NOT_BZIP_DATA;
|
||||
/* We can add support for blockRandomised if anybody complains. There was
|
||||
some code for this in busybox 1.0.0-pre3, but nobody ever noticed that
|
||||
it didn't actually work. */
|
||||
if(get_bits(bd,1)) return RETVAL_OBSOLETE_INPUT;
|
||||
if((origPtr=get_bits(bd,24)) > dbufSize) return RETVAL_DATA_ERROR;
|
||||
/* mapping table: if some byte values are never used (encoding things
|
||||
like ascii text), the compression code removes the gaps to have fewer
|
||||
symbols to deal with, and writes a sparse bitfield indicating which
|
||||
values were present. We make a translation table to convert the symbols
|
||||
back to the corresponding bytes. */
|
||||
t=get_bits(bd, 16);
|
||||
symTotal=0;
|
||||
for (i=0;i<16;i++) {
|
||||
if(t&(1<<(15-i))) {
|
||||
k=get_bits(bd,16);
|
||||
for(j=0;j<16;j++)
|
||||
if(k&(1<<(15-j))) symToByte[symTotal++]=(16*i)+j;
|
||||
}
|
||||
}
|
||||
/* How many different Huffman coding groups does this block use? */
|
||||
groupCount=get_bits(bd,3);
|
||||
if (groupCount<2 || groupCount>MAX_GROUPS) return RETVAL_DATA_ERROR;
|
||||
/* nSelectors: Every GROUP_SIZE many symbols we select a new Huffman coding
|
||||
group. Read in the group selector list, which is stored as MTF encoded
|
||||
bit runs. (MTF=Move To Front, as each value is used it's moved to the
|
||||
start of the list.) */
|
||||
if(!(nSelectors=get_bits(bd, 15))) return RETVAL_DATA_ERROR;
|
||||
for(i=0; i<groupCount; i++) mtfSymbol[i] = i;
|
||||
for(i=0; i<nSelectors; i++) {
|
||||
/* Get next value */
|
||||
for(j=0;get_bits(bd,1);j++) if (j>=groupCount) return RETVAL_DATA_ERROR;
|
||||
/* Decode MTF to get the next selector */
|
||||
uc = mtfSymbol[j];
|
||||
for(;j;j--) mtfSymbol[j] = mtfSymbol[j-1];
|
||||
mtfSymbol[0]=selectors[i]=uc;
|
||||
}
|
||||
/* Read the Huffman coding tables for each group, which code for symTotal
|
||||
literal symbols, plus two run symbols (RUNA, RUNB) */
|
||||
symCount=symTotal+2;
|
||||
for (j=0; j<groupCount; j++) {
|
||||
unsigned char length[MAX_SYMBOLS],temp[MAX_HUFCODE_BITS+1];
|
||||
int minLen, maxLen, pp;
|
||||
/* Read Huffman code lengths for each symbol. They're stored in
|
||||
a way similar to mtf; record a starting value for the first symbol,
|
||||
and an offset from the previous value for everys symbol after that.
|
||||
(Subtracting 1 before the loop and then adding it back at the end is
|
||||
an optimization that makes the test inside the loop simpler: symbol
|
||||
length 0 becomes negative, so an unsigned inequality catches it.) */
|
||||
t=get_bits(bd, 5)-1;
|
||||
for (i = 0; i < symCount; i++) {
|
||||
for(;;) {
|
||||
if (((unsigned)t) > (MAX_HUFCODE_BITS-1))
|
||||
return RETVAL_DATA_ERROR;
|
||||
/* If first bit is 0, stop. Else second bit indicates whether
|
||||
to increment or decrement the value. Optimization: grab 2
|
||||
bits and unget the second if the first was 0. */
|
||||
k = get_bits(bd,2);
|
||||
if (k < 2) {
|
||||
bd->inbufBitCount++;
|
||||
break;
|
||||
}
|
||||
/* Add one if second bit 1, else subtract 1. Avoids if/else */
|
||||
t+=(((k+1)&2)-1);
|
||||
}
|
||||
/* Correct for the initial -1, to get the final symbol length */
|
||||
length[i]=t+1;
|
||||
}
|
||||
/* Find largest and smallest lengths in this group */
|
||||
minLen=maxLen=length[0];
|
||||
for(i = 1; i < symCount; i++) {
|
||||
if(length[i] > maxLen) maxLen = length[i];
|
||||
else if(length[i] < minLen) minLen = length[i];
|
||||
}
|
||||
/* Calculate permute[], base[], and limit[] tables from length[].
|
||||
*
|
||||
* permute[] is the lookup table for converting Huffman coded symbols
|
||||
* into decoded symbols. base[] is the amount to subtract from the
|
||||
* value of a Huffman symbol of a given length when using permute[].
|
||||
*
|
||||
* limit[] indicates the largest numerical value a symbol with a given
|
||||
* number of bits can have. This is how the Huffman codes can vary in
|
||||
* length: each code with a value>limit[length] needs another bit.
|
||||
*/
|
||||
hufGroup=bd->groups+j;
|
||||
hufGroup->minLen = minLen;
|
||||
hufGroup->maxLen = maxLen;
|
||||
/* Note that minLen can't be smaller than 1, so we adjust the base
|
||||
and limit array pointers so we're not always wasting the first
|
||||
entry. We do this again when using them (during symbol decoding).*/
|
||||
base=hufGroup->base-1;
|
||||
limit=hufGroup->limit-1;
|
||||
/* Calculate permute[]. Concurently, initialize temp[] and limit[]. */
|
||||
pp=0;
|
||||
for(i=minLen;i<=maxLen;i++) {
|
||||
temp[i]=limit[i]=0;
|
||||
for(t=0;t<symCount;t++)
|
||||
if(length[t]==i) hufGroup->permute[pp++] = t;
|
||||
}
|
||||
/* Count symbols coded for at each bit length */
|
||||
for (i=0;i<symCount;i++) temp[length[i]]++;
|
||||
/* Calculate limit[] (the largest symbol-coding value at each bit
|
||||
* length, which is (previous limit<<1)+symbols at this level), and
|
||||
* base[] (number of symbols to ignore at each bit length, which is
|
||||
* limit minus the cumulative count of symbols coded for already). */
|
||||
pp=t=0;
|
||||
for (i=minLen; i<maxLen; i++) {
|
||||
pp+=temp[i];
|
||||
/* We read the largest possible symbol size and then unget bits
|
||||
after determining how many we need, and those extra bits could
|
||||
be set to anything. (They're noise from future symbols.) At
|
||||
each level we're really only interested in the first few bits,
|
||||
so here we set all the trailing to-be-ignored bits to 1 so they
|
||||
don't affect the value>limit[length] comparison. */
|
||||
limit[i]= (pp << (maxLen - i)) - 1;
|
||||
pp<<=1;
|
||||
base[i+1]=pp-(t+=temp[i]);
|
||||
}
|
||||
limit[maxLen+1] = INT_MAX; /* Sentinal value for reading next sym. */
|
||||
limit[maxLen]=pp+temp[maxLen]-1;
|
||||
base[minLen]=0;
|
||||
}
|
||||
/* We've finished reading and digesting the block header. Now read this
|
||||
block's Huffman coded symbols from the file and undo the Huffman coding
|
||||
and run length encoding, saving the result into dbuf[dbufCount++]=uc */
|
||||
|
||||
/* Initialize symbol occurrence counters and symbol Move To Front table */
|
||||
for(i=0;i<256;i++) {
|
||||
byteCount[i] = 0;
|
||||
mtfSymbol[i]=(unsigned char)i;
|
||||
}
|
||||
/* Loop through compressed symbols. */
|
||||
runPos=dbufCount=selector=0;
|
||||
for(;;) {
|
||||
/* fetch next Huffman coding group from list. */
|
||||
symCount=GROUP_SIZE-1;
|
||||
if(selector>=nSelectors) return RETVAL_DATA_ERROR;
|
||||
hufGroup=bd->groups+selectors[selector++];
|
||||
base=hufGroup->base-1;
|
||||
limit=hufGroup->limit-1;
|
||||
continue_this_group:
|
||||
/* Read next Huffman-coded symbol. */
|
||||
/* Note: It is far cheaper to read maxLen bits and back up than it is
|
||||
to read minLen bits and then an additional bit at a time, testing
|
||||
as we go. Because there is a trailing last block (with file CRC),
|
||||
there is no danger of the overread causing an unexpected EOF for a
|
||||
valid compressed file. As a further optimization, we do the read
|
||||
inline (falling back to a call to get_bits if the buffer runs
|
||||
dry). The following (up to got_huff_bits:) is equivalent to
|
||||
j=get_bits(bd,hufGroup->maxLen);
|
||||
*/
|
||||
while (bd->inbufBitCount<hufGroup->maxLen) {
|
||||
if(bd->inbufPos==bd->inbufCount) {
|
||||
j = get_bits(bd,hufGroup->maxLen);
|
||||
goto got_huff_bits;
|
||||
}
|
||||
bd->inbufBits=(bd->inbufBits<<8)|bd->inbuf[bd->inbufPos++];
|
||||
bd->inbufBitCount+=8;
|
||||
};
|
||||
bd->inbufBitCount-=hufGroup->maxLen;
|
||||
j = (bd->inbufBits>>bd->inbufBitCount)&((1<<hufGroup->maxLen)-1);
|
||||
got_huff_bits:
|
||||
/* Figure how how many bits are in next symbol and unget extras */
|
||||
i=hufGroup->minLen;
|
||||
while(j>limit[i]) ++i;
|
||||
bd->inbufBitCount += (hufGroup->maxLen - i);
|
||||
/* Huffman decode value to get nextSym (with bounds checking) */
|
||||
if ((i > hufGroup->maxLen)
|
||||
|| (((unsigned)(j=(j>>(hufGroup->maxLen-i))-base[i]))
|
||||
>= MAX_SYMBOLS))
|
||||
return RETVAL_DATA_ERROR;
|
||||
nextSym = hufGroup->permute[j];
|
||||
/* We have now decoded the symbol, which indicates either a new literal
|
||||
byte, or a repeated run of the most recent literal byte. First,
|
||||
check if nextSym indicates a repeated run, and if so loop collecting
|
||||
how many times to repeat the last literal. */
|
||||
if (((unsigned)nextSym) <= SYMBOL_RUNB) { /* RUNA or RUNB */
|
||||
/* If this is the start of a new run, zero out counter */
|
||||
if(!runPos) {
|
||||
runPos = 1;
|
||||
t = 0;
|
||||
}
|
||||
/* Neat trick that saves 1 symbol: instead of or-ing 0 or 1 at
|
||||
each bit position, add 1 or 2 instead. For example,
|
||||
1011 is 1<<0 + 1<<1 + 2<<2. 1010 is 2<<0 + 2<<1 + 1<<2.
|
||||
You can make any bit pattern that way using 1 less symbol than
|
||||
the basic or 0/1 method (except all bits 0, which would use no
|
||||
symbols, but a run of length 0 doesn't mean anything in this
|
||||
context). Thus space is saved. */
|
||||
t += (runPos << nextSym); /* +runPos if RUNA; +2*runPos if RUNB */
|
||||
runPos <<= 1;
|
||||
goto end_of_huffman_loop;
|
||||
}
|
||||
/* When we hit the first non-run symbol after a run, we now know
|
||||
how many times to repeat the last literal, so append that many
|
||||
copies to our buffer of decoded symbols (dbuf) now. (The last
|
||||
literal used is the one at the head of the mtfSymbol array.) */
|
||||
if(runPos) {
|
||||
runPos=0;
|
||||
if(dbufCount+t>=dbufSize) return RETVAL_DATA_ERROR;
|
||||
|
||||
uc = symToByte[mtfSymbol[0]];
|
||||
byteCount[uc] += t;
|
||||
while(t--) dbuf[dbufCount++]=uc;
|
||||
}
|
||||
/* Is this the terminating symbol? */
|
||||
if(nextSym>symTotal) break;
|
||||
/* At this point, nextSym indicates a new literal character. Subtract
|
||||
one to get the position in the MTF array at which this literal is
|
||||
currently to be found. (Note that the result can't be -1 or 0,
|
||||
because 0 and 1 are RUNA and RUNB. But another instance of the
|
||||
first symbol in the mtf array, position 0, would have been handled
|
||||
as part of a run above. Therefore 1 unused mtf position minus
|
||||
2 non-literal nextSym values equals -1.) */
|
||||
if(dbufCount>=dbufSize) return RETVAL_DATA_ERROR;
|
||||
i = nextSym - 1;
|
||||
uc = mtfSymbol[i];
|
||||
/* Adjust the MTF array. Since we typically expect to move only a
|
||||
* small number of symbols, and are bound by 256 in any case, using
|
||||
* memmove here would typically be bigger and slower due to function
|
||||
* call overhead and other assorted setup costs. */
|
||||
do {
|
||||
mtfSymbol[i] = mtfSymbol[i-1];
|
||||
} while (--i);
|
||||
mtfSymbol[0] = uc;
|
||||
uc=symToByte[uc];
|
||||
/* We have our literal byte. Save it into dbuf. */
|
||||
byteCount[uc]++;
|
||||
dbuf[dbufCount++] = (unsigned int)uc;
|
||||
/* Skip group initialization if we're not done with this group. Done this
|
||||
* way to avoid compiler warning. */
|
||||
end_of_huffman_loop:
|
||||
if(symCount--) goto continue_this_group;
|
||||
}
|
||||
/* At this point, we've read all the Huffman-coded symbols (and repeated
|
||||
runs) for this block from the input stream, and decoded them into the
|
||||
intermediate buffer. There are dbufCount many decoded bytes in dbuf[].
|
||||
Now undo the Burrows-Wheeler transform on dbuf.
|
||||
See http://dogma.net/markn/articles/bwt/bwt.htm
|
||||
*/
|
||||
/* Turn byteCount into cumulative occurrence counts of 0 to n-1. */
|
||||
j=0;
|
||||
for(i=0;i<256;i++) {
|
||||
k=j+byteCount[i];
|
||||
byteCount[i] = j;
|
||||
j=k;
|
||||
}
|
||||
/* Figure out what order dbuf would be in if we sorted it. */
|
||||
for (i=0;i<dbufCount;i++) {
|
||||
uc=(unsigned char)(dbuf[i] & 0xff);
|
||||
dbuf[byteCount[uc]] |= (i << 8);
|
||||
byteCount[uc]++;
|
||||
}
|
||||
/* Decode first byte by hand to initialize "previous" byte. Note that it
|
||||
doesn't get output, and if the first three characters are identical
|
||||
it doesn't qualify as a run (hence writeRunCountdown=5). */
|
||||
if(dbufCount) {
|
||||
if(origPtr>=dbufCount) return RETVAL_DATA_ERROR;
|
||||
bd->writePos=dbuf[origPtr];
|
||||
bd->writeCurrent=(unsigned char)(bd->writePos&0xff);
|
||||
bd->writePos>>=8;
|
||||
bd->writeRunCountdown=5;
|
||||
}
|
||||
bd->writeCount=dbufCount;
|
||||
|
||||
return RETVAL_OK;
|
||||
}
|
||||
|
||||
/* Undo burrows-wheeler transform on intermediate buffer to produce output.
|
||||
If start_bunzip was initialized with out_fd=-1, then up to len bytes of
|
||||
data are written to outbuf. Return value is number of bytes written or
|
||||
error (all errors are negative numbers). If out_fd!=-1, outbuf and len
|
||||
are ignored, data is written to out_fd and return is RETVAL_OK or error.
|
||||
*/
|
||||
|
||||
static int read_bunzip(bunzip_data *bd, char *outbuf, int len)
|
||||
{
|
||||
const unsigned int *dbuf;
|
||||
int pos,current,previous,gotcount;
|
||||
|
||||
/* If last read was short due to end of file, return last block now */
|
||||
if(bd->writeCount<0) return bd->writeCount;
|
||||
|
||||
gotcount = 0;
|
||||
dbuf=bd->dbuf;
|
||||
pos=bd->writePos;
|
||||
current=bd->writeCurrent;
|
||||
|
||||
/* We will always have pending decoded data to write into the output
|
||||
buffer unless this is the very first call (in which case we haven't
|
||||
Huffman-decoded a block into the intermediate buffer yet). */
|
||||
|
||||
if (bd->writeCopies) {
|
||||
/* Inside the loop, writeCopies means extra copies (beyond 1) */
|
||||
--bd->writeCopies;
|
||||
/* Loop outputting bytes */
|
||||
for(;;) {
|
||||
/* If the output buffer is full, snapshot state and return */
|
||||
if(gotcount >= len) {
|
||||
bd->writePos=pos;
|
||||
bd->writeCurrent=current;
|
||||
bd->writeCopies++;
|
||||
return len;
|
||||
}
|
||||
/* Write next byte into output buffer, updating CRC */
|
||||
outbuf[gotcount++] = current;
|
||||
bd->writeCRC=(((bd->writeCRC)<<8)
|
||||
^bd->crc32Table[((bd->writeCRC)>>24)^current]);
|
||||
/* Loop now if we're outputting multiple copies of this byte */
|
||||
if (bd->writeCopies) {
|
||||
--bd->writeCopies;
|
||||
continue;
|
||||
}
|
||||
decode_next_byte:
|
||||
if (!bd->writeCount--) break;
|
||||
/* Follow sequence vector to undo Burrows-Wheeler transform */
|
||||
previous=current;
|
||||
pos=dbuf[pos];
|
||||
current=pos&0xff;
|
||||
pos>>=8;
|
||||
/* After 3 consecutive copies of the same byte, the 4th is a repeat
|
||||
count. We count down from 4 instead
|
||||
* of counting up because testing for non-zero is faster */
|
||||
if(--bd->writeRunCountdown) {
|
||||
if(current!=previous) bd->writeRunCountdown=4;
|
||||
} else {
|
||||
/* We have a repeated run, this byte indicates the count */
|
||||
bd->writeCopies=current;
|
||||
current=previous;
|
||||
bd->writeRunCountdown=5;
|
||||
/* Sometimes there are just 3 bytes (run length 0) */
|
||||
if(!bd->writeCopies) goto decode_next_byte;
|
||||
/* Subtract the 1 copy we'd output anyway to get extras */
|
||||
--bd->writeCopies;
|
||||
}
|
||||
}
|
||||
/* Decompression of this block completed successfully */
|
||||
bd->writeCRC=~bd->writeCRC;
|
||||
bd->totalCRC=((bd->totalCRC<<1) | (bd->totalCRC>>31)) ^ bd->writeCRC;
|
||||
/* If this block had a CRC error, force file level CRC error. */
|
||||
if(bd->writeCRC!=bd->headerCRC) {
|
||||
bd->totalCRC=bd->headerCRC+1;
|
||||
return RETVAL_LAST_BLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
/* Refill the intermediate buffer by Huffman-decoding next block of input */
|
||||
/* (previous is just a convenient unused temp variable here) */
|
||||
previous=get_next_block(bd);
|
||||
if(previous) {
|
||||
bd->writeCount=previous;
|
||||
return (previous!=RETVAL_LAST_BLOCK) ? previous : gotcount;
|
||||
}
|
||||
bd->writeCRC=0xffffffffUL;
|
||||
pos=bd->writePos;
|
||||
current=bd->writeCurrent;
|
||||
goto decode_next_byte;
|
||||
}
|
||||
|
||||
/* Allocate the structure, read file header. If in_fd==-1, inbuf must contain
|
||||
a complete bunzip file (len bytes long). If in_fd!=-1, inbuf and len are
|
||||
ignored, and data is read from file handle into temporary buffer. */
|
||||
static int start_bunzip(bunzip_data **bdp, int in_fd, char *inbuf, int len)
|
||||
{
|
||||
bunzip_data *bd;
|
||||
unsigned int i,j,c;
|
||||
const unsigned int BZh0=(((unsigned int)'B')<<24)+(((unsigned int)'Z')<<16)
|
||||
+(((unsigned int)'h')<<8)+(unsigned int)'0';
|
||||
|
||||
/* Figure out how much data to allocate */
|
||||
i=sizeof(bunzip_data);
|
||||
if(in_fd!=-1) i+=IOBUF_SIZE;
|
||||
/* Allocate bunzip_data. Most fields initialize to zero. */
|
||||
bd=*bdp=xmalloc(i);
|
||||
memset(bd,0,sizeof(bunzip_data));
|
||||
/* Setup input buffer */
|
||||
if(-1==(bd->in_fd=in_fd)) {
|
||||
bd->inbuf=inbuf;
|
||||
bd->inbufCount=len;
|
||||
} else bd->inbuf=(unsigned char *)(bd+1);
|
||||
/* Init the CRC32 table (big endian) */
|
||||
for(i=0;i<256;i++) {
|
||||
c=i<<24;
|
||||
for(j=8;j;j--)
|
||||
c=c&0x80000000 ? (c<<1)^0x04c11db7 : (c<<1);
|
||||
bd->crc32Table[i]=c;
|
||||
}
|
||||
/* Setup for I/O error handling via longjmp */
|
||||
i=setjmp(bd->jmpbuf);
|
||||
if(i) return i;
|
||||
|
||||
/* Ensure that file starts with "BZh['1'-'9']." */
|
||||
i = get_bits(bd,32);
|
||||
if (((unsigned int)(i-BZh0-1)) >= 9) return RETVAL_NOT_BZIP_DATA;
|
||||
|
||||
/* Fourth byte (ascii '1'-'9'), indicates block size in units of 100k of
|
||||
uncompressed data. Allocate intermediate buffer for block. */
|
||||
bd->dbufSize=100000*(i-BZh0);
|
||||
|
||||
bd->dbuf=xmalloc(bd->dbufSize * sizeof(int));
|
||||
return RETVAL_OK;
|
||||
}
|
||||
|
||||
/* Example usage: decompress src_fd to dst_fd. (Stops at end of bzip data,
|
||||
not end of file.) */
|
||||
extern int uncompressStream(int src_fd, int dst_fd)
|
||||
{
|
||||
char *outbuf;
|
||||
bunzip_data *bd;
|
||||
int i;
|
||||
|
||||
outbuf=xmalloc(IOBUF_SIZE);
|
||||
if(!(i=start_bunzip(&bd,src_fd,0,0))) {
|
||||
for(;;) {
|
||||
if((i=read_bunzip(bd,outbuf,IOBUF_SIZE)) <= 0) break;
|
||||
if(i!=write(dst_fd,outbuf,i)) {
|
||||
i=RETVAL_UNEXPECTED_OUTPUT_EOF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Check CRC and release memory */
|
||||
if(i==RETVAL_LAST_BLOCK) {
|
||||
if (bd->headerCRC!=bd->totalCRC) {
|
||||
bb_error_msg("Data integrity error when decompressing.");
|
||||
} else {
|
||||
i=RETVAL_OK;
|
||||
}
|
||||
}
|
||||
else if (i==RETVAL_UNEXPECTED_OUTPUT_EOF) {
|
||||
bb_error_msg("Compressed file ends unexpectedly");
|
||||
} else {
|
||||
bb_error_msg("Decompression failed");
|
||||
}
|
||||
if(bd->dbuf) free(bd->dbuf);
|
||||
free(bd);
|
||||
free(outbuf);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#ifdef TESTING
|
||||
|
||||
static char * const bunzip_errors[]={NULL,"Bad file checksum","Not bzip data",
|
||||
"Unexpected input EOF","Unexpected output EOF","Data error",
|
||||
"Out of memory","Obsolete (pre 0.9.5) bzip format not supported."};
|
||||
|
||||
/* Dumb little test thing, decompress stdin to stdout */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i=uncompressStream(0,1);
|
||||
char c;
|
||||
|
||||
if(i) fprintf(stderr,"%s\n", bunzip_errors[-i]);
|
||||
else if(read(0,&c,1)) fprintf(stderr,"Trailing garbage ignored\n");
|
||||
return -i;
|
||||
}
|
||||
#endif
|
||||
@@ -1,293 +0,0 @@
|
||||
#include "config.h"
|
||||
#include "libbb.h"
|
||||
|
||||
/* uncompress for busybox -- (c) 2002 Robert Griebl
|
||||
*
|
||||
* based on the original compress42.c source
|
||||
* (see disclaimer below)
|
||||
*/
|
||||
|
||||
|
||||
/* (N)compress42.c - File compression ala IEEE Computer, Mar 1992.
|
||||
*
|
||||
* Authors:
|
||||
* Spencer W. Thomas (decvax!harpo!utah-cs!utah-gr!thomas)
|
||||
* Jim McKie (decvax!mcvax!jim)
|
||||
* Steve Davies (decvax!vax135!petsd!peora!srd)
|
||||
* Ken Turkowski (decvax!decwrl!turtlevax!ken)
|
||||
* James A. Woods (decvax!ihnp4!ames!jaw)
|
||||
* Joe Orost (decvax!vax135!petsd!joe)
|
||||
* Dave Mack (csu@alembic.acs.com)
|
||||
* Peter Jannesen, Network Communication Systems
|
||||
* (peter@ncs.nl)
|
||||
*
|
||||
* marc@suse.de : a small security fix for a buffer overflow
|
||||
*
|
||||
* [... History snipped ...]
|
||||
*
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Default input buffer size */
|
||||
#define IBUFSIZ 2048
|
||||
|
||||
/* Default output buffer size */
|
||||
#define OBUFSIZ 2048
|
||||
|
||||
/* Defines for third byte of header */
|
||||
#define MAGIC_1 (char_type)'\037' /* First byte of compressed file */
|
||||
#define MAGIC_2 (char_type)'\235' /* Second byte of compressed file */
|
||||
#define BIT_MASK 0x1f /* Mask for 'number of compresssion bits' */
|
||||
/* Masks 0x20 and 0x40 are free. */
|
||||
/* I think 0x20 should mean that there is */
|
||||
/* a fourth header byte (for expansion). */
|
||||
#define BLOCK_MODE 0x80 /* Block compresssion if table is full and */
|
||||
/* compression rate is dropping flush tables */
|
||||
/* the next two codes should not be changed lightly, as they must not */
|
||||
/* lie within the contiguous general code space. */
|
||||
#define FIRST 257 /* first free entry */
|
||||
#define CLEAR 256 /* table clear output code */
|
||||
|
||||
#define INIT_BITS 9 /* initial number of bits/code */
|
||||
|
||||
|
||||
/* machine variants which require cc -Dmachine: pdp11, z8000, DOS */
|
||||
#define FAST
|
||||
|
||||
#define HBITS 17 /* 50% occupancy */
|
||||
#define HSIZE (1<<HBITS)
|
||||
#define HMASK (HSIZE-1)
|
||||
#define HPRIME 9941
|
||||
#define BITS 16
|
||||
#undef MAXSEG_64K
|
||||
#define MAXCODE(n) (1L << (n))
|
||||
|
||||
/* Block compress mode -C compatible with 2.0 */
|
||||
int block_mode = BLOCK_MODE;
|
||||
|
||||
/* user settable max # bits/code */
|
||||
int maxbits = BITS;
|
||||
|
||||
/* Exitcode of compress (-1 no file compressed) */
|
||||
int exit_code = -1;
|
||||
|
||||
/* Input buffer */
|
||||
unsigned char inbuf[IBUFSIZ + 64];
|
||||
|
||||
/* Output buffer */
|
||||
unsigned char outbuf[OBUFSIZ + 2048];
|
||||
|
||||
|
||||
long int htab[HSIZE];
|
||||
unsigned short codetab[HSIZE];
|
||||
|
||||
#define htabof(i) htab[i]
|
||||
#define codetabof(i) codetab[i]
|
||||
#define tab_prefixof(i) codetabof(i)
|
||||
#define tab_suffixof(i) ((unsigned char *)(htab))[i]
|
||||
#define de_stack ((unsigned char *)&(htab[HSIZE-1]))
|
||||
#define clear_htab() memset(htab, -1, sizeof(htab))
|
||||
#define clear_tab_prefixof() memset(codetab, 0, 256);
|
||||
|
||||
|
||||
/*
|
||||
* Decompress stdin to stdout. This routine adapts to the codes in the
|
||||
* file building the "string" table on-the-fly; requiring no table to
|
||||
* be stored in the compressed file. The tables used herein are shared
|
||||
* with those of the compress() routine. See the definitions above.
|
||||
*/
|
||||
|
||||
extern int uncompress(int fd_in, int fd_out)
|
||||
{
|
||||
unsigned char *stackp;
|
||||
long int code;
|
||||
int finchar;
|
||||
long int oldcode;
|
||||
long int incode;
|
||||
int inbits;
|
||||
int posbits;
|
||||
int outpos;
|
||||
int insize;
|
||||
int bitmask;
|
||||
long int free_ent;
|
||||
long int maxcode;
|
||||
long int maxmaxcode;
|
||||
int n_bits;
|
||||
int rsize = 0;
|
||||
|
||||
insize = 0;
|
||||
|
||||
inbuf[0] = bb_xread_char(fd_in);
|
||||
|
||||
maxbits = inbuf[0] & BIT_MASK;
|
||||
block_mode = inbuf[0] & BLOCK_MODE;
|
||||
maxmaxcode = MAXCODE(maxbits);
|
||||
|
||||
if (maxbits > BITS) {
|
||||
bb_error_msg("compressed with %d bits, can only handle %d bits", maxbits,
|
||||
BITS);
|
||||
return -1;
|
||||
}
|
||||
|
||||
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
oldcode = -1;
|
||||
finchar = 0;
|
||||
outpos = 0;
|
||||
posbits = 0 << 3;
|
||||
|
||||
free_ent = ((block_mode) ? FIRST : 256);
|
||||
|
||||
/* As above, initialize the first 256 entries in the table. */
|
||||
clear_tab_prefixof();
|
||||
|
||||
for (code = 255; code >= 0; --code) {
|
||||
tab_suffixof(code) = (unsigned char) code;
|
||||
}
|
||||
|
||||
do {
|
||||
resetbuf:;
|
||||
{
|
||||
int i;
|
||||
int e;
|
||||
int o;
|
||||
|
||||
e = insize - (o = (posbits >> 3));
|
||||
|
||||
for (i = 0; i < e; ++i)
|
||||
inbuf[i] = inbuf[i + o];
|
||||
|
||||
insize = e;
|
||||
posbits = 0;
|
||||
}
|
||||
|
||||
if (insize < (int) sizeof(inbuf) - IBUFSIZ) {
|
||||
rsize = safe_read(fd_in, inbuf + insize, IBUFSIZ);
|
||||
insize += rsize;
|
||||
}
|
||||
|
||||
inbits = ((rsize > 0) ? (insize - insize % n_bits) << 3 :
|
||||
(insize << 3) - (n_bits - 1));
|
||||
|
||||
while (inbits > posbits) {
|
||||
if (free_ent > maxcode) {
|
||||
posbits =
|
||||
((posbits - 1) +
|
||||
((n_bits << 3) -
|
||||
(posbits - 1 + (n_bits << 3)) % (n_bits << 3)));
|
||||
++n_bits;
|
||||
if (n_bits == maxbits) {
|
||||
maxcode = maxmaxcode;
|
||||
} else {
|
||||
maxcode = MAXCODE(n_bits) - 1;
|
||||
}
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
goto resetbuf;
|
||||
}
|
||||
{
|
||||
unsigned char *p = &inbuf[posbits >> 3];
|
||||
|
||||
code =
|
||||
((((long) (p[0])) | ((long) (p[1]) << 8) |
|
||||
((long) (p[2]) << 16)) >> (posbits & 0x7)) & bitmask;
|
||||
}
|
||||
posbits += n_bits;
|
||||
|
||||
|
||||
if (oldcode == -1) {
|
||||
outbuf[outpos++] = (unsigned char) (finchar =
|
||||
(int) (oldcode = code));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (code == CLEAR && block_mode) {
|
||||
clear_tab_prefixof();
|
||||
free_ent = FIRST - 1;
|
||||
posbits =
|
||||
((posbits - 1) +
|
||||
((n_bits << 3) -
|
||||
(posbits - 1 + (n_bits << 3)) % (n_bits << 3)));
|
||||
maxcode = MAXCODE(n_bits = INIT_BITS) - 1;
|
||||
bitmask = (1 << n_bits) - 1;
|
||||
goto resetbuf;
|
||||
}
|
||||
|
||||
incode = code;
|
||||
stackp = de_stack;
|
||||
|
||||
/* Special case for KwKwK string. */
|
||||
if (code >= free_ent) {
|
||||
if (code > free_ent) {
|
||||
unsigned char *p;
|
||||
|
||||
posbits -= n_bits;
|
||||
p = &inbuf[posbits >> 3];
|
||||
|
||||
bb_error_msg
|
||||
("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)",
|
||||
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
|
||||
(posbits & 07));
|
||||
bb_error_msg("uncompress: corrupt input");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*--stackp = (unsigned char) finchar;
|
||||
code = oldcode;
|
||||
}
|
||||
|
||||
/* Generate output characters in reverse order */
|
||||
while ((long int) code >= (long int) 256) {
|
||||
*--stackp = tab_suffixof(code);
|
||||
code = tab_prefixof(code);
|
||||
}
|
||||
|
||||
*--stackp = (unsigned char) (finchar = tab_suffixof(code));
|
||||
|
||||
/* And put them out in forward order */
|
||||
{
|
||||
int i;
|
||||
|
||||
if (outpos + (i = (de_stack - stackp)) >= OBUFSIZ) {
|
||||
do {
|
||||
if (i > OBUFSIZ - outpos) {
|
||||
i = OBUFSIZ - outpos;
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
memcpy(outbuf + outpos, stackp, i);
|
||||
outpos += i;
|
||||
}
|
||||
|
||||
if (outpos >= OBUFSIZ) {
|
||||
write(fd_out, outbuf, outpos);
|
||||
outpos = 0;
|
||||
}
|
||||
stackp += i;
|
||||
} while ((i = (de_stack - stackp)) > 0);
|
||||
} else {
|
||||
memcpy(outbuf + outpos, stackp, i);
|
||||
outpos += i;
|
||||
}
|
||||
}
|
||||
|
||||
/* Generate the new entry. */
|
||||
if ((code = free_ent) < maxmaxcode) {
|
||||
tab_prefixof(code) = (unsigned short) oldcode;
|
||||
tab_suffixof(code) = (unsigned char) finchar;
|
||||
free_ent = code + 1;
|
||||
}
|
||||
|
||||
/* Remember previous code. */
|
||||
oldcode = incode;
|
||||
}
|
||||
|
||||
} while (rsize > 0);
|
||||
|
||||
if (outpos > 0) {
|
||||
write(fd_out, outbuf, outpos);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,985 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* gunzip implementation for busybox
|
||||
*
|
||||
* Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly.
|
||||
*
|
||||
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
|
||||
* based on gzip sources
|
||||
*
|
||||
* Adjusted further by Erik Andersen <andersen@codepoet.org> to support
|
||||
* files as well as stdin/stdout, and to generally behave itself wrt
|
||||
* command line handling.
|
||||
*
|
||||
* General cleanup to better adhere to the style guide and make use of standard
|
||||
* busybox functions by Glenn McGrath <bug1@iinet.net.au>
|
||||
*
|
||||
* read_gz interface + associated hacking 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
|
||||
*
|
||||
*
|
||||
* 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 <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "config.h"
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
typedef struct huft_s {
|
||||
unsigned char e; /* number of extra bits or operation */
|
||||
unsigned char b; /* number of bits in this code or subcode */
|
||||
union {
|
||||
unsigned short n; /* literal, length base, or distance base */
|
||||
struct huft_s *t; /* pointer to next level of table */
|
||||
} v;
|
||||
} huft_t;
|
||||
|
||||
static int gunzip_src_fd;
|
||||
unsigned int gunzip_bytes_out; /* number of output bytes */
|
||||
static unsigned int gunzip_outbuf_count; /* bytes in output buffer */
|
||||
|
||||
/* gunzip_window size--must be a power of two, and
|
||||
* at least 32K for zip's deflate method */
|
||||
static const int gunzip_wsize = 0x8000;
|
||||
static unsigned char *gunzip_window;
|
||||
|
||||
static unsigned int *gunzip_crc_table;
|
||||
unsigned int gunzip_crc;
|
||||
|
||||
/* If BMAX needs to be larger than 16, then h and x[] should be ulg. */
|
||||
#define BMAX 16 /* maximum bit length of any code (16 for explode) */
|
||||
#define N_MAX 288 /* maximum number of codes in any set */
|
||||
|
||||
/* bitbuffer */
|
||||
static unsigned int gunzip_bb; /* bit buffer */
|
||||
static unsigned char gunzip_bk; /* bits in bit buffer */
|
||||
|
||||
/* These control the size of the bytebuffer */
|
||||
static unsigned int bytebuffer_max = 0x8000;
|
||||
static unsigned char *bytebuffer = NULL;
|
||||
static unsigned int bytebuffer_offset = 0;
|
||||
static unsigned int bytebuffer_size = 0;
|
||||
|
||||
static const unsigned short mask_bits[] = {
|
||||
0x0000, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff,
|
||||
0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
|
||||
};
|
||||
|
||||
/* Copy lengths for literal codes 257..285 */
|
||||
static const unsigned short cplens[] = {
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59,
|
||||
67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
|
||||
};
|
||||
|
||||
/* note: see note #13 above about the 258 in this list. */
|
||||
/* Extra bits for literal codes 257..285 */
|
||||
static const unsigned char cplext[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5,
|
||||
5, 5, 5, 0, 99, 99
|
||||
}; /* 99==invalid */
|
||||
|
||||
/* Copy offsets for distance codes 0..29 */
|
||||
static const unsigned short cpdist[] = {
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513,
|
||||
769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577
|
||||
};
|
||||
|
||||
/* Extra bits for distance codes */
|
||||
static const unsigned char cpdext[] = {
|
||||
0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10,
|
||||
11, 11, 12, 12, 13, 13
|
||||
};
|
||||
|
||||
/* Tables for deflate from PKZIP's appnote.txt. */
|
||||
/* Order of the bit length code lengths */
|
||||
static const unsigned char border[] = {
|
||||
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
|
||||
};
|
||||
|
||||
static unsigned int fill_bitbuffer(unsigned int bitbuffer, unsigned int *current, const unsigned int required)
|
||||
{
|
||||
while (*current < required) {
|
||||
if (bytebuffer_offset >= bytebuffer_size) {
|
||||
/* Leave the first 4 bytes empty so we can always unwind the bitbuffer
|
||||
* to the front of the bytebuffer, leave 4 bytes free at end of tail
|
||||
* so we can easily top up buffer in check_trailer_gzip() */
|
||||
if (!(bytebuffer_size = bb_xread(gunzip_src_fd, &bytebuffer[4], bytebuffer_max - 8))) {
|
||||
bb_error_msg_and_die("unexpected end of file");
|
||||
}
|
||||
bytebuffer_size += 4;
|
||||
bytebuffer_offset = 4;
|
||||
}
|
||||
bitbuffer |= ((unsigned int) bytebuffer[bytebuffer_offset]) << *current;
|
||||
bytebuffer_offset++;
|
||||
*current += 8;
|
||||
}
|
||||
return(bitbuffer);
|
||||
}
|
||||
|
||||
static void make_gunzip_crc_table(void)
|
||||
{
|
||||
const unsigned int poly = 0xedb88320; /* polynomial exclusive-or pattern */
|
||||
unsigned short i; /* counter for all possible eight bit values */
|
||||
|
||||
/* initial shift register value */
|
||||
gunzip_crc = 0xffffffffL;
|
||||
gunzip_crc_table = (unsigned int *) malloc(256 * sizeof(unsigned int));
|
||||
|
||||
/* Compute and print table of CRC's, five per line */
|
||||
for (i = 0; i < 256; i++) {
|
||||
unsigned int table_entry; /* crc shift register */
|
||||
unsigned char k; /* byte being shifted into crc apparatus */
|
||||
|
||||
table_entry = i;
|
||||
/* The idea to initialize the register with the byte instead of
|
||||
* zero was stolen from Haruhiko Okumura's ar002
|
||||
*/
|
||||
for (k = 8; k; k--) {
|
||||
if (table_entry & 1) {
|
||||
table_entry = (table_entry >> 1) ^ poly;
|
||||
} else {
|
||||
table_entry >>= 1;
|
||||
}
|
||||
}
|
||||
gunzip_crc_table[i] = table_entry;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Free the malloc'ed tables built by huft_build(), which makes a linked
|
||||
* list of the tables it made, with the links in a dummy first entry of
|
||||
* each table.
|
||||
* t: table to free
|
||||
*/
|
||||
static int huft_free(huft_t * t)
|
||||
{
|
||||
huft_t *p;
|
||||
huft_t *q;
|
||||
|
||||
/* Go through linked list, freeing from the malloced (t[-1]) address. */
|
||||
p = t;
|
||||
while (p != (huft_t *) NULL) {
|
||||
q = (--p)->v.t;
|
||||
free((char *) p);
|
||||
p = q;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Given a list of code lengths and a maximum table size, make a set of
|
||||
* tables to decode that set of codes. Return zero on success, one if
|
||||
* the given code set is incomplete (the tables are still built in this
|
||||
* case), two if the input is invalid (all zero length codes or an
|
||||
* oversubscribed set of lengths), and three if not enough memory.
|
||||
*
|
||||
* b: code lengths in bits (all assumed <= BMAX)
|
||||
* n: number of codes (assumed <= N_MAX)
|
||||
* s: number of simple-valued codes (0..s-1)
|
||||
* d: list of base values for non-simple codes
|
||||
* e: list of extra bits for non-simple codes
|
||||
* t: result: starting table
|
||||
* m: maximum lookup bits, returns actual
|
||||
*/
|
||||
static int huft_build(unsigned int *b, const unsigned int n,
|
||||
const unsigned int s, const unsigned short *d,
|
||||
const unsigned char *e, huft_t ** t, int *m)
|
||||
{
|
||||
unsigned a; /* counter for codes of length k */
|
||||
unsigned c[BMAX + 1]; /* bit length count table */
|
||||
unsigned f; /* i repeats in table every f entries */
|
||||
int g; /* maximum code length */
|
||||
int h; /* table level */
|
||||
register unsigned i; /* counter, current code */
|
||||
register unsigned j; /* counter */
|
||||
register int k; /* number of bits in current code */
|
||||
int l; /* bits per table (returned in m) */
|
||||
register unsigned *p; /* pointer into c[], b[], or v[] */
|
||||
register huft_t *q; /* points to current table */
|
||||
huft_t r; /* table entry for structure assignment */
|
||||
huft_t *u[BMAX]; /* table stack */
|
||||
unsigned v[N_MAX]; /* values in order of bit length */
|
||||
register int w; /* bits before this table == (l * h) */
|
||||
unsigned x[BMAX + 1]; /* bit offsets, then code stack */
|
||||
unsigned *xp; /* pointer into x */
|
||||
int y; /* number of dummy codes added */
|
||||
unsigned z; /* number of entries in current table */
|
||||
|
||||
/* Generate counts for each bit length */
|
||||
memset((void *) (c), 0, sizeof(c));
|
||||
p = b;
|
||||
i = n;
|
||||
do {
|
||||
c[*p]++; /* assume all entries <= BMAX */
|
||||
p++; /* Can't combine with above line (Solaris bug) */
|
||||
} while (--i);
|
||||
if (c[0] == n) { /* null input--all zero length codes */
|
||||
*t = (huft_t *) NULL;
|
||||
*m = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Find minimum and maximum length, bound *m by those */
|
||||
l = *m;
|
||||
for (j = 1; j <= BMAX; j++) {
|
||||
if (c[j]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
k = j; /* minimum code length */
|
||||
if ((unsigned) l < j) {
|
||||
l = j;
|
||||
}
|
||||
for (i = BMAX; i; i--) {
|
||||
if (c[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
g = i; /* maximum code length */
|
||||
if ((unsigned) l > i) {
|
||||
l = i;
|
||||
}
|
||||
*m = l;
|
||||
|
||||
/* Adjust last length count to fill out codes, if needed */
|
||||
for (y = 1 << j; j < i; j++, y <<= 1) {
|
||||
if ((y -= c[j]) < 0) {
|
||||
return 2; /* bad input: more codes than bits */
|
||||
}
|
||||
}
|
||||
if ((y -= c[i]) < 0) {
|
||||
return 2;
|
||||
}
|
||||
c[i] += y;
|
||||
|
||||
/* Generate starting offsets into the value table for each length */
|
||||
x[1] = j = 0;
|
||||
p = c + 1;
|
||||
xp = x + 2;
|
||||
while (--i) { /* note that i == g from above */
|
||||
*xp++ = (j += *p++);
|
||||
}
|
||||
|
||||
/* Make a table of values in order of bit lengths */
|
||||
p = b;
|
||||
i = 0;
|
||||
do {
|
||||
if ((j = *p++) != 0) {
|
||||
v[x[j]++] = i;
|
||||
}
|
||||
} while (++i < n);
|
||||
|
||||
/* Generate the Huffman codes and for each, make the table entries */
|
||||
x[0] = i = 0; /* first Huffman code is zero */
|
||||
p = v; /* grab values in bit order */
|
||||
h = -1; /* no tables yet--level -1 */
|
||||
w = -l; /* bits decoded == (l * h) */
|
||||
u[0] = (huft_t *) NULL; /* just to keep compilers happy */
|
||||
q = (huft_t *) NULL; /* ditto */
|
||||
z = 0; /* ditto */
|
||||
|
||||
/* go through the bit lengths (k already is bits in shortest code) */
|
||||
for (; k <= g; k++) {
|
||||
a = c[k];
|
||||
while (a--) {
|
||||
/* here i is the Huffman code of length k bits for value *p */
|
||||
/* make tables up to required level */
|
||||
while (k > w + l) {
|
||||
h++;
|
||||
w += l; /* previous table always l bits */
|
||||
|
||||
/* compute minimum size table less than or equal to l bits */
|
||||
z = (z = g - w) > (unsigned) l ? l : z; /* upper limit on table size */
|
||||
if ((f = 1 << (j = k - w)) > a + 1) { /* try a k-w bit table *//* too few codes for k-w bit table */
|
||||
f -= a + 1; /* deduct codes from patterns left */
|
||||
xp = c + k;
|
||||
while (++j < z) { /* try smaller tables up to z bits */
|
||||
if ((f <<= 1) <= *++xp) {
|
||||
break; /* enough codes to use up j bits */
|
||||
}
|
||||
f -= *xp; /* else deduct codes from patterns */
|
||||
}
|
||||
}
|
||||
z = 1 << j; /* table entries for j-bit table */
|
||||
|
||||
/* allocate and link in new table */
|
||||
q = (huft_t *) xmalloc((z + 1) * sizeof(huft_t));
|
||||
|
||||
*t = q + 1; /* link to list for huft_free() */
|
||||
*(t = &(q->v.t)) = NULL;
|
||||
u[h] = ++q; /* table starts after link */
|
||||
|
||||
/* connect to last table, if there is one */
|
||||
if (h) {
|
||||
x[h] = i; /* save pattern for backing up */
|
||||
r.b = (unsigned char) l; /* bits to dump before this table */
|
||||
r.e = (unsigned char) (16 + j); /* bits in this table */
|
||||
r.v.t = q; /* pointer to this table */
|
||||
j = i >> (w - l); /* (get around Turbo C bug) */
|
||||
u[h - 1][j] = r; /* connect to last table */
|
||||
}
|
||||
}
|
||||
|
||||
/* set up table entry in r */
|
||||
r.b = (unsigned char) (k - w);
|
||||
if (p >= v + n) {
|
||||
r.e = 99; /* out of values--invalid code */
|
||||
} else if (*p < s) {
|
||||
r.e = (unsigned char) (*p < 256 ? 16 : 15); /* 256 is end-of-block code */
|
||||
r.v.n = (unsigned short) (*p); /* simple code is just the value */
|
||||
p++; /* one compiler does not like *p++ */
|
||||
} else {
|
||||
r.e = (unsigned char) e[*p - s]; /* non-simple--look up in lists */
|
||||
r.v.n = d[*p++ - s];
|
||||
}
|
||||
|
||||
/* fill code-like entries with r */
|
||||
f = 1 << (k - w);
|
||||
for (j = i >> w; j < z; j += f) {
|
||||
q[j] = r;
|
||||
}
|
||||
|
||||
/* backwards increment the k-bit code i */
|
||||
for (j = 1 << (k - 1); i & j; j >>= 1) {
|
||||
i ^= j;
|
||||
}
|
||||
i ^= j;
|
||||
|
||||
/* backup over finished tables */
|
||||
while ((i & ((1 << w) - 1)) != x[h]) {
|
||||
h--; /* don't need to update q */
|
||||
w -= l;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Return true (1) if we were given an incomplete table */
|
||||
return y != 0 && g != 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* inflate (decompress) the codes in a deflated (compressed) block.
|
||||
* Return an error code or zero if it all goes ok.
|
||||
*
|
||||
* tl, td: literal/length and distance decoder tables
|
||||
* bl, bd: number of bits decoded by tl[] and td[]
|
||||
*/
|
||||
static int inflate_codes(huft_t * my_tl, huft_t * my_td, const unsigned int my_bl, const unsigned int my_bd, int setup)
|
||||
{
|
||||
static unsigned int e; /* table entry flag/number of extra bits */
|
||||
static unsigned int n, d; /* length and index for copy */
|
||||
static unsigned int w; /* current gunzip_window position */
|
||||
static huft_t *t; /* pointer to table entry */
|
||||
static unsigned int ml, md; /* masks for bl and bd bits */
|
||||
static unsigned int b; /* bit buffer */
|
||||
static unsigned int k; /* number of bits in bit buffer */
|
||||
static huft_t *tl, *td;
|
||||
static unsigned int bl, bd;
|
||||
static int resumeCopy = 0;
|
||||
|
||||
if (setup) { // 1st time we are called, copy in variables
|
||||
tl = my_tl;
|
||||
td = my_td;
|
||||
bl = my_bl;
|
||||
bd = my_bd;
|
||||
/* make local copies of globals */
|
||||
b = gunzip_bb; /* initialize bit buffer */
|
||||
k = gunzip_bk;
|
||||
w = gunzip_outbuf_count; /* initialize gunzip_window position */
|
||||
|
||||
/* inflate the coded data */
|
||||
ml = mask_bits[bl]; /* precompute masks for speed */
|
||||
md = mask_bits[bd];
|
||||
return 0; // Don't actually do anything the first time
|
||||
}
|
||||
|
||||
if (resumeCopy) goto do_copy;
|
||||
|
||||
while (1) { /* do until end of block */
|
||||
b = fill_bitbuffer(b, &k, bl);
|
||||
if ((e = (t = tl + ((unsigned) b & ml))->e) > 16)
|
||||
do {
|
||||
if (e == 99) {
|
||||
bb_error_msg_and_die("inflate_codes error 1");;
|
||||
}
|
||||
b >>= t->b;
|
||||
k -= t->b;
|
||||
e -= 16;
|
||||
b = fill_bitbuffer(b, &k, e);
|
||||
} while ((e =
|
||||
(t = t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16);
|
||||
b >>= t->b;
|
||||
k -= t->b;
|
||||
if (e == 16) { /* then it's a literal */
|
||||
gunzip_window[w++] = (unsigned char) t->v.n;
|
||||
if (w == gunzip_wsize) {
|
||||
gunzip_outbuf_count = (w);
|
||||
//flush_gunzip_window();
|
||||
w = 0;
|
||||
return 1; // We have a block to read
|
||||
}
|
||||
} else { /* it's an EOB or a length */
|
||||
|
||||
/* exit if end of block */
|
||||
if (e == 15) {
|
||||
break;
|
||||
}
|
||||
|
||||
/* get length of block to copy */
|
||||
b = fill_bitbuffer(b, &k, e);
|
||||
n = t->v.n + ((unsigned) b & mask_bits[e]);
|
||||
b >>= e;
|
||||
k -= e;
|
||||
|
||||
/* decode distance of block to copy */
|
||||
b = fill_bitbuffer(b, &k, bd);
|
||||
if ((e = (t = td + ((unsigned) b & md))->e) > 16)
|
||||
do {
|
||||
if (e == 99)
|
||||
bb_error_msg_and_die("inflate_codes error 2");;
|
||||
b >>= t->b;
|
||||
k -= t->b;
|
||||
e -= 16;
|
||||
b = fill_bitbuffer(b, &k, e);
|
||||
} while ((e =
|
||||
(t =
|
||||
t->v.t + ((unsigned) b & mask_bits[e]))->e) > 16);
|
||||
b >>= t->b;
|
||||
k -= t->b;
|
||||
b = fill_bitbuffer(b, &k, e);
|
||||
d = w - t->v.n - ((unsigned) b & mask_bits[e]);
|
||||
b >>= e;
|
||||
k -= e;
|
||||
|
||||
/* do the copy */
|
||||
do_copy: do {
|
||||
n -= (e =
|
||||
(e =
|
||||
gunzip_wsize - ((d &= gunzip_wsize - 1) > w ? d : w)) > n ? n : e);
|
||||
/* copy to new buffer to prevent possible overwrite */
|
||||
if (w - d >= e) { /* (this test assumes unsigned comparison) */
|
||||
memcpy(gunzip_window + w, gunzip_window + d, e);
|
||||
w += e;
|
||||
d += e;
|
||||
} else {
|
||||
/* do it slow to avoid memcpy() overlap */
|
||||
/* !NOMEMCPY */
|
||||
do {
|
||||
gunzip_window[w++] = gunzip_window[d++];
|
||||
} while (--e);
|
||||
}
|
||||
if (w == gunzip_wsize) {
|
||||
gunzip_outbuf_count = (w);
|
||||
if (n) resumeCopy = 1;
|
||||
else resumeCopy = 0;
|
||||
//flush_gunzip_window();
|
||||
w = 0;
|
||||
return 1;
|
||||
}
|
||||
} while (n);
|
||||
resumeCopy = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* restore the globals from the locals */
|
||||
gunzip_outbuf_count = w; /* restore global gunzip_window pointer */
|
||||
gunzip_bb = b; /* restore global bit buffer */
|
||||
gunzip_bk = k;
|
||||
|
||||
/* normally just after call to inflate_codes, but save code by putting it here */
|
||||
/* free the decoding tables, return */
|
||||
huft_free(tl);
|
||||
huft_free(td);
|
||||
|
||||
/* done */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int inflate_stored(int my_n, int my_b_stored, int my_k_stored, int setup)
|
||||
{
|
||||
static int n, b_stored, k_stored, w;
|
||||
if (setup) {
|
||||
n = my_n;
|
||||
b_stored = my_b_stored;
|
||||
k_stored = my_k_stored;
|
||||
w = gunzip_outbuf_count; /* initialize gunzip_window position */
|
||||
return 0; // Don't do anything first time
|
||||
}
|
||||
|
||||
/* read and output the compressed data */
|
||||
while (n--) {
|
||||
b_stored = fill_bitbuffer(b_stored, &k_stored, 8);
|
||||
gunzip_window[w++] = (unsigned char) b_stored;
|
||||
if (w == (unsigned int) gunzip_wsize) {
|
||||
gunzip_outbuf_count = (w);
|
||||
//flush_gunzip_window();
|
||||
w = 0;
|
||||
b_stored >>= 8;
|
||||
k_stored -= 8;
|
||||
return 1; // We have a block
|
||||
}
|
||||
b_stored >>= 8;
|
||||
k_stored -= 8;
|
||||
}
|
||||
|
||||
/* restore the globals from the locals */
|
||||
gunzip_outbuf_count = w; /* restore global gunzip_window pointer */
|
||||
gunzip_bb = b_stored; /* restore global bit buffer */
|
||||
gunzip_bk = k_stored;
|
||||
return 0; // Finished
|
||||
}
|
||||
|
||||
/*
|
||||
* decompress an inflated block
|
||||
* e: last block flag
|
||||
*
|
||||
* GLOBAL VARIABLES: bb, kk,
|
||||
*/
|
||||
// Return values: -1 = inflate_stored, -2 = inflate_codes
|
||||
static int inflate_block(int *e)
|
||||
{
|
||||
unsigned t; /* block type */
|
||||
register unsigned int b; /* bit buffer */
|
||||
unsigned int k; /* number of bits in bit buffer */
|
||||
|
||||
/* make local bit buffer */
|
||||
|
||||
b = gunzip_bb;
|
||||
k = gunzip_bk;
|
||||
|
||||
/* read in last block bit */
|
||||
b = fill_bitbuffer(b, &k, 1);
|
||||
*e = (int) b & 1;
|
||||
b >>= 1;
|
||||
k -= 1;
|
||||
|
||||
/* read in block type */
|
||||
b = fill_bitbuffer(b, &k, 2);
|
||||
t = (unsigned) b & 3;
|
||||
b >>= 2;
|
||||
k -= 2;
|
||||
|
||||
/* restore the global bit buffer */
|
||||
gunzip_bb = b;
|
||||
gunzip_bk = k;
|
||||
|
||||
/* inflate that block type */
|
||||
switch (t) {
|
||||
case 0: /* Inflate stored */
|
||||
{
|
||||
unsigned int n; /* number of bytes in block */
|
||||
unsigned int b_stored; /* bit buffer */
|
||||
unsigned int k_stored; /* number of bits in bit buffer */
|
||||
|
||||
/* make local copies of globals */
|
||||
b_stored = gunzip_bb; /* initialize bit buffer */
|
||||
k_stored = gunzip_bk;
|
||||
|
||||
/* go to byte boundary */
|
||||
n = k_stored & 7;
|
||||
b_stored >>= n;
|
||||
k_stored -= n;
|
||||
|
||||
/* get the length and its complement */
|
||||
b_stored = fill_bitbuffer(b_stored, &k_stored, 16);
|
||||
n = ((unsigned) b_stored & 0xffff);
|
||||
b_stored >>= 16;
|
||||
k_stored -= 16;
|
||||
|
||||
b_stored = fill_bitbuffer(b_stored, &k_stored, 16);
|
||||
if (n != (unsigned) ((~b_stored) & 0xffff)) {
|
||||
return 1; /* error in compressed data */
|
||||
}
|
||||
b_stored >>= 16;
|
||||
k_stored -= 16;
|
||||
|
||||
inflate_stored(n, b_stored, k_stored, 1); // Setup inflate_stored
|
||||
return -1;
|
||||
}
|
||||
case 1: /* Inflate fixed
|
||||
* decompress an inflated type 1 (fixed Huffman codes) block. We should
|
||||
* either replace this with a custom decoder, or at least precompute the
|
||||
* Huffman tables.
|
||||
*/
|
||||
{
|
||||
int i; /* temporary variable */
|
||||
huft_t *tl; /* literal/length code table */
|
||||
huft_t *td; /* distance code table */
|
||||
unsigned int bl; /* lookup bits for tl */
|
||||
unsigned int bd; /* lookup bits for td */
|
||||
unsigned int l[288]; /* length list for huft_build */
|
||||
|
||||
/* set up literal table */
|
||||
for (i = 0; i < 144; i++) {
|
||||
l[i] = 8;
|
||||
}
|
||||
for (; i < 256; i++) {
|
||||
l[i] = 9;
|
||||
}
|
||||
for (; i < 280; i++) {
|
||||
l[i] = 7;
|
||||
}
|
||||
for (; i < 288; i++) { /* make a complete, but wrong code set */
|
||||
l[i] = 8;
|
||||
}
|
||||
bl = 7;
|
||||
if ((i = huft_build(l, 288, 257, cplens, cplext, &tl, &bl)) != 0) {
|
||||
return i;
|
||||
}
|
||||
|
||||
/* set up distance table */
|
||||
for (i = 0; i < 30; i++) { /* make an incomplete code set */
|
||||
l[i] = 5;
|
||||
}
|
||||
bd = 5;
|
||||
if ((i = huft_build(l, 30, 0, cpdist, cpdext, &td, &bd)) > 1) {
|
||||
huft_free(tl);
|
||||
return i;
|
||||
}
|
||||
|
||||
/* decompress until an end-of-block code */
|
||||
inflate_codes(tl, td, bl, bd, 1); // Setup inflate_codes
|
||||
|
||||
/* huft_free code moved into inflate_codes */
|
||||
|
||||
return -2;
|
||||
}
|
||||
case 2: /* Inflate dynamic */
|
||||
{
|
||||
const int dbits = 6; /* bits in base distance lookup table */
|
||||
const int lbits = 9; /* bits in base literal/length lookup table */
|
||||
|
||||
huft_t *tl; /* literal/length code table */
|
||||
huft_t *td; /* distance code table */
|
||||
unsigned int i; /* temporary variables */
|
||||
unsigned int j;
|
||||
unsigned int l; /* last length */
|
||||
unsigned int m; /* mask for bit lengths table */
|
||||
unsigned int n; /* number of lengths to get */
|
||||
unsigned int bl; /* lookup bits for tl */
|
||||
unsigned int bd; /* lookup bits for td */
|
||||
unsigned int nb; /* number of bit length codes */
|
||||
unsigned int nl; /* number of literal/length codes */
|
||||
unsigned int nd; /* number of distance codes */
|
||||
|
||||
unsigned int ll[286 + 30]; /* literal/length and distance code lengths */
|
||||
unsigned int b_dynamic; /* bit buffer */
|
||||
unsigned int k_dynamic; /* number of bits in bit buffer */
|
||||
|
||||
/* make local bit buffer */
|
||||
b_dynamic = gunzip_bb;
|
||||
k_dynamic = gunzip_bk;
|
||||
|
||||
/* read in table lengths */
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 5);
|
||||
nl = 257 + ((unsigned int) b_dynamic & 0x1f); /* number of literal/length codes */
|
||||
|
||||
b_dynamic >>= 5;
|
||||
k_dynamic -= 5;
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 5);
|
||||
nd = 1 + ((unsigned int) b_dynamic & 0x1f); /* number of distance codes */
|
||||
|
||||
b_dynamic >>= 5;
|
||||
k_dynamic -= 5;
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 4);
|
||||
nb = 4 + ((unsigned int) b_dynamic & 0xf); /* number of bit length codes */
|
||||
|
||||
b_dynamic >>= 4;
|
||||
k_dynamic -= 4;
|
||||
if (nl > 286 || nd > 30) {
|
||||
return 1; /* bad lengths */
|
||||
}
|
||||
|
||||
/* read in bit-length-code lengths */
|
||||
for (j = 0; j < nb; j++) {
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 3);
|
||||
ll[border[j]] = (unsigned int) b_dynamic & 7;
|
||||
b_dynamic >>= 3;
|
||||
k_dynamic -= 3;
|
||||
}
|
||||
for (; j < 19; j++) {
|
||||
ll[border[j]] = 0;
|
||||
}
|
||||
|
||||
/* build decoding table for trees--single level, 7 bit lookup */
|
||||
bl = 7;
|
||||
i = huft_build(ll, 19, 19, NULL, NULL, &tl, &bl);
|
||||
if (i != 0) {
|
||||
if (i == 1) {
|
||||
huft_free(tl);
|
||||
}
|
||||
return i; /* incomplete code set */
|
||||
}
|
||||
|
||||
/* read in literal and distance code lengths */
|
||||
n = nl + nd;
|
||||
m = mask_bits[bl];
|
||||
i = l = 0;
|
||||
while ((unsigned int) i < n) {
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, (unsigned int)bl);
|
||||
j = (td = tl + ((unsigned int) b_dynamic & m))->b;
|
||||
b_dynamic >>= j;
|
||||
k_dynamic -= j;
|
||||
j = td->v.n;
|
||||
if (j < 16) { /* length of code in bits (0..15) */
|
||||
ll[i++] = l = j; /* save last length in l */
|
||||
} else if (j == 16) { /* repeat last length 3 to 6 times */
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 2);
|
||||
j = 3 + ((unsigned int) b_dynamic & 3);
|
||||
b_dynamic >>= 2;
|
||||
k_dynamic -= 2;
|
||||
if ((unsigned int) i + j > n) {
|
||||
return 1;
|
||||
}
|
||||
while (j--) {
|
||||
ll[i++] = l;
|
||||
}
|
||||
} else if (j == 17) { /* 3 to 10 zero length codes */
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 3);
|
||||
j = 3 + ((unsigned int) b_dynamic & 7);
|
||||
b_dynamic >>= 3;
|
||||
k_dynamic -= 3;
|
||||
if ((unsigned int) i + j > n) {
|
||||
return 1;
|
||||
}
|
||||
while (j--) {
|
||||
ll[i++] = 0;
|
||||
}
|
||||
l = 0;
|
||||
} else { /* j == 18: 11 to 138 zero length codes */
|
||||
b_dynamic = fill_bitbuffer(b_dynamic, &k_dynamic, 7);
|
||||
j = 11 + ((unsigned int) b_dynamic & 0x7f);
|
||||
b_dynamic >>= 7;
|
||||
k_dynamic -= 7;
|
||||
if ((unsigned int) i + j > n) {
|
||||
return 1;
|
||||
}
|
||||
while (j--) {
|
||||
ll[i++] = 0;
|
||||
}
|
||||
l = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* free decoding table for trees */
|
||||
huft_free(tl);
|
||||
|
||||
/* restore the global bit buffer */
|
||||
gunzip_bb = b_dynamic;
|
||||
gunzip_bk = k_dynamic;
|
||||
|
||||
/* build the decoding tables for literal/length and distance codes */
|
||||
bl = lbits;
|
||||
|
||||
if ((i = huft_build(ll, nl, 257, cplens, cplext, &tl, &bl)) != 0) {
|
||||
if (i == 1) {
|
||||
bb_error_msg_and_die("Incomplete literal tree");
|
||||
huft_free(tl);
|
||||
}
|
||||
return i; /* incomplete code set */
|
||||
}
|
||||
|
||||
bd = dbits;
|
||||
if ((i = huft_build(ll + nl, nd, 0, cpdist, cpdext, &td, &bd)) != 0) {
|
||||
if (i == 1) {
|
||||
bb_error_msg_and_die("incomplete distance tree");
|
||||
huft_free(td);
|
||||
}
|
||||
huft_free(tl);
|
||||
return i; /* incomplete code set */
|
||||
}
|
||||
|
||||
/* decompress until an end-of-block code */
|
||||
inflate_codes(tl, td, bl, bd, 1); // Setup inflate_codes
|
||||
|
||||
/* huft_free code moved into inflate_codes */
|
||||
|
||||
return -2;
|
||||
}
|
||||
default:
|
||||
/* bad block type */
|
||||
bb_error_msg_and_die("bad block type %d\n", t);
|
||||
}
|
||||
}
|
||||
|
||||
static void calculate_gunzip_crc(void)
|
||||
{
|
||||
int n;
|
||||
for (n = 0; n < gunzip_outbuf_count; n++) {
|
||||
gunzip_crc = gunzip_crc_table[((int) gunzip_crc ^ (gunzip_window[n])) & 0xff] ^ (gunzip_crc >> 8);
|
||||
}
|
||||
gunzip_bytes_out += gunzip_outbuf_count;
|
||||
}
|
||||
|
||||
static int inflate_get_next_window(void)
|
||||
{
|
||||
static int method = -1; // Method == -1 for stored, -2 for codes
|
||||
static int e = 0;
|
||||
static int needAnotherBlock = 1;
|
||||
|
||||
gunzip_outbuf_count = 0;
|
||||
|
||||
while(1) {
|
||||
int ret;
|
||||
|
||||
if (needAnotherBlock) {
|
||||
if(e) {
|
||||
calculate_gunzip_crc();
|
||||
e = 0;
|
||||
needAnotherBlock = 1;
|
||||
return 0;
|
||||
} // Last block
|
||||
method = inflate_block(&e);
|
||||
needAnotherBlock = 0;
|
||||
}
|
||||
|
||||
switch (method) {
|
||||
case -1: ret = inflate_stored(0,0,0,0);
|
||||
break;
|
||||
case -2: ret = inflate_codes(0,0,0,0,0);
|
||||
break;
|
||||
default: bb_error_msg_and_die("inflate error %d", method);
|
||||
}
|
||||
|
||||
if (ret == 1) {
|
||||
calculate_gunzip_crc();
|
||||
return 1; // More data left
|
||||
} else needAnotherBlock = 1; // End of that block
|
||||
}
|
||||
/* Doesnt get here */
|
||||
}
|
||||
|
||||
/* Initialise bytebuffer, be careful not to overfill the buffer */
|
||||
extern void inflate_init(unsigned int bufsize)
|
||||
{
|
||||
/* Set the bytebuffer size, default is same as gunzip_wsize */
|
||||
bytebuffer_max = bufsize + 8;
|
||||
bytebuffer_offset = 4;
|
||||
bytebuffer_size = 0;
|
||||
}
|
||||
|
||||
extern int inflate_unzip(int in, int out)
|
||||
{
|
||||
ssize_t nwrote;
|
||||
typedef void (*sig_type) (int);
|
||||
|
||||
/* Allocate all global buffers (for DYN_ALLOC option) */
|
||||
gunzip_window = xmalloc(gunzip_wsize);
|
||||
gunzip_outbuf_count = 0;
|
||||
gunzip_bytes_out = 0;
|
||||
gunzip_src_fd = in;
|
||||
|
||||
/* initialize gunzip_window, bit buffer */
|
||||
gunzip_bk = 0;
|
||||
gunzip_bb = 0;
|
||||
|
||||
/* Create the crc table */
|
||||
make_gunzip_crc_table();
|
||||
|
||||
/* Allocate space for buffer */
|
||||
bytebuffer = xmalloc(bytebuffer_max);
|
||||
|
||||
while(1) {
|
||||
int ret = inflate_get_next_window();
|
||||
nwrote = bb_full_write(out, gunzip_window, gunzip_outbuf_count);
|
||||
if (nwrote == -1) {
|
||||
bb_perror_msg("write");
|
||||
return -1;
|
||||
}
|
||||
if (ret == 0) break;
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
free(gunzip_window);
|
||||
free(gunzip_crc_table);
|
||||
|
||||
/* Store unused bytes in a global buffer so calling applets can access it */
|
||||
if (gunzip_bk >= 8) {
|
||||
/* Undo too much lookahead. The next read will be byte aligned
|
||||
* so we can discard unused bits in the last meaningful byte. */
|
||||
bytebuffer_offset--;
|
||||
bytebuffer[bytebuffer_offset] = gunzip_bb & 0xff;
|
||||
gunzip_bb >>= 8;
|
||||
gunzip_bk -= 8;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern int inflate_gunzip(int in, int out)
|
||||
{
|
||||
unsigned int stored_crc = 0;
|
||||
unsigned char count;
|
||||
|
||||
inflate_unzip(in, out);
|
||||
|
||||
/* top up the input buffer with the rest of the trailer */
|
||||
count = bytebuffer_size - bytebuffer_offset;
|
||||
if (count < 8) {
|
||||
bb_xread_all(in, &bytebuffer[bytebuffer_size], 8 - count);
|
||||
bytebuffer_size += 8 - count;
|
||||
}
|
||||
for (count = 0; count != 4; count++) {
|
||||
stored_crc |= (bytebuffer[bytebuffer_offset] << (count * 8));
|
||||
bytebuffer_offset++;
|
||||
}
|
||||
|
||||
/* Validate decompression - crc */
|
||||
if (stored_crc != (gunzip_crc ^ 0xffffffffL)) {
|
||||
bb_error_msg("crc error");
|
||||
}
|
||||
|
||||
/* Validate decompression - size */
|
||||
if (gunzip_bytes_out !=
|
||||
(bytebuffer[bytebuffer_offset] | (bytebuffer[bytebuffer_offset+1] << 8) |
|
||||
(bytebuffer[bytebuffer_offset+2] << 16) | (bytebuffer[bytebuffer_offset+3] << 24))) {
|
||||
bb_error_msg("Incorrect length");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2002 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.
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "unarchive.h"
|
||||
|
||||
/* Accept any non-null name, its not really a filter at all */
|
||||
extern char filter_accept_all(archive_handle_t *archive_handle)
|
||||
{
|
||||
if (archive_handle->file_header->name) {
|
||||
return(EXIT_SUCCESS);
|
||||
} else {
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2002 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.
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "unarchive.h"
|
||||
|
||||
/*
|
||||
* Accept names that are in the accept list, ignoring reject list.
|
||||
*/
|
||||
extern char filter_accept_list(archive_handle_t *archive_handle)
|
||||
{
|
||||
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
|
||||
return(EXIT_SUCCESS);
|
||||
} else {
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2002 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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
/*
|
||||
* Reassign the subarchive metadata parser based on the filename extension
|
||||
* e.g. if its a .tar.gz modify archive_handle->sub_archive to process a .tar.gz
|
||||
* or if its a .tar.bz2 make archive_handle->sub_archive handle that
|
||||
*/
|
||||
extern char filter_accept_list_reassign(archive_handle_t *archive_handle)
|
||||
{
|
||||
/* Check the file entry is in the accept list */
|
||||
if (find_list_entry(archive_handle->accept, archive_handle->file_header->name)) {
|
||||
const char *name_ptr;
|
||||
|
||||
/* Extract the last 2 extensions */
|
||||
name_ptr = strrchr(archive_handle->file_header->name, '.');
|
||||
|
||||
/* Modify the subarchive handler based on the extension */
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_GZ
|
||||
if (strcmp(name_ptr, ".gz") == 0) {
|
||||
archive_handle->action_data_subarchive = get_header_tar_gz;
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_DEB_TAR_BZ2
|
||||
if (strcmp(name_ptr, ".bz2") == 0) {
|
||||
archive_handle->action_data_subarchive = get_header_tar_bz2;
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2002 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.
|
||||
*/
|
||||
|
||||
#include <fnmatch.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "unarchive.h"
|
||||
|
||||
/*
|
||||
* Accept names that are in the accept list and not in the reject list
|
||||
*/
|
||||
extern char filter_accept_reject_list(archive_handle_t *archive_handle)
|
||||
{
|
||||
const char *key = archive_handle->file_header->name;
|
||||
const llist_t *accept_entry = find_list_entry(archive_handle->accept, key);
|
||||
const llist_t *reject_entry = find_list_entry(archive_handle->reject, key);
|
||||
|
||||
/* If the key is in a reject list fail */
|
||||
if (reject_entry) {
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Fail if an accept list was specified and the key wasnt in there */
|
||||
if (archive_handle->accept && (accept_entry == NULL)) {
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Accepted */
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* 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 <fnmatch.h>
|
||||
#include <stdlib.h>
|
||||
#include "unarchive.h"
|
||||
|
||||
extern const llist_t *find_list_entry(const llist_t *list, const char *filename)
|
||||
{
|
||||
while (list) {
|
||||
if (fnmatch(list->data, filename, 0) == 0) {
|
||||
return(list);
|
||||
}
|
||||
list = list->link;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
extern char get_header_ar(archive_handle_t *archive_handle)
|
||||
{
|
||||
file_header_t *typed = archive_handle->file_header;
|
||||
union {
|
||||
char raw[60];
|
||||
struct {
|
||||
char name[16];
|
||||
char date[12];
|
||||
char uid[6];
|
||||
char gid[6];
|
||||
char mode[8];
|
||||
char size[10];
|
||||
char magic[2];
|
||||
} formated;
|
||||
} ar;
|
||||
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
|
||||
static char *ar_long_names;
|
||||
static unsigned int ar_long_name_size;
|
||||
#endif
|
||||
|
||||
/* dont use bb_xread as we want to handle the error ourself */
|
||||
if (read(archive_handle->src_fd, ar.raw, 60) != 60) {
|
||||
/* End Of File */
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* ar header starts on an even byte (2 byte aligned)
|
||||
* '\n' is used for padding
|
||||
*/
|
||||
if (ar.raw[0] == '\n') {
|
||||
/* fix up the header, we started reading 1 byte too early */
|
||||
memmove(ar.raw, &ar.raw[1], 59);
|
||||
ar.raw[59] = bb_xread_char(archive_handle->src_fd);
|
||||
archive_handle->offset++;
|
||||
}
|
||||
archive_handle->offset += 60;
|
||||
|
||||
/* align the headers based on the header magic */
|
||||
if ((ar.formated.magic[0] != '`') || (ar.formated.magic[1] != '\n')) {
|
||||
bb_error_msg_and_die("Invalid ar header");
|
||||
}
|
||||
|
||||
typed->mode = strtol(ar.formated.mode, NULL, 8);
|
||||
typed->mtime = atoi(ar.formated.date);
|
||||
typed->uid = atoi(ar.formated.uid);
|
||||
typed->gid = atoi(ar.formated.gid);
|
||||
typed->size = atoi(ar.formated.size);
|
||||
|
||||
/* long filenames have '/' as the first character */
|
||||
if (ar.formated.name[0] == '/') {
|
||||
#ifdef CONFIG_FEATURE_AR_LONG_FILENAMES
|
||||
if (ar.formated.name[1] == '/') {
|
||||
/* If the second char is a '/' then this entries data section
|
||||
* stores long filename for multiple entries, they are stored
|
||||
* in static variable long_names for use in future entries */
|
||||
ar_long_name_size = typed->size;
|
||||
ar_long_names = xmalloc(ar_long_name_size);
|
||||
bb_xread_all(archive_handle->src_fd, ar_long_names, ar_long_name_size);
|
||||
archive_handle->offset += ar_long_name_size;
|
||||
/* This ar entries data section only contained filenames for other records
|
||||
* they are stored in the static ar_long_names for future reference */
|
||||
return (get_header_ar(archive_handle)); /* Return next header */
|
||||
} else if (ar.formated.name[1] == ' ') {
|
||||
/* This is the index of symbols in the file for compilers */
|
||||
data_skip(archive_handle);
|
||||
archive_handle->offset += typed->size;
|
||||
return (get_header_ar(archive_handle)); /* Return next header */
|
||||
} else {
|
||||
/* The number after the '/' indicates the offset in the ar data section
|
||||
(saved in variable long_name) that conatains the real filename */
|
||||
const unsigned int long_offset = atoi(&ar.formated.name[1]);
|
||||
if (long_offset >= ar_long_name_size) {
|
||||
bb_error_msg_and_die("Cant resolve long filename");
|
||||
}
|
||||
typed->name = bb_xstrdup(ar_long_names + long_offset);
|
||||
}
|
||||
#else
|
||||
bb_error_msg_and_die("long filenames not supported");
|
||||
#endif
|
||||
} else {
|
||||
/* short filenames */
|
||||
typed->name = bb_xstrndup(ar.formated.name, 16);
|
||||
}
|
||||
|
||||
typed->name[strcspn(typed->name, " /")] = '\0';
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_header(typed);
|
||||
if (archive_handle->sub_archive) {
|
||||
while (archive_handle->action_data_subarchive(archive_handle->sub_archive) == EXIT_SUCCESS);
|
||||
} else {
|
||||
archive_handle->action_data(archive_handle);
|
||||
}
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
}
|
||||
|
||||
archive_handle->offset += typed->size;
|
||||
/* Set the file pointer to the correct spot, we may have been reading a compressed file */
|
||||
lseek(archive_handle->src_fd, archive_handle->offset, SEEK_SET);
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1,161 +0,0 @@
|
||||
/*
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/sysmacros.h> /* major() and minor() */
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
typedef struct hardlinks_s {
|
||||
file_header_t *entry;
|
||||
int inode;
|
||||
struct hardlinks_s *next;
|
||||
} hardlinks_t;
|
||||
|
||||
extern char get_header_cpio(archive_handle_t *archive_handle)
|
||||
{
|
||||
static hardlinks_t *saved_hardlinks = NULL;
|
||||
static unsigned short pending_hardlinks = 0;
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
char cpio_header[110];
|
||||
int namesize;
|
||||
char dummy[16];
|
||||
int major, minor, nlink, inode;
|
||||
|
||||
if (pending_hardlinks) { /* Deal with any pending hardlinks */
|
||||
hardlinks_t *tmp;
|
||||
hardlinks_t *oldtmp;
|
||||
|
||||
tmp = saved_hardlinks;
|
||||
oldtmp = NULL;
|
||||
|
||||
while (tmp) {
|
||||
bb_error_msg_and_die("need to fix this\n");
|
||||
if (tmp->entry->link_name) { /* Found a hardlink ready to be extracted */
|
||||
file_header = tmp->entry;
|
||||
if (oldtmp) {
|
||||
oldtmp->next = tmp->next; /* Remove item from linked list */
|
||||
} else {
|
||||
saved_hardlinks = tmp->next;
|
||||
}
|
||||
free(tmp);
|
||||
continue;
|
||||
}
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
pending_hardlinks = 0; /* No more pending hardlinks, read next file entry */
|
||||
}
|
||||
|
||||
/* There can be padding before archive header */
|
||||
data_align(archive_handle, 4);
|
||||
|
||||
if (archive_xread_all_eof(archive_handle, cpio_header, 110) == 0) {
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
archive_handle->offset += 110;
|
||||
|
||||
if ((strncmp(&cpio_header[0], "07070", 5) != 0) || ((cpio_header[5] != '1') && (cpio_header[5] != '2'))) {
|
||||
bb_error_msg_and_die("Unsupported cpio format, use newc or crc");
|
||||
}
|
||||
|
||||
{
|
||||
unsigned long tmpsize;
|
||||
sscanf(cpio_header, "%6c%8x%8x%8x%8x%8x%8lx%8lx%16c%8x%8x%8x%8c",
|
||||
dummy, &inode, (unsigned int*)&file_header->mode,
|
||||
(unsigned int*)&file_header->uid, (unsigned int*)&file_header->gid,
|
||||
&nlink, &file_header->mtime, &tmpsize,
|
||||
dummy, &major, &minor, &namesize, dummy);
|
||||
file_header->size = tmpsize;
|
||||
}
|
||||
|
||||
file_header->name = (char *) xmalloc(namesize + 1);
|
||||
archive_xread_all(archive_handle, file_header->name, namesize); /* Read in filename */
|
||||
file_header->name[namesize] = '\0';
|
||||
archive_handle->offset += namesize;
|
||||
|
||||
/* Update offset amount and skip padding before file contents */
|
||||
data_align(archive_handle, 4);
|
||||
|
||||
if (strcmp(file_header->name, "TRAILER!!!") == 0) {
|
||||
printf("%d blocks\n", (int) (archive_handle->offset % 512 ? (archive_handle->offset / 512) + 1 : archive_handle->offset / 512)); /* Always round up */
|
||||
if (saved_hardlinks) { /* Bummer - we still have unresolved hardlinks */
|
||||
hardlinks_t *tmp = saved_hardlinks;
|
||||
hardlinks_t *oldtmp = NULL;
|
||||
while (tmp) {
|
||||
bb_error_msg("%s not created: cannot resolve hardlink", tmp->entry->name);
|
||||
oldtmp = tmp;
|
||||
tmp = tmp->next;
|
||||
free (oldtmp->entry->name);
|
||||
free (oldtmp->entry);
|
||||
free (oldtmp);
|
||||
}
|
||||
saved_hardlinks = NULL;
|
||||
pending_hardlinks = 0;
|
||||
}
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (S_ISLNK(file_header->mode)) {
|
||||
file_header->link_name = (char *) xmalloc(file_header->size + 1);
|
||||
archive_xread_all(archive_handle, file_header->link_name, file_header->size);
|
||||
file_header->link_name[file_header->size] = '\0';
|
||||
archive_handle->offset += file_header->size;
|
||||
file_header->size = 0; /* Stop possible seeks in future */
|
||||
} else {
|
||||
file_header->link_name = NULL;
|
||||
}
|
||||
if (nlink > 1 && !S_ISDIR(file_header->mode)) {
|
||||
if (file_header->size == 0) { /* Put file on a linked list for later */
|
||||
hardlinks_t *new = xmalloc(sizeof(hardlinks_t));
|
||||
new->next = saved_hardlinks;
|
||||
new->inode = inode;
|
||||
new->entry = file_header;
|
||||
saved_hardlinks = new;
|
||||
return(EXIT_SUCCESS); // Skip this one
|
||||
} else { /* Found the file with data in */
|
||||
hardlinks_t *tmp = saved_hardlinks;
|
||||
pending_hardlinks = 1;
|
||||
while (tmp) {
|
||||
if (tmp->inode == inode) {
|
||||
tmp->entry->link_name = bb_xstrdup(file_header->name);
|
||||
nlink--;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
if (nlink > 1) {
|
||||
bb_error_msg("error resolving hardlink: did you create the archive with GNU cpio 2.0-2.2?");
|
||||
}
|
||||
}
|
||||
}
|
||||
file_header->device = makedev(major, minor);
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_data(archive_handle);
|
||||
archive_handle->action_header(archive_handle->file_header);
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
}
|
||||
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
free(file_header->link_name);
|
||||
|
||||
return (EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1,225 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* FIXME:
|
||||
* In privileged mode if uname and gname map to a uid and gid then use the
|
||||
* mapped value instead of the uid/gid values in tar header
|
||||
*
|
||||
* References:
|
||||
* GNU tar and star man pages,
|
||||
* Opengroup's ustar interchange format,
|
||||
* http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "unarchive.h"
|
||||
#include "libbb.h"
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
static char *longname = NULL;
|
||||
static char *linkname = NULL;
|
||||
#endif
|
||||
|
||||
extern char get_header_tar(archive_handle_t *archive_handle)
|
||||
{
|
||||
file_header_t *file_header = archive_handle->file_header;
|
||||
union {
|
||||
/* ustar header, Posix 1003.1 */
|
||||
unsigned char raw[512];
|
||||
struct {
|
||||
char name[100]; /* 0-99 */
|
||||
char mode[8]; /* 100-107 */
|
||||
char uid[8]; /* 108-115 */
|
||||
char gid[8]; /* 116-123 */
|
||||
char size[12]; /* 124-135 */
|
||||
char mtime[12]; /* 136-147 */
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char linkname[100]; /* 157-256 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char version[2]; /* 263-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char devmajor[8]; /* 329-336 */
|
||||
char devminor[8]; /* 337-344 */
|
||||
char prefix[155]; /* 345-499 */
|
||||
char padding[12]; /* 500-512 */
|
||||
} formated;
|
||||
} tar;
|
||||
long sum = 0;
|
||||
long i;
|
||||
static int end = 0;
|
||||
|
||||
/* Align header */
|
||||
data_align(archive_handle, 512);
|
||||
|
||||
if (bb_full_read(archive_handle->src_fd, tar.raw, 512) != 512) {
|
||||
/* Assume end of file */
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
archive_handle->offset += 512;
|
||||
|
||||
/* If there is no filename its an empty header */
|
||||
if (tar.formated.name[0] == 0) {
|
||||
if (end) {
|
||||
/* This is the second consecutive empty header! End of archive!
|
||||
* Read until the end to empty the pipe from gz or bz2
|
||||
*/
|
||||
while (bb_full_read(archive_handle->src_fd, tar.raw, 512) == 512);
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
end = 1;
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
end = 0;
|
||||
|
||||
/* Check header has valid magic, "ustar" is for the proper tar
|
||||
* 0's are for the old tar format
|
||||
*/
|
||||
if (strncmp(tar.formated.magic, "ustar", 5) != 0) {
|
||||
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
|
||||
if (strncmp(tar.formated.magic, "\0\0\0\0\0", 5) != 0)
|
||||
#endif
|
||||
bb_error_msg_and_die("Invalid tar magic");
|
||||
}
|
||||
/* Do checksum on headers */
|
||||
for (i = 0; i < 148 ; i++) {
|
||||
sum += tar.raw[i];
|
||||
}
|
||||
sum += ' ' * 8;
|
||||
for (i = 156; i < 512 ; i++) {
|
||||
sum += tar.raw[i];
|
||||
}
|
||||
if (sum != strtol(tar.formated.chksum, NULL, 8)) {
|
||||
bb_error_msg("Invalid tar header checksum");
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
if (longname) {
|
||||
file_header->name = longname;
|
||||
longname = NULL;
|
||||
}
|
||||
else if (linkname) {
|
||||
file_header->name = linkname;
|
||||
linkname = NULL;
|
||||
} else
|
||||
#endif
|
||||
if (tar.formated.prefix[0] == 0) {
|
||||
file_header->name = strdup(tar.formated.name);
|
||||
} else {
|
||||
file_header->name = concat_path_file(tar.formated.prefix, tar.formated.name);
|
||||
}
|
||||
|
||||
file_header->uid = strtol(tar.formated.uid, NULL, 8);
|
||||
file_header->gid = strtol(tar.formated.gid, NULL, 8);
|
||||
file_header->size = strtol(tar.formated.size, NULL, 8);
|
||||
file_header->mtime = strtol(tar.formated.mtime, NULL, 8);
|
||||
file_header->link_name = (tar.formated.linkname[0] != '\0') ?
|
||||
bb_xstrdup(tar.formated.linkname) : NULL;
|
||||
file_header->device = makedev(strtol(tar.formated.devmajor, NULL, 8),
|
||||
strtol(tar.formated.devminor, NULL, 8));
|
||||
|
||||
/* Set bits 0-11 of the files mode */
|
||||
file_header->mode = 07777 & strtol(tar.formated.mode, NULL, 8);
|
||||
|
||||
/* Set bits 12-15 of the files mode */
|
||||
switch (tar.formated.typeflag) {
|
||||
/* busybox identifies hard links as being regular files with 0 size and a link name */
|
||||
case '1':
|
||||
file_header->mode |= S_IFREG;
|
||||
break;
|
||||
case 'x':
|
||||
case 'g':
|
||||
bb_error_msg_and_die("pax is not tar");
|
||||
break;
|
||||
case '7':
|
||||
/* Reserved for high performance files, treat as normal file */
|
||||
case 0:
|
||||
case '0':
|
||||
#ifdef CONFIG_FEATURE_TAR_OLDGNU_COMPATABILITY
|
||||
if (last_char_is(file_header->name, '/')) {
|
||||
file_header->mode |= S_IFDIR;
|
||||
} else
|
||||
#endif
|
||||
file_header->mode |= S_IFREG;
|
||||
break;
|
||||
case '2':
|
||||
file_header->mode |= S_IFLNK;
|
||||
break;
|
||||
case '3':
|
||||
file_header->mode |= S_IFCHR;
|
||||
break;
|
||||
case '4':
|
||||
file_header->mode |= S_IFBLK;
|
||||
break;
|
||||
case '5':
|
||||
file_header->mode |= S_IFDIR;
|
||||
break;
|
||||
case '6':
|
||||
file_header->mode |= S_IFIFO;
|
||||
break;
|
||||
#ifdef CONFIG_FEATURE_TAR_GNU_EXTENSIONS
|
||||
case 'L': {
|
||||
longname = xmalloc(file_header->size + 1);
|
||||
archive_xread_all(archive_handle, longname, file_header->size);
|
||||
longname[file_header->size] = '\0';
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
return(get_header_tar(archive_handle));
|
||||
}
|
||||
case 'K': {
|
||||
linkname = xmalloc(file_header->size + 1);
|
||||
archive_xread_all(archive_handle, linkname, file_header->size);
|
||||
linkname[file_header->size] = '\0';
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
file_header->name = linkname;
|
||||
return(get_header_tar(archive_handle));
|
||||
}
|
||||
case 'D': /* GNU dump dir */
|
||||
case 'M': /* Continuation of multi volume archive*/
|
||||
case 'N': /* Old GNU for names > 100 characters */
|
||||
case 'S': /* Sparse file */
|
||||
case 'V': /* Volume header */
|
||||
bb_error_msg("Ignoring GNU extension type %c", tar.formated.typeflag);
|
||||
#endif
|
||||
default:
|
||||
bb_error_msg("Unknown typeflag: 0x%x", tar.formated.typeflag);
|
||||
}
|
||||
{ /* Strip trailing '/' in directories */
|
||||
/* Must be done after mode is set as '/' is used to check if its a directory */
|
||||
char *tmp = last_char_is(file_header->name, '/');
|
||||
if (tmp) {
|
||||
*tmp = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (archive_handle->filter(archive_handle) == EXIT_SUCCESS) {
|
||||
archive_handle->action_header(archive_handle->file_header);
|
||||
archive_handle->flags |= ARCHIVE_EXTRACT_QUIET;
|
||||
archive_handle->action_data(archive_handle);
|
||||
archive_handle->passed = llist_add_to(archive_handle->passed, file_header->name);
|
||||
} else {
|
||||
data_skip(archive_handle);
|
||||
}
|
||||
archive_handle->offset += file_header->size;
|
||||
|
||||
free(file_header->link_name);
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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 <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern char get_header_tar_bz2(archive_handle_t *archive_handle)
|
||||
{
|
||||
/* Cant lseek over pipe's */
|
||||
archive_handle->seek = seek_by_char;
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompressStream);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS);
|
||||
|
||||
/* Can only do one file at a time */
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* 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 "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern char get_header_tar_gz(archive_handle_t *archive_handle)
|
||||
{
|
||||
unsigned char magic[2];
|
||||
|
||||
/* Cant lseek over pipe's */
|
||||
archive_handle->seek = seek_by_char;
|
||||
|
||||
archive_xread_all(archive_handle, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("Invalid gzip magic");
|
||||
}
|
||||
|
||||
check_header_gzip(archive_handle->src_fd);
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS);
|
||||
|
||||
/* Can only do one file at a time */
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void header_list(const file_header_t *file_header)
|
||||
{
|
||||
puts(file_header->name);
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void header_skip(const file_header_t *file_header)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void header_verbose_list(const file_header_t *file_header)
|
||||
{
|
||||
struct tm *mtime = localtime(&file_header->mtime);
|
||||
|
||||
printf("%s %d/%d%10u %4u-%02u-%02u %02u:%02u:%02u %s",
|
||||
bb_mode_string(file_header->mode),
|
||||
file_header->uid,
|
||||
file_header->gid,
|
||||
(unsigned int) file_header->size,
|
||||
1900 + mtime->tm_year,
|
||||
1 + mtime->tm_mon,
|
||||
mtime->tm_mday,
|
||||
mtime->tm_hour,
|
||||
mtime->tm_min,
|
||||
mtime->tm_sec,
|
||||
file_header->name);
|
||||
|
||||
if (file_header->link_name) {
|
||||
printf(" -> %s", file_header->link_name);
|
||||
}
|
||||
/* putchar isnt used anywhere else i dont think */
|
||||
puts("");
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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 <unistd.h>
|
||||
#include <string.h>
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
archive_handle_t *init_handle(void)
|
||||
{
|
||||
archive_handle_t *archive_handle;
|
||||
|
||||
/* Initialise default values */
|
||||
archive_handle = xmalloc(sizeof(archive_handle_t));
|
||||
memset(archive_handle, 0, sizeof(archive_handle_t));
|
||||
archive_handle->file_header = xmalloc(sizeof(file_header_t));
|
||||
archive_handle->action_header = header_skip;
|
||||
archive_handle->action_data = data_skip;
|
||||
archive_handle->filter = filter_accept_all;
|
||||
archive_handle->seek = seek_by_jump;
|
||||
|
||||
return(archive_handle);
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* 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 <unistd.h>
|
||||
|
||||
#include "libbb.h"
|
||||
|
||||
/* transformer(), more than meets the eye */
|
||||
extern int open_transformer(int src_fd, int (*transformer)(int src_fd, int dst_fd))
|
||||
{
|
||||
int fd_pipe[2];
|
||||
int pid;
|
||||
|
||||
if (pipe(fd_pipe) != 0) {
|
||||
bb_perror_msg_and_die("Can't create pipe");
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
if (pid == -1) {
|
||||
bb_perror_msg_and_die("Fork failed");
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
/* child process */
|
||||
close(fd_pipe[0]); /* We don't wan't to read from the parent */
|
||||
transformer(src_fd, fd_pipe[1]);
|
||||
close(fd_pipe[1]); /* Send EOF */
|
||||
close(src_fd);
|
||||
exit(0);
|
||||
/* notreached */
|
||||
}
|
||||
|
||||
/* parent process */
|
||||
close(fd_pipe[1]); /* Don't want to write to the child */
|
||||
|
||||
return(fd_pipe[0]);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* 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 "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
/* If we are reading through a pipe(), or from stdin then we cant lseek,
|
||||
* we must read and discard the data to skip over it.
|
||||
*
|
||||
* TODO: rename to seek_by_read
|
||||
*/
|
||||
extern void seek_by_char(const archive_handle_t *archive_handle, const unsigned int jump_size)
|
||||
{
|
||||
if (jump_size) {
|
||||
bb_copyfd_size(archive_handle->src_fd, -1, jump_size);
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* 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 <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
extern void seek_by_jump(const archive_handle_t *archive_handle, const unsigned int amount)
|
||||
{
|
||||
if (lseek(archive_handle->src_fd, (off_t) amount, SEEK_CUR) == (off_t) -1) {
|
||||
#ifdef CONFIG_FEATURE_UNARCHIVE_TAPE
|
||||
if (errno == ESPIPE) {
|
||||
seek_by_char(archive_handle, amount);
|
||||
} else
|
||||
#endif
|
||||
bb_perror_msg_and_die("Seek failure");
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* 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 <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
extern void unpack_ar_archive(archive_handle_t *ar_archive)
|
||||
{
|
||||
char magic[7];
|
||||
|
||||
archive_xread_all(ar_archive, magic, 7);
|
||||
if (strncmp(magic, "!<arch>", 7) != 0) {
|
||||
bb_error_msg_and_die("Invalid ar magic");
|
||||
}
|
||||
ar_archive->offset += 7;
|
||||
|
||||
while (get_header_ar(ar_archive) == EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1,349 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini rpm applet for busybox
|
||||
*
|
||||
* Copyright (C) 2001,2002 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 <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <netinet/in.h> /* For ntohl & htonl function */
|
||||
#include <string.h> /* For strncmp */
|
||||
#include <sys/mman.h> /* For mmap */
|
||||
#include <time.h> /* For ctime */
|
||||
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
#define RPM_CHAR_TYPE 1
|
||||
#define RPM_INT8_TYPE 2
|
||||
#define RPM_INT16_TYPE 3
|
||||
#define RPM_INT32_TYPE 4
|
||||
/* #define RPM_INT64_TYPE 5 ---- These aren't supported (yet) */
|
||||
#define RPM_STRING_TYPE 6
|
||||
#define RPM_BIN_TYPE 7
|
||||
#define RPM_STRING_ARRAY_TYPE 8
|
||||
#define RPM_I18NSTRING_TYPE 9
|
||||
|
||||
#define RPMTAG_NAME 1000
|
||||
#define RPMTAG_VERSION 1001
|
||||
#define RPMTAG_RELEASE 1002
|
||||
#define RPMTAG_SUMMARY 1004
|
||||
#define RPMTAG_DESCRIPTION 1005
|
||||
#define RPMTAG_BUILDTIME 1006
|
||||
#define RPMTAG_BUILDHOST 1007
|
||||
#define RPMTAG_SIZE 1009
|
||||
#define RPMTAG_VENDOR 1011
|
||||
#define RPMTAG_LICENSE 1014
|
||||
#define RPMTAG_PACKAGER 1015
|
||||
#define RPMTAG_GROUP 1016
|
||||
#define RPMTAG_URL 1020
|
||||
#define RPMTAG_PREIN 1023
|
||||
#define RPMTAG_POSTIN 1024
|
||||
#define RPMTAG_FILEFLAGS 1037
|
||||
#define RPMTAG_FILEUSERNAME 1039
|
||||
#define RPMTAG_FILEGROUPNAME 1040
|
||||
#define RPMTAG_SOURCERPM 1044
|
||||
#define RPMTAG_PREINPROG 1085
|
||||
#define RPMTAG_POSTINPROG 1086
|
||||
#define RPMTAG_PREFIXS 1098
|
||||
#define RPMTAG_DIRINDEXES 1116
|
||||
#define RPMTAG_BASENAMES 1117
|
||||
#define RPMTAG_DIRNAMES 1118
|
||||
#define RPMFILE_CONFIG (1 << 0)
|
||||
#define RPMFILE_DOC (1 << 1)
|
||||
|
||||
enum rpm_functions_e {
|
||||
rpm_query = 1,
|
||||
rpm_install = 2,
|
||||
rpm_query_info = 4,
|
||||
rpm_query_package = 8,
|
||||
rpm_query_list = 16,
|
||||
rpm_query_list_doc = 32,
|
||||
rpm_query_list_config = 64
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
uint32_t tag; /* 4 byte tag */
|
||||
uint32_t type; /* 4 byte type */
|
||||
uint32_t offset; /* 4 byte offset */
|
||||
uint32_t count; /* 4 byte count */
|
||||
} rpm_index;
|
||||
|
||||
static void *map;
|
||||
static rpm_index **mytags;
|
||||
static int tagcount;
|
||||
|
||||
void extract_cpio_gz(int fd);
|
||||
rpm_index **rpm_gettags(int fd, int *num_tags);
|
||||
int bsearch_rpmtag(const void *key, const void *item);
|
||||
char *rpm_getstring(int tag, int itemindex);
|
||||
int rpm_getint(int tag, int itemindex);
|
||||
int rpm_getcount(int tag);
|
||||
void exec_script(int progtag, int datatag, char *prefix);
|
||||
void fileaction_dobackup(char *filename, int fileref);
|
||||
void fileaction_setowngrp(char *filename, int fileref);
|
||||
void fileaction_list(char *filename, int itemno);
|
||||
void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref));
|
||||
|
||||
int rpm_main(int argc, char **argv)
|
||||
{
|
||||
int opt = 0, func = 0, rpm_fd, offset;
|
||||
|
||||
while ((opt = getopt(argc, argv, "iqpldc")) != -1) {
|
||||
switch (opt) {
|
||||
case 'i': // First arg: Install mode, with q: Information
|
||||
if (!func) func |= rpm_install;
|
||||
else func |= rpm_query_info;
|
||||
break;
|
||||
case 'q': // First arg: Query mode
|
||||
if (!func) func |= rpm_query;
|
||||
else bb_show_usage();
|
||||
break;
|
||||
case 'p': // Query a package
|
||||
func |= rpm_query_package;
|
||||
break;
|
||||
case 'l': // List files in a package
|
||||
func |= rpm_query_list;
|
||||
break;
|
||||
case 'd': // List doc files in a package (implies list)
|
||||
func |= rpm_query_list;
|
||||
func |= rpm_query_list_doc;
|
||||
break;
|
||||
case 'c': // List config files in a package (implies list)
|
||||
func |= rpm_query_list;
|
||||
func |= rpm_query_list_config;
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (optind == argc) bb_show_usage();
|
||||
while (optind < argc) {
|
||||
rpm_fd = bb_xopen(argv[optind], O_RDONLY);
|
||||
mytags = rpm_gettags(rpm_fd, (int *) &tagcount);
|
||||
offset = lseek(rpm_fd, 0, SEEK_CUR);
|
||||
if (!mytags) { printf("Error reading rpm header\n"); exit(-1); }
|
||||
map = mmap(0, offset > getpagesize() ? (offset + offset % getpagesize()) : getpagesize(), PROT_READ, MAP_SHARED, rpm_fd, 0); // Mimimum is one page
|
||||
if (func & rpm_install) {
|
||||
loop_through_files(RPMTAG_BASENAMES, fileaction_dobackup); /* Backup any config files */
|
||||
extract_cpio_gz(rpm_fd); // Extact the archive
|
||||
loop_through_files(RPMTAG_BASENAMES, fileaction_setowngrp); /* Set the correct file uid/gid's */
|
||||
} else if (func & rpm_query && func & rpm_query_package) {
|
||||
if (!((func & rpm_query_info) || (func & rpm_query_list))) { // If just a straight query, just give package name
|
||||
printf("%s-%s-%s\n", rpm_getstring(RPMTAG_NAME, 0), rpm_getstring(RPMTAG_VERSION, 0), rpm_getstring(RPMTAG_RELEASE, 0));
|
||||
}
|
||||
if (func & rpm_query_info) {
|
||||
/* Do the nice printout */
|
||||
time_t bdate_time;
|
||||
struct tm *bdate;
|
||||
char bdatestring[50];
|
||||
printf("Name : %-29sRelocations: %s\n", rpm_getstring(RPMTAG_NAME, 0), rpm_getstring(RPMTAG_PREFIXS, 0) ? rpm_getstring(RPMTAG_PREFIXS, 0) : "(not relocateable)");
|
||||
printf("Version : %-34sVendor: %s\n", rpm_getstring(RPMTAG_VERSION, 0), rpm_getstring(RPMTAG_VENDOR, 0) ? rpm_getstring(RPMTAG_VENDOR, 0) : "(none)");
|
||||
bdate_time = rpm_getint(RPMTAG_BUILDTIME, 0);
|
||||
bdate = localtime((time_t *) &bdate_time);
|
||||
strftime(bdatestring, 50, "%a %d %b %Y %T %Z", bdate);
|
||||
printf("Release : %-30sBuild Date: %s\n", rpm_getstring(RPMTAG_RELEASE, 0), bdatestring);
|
||||
printf("Install date: %-30sBuild Host: %s\n", "(not installed)", rpm_getstring(RPMTAG_BUILDHOST, 0));
|
||||
printf("Group : %-30sSource RPM: %s\n", rpm_getstring(RPMTAG_GROUP, 0), rpm_getstring(RPMTAG_SOURCERPM, 0));
|
||||
printf("Size : %-33dLicense: %s\n", rpm_getint(RPMTAG_SIZE, 0), rpm_getstring(RPMTAG_LICENSE, 0));
|
||||
printf("URL : %s\n", rpm_getstring(RPMTAG_URL, 0));
|
||||
printf("Summary : %s\n", rpm_getstring(RPMTAG_SUMMARY, 0));
|
||||
printf("Description :\n%s\n", rpm_getstring(RPMTAG_DESCRIPTION, 0));
|
||||
}
|
||||
if (func & rpm_query_list) {
|
||||
int count, it, flags;
|
||||
count = rpm_getcount(RPMTAG_BASENAMES);
|
||||
for (it = 0; it < count; it++) {
|
||||
flags = rpm_getint(RPMTAG_FILEFLAGS, it);
|
||||
switch ((func & rpm_query_list_doc) + (func & rpm_query_list_config))
|
||||
{
|
||||
case rpm_query_list_doc: if (!(flags & RPMFILE_DOC)) continue; break;
|
||||
case rpm_query_list_config: if (!(flags & RPMFILE_CONFIG)) continue; break;
|
||||
case rpm_query_list_doc + rpm_query_list_config: if (!((flags & RPMFILE_CONFIG) || (flags & RPMFILE_DOC))) continue; break;
|
||||
}
|
||||
printf("%s%s\n", rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES, it)), rpm_getstring(RPMTAG_BASENAMES, it));
|
||||
}
|
||||
}
|
||||
}
|
||||
optind++;
|
||||
free (mytags);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void extract_cpio_gz(int fd) {
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned char magic[2];
|
||||
|
||||
/* Initialise */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->seek = seek_by_char;
|
||||
//archive_handle->action_header = header_list;
|
||||
archive_handle->action_data = data_extract_all;
|
||||
archive_handle->flags |= ARCHIVE_PRESERVE_DATE;
|
||||
archive_handle->flags |= ARCHIVE_CREATE_LEADING_DIRS;
|
||||
archive_handle->src_fd = fd;
|
||||
archive_handle->offset = 0;
|
||||
|
||||
bb_xread_all(archive_handle->src_fd, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("Invalid gzip magic");
|
||||
}
|
||||
check_header_gzip(archive_handle->src_fd);
|
||||
chdir("/"); // Install RPM's to root
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, inflate_gunzip);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_cpio(archive_handle) == EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
rpm_index **rpm_gettags(int fd, int *num_tags)
|
||||
{
|
||||
rpm_index **tags = calloc(200, sizeof(struct rpmtag *)); /* We should never need mode than 200, and realloc later */
|
||||
int pass, tagindex = 0;
|
||||
lseek(fd, 96, SEEK_CUR); /* Seek past the unused lead */
|
||||
|
||||
for (pass = 0; pass < 2; pass++) { /* 1st pass is the signature headers, 2nd is the main stuff */
|
||||
struct {
|
||||
char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */
|
||||
uint8_t version; /* 1 byte version number */
|
||||
uint32_t reserved; /* 4 bytes reserved */
|
||||
uint32_t entries; /* Number of entries in header (4 bytes) */
|
||||
uint32_t size; /* Size of store (4 bytes) */
|
||||
} header;
|
||||
rpm_index *tmpindex;
|
||||
int storepos;
|
||||
|
||||
read(fd, &header, sizeof(header));
|
||||
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) return NULL; /* Invalid magic */
|
||||
if (header.version != 1) return NULL; /* This program only supports v1 headers */
|
||||
header.size = ntohl(header.size);
|
||||
header.entries = ntohl(header.entries);
|
||||
storepos = lseek(fd,0,SEEK_CUR) + header.entries * 16;
|
||||
|
||||
while (header.entries--) {
|
||||
tmpindex = tags[tagindex++] = malloc(sizeof(rpm_index));
|
||||
read(fd, tmpindex, sizeof(rpm_index));
|
||||
tmpindex->tag = ntohl(tmpindex->tag); tmpindex->type = ntohl(tmpindex->type); tmpindex->count = ntohl(tmpindex->count);
|
||||
tmpindex->offset = storepos + ntohl(tmpindex->offset);
|
||||
if (pass==0) tmpindex->tag -= 743;
|
||||
}
|
||||
lseek(fd, header.size, SEEK_CUR); /* Seek past store */
|
||||
if (pass==0) lseek(fd, (8 - (lseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR); /* Skip padding to 8 byte boundary after reading signature headers */
|
||||
}
|
||||
tags = realloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */
|
||||
*num_tags = tagindex;
|
||||
return tags; /* All done, leave the file at the start of the gzipped cpio archive */
|
||||
}
|
||||
|
||||
int bsearch_rpmtag(const void *key, const void *item)
|
||||
{
|
||||
rpm_index **tmp = (rpm_index **) item;
|
||||
return ((int) key - tmp[0]->tag);
|
||||
}
|
||||
|
||||
int rpm_getcount(int tag)
|
||||
{
|
||||
rpm_index **found;
|
||||
found = bsearch((void *) tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found) return 0;
|
||||
else return found[0]->count;
|
||||
}
|
||||
|
||||
char *rpm_getstring(int tag, int itemindex)
|
||||
{
|
||||
rpm_index **found;
|
||||
found = bsearch((void *) tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found[0]->count) return NULL;
|
||||
if (found[0]->type == RPM_STRING_TYPE || found[0]->type == RPM_I18NSTRING_TYPE || found[0]->type == RPM_STRING_ARRAY_TYPE) {
|
||||
int n;
|
||||
char *tmpstr = (char *) (map + found[0]->offset);
|
||||
for (n=0; n < itemindex; n++) tmpstr = tmpstr + strlen(tmpstr) + 1;
|
||||
return tmpstr;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
int rpm_getint(int tag, int itemindex)
|
||||
{
|
||||
rpm_index **found;
|
||||
int n, *tmpint;
|
||||
found = bsearch((void *) tag, mytags, tagcount, sizeof(struct rpmtag *), bsearch_rpmtag);
|
||||
if (!found || itemindex >= found[0]->count) return -1;
|
||||
tmpint = (int *) (map + found[0]->offset);
|
||||
if (found[0]->type == RPM_INT32_TYPE) {
|
||||
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 4);
|
||||
return ntohl(*tmpint);
|
||||
} else if (found[0]->type == RPM_INT16_TYPE) {
|
||||
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 2);
|
||||
return ntohs(*tmpint);
|
||||
} else if (found[0]->type == RPM_INT8_TYPE) {
|
||||
for (n=0; n<itemindex; n++) tmpint = (int *) ((void *) tmpint + 1);
|
||||
return ntohs(*tmpint);
|
||||
} else return -1;
|
||||
}
|
||||
|
||||
void fileaction_dobackup(char *filename, int fileref)
|
||||
{
|
||||
struct stat oldfile;
|
||||
int stat_res;
|
||||
char *newname;
|
||||
if (rpm_getint(RPMTAG_FILEFLAGS, fileref) & RPMFILE_CONFIG) { /* Only need to backup config files */
|
||||
stat_res = lstat (filename, &oldfile);
|
||||
if (stat_res == 0 && S_ISREG(oldfile.st_mode)) { /* File already exists - really should check MD5's etc to see if different */
|
||||
newname = bb_xstrdup(filename);
|
||||
newname = strcat(newname, ".rpmorig");
|
||||
copy_file(filename, newname, FILEUTILS_RECUR | FILEUTILS_PRESERVE_STATUS);
|
||||
remove_file(filename, FILEUTILS_RECUR | FILEUTILS_FORCE);
|
||||
free(newname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fileaction_setowngrp(char *filename, int fileref)
|
||||
{
|
||||
int uid, gid;
|
||||
uid = my_getpwnam(rpm_getstring(RPMTAG_FILEUSERNAME, fileref));
|
||||
gid = my_getgrnam(rpm_getstring(RPMTAG_FILEGROUPNAME, fileref));
|
||||
chown (filename, uid, gid);
|
||||
}
|
||||
|
||||
void fileaction_list(char *filename, int fileref)
|
||||
{
|
||||
printf("%s\n", filename);
|
||||
}
|
||||
|
||||
void loop_through_files(int filetag, void (*fileaction)(char *filename, int fileref))
|
||||
{
|
||||
int count = 0;
|
||||
char *filename, *tmp_dirname, *tmp_basename;
|
||||
while (rpm_getstring(filetag, count)) {
|
||||
tmp_dirname = rpm_getstring(RPMTAG_DIRNAMES, rpm_getint(RPMTAG_DIRINDEXES, count)); /* 1st put on the directory */
|
||||
tmp_basename = rpm_getstring(RPMTAG_BASENAMES, count);
|
||||
filename = xmalloc(strlen(tmp_basename) + strlen(tmp_dirname) + 1);
|
||||
strcpy(filename, tmp_dirname); /* First the directory name */
|
||||
strcat(filename, tmp_basename); /* then the filename */
|
||||
fileaction(filename, count++);
|
||||
free(filename);
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/* 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 <sys/types.h>
|
||||
#include <netinet/in.h> /* For ntohl & htonl function */
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define RPM_MAGIC "\355\253\356\333"
|
||||
#define RPM_HEADER_MAGIC "\216\255\350"
|
||||
|
||||
struct rpm_lead {
|
||||
unsigned char magic[4];
|
||||
uint8_t major, minor;
|
||||
uint16_t type;
|
||||
uint16_t archnum;
|
||||
char name[66];
|
||||
uint16_t osnum;
|
||||
uint16_t signature_type;
|
||||
char reserved[16];
|
||||
};
|
||||
|
||||
struct rpm_header {
|
||||
char magic[3]; /* 3 byte magic: 0x8e 0xad 0xe8 */
|
||||
uint8_t version; /* 1 byte version number */
|
||||
uint32_t reserved; /* 4 bytes reserved */
|
||||
uint32_t entries; /* Number of entries in header (4 bytes) */
|
||||
uint32_t size; /* Size of store (4 bytes) */
|
||||
};
|
||||
|
||||
void skip_header(int rpm_fd)
|
||||
{
|
||||
struct rpm_header header;
|
||||
|
||||
bb_xread_all(rpm_fd, &header, sizeof(struct rpm_header));
|
||||
if (strncmp((char *) &header.magic, RPM_HEADER_MAGIC, 3) != 0) {
|
||||
bb_error_msg_and_die("Invalid RPM header magic"); /* Invalid magic */
|
||||
}
|
||||
if (header.version != 1) {
|
||||
bb_error_msg_and_die("Unsupported RPM header version"); /* This program only supports v1 headers */
|
||||
}
|
||||
header.entries = ntohl(header.entries);
|
||||
header.size = ntohl(header.size);
|
||||
lseek (rpm_fd, 16 * header.entries, SEEK_CUR); /* Seek past index entries */
|
||||
lseek (rpm_fd, header.size, SEEK_CUR); /* Seek past store */
|
||||
}
|
||||
|
||||
/* No getopt required */
|
||||
extern int rpm2cpio_main(int argc, char **argv)
|
||||
{
|
||||
struct rpm_lead lead;
|
||||
int rpm_fd;
|
||||
unsigned char magic[2];
|
||||
|
||||
if (argc == 1) {
|
||||
rpm_fd = STDIN_FILENO;
|
||||
} else {
|
||||
rpm_fd = bb_xopen(argv[1], O_RDONLY);
|
||||
}
|
||||
|
||||
bb_xread_all(rpm_fd, &lead, sizeof(struct rpm_lead));
|
||||
if (strncmp((char *) &lead.magic, RPM_MAGIC, 4) != 0) {
|
||||
bb_error_msg_and_die("Invalid RPM magic"); /* Just check the magic, the rest is irrelevant */
|
||||
}
|
||||
|
||||
/* Skip the signature header */
|
||||
skip_header(rpm_fd);
|
||||
lseek(rpm_fd, (8 - (lseek(rpm_fd, 0, SEEK_CUR) % 8)) % 8, SEEK_CUR);
|
||||
|
||||
/* Skip the main header */
|
||||
skip_header(rpm_fd);
|
||||
|
||||
bb_xread_all(rpm_fd, &magic, 2);
|
||||
if ((magic[0] != 0x1f) || (magic[1] != 0x8b)) {
|
||||
bb_error_msg_and_die("Invalid gzip magic");
|
||||
}
|
||||
|
||||
check_header_gzip(rpm_fd);
|
||||
if (inflate_gunzip(rpm_fd, STDOUT_FILENO) != 0) {
|
||||
bb_error_msg("Error inflating");
|
||||
}
|
||||
|
||||
close(rpm_fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,891 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini tar implementation for busybox
|
||||
*
|
||||
* Modified to use common extraction code used by ar, cpio, dpkg-deb, dpkg
|
||||
* Glenn McGrath <bug1@iinet.net.au>
|
||||
*
|
||||
* Note, that as of BusyBox-0.43, tar has been completely rewritten from the
|
||||
* ground up. It still has remnants of the old code lying about, but it is
|
||||
* very different now (i.e., cleaner, less global variables, etc.)
|
||||
*
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* Based in part in the tar implementation in sash
|
||||
* Copyright (c) 1999 by David I. Bell
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
* Permission to distribute sash derived code under the GPL has been granted.
|
||||
*
|
||||
* Based in part on the tar implementation from busybox-0.28
|
||||
* Copyright (C) 1995 Bruce Perens
|
||||
* This is free software under the GNU General Public License.
|
||||
*
|
||||
* 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 <search.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fnmatch.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysmacros.h> /* major() and minor() */
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_CREATE
|
||||
|
||||
/* Tar file constants */
|
||||
# define TAR_MAGIC "ustar" /* ustar and a null */
|
||||
# define TAR_VERSION " " /* Be compatable with GNU tar format */
|
||||
|
||||
static const int TAR_BLOCK_SIZE = 512;
|
||||
static const int TAR_MAGIC_LEN = 6;
|
||||
static const int TAR_VERSION_LEN = 2;
|
||||
|
||||
/* POSIX tar Header Block, from POSIX 1003.1-1990 */
|
||||
enum { NAME_SIZE = 100 }; /* because gcc won't let me use 'static const int' */
|
||||
struct TarHeader { /* byte offset */
|
||||
char name[NAME_SIZE]; /* 0-99 */
|
||||
char mode[8]; /* 100-107 */
|
||||
char uid[8]; /* 108-115 */
|
||||
char gid[8]; /* 116-123 */
|
||||
char size[12]; /* 124-135 */
|
||||
char mtime[12]; /* 136-147 */
|
||||
char chksum[8]; /* 148-155 */
|
||||
char typeflag; /* 156-156 */
|
||||
char linkname[NAME_SIZE]; /* 157-256 */
|
||||
char magic[6]; /* 257-262 */
|
||||
char version[2]; /* 263-264 */
|
||||
char uname[32]; /* 265-296 */
|
||||
char gname[32]; /* 297-328 */
|
||||
char devmajor[8]; /* 329-336 */
|
||||
char devminor[8]; /* 337-344 */
|
||||
char prefix[155]; /* 345-499 */
|
||||
char padding[12]; /* 500-512 (pad to exactly the TAR_BLOCK_SIZE) */
|
||||
};
|
||||
typedef struct TarHeader TarHeader;
|
||||
|
||||
/*
|
||||
** writeTarFile(), writeFileToTarball(), and writeTarHeader() are
|
||||
** the only functions that deal with the HardLinkInfo structure.
|
||||
** Even these functions use the xxxHardLinkInfo() functions.
|
||||
*/
|
||||
typedef struct HardLinkInfo HardLinkInfo;
|
||||
struct HardLinkInfo {
|
||||
HardLinkInfo *next; /* Next entry in list */
|
||||
dev_t dev; /* Device number */
|
||||
ino_t ino; /* Inode number */
|
||||
short linkCount; /* (Hard) Link Count */
|
||||
char name[1]; /* Start of filename (must be last) */
|
||||
};
|
||||
|
||||
/* Some info to be carried along when creating a new tarball */
|
||||
struct TarBallInfo {
|
||||
char *fileName; /* File name of the tarball */
|
||||
int tarFd; /* Open-for-write file descriptor
|
||||
for the tarball */
|
||||
struct stat statBuf; /* Stat info for the tarball, letting
|
||||
us know the inode and device that the
|
||||
tarball lives, so we can avoid trying
|
||||
to include the tarball into itself */
|
||||
int verboseFlag; /* Whether to print extra stuff or not */
|
||||
const llist_t *excludeList; /* List of files to not include */
|
||||
HardLinkInfo *hlInfoHead; /* Hard Link Tracking Information */
|
||||
HardLinkInfo *hlInfo; /* Hard Link Info for the current file */
|
||||
};
|
||||
typedef struct TarBallInfo TarBallInfo;
|
||||
|
||||
/* A nice enum with all the possible tar file content types */
|
||||
enum TarFileType {
|
||||
REGTYPE = '0', /* regular file */
|
||||
REGTYPE0 = '\0', /* regular file (ancient bug compat) */
|
||||
LNKTYPE = '1', /* hard link */
|
||||
SYMTYPE = '2', /* symbolic link */
|
||||
CHRTYPE = '3', /* character special */
|
||||
BLKTYPE = '4', /* block special */
|
||||
DIRTYPE = '5', /* directory */
|
||||
FIFOTYPE = '6', /* FIFO special */
|
||||
CONTTYPE = '7', /* reserved */
|
||||
GNULONGLINK = 'K', /* GNU long (>100 chars) link name */
|
||||
GNULONGNAME = 'L', /* GNU long (>100 chars) file name */
|
||||
};
|
||||
typedef enum TarFileType TarFileType;
|
||||
|
||||
/* Might be faster (and bigger) if the dev/ino were stored in numeric order;) */
|
||||
static inline void addHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr,
|
||||
struct stat *statbuf,
|
||||
const char *name)
|
||||
{
|
||||
/* Note: hlInfoHeadPtr can never be NULL! */
|
||||
HardLinkInfo *hlInfo;
|
||||
|
||||
hlInfo = (HardLinkInfo *) xmalloc(sizeof(HardLinkInfo) + strlen(name));
|
||||
hlInfo->next = *hlInfoHeadPtr;
|
||||
*hlInfoHeadPtr = hlInfo;
|
||||
hlInfo->dev = statbuf->st_dev;
|
||||
hlInfo->ino = statbuf->st_ino;
|
||||
hlInfo->linkCount = statbuf->st_nlink;
|
||||
strcpy(hlInfo->name, name);
|
||||
}
|
||||
|
||||
static void freeHardLinkInfo(HardLinkInfo ** hlInfoHeadPtr)
|
||||
{
|
||||
HardLinkInfo *hlInfo = NULL;
|
||||
HardLinkInfo *hlInfoNext = NULL;
|
||||
|
||||
if (hlInfoHeadPtr) {
|
||||
hlInfo = *hlInfoHeadPtr;
|
||||
while (hlInfo) {
|
||||
hlInfoNext = hlInfo->next;
|
||||
free(hlInfo);
|
||||
hlInfo = hlInfoNext;
|
||||
}
|
||||
*hlInfoHeadPtr = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Might be faster (and bigger) if the dev/ino were stored in numeric order;) */
|
||||
static inline HardLinkInfo *findHardLinkInfo(HardLinkInfo * hlInfo, struct stat *statbuf)
|
||||
{
|
||||
while (hlInfo) {
|
||||
if ((statbuf->st_ino == hlInfo->ino) && (statbuf->st_dev == hlInfo->dev))
|
||||
break;
|
||||
hlInfo = hlInfo->next;
|
||||
}
|
||||
return (hlInfo);
|
||||
}
|
||||
|
||||
/* Put an octal string into the specified buffer.
|
||||
* The number is zero and space padded and possibly null padded.
|
||||
* Returns TRUE if successful. */
|
||||
static int putOctal(char *cp, int len, long value)
|
||||
{
|
||||
int tempLength;
|
||||
char tempBuffer[32];
|
||||
char *tempString = tempBuffer;
|
||||
|
||||
/* Create a string of the specified length with an initial space,
|
||||
* leading zeroes and the octal number, and a trailing null. */
|
||||
sprintf(tempString, "%0*lo", len - 1, value);
|
||||
|
||||
/* If the string is too large, suppress the leading space. */
|
||||
tempLength = strlen(tempString) + 1;
|
||||
if (tempLength > len) {
|
||||
tempLength--;
|
||||
tempString++;
|
||||
}
|
||||
|
||||
/* If the string is still too large, suppress the trailing null. */
|
||||
if (tempLength > len)
|
||||
tempLength--;
|
||||
|
||||
/* If the string is still too large, fail. */
|
||||
if (tempLength > len)
|
||||
return FALSE;
|
||||
|
||||
/* Copy the string to the field. */
|
||||
memcpy(cp, tempString, len);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Write out a tar header for the specified file/directory/whatever */
|
||||
static inline int writeTarHeader(struct TarBallInfo *tbInfo,
|
||||
const char *header_name,
|
||||
const char *real_name, struct stat *statbuf)
|
||||
{
|
||||
long chksum = 0;
|
||||
struct TarHeader header;
|
||||
const unsigned char *cp = (const unsigned char *) &header;
|
||||
ssize_t size = sizeof(struct TarHeader);
|
||||
|
||||
memset(&header, 0, size);
|
||||
|
||||
strncpy(header.name, header_name, sizeof(header.name));
|
||||
|
||||
putOctal(header.mode, sizeof(header.mode), statbuf->st_mode);
|
||||
putOctal(header.uid, sizeof(header.uid), statbuf->st_uid);
|
||||
putOctal(header.gid, sizeof(header.gid), statbuf->st_gid);
|
||||
putOctal(header.size, sizeof(header.size), 0); /* Regular file size is handled later */
|
||||
putOctal(header.mtime, sizeof(header.mtime), statbuf->st_mtime);
|
||||
strncpy(header.magic, TAR_MAGIC TAR_VERSION,
|
||||
TAR_MAGIC_LEN + TAR_VERSION_LEN);
|
||||
|
||||
/* Enter the user and group names (default to root if it fails) */
|
||||
if (my_getpwuid(header.uname, statbuf->st_uid, sizeof(header.uname)) == NULL)
|
||||
strcpy(header.uname, "root");
|
||||
if (my_getgrgid(header.gname, statbuf->st_gid, sizeof(header.gname)) == NULL)
|
||||
strcpy(header.gname, "root");
|
||||
|
||||
if (tbInfo->hlInfo) {
|
||||
/* This is a hard link */
|
||||
header.typeflag = LNKTYPE;
|
||||
strncpy(header.linkname, tbInfo->hlInfo->name,
|
||||
sizeof(header.linkname));
|
||||
} else if (S_ISLNK(statbuf->st_mode)) {
|
||||
char *lpath = xreadlink(real_name);
|
||||
|
||||
if (!lpath) /* Already printed err msg inside xreadlink() */
|
||||
return (FALSE);
|
||||
header.typeflag = SYMTYPE;
|
||||
strncpy(header.linkname, lpath, sizeof(header.linkname));
|
||||
free(lpath);
|
||||
} else if (S_ISDIR(statbuf->st_mode)) {
|
||||
header.typeflag = DIRTYPE;
|
||||
strncat(header.name, "/", sizeof(header.name));
|
||||
} else if (S_ISCHR(statbuf->st_mode)) {
|
||||
header.typeflag = CHRTYPE;
|
||||
putOctal(header.devmajor, sizeof(header.devmajor),
|
||||
major(statbuf->st_rdev));
|
||||
putOctal(header.devminor, sizeof(header.devminor),
|
||||
minor(statbuf->st_rdev));
|
||||
} else if (S_ISBLK(statbuf->st_mode)) {
|
||||
header.typeflag = BLKTYPE;
|
||||
putOctal(header.devmajor, sizeof(header.devmajor),
|
||||
major(statbuf->st_rdev));
|
||||
putOctal(header.devminor, sizeof(header.devminor),
|
||||
minor(statbuf->st_rdev));
|
||||
} else if (S_ISFIFO(statbuf->st_mode)) {
|
||||
header.typeflag = FIFOTYPE;
|
||||
} else if (S_ISREG(statbuf->st_mode)) {
|
||||
header.typeflag = REGTYPE;
|
||||
putOctal(header.size, sizeof(header.size), statbuf->st_size);
|
||||
} else {
|
||||
bb_error_msg("%s: Unknown file type", real_name);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* Calculate and store the checksum (i.e., the sum of all of the bytes of
|
||||
* the header). The checksum field must be filled with blanks for the
|
||||
* calculation. The checksum field is formatted differently from the
|
||||
* other fields: it has [6] digits, a null, then a space -- rather than
|
||||
* digits, followed by a null like the other fields... */
|
||||
memset(header.chksum, ' ', sizeof(header.chksum));
|
||||
cp = (const unsigned char *) &header;
|
||||
while (size-- > 0)
|
||||
chksum += *cp++;
|
||||
putOctal(header.chksum, 7, chksum);
|
||||
|
||||
/* Now write the header out to disk */
|
||||
if ((size =
|
||||
bb_full_write(tbInfo->tarFd, (char *) &header,
|
||||
sizeof(struct TarHeader))) < 0) {
|
||||
bb_error_msg(bb_msg_io_error, real_name);
|
||||
return (FALSE);
|
||||
}
|
||||
/* Pad the header up to the tar block size */
|
||||
for (; size < TAR_BLOCK_SIZE; size++) {
|
||||
write(tbInfo->tarFd, "\0", 1);
|
||||
}
|
||||
/* Now do the verbose thing (or not) */
|
||||
|
||||
if (tbInfo->verboseFlag) {
|
||||
FILE *vbFd = stdout;
|
||||
|
||||
if (tbInfo->tarFd == STDOUT_FILENO) /* If the archive goes to stdout, verbose to stderr */
|
||||
vbFd = stderr;
|
||||
|
||||
fprintf(vbFd, "%s\n", header.name);
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
# ifdef CONFIG_FEATURE_TAR_FROM
|
||||
static inline int exclude_file(const llist_t *excluded_files, const char *file)
|
||||
{
|
||||
while (excluded_files) {
|
||||
if (excluded_files->data[0] == '/') {
|
||||
if (fnmatch(excluded_files->data, file,
|
||||
FNM_PATHNAME | FNM_LEADING_DIR) == 0)
|
||||
return 1;
|
||||
} else {
|
||||
const char *p;
|
||||
|
||||
for (p = file; p[0] != '\0'; p++) {
|
||||
if ((p == file || p[-1] == '/') && p[0] != '/' &&
|
||||
fnmatch(excluded_files->data, p,
|
||||
FNM_PATHNAME | FNM_LEADING_DIR) == 0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
excluded_files = excluded_files->link;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
|
||||
static int writeFileToTarball(const char *fileName, struct stat *statbuf,
|
||||
void *userData)
|
||||
{
|
||||
struct TarBallInfo *tbInfo = (struct TarBallInfo *) userData;
|
||||
const char *header_name;
|
||||
|
||||
/*
|
||||
** Check to see if we are dealing with a hard link.
|
||||
** If so -
|
||||
** Treat the first occurance of a given dev/inode as a file while
|
||||
** treating any additional occurances as hard links. This is done
|
||||
** by adding the file information to the HardLinkInfo linked list.
|
||||
*/
|
||||
tbInfo->hlInfo = NULL;
|
||||
if (statbuf->st_nlink > 1) {
|
||||
tbInfo->hlInfo = findHardLinkInfo(tbInfo->hlInfoHead, statbuf);
|
||||
if (tbInfo->hlInfo == NULL)
|
||||
addHardLinkInfo(&tbInfo->hlInfoHead, statbuf, fileName);
|
||||
}
|
||||
|
||||
/* It is against the rules to archive a socket */
|
||||
if (S_ISSOCK(statbuf->st_mode)) {
|
||||
bb_error_msg("%s: socket ignored", fileName);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
/* It is a bad idea to store the archive we are in the process of creating,
|
||||
* so check the device and inode to be sure that this particular file isn't
|
||||
* the new tarball */
|
||||
if (tbInfo->statBuf.st_dev == statbuf->st_dev &&
|
||||
tbInfo->statBuf.st_ino == statbuf->st_ino) {
|
||||
bb_error_msg("%s: file is the archive; skipping", fileName);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
header_name = fileName;
|
||||
while (header_name[0] == '/') {
|
||||
static int alreadyWarned = FALSE;
|
||||
|
||||
if (alreadyWarned == FALSE) {
|
||||
bb_error_msg("Removing leading '/' from member names");
|
||||
alreadyWarned = TRUE;
|
||||
}
|
||||
header_name++;
|
||||
}
|
||||
|
||||
if (strlen(fileName) >= NAME_SIZE) {
|
||||
bb_error_msg(bb_msg_name_longer_than_foo, NAME_SIZE);
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
if (header_name[0] == '\0')
|
||||
return TRUE;
|
||||
|
||||
# ifdef CONFIG_FEATURE_TAR_FROM
|
||||
if (exclude_file(tbInfo->excludeList, header_name)) {
|
||||
return SKIP;
|
||||
}
|
||||
# endif /* CONFIG_FEATURE_TAR_FROM */
|
||||
|
||||
if (writeTarHeader(tbInfo, header_name, fileName, statbuf) == FALSE) {
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* Now, if the file is a regular file, copy it out to the tarball */
|
||||
if ((tbInfo->hlInfo == NULL)
|
||||
&& (S_ISREG(statbuf->st_mode))) {
|
||||
int inputFileFd;
|
||||
ssize_t readSize = 0;
|
||||
|
||||
/* open the file we want to archive, and make sure all is well */
|
||||
if ((inputFileFd = open(fileName, O_RDONLY)) < 0) {
|
||||
bb_perror_msg("%s: Cannot open", fileName);
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
/* write the file to the archive */
|
||||
readSize = bb_copyfd_eof(inputFileFd, tbInfo->tarFd);
|
||||
|
||||
/* Pad the file up to the tar block size */
|
||||
for (; (readSize % TAR_BLOCK_SIZE) != 0; readSize++) {
|
||||
write(tbInfo->tarFd, "\0", 1);
|
||||
}
|
||||
close(inputFileFd);
|
||||
}
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static inline int writeTarFile(const int tar_fd, const int verboseFlag,
|
||||
const unsigned long dereferenceFlag, const llist_t *include,
|
||||
const llist_t *exclude, const int gzip)
|
||||
{
|
||||
#ifdef CONFIG_FEATURE_TAR_GZIP
|
||||
int gzipDataPipe[2] = { -1, -1 };
|
||||
int gzipStatusPipe[2] = { -1, -1 };
|
||||
pid_t gzipPid = 0;
|
||||
volatile int vfork_exec_errno = 0;
|
||||
#endif
|
||||
|
||||
int errorFlag = FALSE;
|
||||
ssize_t size;
|
||||
struct TarBallInfo tbInfo;
|
||||
|
||||
tbInfo.hlInfoHead = NULL;
|
||||
|
||||
fchmod(tar_fd, 0644);
|
||||
tbInfo.tarFd = tar_fd;
|
||||
tbInfo.verboseFlag = verboseFlag;
|
||||
|
||||
/* Store the stat info for the tarball's file, so
|
||||
* can avoid including the tarball into itself.... */
|
||||
if (fstat(tbInfo.tarFd, &tbInfo.statBuf) < 0)
|
||||
bb_perror_msg_and_die("Couldnt stat tar file");
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_GZIP
|
||||
if (gzip) {
|
||||
if (pipe(gzipDataPipe) < 0 || pipe(gzipStatusPipe) < 0) {
|
||||
bb_perror_msg_and_die("Failed to create gzip pipe");
|
||||
}
|
||||
|
||||
signal(SIGPIPE, SIG_IGN); /* we only want EPIPE on errors */
|
||||
|
||||
# if __GNUC__
|
||||
/* Avoid vfork clobbering */
|
||||
(void) &include;
|
||||
(void) &errorFlag;
|
||||
# endif
|
||||
|
||||
gzipPid = vfork();
|
||||
|
||||
if (gzipPid == 0) {
|
||||
dup2(gzipDataPipe[0], 0);
|
||||
close(gzipDataPipe[1]);
|
||||
|
||||
if (tbInfo.tarFd != 1)
|
||||
dup2(tbInfo.tarFd, 1);
|
||||
|
||||
close(gzipStatusPipe[0]);
|
||||
fcntl(gzipStatusPipe[1], F_SETFD, FD_CLOEXEC); /* close on exec shows sucess */
|
||||
|
||||
execl("/bin/gzip", "gzip", "-f", 0);
|
||||
vfork_exec_errno = errno;
|
||||
|
||||
close(gzipStatusPipe[1]);
|
||||
exit(-1);
|
||||
} else if (gzipPid > 0) {
|
||||
close(gzipDataPipe[0]);
|
||||
close(gzipStatusPipe[1]);
|
||||
|
||||
while (1) {
|
||||
char buf;
|
||||
|
||||
int n = bb_full_read(gzipStatusPipe[0], &buf, 1);
|
||||
|
||||
if (n == 0 && vfork_exec_errno != 0) {
|
||||
errno = vfork_exec_errno;
|
||||
bb_perror_msg_and_die("Could not exec gzip process");
|
||||
} else if ((n < 0) && (errno == EAGAIN || errno == EINTR))
|
||||
continue; /* try it again */
|
||||
break;
|
||||
}
|
||||
close(gzipStatusPipe[0]);
|
||||
|
||||
tbInfo.tarFd = gzipDataPipe[1];
|
||||
} else {
|
||||
bb_perror_msg_and_die("Failed to vfork gzip process");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
tbInfo.excludeList = exclude;
|
||||
|
||||
/* Read the directory/files and iterate over them one at a time */
|
||||
while (include) {
|
||||
if (!recursive_action(include->data, TRUE, dereferenceFlag, FALSE,
|
||||
writeFileToTarball, writeFileToTarball,
|
||||
(void *) &tbInfo)) {
|
||||
errorFlag = TRUE;
|
||||
}
|
||||
include = include->link;
|
||||
}
|
||||
/* Write two empty blocks to the end of the archive */
|
||||
for (size = 0; size < (2 * TAR_BLOCK_SIZE); size++) {
|
||||
write(tbInfo.tarFd, "\0", 1);
|
||||
}
|
||||
|
||||
/* To be pedantically correct, we would check if the tarball
|
||||
* is smaller than 20 tar blocks, and pad it if it was smaller,
|
||||
* but that isn't necessary for GNU tar interoperability, and
|
||||
* so is considered a waste of space */
|
||||
|
||||
/* Hang up the tools, close up shop, head home */
|
||||
close(tbInfo.tarFd);
|
||||
if (errorFlag)
|
||||
bb_error_msg("Error exit delayed from previous errors");
|
||||
|
||||
freeHardLinkInfo(&tbInfo.hlInfoHead);
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_GZIP
|
||||
if (gzip && gzipPid) {
|
||||
if (waitpid(gzipPid, NULL, 0) == -1)
|
||||
printf("Couldnt wait ?");
|
||||
}
|
||||
#endif
|
||||
|
||||
return !errorFlag;
|
||||
}
|
||||
#endif /* tar_create */
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_FROM
|
||||
static llist_t *append_file_list_to_list(llist_t *list)
|
||||
{
|
||||
FILE *src_stream;
|
||||
llist_t *cur = list;
|
||||
llist_t *tmp;
|
||||
char *line;
|
||||
llist_t *newlist = NULL;
|
||||
|
||||
while(cur) {
|
||||
src_stream = bb_xfopen(cur->data, "r");
|
||||
tmp = cur;
|
||||
cur = cur->link;
|
||||
free(tmp);
|
||||
while((line = bb_get_chomped_line_from_file(src_stream)) != NULL) {
|
||||
newlist = llist_add_to(newlist, line);
|
||||
}
|
||||
fclose(src_stream);
|
||||
}
|
||||
return newlist;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_COMPRESS
|
||||
static char get_header_tar_Z(archive_handle_t *archive_handle)
|
||||
{
|
||||
/* Cant lseek over pipe's */
|
||||
archive_handle->seek = seek_by_char;
|
||||
|
||||
/* do the decompression, and cleanup */
|
||||
if ((bb_xread_char(archive_handle->src_fd) != 0x1f) || (bb_xread_char(archive_handle->src_fd) != 0x9d)) {
|
||||
bb_error_msg_and_die("Invalid magic");
|
||||
}
|
||||
|
||||
archive_handle->src_fd = open_transformer(archive_handle->src_fd, uncompress);
|
||||
archive_handle->offset = 0;
|
||||
while (get_header_tar(archive_handle) == EXIT_SUCCESS);
|
||||
|
||||
/* Can only do one file at a time */
|
||||
return(EXIT_FAILURE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CTX_TEST (1 << 0)
|
||||
#define CTX_EXTRACT (1 << 1)
|
||||
#define TAR_OPT_BASEDIR (1 << 2)
|
||||
#define TAR_OPT_TARNAME (1 << 3)
|
||||
#define TAR_OPT_2STDOUT (1 << 4)
|
||||
#define TAR_OPT_P (1 << 5)
|
||||
#define TAR_OPT_VERBOSE (1 << 6)
|
||||
#define TAR_OPT_KEEP_OLD (1 << 7)
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_CREATE
|
||||
# define CTX_CREATE (1 << 8)
|
||||
# define TAR_OPT_DEREFERNCE (1 << 9)
|
||||
# define TAR_OPT_STR_CREATE "ch"
|
||||
# define TAR_OPT_FLAG_CREATE 2
|
||||
#else
|
||||
//# define CTX_CREATE 0
|
||||
# define TAR_OPT_STR_CREATE ""
|
||||
# define TAR_OPT_FLAG_CREATE 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_BZIP2
|
||||
# define TAR_OPT_BZIP2 (1 << (8 + TAR_OPT_FLAG_CREATE))
|
||||
# define TAR_OPT_STR_BZIP2 "j"
|
||||
# define TAR_OPT_FLAG_BZIP2 1
|
||||
#else
|
||||
# define TAR_OPT_STR_BZIP2 ""
|
||||
# define TAR_OPT_FLAG_BZIP2 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_FROM
|
||||
# define TAR_OPT_INCLUDE_FROM (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2))
|
||||
# define TAR_OPT_EXCLUDE_FROM (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2 + 1))
|
||||
# define TAR_OPT_STR_FROM "T:X:"
|
||||
# define TAR_OPT_FLAG_FROM 2
|
||||
#else
|
||||
# define TAR_OPT_STR_FROM ""
|
||||
# define TAR_OPT_FLAG_FROM 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_GZIP
|
||||
# define TAR_OPT_GZIP (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2 + TAR_OPT_FLAG_FROM))
|
||||
# define TAR_OPT_STR_GZIP "z"
|
||||
# define TAR_OPT_FLAG_GZIP 1
|
||||
#else
|
||||
# define TAR_OPT_STR_GZIP ""
|
||||
# define TAR_OPT_FLAG_GZIP 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_COMPRESS
|
||||
# define TAR_OPT_UNCOMPRESS (1 << (8 + TAR_OPT_FLAG_CREATE + TAR_OPT_FLAG_BZIP2 + TAR_OPT_FLAG_FROM + TAR_OPT_FLAG_GZIP))
|
||||
# define TAR_OPT_STR_COMPRESS "Z"
|
||||
#else
|
||||
# define TAR_OPT_STR_COMPRESS ""
|
||||
#endif
|
||||
|
||||
static const char tar_options[]="txC:f:Opvk" \
|
||||
TAR_OPT_STR_CREATE \
|
||||
TAR_OPT_STR_BZIP2 \
|
||||
TAR_OPT_STR_FROM \
|
||||
TAR_OPT_STR_GZIP \
|
||||
TAR_OPT_STR_COMPRESS;
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_LONG_OPTIONS
|
||||
static const struct option tar_long_options[] = {
|
||||
{ "list", 0, NULL, 't' },
|
||||
{ "extract", 0, NULL, 'x' },
|
||||
{ "directory", 1, NULL, 'C' },
|
||||
{ "file", 1, NULL, 'f' },
|
||||
{ "to-stdout", 0, NULL, 'O' },
|
||||
{ "same-permissions", 0, NULL, 'p' },
|
||||
{ "verbose", 0, NULL, 'v' },
|
||||
{ "keep-old", 0, NULL, 'k' },
|
||||
# ifdef CONFIG_FEATURE_TAR_CREATE
|
||||
{ "create", 0, NULL, 'c' },
|
||||
{ "dereference", 0, NULL, 'h' },
|
||||
# endif
|
||||
# ifdef CONFIG_FEATURE_TAR_BZIP2
|
||||
{ "bzip2", 0, NULL, 'j' },
|
||||
# endif
|
||||
# ifdef CONFIG_FEATURE_TAR_FROM
|
||||
{ "files-from", 1, NULL, 'T' },
|
||||
{ "exclude-from", 1, NULL, 'X' },
|
||||
# endif
|
||||
# ifdef CONFIG_FEATURE_TAR_GZIP
|
||||
{ "gzip", 0, NULL, 'z' },
|
||||
# endif
|
||||
# ifdef CONFIG_FEATURE_TAR_COMPRESS
|
||||
{ "compress", 0, NULL, 'Z' },
|
||||
# endif
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
int tar_main(int argc, char **argv)
|
||||
{
|
||||
char (*get_header_ptr)(archive_handle_t *) = get_header_tar;
|
||||
archive_handle_t *tar_handle;
|
||||
char *base_dir = NULL;
|
||||
const char *tar_filename = "-";
|
||||
unsigned long opt;
|
||||
unsigned long ctx_flag = 0;
|
||||
|
||||
if (argc < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
/* Prepend '-' to the first argument if required */
|
||||
if (argv[1][0] != '-') {
|
||||
char *tmp;
|
||||
|
||||
bb_xasprintf(&tmp, "-%s", argv[1]);
|
||||
argv[1] = tmp;
|
||||
}
|
||||
|
||||
/* Initialise default values */
|
||||
tar_handle = init_handle();
|
||||
tar_handle->flags = ARCHIVE_CREATE_LEADING_DIRS | ARCHIVE_PRESERVE_DATE | ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
|
||||
bb_opt_complementaly = "c~tx:t~cx:x~ct:X*:T*";
|
||||
#ifdef CONFIG_FEATURE_TAR_LONG_OPTIONS
|
||||
bb_applet_long_options = tar_long_options;
|
||||
#endif
|
||||
|
||||
opt = bb_getopt_ulflags(argc, argv, tar_options,
|
||||
&base_dir, /* Change to dir <optarg> */
|
||||
&tar_filename /* archive filename */
|
||||
#ifdef CONFIG_FEATURE_TAR_FROM
|
||||
, &(tar_handle->accept),
|
||||
&(tar_handle->reject)
|
||||
#endif
|
||||
);
|
||||
|
||||
/* Check one and only one context option was given */
|
||||
if(opt & BB_GETOPT_ERROR) {
|
||||
bb_show_usage();
|
||||
}
|
||||
#ifdef CONFIG_FEATURE_TAR_CREATE
|
||||
ctx_flag = opt & (CTX_CREATE | CTX_TEST | CTX_EXTRACT);
|
||||
#else
|
||||
ctx_flag = opt & (CTX_TEST | CTX_EXTRACT);
|
||||
#endif
|
||||
if (ctx_flag == 0) {
|
||||
bb_show_usage();
|
||||
}
|
||||
if(ctx_flag & CTX_TEST) {
|
||||
if ((tar_handle->action_header == header_list) ||
|
||||
(tar_handle->action_header == header_verbose_list)) {
|
||||
tar_handle->action_header = header_verbose_list;
|
||||
} else {
|
||||
tar_handle->action_header = header_list;
|
||||
}
|
||||
}
|
||||
if(ctx_flag & CTX_EXTRACT) {
|
||||
if (tar_handle->action_data != data_extract_to_stdout)
|
||||
tar_handle->action_data = data_extract_all;
|
||||
}
|
||||
if(opt & TAR_OPT_2STDOUT) {
|
||||
/* To stdout */
|
||||
tar_handle->action_data = data_extract_to_stdout;
|
||||
}
|
||||
if(opt & TAR_OPT_VERBOSE) {
|
||||
if ((tar_handle->action_header == header_list) ||
|
||||
(tar_handle->action_header == header_verbose_list))
|
||||
{
|
||||
tar_handle->action_header = header_verbose_list;
|
||||
} else {
|
||||
tar_handle->action_header = header_list;
|
||||
}
|
||||
}
|
||||
if (opt & TAR_OPT_KEEP_OLD) {
|
||||
tar_handle->flags &= ~ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_GZIP
|
||||
if(opt & TAR_OPT_GZIP) {
|
||||
get_header_ptr = get_header_tar_gz;
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_TAR_BZIP2
|
||||
if(opt & TAR_OPT_BZIP2) {
|
||||
get_header_ptr = get_header_tar_bz2;
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_TAR_COMPRESS
|
||||
if(opt & TAR_OPT_UNCOMPRESS) {
|
||||
get_header_ptr = get_header_tar_Z;
|
||||
}
|
||||
#endif
|
||||
#ifdef CONFIG_FEATURE_TAR_FROM
|
||||
if(opt & TAR_OPT_EXCLUDE_FROM) {
|
||||
tar_handle->reject = append_file_list_to_list(tar_handle->reject);
|
||||
}
|
||||
if(opt & TAR_OPT_INCLUDE_FROM) {
|
||||
tar_handle->accept = append_file_list_to_list(tar_handle->accept);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check if we are reading from stdin */
|
||||
if ((argv[optind]) && (*argv[optind] == '-')) {
|
||||
/* Default is to read from stdin, so just skip to next arg */
|
||||
optind++;
|
||||
}
|
||||
|
||||
/* Setup an array of filenames to work with */
|
||||
/* TODO: This is the same as in ar, separate function ? */
|
||||
while (optind < argc) {
|
||||
char *filename_ptr = last_char_is(argv[optind], '/');
|
||||
if (filename_ptr) {
|
||||
*filename_ptr = '\0';
|
||||
}
|
||||
tar_handle->accept = llist_add_to(tar_handle->accept, argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
|
||||
if ((tar_handle->accept) || (tar_handle->reject)) {
|
||||
tar_handle->filter = filter_accept_reject_list;
|
||||
}
|
||||
|
||||
/* Open the tar file */
|
||||
{
|
||||
FILE *tar_stream;
|
||||
int flags;
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_CREATE
|
||||
if (opt & CTX_CREATE) {
|
||||
/* Make sure there is at least one file to tar up. */
|
||||
if (tar_handle->accept == NULL) {
|
||||
bb_error_msg_and_die("Cowardly refusing to create an empty archive");
|
||||
}
|
||||
tar_stream = stdout;
|
||||
flags = O_WRONLY | O_CREAT | O_EXCL;
|
||||
unlink(tar_filename);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
tar_stream = stdin;
|
||||
flags = O_RDONLY;
|
||||
}
|
||||
|
||||
if ((tar_filename[0] == '-') && (tar_filename[1] == '\0')) {
|
||||
tar_handle->src_fd = fileno(tar_stream);
|
||||
tar_handle->seek = seek_by_char;
|
||||
} else {
|
||||
tar_handle->src_fd = bb_xopen(tar_filename, flags);
|
||||
}
|
||||
}
|
||||
|
||||
if ((base_dir) && (chdir(base_dir))) {
|
||||
bb_perror_msg_and_die("Couldnt chdir to %s", base_dir);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FEATURE_TAR_CREATE
|
||||
/* create an archive */
|
||||
if (opt & CTX_CREATE) {
|
||||
int verboseFlag = FALSE;
|
||||
int gzipFlag = FALSE;
|
||||
|
||||
# ifdef CONFIG_FEATURE_TAR_GZIP
|
||||
if (get_header_ptr == get_header_tar_gz) {
|
||||
gzipFlag = TRUE;
|
||||
}
|
||||
# endif /* CONFIG_FEATURE_TAR_GZIP */
|
||||
# ifdef CONFIG_FEATURE_TAR_BZIP2
|
||||
if (get_header_ptr == get_header_tar_bz2) {
|
||||
bb_error_msg_and_die("Creating bzip2 compressed archives is not currently supported.");
|
||||
}
|
||||
# endif /* CONFIG_FEATURE_TAR_BZIP2 */
|
||||
|
||||
if ((tar_handle->action_header == header_list) ||
|
||||
(tar_handle->action_header == header_verbose_list)) {
|
||||
verboseFlag = TRUE;
|
||||
}
|
||||
writeTarFile(tar_handle->src_fd, verboseFlag, opt & TAR_OPT_DEREFERNCE, tar_handle->accept,
|
||||
tar_handle->reject, gzipFlag);
|
||||
} else
|
||||
#endif /* CONFIG_FEATURE_TAR_CREATE */
|
||||
{
|
||||
while (get_header_ptr(tar_handle) == EXIT_SUCCESS);
|
||||
|
||||
/* Ckeck that every file that should have been extracted was */
|
||||
while (tar_handle->accept) {
|
||||
if (find_list_entry(tar_handle->reject, tar_handle->accept->data) == NULL) {
|
||||
if (find_list_entry(tar_handle->passed, tar_handle->accept->data) == NULL) {
|
||||
bb_error_msg_and_die("%s: Not found in archive\n", tar_handle->accept->data);
|
||||
}
|
||||
}
|
||||
tar_handle->accept = tar_handle->accept->link;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_FEATURE_CLEAN_UP
|
||||
if (tar_handle->src_fd != STDIN_FILENO) {
|
||||
close(tar_handle->src_fd);
|
||||
}
|
||||
#endif /* CONFIG_FEATURE_CLEAN_UP */
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Uncompress applet for busybox (c) 2002 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.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "libbb.h"
|
||||
#include "unarchive.h"
|
||||
|
||||
#define GUNZIP_TO_STDOUT 1
|
||||
#define GUNZIP_FORCE 2
|
||||
|
||||
extern int uncompress_main(int argc, char **argv)
|
||||
{
|
||||
int status = EXIT_SUCCESS;
|
||||
unsigned long flags;
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "cf");
|
||||
|
||||
while (optind < argc) {
|
||||
const char *compressed_file = argv[optind++];
|
||||
const char *delete_path = NULL;
|
||||
char *uncompressed_file = NULL;
|
||||
int src_fd;
|
||||
int dst_fd;
|
||||
|
||||
if (strcmp(compressed_file, "-") == 0) {
|
||||
src_fd = STDIN_FILENO;
|
||||
flags |= GUNZIP_TO_STDOUT;
|
||||
} else {
|
||||
src_fd = bb_xopen(compressed_file, O_RDONLY);
|
||||
}
|
||||
|
||||
/* Check that the input is sane. */
|
||||
if (isatty(src_fd) && ((flags & GUNZIP_FORCE) == 0)) {
|
||||
bb_error_msg_and_die
|
||||
("compressed data not read from terminal. Use -f to force it.");
|
||||
}
|
||||
|
||||
/* Set output filename and number */
|
||||
if (flags & GUNZIP_TO_STDOUT) {
|
||||
dst_fd = STDOUT_FILENO;
|
||||
} else {
|
||||
struct stat stat_buf;
|
||||
char *extension;
|
||||
|
||||
uncompressed_file = bb_xstrdup(compressed_file);
|
||||
|
||||
extension = strrchr(uncompressed_file, '.');
|
||||
if (!extension || (strcmp(extension, ".Z") != 0)) {
|
||||
bb_error_msg_and_die("Invalid extension");
|
||||
}
|
||||
*extension = '\0';
|
||||
|
||||
/* Open output file */
|
||||
dst_fd = bb_xopen(uncompressed_file, O_WRONLY | O_CREAT);
|
||||
|
||||
/* Set permissions on the file */
|
||||
stat(compressed_file, &stat_buf);
|
||||
chmod(uncompressed_file, stat_buf.st_mode);
|
||||
|
||||
/* If unzip succeeds remove the old file */
|
||||
delete_path = compressed_file;
|
||||
}
|
||||
|
||||
/* do the decompression, and cleanup */
|
||||
if ((bb_xread_char(src_fd) != 0x1f) || (bb_xread_char(src_fd) != 0x9d)) {
|
||||
bb_error_msg_and_die("Invalid magic");
|
||||
}
|
||||
|
||||
status = uncompress(src_fd, dst_fd);
|
||||
|
||||
if ((status != EXIT_SUCCESS) && (uncompressed_file)) {
|
||||
/* Unzip failed, remove the uncomressed file instead of compressed file */
|
||||
delete_path = uncompressed_file;
|
||||
}
|
||||
|
||||
if (dst_fd != STDOUT_FILENO) {
|
||||
close(dst_fd);
|
||||
}
|
||||
if (src_fd != STDIN_FILENO) {
|
||||
close(src_fd);
|
||||
}
|
||||
|
||||
/* delete_path will be NULL if in test mode or from stdin */
|
||||
if (delete_path && (unlink(delete_path) == -1)) {
|
||||
bb_error_msg_and_die("Couldn't remove %s", delete_path);
|
||||
}
|
||||
|
||||
free(uncompressed_file);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -1,247 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini unzip 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
|
||||
*
|
||||
*/
|
||||
|
||||
/* For reference see
|
||||
* http://www.pkware.com/products/enterprise/white_papers/appnote.txt
|
||||
* http://www.info-zip.org/pub/infozip/doc/appnote-iz-latest.zip
|
||||
*/
|
||||
|
||||
/* TODO Endian issues, exclude, should we accept input from stdin ? */
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "unarchive.h"
|
||||
#include "busybox.h"
|
||||
|
||||
#define ZIP_FILEHEADER_MAGIC 0x04034b50
|
||||
#define ZIP_CDS_MAGIC 0x02014b50
|
||||
#define ZIP_CDS_END_MAGIC 0x06054b50
|
||||
#define ZIP_DD_MAGIC 0x08074b50
|
||||
|
||||
extern unsigned int gunzip_crc;
|
||||
extern unsigned int gunzip_bytes_out;
|
||||
|
||||
static void header_list_unzip(const file_header_t *file_header)
|
||||
{
|
||||
printf(" inflating: %s\n", file_header->name);
|
||||
}
|
||||
|
||||
static void header_verbose_list_unzip(const file_header_t *file_header)
|
||||
{
|
||||
unsigned int dostime = (unsigned int) file_header->mtime;
|
||||
|
||||
/* can printf arguments cut of the decade component ? */
|
||||
unsigned short year = 1980 + ((dostime & 0xfe000000) >> 25);
|
||||
while (year >= 100) {
|
||||
year -= 100;
|
||||
}
|
||||
|
||||
printf("%9u %02u-%02u-%02u %02u:%02u %s\n",
|
||||
(unsigned int) file_header->size,
|
||||
(dostime & 0x01e00000) >> 21,
|
||||
(dostime & 0x001f0000) >> 16,
|
||||
year,
|
||||
(dostime & 0x0000f800) >> 11,
|
||||
(dostime & 0x000007e0) >> 5,
|
||||
file_header->name);
|
||||
}
|
||||
|
||||
extern int unzip_main(int argc, char **argv)
|
||||
{
|
||||
union {
|
||||
unsigned char raw[26];
|
||||
struct {
|
||||
unsigned short version; /* 0-1 */
|
||||
unsigned short flags; /* 2-3 */
|
||||
unsigned short method; /* 4-5 */
|
||||
unsigned short modtime; /* 6-7 */
|
||||
unsigned short moddate; /* 8-9 */
|
||||
unsigned int crc32 __attribute__ ((packed)); /* 10-13 */
|
||||
unsigned int cmpsize __attribute__ ((packed));; /* 14-17 */
|
||||
unsigned int ucmpsize __attribute__ ((packed));; /* 18-21 */
|
||||
unsigned short filename_len; /* 22-23 */
|
||||
unsigned short extra_len; /* 24-25 */
|
||||
} formated __attribute__ ((packed));
|
||||
} zip_header;
|
||||
|
||||
archive_handle_t *archive_handle;
|
||||
unsigned int total_size = 0;
|
||||
unsigned int total_entries = 0;
|
||||
char *base_dir = NULL;
|
||||
int opt = 0;
|
||||
|
||||
/* Initialise */
|
||||
archive_handle = init_handle();
|
||||
archive_handle->action_data = NULL;
|
||||
archive_handle->action_header = header_list_unzip;
|
||||
|
||||
while ((opt = getopt(argc, argv, "lnopqd:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'l': /* list */
|
||||
archive_handle->action_header = header_verbose_list_unzip;
|
||||
archive_handle->action_data = data_skip;
|
||||
break;
|
||||
case 'n': /* never overwright existing files */
|
||||
break;
|
||||
case 'o':
|
||||
archive_handle->flags = ARCHIVE_EXTRACT_UNCONDITIONAL;
|
||||
break;
|
||||
case 'p': /* extract files to stdout */
|
||||
archive_handle->action_data = data_extract_to_stdout;
|
||||
break;
|
||||
case 'q': /* Extract files quietly */
|
||||
archive_handle->action_header = header_skip;
|
||||
break;
|
||||
case 'd': /* Extract files to specified base directory*/
|
||||
base_dir = optarg;
|
||||
break;
|
||||
#if 0
|
||||
case 'x': /* Exclude the specified files */
|
||||
archive_handle->filter = filter_accept_reject_list;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
|
||||
if (argc == optind) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
printf("Archive: %s\n", argv[optind]);
|
||||
if (archive_handle->action_header == header_verbose_list_unzip) {
|
||||
printf(" Length Date Time Name\n");
|
||||
printf(" -------- ---- ---- ----\n");
|
||||
}
|
||||
|
||||
if (*argv[optind] == '-') {
|
||||
archive_handle->src_fd = STDIN_FILENO;
|
||||
archive_handle->seek = seek_by_char;
|
||||
} else {
|
||||
archive_handle->src_fd = bb_xopen(argv[optind++], O_RDONLY);
|
||||
}
|
||||
|
||||
if ((base_dir) && (chdir(base_dir))) {
|
||||
bb_perror_msg_and_die("Couldnt chdir");
|
||||
}
|
||||
|
||||
while (optind < argc) {
|
||||
archive_handle->filter = filter_accept_list;
|
||||
archive_handle->accept = llist_add_to(archive_handle->accept, argv[optind]);
|
||||
optind++;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
unsigned int magic;
|
||||
int dst_fd;
|
||||
|
||||
/* TODO Endian issues */
|
||||
archive_xread_all(archive_handle, &magic, 4);
|
||||
archive_handle->offset += 4;
|
||||
|
||||
if (magic == ZIP_CDS_MAGIC) {
|
||||
break;
|
||||
}
|
||||
else if (magic != ZIP_FILEHEADER_MAGIC) {
|
||||
bb_error_msg_and_die("Invlaide zip magic");
|
||||
}
|
||||
|
||||
/* Read the file header */
|
||||
archive_xread_all(archive_handle, zip_header.raw, 26);
|
||||
archive_handle->offset += 26;
|
||||
archive_handle->file_header->mode = S_IFREG | 0777;
|
||||
|
||||
if (zip_header.formated.method != 8) {
|
||||
bb_error_msg_and_die("Unsupported compression method %d\n", zip_header.formated.method);
|
||||
}
|
||||
|
||||
/* Read filename */
|
||||
archive_handle->file_header->name = xmalloc(zip_header.formated.filename_len + 1);
|
||||
archive_xread_all(archive_handle, archive_handle->file_header->name, zip_header.formated.filename_len);
|
||||
archive_handle->offset += zip_header.formated.filename_len;
|
||||
archive_handle->file_header->name[zip_header.formated.filename_len] = '\0';
|
||||
|
||||
/* Skip extra header bits */
|
||||
archive_handle->file_header->size = zip_header.formated.extra_len;
|
||||
data_skip(archive_handle);
|
||||
archive_handle->offset += zip_header.formated.extra_len;
|
||||
|
||||
/* Handle directories */
|
||||
archive_handle->file_header->mode = S_IFREG | 0777;
|
||||
if (last_char_is(archive_handle->file_header->name, '/')) {
|
||||
archive_handle->file_header->mode ^= S_IFREG;
|
||||
archive_handle->file_header->mode |= S_IFDIR;
|
||||
}
|
||||
|
||||
/* Data section */
|
||||
archive_handle->file_header->size = zip_header.formated.cmpsize;
|
||||
if (archive_handle->action_data) {
|
||||
archive_handle->action_data(archive_handle);
|
||||
} else {
|
||||
dst_fd = bb_xopen(archive_handle->file_header->name, O_WRONLY | O_CREAT);
|
||||
inflate_init(zip_header.formated.cmpsize);
|
||||
inflate_unzip(archive_handle->src_fd, dst_fd);
|
||||
close(dst_fd);
|
||||
chmod(archive_handle->file_header->name, archive_handle->file_header->mode);
|
||||
|
||||
/* Validate decompression - crc */
|
||||
if (zip_header.formated.crc32 != (gunzip_crc ^ 0xffffffffL)) {
|
||||
bb_error_msg("Invalid compressed data--crc error");
|
||||
}
|
||||
|
||||
/* Validate decompression - size */
|
||||
if (gunzip_bytes_out != zip_header.formated.ucmpsize) {
|
||||
bb_error_msg("Invalid compressed data--length error");
|
||||
}
|
||||
}
|
||||
|
||||
/* local file descriptor section */
|
||||
archive_handle->offset += zip_header.formated.cmpsize;
|
||||
/* This ISNT unix time */
|
||||
archive_handle->file_header->mtime = zip_header.formated.modtime | (zip_header.formated.moddate << 16);
|
||||
archive_handle->file_header->size = zip_header.formated.ucmpsize;
|
||||
total_size += archive_handle->file_header->size;
|
||||
total_entries++;
|
||||
|
||||
archive_handle->action_header(archive_handle->file_header);
|
||||
|
||||
/* Data descriptor section */
|
||||
if (zip_header.formated.flags & 4) {
|
||||
/* skip over duplicate crc, compressed size and uncompressed size */
|
||||
unsigned char data_description[12];
|
||||
archive_xread_all(archive_handle, data_description, 12);
|
||||
archive_handle->offset += 12;
|
||||
}
|
||||
}
|
||||
/* Central directory section */
|
||||
|
||||
if (archive_handle->action_header == header_verbose_list_unzip) {
|
||||
printf(" -------- -------\n");
|
||||
printf("%9d %d files\n", total_size, total_entries);
|
||||
}
|
||||
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see scripts/kbuild/config-language.txt.
|
||||
#
|
||||
|
||||
menu "Console Utilities"
|
||||
|
||||
config CONFIG_CHVT
|
||||
bool "chvt"
|
||||
default n
|
||||
help
|
||||
This program is used to change to another terminal.
|
||||
Example: chvt 4 (change to terminal /dev/tty4)
|
||||
|
||||
config CONFIG_CLEAR
|
||||
bool "clear"
|
||||
default n
|
||||
help
|
||||
This program clears the terminal screen.
|
||||
|
||||
config CONFIG_DEALLOCVT
|
||||
bool "deallocvt"
|
||||
default n
|
||||
help
|
||||
This program deallocates unused virtual consoles.
|
||||
|
||||
config CONFIG_DUMPKMAP
|
||||
bool "dumpkmap"
|
||||
default n
|
||||
help
|
||||
This program dumps the kernel's keyboard translation table to
|
||||
stdout, in binary format. You can then use loadkmap to load it.
|
||||
|
||||
config CONFIG_LOADFONT
|
||||
bool "loadfont"
|
||||
default n
|
||||
help
|
||||
This program loads a console font from standard input.
|
||||
|
||||
config CONFIG_LOADKMAP
|
||||
bool "loadkmap"
|
||||
default n
|
||||
help
|
||||
This program loads a keyboard translation table from
|
||||
standard input.
|
||||
|
||||
config CONFIG_OPENVT
|
||||
bool "openvt"
|
||||
default n
|
||||
help
|
||||
This program is used to start a command on an unused
|
||||
virtual terminal.
|
||||
|
||||
config CONFIG_RESET
|
||||
bool "reset"
|
||||
default n
|
||||
help
|
||||
This program is used to reset the terminal screen, if it
|
||||
gets messed up.
|
||||
|
||||
config CONFIG_SETKEYCODES
|
||||
bool "setkeycodes"
|
||||
default n
|
||||
help
|
||||
This program loads entries into the kernel's scancode-to-keycode
|
||||
map, allowing unusual keyboards to generate usable keycodes.
|
||||
|
||||
endmenu
|
||||
@@ -1,32 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
#
|
||||
|
||||
top_srcdir=..
|
||||
top_builddir=..
|
||||
srcdir=$(top_srcdir)/console/tools
|
||||
CONSOLETOOLS_DIR:=./
|
||||
include $(top_builddir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
#
|
||||
|
||||
CONSOLETOOLS_AR:=console-tools.a
|
||||
ifndef $(CONSOLETOOLS_DIR)
|
||||
CONSOLETOOLS_DIR:=$(top_builddir)/console-tools/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/console-tools
|
||||
|
||||
CONSOLETOOLS_DIR-y:=
|
||||
CONSOLETOOLS_DIR-$(CONFIG_CHVT) += chvt.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_CLEAR) += clear.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_DEALLOCVT) += deallocvt.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_DUMPKMAP) += dumpkmap.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_LOADFONT) += loadfont.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_LOADKMAP) += loadkmap.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_OPENVT) += openvt.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_RESET) += reset.o
|
||||
CONSOLETOOLS_DIR-$(CONFIG_SETKEYCODES) += setkeycodes.o
|
||||
|
||||
libraries-y+=$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR)
|
||||
|
||||
$(CONSOLETOOLS_DIR)$(CONSOLETOOLS_AR): $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS_DIR-y))
|
||||
$(AR) $(ARFLAGS) $@ $(patsubst %,$(CONSOLETOOLS_DIR)%, $(CONSOLETOOLS_DIR-y))
|
||||
|
||||
$(CONSOLETOOLS_DIR)%.o: $(srcdir)/%.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chvt implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
*/
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#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) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
fd = get_console_fd();
|
||||
num = bb_xgetlarg(argv[1], 10, 0, INT_MAX);
|
||||
if (ioctl(fd, VT_ACTIVATE, num)) {
|
||||
bb_perror_msg_and_die("VT_ACTIVATE");
|
||||
}
|
||||
if (ioctl(fd, VT_WAITACTIVE, num)) {
|
||||
bb_perror_msg_and_die("VT_WAITACTIVE");
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,56 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Disallocate virtual terminal(s)
|
||||
*
|
||||
* Copyright (C) 2003 by Tito Ragusa <farmatito@tiscali.it>
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
*/
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#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[])
|
||||
{
|
||||
/* num = 0 deallocate all unused consoles */
|
||||
int num = 0;
|
||||
|
||||
switch(argc)
|
||||
{
|
||||
case 2:
|
||||
if((num = bb_xgetlarg(argv[1], 10, 0, INT_MAX)) == 0)
|
||||
bb_error_msg_and_die("0: illegal VT number");
|
||||
/* Falltrough */
|
||||
case 1:
|
||||
break;
|
||||
default:
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if (ioctl( get_console_fd(), VT_DISALLOCATE, num )) {
|
||||
bb_perror_msg_and_die("VT_DISALLOCATE");
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* openvt.c - open a vt to run a command.
|
||||
*
|
||||
* busyboxed by Quy Tonthat <quy@signal3.com>
|
||||
* hacked by Tito <farmatito@tiscali.it>
|
||||
*
|
||||
* 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 <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
int openvt_main(int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
char vtname[sizeof VC_FORMAT + 2];
|
||||
|
||||
|
||||
if (argc < 3)
|
||||
bb_show_usage();
|
||||
|
||||
/* check for Illegal vt number: < 1 or > 12 */
|
||||
sprintf(vtname, VC_FORMAT,(int)bb_xgetlarg(argv[1], 10, 1, 12));
|
||||
|
||||
argv+=2;
|
||||
argc-=2;
|
||||
|
||||
if(fork() == 0) {
|
||||
/* leave current vt */
|
||||
|
||||
#ifdef ESIX_5_3_2_D
|
||||
if (setpgrp() < 0) {
|
||||
#else
|
||||
if (setsid() < 0) {
|
||||
#endif
|
||||
|
||||
bb_perror_msg_and_die("Unable to set new session");
|
||||
}
|
||||
close(0); /* so that new vt becomes stdin */
|
||||
|
||||
/* and grab new one */
|
||||
fd = bb_xopen(vtname, O_RDWR);
|
||||
|
||||
/* Reassign stdout and sterr */
|
||||
close(1);
|
||||
close(2);
|
||||
dup(fd);
|
||||
dup(fd);
|
||||
|
||||
execvp(argv[0], argv);
|
||||
_exit(1);
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,45 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini reset implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
* Written by Erik Andersen 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
|
||||
*
|
||||
*/
|
||||
|
||||
/* no options, no getopt */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int reset_main(int argc, char **argv)
|
||||
{
|
||||
if (isatty(0) || isatty(0) || isatty(0)) {
|
||||
/* See 'man 4 console_codes' for details:
|
||||
* "ESC c" -- Reset
|
||||
* "ESC ( K" -- Select user mapping
|
||||
* "ESC [ J" -- Erase display
|
||||
* "ESC [ 0 m" -- Reset all Graphics Rendition display attributes
|
||||
* "ESC [ ? 25 h" -- Make cursor visible.
|
||||
*/
|
||||
printf("\033c\033(K\033[J\033[0m\033[?25h");
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,613 +0,0 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see scripts/kbuild/config-language.txt.
|
||||
#
|
||||
|
||||
menu "Coreutils"
|
||||
|
||||
config CONFIG_BASENAME
|
||||
bool "basename"
|
||||
default n
|
||||
help
|
||||
basename is used to strip the directory and suffix from filenames,
|
||||
leaving just the filename itself. Enable this option if you wish
|
||||
to enable the 'basename' utility.
|
||||
|
||||
config CONFIG_CAL
|
||||
bool "cal"
|
||||
default n
|
||||
help
|
||||
cal is used to display a monthly calender.
|
||||
|
||||
config CONFIG_CAT
|
||||
bool "cat"
|
||||
default n
|
||||
help
|
||||
cat is used to concatenate files and print them to the standard
|
||||
output. Enable this option if you wish to enable the 'cat' utility.
|
||||
|
||||
config CONFIG_CHGRP
|
||||
bool "chgrp"
|
||||
default n
|
||||
help
|
||||
chgrp is used to change the group ownership of files.
|
||||
|
||||
config CONFIG_CHMOD
|
||||
bool "chmod"
|
||||
default n
|
||||
help
|
||||
chmod is used to change the access permission of files.
|
||||
|
||||
config CONFIG_CHOWN
|
||||
bool "chown"
|
||||
default n
|
||||
help
|
||||
chown is used to change the user and/or group ownership
|
||||
of files.
|
||||
|
||||
config CONFIG_CHROOT
|
||||
bool "chroot"
|
||||
default n
|
||||
help
|
||||
chroot is used to change the root directory and run a command.
|
||||
The default command is `/bin/sh'.
|
||||
|
||||
config CONFIG_CMP
|
||||
bool "cmp"
|
||||
default n
|
||||
help
|
||||
cmp is used to compare two files and returns the result
|
||||
to standard output.
|
||||
|
||||
config CONFIG_CP
|
||||
bool "cp"
|
||||
default n
|
||||
help
|
||||
cp is used to copy files and directories.
|
||||
|
||||
config CONFIG_CUT
|
||||
bool "cut"
|
||||
default n
|
||||
help
|
||||
cut is used to print selected parts of lines from
|
||||
each file to stdout.
|
||||
|
||||
if CONFIG_WATCH
|
||||
config CONFIG_DATE
|
||||
default y
|
||||
comment "date (forced enabled for use with watch)"
|
||||
endif
|
||||
|
||||
if !CONFIG_WATCH
|
||||
config CONFIG_DATE
|
||||
bool "date"
|
||||
default n
|
||||
help
|
||||
date is used to set the system date or display the
|
||||
current time in the given format.
|
||||
endif
|
||||
|
||||
config CONFIG_FEATURE_DATE_ISOFMT
|
||||
bool " Enable ISO date format output (-I)"
|
||||
default y
|
||||
depends on CONFIG_DATE
|
||||
help
|
||||
Enable option (-I) to output an ISO-8601 compliant
|
||||
date/time string.
|
||||
|
||||
config CONFIG_DD
|
||||
bool "dd"
|
||||
default n
|
||||
help
|
||||
dd copies a file (from standard input to standard output,
|
||||
by default) using specific input and output blocksizes,
|
||||
while optionally performing conversions on it.
|
||||
|
||||
config CONFIG_DF
|
||||
bool "df"
|
||||
default n
|
||||
help
|
||||
df reports the amount of disk space used and available
|
||||
on filesystems.
|
||||
|
||||
config CONFIG_DIRNAME
|
||||
bool "dirname"
|
||||
default n
|
||||
help
|
||||
dirname is used to strip a non-directory suffix from
|
||||
a file name.
|
||||
|
||||
config CONFIG_DOS2UNIX
|
||||
bool "dos2unix/unix2dos"
|
||||
default n
|
||||
help
|
||||
dos2unix is used to convert a text file from DOS format to
|
||||
UNIX format, and vice versa.
|
||||
|
||||
config CONFIG_UNIX2DOS
|
||||
bool
|
||||
default y
|
||||
depends on CONFIG_DOS2UNIX
|
||||
|
||||
config CONFIG_DU
|
||||
bool "du (default blocksize of 512 bytes)"
|
||||
default n
|
||||
help
|
||||
du is used to report the amount of disk space used
|
||||
for specified files.
|
||||
|
||||
config CONFIG_FEATURE_DU_DEFALT_BLOCKSIZE_1K
|
||||
bool " Use a default blocksize of 1024 bytes (1K)"
|
||||
default y
|
||||
depends on CONFIG_DU
|
||||
help
|
||||
Use a blocksize of (1K) instead of the default 512b.
|
||||
|
||||
config CONFIG_ECHO
|
||||
bool "echo (basic SUSv3 version taking no options)"
|
||||
default n
|
||||
help
|
||||
echo is used to print a specified string to stdout.
|
||||
|
||||
config CONFIG_FEATURE_FANCY_ECHO
|
||||
bool " Enable echo options (-n and -e)"
|
||||
default y
|
||||
depends on CONFIG_ECHO
|
||||
help
|
||||
This adds options (-n and -e) to echo.
|
||||
|
||||
config CONFIG_ENV
|
||||
bool "env"
|
||||
default n
|
||||
help
|
||||
env is used to set an environment variable and run
|
||||
a command; without options it displays the current
|
||||
environment.
|
||||
|
||||
config CONFIG_EXPR
|
||||
bool "expr"
|
||||
default n
|
||||
help
|
||||
expr is used to calculate numbers and print the result
|
||||
to standard output.
|
||||
|
||||
if CONFIG_HUSH || CONFIG_LASH || CONFIG_MSH
|
||||
config CONFIG_FALSE
|
||||
default y
|
||||
comment "false (forced enabled for use with shell)"
|
||||
endif
|
||||
|
||||
if !CONFIG_HUSH && !CONFIG_LASH && !CONFIG_MSH
|
||||
config CONFIG_FALSE
|
||||
bool "false"
|
||||
default n
|
||||
help
|
||||
false returns an exit code of FALSE (1).
|
||||
endif
|
||||
|
||||
config CONFIG_FOLD
|
||||
bool "fold"
|
||||
default n
|
||||
help
|
||||
Wrap text to fit a specific width.
|
||||
|
||||
config CONFIG_HEAD
|
||||
bool "head"
|
||||
default n
|
||||
help
|
||||
head is used to print the first specified number of lines
|
||||
from files.
|
||||
|
||||
config CONFIG_FEATURE_FANCY_HEAD
|
||||
bool " Enable head options (-c, -q, and -v)"
|
||||
default n
|
||||
depends on CONFIG_HEAD
|
||||
help
|
||||
This enables the head options (-c, -q, and -v).
|
||||
|
||||
config CONFIG_HOSTID
|
||||
bool "hostid"
|
||||
default n
|
||||
help
|
||||
hostid prints the numeric identifier (in hexadecimal) for
|
||||
the current host.
|
||||
|
||||
config CONFIG_ID
|
||||
bool "id"
|
||||
default n
|
||||
help
|
||||
id displays the current user and group ID names.
|
||||
|
||||
config CONFIG_INSTALL
|
||||
bool "install"
|
||||
default n
|
||||
help
|
||||
Copy files and set attributes.
|
||||
|
||||
config CONFIG_LENGTH
|
||||
bool "length"
|
||||
default n
|
||||
help
|
||||
length is used to print out the length of a specified string.
|
||||
|
||||
config CONFIG_LN
|
||||
bool "ln"
|
||||
default n
|
||||
help
|
||||
ln is used to create hard or soft links between files.
|
||||
|
||||
config CONFIG_LOGNAME
|
||||
bool "logname"
|
||||
default n
|
||||
help
|
||||
logname is used to print the current user's login name.
|
||||
|
||||
config CONFIG_LS
|
||||
bool "ls"
|
||||
default n
|
||||
help
|
||||
ls is used to list the contents of directories.
|
||||
|
||||
config CONFIG_FEATURE_LS_FILETYPES
|
||||
bool " Enable filetyping options (-p and -F)"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Enable the ls options (-p and -F).
|
||||
|
||||
config CONFIG_FEATURE_LS_FOLLOWLINKS
|
||||
bool " Enable symlinks dereferencing (-L)"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Enable the ls option (-L).
|
||||
|
||||
config CONFIG_FEATURE_LS_RECURSIVE
|
||||
bool " Enable recursion (-R)"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Enable the ls option (-R).
|
||||
|
||||
config CONFIG_FEATURE_LS_SORTFILES
|
||||
bool " Sort the file names"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Allow ls to sort file names alphabetically.
|
||||
|
||||
config CONFIG_FEATURE_LS_TIMESTAMPS
|
||||
bool " Show file timestamps"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Allow ls to display timestamps for files.
|
||||
|
||||
config CONFIG_FEATURE_LS_USERNAME
|
||||
bool " Show username/groupnames"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Allow ls to display username/groupname for files.
|
||||
|
||||
config CONFIG_FEATURE_LS_COLOR
|
||||
bool " Use color to identify file types"
|
||||
default y
|
||||
depends on CONFIG_LS
|
||||
help
|
||||
Allow ls to use color when displaying files.
|
||||
|
||||
config CONFIG_MD5SUM
|
||||
bool "md5sum"
|
||||
default n
|
||||
help
|
||||
md5sum is used to print or check MD5 checksums.
|
||||
|
||||
config CONFIG_MKDIR
|
||||
bool "mkdir"
|
||||
default n
|
||||
help
|
||||
mkdir is used to create directories with the specified names.
|
||||
|
||||
config CONFIG_MKFIFO
|
||||
bool "mkfifo"
|
||||
default n
|
||||
help
|
||||
mkfifo is used to create FIFOs (named pipes).
|
||||
The `mknod' program can also create FIFOs.
|
||||
|
||||
config CONFIG_MKNOD
|
||||
bool "mknod"
|
||||
default n
|
||||
help
|
||||
mknod is used to create FIFOs or block/character special
|
||||
files with the specified names.
|
||||
|
||||
config CONFIG_MV
|
||||
bool "mv"
|
||||
default n
|
||||
help
|
||||
mv is used to move or rename files or directories.
|
||||
|
||||
config CONFIG_OD
|
||||
bool "od"
|
||||
default n
|
||||
help
|
||||
od is used to dump binary files in octal and other formats.
|
||||
|
||||
config CONFIG_PRINTF
|
||||
bool "printf"
|
||||
default n
|
||||
help
|
||||
printf is used to format and print specified strings.
|
||||
It's similar to `echo' except it has more options.
|
||||
|
||||
config CONFIG_PWD
|
||||
bool "pwd"
|
||||
default n
|
||||
help
|
||||
pwd is used to print the current directory.
|
||||
|
||||
config CONFIG_REALPATH
|
||||
bool "realpath"
|
||||
default n
|
||||
help
|
||||
Return the canonicalized absolute pathname.
|
||||
This isn't provided by GNU shellutils, but where else does it belong.
|
||||
|
||||
config CONFIG_RM
|
||||
bool "rm"
|
||||
default n
|
||||
help
|
||||
rm is used to remove files or directories.
|
||||
|
||||
config CONFIG_RMDIR
|
||||
bool "rmdir"
|
||||
default n
|
||||
help
|
||||
rmdir is used to remove empty directories.
|
||||
|
||||
config CONFIG_SEQ
|
||||
bool "seq"
|
||||
default n
|
||||
help
|
||||
print a sequence of numbers
|
||||
|
||||
config CONFIG_SHA1SUM
|
||||
bool "sha1sum"
|
||||
default n
|
||||
help
|
||||
Compute and check SHA1 message digest
|
||||
|
||||
config CONFIG_SLEEP
|
||||
bool "sleep (single integer arg with no suffix)"
|
||||
default n
|
||||
help
|
||||
sleep is used to pause for a specified number of seconds,
|
||||
|
||||
config CONFIG_FEATURE_FANCY_SLEEP
|
||||
bool " Enable multiple integer args and optional time suffixes"
|
||||
default n
|
||||
depends on CONFIG_SLEEP
|
||||
help
|
||||
Allow sleep to pause for specified minutes, hours, and days.
|
||||
|
||||
config CONFIG_SORT
|
||||
bool "sort"
|
||||
default n
|
||||
help
|
||||
sort is used to sort lines of text in specified files.
|
||||
|
||||
config CONFIG_STTY
|
||||
bool "stty"
|
||||
default n
|
||||
help
|
||||
stty is used to change and print terminal line settings.
|
||||
|
||||
config CONFIG_SYNC
|
||||
bool "sync"
|
||||
default n
|
||||
help
|
||||
sync is used to flush filesystem buffers.
|
||||
|
||||
config CONFIG_TAIL
|
||||
bool "tail"
|
||||
default n
|
||||
help
|
||||
tail is used to print the last specified number of lines
|
||||
from files.
|
||||
|
||||
config CONFIG_FEATURE_FANCY_TAIL
|
||||
bool " Enable extra tail options (-q, -s, and -v)"
|
||||
default y
|
||||
depends on CONFIG_TAIL
|
||||
help
|
||||
The options (-q, -s, and -v) are provided by GNU tail, but
|
||||
are not specific in the SUSv3 standard.
|
||||
|
||||
config CONFIG_TEE
|
||||
bool "tee"
|
||||
default n
|
||||
help
|
||||
tee is used to read from standard input and write
|
||||
to standard output and files.
|
||||
|
||||
config CONFIG_FEATURE_TEE_USE_BLOCK_IO
|
||||
bool " Enable block i/o (larger/faster) instead of byte i/o."
|
||||
default n
|
||||
depends on CONFIG_TEE
|
||||
help
|
||||
Enable this option for a faster tee, at expense of size.
|
||||
|
||||
if CONFIG_ASH || CONFIG_HUSH || CONFIG_LASH || CONFIG_MSH
|
||||
config CONFIG_TEST
|
||||
default y
|
||||
comment "test (forced enabled for use with shell)"
|
||||
endif
|
||||
|
||||
if !CONFIG_ASH && !CONFIG_HUSH && !CONFIG_LASH && !CONFIG_MSH
|
||||
config CONFIG_TEST
|
||||
bool "test"
|
||||
default n
|
||||
help
|
||||
test is used to check file types and compare values,
|
||||
returning an appropriate exit code. The shells (ash
|
||||
and bash) have test builtin.
|
||||
endif
|
||||
|
||||
config CONFIG_FEATURE_TEST_64
|
||||
bool " Extend test to 64 bit"
|
||||
default n
|
||||
depends on CONFIG_TEST
|
||||
help
|
||||
Enable 64-bit support in test.
|
||||
|
||||
config CONFIG_TOUCH
|
||||
bool "touch"
|
||||
default n
|
||||
help
|
||||
touch is used to create or change the access and/or
|
||||
modification timestamp of specified files.
|
||||
|
||||
config CONFIG_TR
|
||||
bool "tr"
|
||||
default n
|
||||
help
|
||||
tr is used to squeeze, and/or delete characters from standard
|
||||
input, writing to standard output.
|
||||
|
||||
if CONFIG_HUSH || CONFIG_LASH || CONFIG_MSH
|
||||
config CONFIG_TRUE
|
||||
default y
|
||||
comment "true (forced enabled for use with shell)"
|
||||
endif
|
||||
|
||||
if !CONFIG_HUSH && !CONFIG_LASH && !CONFIG_MSH
|
||||
config CONFIG_TRUE
|
||||
bool "true"
|
||||
default n
|
||||
help
|
||||
true returns an exit code of TRUE (0).
|
||||
|
||||
endif
|
||||
|
||||
config CONFIG_TTY
|
||||
bool "tty"
|
||||
default n
|
||||
help
|
||||
tty is used to print the name of the current terminal to
|
||||
standard output.
|
||||
|
||||
config CONFIG_UNAME
|
||||
bool "uname"
|
||||
default n
|
||||
help
|
||||
uname is used to print system information.
|
||||
|
||||
config CONFIG_UNIQ
|
||||
bool "uniq"
|
||||
default n
|
||||
help
|
||||
uniq is used to remove duplicate lines from a sorted file.
|
||||
|
||||
config CONFIG_USLEEP
|
||||
bool "usleep"
|
||||
default n
|
||||
help
|
||||
usleep is used to pause for a specified number of microseconds.
|
||||
|
||||
config CONFIG_UUDECODE
|
||||
bool "uudecode"
|
||||
default n
|
||||
help
|
||||
uudecode is used to decode a uuencoded file.
|
||||
|
||||
config CONFIG_UUENCODE
|
||||
bool "uuencode"
|
||||
default n
|
||||
help
|
||||
uuencode is used to uuencode a file.
|
||||
|
||||
config CONFIG_WATCH
|
||||
bool "watch"
|
||||
default n
|
||||
help
|
||||
watch is used to execute a program periodically, showing
|
||||
output to the screen.
|
||||
|
||||
config CONFIG_WC
|
||||
bool "wc"
|
||||
default n
|
||||
help
|
||||
wc is used to print the number of bytes, words, and lines,
|
||||
in specified files.
|
||||
|
||||
config CONFIG_WHO
|
||||
bool "who"
|
||||
default n
|
||||
select CONFIG_FEATURE_UTMP
|
||||
help
|
||||
who is used to show who is logged on.
|
||||
|
||||
config CONFIG_WHOAMI
|
||||
bool "whoami"
|
||||
default n
|
||||
help
|
||||
whoami is used to print the username of the current
|
||||
user id (same as id -un).
|
||||
|
||||
config CONFIG_YES
|
||||
bool "yes"
|
||||
default n
|
||||
help
|
||||
yes is used to repeatedly output a specific string, or
|
||||
the default string `y'.
|
||||
|
||||
comment "Common options for cp and mv"
|
||||
depends on CONFIG_CP || CONFIG_MV
|
||||
|
||||
config CONFIG_FEATURE_PRESERVE_HARDLINKS
|
||||
bool " Preserve hard links"
|
||||
default n
|
||||
depends on CONFIG_CP || CONFIG_MV
|
||||
help
|
||||
Allow cp and mv to preserve hard links.
|
||||
|
||||
comment "Common options for ls and more"
|
||||
depends on CONFIG_LS || CONFIG_MORE
|
||||
|
||||
config CONFIG_FEATURE_AUTOWIDTH
|
||||
bool " Calculate terminal & column widths"
|
||||
default y
|
||||
depends on CONFIG_LS || CONFIG_MORE
|
||||
help
|
||||
This option allows utilities such as 'ls' and 'more' to determine the
|
||||
width of the screen, which can allow them to display additional text
|
||||
or avoid wrapping text onto the next line. If you leave this
|
||||
disabled, your utilities will be especially primitive and will be
|
||||
unable to determine the current screen width.
|
||||
|
||||
comment "Common options for df, du, ls"
|
||||
depends on CONFIG_DF || CONFIG_DU || CONFIG_LS
|
||||
|
||||
config CONFIG_FEATURE_HUMAN_READABLE
|
||||
bool " Support for human readable output (example 13k, 23M, 235G)"
|
||||
default n
|
||||
depends on CONFIG_DF || CONFIG_DU || CONFIG_LS
|
||||
help
|
||||
Allow df, du, and ls to have human readable output.
|
||||
|
||||
comment "Common options for md5sum, sha1sum"
|
||||
depends on CONFIG_MD5SUM || CONFIG_SHA1SUM
|
||||
|
||||
config CONFIG_FEATURE_MD5_SHA1_SUM_CHECK
|
||||
bool " Enable -c, -s and -w options"
|
||||
default n
|
||||
depends on CONFIG_MD5SUM || CONFIG_SHA1SUM
|
||||
help
|
||||
Enabling the -c options allows files to be checked
|
||||
against pre-calculated hash values.
|
||||
|
||||
-s and -w are useful options when verifying checksums.
|
||||
|
||||
endmenu
|
||||
@@ -1,32 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
#
|
||||
|
||||
top_srcdir=..
|
||||
top_builddir=..
|
||||
srcdir=$(top_srcdir)/coreutils
|
||||
SHELLUTILS_DIR:=./
|
||||
include $(top_builddir)/Rules.mak
|
||||
include $(top_builddir)/.config
|
||||
include $(srcdir)/Makefile.in
|
||||
all: $(libraries-y)
|
||||
-include $(top_builddir)/.depend
|
||||
|
||||
clean:
|
||||
rm -f *.o *.a $(AR_TARGET)
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
# Makefile for busybox
|
||||
#
|
||||
# Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
#
|
||||
|
||||
COREUTILS_AR:=coreutils.a
|
||||
ifndef $(COREUTILS_DIR)
|
||||
COREUTILS_DIR:=$(top_builddir)/coreutils/
|
||||
endif
|
||||
srcdir=$(top_srcdir)/coreutils
|
||||
|
||||
COREUTILS-y:=
|
||||
COREUTILS-$(CONFIG_BASENAME) += basename.o
|
||||
COREUTILS-$(CONFIG_CAL) += cal.o
|
||||
COREUTILS-$(CONFIG_CAT) += cat.o
|
||||
COREUTILS-$(CONFIG_CHGRP) += chgrp.o
|
||||
COREUTILS-$(CONFIG_CHMOD) += chmod.o
|
||||
COREUTILS-$(CONFIG_CHOWN) += chown.o
|
||||
COREUTILS-$(CONFIG_CHROOT) += chroot.o
|
||||
COREUTILS-$(CONFIG_CMP) += cmp.o
|
||||
COREUTILS-$(CONFIG_CP) += cp.o
|
||||
COREUTILS-$(CONFIG_CUT) += cut.o
|
||||
COREUTILS-$(CONFIG_DATE) += date.o
|
||||
COREUTILS-$(CONFIG_DD) += dd.o
|
||||
COREUTILS-$(CONFIG_DF) += df.o
|
||||
COREUTILS-$(CONFIG_DIRNAME) += dirname.o
|
||||
COREUTILS-$(CONFIG_DOS2UNIX) += dos2unix.o
|
||||
COREUTILS-$(CONFIG_DU) += du.o
|
||||
COREUTILS-$(CONFIG_ECHO) += echo.o
|
||||
COREUTILS-$(CONFIG_ENV) += env.o
|
||||
COREUTILS-$(CONFIG_EXPR) += expr.o
|
||||
COREUTILS-$(CONFIG_FALSE) += false.o
|
||||
COREUTILS-$(CONFIG_FOLD) += fold.o
|
||||
COREUTILS-$(CONFIG_HEAD) += head.o
|
||||
COREUTILS-$(CONFIG_HOSTID) += hostid.o
|
||||
COREUTILS-$(CONFIG_ID) += id.o
|
||||
COREUTILS-$(CONFIG_INSTALL) += install.o
|
||||
COREUTILS-$(CONFIG_LENGTH) += length.o
|
||||
COREUTILS-$(CONFIG_LN) += ln.o
|
||||
COREUTILS-$(CONFIG_LOGNAME) += logname.o
|
||||
COREUTILS-$(CONFIG_LS) += ls.o
|
||||
COREUTILS-$(CONFIG_MD5SUM) += md5_sha1_sum.o
|
||||
COREUTILS-$(CONFIG_MKDIR) += mkdir.o
|
||||
COREUTILS-$(CONFIG_MKFIFO) += mkfifo.o
|
||||
COREUTILS-$(CONFIG_MKNOD) += mknod.o
|
||||
COREUTILS-$(CONFIG_MV) += mv.o
|
||||
COREUTILS-$(CONFIG_OD) += od.o
|
||||
COREUTILS-$(CONFIG_PRINTF) += printf.o
|
||||
COREUTILS-$(CONFIG_PWD) += pwd.o
|
||||
COREUTILS-$(CONFIG_REALPATH) += realpath.o
|
||||
COREUTILS-$(CONFIG_RM) += rm.o
|
||||
COREUTILS-$(CONFIG_RMDIR) += rmdir.o
|
||||
COREUTILS-$(CONFIG_SEQ) += seq.o
|
||||
COREUTILS-$(CONFIG_SHA1SUM) += md5_sha1_sum.o
|
||||
COREUTILS-$(CONFIG_SLEEP) += sleep.o
|
||||
COREUTILS-$(CONFIG_SORT) += sort.o
|
||||
COREUTILS-$(CONFIG_STTY) += stty.o
|
||||
COREUTILS-$(CONFIG_SYNC) += sync.o
|
||||
COREUTILS-$(CONFIG_TAIL) += tail.o
|
||||
COREUTILS-$(CONFIG_TEE) += tee.o
|
||||
COREUTILS-$(CONFIG_TEST) += test.o
|
||||
COREUTILS-$(CONFIG_TOUCH) += touch.o
|
||||
COREUTILS-$(CONFIG_TR) += tr.o
|
||||
COREUTILS-$(CONFIG_TRUE) += true.o
|
||||
COREUTILS-$(CONFIG_TTY) += tty.o
|
||||
COREUTILS-$(CONFIG_UNAME) += uname.o
|
||||
COREUTILS-$(CONFIG_UNIQ) += uniq.o
|
||||
COREUTILS-$(CONFIG_USLEEP) += usleep.o
|
||||
COREUTILS-$(CONFIG_UUDECODE) += uudecode.o
|
||||
COREUTILS-$(CONFIG_UUENCODE) += uuencode.o
|
||||
COREUTILS-$(CONFIG_WATCH) += watch.o
|
||||
COREUTILS-$(CONFIG_WC) += wc.o
|
||||
COREUTILS-$(CONFIG_WHO) += who.o
|
||||
COREUTILS-$(CONFIG_WHOAMI) += whoami.o
|
||||
COREUTILS-$(CONFIG_YES) += yes.o
|
||||
|
||||
libraries-y+=$(COREUTILS_DIR)$(COREUTILS_AR)
|
||||
|
||||
$(COREUTILS_DIR)$(COREUTILS_AR): $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
|
||||
$(AR) $(ARFLAGS) $@ $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
|
||||
|
||||
$(COREUTILS_DIR)%.o: $(srcdir)/%.c
|
||||
$(CC) $(CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini basename implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/basename.html */
|
||||
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Changes:
|
||||
* 1) Now checks for too many args. Need at least one and at most two.
|
||||
* 2) Don't check for options, as per SUSv3.
|
||||
* 3) Save some space by using strcmp(). Calling strncmp() here was silly.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int basename_main(int argc, char **argv)
|
||||
{
|
||||
size_t m, n;
|
||||
char *s;
|
||||
|
||||
if (((unsigned int)(argc-2)) >= 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
s = bb_get_last_path_component(*++argv);
|
||||
|
||||
if (*++argv) {
|
||||
n = strlen(*argv);
|
||||
m = strlen(s);
|
||||
if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) {
|
||||
s[m-n] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
puts(s);
|
||||
|
||||
bb_fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||
}
|
||||
@@ -1,379 +0,0 @@
|
||||
/*
|
||||
* Calendar implementation for busybox
|
||||
*
|
||||
* See original copyright at the end of this 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
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant with -j and -y extensions (from util-linux). */
|
||||
/* BB_AUDIT BUG: The output of 'cal -j 1752' is incorrect. The upstream
|
||||
* BB_AUDIT BUG: version in util-linux seems to be broken as well. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cal.html */
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* Major size reduction... over 50% (>1.5k) on i386.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "busybox.h"
|
||||
|
||||
#ifdef CONFIG_LOCALE_SUPPORT
|
||||
#include <locale.h>
|
||||
#endif
|
||||
|
||||
#define THURSDAY 4 /* for reformation */
|
||||
#define SATURDAY 6 /* 1 Jan 1 was a Saturday */
|
||||
|
||||
#define FIRST_MISSING_DAY 639787 /* 3 Sep 1752 */
|
||||
#define NUMBER_MISSING_DAYS 11 /* 11 day correction */
|
||||
|
||||
#define MAXDAYS 42 /* max slots in a month array */
|
||||
#define SPACE -1 /* used in day array */
|
||||
|
||||
static const char days_in_month[] = {
|
||||
0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
|
||||
};
|
||||
|
||||
static const char sep1752[] = {
|
||||
1, 2, 14, 15, 16,
|
||||
17, 18, 19, 20, 21, 22, 23,
|
||||
24, 25, 26, 27, 28, 29, 30
|
||||
};
|
||||
|
||||
static int julian;
|
||||
|
||||
/* leap year -- account for Gregorian reformation in 1752 */
|
||||
#define leap_year(yr) \
|
||||
((yr) <= 1752 ? !((yr) % 4) : \
|
||||
(!((yr) % 4) && ((yr) % 100)) || !((yr) % 400))
|
||||
|
||||
static int is_leap_year(int year)
|
||||
{
|
||||
return leap_year(year);
|
||||
}
|
||||
#undef leap_year
|
||||
#define leap_year(yr) is_leap_year(yr)
|
||||
|
||||
/* number of centuries since 1700, not inclusive */
|
||||
#define centuries_since_1700(yr) \
|
||||
((yr) > 1700 ? (yr) / 100 - 17 : 0)
|
||||
|
||||
/* number of centuries since 1700 whose modulo of 400 is 0 */
|
||||
#define quad_centuries_since_1700(yr) \
|
||||
((yr) > 1600 ? ((yr) - 1600) / 400 : 0)
|
||||
|
||||
/* number of leap years between year 1 and this year, not inclusive */
|
||||
#define leap_years_since_year_1(yr) \
|
||||
((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
|
||||
|
||||
static void center __P((char *, int, int));
|
||||
static void day_array __P((int, int, int *));
|
||||
static void trim_trailing_spaces_and_print __P((char *));
|
||||
|
||||
static void blank_string(char *buf, size_t buflen);
|
||||
static char *build_row(char *p, int *dp);
|
||||
|
||||
#define DAY_LEN 3 /* 3 spaces per day */
|
||||
#define J_DAY_LEN (DAY_LEN + 1)
|
||||
#define WEEK_LEN 20 /* 7 * 3 - one space at the end */
|
||||
#define J_WEEK_LEN (WEEK_LEN + 7)
|
||||
#define HEAD_SEP 2 /* spaces between day headings */
|
||||
|
||||
int cal_main(int argc, char **argv)
|
||||
{
|
||||
struct tm *local_time;
|
||||
struct tm zero_tm;
|
||||
time_t now;
|
||||
int month, year, flags, i;
|
||||
char *month_names[12];
|
||||
char day_headings[28]; /* 28 for julian, 21 for nonjulian */
|
||||
char buf[40];
|
||||
|
||||
#ifdef CONFIG_LOCALE_SUPPORT
|
||||
setlocale(LC_TIME, "");
|
||||
#endif
|
||||
|
||||
flags = bb_getopt_ulflags(argc, argv, "jy");
|
||||
|
||||
julian = flags & 1;
|
||||
|
||||
argv += optind;
|
||||
|
||||
month = 0;
|
||||
|
||||
if ((argc -= optind) > 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
if (!argc) {
|
||||
time(&now);
|
||||
local_time = localtime(&now);
|
||||
year = local_time->tm_year + 1900;
|
||||
if (!(flags & 2)) {
|
||||
month = local_time->tm_mon + 1;
|
||||
}
|
||||
} else {
|
||||
if (argc == 2) {
|
||||
month = bb_xgetularg10_bnd(*argv++, 1, 12);
|
||||
}
|
||||
year = bb_xgetularg10_bnd(*argv, 1, 9999);
|
||||
}
|
||||
|
||||
blank_string(day_headings, sizeof(day_headings) - 7 + 7*julian);
|
||||
|
||||
i = 0;
|
||||
do {
|
||||
zero_tm.tm_mon = i;
|
||||
strftime(buf, sizeof(buf), "%B", &zero_tm);
|
||||
month_names[i] = bb_xstrdup(buf);
|
||||
|
||||
if (i < 7) {
|
||||
zero_tm.tm_wday = i;
|
||||
strftime(buf, sizeof(buf), "%a", &zero_tm);
|
||||
strncpy(day_headings + i * (3+julian) + julian, buf, 2);
|
||||
}
|
||||
} while (++i < 12);
|
||||
|
||||
if (month) {
|
||||
int row, len, days[MAXDAYS];
|
||||
int *dp = days;
|
||||
char lineout[30];
|
||||
|
||||
day_array(month, year, dp);
|
||||
len = sprintf(lineout, "%s %d", month_names[month - 1], year);
|
||||
bb_printf("%*s%s\n%s\n",
|
||||
((7*julian + WEEK_LEN) - len) / 2, "",
|
||||
lineout, day_headings);
|
||||
for (row = 0; row < 6; row++) {
|
||||
build_row(lineout, dp)[0] = '\0';
|
||||
dp += 7;
|
||||
trim_trailing_spaces_and_print(lineout);
|
||||
}
|
||||
} else {
|
||||
int row, which_cal, week_len, days[12][MAXDAYS];
|
||||
int *dp;
|
||||
char lineout[80];
|
||||
|
||||
sprintf(lineout, "%d", year);
|
||||
center(lineout,
|
||||
(WEEK_LEN * 3 + HEAD_SEP * 2)
|
||||
+ julian * (J_WEEK_LEN * 2 + HEAD_SEP
|
||||
- (WEEK_LEN * 3 + HEAD_SEP * 2)),
|
||||
0);
|
||||
puts("\n"); /* two \n's */
|
||||
for (i = 0; i < 12; i++) {
|
||||
day_array(i + 1, year, days[i]);
|
||||
}
|
||||
blank_string(lineout, sizeof(lineout));
|
||||
week_len = WEEK_LEN + julian * (J_WEEK_LEN - WEEK_LEN);
|
||||
for (month = 0; month < 12; month += 3-julian) {
|
||||
center(month_names[month], week_len, HEAD_SEP);
|
||||
if (!julian) {
|
||||
center(month_names[month + 1], week_len, HEAD_SEP);
|
||||
}
|
||||
center(month_names[month + 2 - julian], week_len, 0);
|
||||
bb_printf("\n%s%*s%s", day_headings, HEAD_SEP, "", day_headings);
|
||||
if (!julian) {
|
||||
bb_printf("%*s%s", HEAD_SEP, "", day_headings);
|
||||
}
|
||||
putchar('\n');
|
||||
for (row = 0; row < (6*7); row += 7) {
|
||||
for (which_cal = 0; which_cal < 3-julian; which_cal++) {
|
||||
dp = days[month + which_cal] + row;
|
||||
build_row(lineout + which_cal * (week_len + 2), dp);
|
||||
}
|
||||
/* blank_string took care of nul termination. */
|
||||
trim_trailing_spaces_and_print(lineout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bb_fflush_stdout_and_exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* day_array --
|
||||
* Fill in an array of 42 integers with a calendar. Assume for a moment
|
||||
* that you took the (maximum) 6 rows in a calendar and stretched them
|
||||
* out end to end. You would have 42 numbers or spaces. This routine
|
||||
* builds that array for any month from Jan. 1 through Dec. 9999.
|
||||
*/
|
||||
static void day_array(int month, int year, int *days)
|
||||
{
|
||||
long temp;
|
||||
int i;
|
||||
int j_offset;
|
||||
int day, dw, dm;
|
||||
|
||||
memset(days, SPACE, MAXDAYS * sizeof(int));
|
||||
|
||||
if ((month == 9) && (year == 1752)) {
|
||||
j_offset = julian * 244;
|
||||
i = 0;
|
||||
do {
|
||||
days[i+2] = sep1752[i] + j_offset;
|
||||
} while (++i < sizeof(sep1752));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* day_in_year
|
||||
* return the 1 based day number within the year
|
||||
*/
|
||||
day = 1;
|
||||
if ((month > 2) && leap_year(year)) {
|
||||
++day;
|
||||
}
|
||||
|
||||
i = month;
|
||||
while (i) {
|
||||
day += days_in_month[--i];
|
||||
}
|
||||
|
||||
/* day_in_week
|
||||
* return the 0 based day number for any date from 1 Jan. 1 to
|
||||
* 31 Dec. 9999. Assumes the Gregorian reformation eliminates
|
||||
* 3 Sep. 1752 through 13 Sep. 1752. Returns Thursday for all
|
||||
* missing days.
|
||||
*/
|
||||
dw = THURSDAY;
|
||||
temp = (long)(year - 1) * 365 + leap_years_since_year_1(year - 1)
|
||||
+ day;
|
||||
if (temp < FIRST_MISSING_DAY) {
|
||||
dw = ((temp - 1 + SATURDAY) % 7);
|
||||
} else if (temp >= (FIRST_MISSING_DAY + NUMBER_MISSING_DAYS)) {
|
||||
dw = (((temp - 1 + SATURDAY) - NUMBER_MISSING_DAYS) % 7);
|
||||
}
|
||||
|
||||
if (!julian) {
|
||||
day = 1;
|
||||
}
|
||||
|
||||
dm = days_in_month[month];
|
||||
if ((month == 2) && leap_year(year)) {
|
||||
++dm;
|
||||
}
|
||||
|
||||
while (dm) {
|
||||
days[dw++] = day++;
|
||||
--dm;
|
||||
}
|
||||
}
|
||||
|
||||
static void trim_trailing_spaces_and_print(char *s)
|
||||
{
|
||||
char *p = s;
|
||||
|
||||
while (*p) {
|
||||
++p;
|
||||
}
|
||||
while (p > s) {
|
||||
--p;
|
||||
if (!(isspace)(*p)) { /* We want the function... not the inline. */
|
||||
p[1] = '\0';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
puts(s);
|
||||
}
|
||||
|
||||
static void center(char *str, int len, int separate)
|
||||
{
|
||||
int n = strlen(str);
|
||||
len -= n;
|
||||
bb_printf("%*s%*s", (len/2) + n, str, (len/2) + (len % 2) + separate, "");
|
||||
}
|
||||
|
||||
static void blank_string(char *buf, size_t buflen)
|
||||
{
|
||||
memset(buf, ' ', buflen);
|
||||
buf[buflen-1] = '\0';
|
||||
}
|
||||
|
||||
static char *build_row(char *p, int *dp)
|
||||
{
|
||||
int col, val, day;
|
||||
|
||||
memset(p, ' ', (julian + DAY_LEN) * 7);
|
||||
|
||||
col = 0;
|
||||
do {
|
||||
if ((day = *dp++) != SPACE) {
|
||||
if (julian) {
|
||||
++p;
|
||||
if (day >= 100) {
|
||||
*p = '0';
|
||||
p[-1] = (day / 100) + '0';
|
||||
day %= 100;
|
||||
}
|
||||
}
|
||||
if ((val = day / 10) > 0) {
|
||||
*p = val + '0';
|
||||
}
|
||||
*++p = day % 10 + '0';
|
||||
p += 2;
|
||||
} else {
|
||||
p += DAY_LEN + julian;
|
||||
}
|
||||
} while (++col < 7);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Kim Letkeman.
|
||||
*
|
||||
* 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. 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.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* cat implementation for busybox
|
||||
*
|
||||
* Copyright (C) 2003 Manuel Novoa III <mjn3@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
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/cat.html */
|
||||
|
||||
/* Mar 16, 2003 Manuel Novoa III (mjn3@codepoet.org)
|
||||
*
|
||||
* This is a new implementation of 'cat' which aims to be SUSv3 compliant.
|
||||
*
|
||||
* Changes from the previous implementation include:
|
||||
* 1) Multiple '-' args are accepted as required by SUSv3. The previous
|
||||
* implementation would close stdin and segfault on a subsequent '-'.
|
||||
* 2) The '-u' options is required by SUSv3. Note that the specified
|
||||
* behavior for '-u' is done by default, so all we need do is accept
|
||||
* the option.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
extern int cat_main(int argc, char **argv)
|
||||
{
|
||||
FILE *f;
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
bb_getopt_ulflags(argc, argv, "u");
|
||||
|
||||
argv += optind;
|
||||
if (!*argv) {
|
||||
*--argv = "-";
|
||||
}
|
||||
|
||||
do {
|
||||
if ((f = bb_wfopen_input(*argv)) != NULL) {
|
||||
int r = bb_copyfd_eof(fileno(f), STDOUT_FILENO);
|
||||
bb_fclose_nonstdin(f);
|
||||
if (r >= 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
retval = EXIT_FAILURE;
|
||||
} while (*++argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chgrp implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@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
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 defects - unsupported options -h, -H, -L, and -P. */
|
||||
/* BB_AUDIT GNU defects - unsupported options -h, -c, -f, -v, and long options. */
|
||||
/* BB_AUDIT Note: gnu chgrp does not support -H, -L, or -P. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chgrp.html */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "busybox.h"
|
||||
|
||||
/* Don't use lchown glibc older then 2.1.x */
|
||||
#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
|
||||
#define lchown chown
|
||||
#endif
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (lchown(fileName, statbuf->st_uid, *((long *) junk)) == 0) {
|
||||
return (TRUE);
|
||||
}
|
||||
bb_perror_msg("%s", fileName); /* Avoid multibyte problems. */
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chgrp_main(int argc, char **argv)
|
||||
{
|
||||
long gid;
|
||||
int recursiveFlag;
|
||||
int retval = EXIT_SUCCESS;
|
||||
|
||||
recursiveFlag = bb_getopt_ulflags(argc, argv, "R");
|
||||
|
||||
if (argc - optind < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
argv += optind;
|
||||
|
||||
/* Find the selected group */
|
||||
gid = get_ug_id(*argv, my_getgrnam);
|
||||
++argv;
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
do {
|
||||
if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, &gid)) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
} while (*++argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
@@ -1,112 +0,0 @@
|
||||
/* vi: set sw=4 ts=4: */
|
||||
/*
|
||||
* Mini chmod implementation for busybox
|
||||
*
|
||||
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
||||
*
|
||||
* Reworked by (C) 2002 Vladimir Oleynik <dzo@simtreas.ru>
|
||||
* to correctly parse '-rwxgoa'
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
/* BB_AUDIT SUSv3 compliant */
|
||||
/* BB_AUDIT GNU defects - unsupported options -c, -f, -v, and long options. */
|
||||
/* http://www.opengroup.org/onlinepubs/007904975/utilities/chmod.html */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include "busybox.h"
|
||||
|
||||
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
|
||||
{
|
||||
if (!bb_parse_mode((char *)junk, &(statbuf->st_mode)))
|
||||
bb_error_msg_and_die( "invalid mode: %s", (char *)junk);
|
||||
if (chmod(fileName, statbuf->st_mode) == 0)
|
||||
return (TRUE);
|
||||
bb_perror_msg("%s", fileName); /* Avoid multibyte problems. */
|
||||
return (FALSE);
|
||||
}
|
||||
|
||||
int chmod_main(int argc, char **argv)
|
||||
{
|
||||
int retval = EXIT_SUCCESS;
|
||||
int recursiveFlag = FALSE;
|
||||
int count;
|
||||
char *smode;
|
||||
char **p;
|
||||
char *p0;
|
||||
char opt = '-';
|
||||
|
||||
++argv;
|
||||
count = 0;
|
||||
|
||||
for (p = argv ; *p ; p++) {
|
||||
p0 = p[0];
|
||||
if (p0[0] == opt) {
|
||||
if ((p0[1] == '-') && !p0[2]) {
|
||||
opt = 0; /* Disable further option processing. */
|
||||
continue;
|
||||
}
|
||||
if (p0[1] == 'R') {
|
||||
char *s = p0 + 2;
|
||||
while (*s == 'R') {
|
||||
++s;
|
||||
}
|
||||
if (*s) {
|
||||
bb_show_usage();
|
||||
}
|
||||
recursiveFlag = TRUE;
|
||||
continue;
|
||||
}
|
||||
if (count) {
|
||||
bb_show_usage();
|
||||
}
|
||||
}
|
||||
argv[count] = p0;
|
||||
++count;
|
||||
}
|
||||
|
||||
argv[count] = NULL;
|
||||
|
||||
if (count < 2) {
|
||||
bb_show_usage();
|
||||
}
|
||||
|
||||
smode = *argv;
|
||||
++argv;
|
||||
|
||||
/* Ok, ready to do the deed now */
|
||||
do {
|
||||
if (! recursive_action (*argv, recursiveFlag, FALSE, FALSE,
|
||||
fileAction, fileAction, smode)) {
|
||||
retval = EXIT_FAILURE;
|
||||
}
|
||||
} while (*++argv);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-file-style: "linux"
|
||||
c-basic-offset: 4
|
||||
tab-width: 4
|
||||
End:
|
||||
*/
|
||||
Loaded 100 of 977 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user